fix: normalize Java annotation vendor extension lists#24171
Conversation
395f48a to
d261d20
Compare
There was a problem hiding this comment.
5 issues found and verified against the latest diff
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="docs/generators/java-vertx-web.md">
<violation number="1" location="docs/generators/java-vertx-web.md:87">
P2: java-vertx-web generator docs advertise string/list support for `x-class-extra-annotation` and `x-field-extra-annotation`, but the generator's Mustache templates never render these vendor extensions</violation>
<violation number="2" location="docs/generators/java-vertx-web.md:88">
P2: `x-field-extra-annotation` description only mentions 'property' despite being applicable to both `FIELD` and `OPERATION_PARAMETER`. The description should mention both targets to match the applicability column and avoid confusing users about operation-parameter support.</violation>
</file>
<file name="docs/generators/java-undertow-server.md">
<violation number="1" location="docs/generators/java-undertow-server.md:88">
P2: `x-field-extra-annotation` description only mentions 'property' but the extension also applies to `OPERATION_PARAMETER`</violation>
</file>
Reply with feedback, questions, or to request a fix.
Re-trigger cubic
| |x-class-extra-annotation|List of custom annotations to be added to model|MODEL|null | ||
| |x-field-extra-annotation|List of custom annotations to be added to property|FIELD, OPERATION_PARAMETER|null | ||
| |x-class-extra-annotation|Custom annotation(s) to be added to model; accepts a string or list of strings|MODEL|null | ||
| |x-field-extra-annotation|Custom annotation(s) to be added to property; accepts a string or list of strings|FIELD, OPERATION_PARAMETER|null |
There was a problem hiding this comment.
P2: x-field-extra-annotation description only mentions 'property' despite being applicable to both FIELD and OPERATION_PARAMETER. The description should mention both targets to match the applicability column and avoid confusing users about operation-parameter support.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At docs/generators/java-vertx-web.md, line 88:
<comment>`x-field-extra-annotation` description only mentions 'property' despite being applicable to both `FIELD` and `OPERATION_PARAMETER`. The description should mention both targets to match the applicability column and avoid confusing users about operation-parameter support.</comment>
<file context>
@@ -84,8 +84,8 @@ These options may be applied as additional-properties (cli) or configOptions (pl
-|x-class-extra-annotation|List of custom annotations to be added to model|MODEL|null
-|x-field-extra-annotation|List of custom annotations to be added to property|FIELD, OPERATION_PARAMETER|null
+|x-class-extra-annotation|Custom annotation(s) to be added to model; accepts a string or list of strings|MODEL|null
+|x-field-extra-annotation|Custom annotation(s) to be added to property; accepts a string or list of strings|FIELD, OPERATION_PARAMETER|null
</file context>
| |x-field-extra-annotation|Custom annotation(s) to be added to property; accepts a string or list of strings|FIELD, OPERATION_PARAMETER|null | |
| |x-field-extra-annotation|Custom annotation(s) to be added to property or operation parameter; accepts a string or list of strings|FIELD, OPERATION_PARAMETER|null |
| |x-content-type|Specify custom value for 'Content-Type' header for operation|OPERATION|null | ||
| |x-class-extra-annotation|List of custom annotations to be added to model|MODEL|null | ||
| |x-field-extra-annotation|List of custom annotations to be added to property|FIELD, OPERATION_PARAMETER|null | ||
| |x-class-extra-annotation|Custom annotation(s) to be added to model; accepts a string or list of strings|MODEL|null |
There was a problem hiding this comment.
P2: java-vertx-web generator docs advertise string/list support for x-class-extra-annotation and x-field-extra-annotation, but the generator's Mustache templates never render these vendor extensions
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At docs/generators/java-vertx-web.md, line 87:
<comment>java-vertx-web generator docs advertise string/list support for `x-class-extra-annotation` and `x-field-extra-annotation`, but the generator's Mustache templates never render these vendor extensions</comment>
<file context>
@@ -84,8 +84,8 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|x-content-type|Specify custom value for 'Content-Type' header for operation|OPERATION|null
-|x-class-extra-annotation|List of custom annotations to be added to model|MODEL|null
-|x-field-extra-annotation|List of custom annotations to be added to property|FIELD, OPERATION_PARAMETER|null
+|x-class-extra-annotation|Custom annotation(s) to be added to model; accepts a string or list of strings|MODEL|null
+|x-field-extra-annotation|Custom annotation(s) to be added to property; accepts a string or list of strings|FIELD, OPERATION_PARAMETER|null
</file context>
There was a problem hiding this comment.
Again, pre-existing issue worth fixing as a separate PR.
| |x-class-extra-annotation|List of custom annotations to be added to model|MODEL|null | ||
| |x-field-extra-annotation|List of custom annotations to be added to property|FIELD, OPERATION_PARAMETER|null | ||
| |x-class-extra-annotation|Custom annotation(s) to be added to model; accepts a string or list of strings|MODEL|null | ||
| |x-field-extra-annotation|Custom annotation(s) to be added to property; accepts a string or list of strings|FIELD, OPERATION_PARAMETER|null |
There was a problem hiding this comment.
P2: x-field-extra-annotation description only mentions 'property' but the extension also applies to OPERATION_PARAMETER
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At docs/generators/java-undertow-server.md, line 88:
<comment>`x-field-extra-annotation` description only mentions 'property' but the extension also applies to `OPERATION_PARAMETER`</comment>
<file context>
@@ -84,8 +84,8 @@ These options may be applied as additional-properties (cli) or configOptions (pl
-|x-class-extra-annotation|List of custom annotations to be added to model|MODEL|null
-|x-field-extra-annotation|List of custom annotations to be added to property|FIELD, OPERATION_PARAMETER|null
+|x-class-extra-annotation|Custom annotation(s) to be added to model; accepts a string or list of strings|MODEL|null
+|x-field-extra-annotation|Custom annotation(s) to be added to property; accepts a string or list of strings|FIELD, OPERATION_PARAMETER|null
</file context>
| |x-field-extra-annotation|Custom annotation(s) to be added to property; accepts a string or list of strings|FIELD, OPERATION_PARAMETER|null | |
| |x-field-extra-annotation|Custom annotation(s) to be added to property or operation parameter; accepts a string or list of strings|FIELD, OPERATION_PARAMETER|null |
…le and multiple values
d261d20 to
2470265
Compare
Continuation of #23750.
This keeps the original fix for
x-class-extra-annotationand addresses the review feedback by:supportedLibrariescoverage for Java client model annotationsFocused test run:
./mvnw -pl modules/openapi-generator -am -Dtest=JavaClientCodegenTest#testAllOfClassWithAnnotations,SpringCodegenTest#testAllOfClassWithAnnotations -Dsurefire.failIfNoSpecifiedTests=false testAlso 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, andx-operation-extra-annotationaccept 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.DefaultCodegen.normalizeVendorExtensionWithStringListand used it inAbstractJavaCodegenandSpringCodegen; preserves single strings, block scalars, and lists. Also applied tox-implements.x-class-extra-annotationon models andx-field-extra-annotationon all model properties; normalizex-field-extra-annotationon all operation parameters.x-operation-extra-annotationon operations and parameter annotations.Written for commit 2470265. Summary will update on new commits.