Skip to content

Commit 33678e6

Browse files
committed
fix: crate spec as data/base64 link when ssr
1 parent 9756364 commit 33678e6

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/services/models/ApiInfo.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,17 @@ export class ApiInfoModel implements OpenAPIInfo {
2121
type: 'application/json',
2222
});
2323
return window.URL.createObjectURL(blob);
24+
} else if (!isBrowser) {
25+
return (
26+
'data:application/octet-stream;base64,' +
27+
new Buffer(JSON.stringify(this.parser.spec, null, 2)).toString('base64')
28+
);
2429
}
2530
return this.parser.specUrl;
2631
}
2732

2833
get downloadFileName(): string | undefined {
29-
if (!this.parser.specUrl && isBrowser && window.Blob && window.URL) {
34+
if (!this.parser.specUrl) {
3035
return 'swagger.json';
3136
}
3237
return undefined;

0 commit comments

Comments
 (0)