fix: normalize Java annotation vendor extension lists

Merged
WI
5mo ago
+306-96

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 supportedLibraries coverage 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 in AbstractJavaCodegen and SpringCodegen; preserves single strings, block scalars, and lists. Also applied to x-implements.
    • Normalize x-class-extra-annotation on models and x-field-extra-annotation on all model properties; normalize x-field-extra-annotation on all operation parameters.
    • In Spring, normalize x-operation-extra-annotation on 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.