From cecb737c00549e82d388c342328785e3562068dc Mon Sep 17 00:00:00 2001 From: anastasiia-developer Date: Tue, 10 May 2022 11:26:15 +0300 Subject: [PATCH] fix: downloadDefinitionUrl instead of downloadFileName --- README.md | 1 - src/services/RedocNormalizedOptions.ts | 6 +++--- src/services/__tests__/models/ApiInfo.test.ts | 6 ++++-- src/services/models/ApiInfo.ts | 8 ++++++-- 4 files changed, 13 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index 7c2eb928..5b76db06 100644 --- a/README.md +++ b/README.md @@ -212,7 +212,6 @@ You can use all of the following options with the standalone version of the { }, } 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); }); }); }); diff --git a/src/services/models/ApiInfo.ts b/src/services/models/ApiInfo.ts index e9172443..b5d71802 100644 --- a/src/services/models/ApiInfo.ts +++ b/src/services/models/ApiInfo.ts @@ -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; }