Skip to content
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

x-field-extra-annotation: "@javax.validation.Valid" properties not working when generating JAVA file from YAML #20419

Open
ambilalmca opened this issue Jan 8, 2025 · 0 comments

Comments

@ambilalmca
Copy link

ambilalmca commented Jan 8, 2025

I have a requirement to generate @Valid annotation for all generated DTO files at field level based on my Spec.

Created spec as below.

AccountDetailsRequestBody:
type: object
additionalProperties: false
x-field-extra-annotation: "@javax.validation.Valid"
properties:
payload:
type: object
x-field-extra-annotation: "@javax.validation.Valid"
additionalProperties: false
properties:
accountDetail:
$ref: '#/components/schemas/AccountDetail'

but while generating JAVA DTO file using below command, its not generating this @Valid annotation at field level.

java -Dmodels -DmodelDocs=false -jar openapi-generator-cli.jar generate -i ./input/system-api/common/indicators.yaml -g spring -o output-model/system-api -t ./spring-boot-lombok-actuator -p useActuator=true,useLombok=true,actuatorPath=/actuator

tried with latest version as well such as 6.0.0 and 7.9.0

As confirmed by another thread, its implemented in 6.0.0 itself. but not working.

Main objective is to avoid adding @Valid annotation for all nested objects to perform schema validations for request body object.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant