From 88ed5f9348187dab6ba4470940f41d3462d6a216 Mon Sep 17 00:00:00 2001 From: cyphercodes Date: Sun, 7 Jun 2026 06:35:57 +0300 Subject: [PATCH] Fix custom download URL filenames --- src/services/__tests__/models/ApiInfo.test.ts | 6 +++--- src/services/models/ApiInfo.ts | 9 ++++++--- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/src/services/__tests__/models/ApiInfo.test.ts b/src/services/__tests__/models/ApiInfo.test.ts index 9b9ed51ee..f77fce7d8 100644 --- a/src/services/__tests__/models/ApiInfo.test.ts +++ b/src/services/__tests__/models/ApiInfo.test.ts @@ -130,7 +130,7 @@ describe('Models', () => { expect(info.downloadFileName).toEqual('test.yaml'); }); - test('should correctly populate download link', () => { + test('should correctly populate custom download link without forcing a file name', () => { parser.spec = { openapi: '3.0.0', info: { @@ -150,7 +150,7 @@ describe('Models', () => { }, ] `); - expect(info.downloadFileName).toMatchInlineSnapshot(`"openapi.json"`); + expect(info.downloadFileName).toMatchInlineSnapshot(`undefined`); }); test('should correctly populate download link and download file name', () => { @@ -188,7 +188,7 @@ describe('Models', () => { }, ] `); - expect(info2.downloadFileName).toMatchInlineSnapshot(`"openapi.json"`); + expect(info2.downloadFileName).toMatchInlineSnapshot(`undefined`); }); }); }); diff --git a/src/services/models/ApiInfo.ts b/src/services/models/ApiInfo.ts index db6d3fa53..65334d9d3 100644 --- a/src/services/models/ApiInfo.ts +++ b/src/services/models/ApiInfo.ts @@ -70,9 +70,12 @@ export class ApiInfoModel implements OpenAPIInfo { } private getDownloadFileName(): string | undefined { - if (!this.parser.specUrl && !this.options.downloadDefinitionUrl) { - return this.options.downloadFileName || 'openapi.json'; + if (this.options.downloadFileName) { + return this.options.downloadFileName; + } + + if (!this.parser.specUrl && !this.options.downloadDefinitionUrl && !this.options.downloadUrls) { + return 'openapi.json'; } - return this.options.downloadFileName; } }