Skip to content

Commit 9c999b6

Browse files
authored
[General] Remove defunct global property withXml from generator, docs, 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
1 parent 258b7af commit 9c999b6

File tree

21 files changed

+234
-258
lines changed

21 files changed

+234
-258
lines changed

bin/configs/java-microprofile-rest-client-3.0-jackson-with-xml.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@ outputDir: samples/client/petstore/java/microprofile-rest-client-3.0-jackson-wit
33
library: microprofile
44
inputSpec: modules/openapi-generator/src/test/resources/3_0/petstore.yaml
55
templateDir: modules/openapi-generator/src/main/resources/Java
6-
withXml: true
76
additionalProperties:
87
serializationLibrary: jackson
98
artifactId: microprofile-rest-client-3-jackson-with-xml
109
configKey: petstore
1110
microprofileRestClientVersion: "3.0"
1211
hideGenerationTimestamp: true
12+
withXml: true

docs/global-properties.md

+16-17
Original file line numberDiff line numberDiff line change
@@ -5,23 +5,22 @@ title: Global Properties
55

66
## Available Global Properties
77

8-
| Property | Description | Acceptable value |
9-
| -------- | ------------| ---------------- |
10-
| debugOpenAPI | Dumps JSON formatted and fully parsed OpenAPI document during generation | none |
11-
| debugModels | Dumps JSON formatted template-bound model information during generation | none |
12-
| debugOperations | Dumps JSON formatted template-bound operation information during generation | none |
13-
| debugSupportingFiles | Dumps JSON formatted Supporting File information during generation | none |
14-
| verbose | Defines the verbosity | `true` or `false` |
15-
| generateAliasAsModel | Defines whether primitive types defined at the model/schema level will be wrapped in a model | `true` or `false` |
16-
| org.openapitools.codegen.utils.oncelogger.enabled | Enable/disable the "OnceLogger" which reduces noise for select repeated logs | `true` or `false` |
17-
| 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 |
18-
| 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 |
19-
| 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 |
20-
| apiDocs | Allows the user to define if api docs will be generated. Prefer using the more robust `.openapi-generator-ignore`. | `true` or `false` |
21-
| modelDocs | Allows the user to define if model docs will be generated. Prefer using the more robust `.openapi-generator-ignore`. | `true` or `false` |
22-
| apiTests | Allows the user to define if api tests will be generated. Prefer using the more robust `.openapi-generator-ignore`. | `true` or `false` |
23-
| modelTests | Allows the user to define if model tests will be generated. Prefer using the more robust `.openapi-generator-ignore`. | `true` or `false` |
24-
| withXml | Allows the user to control support of XML generated constructs, where supported | none |
8+
| Property | Description | Acceptable value |
9+
|---------------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------|------------------------------------------------------|
10+
| debugOpenAPI | Dumps JSON formatted and fully parsed OpenAPI document during generation | none |
11+
| debugModels | Dumps JSON formatted template-bound model information during generation | none |
12+
| debugOperations | Dumps JSON formatted template-bound operation information during generation | none |
13+
| debugSupportingFiles | Dumps JSON formatted Supporting File information during generation | none |
14+
| verbose | Defines the verbosity | `true` or `false` |
15+
| generateAliasAsModel | Defines whether primitive types defined at the model/schema level will be wrapped in a model | `true` or `false` |
16+
| org.openapitools.codegen.utils.oncelogger.enabled | Enable/disable the "OnceLogger" which reduces noise for select repeated logs | `true` or `false` |
17+
| 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 |
18+
| 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 |
19+
| 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 |
20+
| apiDocs | Allows the user to define if api docs will be generated. Prefer using the more robust `.openapi-generator-ignore`. | `true` or `false` |
21+
| modelDocs | Allows the user to define if model docs will be generated. Prefer using the more robust `.openapi-generator-ignore`. | `true` or `false` |
22+
| apiTests | Allows the user to define if api tests will be generated. Prefer using the more robust `.openapi-generator-ignore`. | `true` or `false` |
23+
| modelTests | Allows the user to define if model tests will be generated. Prefer using the more robust `.openapi-generator-ignore`. | `true` or `false` |
2524

2625

2726
## Note on Global Property declaration

modules/openapi-generator-gradle-plugin/README.adoc

-5
Original file line numberDiff line numberDiff line change
@@ -389,11 +389,6 @@ apply plugin: 'org.openapi.generator'
389389
|true
390390
|Defines whether or not api-related _documentation_ files should be generated.
391391

392-
|withXml
393-
|Boolean
394-
|false
395-
|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.
396-
397392
|configOptions
398393
|Map(String,String)
399394
|None

modules/openapi-generator-gradle-plugin/src/main/kotlin/org/openapitools/generator/gradle/plugin/OpenApiGeneratorPlugin.kt

