Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hide the "Download OpenAPI specification" button. #394

Closed
shreyas-agnihotri opened this issue Dec 16, 2017 · 18 comments
Closed

Hide the "Download OpenAPI specification" button. #394

shreyas-agnihotri opened this issue Dec 16, 2017 · 18 comments

Comments

@shreyas-agnihotri
Copy link

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

@shreyas-agnihotri
Copy link
Author

shreyas-agnihotri commented Dec 16, 2017

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

@bartfeenstra
Copy link

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 :)

@willvincent
Copy link

willvincent commented Dec 20, 2017

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.

@RomanHotsiy
Copy link
Member

@willvincent @bartfeenstra thanks for answering.

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

@adamaltman
Copy link
Member

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.

@shreyas-agnihotri
Copy link
Author

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

@RomanHotsiy
Copy link
Member

New option will be added in the upcoming redoc@1.21.0 - 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.

@RomanHotsiy
Copy link
Member

Released in 1.21.0

@MikeChristensen
Copy link

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

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

@MikeChristensen
Copy link

Figured it out:

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

@levpachmanov
Copy link
Contributor

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

@sionlane
Copy link

sionlane commented Dec 3, 2020

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!

@adamaltman
Copy link
Member

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

@sionlane
Copy link

sionlane commented Dec 3, 2020

great, thanks

@Taoshan98
Copy link

is it possible to hide the "Download" button from the .yaml file?

@Brian-Webster
Copy link

If you need your spec to be private, you can use redoc to render the spec offline, save the resulting output, and then host only that output.

@hadpro24
Copy link

New option will be added in the upcoming redoc@1.21.0 - 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.

Thank you

@vfa-tanna
Copy link

vfa-tanna commented Mar 3, 2024

hideDownloadButton: true not working with me?
docs: https://redocly.com/blog/hide-download-button/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests