Skip to content

Commit 454e5bd

Browse files
committed
feat: new option hide-download-button
resolves #394
1 parent 420c51a commit 454e5bd

File tree

4 files changed

+8
-1
lines changed

4 files changed

+8
-1
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,7 @@ ReDoc makes use of the following [vendor extensions](http://swagger.io/specifica
151151
* `suppress-warnings` - if set, warnings are not rendered at the top of documentation (they still are logged to the console).
152152
* `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.
153153
* `hide-hostname` - if set, the protocol and hostname is not shown in the operation definition.
154+
* `hide-download-button` - do not show "Download" spec button. **THIS DOESN'T MAKE YOUR SPEC PRIVATE**, it just hides the button.
154155
* `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.
155156
* `required-props-first` - show required properties first ordered in the same order as in `required` array.
156157
* `no-auto-auth` - do not inject Authentication section automatically

lib/components/ApiInfo/api-info.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<div class="api-info-wrapper">
22
<h1>{{info.title}} <span class="api-info-version">({{info.version}})</span></h1>
3-
<p class="download-openapi" *ngIf="specUrl">
3+
<p class="download-openapi" *ngIf="specUrl && !hideDownloadButton">
44
Download OpenAPI specification:
55
<a class="openapi-button" [attr.download]="downloadFilename" [attr.href]="specUrl"> Download </a>
66
</p>

lib/components/ApiInfo/api-info.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@ export class ApiInfo extends BaseComponent implements OnInit {
1414
info: any = {};
1515
specUrl: String | SafeResourceUrl;
1616
downloadFilename = '';
17+
18+
hideDownloadButton = this.optionsService.options.hideDownloadButton;
19+
1720
constructor(specMgr: SpecManager,
1821
private optionsService: OptionsService,
1922
elRef: ElementRef,

lib/services/options.service.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ const OPTION_NAMES = new Set([
2121
'pathInMiddlePanel',
2222
'untrustedSpec',
2323
'hideLoading',
24+
'hideDownloadButton',
2425
'ignoredHeaderParameters',
2526
'nativeScrollbars',
2627
]);
@@ -31,6 +32,7 @@ export interface Options {
3132
specUrl?: string;
3233
suppressWarnings?: boolean;
3334
hideHostname?: boolean;
35+
hideDownloadButton?: boolean;
3436
lazyRendering?: boolean;
3537
expandResponses?: Set<string> | 'all';
3638
$scrollParent?: HTMLElement | Window;
@@ -105,6 +107,7 @@ export class OptionsService {
105107
if (isString(this._options.disableLazySchemas)) this._options.disableLazySchemas = true;
106108
if (isString(this._options.suppressWarnings)) this._options.suppressWarnings = true;
107109
if (isString(this._options.hideHostname)) this._options.hideHostname = true;
110+
if (isString(this._options.hideDownloadButton)) this._options.hideDownloadButton = true;
108111
if (isString(this._options.lazyRendering)) this._options.lazyRendering = true;
109112
if (isString(this._options.requiredPropsFirst)) this._options.requiredPropsFirst = true;
110113
if (isString(this._options.noAutoAuth)) this._options.noAutoAuth = true;

0 commit comments

Comments
 (0)