-1
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,6 @@ class OpenApiGeneratorPlugin : Plugin<Project> {
144144
generateModelDocumentation.set(generate.generateModelDocumentation)
145145
generateApiTests.set(generate.generateApiTests)
146146
generateApiDocumentation.set(generate.generateApiDocumentation)
147-
withXml.set(generate.withXml)
148147
configOptions.set(generate.configOptions)
149148
logToStderr.set(generate.logToStderr)
150149
enablePostProcessFile.set(generate.enablePostProcessFile)

modules/openapi-generator-gradle-plugin/src/main/kotlin/org/openapitools/generator/gradle/plugin/extensions/OpenApiGeneratorGenerateExtension.kt

-7
Original file line numberDiff line numberDiff line change
@@ -342,12 +342,6 @@ open class OpenApiGeneratorGenerateExtension(project: Project) {
342342
*/
343343
val generateApiDocumentation = project.objects.property<Boolean>()
344344

345-
/**
346-
* A special-case setting which configures some generators with XML support. In some cases,
347-
* this forces json OR xml, so the default here is false.
348-
*/
349-
val withXml = project.objects.property<Boolean>()
350-
351345
/**
352346
* To write all log messages (not just errors) to STDOUT
353347
*/
@@ -408,7 +402,6 @@ open class OpenApiGeneratorGenerateExtension(project: Project) {
408402
generateModelDocumentation.set(true)
409403
generateApiTests.set(true)
410404
generateApiDocumentation.set(true)
411-
withXml.set(false)
412405
configOptions.set(mapOf())
413406
validateSpec.set(true)
414407
logToStderr.set(false)

modules/openapi-generator-gradle-plugin/src/main/kotlin/org/openapitools/generator/gradle/plugin/tasks/GenerateTask.kt

-12
Original file line numberDiff line numberDiff line change
@@ -506,14 +506,6 @@ open class GenerateTask @Inject constructor(private val objectFactory: ObjectFac
506506
@Input
507507
val generateApiDocumentation = project.objects.property<Boolean>()
508508

509-
/**
510-
* A special-case setting which configures some generators with XML support. In some cases,
511-
* this forces json OR xml, so the default here is false.
512-
*/
513-
@Optional
514-
@Input
515-
val withXml = project.objects.property<Boolean>()
516-
517509
/**
518510
* To write all log messages (not just errors) to STDOUT
519511
*/
@@ -680,10 +672,6 @@ open class GenerateTask @Inject constructor(private val objectFactory: ObjectFac
680672
GlobalSettings.setProperty(CodegenConstants.API_TESTS, generateApiTests.get().toString())
681673
}
682674

683-
if (withXml.isPresent) {
684-
GlobalSettings.setProperty(CodegenConstants.WITH_XML, withXml.get().toString())
685-
}
686-
687675
if (inputSpec.isPresent && remoteInputSpec.isPresent) {
688676
logger.warn("Both inputSpec and remoteInputSpec is specified. The remoteInputSpec will take priority over inputSpec.")
689677
}

modules/openapi-generator-maven-plugin/README.md

-1
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,6 @@ mvn clean compile
107107
| `generateModelDocumentation` | `openapi.generator.maven.plugin.generateModelDocumentation` | generate the model documentation (`true` by default. Only available if `generateModels` is `true`)
108108
| `generateApiTests` | `openapi.generator.maven.plugin.generateApiTests` | generate the api tests (`true` by default. Only available if `generateApis` is `true`)
109109
| `generateApiDocumentation` | `openapi.generator.maven.plugin.generateApiDocumentation` | generate the api documentation (`true` by default. Only available if `generateApis` is `true`)
110-
| `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)
111110
| `skip` | `codegen.skip` | skip code generation (`false` by default. Can also be set globally through the `codegen.skip` property)
112111
| `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)
113112
| `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`.

modules/openapi-generator-maven-plugin/src/main/java/org/openapitools/codegen/plugin/CodeGenMojo.java

-7
Original file line numberDiff line numberDiff line change
@@ -496,12 +496,6 @@ public class CodeGenMojo extends AbstractMojo {
496496
@Parameter(name = "generateApiDocumentation", property = "openapi.generator.maven.plugin.generateApiDocumentation")
497497
private Boolean generateApiDocumentation = true;
498498

499-
/**
500-
* Generate the api documentation
501-
*/
502-
@Parameter(name = "withXml", property = "openapi.generator.maven.plugin.withXml")
503-
private Boolean withXml = false;
504-
505499
/**
506500
* Skip the execution.
507501
*/
@@ -811,7 +805,6 @@ public void execute() throws MojoExecutionException {
811805
GlobalSettings.setProperty(CodegenConstants.MODEL_DOCS, generateModelDocumentation.toString());
812806
GlobalSettings.setProperty(CodegenConstants.API_TESTS, generateApiTests.toString());
813807
GlobalSettings.setProperty(CodegenConstants.API_DOCS, generateApiDocumentation.toString());
814-
GlobalSettings.setProperty(CodegenConstants.WITH_XML, withXml.toString());
815808
GlobalSettings.setProperty(CodegenConstants.GENERATE_RECURSIVE_DEPENDENT_MODELS, generateRecursiveDependentModels.toString());
816809

817810
if (configOptions != null) {

modules/openapi-generator/src/main/java/org/openapitools/codegen/CodegenConstants.java

+2-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@ public class CodegenConstants {
3333
public static final String API_TESTS = "apiTests";
3434
public static final String API_DOCS = "apiDocs";
3535

36-
public static final String WITH_XML = "withXml";
3736
public static final String SKIP_FORM_MODEL = "skipFormModel";
3837
/* /end System Properties */
3938

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

439438
public static final String FASTAPI_IMPLEMENTATION_PACKAGE = "fastapiImplementationPackage";
440439

440+
public static final String WITH_XML = "withXml";
441+
441442
public static final String WITH_GO_MOD = "withGoMod";
442443

443444
public static final String GENERATE_MARSHAL_JSON = "generateMarshalJSON";

modules/openapi-generator/src/main/resources/csharp/libraries/generichost/README.client.mustache

-1
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,6 @@ Class | Method | HTTP request | Description
200200
- modelDocs: {{generateModelDocs}}
201201
- apiTests: {{generateApiTests}}
202202
- modelTests: {{generateModelTests}}
203-
- withXml: {{withXml}}
204203

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

0 commit comments

Comments
 (0)