Skip to content

Commit

Permalink
[typescript-axios] Fix api generating incorrect seralization type che…
Browse files Browse the repository at this point in the history
…ck (#4051)

Seralization check should be ensuring the param type is not a string, which matches that of the flow generator logic.
  • Loading branch information
JMontagu authored and macjohnny committed Oct 4, 2019
1 parent f955966 commit e0c389f
Show file tree
Hide file tree
Showing 9 changed files with 43 additions and 43 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ export const {{classname}}AxiosParamCreator = function (configuration?: Configur
localVarRequestOptions.data = localVarFormParams{{#vendorExtensions}}{{^multipartFormData}}.toString(){{/multipartFormData}}{{/vendorExtensions}};
{{/hasFormParams}}
{{#bodyParam}}
const needsSerialization = (<any>"{{dataType}}" !== "string") || localVarRequestOptions.headers['Content-Type'] === 'application/json';
const needsSerialization = (typeof {{paramName}} !== "string") || localVarRequestOptions.headers['Content-Type'] === 'application/json';
localVarRequestOptions.data = needsSerialization ? JSON.stringify({{paramName}} !== undefined ? {{paramName}} : {}) : ({{paramName}} || "");
{{/bodyParam}}
Expand Down
14 changes: 7 additions & 7 deletions samples/client/petstore/typescript-axios/builds/default/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,7 @@ export const PetApiAxiosParamCreator = function (configuration?: Configuration)
// fix override query string Detail: https://stackoverflow.com/a/7517673/1077943
delete localVarUrlObj.search;
localVarRequestOptions.headers = {...localVarHeaderParameter, ...options.headers};
const needsSerialization = (<any>"Pet" !== "string") || localVarRequestOptions.headers['Content-Type'] === 'application/json';
const needsSerialization = (typeof body !== "string") || localVarRequestOptions.headers['Content-Type'] === 'application/json';
localVarRequestOptions.data = needsSerialization ? JSON.stringify(body !== undefined ? body : {}) : (body || "");

return {
Expand Down Expand Up @@ -525,7 +525,7 @@ export const PetApiAxiosParamCreator = function (configuration?: Configuration)
// fix override query string Detail: https://stackoverflow.com/a/7517673/1077943
delete localVarUrlObj.search;
localVarRequestOptions.headers = {...localVarHeaderParameter, ...options.headers};
const needsSerialization = (<any>"Pet" !== "string") || localVarRequestOptions.headers['Content-Type'] === 'application/json';
const needsSerialization = (typeof body !== "string") || localVarRequestOptions.headers['Content-Type'] === 'application/json';
localVarRequestOptions.data = needsSerialization ? JSON.stringify(body !== undefined ? body : {}) : (body || "");

return {
Expand Down Expand Up @@ -1126,7 +1126,7 @@ export const StoreApiAxiosParamCreator = function (configuration?: Configuration
// fix override query string Detail: https://stackoverflow.com/a/7517673/1077943
delete localVarUrlObj.search;
localVarRequestOptions.headers = {...localVarHeaderParameter, ...options.headers};
const needsSerialization = (<any>"Order" !== "string") || localVarRequestOptions.headers['Content-Type'] === 'application/json';
const needsSerialization = (typeof body !== "string") || localVarRequestOptions.headers['Content-Type'] === 'application/json';
localVarRequestOptions.data = needsSerialization ? JSON.stringify(body !== undefined ? body : {}) : (body || "");

return {
Expand Down Expand Up @@ -1342,7 +1342,7 @@ export const UserApiAxiosParamCreator = function (configuration?: Configuration)
// fix override query string Detail: https://stackoverflow.com/a/7517673/1077943
delete localVarUrlObj.search;
localVarRequestOptions.headers = {...localVarHeaderParameter, ...options.headers};
const needsSerialization = (<any>"User" !== "string") || localVarRequestOptions.headers['Content-Type'] === 'application/json';
const needsSerialization = (typeof body !== "string") || localVarRequestOptions.headers['Content-Type'] === 'application/json';
localVarRequestOptions.data = needsSerialization ? JSON.stringify(body !== undefined ? body : {}) : (body || "");

return {
Expand Down Expand Up @@ -1380,7 +1380,7 @@ export const UserApiAxiosParamCreator = function (configuration?: Configuration)
// fix override query string Detail: https://stackoverflow.com/a/7517673/1077943
delete localVarUrlObj.search;
localVarRequestOptions.headers = {...localVarHeaderParameter, ...options.headers};
const needsSerialization = (<any>"Array&lt;User&gt;" !== "string") || localVarRequestOptions.headers['Content-Type'] === 'application/json';
const needsSerialization = (typeof body !== "string") || localVarRequestOptions.headers['Content-Type'] === 'application/json';
localVarRequestOptions.data = needsSerialization ? JSON.stringify(body !== undefined ? body : {}) : (body || "");

return {
Expand Down Expand Up @@ -1418,7 +1418,7 @@ export const UserApiAxiosParamCreator = function (configuration?: Configuration)
// fix override query string Detail: https://stackoverflow.com/a/7517673/1077943
delete localVarUrlObj.search;
localVarRequestOptions.headers = {...localVarHeaderParameter, ...options.headers};
const needsSerialization = (<any>"Array&lt;User&gt;" !== "string") || localVarRequestOptions.headers['Content-Type'] === 'application/json';
const needsSerialization = (typeof body !== "string") || localVarRequestOptions.headers['Content-Type'] === 'application/json';
localVarRequestOptions.data = needsSerialization ? JSON.stringify(body !== undefined ? body : {}) : (body || "");

return {
Expand Down Expand Up @@ -1608,7 +1608,7 @@ export const UserApiAxiosParamCreator = function (configuration?: Configuration)
// fix override query string Detail: https://stackoverflow.com/a/7517673/1077943
delete localVarUrlObj.search;
localVarRequestOptions.headers = {...localVarHeaderParameter, ...options.headers};
const needsSerialization = (<any>"User" !== "string") || localVarRequestOptions.headers['Content-Type'] === 'application/json';
const needsSerialization = (typeof body !== "string") || localVarRequestOptions.headers['Content-Type'] === 'application/json';
localVarRequestOptions.data = needsSerialization ? JSON.stringify(body !== undefined ? body : {}) : (body || "");

return {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,7 @@ export const PetApiAxiosParamCreator = function (configuration?: Configuration)
// fix override query string Detail: https://stackoverflow.com/a/7517673/1077943
delete localVarUrlObj.search;
localVarRequestOptions.headers = {...localVarHeaderParameter, ...options.headers};
const needsSerialization = (<any>"Pet" !== "string") || localVarRequestOptions.headers['Content-Type'] === 'application/json';
const needsSerialization = (typeof body !== "string") || localVarRequestOptions.headers['Content-Type'] === 'application/json';
localVarRequestOptions.data = needsSerialization ? JSON.stringify(body !== undefined ? body : {}) : (body || "");

return {
Expand Down Expand Up @@ -525,7 +525,7 @@ export const PetApiAxiosParamCreator = function (configuration?: Configuration)
// fix override query string Detail: https://stackoverflow.com/a/7517673/1077943
delete localVarUrlObj.search;
localVarRequestOptions.headers = {...localVarHeaderParameter, ...options.headers};
const needsSerialization = (<any>"Pet" !== "string") || localVarRequestOptions.headers['Content-Type'] === 'application/json';
const needsSerialization = (typeof body !== "string") || localVarRequestOptions.headers['Content-Type'] === 'application/json';
localVarRequestOptions.data = needsSerialization ? JSON.stringify(body !== undefined ? body : {}) : (body || "");

return {
Expand Down Expand Up @@ -1126,7 +1126,7 @@ export const StoreApiAxiosParamCreator = function (configuration?: Configuration
// fix override query string Detail: https://stackoverflow.com/a/7517673/1077943
delete localVarUrlObj.search;
localVarRequestOptions.headers = {...localVarHeaderParameter, ...options.headers};
const needsSerialization = (<any>"Order" !== "string") || localVarRequestOptions.headers['Content-Type'] === 'application/json';
const needsSerialization = (typeof body !== "string") || localVarRequestOptions.headers['Content-Type'] === 'application/json';
localVarRequestOptions.data = needsSerialization ? JSON.stringify(body !== undefined ? body : {}) : (body || "");

return {
Expand Down Expand Up @@ -1342,7 +1342,7 @@ export const UserApiAxiosParamCreator = function (configuration?: Configuration)
// fix override query string Detail: https://stackoverflow.com/a/7517673/1077943
delete localVarUrlObj.search;
localVarRequestOptions.headers = {...localVarHeaderParameter, ...options.headers};
const needsSerialization = (<any>"User" !== "string") || localVarRequestOptions.headers['Content-Type'] === 'application/json';
const needsSerialization = (typeof body !== "string") || localVarRequestOptions.headers['Content-Type'] === 'application/json';
localVarRequestOptions.data = needsSerialization ? JSON.stringify(body !== undefined ? body : {}) : (body || "");

return {
Expand Down Expand Up @@ -1380,7 +1380,7 @@ export const UserApiAxiosParamCreator = function (configuration?: Configuration)
// fix override query string Detail: https://stackoverflow.com/a/7517673/1077943
delete localVarUrlObj.search;
localVarRequestOptions.headers = {...localVarHeaderParameter, ...options.headers};
const needsSerialization = (<any>"Array&lt;User&gt;" !== "string") || localVarRequestOptions.headers['Content-Type'] === 'application/json';
const needsSerialization = (typeof body !== "string") || localVarRequestOptions.headers['Content-Type'] === 'application/json';
localVarRequestOptions.data = needsSerialization ? JSON.stringify(body !== undefined ? body : {}) : (body || "");

return {
Expand Down Expand Up @@ -1418,7 +1418,7 @@ export const UserApiAxiosParamCreator = function (configuration?: Configuration)
// fix override query string Detail: https://stackoverflow.com/a/7517673/1077943
delete localVarUrlObj.search;
localVarRequestOptions.headers = {...localVarHeaderParameter, ...options.headers};
const needsSerialization = (<any>"Array&lt;User&gt;" !== "string") || localVarRequestOptions.headers['Content-Type'] === 'application/json';
const needsSerialization = (typeof body !== "string") || localVarRequestOptions.headers['Content-Type'] === 'application/json';
localVarRequestOptions.data = needsSerialization ? JSON.stringify(body !== undefined ? body : {}) : (body || "");

return {
Expand Down Expand Up @@ -1608,7 +1608,7 @@ export const UserApiAxiosParamCreator = function (configuration?: Configuration)
// fix override query string Detail: https://stackoverflow.com/a/7517673/1077943
delete localVarUrlObj.search;
localVarRequestOptions.headers = {...localVarHeaderParameter, ...options.headers};
const needsSerialization = (<any>"User" !== "string") || localVarRequestOptions.headers['Content-Type'] === 'application/json';
const needsSerialization = (typeof body !== "string") || localVarRequestOptions.headers['Content-Type'] === 'application/json';
localVarRequestOptions.data = needsSerialization ? JSON.stringify(body !== undefined ? body : {}) : (body || "");

return {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -341,7 +341,7 @@ export const PetApiAxiosParamCreator = function (configuration?: Configuration)
// fix override query string Detail: https://stackoverflow.com/a/7517673/1077943
delete localVarUrlObj.search;
localVarRequestOptions.headers = {...localVarHeaderParameter, ...options.headers};
const needsSerialization = (<any>"Pet" !== "string") || localVarRequestOptions.headers['Content-Type'] === 'application/json';
const needsSerialization = (typeof pet !== "string") || localVarRequestOptions.headers['Content-Type'] === 'application/json';
localVarRequestOptions.data = needsSerialization ? JSON.stringify(pet !== undefined ? pet : {}) : (pet || "");

return {
Expand Down Expand Up @@ -574,7 +574,7 @@ export const PetApiAxiosParamCreator = function (configuration?: Configuration)
// fix override query string Detail: https://stackoverflow.com/a/7517673/1077943
delete localVarUrlObj.search;
localVarRequestOptions.headers = {...localVarHeaderParameter, ...options.headers};
const needsSerialization = (<any>"Pet" !== "string") || localVarRequestOptions.headers['Content-Type'] === 'application/json';
const needsSerialization = (typeof pet !== "string") || localVarRequestOptions.headers['Content-Type'] === 'application/json';
localVarRequestOptions.data = needsSerialization ? JSON.stringify(pet !== undefined ? pet : {}) : (pet || "");

return {
Expand Down Expand Up @@ -1181,7 +1181,7 @@ export const StoreApiAxiosParamCreator = function (configuration?: Configuration
// fix override query string Detail: https://stackoverflow.com/a/7517673/1077943
delete localVarUrlObj.search;
localVarRequestOptions.headers = {...localVarHeaderParameter, ...options.headers};
const needsSerialization = (<any>"Order" !== "string") || localVarRequestOptions.headers['Content-Type'] === 'application/json';
const needsSerialization = (typeof order !== "string") || localVarRequestOptions.headers['Content-Type'] === 'application/json';
localVarRequestOptions.data = needsSerialization ? JSON.stringify(order !== undefined ? order : {}) : (order || "");

return {
Expand Down Expand Up @@ -1397,7 +1397,7 @@ export const UserApiAxiosParamCreator = function (configuration?: Configuration)
// fix override query string Detail: https://stackoverflow.com/a/7517673/1077943
delete localVarUrlObj.search;
localVarRequestOptions.headers = {...localVarHeaderParameter, ...options.headers};
const needsSerialization = (<any>"User" !== "string") || localVarRequestOptions.headers['Content-Type'] === 'application/json';
const needsSerialization = (typeof user !== "string") || localVarRequestOptions.headers['Content-Type'] === 'application/json';
localVarRequestOptions.data = needsSerialization ? JSON.stringify(user !== undefined ? user : {}) : (user || "");

return {
Expand Down Expand Up @@ -1435,7 +1435,7 @@ export const UserApiAxiosParamCreator = function (configuration?: Configuration)
// fix override query string Detail: https://stackoverflow.com/a/7517673/1077943
delete localVarUrlObj.search;
localVarRequestOptions.headers = {...localVarHeaderParameter, ...options.headers};
const needsSerialization = (<any>"Array&lt;User&gt;" !== "string") || localVarRequestOptions.headers['Content-Type'] === 'application/json';
const needsSerialization = (typeof user !== "string") || localVarRequestOptions.headers['Content-Type'] === 'application/json';
localVarRequestOptions.data = needsSerialization ? JSON.stringify(user !== undefined ? user : {}) : (user || "");

return {
Expand Down Expand Up @@ -1473,7 +1473,7 @@ export const UserApiAxiosParamCreator = function (configuration?: Configuration)
// fix override query string Detail: https://stackoverflow.com/a/7517673/1077943
delete localVarUrlObj.search;
localVarRequestOptions.headers = {...localVarHeaderParameter, ...options.headers};
const needsSerialization = (<any>"Array&lt;User&gt;" !== "string") || localVarRequestOptions.headers['Content-Type'] === 'application/json';
const needsSerialization = (typeof user !== "string") || localVarRequestOptions.headers['Content-Type'] === 'application/json';
localVarRequestOptions.data = needsSerialization ? JSON.stringify(user !== undefined ? user : {}) : (user || "");

return {
Expand Down Expand Up @@ -1663,7 +1663,7 @@ export const UserApiAxiosParamCreator = function (configuration?: Configuration)
// fix override query string Detail: https://stackoverflow.com/a/7517673/1077943
delete localVarUrlObj.search;
localVarRequestOptions.headers = {...localVarHeaderParameter, ...options.headers};
const needsSerialization = (<any>"User" !== "string") || localVarRequestOptions.headers['Content-Type'] === 'application/json';
const needsSerialization = (typeof user !== "string") || localVarRequestOptions.headers['Content-Type'] === 'application/json';
localVarRequestOptions.data = needsSerialization ? JSON.stringify(user !== undefined ? user : {}) : (user || "");

return {
Expand Down
Loading

0 comments on commit e0c389f

Please sign in to comment.