-
-
Notifications
You must be signed in to change notification settings - Fork 7.3k
[kotlin-spring] Support model objects and date-time query params #8257
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-spring] Support model objects and date-time query params #8257
Conversation
|
👍 Thanks for opening this issue! The team will review the labels and make any necessary changes. |
|
I added another commit that adds date/date-time support to this PR, as opening a separate PR would immediately result in a merge conflict, since both commits modify the one-line file |
4f13591 to
f3ff42b
Compare
f3ff42b to
d41922b
Compare
|
I re-pushed the commits since circleci failed to download dependencies last time. |
|
I'll try to test it out later this week. Thanks for the PR. |
adopted OpenAPITools#3860 for kotlin-spring
d41922b to
da2a75d
Compare
|
Thanks. The labels do not make sense in my opinion, as it neither adds a new generator, nor is it related to ktorm? |
|
Fixed the label. |
|
Any news on this? |
|
@sburnicki sorry we're busy with v5.1.0 release (which was published recently). Can you please resolve the merge conflicts and PM me via Slack when this PR is ready for another review? Thanks. |
|
When this fix will be merged? We had to use java version of spring generator to get around of this bug(( Using kotlin generator is preferable as produced dto's has nullable/notnullable types. Maybe you need some help? |
|
I also used workarounds since this wasn't merged and then forgot about this PR. I didn't notice the update from wing328 to be honest. I'm quite busy at the moment and have no idea when I will be able to pick up the work. |
|
How can I fix conflict in foreign fork? Only option that I see is to make new fork, move all changes there and crate new PR) |
|
I gave you access to my fork, it's not used for anything else anyway. |
…in-spring-support-objects-inquery-param # Conflicts: # modules/openapi-generator/src/main/resources/kotlin-spring/queryParams.mustache # modules/openapi-generator/src/test/java/org/openapitools/codegen/kotlin/spring/KotlinSpringServerCodegenTest.java
|
Done 😉 |
|
@wing328 This seems to be ready then :) |
|
I'll try to review and test tomorrow. Thanks again for the PR. |
|
@wing328 how is it going then? The build doesn't seem to work for reasons not related to the PR itself. Would be happy to see this merged. |
|
Tested locally and didn't spot issues related to this change. Found an issue with the auto-generated test file thought. Will file a PR to fix it separately. Thanks again for the PR and sorry for the delay in reviewing. |
These commits add support for two things:
@RequestParamannotation, if the query param is not a model.I added test cases adopted from the java spring codegen, which had the same issues (see linked issues and PRs in #8080) and tested the changes locally.
Manually test changes
Tests for model object params
Generate code based on one of the existing examples before the PR:
and make
/tmp/openapi/8080/src/main/kotlin/org/openapitools/api/PonyApi.ktreturn the following:also modify the return type and test to compile. After running
mvn spring-boot:run, you can query via curl:which won't return anything, as
pageQueryisnull.After this PR, run the same steps again. Executing the curl command will correctly return
{"offset":1,"limit":2}, sincespring was able to parse the parameters as a valid
pageQueryobject.Steps for date-time params
Same procedure as above:
Generate code for
src/test/resources/3_0/issue_2053.yaml:java -jar modules/openapi-generator-cli/target/openapi-generator-cli.jar generate -g kotlin-spring \ -i modules/openapi-generator/src/test/resources/3_0/issue_2053.yaml \ -o /tmp/openapi/datetime/ \ --skip-validate-specTest with curl:
Both requests fail with HTTP 400, since Spring cannot parse the parameters.
After the PR, repeat the same steps, both requests will return HTTP 501 (not implemented) and not fail anymore.
PR checklist
./bin/generate-samples.shto update all Petstore samples related to your fix. 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*. For Windows users, please run the script in Git BASH.master,5.1.x,6.0.xPlease review:
@jimschubert (2017/09), @dr4ke616 (2018/08) @karismann (2019/03) @Zomzog (2019/04) @andrewemery (2019/10) @4brunu (2019/11) @yutaka0m (2020/03)