OpenAPITools / OpenAPITools/openapi-generator
[BUG][JAVA] jaxrs-cxf producing xml annotations with enum (instead of json)
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 26.8k
- Forks
- 7.7k
- PR merge metrics
- PR metrics pending
Description
Description
Java enums are produced with annotations of javax.xml.bind.annotation.* whereas it should be com.fasterxml.jackson.annotation.* only. But those JSON annotations are missing, though it’s jax-rs!
File which contains the bug
This is our current workaround, instead of type: string / enum: [a,b,c] we are putting a reference to a schema.

Only with this workaround annotations are produced correctly.
in pom.xml
<plugin>
<groupId>org.openapitools</groupId>
<artifactId>openapi-generator-maven-plugin</artifactId>
<version>4.2.2</version>
<executions>
<execution>
<id>myid</id>
<goals>
<goal>generate</goal>
</goals>
<configuration>
<inputSpec>${project.basedir}/../api/example.yaml</inputSpec>
<generatorName>jaxrs-cxf</generatorName>
<generateApis>false</generateApis>
<generateApiTests>false</generateApiTests>
<generateApiDocumentation>false</generateApiDocumentation>
<generateModels>true</generateModels>
<generateModelTests>false</generateModelTests>
<generateModelDocumentation>false</generateModelDocumentation>
<invokerPackage>mypackage.invoker</invokerPackage>
<apiPackage>mypackage.api</apiPackage>
<modelPackage>mypackage.model</modelPackage>
<output>${project.basedir}</output>
<withXml>false</withXml>
<configOptions>
<java8>true</java8>
<dateLibrary>java8</dateLibrary>
<generateNonSpringApplication>true</generateNonSpringApplication>
<useBeanValidationFeature>true</useBeanValidationFeature>
<useBeanValidation>false</useBeanValidation>
<useAnnotatedBasePath>true</useAnnotatedBasePath>
</configOptions>
</configuration>
</execution>
</executions>
</plugin>
Related issues/PRs
Maybe the bug has been mentioned here
https://github.com/swagger-api/swagger-codegen/issues/4160
But that’s been Nov 8, 2016 and that time it was for swagger-codegen.
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 with modules/openapi-generator/src/main/resources/JavaJaxRS/cxf/enumClass.mustache and inspect how enum annotations are selected for the jaxrs-cxf generator. Reproduce generation using the enum schema described in the issue, then verify the generated enum uses the expected Jackson annotations without the unintended JAXB XML annotations.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- api, backend
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 45/100