[#12887] typescript-axios: object as query parameter resolved
This pr is a solution to an open issue https://github.com/OpenAPITools/openapi-generator/issues/12887.
With nested object, the leaf key-value pairs are taken and parent key is ignored. For ex:
{ pagenation: { size: 10, page: 1, }, query: "searchText" }
will be sent as url?query=searchText&page=1&size=10
@mkusaka @davidgamero kindly review the changes if they are at the right place. Thanks!
PR checklist
- [x] Read the contribution guidelines.
- [x] Pull Request title clearly describes the work in the pull request and Pull Request description provides details about how to validate the work. Missing information here may result in delayed response from the community.
- [x] Run the following to build the project and update samples:
Commit all changed files. This is important, as CI jobs will verify all generator outputs of your HEAD commit as it would merge with master. These must match the expectations made by your contribution. You may regenerate an individual generator by passing the relevant config(s) as an argument to the script, for example./mvnw clean package ./bin/generate-samples.sh ./bin/utils/export_docs_generators.sh./bin/generate-samples.sh bin/configs/java*. For Windows users, please run the script in Git BASH. - [x] File the PR against the correct branch:
master(6.1.0) (minor release - breaking changes with fallbacks),7.0.x(breaking changes without fallbacks) - [x] If your PR is targeting a particular programming language, @mention the technical committee members, so they are more likely to review the pull request.
cc @TiFu (2017/07) @taxpon (2017/07) @sebastianhaas (2017/07) @kenisteward (2017/07) @Vrolijkx (2017/09) @macjohnny (2018/01) @topce (2018/10) @akehir (2019/07) @petejohansonxo (2019/11) @amakhrov (2020/02) @davidgamero (2022/03) @mkusaka (2022/04)
IIRC the current behavior was intentional initially and now we cant change this without breaking backwards compatibility
maybe we can introduce a flag if this new behavior is important
@macjohnny Thanks for pointing it out. I have updated the code to support backward compatibility.
setSearchParams( url, { stand: 123 }, { sit: 654 }, { sit: [{ flip: 123, stand: 456 }] }, { sit: [1, 2, 3, 4] } )
will produce below params
?stand=123&sit=654&flip=123&stand=456&sit=1&sit=2&sit=3&sit=4
Here is a link to my code sandbox to try out different cases.
thanks for updating the PR can you give a small example what problem it is now trying to solve? i.e. what is the input schema, resulting code before and after?
@macjohnny below is the brief description:
In our index.yml we have an API path as below:

Parameter pageable has below schema

so during the api call, setSearchParams function was hit with params setSearchParams( url, {pageable: {size:10, page: 2}}), which was eventually making an api call as /cool/api/?pageable=%5Bobject+Object%5D. Clearly, this does not have the desired parameters as our actual parameters are lost.
With this solution, the API is hit as /cool/api/?size=10&page=2, which has the desired parameters.
@shubham-lakhiwal can you please re-generate the samples?
@macjohnny thanks for reviewing it. Sorry for not converting into draft.
@macjohnny I am sorry to bring this up late. A small bug was left behind in this pull request by the last commit. There is another pull request for the fix. Kindly review. https://github.com/OpenAPITools/openapi-generator/pull/13149