Fix undefined request body when body === false or 0, "" in other clients

This commit is contained in:
Ferdi Koomen 2022-06-13 21:45:26 +02:00
parent aa20f9e17b
commit 32ff947dee
3 changed files with 4 additions and 5 deletions

View File

@ -1,5 +1,5 @@
const getRequestBody = (options: ApiRequestOptions): any => {
if (options.body) {
if (options.body !== undefined) {
if (options.mediaType?.includes('/json')) {
return JSON.stringify(options.body)
} else if (isString(options.body) || isBlob(options.body) || isFormData(options.body)) {

View File

@ -1,5 +1,5 @@
const getRequestBody = (options: ApiRequestOptions): any => {
if (options.body) {
if (options.body !== undefined) {
if (options.mediaType?.includes('/json')) {
return JSON.stringify(options.body)
} else if (isString(options.body) || isBlob(options.body) || isFormData(options.body)) {
@ -8,6 +8,5 @@ const getRequestBody = (options: ApiRequestOptions): any => {
return JSON.stringify(options.body);
}
}
return undefined;
};

View File

@ -409,7 +409,7 @@ const getHeaders = async (config: OpenAPIConfig, options: ApiRequestOptions): Pr
};
const getRequestBody = (options: ApiRequestOptions): any => {
if (options.body) {
if (options.body !== undefined) {
if (options.mediaType?.includes('/json')) {
return JSON.stringify(options.body)
} else if (isString(options.body) || isBlob(options.body) || isFormData(options.body)) {
@ -3468,7 +3468,7 @@ const getHeaders = async (config: OpenAPIConfig, options: ApiRequestOptions): Pr
};
const getRequestBody = (options: ApiRequestOptions): any => {
if (options.body) {
if (options.body !== undefined) {
if (options.mediaType?.includes('/json')) {
return JSON.stringify(options.body)
} else if (isString(options.body) || isBlob(options.body) || isFormData(options.body)) {