swagger-api / swagger-api/swagger-codegen
[JAVA][maven-plugin]When used with Jersey2 and withXml true, required jackson-dataformat-xml dependency is missing in pom
Nobody has claimed this yet.
- Dominant language
- Mustache
- Stars
- 17.8k
- Forks
- 6k
- PR merge metrics
- No merged PRs in 30d
Description
Description
When the maven plugin is used to generate the client classes with jersey2 as the library and withXml option as true.
The following import is done in model
import com.fasterxml.jackson.dataformat.xml.annotation.*;
for using @JacksonXmlProperty(localName = "id")
But the dependency is missing in the pom.xml and the build.gradle files generated
Only jaxb dependency gets added into the pom
Not sure if it should be in the build.gradle also
I can see the corresponding mustache that the jacksin-dataformat is missing
https://github.com/swagger-api/swagger-codegen/blob/068b1ebcb7b04a48ad38f1cadd24bb3810c9f1ab/modules/swagger-codegen/src/main/resources/Java/libraries/jersey2/pom.mustache#L251
I don't see withXML conditional in the gradle mustace - https://github.com/swagger-api/swagger-codegen/blob/068b1ebcb7b04a48ad38f1cadd24bb3810c9f1ab/modules/swagger-codegen/src/main/resources/Java/libraries/jersey2/build.gradle.mustache
Swagger-codegen version
2.3.1
Not sure if it is a regression
Swagger declaration file content or url
Not able to provide
Command line used for generation
Java codegen from swagger.json input through maven plugin
XXX for used for some obfuscation for confidentiality
<configuration>
<inputSpec>${project.basedir}/target/swagger/swagger.json</inputSpec>
<output>target/swagger/client</output>
<language>java</language>
<configOptions>
<apiPackage>XXX</apiPackage>
<modelPackage>XXX</modelPackage>
<invokerPackage>XXX</invokerPackage>
<generateApiDocs>false</generateApiDocs>
<generateModelDocs>false</generateModelDocs>
<generateApiTests>false</generateApiTests>
<generateModelTests>false</generateModelTests>
<dateLibrary>java8</dateLibrary>
<library>jersey2</library>
<withXml>true</withXml>
</configOptions>
</configuration>
Steps to reproduce
Use codege maven plugin to generate a client for Java with library jersey2 and withXml enabled as shown above
Related issues/PRs
https://github.com/swagger-api/swagger-codegen/pull/5962
Suggest a fix/enhancement
Change the mustache files to include the required libraries
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
Inspect modules/swagger-codegen/src/main/resources/Java/libraries/jersey2/pom.mustache and build.gradle.mustache, focusing on the withXml condition and existing JAXB dependency handling. Confirm that generated Jersey2 Java clients with withXml enabled include jackson-dataformat-xml in both build files, then verify the generated build configuration resolves the referenced Jackson XML annotations.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- build-system
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 35/100