Skip to content

Commit

Permalink
[General] Remove defunct global property withXml from generator, do…
Browse files Browse the repository at this point in the history
…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
  • Loading branch information
Philzen committed May 27, 2024
1 parent 258b7af commit 9c999b6
Show file tree
Hide file tree
Showing 21 changed files with 234 additions and 258 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ outputDir: samples/client/petstore/java/microprofile-rest-client-3.0-jackson-wit
library: microprofile
inputSpec: modules/openapi-generator/src/test/resources/3_0/petstore.yaml
templateDir: modules/openapi-generator/src/main/resources/Java
withXml: true
additionalProperties:
serializationLibrary: jackson
artifactId: microprofile-rest-client-3-jackson-with-xml
configKey: petstore
microprofileRestClientVersion: "3.0"
hideGenerationTimestamp: true
withXml: true
33 changes: 16 additions & 17 deletions docs/global-properties.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,23 +5,22 @@ title: Global Properties

## Available Global Properties

| Property | Description | Acceptable value |
| -------- | ------------| ---------------- |
| debugOpenAPI | Dumps JSON formatted and fully parsed OpenAPI document during generation | none |
| debugModels | Dumps JSON formatted template-bound model information during generation | none |
| debugOperations | Dumps JSON formatted template-bound operation information during generation | none |
| debugSupportingFiles | Dumps JSON formatted Supporting File information during generation | none |
| verbose | Defines the verbosity | `true` or `false` |
| generateAliasAsModel | Defines whether primitive types defined at the model/schema level will be wrapped in a model | `true` or `false` |
| org.openapitools.codegen.utils.oncelogger.enabled | Enable/disable the "OnceLogger" which reduces noise for select repeated logs | `true` or `false` |
| supportingFiles | Allows the user to define which supporting files will be generated. Prefer using the more robust `.openapi-generator-ignore`. | no value, or a colon-separated string of file names |
| models | Allows the user to define which models will be generated. Prefer using the more robust `.openapi-generator-ignore`. | no value, or a colon-separated string of model names |
| apis | Allows the user to define which apis will be generated. Prefer using the more robust `.openapi-generator-ignore`. | no value, or a colon-separated string of api names |
| apiDocs | Allows the user to define if api docs will be generated. Prefer using the more robust `.openapi-generator-ignore`. | `true` or `false` |
| modelDocs | Allows the user to define if model docs will be generated. Prefer using the more robust `.openapi-generator-ignore`. | `true` or `false` |
| apiTests | Allows the user to define if api tests will be generated. Prefer using the more robust `.openapi-generator-ignore`. | `true` or `false` |
| modelTests | Allows the user to define if model tests will be generated. Prefer using the more robust `.openapi-generator-ignore`. | `true` or `false` |
| withXml | Allows the user to control support of XML generated constructs, where supported | none |
| Property | Description | Acceptable value |
|---------------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------|------------------------------------------------------|
| debugOpenAPI | Dumps JSON formatted and fully parsed OpenAPI document during generation | none |
| debugModels | Dumps JSON formatted template-bound model information during generation | none |
| debugOperations | Dumps JSON formatted template-bound operation information during generation | none |
| debugSupportingFiles | Dumps JSON formatted Supporting File information during generation | none |
| verbose | Defines the verbosity | `true` or `false` |
| generateAliasAsModel | Defines whether primitive types defined at the model/schema level will be wrapped in a model | `true` or `false` |
| org.openapitools.codegen.utils.oncelogger.enabled | Enable/disable the "OnceLogger" which reduces noise for select repeated logs | `true` or `false` |
| supportingFiles | Allows the user to define which supporting files will be generated. Prefer using the more robust `.openapi-generator-ignore`. | no value, or a colon-separated string of file names |
| models | Allows the user to define which models will be generated. Prefer using the more robust `.openapi-generator-ignore`. | no value, or a colon-separated string of model names |
| apis | Allows the user to define which apis will be generated. Prefer using the more robust `.openapi-generator-ignore`. | no value, or a colon-separated string of api names |
| apiDocs | Allows the user to define if api docs will be generated. Prefer using the more robust `.openapi-generator-ignore`. | `true` or `false` |
| modelDocs | Allows the user to define if model docs will be generated. Prefer using the more robust `.openapi-generator-ignore`. | `true` or `false` |
| apiTests | Allows the user to define if api tests will be generated. Prefer using the more robust `.openapi-generator-ignore`. | `true` or `false` |
| modelTests | Allows the user to define if model tests will be generated. Prefer using the more robust `.openapi-generator-ignore`. | `true` or `false` |


## Note on Global Property declaration
Expand Down
5 changes: 0 additions & 5 deletions modules/openapi-generator-gradle-plugin/README.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -389,11 +389,6 @@ apply plugin: 'org.openapi.generator'
|true
|Defines whether or not api-related _documentation_ files should be generated.

|withXml
|Boolean
|false
|A special-case setting which configures some generators with XML support. In some cases, this forces json OR xml, so the default here is false.

