mirror of
https://github.com/Redocly/redoc.git
synced 2025-08-05 12:50:18 +03:00
fix: downloadDefinitionUrl instead of downloadFileName
This commit is contained in:
parent
f9f7ced497
commit
cecb737c00
|
@ -212,7 +212,6 @@ You can use all of the following options with the standalone version of the <red
|
|||
* `generatedPayloadSamplesMaxDepth` - set the maximum render depth for JSON payload samples (responses and request body). The default value is `10`.
|
||||
* `maxDisplayedEnumValues` - display only specified number of enum values. hide rest values under spoiler.
|
||||
* `hideDownloadButton` - do not show "Download" spec button. **THIS DOESN'T MAKE YOUR SPEC PRIVATE**, it just hides the button.
|
||||
* `downloadFileName` - set a custom file name for the downloaded API definition file. The file is always in JSON format regardless of the file extension you set with this option. The default file name is `openapi.json`. **This option is supported only in redoc-cli**.
|
||||
* `hideHostname` - if set, the protocol and hostname is not shown in the operation definition.
|
||||
* `hideLoading` - do not show loading animation. Useful for small docs.
|
||||
* `hideFab` - do not show FAB in mobile view. Useful for implementing a custom floating action button.
|
||||
|
|
|
@ -27,7 +27,7 @@ export interface RedocRawOptions {
|
|||
untrustedSpec?: boolean | string;
|
||||
hideLoading?: boolean | string;
|
||||
hideDownloadButton?: boolean | string;
|
||||
downloadFileName?: string;
|
||||
downloadDefinitionUrl?: string;
|
||||
disableSearch?: boolean | string;
|
||||
onlyRequiredInSamples?: boolean | string;
|
||||
showExtensions?: boolean | string | string[];
|
||||
|
@ -226,7 +226,7 @@ export class RedocNormalizedOptions {
|
|||
pathInMiddlePanel: boolean;
|
||||
untrustedSpec: boolean;
|
||||
hideDownloadButton: boolean;
|
||||
downloadFileName: string;
|
||||
downloadDefinitionUrl?: string;
|
||||
disableSearch: boolean;
|
||||
onlyRequiredInSamples: boolean;
|
||||
showExtensions: boolean | string[];
|
||||
|
@ -293,7 +293,7 @@ export class RedocNormalizedOptions {
|
|||
this.pathInMiddlePanel = argValueToBoolean(raw.pathInMiddlePanel);
|
||||
this.untrustedSpec = argValueToBoolean(raw.untrustedSpec);
|
||||
this.hideDownloadButton = argValueToBoolean(raw.hideDownloadButton);
|
||||
this.downloadFileName = raw.downloadFileName || 'openapi.json';
|
||||
this.downloadDefinitionUrl = raw.downloadDefinitionUrl;
|
||||
this.disableSearch = argValueToBoolean(raw.disableSearch);
|
||||
this.onlyRequiredInSamples = argValueToBoolean(raw.onlyRequiredInSamples);
|
||||
this.showExtensions = RedocNormalizedOptions.normalizeShowExtensions(raw.showExtensions);
|
||||
|
|
|
@ -83,9 +83,11 @@ describe('Models', () => {
|
|||
},
|
||||
} as any;
|
||||
|
||||
const opts = new RedocNormalizedOptions({ downloadFileName: 'filename.json' });
|
||||
const opts = new RedocNormalizedOptions({
|
||||
downloadDefinitionUrl: 'https:test.com/filename.yaml',
|
||||
});
|
||||
const info = new ApiInfoModel(parser, opts);
|
||||
expect(info.downloadFileName).toEqual('filename.json');
|
||||
expect(info.downloadFileName).toEqual(undefined);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
|
@ -34,6 +34,10 @@ export class ApiInfoModel implements OpenAPIInfo {
|
|||
}
|
||||
|
||||
private getDownloadLink(): string | undefined {
|
||||
if (this.options.downloadDefinitionUrl) {
|
||||
return this.options.downloadDefinitionUrl;
|
||||
}
|
||||
|
||||
if (this.parser.specUrl) {
|
||||
return this.parser.specUrl;
|
||||
}
|
||||
|
@ -47,8 +51,8 @@ export class ApiInfoModel implements OpenAPIInfo {
|
|||
}
|
||||
|
||||
private getDownloadFileName(): string | undefined {
|
||||
if (!this.parser.specUrl) {
|
||||
return this.options.downloadFileName;
|
||||
if (!this.parser.specUrl && !this.options.downloadDefinitionUrl) {
|
||||
return 'openapi.json';
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user