-
-
Notifications
You must be signed in to change notification settings - Fork 6.5k
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] fix beanvalidation compilation failed when items type in array is int64 #18379
Conversation
cc |
Thanks for the PR! |
sure, I will finish unit tests today, and I found another bug related to beanvalidation package import, adding a config before fixing this bug doesn't seem particularly appropriate here. |
b492202
to
ad46997
Compare
ad46997
to
3715adf
Compare
Tests are added into if (items.get$ref() != null) {
Map<String, Schema> shemas = this.openAPI.getComponents().getSchemas();
String ref = ModelUtils.getSimpleRef(items.get$ref());
if (ref != null) {
Schema<?> schema = shemas.get(ref);
if (schema == null || ModelUtils.isObjectSchema(schema)) {
return "@Valid ";
}
items = schema;
}
} Test result is here: |
tested locally and the output compiles without issues
|
… is int64
fix #18082
Changes:
I changed the getBeanValidation function for AbstractJavaCodegen to align with the logic in beanValidationCore.mustache. Added judgment on Long types.
Tests:
openapi.yaml
run following command to generate:
openapi-generator-cli generate -i openapi.yaml -o test --additional-properties=useBeanValidation=true,useJakartaEe=true -g java
And the code compiled successfully.
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.1.0 minor release - breaking changes with fallbacks),8.0.x
(breaking changes without fallbacks)