diff --git a/README.md b/README.md index 8b7f718bbd..8db64a63db 100644 --- a/README.md +++ b/README.md @@ -151,6 +151,7 @@ ReDoc makes use of the following [vendor extensions](http://swagger.io/specifica * `suppress-warnings` - if set, warnings are not rendered at the top of documentation (they still are logged to the console). * `lazy-rendering` - if set, enables lazy rendering mode in ReDoc. This mode is useful for APIs with big number of operations (e.g. > 50). In this mode ReDoc shows initial screen ASAP and then renders the rest operations asynchronously while showing progress bar on the top. Check out the [demo](https://rebilly.github.io/ReDoc) for the example. * `hide-hostname` - if set, the protocol and hostname is not shown in the operation definition. +* `hide-download-button` - do not show "Download" spec button. **THIS DOESN'T MAKE YOUR SPEC PRIVATE**, it just hides the button. * `expand-responses` - specify which responses to expand by default by response codes. Values should be passed as comma-separated list without spaces e.g. `expand-responses="200,201"`. Special value `"all"` expands all responses by default. Be careful: this option can slow-down documentation rendering time. * `required-props-first` - show required properties first ordered in the same order as in `required` array. * `no-auto-auth` - do not inject Authentication section automatically diff --git a/lib/components/ApiInfo/api-info.html b/lib/components/ApiInfo/api-info.html index df0faf07b7..dbb2003348 100644 --- a/lib/components/ApiInfo/api-info.html +++ b/lib/components/ApiInfo/api-info.html @@ -1,6 +1,6 @@

{{info.title}} ({{info.version}})

-

+

Download OpenAPI specification: Download

diff --git a/lib/components/ApiInfo/api-info.ts b/lib/components/ApiInfo/api-info.ts index 1f6240c882..153f539cdd 100644 --- a/lib/components/ApiInfo/api-info.ts +++ b/lib/components/ApiInfo/api-info.ts @@ -14,6 +14,9 @@ export class ApiInfo extends BaseComponent implements OnInit { info: any = {}; specUrl: String | SafeResourceUrl; downloadFilename = ''; + + hideDownloadButton = this.optionsService.options.hideDownloadButton; + constructor(specMgr: SpecManager, private optionsService: OptionsService, elRef: ElementRef, diff --git a/lib/services/options.service.ts b/lib/services/options.service.ts index 97d099d386..82dea74b88 100644 --- a/lib/services/options.service.ts +++ b/lib/services/options.service.ts @@ -21,6 +21,7 @@ const OPTION_NAMES = new Set([ 'pathInMiddlePanel', 'untrustedSpec', 'hideLoading', + 'hideDownloadButton', 'ignoredHeaderParameters', 'nativeScrollbars', ]); @@ -31,6 +32,7 @@ export interface Options { specUrl?: string; suppressWarnings?: boolean; hideHostname?: boolean; + hideDownloadButton?: boolean; lazyRendering?: boolean; expandResponses?: Set | 'all'; $scrollParent?: HTMLElement | Window; @@ -105,6 +107,7 @@ export class OptionsService { if (isString(this._options.disableLazySchemas)) this._options.disableLazySchemas = true; if (isString(this._options.suppressWarnings)) this._options.suppressWarnings = true; if (isString(this._options.hideHostname)) this._options.hideHostname = true; + if (isString(this._options.hideDownloadButton)) this._options.hideDownloadButton = true; if (isString(this._options.lazyRendering)) this._options.lazyRendering = true; if (isString(this._options.requiredPropsFirst)) this._options.requiredPropsFirst = true; if (isString(this._options.noAutoAuth)) this._options.noAutoAuth = true;