OpenAPITools / OpenAPITools/openapi-generator
[BUG][JAVA] vendorExtension.x-class-extra-annotation doesn't generate lists of annotations correctly
Open
Nobody has claimed this yet.
Issue: Bug
- Dominant language
- Java
- Stars
- 26.8k
- Forks
- 7.7k
- PR merge metrics
- PR metrics pending
Description
Bug Report Checklist
- Have you provided a full/minimal spec to reproduce the issue?
- Have you validated the input using an OpenAPI validator?
- Have you tested with the latest master to confirm the issue still exists?
- Have you searched for related issues/PRs?
- What's the actual output vs expected output?
- [Optional] Sponsorship to speed up the bug fix or feature request (example)
Description
The x-class-extra-annotation vendor extension doesn't generate lists of annotations correctly.
openapi-generator version
7.22.0
OpenAPI declaration file content or url
openapi: 3.0.1
info:
title: x-class-extra-annotation test
version: 0.0.1
paths:
/:
get:
responses:
'200':
description: desc
content:
application/json:
schema:
$ref: '#/components/schemas/User'
components:
schemas:
User:
x-class-extra-annotation:
- '@CustomAnnotationA'
- '@CustomAnnotationB'
properties:
name:
type: string
Generation Details
openapi-generator-cli generate \
-i ./openapi.yaml \
-g java \
-o ./build/generated/openapi \
--global-property models,modelDocs=false,modelTests=false \
--additional-properties=hideGenerationTimestamp=true
Steps to reproduce
- Add the
x-class-extra-annotationfield to your schema using a list of values e.g.
x-class-extra-annotation:
- '@CustomAnnotationA'
- '@CustomAnnotationB'
- Run the generator with the CLI command above
Expected output
@javax.annotation.Generated(...)
@CustomAnnotationA
@CustomAnnotationB
public class User {
// ...
}
Actual output
@javax.annotation.Generated(...)
[@CustomAnnotationA, @CustomAnnotationB]
[@CustomAnnotationA, @CustomAnnotationB]
public class User {
// ...
}
Related issues/PRs
Suggest a fix
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the issue with the provided openapi.yaml and the openapi-generator-cli command using generator version 7.22.0. Trace how the Java generator handles the schema's x-class-extra-annotation list; done means generated User.java contains each annotation once on its own line instead of the list representation.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Quiet
- Clarity
- Clearly specified
- Newbie friendliness
- 68/100