[jaxrs-spec] Emit @Email bean validation for string with format: email
Adds @Email bean-validation support to the jaxrs-spec server generator so that type: string / format: email properties and parameters are validated at runtime, matching the behaviour already provided by the Spring generator.
Background
DefaultCodegen already sets isEmail = true for format: email schemas across every Java generator, but jaxrs-spec's beanValidationCore.mustache never consumed the flag. As a result email fields/parameters were emitted as a plain String with no @Email constraint (documentation-only), unlike Spring which renders @Email.
Change
- emit
@EmailwhenisEmailis set underuseBeanValidation - No new import is required —
javax/jakartapackage is selected automatically (including underuseJakartaEe=true).
PR checklist
- Read the contribution guidelines.
- Run the following to build the project and update samples:
(For Windows users, please run the script in WSL)./mvnw clean package || exit ./bin/generate-samples.sh ./bin/configs/*.yaml || exit ./bin/utils/export_docs_generators.sh || exit
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. - If your PR is targeting a particular programming language, @mention the technical committee members, so they are more likely to review the pull request.
Summary by cubic
Adds @Email bean validation to the jaxrs-spec server generator for type: string with format: email so models and query params are validated at runtime, matching Spring. Active only when useBeanValidation is enabled.
-
New Features
- Emit
@EmailwhenisEmailis set inbeanValidationCore.mustache. - Uses existing wildcard import
{{javaxPackage}}.validation.constraints.*forjavax/jakarta. - Applies to models and query parameters; inherited by all jaxrs-spec libraries.
- Emit
-
Tests
- Expanded
issue_4876_format_email.yamlwith a requiredformat: emailquery parameter; added tests forjavax,jakarta, and disableduseBeanValidation. - Updated
required-and-readonly-property.yamland regenerated thejaxrs-spec-required-and-readonly-propertysample with required/optional email fields to verify@Emailoutput compiles.
- Expanded