From 33678e647e053ab0145cbd3694842f6fc5a70bc7 Mon Sep 17 00:00:00 2001 From: Roman Hotsiy Date: Wed, 10 Jan 2018 18:24:55 +0200 Subject: [PATCH] fix: crate spec as data/base64 link when ssr --- src/services/models/ApiInfo.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/services/models/ApiInfo.ts b/src/services/models/ApiInfo.ts index 73ab9128cf..8e82fd5597 100644 --- a/src/services/models/ApiInfo.ts +++ b/src/services/models/ApiInfo.ts @@ -21,12 +21,17 @@ export class ApiInfoModel implements OpenAPIInfo { type: 'application/json', }); return window.URL.createObjectURL(blob); + } else if (!isBrowser) { + return ( + 'data:application/octet-stream;base64,' + + new Buffer(JSON.stringify(this.parser.spec, null, 2)).toString('base64') + ); } return this.parser.specUrl; } get downloadFileName(): string | undefined { - if (!this.parser.specUrl && isBrowser && window.Blob && window.URL) { + if (!this.parser.specUrl) { return 'swagger.json'; } return undefined;