-
-
Notifications
You must be signed in to change notification settings - Fork 6.6k
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
Fix #19439 and generated Java code for oneOf/anyOf models and enums #19443
Conversation
Hi @beikov, thanks for the PR! I see in #19439 there's an explanation and sample case for why the condition And finally, could you please have a look at the failing check? Thanks! |
Hi @martin-mfg, sure here is a short description of what the changes are about:
The other two commits are hopefully clear. I will look into the failures now. |
b41e61c
to
b45de4f
Compare
The test failure is due to a test trying to deserialize |
Now there is a failure in the OpenAPI3 tests ( I guess that the desired behavior is the exception though since the OpenAPI3 tests are probably newer. I'll revert my defaulting approach and adapt the old test. |
@@ -23,7 +23,7 @@ | |||
{{#withXml}} | |||
@XmlEnumValue({{#isInteger}}"{{/isInteger}}{{#isDouble}}"{{/isDouble}}{{#isLong}}"{{/isLong}}{{#isFloat}}"{{/isFloat}}{{{value}}}{{#isInteger}}"{{/isInteger}}{{#isDouble}}"{{/isDouble}}{{#isLong}}"{{/isLong}}{{#isFloat}}"{{/isFloat}}) | |||
{{/withXml}} | |||
{{{name}}}({{{value}}}){{^-last}}, | |||
{{{name}}}({{^isUri}}{{^isString}}{{dataType}}.valueOf({{/isString}}{{/isUri}}{{{value}}}{{^isUri}}{{^isString}}){{/isString}}{{/isUri}}){{^-last}}, |
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.
Could you please add to bin/configs/
an example of a case where this change prevents the generation of invalid code?
Btw, I noticed this doesn't work with e.g. type: string ; format: date
. Because the method LocalDate.valueOf
does not exist. Fixing this is not necessary to get this PR merged. But you are of course still very welcome to fix this.
@@ -912,7 +912,7 @@ public boolean isNullTypeSchema(Schema schema) { | |||
} | |||
|
|||
if (schema instanceof JsonSchema) { // 3.1 spec | |||
if (Boolean.TRUE.equals(schema.getNullable())) { | |||
if (Boolean.TRUE.equals(schema.getNullable()) && schema.get$ref() == null) { |
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.
Could you please add to bin/configs/ a small example of a case where this change prevents the generation of invalid code?
Thanks.
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.
I tried long and hard, but couldn't reproduce this within the sample specs. Can you take a look? Just take this spec and you will see the error in e.g. model.RepositoryWebhooks
, where you will see AnyOf license
instead of SimpleLicense license
.
…ull in OpenAPINormalizer#isNullTypeSchema
b45de4f
to
644c46c
Compare
I was finally able to reproduce another issue that I found, which is using |
do you mind opening a separate issue with details to track it? |
The fixes from this PR have been merged via #19815 and #19817. They also solve the problem @beikov mentioned above.
|
I'll close this PR since @martin-mfg addressed all the issues I had with his recent commits. |
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
(upcoming 7.6.0 minor release - breaking changes with fallbacks),8.0.x
(breaking changes without fallbacks)@bbdouglas (2017/07) @sreeshas (2017/08) @jfiala (2017/08) @lukoyanov (2017/09) @cbornet (2017/09) @jeff9finger (2018/01) @karismann (2019/03) @Zomzog (2019/04) @lwlee2608 (2019/10) @martin-mfg (2023/08)