Redocly / redoc

📘 OpenAPI/Swagger-generated API Reference Documentation
https://redocly.github.io/redoc/
MIT License
23.7k stars 2.31k forks source link

Hide the "Download OpenAPI specification" button. #394

Closed shreyas-agnihotri closed 6 years ago

shreyas-agnihotri commented 6 years ago

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

shreyas-agnihotri commented 6 years ago

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

bartfeenstra commented 6 years ago

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 commented 6 years ago

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 commented 6 years ago

@willvincent @bartfeenstra thanks for answering.

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

adamaltman commented 6 years ago

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 commented 6 years ago

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

RomanHotsiy commented 6 years ago

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 commented 6 years ago

Released in 1.21.0

MikeChristensen commented 5 years ago

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

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

Figured it out:

<RedocStandalone specUrl="/Specs/home.yaml" options={{ "hideDownloadButton": true }} />
levpachmanov commented 4 years ago

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

sionlane commented 4 years ago

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 commented 4 years ago

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

sionlane commented 4 years ago

great, thanks

Taoshan98 commented 3 years ago

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

Brian-Webster commented 3 years ago

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 commented 2 years ago

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 commented 9 months ago

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

thibleroy commented 3 months ago

@vfa-tanna use theme.openapi.hideDownloadButton parameter example :

redocly build-docs spec.yaml --output=spec-front.html --template redoc-template.html --theme.openapi.hideDownloadButton