-
-
Notifications
You must be signed in to change notification settings - Fork 6.7k
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] [Microprofile] Add Json-B polymorphism type info annotations #20164
Conversation
It seems like the JsonNullable in the equals is actually not the problem. As soon as Edit: I completely disabled openApiNullable for the Microprofile generator - doesn't make sense to allow this to be |
import {{rootJavaEEPackage}}.json.bind.annotation.JsonbSubtype; | ||
import {{rootJavaEEPackage}}.json.bind.annotation.JsonbTransient; | ||
import {{rootJavaEEPackage}}.json.bind.annotation.JsonbTypeInfo; | ||
{{/jsonbPolymorphism}} | ||
import {{rootJavaEEPackage}}.json.bind.annotation.JsonbCreator; |
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.
The JsonbCreator import was previously never included, the vendorExtensions.x-has-readonly-properties
is only available in the #model
context I think. For Jackson the import only work because it is added in the #imports
.
Not sure why that one CircleCI check fails on some Go test, seems to be unrelated/random? This is ready for review now |
restarted the failed job. let's see how that goes |
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.
Thanks for the PR! It mostly looks good to me. I have only one small comment:
@@ -10,3 +10,4 @@ additionalProperties: | |||
microprofileRestClientVersion: "3.0" | |||
hideGenerationTimestamp: true | |||
useReflectionEqualsHashCode: true | |||
openApiNullable: false |
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.
This can be removed now, since openApiNullable is being disabled for microprofile. Same comment applies to bin/configs/java-microprofile-rest-client-3.0.yaml
.
Thanks for the review! |
Upgraded to openapi generator version 7.11. One of our issues was fixed in this version but we got two new issues back for which I added workarounds.. It looks like both are caused by the new support for JSON-B polymorphism type annotations introduced by OpenAPITools/openapi-generator#20164: Solves PZ-5160
Adds JSON-B type info annotations for the Microprofile library (and Jackson, it seems like type info was generally missing for micrprofile?).
I only added support for MP version 3.0 since the polymorphism stuff requires Jakarta Json Binding version 3 and therefore required jakarta namespace etc.
The reason I'm not simply checking for
microprofile3
in the typeInfoAnnotation template is that it is placed in the Java directory and used by multiple libraries. So I decided to add a more general propertyjsonbPolymorphism
that could also be used in other libraries. It indicates that at least version 3 of the json bind API is used.Since none of the existing configs for the samples used a spec where these annotation could come into play, I changed one Jackson and one Json-B config to use an other petstore spec that does have polymorphism.
With that I also noticed a "bug" in the equals introduced in #20011. It seems like Microprofile does not support JsonNullable and therefore the dependency is missing.
The JsonNullable should probably be removed from the equals, I'll create an issue for that.-> disabled openApiNullable for MP library instead since it is not supported anywayThis PR relates to the request in #12343 – but there are more generators that use JSON-B that would need to be implemented.
For the "java" generator, there are many mentions of jsonb in the templates of various libraries, but at the moment, only Microprofile supports it. So the change to the typeInfoAnnotations template in the java directory should not affect any other library at the moment.
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)