Skip to content

Commit 7e5f720

Browse files
Remove deprecations 5.0 (#6060)
* [breaking] Enforce vendor extension naming convention * [breaking] Rename system properties to global properties * [docs] Update site with global properties list and usage explanation * Use proper vendor extension casing in all templates * Set remaining vendor extensions to convention of lower kebab-cased with x- prefix * [samples] Regenerate * Update modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/RustServerCodegen.java Before we were adding hasPathParams twice, once with !op.pathParams.isEmpty(), and then again with hasPathParams. This was probably caused by a mistaken merge. This is causing the difference in samples Co-authored-by: Richard Whitehouse <[email protected]> * [Samples] Regenerated! * Fix -D conversion to additional-properties, missed in bat files * JERSEY2 option changed * [samples] Regenerate * [scala][finch] Fix remaining vendor extensions format to conventino * [scala] The -D option was replaced with --global-property * [samples] Regenerate * Fix -DskipFormModel usage which has been moved to --global-property skipFormModel=true * [samples] Regenerate Co-authored-by: Richard Whitehouse <[email protected]>
1 parent 40a7e53 commit 7e5f720

File tree

124 files changed

+404
-5185
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

124 files changed

+404
-5185
lines changed

bin/apex-petstore.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,6 @@ fi
2727

2828
# if you've executed sbt assembly previously it will use that instead.
2929
export JAVA_OPTS="${JAVA_OPTS} -Xmx1024M -DloggerPath=conf/log4j.properties"
30-
ags="generate -t modules/openapi-generator/src/main/resources/apex -i modules/openapi-generator/src/test/resources/3_0/petstore.yaml -g apex -o samples/client/petstore/apex -DskipFormModel=true $@"
30+
ags="generate -t modules/openapi-generator/src/main/resources/apex -i modules/openapi-generator/src/test/resources/3_0/petstore.yaml -g apex -o samples/client/petstore/apex --global-property skipFormModel=true $@"
3131

3232
java $JAVA_OPTS -jar $executable $ags

bin/ruby-client-petstore-faraday.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,6 @@ find samples/client/petstore/ruby-faraday/spec -type f -not -name petstore_helpe
3838

3939
# if you've executed sbt assembly previously it will use that instead.
4040
export JAVA_OPTS="${JAVA_OPTS} -Xmx1024M -DloggerPath=conf/log4j.properties"
41-
ags="generate -t modules/openapi-generator/src/main/resources/ruby-client -i modules/openapi-generator/src/test/resources/3_0/petstore-with-fake-endpoints-models-for-testing.yaml -g ruby -c bin/ruby-petstore-faraday.json -o samples/client/petstore/ruby-faraday --additional-properties skipFormModel=true $@"
41+
ags="generate -t modules/openapi-generator/src/main/resources/ruby-client -i modules/openapi-generator/src/test/resources/3_0/petstore-with-fake-endpoints-models-for-testing.yaml -g ruby -c bin/ruby-petstore-faraday.json -o samples/client/petstore/ruby-faraday --global-property skipFormModel=true $@"
4242

4343
java $JAVA_OPTS -jar $executable $ags

bin/ruby-client-petstore.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,6 @@ find samples/client/petstore/ruby/spec -type f -not -name petstore_helper.rb -no
3838

3939
# if you've executed sbt assembly previously it will use that instead.
4040
export JAVA_OPTS="${JAVA_OPTS} -Xmx1024M -DloggerPath=conf/log4j.properties"
41-
ags="generate -t modules/openapi-generator/src/main/resources/ruby-client -i modules/openapi-generator/src/test/resources/3_0/petstore-with-fake-endpoints-models-for-testing.yaml -g ruby -c bin/ruby-petstore.json -o samples/client/petstore/ruby --additional-properties skipFormModel=true $@"
41+
ags="generate -t modules/openapi-generator/src/main/resources/ruby-client -i modules/openapi-generator/src/test/resources/3_0/petstore-with-fake-endpoints-models-for-testing.yaml -g ruby -c bin/ruby-petstore.json -o samples/client/petstore/ruby --global-property skipFormModel=true $@"
4242

4343
java $JAVA_OPTS -jar $executable $ags

bin/scala-finch-petstore-server.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,6 @@ fi
2727

2828
# if you've executed sbt assembly previously it will use that instead.
2929
export JAVA_OPTS="${JAVA_OPTS} -Xmx1024M -DloggerPath=conf/log4j.properties"
30-
ags="generate -t modules/openapi-generator/src/main/resources/scala-finch -i modules/openapi-generator/src/test/resources/3_0/petstore.yaml -g scala-finch -o samples/server/petstore/scala-finch -DskipFormModel=true $@"
30+
ags="generate -t modules/openapi-generator/src/main/resources/scala-finch -i modules/openapi-generator/src/test/resources/3_0/petstore.yaml -g scala-finch -o samples/server/petstore/scala-finch --global-property skipFormModel=true $@"
3131

3232
java $JAVA_OPTS -jar $executable $ags

bin/scala-lagom-server-petstore.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,6 @@ fi
2727

2828
# if you've executed sbt assembly previously it will use that instead.
2929
export JAVA_OPTS="${JAVA_OPTS} -Xmx1024M -DloggerPath=conf/log4j.properties"
30-
ags="generate -t modules/openapi-generator/src/main/resources/scala-lagom-server -i modules/openapi-generator/src/test/resources/3_0/petstore.yaml -g scala-lagom-server -o samples/server/petstore/scala-lagom-server -DskipFormModel=true $@"
30+
ags="generate -t modules/openapi-generator/src/main/resources/scala-lagom-server -i modules/openapi-generator/src/test/resources/3_0/petstore.yaml -g scala-lagom-server -o samples/server/petstore/scala-lagom-server --global-property skipFormModel=true $@"
3131

3232
java $JAVA_OPTS -jar $executable $ags

bin/scalaz-petstore.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,6 @@ fi
2727

2828
# if you've executed sbt assembly previously it will use that instead.
2929
export JAVA_OPTS="${JAVA_OPTS} -Xmx1024M -DloggerPath=conf/log4j.properties"
30-
ags="generate -t modules/openapi-generator/src/main/resources/scalaz -i modules/openapi-generator/src/test/resources/3_0/petstore.yaml -g scalaz -o samples/client/petstore/scalaz -DskipFormModel=true $@"
30+
ags="generate -t modules/openapi-generator/src/main/resources/scalaz -i modules/openapi-generator/src/test/resources/3_0/petstore.yaml -g scalaz -o samples/client/petstore/scalaz --global-property skipFormModel=true $@"
3131

3232
java $JAVA_OPTS -jar $executable $ags

bin/windows/android-petstore-httpclient.bat

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,6 @@ If Not Exist %executable% (
55
)
66

77
REM set JAVA_OPTS=%JAVA_OPTS% -Xmx1024M -DloggerPath=conf/log4j.properties
8-
set ags=generate -i modules\openapi-generator\src\test\resources\2_0\petstore.yaml -g android -o samples\client\petstore\android\httpclient -Dlibrary=httpclient
8+
set ags=generate -i modules\openapi-generator\src\test\resources\2_0\petstore.yaml -g android -o samples\client\petstore\android\httpclient --additional-properties library=httpclient
99

1010
java %JAVA_OPTS% -jar %executable% %ags%

bin/windows/go-experimental-petstore.bat

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ echo Removing files and folders under %STUB_DIR%
1414
del /F /S /Q %STUB_DIR%
1515

1616
REM set JAVA_OPTS=%JAVA_OPTS% -Xmx1024M -DloggerPath=conf/log4j.properties
17-
set ags=generate -t modules\openapi-generator\src\main\resources\%GENERATOR% -i %SPEC% -g %GENERATOR% -o %STUB_DIR% -DpackageName=petstore
17+
set ags=generate -t modules\openapi-generator\src\main\resources\%GENERATOR% -i %SPEC% -g %GENERATOR% -o %STUB_DIR% --additional-properties packageName=petstore
1818

1919
java %JAVA_OPTS% -jar %executable% %ags%
2020

docs/customization.md

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,8 @@ You can use this as additional dependency of the `openapi-generator-maven-plugin
9090
If you publish your artifact to a distant maven repository, do not forget to add this repository as `pluginRepository` for your project.
9191

9292
## Selective generation
93-
You may not want to generate *all* models in your project. Likewise you may want just one or two apis to be written. If that's the case, you can use system properties to control the output:
93+
94+
You may not want to generate *all* models in your project. Likewise, you may want just one or two apis to be written. If that's the case, you can use system properties or [global properties](./global-properties.md) to control the output.
9495

9596
The default is generate *everything* supported by the specific library. Once you enable a feature, it will restrict the contents generated:
9697

@@ -142,7 +143,13 @@ When using selective generation, _only_ the templates needed for the specific ge
142143
To skip models defined as the form parameters in "requestBody", please use `skipFormModel` (default to false) (this option is introduced at v3.2.2)
143144

144145
```sh
145-
java -DskipFormModel=true
146+
java -DskipFormModel=true <path to jar> generate …
147+
```
148+
149+
or
150+
151+
```sh
152+
java <path to jar> generate --global-property skipFormModel=true …
146153
```
147154

148155
This option will be helpful to skip model generation due to the form parameter, which is defined differently in OAS3 as there's no form parameter in OAS3

docs/global-properties.md

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
---
2+
id: globals
3+
title: Global Properties
4+
---
5+
6+
## Available Global Properties
7+
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 comma-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 comma-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 comma-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 |
25+
26+
27+
## Note on Global Property declaration
28+
29+
There are _two ways_ to provide selective generation properties or "global properties". First, these can be passed as Java System Properties. Second, these can be passed via the global property tooling option (`--global-property` in CLI and `globalProperty` in Maven and Gradle configurations). This differentiation is new in version 5.0 with the removal of the `-D` CLI option and the renaming of `systemProperties`. If you're upgrading to OpenAPI Generator 5.0+
30+
31+
While the examples seen in [Customization](./customization.md) use the Java System Property syntax, keep in mind that the following are equivalent:
32+
33+
```sh
34+
java -Dmodels {jar} generate {opts}
35+
```
36+
37+
and
38+
39+
```sh
40+
java {jar} generate {opts} --global-property=models
41+
```
42+
43+
Why the two differing ways to provide the same properties? We previously accepted a `-D` tooling option which resembled Java System Property declaration. In older versions of OpenAPI Generator, the option modified the SystemProperties collection directly and was truly a "system property". This option changed during the 4.x release in an effort to make OpenAPI Generator thread-safe and isolate its configuration via thread locals. We no longer mutate System Properties. In the 4.x release and earlier, specifying the tooling `-D` option with system properties intended for other tools like swagger-parser rather than passing them as true Java System Properties would lead to unexpected behavior for the user; if our tool set the system property _after_ invoking certain code, it would seem to the user like Java System Properties weren't working!

docs/usage.md

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -261,14 +261,14 @@ SYNOPSIS
261261
[(-a <authorization> | --auth <authorization>)]
262262
[--api-name-suffix <api name suffix>] [--api-package <api package>]
263263
[--artifact-id <artifact id>] [--artifact-version <artifact version>]
264-
[(-c <configuration file> | --config <configuration file>)]
265-
[-D <system properties>...] [--dry-run]
264+
[(-c <configuration file> | --config <configuration file>)] [--dry-run]
266265
[(-e <templating engine> | --engine <templating engine>)]
267266
[--enable-post-process-file]
268267
[(-g <generator name> | --generator-name <generator name>)]
269268
[--generate-alias-as-model] [--git-host <git host>]
270269
[--git-repo-id <git repo id>] [--git-user-id <git user id>]
271-
[--group-id <group id>] [--http-user-agent <http user agent>]
270+
[--global-property <global properties>...] [--group-id <group id>]
271+
[--http-user-agent <http user agent>]
272272
(-i <spec file> | --input-spec <spec file>)
273273
[--ignore-file-override <ignore file override location>]
274274
[--import-mappings <import mappings>...]
@@ -324,10 +324,6 @@ OPTIONS
324324
different for each language. Run config-help -g {generator name}
325325
command for language-specific config options.
326326
327-
-D <system properties>
328-
sets specified system properties in the format of
329-
name=value,name=value (or multiple options, each with name=value)
330-
331327
--dry-run
332328
Try things out and report on potential changes (without actually
333329
making changes).
@@ -343,11 +339,11 @@ OPTIONS
343339
344340
--generate-alias-as-model
345341
Generate model implementation for aliases to map and array schemas.
346-
An 'alias' is an array, map, or list which is defined inline in a
347-
OpenAPI document and becomes a model in the generated code.
348-
A 'map' schema is an object that can have undeclared properties,
349-
i.e. the 'additionalproperties' attribute is set on that object.
350-
An 'array' schema is a list of sub schemas in a OAS document.
342+
An 'alias' is an array, map, or list which is defined inline in a
343+
OpenAPI document and becomes a model in the generated code. A 'map'
344+
schema is an object that can have undeclared properties, i.e. the
345+
'additionalproperties' attribute is set on that object. An 'array'
346+
schema is a list of sub schemas in a OAS document
351347
352348
--git-host <git host>
353349
Git host, e.g. gitlab.com.
@@ -358,6 +354,11 @@ OPTIONS
358354
--git-user-id <git user id>
359355
Git user ID, e.g. openapitools.
360356
357+
--global-property <global properties>
358+
sets specified global properties (previously called 'system
359+
properties') in the format of name=value,name=value (or multiple
360+
options, each with name=value)
361+
361362
--group-id <group id>
362363
groupId in generated pom.xml
363364

modules/openapi-generator-cli/src/main/java/org/openapitools/codegen/cmd/Generate.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,9 +71,8 @@ public class Generate extends OpenApiGeneratorCommand {
7171
+ "Pass in a URL-encoded string of name:header with a comma separating multiple values")
7272
private String auth;
7373

74-
// TODO: Remove -D short option in 5.0
7574
@Option(
76-
name = {"-D", "--global-property"},
75+
name = {"--global-property"},
7776
title = "global properties",
7877
description = "sets specified global properties (previously called 'system properties') in "
7978
+ "the format of name=value,name=value (or multiple options, each with name=value)")

0 commit comments

Comments
 (0)