diff --git a/src/services/RedocNormalizedOptions.ts b/src/services/RedocNormalizedOptions.ts index eceb105738..ccca10a944 100644 --- a/src/services/RedocNormalizedOptions.ts +++ b/src/services/RedocNormalizedOptions.ts @@ -13,6 +13,7 @@ export interface RedocRawOptions { pathInMiddlePanel?: boolean | string; untrustedSpec?: boolean | string; hideLoading?: boolean | string; + hideDownloadButton?: boolean | string; } function argValueToBoolean(val?: string | boolean): boolean { @@ -89,6 +90,7 @@ export class RedocNormalizedOptions { nativeScrollbars: boolean; pathInMiddlePanel: boolean; untrustedSpec: boolean; + hideDownloadButton: boolean; constructor(raw: RedocRawOptions) { this.theme = mergeObjects({} as any, defaultTheme, raw.theme || {}); @@ -100,5 +102,6 @@ export class RedocNormalizedOptions { this.nativeScrollbars = argValueToBoolean(raw.nativeScrollbars); this.pathInMiddlePanel = argValueToBoolean(raw.pathInMiddlePanel); this.untrustedSpec = argValueToBoolean(raw.untrustedSpec); + this.hideDownloadButton = argValueToBoolean(raw.hideDownloadButton); } } diff --git a/src/services/SpecStore.ts b/src/services/SpecStore.ts index cde6e2744e..0f6544fda9 100644 --- a/src/services/SpecStore.ts +++ b/src/services/SpecStore.ts @@ -24,7 +24,7 @@ export class SpecStore { @computed get info(): ApiInfoModel { - return new ApiInfoModel(this.parser); + return new ApiInfoModel(this.parser, this.options); } @computed diff --git a/src/services/models/ApiInfo.ts b/src/services/models/ApiInfo.ts index 12f1e87c2f..3dfa102f0a 100644 --- a/src/services/models/ApiInfo.ts +++ b/src/services/models/ApiInfo.ts @@ -1,6 +1,7 @@ import { OpenAPIContact, OpenAPIInfo, OpenAPILicense } from '../../types'; import { isBrowser } from '../../utils/'; import { OpenAPIParser } from '../OpenAPIParser'; +import { RedocNormalizedOptions } from '../RedocNormalizedOptions'; export class ApiInfoModel implements OpenAPIInfo { title: string; @@ -11,12 +12,18 @@ export class ApiInfoModel implements OpenAPIInfo { contact?: OpenAPIContact; license?: OpenAPILicense; - constructor(public parser: OpenAPIParser) { + constructor(private parser: OpenAPIParser, private options: RedocNormalizedOptions) { Object.assign(this, parser.spec.info); } get downloadLink() { - if (!this.parser.specUrl && isBrowser && window.Blob && window.URL) { + if (this.options.hideDownloadButton) return undefined; + + if (this.parser.specUrl) { + return this.parser.specUrl; + } + + if (isBrowser && window.Blob && window.URL) { const blob = new Blob([JSON.stringify(this.parser.spec, null, 2)], { type: 'application/json', }); @@ -27,7 +34,6 @@ export class ApiInfoModel implements OpenAPIInfo { new Buffer(JSON.stringify(this.parser.spec, null, 2)).toString('base64') ); } - return this.parser.specUrl; } get downloadFileName(): string | undefined { diff --git a/src/theme.ts b/src/theme.ts index 72430c9664..be4493310d 100644 --- a/src/theme.ts +++ b/src/theme.ts @@ -53,7 +53,7 @@ const theme = { backgroundColor: '#fafafa', }, logo: { - maxHeight: '120px', + maxHeight: '150px', }, rightPanel: { backgroundColor: '#263238',