Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] Java generator - maven plugin - withXml maven plugin configuration option is not honored during maven build #3839

Closed
RockyMM opened this issue Sep 5, 2019 · 0 comments · Fixed by #18568

Comments

@RockyMM
Copy link
Contributor

RockyMM commented Sep 5, 2019

Description

I used generatorName java with a simple Swagger 3.0 spec file.

I noticed that the withXml option of the Maven plugin is not used. After issuing mvn clean generate-sources the sources are not annotated with @Xml* annotations.

This can be verified with verbose maven pluging configuration option set to true where at the very end of execution I noticed:

"modelDocPath" : "docs/",
  "withXml" : false,
  "scmDeveloperConnection" : "scm:git:git@github.com:openapitools/openapi-generator.git",
  "feignVersion" : "9.x",
  "licenseUrl" : "http://unlicense.org",
  "jsr310" : "true",

To get generated model with @Xml* annotations, I used additionalProperties.

openapi-generator version
            <groupId>org.openapitools</groupId>
            <artifactId>openapi-generator-maven-plugin</artifactId>
            <version>4.1.1</version>

Seems to be working with

			<groupId>io.swagger.codegen.v3</groupId>
			<artifactId>swagger-codegen-maven-plugin</artifactId>
			<version>3.0.11</version>
OpenAPI declaration file content or url

Complete Maven example project: https://github.com/RockyMM/openapi-modelgen-test

Command line used for generation

mvn clean generate-sources

Suggest a fix

After 10 minute search (without cloning openapi-generator) I would start looking in AbstractJavaCodegen class, as the maven plugin class seems to be working correctly. But then again, I am really not not not familiar with the project.

Philzen added a commit to Philzen/openapi-generator that referenced this issue May 3, 2024
Philzen added a commit to Philzen/openapi-generator that referenced this issue May 21, 2024
Philzen added a commit to Philzen/openapi-generator that referenced this issue May 21, 2024
Philzen added a commit to Philzen/openapi-generator that referenced this issue May 26, 2024
wing328 pushed a commit that referenced this issue May 27, 2024
…cs, maven & gradle plugin (#18568)

* Mention that Golang generator also supports XML annotations

Looking at src/main/resources/go/model_simple.mustache and
src/main/java/org/openapitools/codegen/languages/GoClientCodegen.java
the GoLang seems to cater for withXml=true

* Fix maven plugin config description for `withXml`

* Add basic test for global withXml setting

* Use global withXml setting if not configured in ConfigOptions

Resolves #3839 and #5764

* Don't generate metadata or other files when only Models are tested

* Reformat table for readability

* Remove global property `withXml` from generator and docs

* Move WITH_XML constant out of system constants block

Currently there is only a single reference to this value in the whole
codebase (GoClientOptionsProvider). Maybe we should re-think how this
file is organised (i.e. provide a clearer split / mapping / understanding
what are system properties vs. global properties vs. configOptions and
where to put them).

* Remove global option `withXml` from Maven plugin (Breaking change)

This is a "soft" breaking change: Plugin will no longer execute if
user have this option – which is good, b/c it never worked as expected.
We may want to hint this in the 8.0 release notes.

* Remove global property `withXml` from Gradle plugin (Breaking change)

This is a "soft" breaking change: Plugin will no longer execute if
user have this option – which is good, b/c it never worked as expected.
We may want to hint this in the 8.0 release notes, so they can add it
to the `configOptions` map if required, or simply delete it

* Update samples to reflect removed `withXml` property

* Move `withXml` option into ConfigOptions for Java Microprofile sample

* Remove unused local vars and parameters

* Avoid repetition using fluent assertions

* Remove extraneous debug output
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
1 participant