diff --git a/modules/openapi-generator/src/main/resources/Javascript/ApiClient.mustache b/modules/openapi-generator/src/main/resources/Javascript/ApiClient.mustache index 47ec095c769..7fd5f5e6cec 100644 --- a/modules/openapi-generator/src/main/resources/Javascript/ApiClient.mustache +++ b/modules/openapi-generator/src/main/resources/Javascript/ApiClient.mustache @@ -459,8 +459,6 @@ if(contentType != 'multipart/form-data') { request.type(contentType); } - } else if (!request.header['Content-Type']) { - request.type('application/json'); } if (contentType === 'application/x-www-form-urlencoded') { @@ -478,6 +476,9 @@ } } } else if (bodyParam !== null && bodyParam !== undefined) { + if (!request.header['Content-Type']) { + request.type('application/json'); + } request.send(bodyParam); } diff --git a/modules/openapi-generator/src/main/resources/Javascript/es6/ApiClient.mustache b/modules/openapi-generator/src/main/resources/Javascript/es6/ApiClient.mustache index f98d9fbf3e5..aa54b3d1bb8 100644 --- a/modules/openapi-generator/src/main/resources/Javascript/es6/ApiClient.mustache +++ b/modules/openapi-generator/src/main/resources/Javascript/es6/ApiClient.mustache @@ -421,8 +421,6 @@ class ApiClient { if(contentType != 'multipart/form-data') { request.type(contentType); } - } else if (!request.header['Content-Type']) { - request.type('application/json'); } if (contentType === 'application/x-www-form-urlencoded') { @@ -440,6 +438,9 @@ class ApiClient { } } } else if (bodyParam !== null && bodyParam !== undefined) { + if (!request.header['Content-Type']) { + request.type('application/json'); + } request.send(bodyParam); } diff --git a/samples/client/petstore/javascript-es6/src/ApiClient.js b/samples/client/petstore/javascript-es6/src/ApiClient.js index 5d266cc248c..9d51da74d54 100644 --- a/samples/client/petstore/javascript-es6/src/ApiClient.js +++ b/samples/client/petstore/javascript-es6/src/ApiClient.js @@ -408,8 +408,6 @@ class ApiClient { if(contentType != 'multipart/form-data') { request.type(contentType); } - } else if (!request.header['Content-Type']) { - request.type('application/json'); } if (contentType === 'application/x-www-form-urlencoded') { @@ -427,6 +425,9 @@ class ApiClient { } } } else if (bodyParam !== null && bodyParam !== undefined) { + if (!request.header['Content-Type']) { + request.type('application/json'); + } request.send(bodyParam); } diff --git a/samples/client/petstore/javascript-promise-es6/src/ApiClient.js b/samples/client/petstore/javascript-promise-es6/src/ApiClient.js index dc4ff806226..581711e0194 100644 --- a/samples/client/petstore/javascript-promise-es6/src/ApiClient.js +++ b/samples/client/petstore/javascript-promise-es6/src/ApiClient.js @@ -400,8 +400,6 @@ class ApiClient { if(contentType != 'multipart/form-data') { request.type(contentType); } - } else if (!request.header['Content-Type']) { - request.type('application/json'); } if (contentType === 'application/x-www-form-urlencoded') { @@ -419,6 +417,9 @@ class ApiClient { } } } else if (bodyParam !== null && bodyParam !== undefined) { + if (!request.header['Content-Type']) { + request.type('application/json'); + } request.send(bodyParam); } diff --git a/samples/client/petstore/javascript-promise/src/ApiClient.js b/samples/client/petstore/javascript-promise/src/ApiClient.js index 634c1cc2cce..f227bc3543e 100644 --- a/samples/client/petstore/javascript-promise/src/ApiClient.js +++ b/samples/client/petstore/javascript-promise/src/ApiClient.js @@ -449,8 +449,6 @@ if(contentType != 'multipart/form-data') { request.type(contentType); } - } else if (!request.header['Content-Type']) { - request.type('application/json'); } if (contentType === 'application/x-www-form-urlencoded') { @@ -468,6 +466,9 @@ } } } else if (bodyParam !== null && bodyParam !== undefined) { + if (!request.header['Content-Type']) { + request.type('application/json'); + } request.send(bodyParam); } diff --git a/samples/client/petstore/javascript/src/ApiClient.js b/samples/client/petstore/javascript/src/ApiClient.js index b86103b6baf..17f85b1e2c8 100644 --- a/samples/client/petstore/javascript/src/ApiClient.js +++ b/samples/client/petstore/javascript/src/ApiClient.js @@ -458,8 +458,6 @@ if(contentType != 'multipart/form-data') { request.type(contentType); } - } else if (!request.header['Content-Type']) { - request.type('application/json'); } if (contentType === 'application/x-www-form-urlencoded') { @@ -477,6 +475,9 @@ } } } else if (bodyParam !== null && bodyParam !== undefined) { + if (!request.header['Content-Type']) { + request.type('application/json'); + } request.send(bodyParam); } diff --git a/samples/openapi3/client/petstore/javascript-es6/src/ApiClient.js b/samples/openapi3/client/petstore/javascript-es6/src/ApiClient.js index fc521813b36..83cba1cae1a 100644 --- a/samples/openapi3/client/petstore/javascript-es6/src/ApiClient.js +++ b/samples/openapi3/client/petstore/javascript-es6/src/ApiClient.js @@ -409,8 +409,6 @@ class ApiClient { if(contentType != 'multipart/form-data') { request.type(contentType); } - } else if (!request.header['Content-Type']) { - request.type('application/json'); } if (contentType === 'application/x-www-form-urlencoded') { @@ -428,6 +426,9 @@ class ApiClient { } } } else if (bodyParam !== null && bodyParam !== undefined) { + if (!request.header['Content-Type']) { + request.type('application/json'); + } request.send(bodyParam); }