-
-
Notifications
You must be signed in to change notification settings - Fork 7.2k
[Java] [Spring] Use deduction configOptions for oneOfInterfaces #20919
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
[Java] [Spring] Use deduction configOptions for oneOfInterfaces #20919
Conversation
# Conflicts: # modules/openapi-generator-cli/pom.xml # modules/openapi-generator-core/pom.xml # modules/openapi-generator-gradle-plugin/pom.xml # modules/openapi-generator-maven-plugin/pom.xml # modules/openapi-generator-online/pom.xml # modules/openapi-generator/pom.xml # modules/openapi-generator/src/test/java/org/openapitools/codegen/java/spring/SpringCodegenTest.java # pom.xml
# Conflicts: # pom.xml
# Conflicts: # bin/configs/java-okhttp-user-defined-templates.yaml # modules/openapi-generator/src/main/resources/php-flight/register_routes.mustache # modules/openapi-generator/src/main/resources/php-flight/register_routes_test.mustache # modules/openapi-generator/src/test/java/org/openapitools/codegen/DefaultCodegenTest.java # modules/openapi-generator/src/test/resources/3_0/python/petstore-with-fake-endpoints-models-for-testing.yaml # modules/openapi-generator/src/test/resources/3_0/spring/issue_18340.yaml # samples/client/echo_api/java/okhttp-gson-user-defined-templates/.github/workflows/maven.yml # samples/client/echo_api/java/okhttp-gson-user-defined-templates/.openapi-generator/FILES # samples/client/echo_api/java/okhttp-gson-user-defined-templates/gradle/wrapper/gradle-wrapper.jar # samples/client/echo_api/java/okhttp-gson-user-defined-templates/gradle/wrapper/gradle-wrapper.properties # samples/client/echo_api/java/okhttp-gson-user-defined-templates/gradlew # samples/client/echo_api/java/okhttp-gson-user-defined-templates/gradlew.bat # samples/client/echo_api/java/okhttp-gson-user-defined-templates/info.md # samples/openapi3/client/petstore/python/tests/test_model.py # samples/server/petstore/php-flight/RegisterRoutes.php # samples/server/petstore/php-flight/Test/RegisterRoutesTest.php
# Conflicts: # modules/openapi-generator/src/test/java/org/openapitools/codegen/java/JavaClientCodegenTest.java
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
small improvements
Merge master
…into useDeductionForOneOfInterfaces # Conflicts: # modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/SpringCodegen.java
Merge master
Add comment to force rebuild
@martin-mfg thanks for the PR. I've merged your changes and master When this PR is merged by @wing328 I will implement the samedi Deduction mechanism for java client using Jackson |
Hey there, i was looking for an usage of |
Hi @rqton Unfortunately this PR is not merged. Not sure why because it works. In the meantime I use templateDir to override the spring oneof_interface.mustache.
|
@jpfinne sorry for late review as there are too many PRs can you resolve the merge conflicts when you've time? I'll try to get it merged and included in the upcoming release. |
@@ -0,0 +1,12 @@ | |||
generatorName: spring | |||
outputDir: samples/openapi3/server/petstore/spring-boot-oneof-interface |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what about adding this to the github workflow so that it will be tested moving forward?
https://github.com/OpenAPITools/openapi-generator/blob/master/.github/workflows/samples-spring.yaml
https://github.com/OpenAPITools/openapi-generator/blob/master/.github/workflows/samples-spring-jdk17.yaml
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@wing328 I did not know about this.
Maybe something to add to https://github.com/openapitools/openapi-generator/blob/master/CONTRIBUTING.md
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@wing328 any chance that this PR get merged?
# Conflicts: # modules/openapi-generator/src/main/resources/JavaSpring/oneof_interface.mustache
@wing328 is there something missing in this PR? |
Just merged. Sorry for the delay Thanks for the PR as always |
Fix #20891
Add a new configOption to the spring generator:
useOneOfInterfacesDeduction
When useOneOfInterfaces=true
it allows the generation of an additional annotation on the generated inferface
@JsonTypeInfo(use = JsonTypeInfo.Id.DEDUCTION)
and the necessary @JsonSubTypes
PR checklist
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.
master
(upcoming7.x.0
minor release - breaking changes with fallbacks),8.0.x
(breaking changes without fallbacks)@cachescrubber (2022/02) @welshm (2022/02) @MelleD (2022/02) @atextor (2022/02) @manedev79 (2022/02) @javisst (2022/02) @borsch (2022/02) @banlevente (2022/02) @Zomzog (2022/09) @martin-mfg (2023/08)