Skip to content

Conversation

@mahmoudzeyada
Copy link
Contributor

Fix: Properly Serialize Query Parameters in OpenAPI Generator for TypeScript NestJS

Issue

The current template assigns query parameters using:

queryParameters['{{baseName}}'] = {{paramName}}.join(COLLECTION_FORMATS['{{collectionFormat}}']);

However, this does not work with URLSearchParams, as it does not allow direct property assignment. Instead, it requires .set() or .append() to properly modify query parameters.

Fix

Replace the assignment with:

queryParameters.append('{{baseName}}', {{paramName}}.join(COLLECTION_FORMATS['{{collectionFormat}}']));

This ensures that query parameters are correctly added and serialized in the request URL.

@mahmoudzeyada mahmoudzeyada force-pushed the fix/typescript-nestjs-query-params branch from 55edc7a to 3b357a2 Compare February 28, 2025 00:01
@wing328
Copy link
Member

wing328 commented Mar 8, 2025

Thanks for the PR but your commit (as shown in the Commits tab) is not linked to your Github account, which means this PR won't count as your contribution in https://github.com/OpenAPITools/openapi-generator/graphs/contributors.

Let me know if you need help fixing it.

Ref: https://github.com/OpenAPITools/openapi-generator/wiki/FAQ#how-can-i-update-commits-that-are-not-linked-to-my-github-account

@wing328
Copy link
Member

wing328 commented Mar 8, 2025

can you please follow step 3 in the PR checklist to update the samples ?

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) @joscha (2024/10)

Copy link
Member

@macjohnny macjohnny left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks for the fix!

@macjohnny
Copy link
Member

@mahmoudzeyada please update the samples

@macjohnny
Copy link
Member

@mahmoudzeyada
Copy link
Contributor Author

Okay I will update

@mahmoudzeyada mahmoudzeyada force-pushed the fix/typescript-nestjs-query-params branch from 3b357a2 to 67c42f9 Compare March 10, 2025 10:02
@mahmoudzeyada
Copy link
Contributor Author

mahmoudzeyada commented Mar 10, 2025

@macjohnny @wing328 updated samples and fixed git author-related error

@macjohnny macjohnny merged commit 21be5f5 into OpenAPITools:master Mar 10, 2025
16 checks passed
kpy3 pushed a commit to kpy3/openapi-generator that referenced this pull request Mar 13, 2025
…penAPITools#20755)

* fix(typescript-nestjs): handle query params serialization properly

* fix(typescript-nestjs): updated the samples for param serialization fix
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants