fix: normalize Java annotation vendor extension lists
Merged
WI
5mo ago+306+306+012345678901234567890123456789-96-96-01234567890123456789
Continuation of #23750.
This keeps the original fix for x-class-extra-annotation and addresses the review feedback by:
- moving string/list normalization into a reusable shared helper
- applying normalization to Java/Spring class, field/parameter, and operation annotation vendor extensions
- preserving backward compatibility for scalar strings, block scalar strings, one-element lists, and multi-element lists
- merging duplicate tests and using
supportedLibrariescoverage for Java client model annotations - adding Spring coverage for class, field, operation, and parameter annotations
- updating vendor extension descriptions and generated generator docs
Focused test run:
./mvnw -pl modules/openapi-generator -am -Dtest=JavaClientCodegenTest#testAllOfClassWithAnnotations,SpringCodegenTest#testAllOfClassWithAnnotations -Dsurefire.failIfNoSpecifiedTests=false test
Also regenerated the affected Spring oneOf samples to confirm no generated sample diff remains.
Summary by cubic
Normalize Java annotation vendor extensions so x-class-extra-annotation, x-field-extra-annotation, and x-operation-extra-annotation accept a string or a list, and each annotation is rendered on its own line. Applies across Java and Spring generators for models, properties/parameters, and operations.
- Bug Fixes
- Added
DefaultCodegen.normalizeVendorExtensionWithStringList(with Javadocs) and used it inAbstractJavaCodegenandSpringCodegen; preserves single strings, block scalars, and lists. Also applied tox-implements. - Normalize
x-class-extra-annotationon models andx-field-extra-annotationon all model properties; normalizex-field-extra-annotationon all operation parameters. - In Spring, normalize
x-operation-extra-annotationon operations and parameter annotations. - Updated mustache templates to iterate and emit each annotation line.
- Updated generator docs to state accepted types; added tests covering Java libraries and Spring for class, property, operation, and parameter annotations.
- Added