Skip to content

Commit

Permalink
feat: new option hide-download-button
Browse files Browse the repository at this point in the history
resolves #394
  • Loading branch information
RomanHotsiy committed Feb 16, 2018
1 parent 420c51a commit 454e5bd
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 1 deletion.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion lib/components/ApiInfo/api-info.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<div class="api-info-wrapper">
<h1>{{info.title}} <span class="api-info-version">({{info.version}})</span></h1>
<p class="download-openapi" *ngIf="specUrl">
<p class="download-openapi" *ngIf="specUrl && !hideDownloadButton">
Download OpenAPI specification:
<a class="openapi-button" [attr.download]="downloadFilename" [attr.href]="specUrl"> Download </a>
</p>
Expand Down
3 changes: 3 additions & 0 deletions lib/components/ApiInfo/api-info.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
3 changes: 3 additions & 0 deletions lib/services/options.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ const OPTION_NAMES = new Set([
'pathInMiddlePanel',
'untrustedSpec',
'hideLoading',
'hideDownloadButton',
'ignoredHeaderParameters',
'nativeScrollbars',
]);
Expand All @@ -31,6 +32,7 @@ export interface Options {
specUrl?: string;
suppressWarnings?: boolean;
hideHostname?: boolean;
hideDownloadButton?: boolean;
lazyRendering?: boolean;
expandResponses?: Set<string> | 'all';
$scrollParent?: HTMLElement | Window;
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit 454e5bd

Please sign in to comment.