diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index e701fb5ba33..f84bf3a3e60 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -85,12 +85,17 @@ For [Vendor Extensions](https://github.com/OAI/OpenAPI-Specification/blob/master To add test cases (optional) covering the change in the code generator, please refer to [modules/openapi-generator/src/test/java/org/openapitools/codegen](https://github.com/openapitools/openapi-generator/tree/master/modules/openapi-generator/src/test/java/org/openapitools/codegen) To test the templates, please perform the following: -- Update the Petstore sample by running the shell scripts under `bin` and `bin/openapi3` folder. For example, run `./bin/python-petstore.sh` and `./bin/openapi3/python-petstore.sh` to update the Python PetStore API client under [`samples/client/petstore/python`](https://github.com/openapitools/openapi-generator/tree/master/samples/client/petstore/python) and [`samples/openapi3/client/petstore/python`](https://github.com/openapitools/openapi-generator/tree/master/samples/openapi3/client/petstore/python). For Windows, the batch files can be found under `bin\windows` folder. (If you find that there are new files generated or unexpected changes as a result of the update, that's not unusual as the test cases are added to the OpenAPI spec from time to time. If you've questions or concerns, please open a ticket to start a discussion) -- During development it can be helpful to quickly regenerate the samples without recompiling all of openapi-generator, e.g. when you have only updated the mustache templates. This can be done by passing the `-t` parameter: `./bin/python-petstore.sh -t modules/openapi-generator/src/main/resources/python`. -- Run the tests in the sample folder using maven `mvn integration-test -rf :`, e.g. open a shell in `samples/client/petstore/python`, run `mvn integration-test -rf :PythonPetstoreClientTests`. The artifactId of the project can be found in the pom.xml file. (some languages may not contain unit testing for Petstore and we're looking for contribution from the community to implement those tests) + +- Update the Petstore sample by running the shell scripts under the `bin` folder. For example, run `./bin/generate-samples.sh . +/bin/configs/python*` to update the Python-related samples under [`samples`](https://github.com/openapitools/openapi-generator/t +ree/master/samples). For Windows, please install [GIT bash](https://gitforwindows.org/). (If you find that there are new files g +enerated or unexpected changes as a result of the update, that's not unusual as the test cases are added to the OpenAPI spec fro +m time to time. If you've questions or concerns, please open a ticket to start a discussion) +- During development it can be helpful to quickly regenerate the samples without recompiling all of openapi-generator, e.g. when you have only updated the mustache templates. This can be done by passing the `-t` parameter: `-t modules/openapi-generator/src/main/resources/python`. +- Run the tests in the sample folder using maven `mvn integration-test -f /path/to/pom.xml`, e.g. `mvn integration-test -f samples/client/petstore/python/pom.xml`. (some languages may not contain unit testing for Petstore and we're looking for contribution from the community to implement those tests) - Finally, git commit the updated samples files: `git commit -a` (`git add -A` if added files with new test cases) -- For new test cases, please add to the [Fake Petstore spec](https://github.com/OpenAPITools/openapi-generator/blob/master/modules/openapi-generator/src/test/resources/2_0/petstore-with-fake-endpoints-models-for-testing.yaml) +- For new test cases, please add to the [Fake Petstore spec](https://github.com/OpenAPITools/openapi-generator/blob/master/modules/openapi-generator/src/test/resources/3_0/petstore-with-fake-endpoints-models-for-testing.yaml) To start the CI tests, you can: - Run `mvn verify -Psamples`, assuming you have all the required tools installed to run tests for different languages. diff --git a/README.md b/README.md index bf67bf6c193..8c35ffe7ee2 100644 --- a/README.md +++ b/README.md @@ -77,7 +77,7 @@ OpenAPI Generator allows generation of API client libraries (SDK generation), se - [1.4 - Build Projects](#14---build-projects) - [1.5 - Homebrew](#15---homebrew) - [1.6 - Docker](#16---docker) - - [1.7 - NPM](#17---npm) + - [1.7 - NPM](#17---npm) - [2 - Getting Started](#2---getting-started) - [3 - Usage](#3---usage) - [3.1 - Customization](#31---customization) @@ -457,29 +457,28 @@ NAME SYNOPSIS openapi-generator-cli generate [(-a | --auth )] - [--api-name-suffix ] - [--api-package ] [--artifact-id ] - [--artifact-version ] - [(-c | --config )] - [-D ...] + [--api-name-suffix ] [--api-package ] + [--artifact-id ] [--artifact-version ] + [(-c | --config )] [--dry-run] [(-e | --engine )] [--enable-post-process-file] [(-g | --generator-name )] - [--generate-alias-as-model] [--git-repo-id ] - [--git-user-id ] [--group-id ] + [--generate-alias-as-model] [--git-host ] + [--git-repo-id ] [--git-user-id ] + [--global-property ...] [--group-id ] [--http-user-agent ] - (-i | --input-spec ) + [(-i | --input-spec )] [--ignore-file-override ] [--import-mappings ...] [--instantiation-types ...] [--invoker-package ] [--language-specific-primitives ...] - [--library ] [--log-to-stderr] [--minimal-update] + [--legacy-discriminator-behavior] [--library ] + [--log-to-stderr] [--minimal-update] [--model-name-prefix ] [--model-name-suffix ] [--model-package ] - [(-o | --output )] - [(-p | --additional-properties )...] + [(-o | --output )] [(-p | --additional-properties )...] [--package-name ] [--release-note ] [--remove-operation-id-prefix] [--reserved-words-mappings ...] @@ -509,13 +508,12 @@ mvn package ``` Other languages have petstore samples, too: -```sh -./bin/android-petstore-all.sh -./bin/java-petstore-all.sh -./bin/objc-petstore.sh -``` -... and others. [Here is a list of all scripts.](https://github.com/OpenAPITools/openapi-generator/wiki/Samples-folder#scripts) +- [Swift5](https://github.com/OpenAPITools/openapi-generator/tree/master/samples/client/petstore/swift5) +- [Ruby](https://github.com/OpenAPITools/openapi-generator/tree/master/samples/client/petstore/ruby) +- [Kotlin](https://github.com/OpenAPITools/openapi-generator/tree/master/samples/client/petstore/kotlin) + +... and more. ### [3.1 - Customization](#table-of-contents) diff --git a/docs/building.md b/docs/building.md index 237263c8ef4..38de51c2221 100644 --- a/docs/building.md +++ b/docs/building.md @@ -45,7 +45,7 @@ Once built, `run-in-docker.sh` will act as an executable for openapi-generator-c ./run-in-docker.sh list # Executes 'list' command for openapi-generator-cli ./run-in-docker.sh /gen/bin/generate-samples.sh /gen/bin/configs/go-petstore.yaml # Builds the Go client ./run-in-docker.sh generate -i modules/openapi-generator/src/test/resources/2_0/petstore.yaml \ - -g go -o /gen/out/go-petstore -DpackageName=petstore # generates go client, outputs locally to ./out/go-petstore + -g go -o /gen/out/go-petstore --packageName=petstore # generates go client, outputs locally to ./out/go-petstore ``` ### Docker in Vagrant diff --git a/docs/contributing.md b/docs/contributing.md index f7182f3a21f..496391bd9dd 100644 --- a/docs/contributing.md +++ b/docs/contributing.md @@ -89,12 +89,17 @@ For [Vendor Extensions](https://github.com/OAI/OpenAPI-Specification/blob/master To add test cases (optional) covering the change in the code generator, please refer to [modules/openapi-generator/src/test/java/org/openapitools/codegen](https://github.com/openapitools/openapi-generator/tree/master/modules/openapi-generator/src/test/java/org/openapitools/codegen) To test the templates, please perform the following: -- Update the Petstore sample by running the shell scripts under `bin` and `bin/openapi3` folder. For example, run `./bin/python-petstore.sh` and `./bin/openapi3/python-petstore.sh` to update the Python PetStore API client under [`samples/client/petstore/python`](https://github.com/openapitools/openapi-generator/tree/master/samples/client/petstore/python) and [`samples/openapi3/client/petstore/python`](https://github.com/openapitools/openapi-generator/tree/master/samples/openapi3/client/petstore/python). For Windows, the batch files can be found under `bin\windows` folder. (If you find that there are new files generated or unexpected changes as a result of the update, that's not unusual as the test cases are added to the OpenAPI spec from time to time. If you've questions or concerns, please open a ticket to start a discussion) -- During development it can be helpful to quickly regenerate the samples without recompiling all of openapi-generator, e.g. when you have only updated the mustache templates. This can be done by passing the `-t` parameter: `./bin/python-petstore.sh -t modules/openapi-generator/src/main/resources/python`. -- Run the tests in the sample folder using maven `mvn integration-test -rf :`, e.g. open a shell in `samples/client/petstore/python`, run `mvn integration-test -rf :PythonPetstoreClientTests`. The artifactId of the project can be found in the pom.xml file. (some languages may not contain unit testing for Petstore and we're looking for contribution from the community to implement those tests) + +- Update the Petstore sample by running the shell scripts under the `bin` folder. For example, run `./bin/generate-samples.sh . +/bin/configs/python*` to update the Python-related samples under [`samples`](https://github.com/openapitools/openapi-generator/t +ree/master/samples). For Windows, please install [GIT bash](https://gitforwindows.org/). (If you find that there are new files g +enerated or unexpected changes as a result of the update, that's not unusual as the test cases are added to the OpenAPI spec fro +m time to time. If you've questions or concerns, please open a ticket to start a discussion) +- During development it can be helpful to quickly regenerate the samples without recompiling all of openapi-generator, e.g. when you have only updated the mustache templates. This can be done by passing the `-t` parameter: `-t modules/openapi-generator/src/main/resources/python`. +- Run the tests in the sample folder using maven `mvn integration-test -f /path/to/pom.xml`, e.g. `mvn integration-test -f samples/client/petstore/python/pom.xml`. (some languages may not contain unit testing for Petstore and we're looking for contribution from the community to implement those tests) - Finally, git commit the updated samples files: `git commit -a` (`git add -A` if added files with new test cases) -- For new test cases, please add to the [Fake Petstore spec](https://github.com/OpenAPITools/openapi-generator/blob/master/modules/openapi-generator/src/test/resources/2_0/petstore-with-fake-endpoints-models-for-testing.yaml) +- For new test cases, please add to the [Fake Petstore spec](https://github.com/OpenAPITools/openapi-generator/blob/master/modules/openapi-generator/src/test/resources/3_0/petstore-with-fake-endpoints-models-for-testing.yaml) To start the CI tests, you can: - Run `mvn verify -Psamples`, assuming you have all the required tools installed to run tests for different languages. diff --git a/docs/customization.md b/docs/customization.md index fe40349f31e..8d3ec378a30 100644 --- a/docs/customization.md +++ b/docs/customization.md @@ -93,49 +93,49 @@ If you publish your artifact to a distant maven repository, do not forget to add 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. -The default is generate *everything* supported by the specific library. Once you enable a feature, it will restrict the contents generated: +The default is generate *everything* supported by the specific library. Once you enable a feature, it will restrict the contents generated: ```sh # generate only models -java -Dmodels {opts} +--global-property models # generate only apis -java -Dapis {opts} +--global-property apis # generate only supporting files -java -DsupportingFiles +--global-property supportingFiles # generate models and supporting files -java -Dmodels -DsupportingFiles +--global-property models,supportingFiles ``` To control the specific files being generated, you can pass a CSV list of what you want: ```sh # generate the User and Pet models only --Dmodels=User,Pet +--global-property models="User,Pet" # generate the User model and the supportingFile `StringUtil.java`: --Dmodels=User -DsupportingFiles=StringUtil.java +--global-property models=User,supportingFiles=StringUtil.java ``` -To control generation of docs and tests for api and models, pass false to the option. For api, these options are `-DapiTests=false` and `-DapiDocs=false`. For models, `-DmodelTests=false` and `-DmodelDocs=false`. -These options default to true and don't limit the generation of the feature options listed above (like `-Dapi`): +To control generation of docs and tests for api and models, pass false to the option. For api, these options are `--global-property apiTests=false,apiDocs=false`. For models, `--global-property modelTests=false,modelDocs=false`. +These options default to true and don't limit the generation of the feature options listed above (like `--global-property api`): ```sh # generate only models (with tests and documentation) -java -Dmodels {opts} +--global-property models # generate only models (with tests but no documentation) -java -Dmodels -DmodelDocs=false {opts} +--global-property models,modelDocs=false # generate only User and Pet models (no tests and no documentation) -java -Dmodels=User,Pet -DmodelTests=false {opts} +--global-property models="User,Pet",modelTests=false # generate only apis (without tests) -java -Dapis -DapiTests=false {opts} +--global-property apis,apiTests=false # generate only apis (modelTests option is ignored) -java -Dapis -DmodelTests=false {opts} +--global-property apis,modelTests=false ``` When using selective generation, _only_ the templates needed for the specific generation will be used. @@ -143,13 +143,7 @@ When using selective generation, _only_ the templates needed for the specific ge To skip models defined as the form parameters in "requestBody", please use `skipFormModel` (default to false) (this option is introduced at v3.2.2) ```sh -java -DskipFormModel=true generate … -``` - -or - -```sh -java generate --global-property skipFormModel=true … +--global-property skipFormModel=true ``` 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 diff --git a/docs/debugging.md b/docs/debugging.md index f35290ee3c3..bdf7e992c6e 100644 --- a/docs/debugging.md +++ b/docs/debugging.md @@ -13,48 +13,117 @@ For example, if you generate the aspnetcore generator passing `--minimal-update ```bash export JAVA_OPTS="-Dlog.level=off" -./bin/aspnetcore-petstore-server.sh --minimal-update --dry-run +./bin/generate-samples.sh ./bin/configs/lua.yaml -- --minimal-update --dry-run ``` You'll see the output similar to the following: -``` -# START SCRIPT: ./bin/aspnetcore-petstore-server.sh +```bash +$ ./bin/generate-samples.sh ./bin/configs/lua.yaml -- --minimal-update --dry-run +# START SCRIPT: ./bin/generate-samples.sh +This script generates all configs under bin/configs by default. +You may generate a targeted script or set of scripts using glob patterns. +For example: + ./bin/generate-samples.sh bin/configs/java-* + +You may generate a single config with additional options if you use -- to +separate the single config file from the generator arguments. + +For example: + ./bin/generate-samples.sh bin/configs/java-vertx.yaml -- --global-property debugModels=true + + +[main] INFO o.o.codegen.DefaultGenerator - Generating with dryRun=true +[main] INFO o.o.codegen.DefaultGenerator - OpenAPI Generator: lua (client) +[main] INFO o.o.codegen.DefaultGenerator - Generator 'lua' is considered beta. +[main] WARN o.o.codegen.utils.ModelUtils - Multiple schemas found in the OAS 'content' section, returning only the first one (application/xml) +[main] WARN o.o.codegen.utils.ModelUtils - Multiple schemas found in the OAS 'content' section, returning only the first one (application/xml) +[main] WARN o.o.codegen.utils.ModelUtils - Multiple schemas found in the OAS 'content' section, returning only the first one (application/xml) +[main] WARN o.o.codegen.utils.ModelUtils - Multiple schemas found in the OAS 'content' section, returning only the first one (application/xml) +[main] WARN o.o.codegen.utils.ModelUtils - Multiple schemas found in the OAS 'content' section, returning only the first one (application/xml) +[main] WARN o.o.codegen.utils.ModelUtils - Multiple schemas found in the OAS 'content' section, returning only the first one (application/xml) +[main] WARN o.o.codegen.utils.ModelUtils - Multiple schemas found in the OAS 'content' section, returning only the first one (application/xml) +[main] WARN o.o.codegen.utils.ModelUtils - Multiple schemas found in the OAS 'content' section, returning only the first one (application/xml) +[main] WARN o.o.codegen.utils.ModelUtils - Multiple schemas found in the OAS 'content' section, returning only the first one (application/xml) +[main] WARN o.o.codegen.utils.ModelUtils - Multiple schemas found in the OAS 'content' section, returning only the first one (application/xml) +[main] WARN o.o.codegen.utils.ModelUtils - Multiple schemas found in the OAS 'content' section, returning only the first one (application/xml) +[main] WARN o.o.codegen.utils.ModelUtils - Multiple schemas found in the OAS 'content' section, returning only the first one (application/xml) +[main] WARN o.o.codegen.utils.ModelUtils - Multiple schemas found in the OAS 'content' section, returning only the first one (application/xml) +[main] WARN o.o.codegen.utils.ModelUtils - Multiple schemas found in the OAS 'content' section, returning only the first one (application/xml) +[main] WARN o.o.codegen.utils.ModelUtils - Multiple schemas found in the OAS 'content' section, returning only the first one (application/xml) +[main] WARN o.o.codegen.utils.ModelUtils - Multiple schemas found in the OAS 'content' section, returning only the first one (application/xml) +[main] WARN o.o.codegen.utils.ModelUtils - Multiple schemas found in the OAS 'content' section, returning only the first one (application/xml) +[main] WARN o.o.codegen.utils.ModelUtils - Multiple schemas found in the OAS 'content' section, returning only the first one (application/xml) +[main] INFO o.o.codegen.DefaultGenerator - Model inline_object (marked as unused due to form parameters) is generated due to the system property skipFormModel=false (default) +[main] INFO o.o.codegen.DefaultGenerator - Model inline_object_1 (marked as unused due to form parameters) is generated due to the system property skipFormModel=false (default) +[main] WARN o.o.codegen.utils.ModelUtils - Multiple schemas found in the OAS 'content' section, returning only the first one (application/xml) +[main] WARN o.o.codegen.utils.ModelUtils - Multiple schemas found in the OAS 'content' section, returning only the first one (application/xml) +[main] WARN o.o.codegen.utils.ModelUtils - Multiple schemas found in the OAS 'content' section, returning only the first one (application/json) +[main] WARN o.o.codegen.DefaultCodegen - Multiple MediaTypes found, using only the first one +[main] WARN o.o.codegen.utils.ModelUtils - Multiple schemas found in the OAS 'content' section, returning only the first one (application/xml) +[main] WARN o.o.codegen.utils.ModelUtils - Multiple schemas found in the OAS 'content' section, returning only the first one (application/xml) +[main] WARN o.o.codegen.utils.ModelUtils - Multiple schemas found in the OAS 'content' section, returning only the first one (application/json) +[main] WARN o.o.codegen.utils.ModelUtils - Multiple schemas found in the OAS 'content' section, returning only the first one (application/xml) +[main] WARN o.o.codegen.utils.ModelUtils - Multiple schemas found in the OAS 'content' section, returning only the first one (application/xml) +[main] WARN o.o.codegen.utils.ModelUtils - Multiple schemas found in the OAS 'content' section, returning only the first one (application/xml) +[main] WARN o.o.codegen.utils.ModelUtils - Multiple schemas found in the OAS 'content' section, returning only the first one (application/xml) +[main] WARN o.o.codegen.utils.ModelUtils - Multiple schemas found in the OAS 'content' section, returning only the first one (application/xml) +[main] WARN o.o.codegen.utils.ModelUtils - Multiple schemas found in the OAS 'content' section, returning only the first one (application/xml) +[main] WARN o.o.codegen.utils.ModelUtils - Multiple schemas found in the OAS 'content' section, returning only the first one (application/xml) +[main] WARN o.o.codegen.utils.ModelUtils - Multiple schemas found in the OAS 'content' section, returning only the first one (application/xml) +[main] WARN o.o.codegen.utils.ModelUtils - Multiple schemas found in the OAS 'content' section, returning only the first one (application/xml) +[main] WARN o.o.codegen.utils.ModelUtils - Multiple schemas found in the OAS 'content' section, returning only the first one (application/xml) +[main] WARN o.o.codegen.utils.ModelUtils - Multiple schemas found in the OAS 'content' section, returning only the first one (application/xml) +[main] WARN o.o.codegen.utils.ModelUtils - Multiple schemas found in the OAS 'content' section, returning only the first one (application/xml) +[main] WARN o.o.codegen.utils.ModelUtils - Multiple schemas found in the OAS 'content' section, returning only the first one (application/xml) +[main] WARN o.o.codegen.utils.ModelUtils - Multiple schemas found in the OAS 'content' section, returning only the first one (application/xml) +[main] ERROR o.o.codegen.DefaultGenerator - Dry Run Results: -s /path/to/aspnetcore/.openapi-generator-ignore -n /path/to/aspnetcore/.openapi-generator/VERSION -n /path/to/aspnetcore/Org.OpenAPITools.sln -n /path/to/aspnetcore/README.md -n /path/to/aspnetcore/build.bat -n /path/to/aspnetcore/build.sh -w /path/to/aspnetcore/src/Org.OpenAPITools/.gitignore -n /path/to/aspnetcore/src/Org.OpenAPITools/Attributes/ValidateModelStateAttribute.cs -n /path/to/aspnetcore/src/Org.OpenAPITools/Authentication/ApiAuthentication.cs -n /path/to/aspnetcore/src/Org.OpenAPITools/Controllers/PetApi.cs -n /path/to/aspnetcore/src/Org.OpenAPITools/Controllers/StoreApi.cs -n /path/to/aspnetcore/src/Org.OpenAPITools/Controllers/UserApi.cs -n /path/to/aspnetcore/src/Org.OpenAPITools/Converters/CustomEnumConverter.cs -n /path/to/aspnetcore/src/Org.OpenAPITools/Dockerfile -n /path/to/aspnetcore/src/Org.OpenAPITools/Filters/BasePathFilter.cs -n /path/to/aspnetcore/src/Org.OpenAPITools/Filters/GeneratePathParamsValidationFilter.cs -n /path/to/aspnetcore/src/Org.OpenAPITools/Models/ApiResponse.cs -n /path/to/aspnetcore/src/Org.OpenAPITools/Models/Category.cs -n /path/to/aspnetcore/src/Org.OpenAPITools/Models/Order.cs -n /path/to/aspnetcore/src/Org.OpenAPITools/Models/Pet.cs -n /path/to/aspnetcore/src/Org.OpenAPITools/Models/Tag.cs -n /path/to/aspnetcore/src/Org.OpenAPITools/Models/User.cs -n /path/to/aspnetcore/src/Org.OpenAPITools/Org.OpenAPITools.csproj -n /path/to/aspnetcore/src/Org.OpenAPITools/Program.cs -w /path/to/aspnetcore/src/Org.OpenAPITools/Properties/launchSettings.json -n /path/to/aspnetcore/src/Org.OpenAPITools/Startup.cs -w /path/to/aspnetcore/src/Org.OpenAPITools/appsettings.json -w /path/to/aspnetcore/src/Org.OpenAPITools/wwwroot/README.md -w /path/to/aspnetcore/src/Org.OpenAPITools/wwwroot/index.html -n /path/to/aspnetcore/src/Org.OpenAPITools/wwwroot/openapi-original.json -w /path/to/aspnetcore/src/Org.OpenAPITools/wwwroot/web.config +k /Users/williamcheng/Code/openapi-generator/samples/client/petstore/lua/.openapi-generator-ignore +n /Users/williamcheng/Code/openapi-generator/samples/client/petstore/lua/.openapi-generator/VERSION +k /Users/williamcheng/Code/openapi-generator/samples/client/petstore/lua/spec/api_response_spec.lua +k /Users/williamcheng/Code/openapi-generator/samples/client/petstore/lua/spec/category_spec.lua +k /Users/williamcheng/Code/openapi-generator/samples/client/petstore/lua/spec/inline_object_1_spec.lua +k /Users/williamcheng/Code/openapi-generator/samples/client/petstore/lua/spec/inline_object_spec.lua +k /Users/williamcheng/Code/openapi-generator/samples/client/petstore/lua/spec/order_spec.lua +k /Users/williamcheng/Code/openapi-generator/samples/client/petstore/lua/spec/pet_api_spec.lua +k /Users/williamcheng/Code/openapi-generator/samples/client/petstore/lua/spec/pet_spec.lua +k /Users/williamcheng/Code/openapi-generator/samples/client/petstore/lua/spec/store_api_spec.lua +k /Users/williamcheng/Code/openapi-generator/samples/client/petstore/lua/spec/tag_spec.lua +k /Users/williamcheng/Code/openapi-generator/samples/client/petstore/lua/spec/user_api_spec.lua +k /Users/williamcheng/Code/openapi-generator/samples/client/petstore/lua/spec/user_spec.lua + + +States: + + - w Write + - n Write if New/Updated + - i Ignored + - s Skipped Overwrite + - k Skipped by user option(s) + - e Error evaluating file write state + + +[main] ERROR o.o.codegen.DefaultGenerator - + +Dry Run Results: + +k /Users/williamcheng/Code/openapi-generator/samples/client/petstore/lua/.openapi-generator-ignore +n /Users/williamcheng/Code/openapi-generator/samples/client/petstore/lua/.openapi-generator/VERSION +k /Users/williamcheng/Code/openapi-generator/samples/client/petstore/lua/spec/api_response_spec.lua +k /Users/williamcheng/Code/openapi-generator/samples/client/petstore/lua/spec/category_spec.lua +k /Users/williamcheng/Code/openapi-generator/samples/client/petstore/lua/spec/inline_object_1_spec.lua +k /Users/williamcheng/Code/openapi-generator/samples/client/petstore/lua/spec/inline_object_spec.lua +k /Users/williamcheng/Code/openapi-generator/samples/client/petstore/lua/spec/order_spec.lua +k /Users/williamcheng/Code/openapi-generator/samples/client/petstore/lua/spec/pet_api_spec.lua +k /Users/williamcheng/Code/openapi-generator/samples/client/petstore/lua/spec/pet_spec.lua +k /Users/williamcheng/Code/openapi-generator/samples/client/petstore/lua/spec/store_api_spec.lua +k /Users/williamcheng/Code/openapi-generator/samples/client/petstore/lua/spec/tag_spec.lua +k /Users/williamcheng/Code/openapi-generator/samples/client/petstore/lua/spec/user_api_spec.lua +k /Users/williamcheng/Code/openapi-generator/samples/client/petstore/lua/spec/user_spec.lua States: @@ -78,13 +147,13 @@ If you find an operation that you feel should result in a different state, pleas Sometimes, you may have issues with variables in your templates. As discussed in the [templating](./templating.md) docs, we offer a variety of system properties for inspecting the models bound to templates.
-
-DdebugOpenAPI
+
--global-property debugOpenAPI
Prints out the JSON model of the OpenAPI Document, as seen by OpenAPI Generator
-
-DdebugModels
+
--global-property debugModels
Prints out the JSON model passed to model templates
-
-DdebugOperations
+
--global-property debugOperations
Prints out the JSON model passed to operation (api) templates
-
-DdebugSupportingFiles
+
--global-property debugSupportingFiles
Prints out the JSON model passed to supporting files
@@ -94,14 +163,13 @@ One or more of these properties can be passed alongside other command line optio openapi-generator generate -g go \ -o out \ -i petstore-minimal.yaml \ - -DdebugModels \ - -DdebugOperations + --global-property debugModels,debugOperations ``` Or you can add these to your `JAVA_OPTS` environment variable (this applies to every invocation of the tool): ```bash -export JAVA_OPTS="${JAVA_OPTS} -DdebugModels -DdebugOperations" +export JAVA_OPTS="${JAVA_OPTS} --global-property debugModels,debugOperations" ``` > NOTE: Globally available system options like these will apply to all invocations of the generator (CLI and plugins) diff --git a/docs/faq-generators.md b/docs/faq-generators.md index d8d3162c496..ba2f7ca4f0d 100644 --- a/docs/faq-generators.md +++ b/docs/faq-generators.md @@ -41,7 +41,7 @@ mvn clean package java -jar modules/openapi-generator-cli/target/openapi-generator-cli.jar generate \ -i https://raw.githubusercontent.com/OpenAPITools/openapi-generator/master/modules/openapi-generator/src/test/resources/2_0/petstore.json \ -l java --library=okhttp-gson \ - -D hideGenerationTimestamp=true \ + --additional-properties hideGenerationTimestamp=true \ -o /var/tmp/java/okhttp-gson/ ``` diff --git a/docs/new-generator.md b/docs/new-generator.md index dc83018900c..1526e91dff4 100644 --- a/docs/new-generator.md +++ b/docs/new-generator.md @@ -23,7 +23,7 @@ The minimum set of files required to create a new generator are: - Should include a README explaining usage - Must include an `api.mustache` - Exists under `modules/openapi-generator/src/main/resources/` (plus `embeddedTemplate` dir value, see below) -* Sample scripts under `./bin` and `./bin/windows` +* Sample scripts under `./bin` - Gives users a "real life" example of generated output - Samples are used by CI to verify generators and test for regressions in some cases diff --git a/docs/templating.md b/docs/templating.md index cd93f62ed6d..19c80f632df 100644 --- a/docs/templating.md +++ b/docs/templating.md @@ -157,7 +157,7 @@ index a4d0f9f..49b17c7 100644 ``` -Next, we'll find the code which generates API methods. You'll see `{{#operations}}{{#operation}}` which is a mustache "loop" which executes the template logic if the model applied to the template has an `operations` array, and a non-null `operation` instance in that array. You can pass `-DdebugOpenAPI` when generating via CLI to inspect the full object model. +Next, we'll find the code which generates API methods. You'll see `{{#operations}}{{#operation}}` which is a mustache "loop" which executes the template logic if the model applied to the template has an `operations` array, and a non-null `operation` instance in that array. You can pass `--global-property debugOpenAPI=true` when generating via CLI to inspect the full object model. Further down in `api.mustache`, find implementation of the method call, and add the `@Loggable` annotation. This template is easy because it has a single method implementation. @@ -467,7 +467,7 @@ java $JAVA_OPTS -cp /your/path/build/libs/pebble-template-adapter-1.0-SNAPSHOT-a -e pebble \ -o /tmp/pebble-example/out \ -t /tmp/pebble-example/templates \ - -Dmodels -DmodelDocs=false -DmodelTests=false -Dapis -DapiTests=false -DapiDocs=false + --global-property models,modelDocs,modelTests,apis,apiTests,apiDocs ``` Notice how we've targeted our custom template engine adapter via `-e pebble`. If you don't include the SPI file under `META-INF/services`, you'll need to specify the exact classpath: `org.openapitools.examples.templating.PebbleTemplateAdapter`. Notice that the target class here matches the Kotlin class name. This is because of the `@file:JvmName` annotation. @@ -531,7 +531,7 @@ Examples for the following structures will be presented using the following spec ### Operations -> Inspect operation structures passed to templates with system property `-DdebugOpenAPI` +> Inspect operation structures passed to templates with system property `--global-property debugOpenAPI=true` > > Example: > @@ -539,7 +539,7 @@ Examples for the following structures will be presented using the following spec > openapi-generator generate -g go \ > -o out \ > -i petstore-minimal.yaml \ -> -DdebugOpenAPI +> --global-property debugOpenAPI=true > ``` > @@ -563,7 +563,7 @@ Here, an Operation with tag `Pet` will generate two files: `SWGPetApi.h` and `SW ### Models -> Inspect models passed to templates with system property `-DdebugModels` +> Inspect models passed to templates with system property `--global-property debugModels=true` > > Execute: > @@ -571,13 +571,13 @@ Here, an Operation with tag `Pet` will generate two files: `SWGPetApi.h` and `SW > openapi-generator generate -g go \ > -o out \ > -i petstore-minimal.yaml \ -> -DdebugModels +> --global-property debugModels=true > ``` > Each model identified inside the generator will be passed into the `Models` data structure and will generate a new model file (or files) for each model. -A `Pet` model with three properties will provide a _lot_ of information about the type and properties. The output from `-DdebugModels` is presented in truncated format here. +A `Pet` model with three properties will provide a _lot_ of information about the type and properties. The output from `--global-property debugModels=true` is presented in truncated format here. ```json [ { @@ -788,7 +788,7 @@ We expose the same properties in multiple sets because this allows us to conditi ### supportingFiles -> Inspect supportingFiles passed to templates with system property `-DdebugSupportingFiles` +> Inspect supportingFiles passed to templates with system property `--global-property debugSupportingFiles=true` > > Execute: > @@ -796,7 +796,7 @@ We expose the same properties in multiple sets because this allows us to conditi > openapi-generator generate -g go \ > -o out \ > -i petstore-minimal.yaml \ -> -DdebugSupportingFiles +> --global-property debugSupportingFiles=true > ``` > diff --git a/docs/usage.md b/docs/usage.md index 68e022e5fbf..f0b96aad3ec 100644 --- a/docs/usage.md +++ b/docs/usage.md @@ -399,7 +399,7 @@ OPTIONS --log-to-stderr write all log messages (not just errors) to STDOUT. Useful for - piping the JSON output of debug options (e.g. `-DdebugOperations`) + piping the JSON output of debug options (e.g. `--global-property debugOperations=true`) to an external parser directly while testing a generator. --minimal-update diff --git a/modules/openapi-generator/src/main/resources/META-INF/services/org.openapitools.codegen.CodegenConfig b/modules/openapi-generator/src/main/resources/META-INF/services/org.openapitools.codegen.CodegenConfig index 6c7fe9cfae2..87020fffa16 100644 --- a/modules/openapi-generator/src/main/resources/META-INF/services/org.openapitools.codegen.CodegenConfig +++ b/modules/openapi-generator/src/main/resources/META-INF/services/org.openapitools.codegen.CodegenConfig @@ -126,4 +126,4 @@ org.openapitools.codegen.languages.TypeScriptInversifyClientCodegen org.openapitools.codegen.languages.TypeScriptJqueryClientCodegen org.openapitools.codegen.languages.TypeScriptNodeClientCodegen org.openapitools.codegen.languages.TypeScriptReduxQueryClientCodegen -org.openapitools.codegen.languages.TypeScriptRxjsClientCodegen \ No newline at end of file +org.openapitools.codegen.languages.TypeScriptRxjsClientCodegen