|configOptions
|Map(String,String)
|None
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,6 @@ class OpenApiGeneratorPlugin : Plugin<Project> {
generateModelDocumentation.set(generate.generateModelDocumentation)
generateApiTests.set(generate.generateApiTests)
generateApiDocumentation.set(generate.generateApiDocumentation)
withXml.set(generate.withXml)
configOptions.set(generate.configOptions)
logToStderr.set(generate.logToStderr)
enablePostProcessFile.set(generate.enablePostProcessFile)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -342,12 +342,6 @@ open class OpenApiGeneratorGenerateExtension(project: Project) {
*/
val generateApiDocumentation = project.objects.property<Boolean>()

/**
* A special-case setting which configures some generators with XML support. In some cases,
* this forces json OR xml, so the default here is false.
*/
val withXml = project.objects.property<Boolean>()

/**
* To write all log messages (not just errors) to STDOUT
*/
Expand Down Expand Up @@ -408,7 +402,6 @@ open class OpenApiGeneratorGenerateExtension(project: Project) {
generateModelDocumentation.set(true)
generateApiTests.set(true)
generateApiDocumentation.set(true)
withXml.set(false)
configOptions.set(mapOf())
validateSpec.set(true)
logToStderr.set(false)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -506,14 +506,6 @@ open class GenerateTask @Inject constructor(private val objectFactory: ObjectFac
@Input
val generateApiDocumentation = project.objects.property<Boolean>()

/**
* A special-case setting which configures some generators with XML support. In some cases,
* this forces json OR xml, so the default here is false.
*/
@Optional
@Input
val withXml = project.objects.property<Boolean>()

/**
* To write all log messages (not just errors) to STDOUT
*/
Expand Down Expand Up @@ -680,10 +672,6 @@ open class GenerateTask @Inject constructor(private val objectFactory: ObjectFac
GlobalSettings.setProperty(CodegenConstants.API_TESTS, generateApiTests.get().toString())
}

if (withXml.isPresent) {
GlobalSettings.setProperty(CodegenConstants.WITH_XML, withXml.get().toString())
}

if (inputSpec.isPresent && remoteInputSpec.isPresent) {
logger.warn("Both inputSpec and remoteInputSpec is specified. The remoteInputSpec will take priority over inputSpec.")
}
Expand Down
1 change: 0 additions & 1 deletion modules/openapi-generator-maven-plugin/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,6 @@ mvn clean compile
| `generateModelDocumentation` | `openapi.generator.maven.plugin.generateModelDocumentation` | generate the model documentation (`true` by default. Only available if `generateModels` is `true`)
| `generateApiTests` | `openapi.generator.maven.plugin.generateApiTests` | generate the api tests (`true` by default. Only available if `generateApis` is `true`)
| `generateApiDocumentation` | `openapi.generator.maven.plugin.generateApiDocumentation` | generate the api documentation (`true` by default. Only available if `generateApis` is `true`)
| `withXml` | `openapi.generator.maven.plugin.withXml` | enable XML annotations inside the generated models and API (only works with Java `language` and libraries that provide support for JSON and XML)
| `skip` | `codegen.skip` | skip code generation (`false` by default. Can also be set globally through the `codegen.skip` property)
| `skipIfSpecIsUnchanged` | `codegen.skipIfSpecIsUnchanged` | Skip the execution if the source file is older than the output folder (`false` by default. Can also be set globally through the `codegen.skipIfSpecIsUnchanged` property)
| `addCompileSourceRoot` | `openapi.generator.maven.plugin.addCompileSourceRoot` | Add the output directory to the project as a source root, so that the generated java types are compiled and included in the project artifact (`true` by default). Mutually exclusive with `addTestCompileSourceRoot`.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -496,12 +496,6 @@ public class CodeGenMojo extends AbstractMojo {
@Parameter(name = "generateApiDocumentation", property = "openapi.generator.maven.plugin.generateApiDocumentation")
private Boolean generateApiDocumentation = true;

/**
* Generate the api documentation
*/
@Parameter(name = "withXml", property = "openapi.generator.maven.plugin.withXml")
private Boolean withXml = false;

/**
* Skip the execution.
*/
Expand Down Expand Up @@ -811,7 +805,6 @@ public void execute() throws MojoExecutionException {
GlobalSettings.setProperty(CodegenConstants.MODEL_DOCS, generateModelDocumentation.toString());
GlobalSettings.setProperty(CodegenConstants.API_TESTS, generateApiTests.toString());
GlobalSettings.setProperty(CodegenConstants.API_DOCS, generateApiDocumentation.toString());
GlobalSettings.setProperty(CodegenConstants.WITH_XML, withXml.toString());
GlobalSettings.setProperty(CodegenConstants.GENERATE_RECURSIVE_DEPENDENT_MODELS, generateRecursiveDependentModels.toString());

if (configOptions != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ public class CodegenConstants {
public static final String API_TESTS = "apiTests";
public static final String API_DOCS = "apiDocs";

public static final String WITH_XML = "withXml";
public static final String SKIP_FORM_MODEL = "skipFormModel";
/* /end System Properties */

Expand Down Expand Up @@ -438,6 +437,8 @@ public static enum ENUM_PROPERTY_NAMING_TYPE {camelCase, PascalCase, snake_case,

public static final String FASTAPI_IMPLEMENTATION_PACKAGE = "fastapiImplementationPackage";

public static final String WITH_XML = "withXml";

public static final String WITH_GO_MOD = "withGoMod";

public static final String GENERATE_MARSHAL_JSON = "generateMarshalJSON";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,6 @@ Class | Method | HTTP request | Description
- modelDocs: {{generateModelDocs}}
- apiTests: {{generateApiTests}}
- modelTests: {{generateModelTests}}
- withXml: {{withXml}}

## [OpenApi Generator Parameters](https://openapi-generator.tech/docs/generators/csharp-netcore)
- allowUnicodeIdentifiers: {{allowUnicodeIdentifiers}}
Expand Down
Loading

0 comments on commit 9c999b6

Please sign in to comment.