Skip to content

Commit 162faa8

Browse files
committed
Appen support Blob type
1 parent e250c5f commit 162faa8

File tree

4 files changed

+8
-2
lines changed

4 files changed

+8
-2
lines changed

src/templates/core/ApiRequestOptions.hbs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,5 @@ export type ApiRequestOptions = {
1212
readonly mediaType?: string;
1313
readonly responseHeader?: string;
1414
readonly errors?: Record<number, string>;
15+
readonly type?: string;
1516
};

src/templates/core/fetch/getResponseBody.hbs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
1-
export const getResponseBody = async (response: Response): Promise<any> => {
1+
export const getResponseBody = async (response: Response, options: ApiRequestOptions): Promise<any> => {
22
if (response.status !== 204) {
33
try {
4+
if(options.type === 'Blob') {
5+
return await response.blob();
6+
}
7+
48
const contentType = response.headers.get('Content-Type');
59
if (contentType) {
610
const jsonTypes = ['application/json', 'application/problem+json']

src/templates/core/fetch/request.hbs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ export const request = <T>(config: OpenAPIConfig, options: ApiRequestOptions): C
7272

7373
if (!onCancel.isCancelled) {
7474
const response = await sendRequest(config, options, url, body, formData, headers, onCancel);
75-
const responseBody = await getResponseBody(response);
75+
const responseBody = await getResponseBody(response, options);
7676
const responseHeader = getResponseHeader(response, options.responseHeader);
7777

7878
const result: ApiResult = {

src/templates/exportService.hbs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,7 @@ export class {{{name}}}{{{@root.postfix}}} {
145145
{{/each}}
146146
},
147147
{{/if}}
148+
type: '{{>result}}',
148149
});
149150
}
150151

0 commit comments

Comments
 (0)