Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/services/__tests__/models/ApiInfo.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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: {
Expand All @@ -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', () => {
Expand Down Expand Up @@ -188,7 +188,7 @@ describe('Models', () => {
},
]
`);
expect(info2.downloadFileName).toMatchInlineSnapshot(`"openapi.json"`);
expect(info2.downloadFileName).toMatchInlineSnapshot(`undefined`);
});
});
});
9 changes: 6 additions & 3 deletions src/services/models/ApiInfo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}