Redoc: Hide the "Download OpenAPI specification" button.

Created on 16 Dec 2017  路  14Comments  路  Source: Redocly/redoc

Is there an easy way to hide this button/functionality? We don't want to expose this option to our users.

enhancement

Most helpful comment

New option will be added in the upcoming [email protected] - hide-download-button

Usage:

<redoc spec-url="..." hide-download-button> </redoc>

Important: THIS DOESN'T MAKE YOUR SPEC PRIVATE! As @adamaltman mentioned, the spec still downloads to the browser so the user is still capable of saving it.

All 14 comments

Would be ideal if this could be specified as a tag attribute.
<redoc spec-url='swagger.yaml' no-download-openapi lazy-rendering>

Would you be able to apply some custom CSS to hide it?

As someone who has consumed many third-party APIs I do appreciate being able to easily download specs so my code can use it too, though :)

There aren't enough classes to really write a "good" css selector but this seems to work, at least in the new 2.0 alpha version, I don't have the prior version handy to see if the markup is the same.

  .api-content .api-info > p {
    display: none !important;
  }

The .api-content part of that selector really isn't necessary, but I wanted it to be very specific.


Anyway, I agree, there really needs to be a config option to disable rendering of the button entirely. For my current usage, we have a private API that we control access to the docs via user login, since our api changes over time and is private, we don't want anyone downloading it.

@willvincent @bartfeenstra thanks for answering.

I will definitely add a config option to hide this button.

It seems that even if the button is hidden, the spec still downloads to the browser, if that's what the page uses to render the docs. So, the user is still capable of saving it, if that's what they are after doing.

I guess just hiding the button would be fine for most people.

New option will be added in the upcoming [email protected] - hide-download-button

Usage:

<redoc spec-url="..." hide-download-button> </redoc>

Important: THIS DOESN'T MAKE YOUR SPEC PRIVATE! As @adamaltman mentioned, the spec still downloads to the browser so the user is still capable of saving it.

Released in 1.21.0

This doesn't seem to work when using the React component.

render() {
  return (
    <div>
      <RedocStandalone specUrl="/Specs/home.yaml" hide-download-button />
    </div>
  );

Figured it out:

<RedocStandalone specUrl="/Specs/home.yaml" options={{ "hideDownloadButton": true }} />

if you are using the cli you can use --options='{"hideDownloadButton": true}'

Can anyone confirm where this option should be added/defined?

I added it here in the redoc.html file within /templates

<script src="/script/redoc.standalone.js"> </script>
  </body>
  <script language="JavaScript">
    Redoc.init(
      '/{{documentationId}}/apispec',
      {
        nativeScrollbars: true,
        noAutoAuth: true,
        requiredPropsFirst: true,
        hideHostname: true,
        hideSchemaTitles: true,
        menuToggle: true,
        pathInMiddlePanel: false
        hideDownloadButton: true 
      },
      document.getElementById('redoc-container'));
  </script>

And the redoc pages no longer rendered!

@sionlane I think you're missing a comma after pathInMiddlePanel: false,.

great, thanks

Was this page helpful?
0 / 5 - 0 ratings

Related issues

typekpb picture typekpb  路  4Comments

martnst picture martnst  路  3Comments

shreyas-agnihotri picture shreyas-agnihotri  路  3Comments

skllcrn picture skllcrn  路  3Comments

JonKohler picture JonKohler  路  3Comments