test(media type): update snapshot

This commit is contained in:
Maarten Van Hoof 2021-04-07 15:31:00 +02:00
parent ea7f26b0e9
commit 968bef7215

View File

@ -35,6 +35,7 @@ export type ApiRequestOptions = {
readonly query?: Record<string, any>;
readonly formData?: Record<string, any>;
readonly body?: any;
readonly bodyMediaType?: string;
readonly responseHeader?: string;
readonly errors?: Record<number, string>;
}"
@ -180,12 +181,16 @@ async function getHeaders(options: ApiRequestOptions): Promise<Headers> {
}
if (options.body) {
if (isBlob(options.body)) {
headers.append('Content-Type', options.body.type || 'application/octet-stream');
} else if (isString(options.body)) {
headers.append('Content-Type', 'text/plain');
if (options.bodyMediaType) {
headers.append('Content-Type', options.bodyMediaType);
} else {
headers.append('Content-Type', 'application/json');
if (isBlob(options.body)) {
headers.append('Content-Type', options.body.type || 'application/octet-stream');
} else if (isString(options.body)) {
headers.append('Content-Type', 'text/plain');
} else {
headers.append('Content-Type', 'application/json');
}
}
}
return headers;
@ -196,7 +201,9 @@ function getRequestBody(options: ApiRequestOptions): BodyInit | undefined {
return getFormData(options.formData);
}
if (options.body) {
if (isString(options.body) || isBlob(options.body)) {
if (options.bodyMediaType?.includes('/json')) {
return JSON.stringify(options.body)
} else if (isString(options.body) || isBlob(options.body)) {
return options.body;
} else {
return JSON.stringify(options.body);
@ -2383,6 +2390,7 @@ export type ApiRequestOptions = {
readonly query?: Record<string, any>;
readonly formData?: Record<string, any>;
readonly body?: any;
readonly bodyMediaType?: string;
readonly responseHeader?: string;
readonly errors?: Record<number, string>;
}"
@ -2528,12 +2536,16 @@ async function getHeaders(options: ApiRequestOptions): Promise<Headers> {
}
if (options.body) {
if (isBlob(options.body)) {
headers.append('Content-Type', options.body.type || 'application/octet-stream');
} else if (isString(options.body)) {
headers.append('Content-Type', 'text/plain');
if (options.bodyMediaType) {
headers.append('Content-Type', options.bodyMediaType);
} else {
headers.append('Content-Type', 'application/json');
if (isBlob(options.body)) {
headers.append('Content-Type', options.body.type || 'application/octet-stream');
} else if (isString(options.body)) {
headers.append('Content-Type', 'text/plain');
} else {
headers.append('Content-Type', 'application/json');
}
}
}
return headers;
@ -2544,7 +2556,9 @@ function getRequestBody(options: ApiRequestOptions): BodyInit | undefined {
return getFormData(options.formData);
}
if (options.body) {
if (isString(options.body) || isBlob(options.body)) {
if (options.bodyMediaType?.includes('/json')) {
return JSON.stringify(options.body)
} else if (isString(options.body) || isBlob(options.body)) {
return options.body;
} else {
return JSON.stringify(options.body);
@ -4481,6 +4495,7 @@ export class ComplexService {
method: 'PUT',
path: \`/api/v\${OpenAPI.VERSION}/complex/\${id}\`,
body: requestBody,
bodyMediaType: 'application/json-patch+json',
});
return result.body;
}
@ -4777,6 +4792,7 @@ export class ParametersService {
'parameterForm': parameterForm,
},
body: requestBody,
bodyMediaType: 'application/json',
});
return result.body;
}
@ -4821,6 +4837,7 @@ export class ParametersService {
'parameter_form': parameterForm,
},
body: requestBody,
bodyMediaType: 'application/json',
});
return result.body;
}
@ -4841,6 +4858,7 @@ export class ParametersService {
'parameter': parameter,
},
body: requestBody,
bodyMediaType: 'application/json',
});
return result.body;
}
@ -4861,6 +4879,7 @@ export class ParametersService {
'parameter': parameter,
},
body: requestBody,
bodyMediaType: 'application/json',
});
return result.body;
}
@ -4889,6 +4908,7 @@ export class RequestBodyService {
method: 'POST',
path: \`/api/v\${OpenAPI.VERSION}/requestBody/\`,
body: requestBody,
bodyMediaType: 'application/json',
});
return result.body;
}