Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[kotlin][client] Explode query param properly #20714

Conversation

maksim-kosolapov
Copy link
Contributor

@maksim-kosolapov maksim-kosolapov commented Feb 23, 2025

Problem

It's not possible to use request objects in the API (e.g. findItems(SearchRequest(name, status, fromDate, ...))). One more example is a pagination parameter, something like Page(size,offset). I'd like to use a model in the API but it's not possible at the moment.

Kotlin Client generator is not exploding a query object properly. It uses the object toString() method, so API request doesn't work. See OpenAPI Parameter Serialization.

Used isModel, isDeepObject, vars template variables to fill localVariableQuery with the fields of the query object.

It should work fine for objects with primitive, enum, date props. The behavior for nested objects and arrays is undefined (And it is mentioned in the doc)

The generated QueryApi.kt sample from the echo-api shows the expected query parameters.

To close #20715

CC: @dr4ke616 @karismann @Zomzog @andrewemery @4brunu @yutaka0m @stefankoppier @e5l

PR checklist
  • Read the contribution guidelines.
  • 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.
  • Run the following to build the project and update samples:
    ./mvnw clean package || exit
    ./bin/generate-samples.sh ./bin/configs/*.yaml || exit
    ./bin/utils/export_docs_generators.sh || exit
    
    (For Windows users, please run the script in Git BASH)
    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 ./bin/generate-samples.sh bin/configs/java*.
    IMPORTANT: Do NOT purge/delete any folders/files (e.g. tests) when regenerating the samples as manually written tests may be removed.
  • File the PR against the correct branch: master (upcoming 7.x.0 minor release - breaking changes with fallbacks), 8.0.x (breaking changes without fallbacks)
  • If your PR is targeting a particular programming language, @mention the technical committee members, so they are more likely to review the pull request.

@maksim-kosolapov maksim-kosolapov force-pushed the kotlin-client-query-params-explode-object branch from 3c3476f to 8391747 Compare February 25, 2025 07:43
@maksim-kosolapov
Copy link
Contributor Author

maksim-kosolapov commented Feb 25, 2025

image

@dr4ke616 @karismann @Zomzog @andrewemery @4brunu @yutaka0m @stefankoppier @e5l or anybody, hey folks! could you explain what does this message mean? I'm curious if it's a blocker for review

@wing328 wing328 merged commit 09df015 into OpenAPITools:master Feb 26, 2025
19 checks passed
@wing328
Copy link
Member

wing328 commented Feb 26, 2025

thanks for the PR, which has been merged

@maksim-kosolapov
Copy link
Contributor Author

thanks for the PR, which has been merged

Thanks for looking into it.

qq: does the above "Merging is blocked" just say me that I have no permissions to merge? The message is unclear then, it looks like there are some settings in the repo blocking merge)

@wing328
Copy link
Member

wing328 commented Feb 26, 2025

i would think so

(i don't see this message in my side as i've the merge right)

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.

[BUG] [Kotlin][Client] Query params are not exploded properly.
2 participants