You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
JS Objects used to be flattened into individual parameters. Now they just get JSON.stringified.
Example:
Page Object:
{page: 1,items: 10}
7.11.0
/api/request?page=1&items=10
7.12.0
/api/request?page={page:1,items:10}
There is no config to set the behaviour to how it was previously.
openapi-generator version
7.11.0
privateaddToHttpParamsRecursive(httpParams: HttpParams,value?: any,key?: string): HttpParams{if(value==null){returnhttpParams;}if(typeofvalue==="object"){if(Array.isArray(value)){(valueasany[]).forEach(elem=>httpParams=this.addToHttpParamsRecursive(httpParams,elem,key));}elseif(valueinstanceofDate){if(key!=null){httpParams=httpParams.append(key,(valueasDate).toISOString().substring(0,10));}else{throwError("key may not be null if value is Date");}}else{Object.keys(value).forEach(k=>httpParams=this.addToHttpParamsRecursive(httpParams,value[k],key!=null ? `${key}.${k}` : k));}}elseif(key!=null){httpParams=httpParams.append(key,value);}else{throwError("key may not be null if value is not object or array");}returnhttpParams;}
7.12.0
protectedaddToHttpParamsRecursive(httpParams: HttpParams,value?: any,key?: string): HttpParams{if(value===null||value===undefined){returnhttpParams;}if(typeofvalue==='object'){// If JSON format is preferred, key must be provided.if(key!=null){returnhttpParams.append(key,JSON.stringify(value));}// Otherwise, if it's an array, add each element.if(Array.isArray(value)){value.forEach(elem=>httpParams=this.addToHttpParamsRecursive(httpParams,elem,key));}elseif(valueinstanceofDate){if(key!=null){httpParams=httpParams.append(key,value.toISOString());}else{throwError("key may not be null if value is Date");}}else{Object.keys(value).forEach(k=>{constparamKey=key ? `${key}.${k}` : k;httpParams=this.addToHttpParamsRecursive(httpParams,value[k],paramKey);});}returnhttpParams;}elseif(key!=null){returnhttpParams.append(key,value);}throwError("key may not be null if value is not object or array");}
MrAlexand0r
changed the title
[BUG][typescript-angualr] 7.12.0 refactoring changes behaviour of http params
[BUG][typescript-angular] 7.12.0 refactoring changes behaviour of http params
Mar 31, 2025
I can see that a fix has been implemented, but for my case, serializing the object when a key is provided does not solve the issue.
In the case of having a spring boot appliciation with spring docs generated api spec, using the @pageable annotation for automatic query params resolution cases the query param to get the key "pageable" and in turn telling it to be parsed into json.
Therefore a config would be nice to tell the generator to not JSON.stringify
Description
JS Objects used to be flattened into individual parameters. Now they just get JSON.stringified.
Example:
Page Object:
7.11.0
/api/request?page=1&items=10
7.12.0
/api/request?page={page:1,items:10}
There is no config to set the behaviour to how it was previously.
openapi-generator version
7.11.0
7.12.0
Steps to reproduce
Run openapi-generator with the latest version
Related issues/PRs
This merge causes the issue:
#20681
Suggest a fix
I would suggest to either add a config to enable/disable json http params, or revert the addToHttpParamsRecursive method to how it was previously
The text was updated successfully, but these errors were encountered: