mirror of
https://github.com/OpenAPITools/openapi-generator.git
synced 2025-07-04 06:30:52 +00:00
Merge remote-tracking branch 'origin/master' into 6.0.x
This commit is contained in:
commit
acd747ca6d
@ -10,7 +10,7 @@ jobs:
|
|||||||
machine:
|
machine:
|
||||||
image: circleci/classic:latest
|
image: circleci/classic:latest
|
||||||
working_directory: ~/OpenAPITools/openapi-generator
|
working_directory: ~/OpenAPITools/openapi-generator
|
||||||
parallelism: 3
|
parallelism: 4
|
||||||
shell: /bin/bash --login
|
shell: /bin/bash --login
|
||||||
environment:
|
environment:
|
||||||
CIRCLE_ARTIFACTS: /tmp/circleci-artifacts
|
CIRCLE_ARTIFACTS: /tmp/circleci-artifacts
|
||||||
|
19
.gitignore
vendored
19
.gitignore
vendored
@ -62,14 +62,17 @@ samples/server-generator/node/output/node_modules
|
|||||||
samples/server/petstore/nodejs/node_modules
|
samples/server/petstore/nodejs/node_modules
|
||||||
samples/server/petstore/nodejs-server/node_modules
|
samples/server/petstore/nodejs-server/node_modules
|
||||||
|
|
||||||
# qt5 cpp
|
# qt cpp
|
||||||
*.pro.user
|
samples/client/build
|
||||||
samples/client/petstore/qt5cpp/PetStore/moc_*
|
samples/client/petstore/build
|
||||||
samples/client/petstore/qt5cpp/PetStore/*.o
|
samples/client/petstore/cpp-qt/PetStore/moc_*
|
||||||
samples/client/petstore/qt5cpp/build-*
|
samples/client/petstore/cpp-qt/PetStore/*.o
|
||||||
samples/client/petstore/qt5cpp/PetStore/PetStore
|
samples/client/petstore/cpp-qt/build-*
|
||||||
samples/client/petstore/qt5cpp/PetStore/Makefile
|
samples/client/petstore/cpp-qt/build-*
|
||||||
samples/client/petstore/qt5cpp/PetStore/PetStore.pro.user
|
samples/client/petstore/cpp-qt/PetStore/PetStore
|
||||||
|
samples/client/petstore/cpp-qt/PetStore/Makefile
|
||||||
|
samples/client/petstore/cpp-qt/PetStore/PetStore.pro.user
|
||||||
|
samples/client/petstore/cpp-qt/CMakeLists.txt.user
|
||||||
|
|
||||||
# cpprestsdk
|
# cpprestsdk
|
||||||
samples/client/petstore/cpp-restsdk/CMakeCache.txt
|
samples/client/petstore/cpp-restsdk/CMakeCache.txt
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
kind: pipeline
|
kind: pipeline
|
||||||
name: default
|
type: docker
|
||||||
|
name: java11-test
|
||||||
steps:
|
steps:
|
||||||
# test Java 11 HTTP client
|
# test Java 11 HTTP client
|
||||||
- name: java11-test
|
- name: java11-test
|
||||||
@ -15,11 +16,23 @@ steps:
|
|||||||
- /bin/bash bin/utils/test-fake-petstore-for-all.sh
|
- /bin/bash bin/utils/test-fake-petstore-for-all.sh
|
||||||
# generate test scripts
|
# generate test scripts
|
||||||
- /bin/bash bin/tests/run-all-test
|
- /bin/bash bin/tests/run-all-test
|
||||||
|
|
||||||
|
---
|
||||||
|
kind: pipeline
|
||||||
|
type: docker
|
||||||
|
name: nim-client-test
|
||||||
|
steps:
|
||||||
# test nim client
|
# test nim client
|
||||||
- name: nim-client-test
|
- name: nim-client-test
|
||||||
image: nimlang/nim
|
image: nimlang/nim
|
||||||
commands:
|
commands:
|
||||||
- (cd samples/client/petstore/nim/ && nim c sample_client.nim)
|
- (cd samples/client/petstore/nim/ && nim c sample_client.nim)
|
||||||
|
|
||||||
|
---
|
||||||
|
kind: pipeline
|
||||||
|
type: docker
|
||||||
|
name: protobuf-schema-test
|
||||||
|
steps:
|
||||||
# test protobuf schema generator
|
# test protobuf schema generator
|
||||||
- name: protobuf-schema-test
|
- name: protobuf-schema-test
|
||||||
image: nanoservice/protobuf-go
|
image: nanoservice/protobuf-go
|
||||||
@ -29,12 +42,24 @@ steps:
|
|||||||
- cd samples/config/petstore/protobuf-schema
|
- cd samples/config/petstore/protobuf-schema
|
||||||
- protoc --go_out=/var/tmp/go/ services/*
|
- protoc --go_out=/var/tmp/go/ services/*
|
||||||
- protoc --go_out=/var/tmp/go/ models/*
|
- protoc --go_out=/var/tmp/go/ models/*
|
||||||
|
|
||||||
|
---
|
||||||
|
kind: pipeline
|
||||||
|
type: docker
|
||||||
|
name: aspnetcore-test
|
||||||
|
steps:
|
||||||
# test aspnetcore 3.x
|
# test aspnetcore 3.x
|
||||||
- name: aspnetcore-test
|
- name: aspnetcore-test
|
||||||
image: mcr.microsoft.com/dotnet/core/sdk:3.1
|
image: mcr.microsoft.com/dotnet/core/sdk:3.1
|
||||||
commands:
|
commands:
|
||||||
- (cd samples/server/petstore/aspnetcore-3.1/ && /bin/sh build.sh)
|
- (cd samples/server/petstore/aspnetcore-3.1/ && /bin/sh build.sh)
|
||||||
- (cd samples/server/petstore/aspnetcore-3.0/ && /bin/sh build.sh)
|
- (cd samples/server/petstore/aspnetcore-3.0/ && /bin/sh build.sh)
|
||||||
|
|
||||||
|
---
|
||||||
|
kind: pipeline
|
||||||
|
type: docker
|
||||||
|
name: ocaml-test
|
||||||
|
steps:
|
||||||
# test ocaml petstore client
|
# test ocaml petstore client
|
||||||
- name: ocaml-test
|
- name: ocaml-test
|
||||||
image: ocaml/opam2:4.07
|
image: ocaml/opam2:4.07
|
||||||
@ -46,11 +71,23 @@ steps:
|
|||||||
- eval $(opam env)
|
- eval $(opam env)
|
||||||
- sudo chmod -R 777 .
|
- sudo chmod -R 777 .
|
||||||
- dune build --build-dir=./_build
|
- dune build --build-dir=./_build
|
||||||
|
|
||||||
|
---
|
||||||
|
kind: pipeline
|
||||||
|
type: docker
|
||||||
|
name: haskell-client-test
|
||||||
|
steps:
|
||||||
# test haskell client
|
# test haskell client
|
||||||
- name: haskell-client-test
|
- name: haskell-client-test
|
||||||
image: haskell:8.6.5
|
image: haskell:8.10.4
|
||||||
commands:
|
commands:
|
||||||
- (cd samples/client/petstore/haskell-http-client/ && stack --allow-different-user --install-ghc --no-haddock-deps haddock --fast && stack --allow-different-user test --fast)
|
- (cd samples/client/petstore/haskell-http-client/ && stack --allow-different-user --install-ghc --no-haddock-deps haddock --fast && stack --allow-different-user test --fast)
|
||||||
|
|
||||||
|
---
|
||||||
|
kind: pipeline
|
||||||
|
type: docker
|
||||||
|
name: erlang
|
||||||
|
steps:
|
||||||
# test erlang client and server
|
# test erlang client and server
|
||||||
- name: erlang
|
- name: erlang
|
||||||
image: erlang:alpine
|
image: erlang:alpine
|
||||||
|
@ -43,6 +43,21 @@ elif [ "$NODE_INDEX" = "2" ]; then
|
|||||||
|
|
||||||
# run integration tests
|
# run integration tests
|
||||||
mvn --no-snapshot-updates --quiet verify -Psamples.misc -Dorg.slf4j.simpleLogger.defaultLogLevel=error
|
mvn --no-snapshot-updates --quiet verify -Psamples.misc -Dorg.slf4j.simpleLogger.defaultLogLevel=error
|
||||||
|
elif [ "$NODE_INDEX" = "3" ]; then
|
||||||
|
|
||||||
|
echo "Running node $NODE_INDEX to test 'samples.circleci.node3' defined in pom.xml ..."
|
||||||
|
#wget https://www.python.org/ftp/python/3.8.9/Python-3.8.9.tgz
|
||||||
|
#tar -xf Python-3.8.9.tgz
|
||||||
|
#cd Python-3.8.9
|
||||||
|
#./configure --enable-optimizations
|
||||||
|
#sudo make altinstall
|
||||||
|
pyenv install --list
|
||||||
|
pyenv install 3.6.3
|
||||||
|
pyenv global 3.6.3
|
||||||
|
python3 --version
|
||||||
|
|
||||||
|
mvn --no-snapshot-updates --quiet verify -Psamples.circleci.node3 -Dorg.slf4j.simpleLogger.defaultLogLevel=error
|
||||||
|
|
||||||
else
|
else
|
||||||
echo "Running node $NODE_INDEX to test 'samples.circleci.others' defined in pom.xml ..."
|
echo "Running node $NODE_INDEX to test 'samples.circleci.others' defined in pom.xml ..."
|
||||||
#sudo update-java-alternatives -s java-1.7.0-openjdk-amd64
|
#sudo update-java-alternatives -s java-1.7.0-openjdk-amd64
|
||||||
|
@ -824,6 +824,7 @@ Here are some companies/projects (alphabetical order) using OpenAPI Generator in
|
|||||||
- 2021-07-16 - [銀行事業のサーバーサイド開発について / LINE 京都開発室 エンジニア採用説明会](https://www.youtube.com/watch?v=YrrKQHxLPpQ) by 野田誠人, Robert Mitchell
|
- 2021-07-16 - [銀行事業のサーバーサイド開発について / LINE 京都開発室 エンジニア採用説明会](https://www.youtube.com/watch?v=YrrKQHxLPpQ) by 野田誠人, Robert Mitchell
|
||||||
- 2021-07-29 - [How To Rewrite a Huge Codebase](https://dzone.com/articles/how-to-rewrite-a-huge-code-base) by [Curtis Poe](https://dzone.com/users/4565446/publiusovidius.html)
|
- 2021-07-29 - [How To Rewrite a Huge Codebase](https://dzone.com/articles/how-to-rewrite-a-huge-code-base) by [Curtis Poe](https://dzone.com/users/4565446/publiusovidius.html)
|
||||||
- 2021-08-21 - [Generating Client APIs using Swagger Part 1](https://medium.com/@flowsquad/generating-client-apis-using-swagger-part-1-2d46f13f5e92) by [FlowSquad.io](https://medium.com/@flowsquad)
|
- 2021-08-21 - [Generating Client APIs using Swagger Part 1](https://medium.com/@flowsquad/generating-client-apis-using-swagger-part-1-2d46f13f5e92) by [FlowSquad.io](https://medium.com/@flowsquad)
|
||||||
|
- 2021-09-11 - [Invoking AWS ParallelCluster API](https://docs.aws.amazon.com/parallelcluster/latest/ug/api-reference-v3.html) at [AWS ParallelCluster API official documentation](https://docs.aws.amazon.com/parallelcluster/latest/ug/api-reference-v3.html)
|
||||||
|
|
||||||
## [6 - About Us](#table-of-contents)
|
## [6 - About Us](#table-of-contents)
|
||||||
|
|
||||||
|
@ -2,3 +2,5 @@ generatorName: haskell-http-client
|
|||||||
outputDir: samples/client/petstore/haskell-http-client
|
outputDir: samples/client/petstore/haskell-http-client
|
||||||
inputSpec: modules/openapi-generator/src/test/resources/2_0/petstore-with-fake-endpoints-models-for-testing.yaml
|
inputSpec: modules/openapi-generator/src/test/resources/2_0/petstore-with-fake-endpoints-models-for-testing.yaml
|
||||||
templateDir: modules/openapi-generator/src/main/resources/haskell-http-client
|
templateDir: modules/openapi-generator/src/main/resources/haskell-http-client
|
||||||
|
additionalProperties:
|
||||||
|
queryExtraUnreserved: ''
|
||||||
|
@ -9,3 +9,4 @@ additionalProperties:
|
|||||||
podSummary: PetstoreClient
|
podSummary: PetstoreClient
|
||||||
projectName: PetstoreClient
|
projectName: PetstoreClient
|
||||||
podHomepage: https://github.com/openapitools/openapi-generator
|
podHomepage: https://github.com/openapitools/openapi-generator
|
||||||
|
removeMigrationProjectNameClass: true
|
||||||
|
@ -0,0 +1,10 @@
|
|||||||
|
generatorName: typescript-angular
|
||||||
|
outputDir: samples/client/petstore/typescript-angular-v12-provided-in-root/builds/with-npm
|
||||||
|
inputSpec: modules/openapi-generator/src/test/resources/2_0/petstore.yaml
|
||||||
|
templateDir: modules/openapi-generator/src/main/resources/typescript-angular
|
||||||
|
additionalProperties:
|
||||||
|
ngVersion: 12.0.0
|
||||||
|
npmVersion: 1.0.0
|
||||||
|
npmName: '@openapitools/typescript-angular-petstore'
|
||||||
|
npmRepository: https://skimdb.npmjs.com/registry
|
||||||
|
snapshot: false
|
6
bin/configs/typescript-angular-v12-provided-in-root.yaml
Normal file
6
bin/configs/typescript-angular-v12-provided-in-root.yaml
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
generatorName: typescript-angular
|
||||||
|
outputDir: samples/client/petstore/typescript-angular-v12-provided-in-root/builds/default
|
||||||
|
inputSpec: modules/openapi-generator/src/test/resources/2_0/petstore.yaml
|
||||||
|
templateDir: modules/openapi-generator/src/main/resources/typescript-angular
|
||||||
|
additionalProperties:
|
||||||
|
ngVersion: 12.0.0
|
@ -135,6 +135,9 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|
|||||||
<li>static</li>
|
<li>static</li>
|
||||||
<li>static_assert</li>
|
<li>static_assert</li>
|
||||||
<li>static_cast</li>
|
<li>static_cast</li>
|
||||||
|
<li>stderr</li>
|
||||||
|
<li>stdin</li>
|
||||||
|
<li>stdout</li>
|
||||||
<li>struct</li>
|
<li>struct</li>
|
||||||
<li>switch</li>
|
<li>switch</li>
|
||||||
<li>synchronized</li>
|
<li>synchronized</li>
|
||||||
|
@ -30,6 +30,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|
|||||||
|legacyDiscriminatorBehavior|Set to false for generators with better support for discriminators. (Python, Java, Go, PowerShell, C#have this enabled by default).|<dl><dt>**true**</dt><dd>The mapping in the discriminator includes descendent schemas that allOf inherit from self and the discriminator mapping schemas in the OAS document.</dd><dt>**false**</dt><dd>The mapping in the discriminator includes any descendent schemas that allOf inherit from self, any oneOf schemas, any anyOf schemas, any x-discriminator-values, and the discriminator mapping schemas in the OAS document AND Codegen validates that oneOf and anyOf schemas contain the required discriminator and throws an error if the discriminator is missing.</dd></dl>|true|
|
|legacyDiscriminatorBehavior|Set to false for generators with better support for discriminators. (Python, Java, Go, PowerShell, C#have this enabled by default).|<dl><dt>**true**</dt><dd>The mapping in the discriminator includes descendent schemas that allOf inherit from self and the discriminator mapping schemas in the OAS document.</dd><dt>**false**</dt><dd>The mapping in the discriminator includes any descendent schemas that allOf inherit from self, any oneOf schemas, any anyOf schemas, any x-discriminator-values, and the discriminator mapping schemas in the OAS document AND Codegen validates that oneOf and anyOf schemas contain the required discriminator and throws an error if the discriminator is missing.</dd></dl>|true|
|
||||||
|modelDeriving|Additional classes to include in the deriving() clause of Models| |null|
|
|modelDeriving|Additional classes to include in the deriving() clause of Models| |null|
|
||||||
|prependFormOrBodyParameters|Add form or body parameters to the beginning of the parameter list.| |false|
|
|prependFormOrBodyParameters|Add form or body parameters to the beginning of the parameter list.| |false|
|
||||||
|
|queryExtraUnreserved|Configures additional querystring characters which must not be URI encoded, e.g. '+' or ':'| |null|
|
||||||
|requestType|Set the name of the type used to generate requests| |null|
|
|requestType|Set the name of the type used to generate requests| |null|
|
||||||
|sortModelPropertiesByRequiredFlag|Sort model properties to place required parameters before optional parameters.| |true|
|
|sortModelPropertiesByRequiredFlag|Sort model properties to place required parameters before optional parameters.| |true|
|
||||||
|sortParamsByRequiredFlag|Sort method arguments to place required parameters before optional parameters.| |true|
|
|sortParamsByRequiredFlag|Sort method arguments to place required parameters before optional parameters.| |true|
|
||||||
|
@ -61,6 +61,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|
|||||||
<li>Any</li>
|
<li>Any</li>
|
||||||
<li>Array</li>
|
<li>Array</li>
|
||||||
<li>Boolean</li>
|
<li>Boolean</li>
|
||||||
|
<li>Byte</li>
|
||||||
<li>Double</li>
|
<li>Double</li>
|
||||||
<li>Float</li>
|
<li>Float</li>
|
||||||
<li>Int</li>
|
<li>Int</li>
|
||||||
|
@ -56,6 +56,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|
|||||||
<li>Any</li>
|
<li>Any</li>
|
||||||
<li>Array</li>
|
<li>Array</li>
|
||||||
<li>Boolean</li>
|
<li>Boolean</li>
|
||||||
|
<li>Byte</li>
|
||||||
<li>Double</li>
|
<li>Double</li>
|
||||||
<li>Float</li>
|
<li>Float</li>
|
||||||
<li>Int</li>
|
<li>Int</li>
|
||||||
|
@ -56,6 +56,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|
|||||||
<li>Any</li>
|
<li>Any</li>
|
||||||
<li>Array</li>
|
<li>Array</li>
|
||||||
<li>Boolean</li>
|
<li>Boolean</li>
|
||||||
|
<li>Byte</li>
|
||||||
<li>Double</li>
|
<li>Double</li>
|
||||||
<li>Float</li>
|
<li>Float</li>
|
||||||
<li>Int</li>
|
<li>Int</li>
|
||||||
|
@ -56,6 +56,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|
|||||||
<li>Any</li>
|
<li>Any</li>
|
||||||
<li>Array</li>
|
<li>Array</li>
|
||||||
<li>Boolean</li>
|
<li>Boolean</li>
|
||||||
|
<li>Byte</li>
|
||||||
<li>Double</li>
|
<li>Double</li>
|
||||||
<li>Float</li>
|
<li>Float</li>
|
||||||
<li>Int</li>
|
<li>Int</li>
|
||||||
|
@ -56,6 +56,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|
|||||||
<li>Any</li>
|
<li>Any</li>
|
||||||
<li>Array</li>
|
<li>Array</li>
|
||||||
<li>Boolean</li>
|
<li>Boolean</li>
|
||||||
|
<li>Byte</li>
|
||||||
<li>Double</li>
|
<li>Double</li>
|
||||||
<li>Float</li>
|
<li>Float</li>
|
||||||
<li>Int</li>
|
<li>Int</li>
|
||||||
|
@ -64,6 +64,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|
|||||||
<li>Any</li>
|
<li>Any</li>
|
||||||
<li>Array</li>
|
<li>Array</li>
|
||||||
<li>Boolean</li>
|
<li>Boolean</li>
|
||||||
|
<li>Byte</li>
|
||||||
<li>Double</li>
|
<li>Double</li>
|
||||||
<li>Float</li>
|
<li>Float</li>
|
||||||
<li>Int</li>
|
<li>Int</li>
|
||||||
|
@ -62,6 +62,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|
|||||||
<li>Any</li>
|
<li>Any</li>
|
||||||
<li>Array</li>
|
<li>Array</li>
|
||||||
<li>Boolean</li>
|
<li>Boolean</li>
|
||||||
|
<li>Byte</li>
|
||||||
<li>Double</li>
|
<li>Double</li>
|
||||||
<li>Float</li>
|
<li>Float</li>
|
||||||
<li>Int</li>
|
<li>Int</li>
|
||||||
|
@ -57,6 +57,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|
|||||||
<li>Any</li>
|
<li>Any</li>
|
||||||
<li>Array</li>
|
<li>Array</li>
|
||||||
<li>Boolean</li>
|
<li>Boolean</li>
|
||||||
|
<li>Byte</li>
|
||||||
<li>Double</li>
|
<li>Double</li>
|
||||||
<li>Float</li>
|
<li>Float</li>
|
||||||
<li>Int</li>
|
<li>Int</li>
|
||||||
|
@ -56,6 +56,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|
|||||||
<li>Any</li>
|
<li>Any</li>
|
||||||
<li>Array</li>
|
<li>Array</li>
|
||||||
<li>Boolean</li>
|
<li>Boolean</li>
|
||||||
|
<li>Byte</li>
|
||||||
<li>Double</li>
|
<li>Double</li>
|
||||||
<li>Float</li>
|
<li>Float</li>
|
||||||
<li>Int</li>
|
<li>Int</li>
|
||||||
|
@ -33,6 +33,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|
|||||||
|prependFormOrBodyParameters|Add form or body parameters to the beginning of the parameter list.| |false|
|
|prependFormOrBodyParameters|Add form or body parameters to the beginning of the parameter list.| |false|
|
||||||
|projectName|Project name in Xcode| |null|
|
|projectName|Project name in Xcode| |null|
|
||||||
|readonlyProperties|Make properties readonly (default: false)| |null|
|
|readonlyProperties|Make properties readonly (default: false)| |null|
|
||||||
|
|removeMigrationProjectNameClass|Make properties removeMigrationProjectNameClass (default: false)| |null|
|
||||||
|responseAs|Optionally use libraries to manage response. Currently PromiseKit, RxSwift, Result, Combine are available.| |null|
|
|responseAs|Optionally use libraries to manage response. Currently PromiseKit, RxSwift, Result, Combine are available.| |null|
|
||||||
|sortModelPropertiesByRequiredFlag|Sort model properties to place required parameters before optional parameters.| |true|
|
|sortModelPropertiesByRequiredFlag|Sort model properties to place required parameters before optional parameters.| |true|
|
||||||
|sortParamsByRequiredFlag|Sort method arguments to place required parameters before optional parameters.| |true|
|
|sortParamsByRequiredFlag|Sort method arguments to place required parameters before optional parameters.| |true|
|
||||||
|
@ -19,7 +19,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|
|||||||
|modelFileSuffix|The suffix of the file of the generated model (model<suffix>.ts).| |null|
|
|modelFileSuffix|The suffix of the file of the generated model (model<suffix>.ts).| |null|
|
||||||
|modelPropertyNaming|Naming convention for the property: 'camelCase', 'PascalCase', 'snake_case' and 'original', which keeps the original name. Only change it if you provide your own run-time code for (de-)serialization of models| |original|
|
|modelPropertyNaming|Naming convention for the property: 'camelCase', 'PascalCase', 'snake_case' and 'original', which keeps the original name. Only change it if you provide your own run-time code for (de-)serialization of models| |original|
|
||||||
|modelSuffix|The suffix of the generated model.| |null|
|
|modelSuffix|The suffix of the generated model.| |null|
|
||||||
|ngVersion|The version of Angular. (At least 6.0.0)| |11.0.0|
|
|ngVersion|The version of Angular. (At least 6.0.0)| |12.0.0|
|
||||||
|npmName|The name under which you want to publish generated npm package. Required to generate a full package| |null|
|
|npmName|The name under which you want to publish generated npm package. Required to generate a full package| |null|
|
||||||
|npmRepository|Use this property to set an url your private npmRepo in the package.json| |null|
|
|npmRepository|Use this property to set an url your private npmRepo in the package.json| |null|
|
||||||
|npmVersion|The version of your npm package. If not provided, using the version from the OpenAPI specification file.| |1.0.0|
|
|npmVersion|The version of your npm package. If not provided, using the version from the OpenAPI specification file.| |1.0.0|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
buildscript {
|
buildscript {
|
||||||
ext.kotlin_version = '1.3.20'
|
ext.kotlin_version = '1.3.30'
|
||||||
repositories {
|
repositories {
|
||||||
mavenLocal()
|
mavenLocal()
|
||||||
maven { url "https://repo1.maven.org/maven2" }
|
maven { url "https://repo1.maven.org/maven2" }
|
||||||
|
@ -644,6 +644,8 @@ open class GenerateTask : DefaultTask() {
|
|||||||
engine.ifNotEmpty { value ->
|
engine.ifNotEmpty { value ->
|
||||||
if ("handlebars".equals(value, ignoreCase = true)) {
|
if ("handlebars".equals(value, ignoreCase = true)) {
|
||||||
configurator.setTemplatingEngineName("handlebars")
|
configurator.setTemplatingEngineName("handlebars")
|
||||||
|
} else {
|
||||||
|
configurator.setTemplatingEngineName(value)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -228,4 +228,40 @@ class GenerateTaskDslTest : TestBase() {
|
|||||||
assertEquals(TaskOutcome.FAILED, result.task(":openApiGenerate")?.outcome,
|
assertEquals(TaskOutcome.FAILED, result.task(":openApiGenerate")?.outcome,
|
||||||
"Expected a failed run, but found ${result.task(":openApiGenerate")?.outcome}")
|
"Expected a failed run, but found ${result.task(":openApiGenerate")?.outcome}")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun `openapiGenerate should attempt to set my-custom-engine (or any other) when specified as engine`() {
|
||||||
|
// Arrange
|
||||||
|
val projectFiles = mapOf(
|
||||||
|
"spec.yaml" to javaClass.classLoader.getResourceAsStream("specs/petstore-v3.0.yaml")
|
||||||
|
)
|
||||||
|
|
||||||
|
withProject("""
|
||||||
|
plugins {
|
||||||
|
id 'org.openapi.generator'
|
||||||
|
}
|
||||||
|
openApiGenerate {
|
||||||
|
generatorName = "kotlin"
|
||||||
|
inputSpec = file("spec.yaml").absolutePath
|
||||||
|
outputDir = file("build/kotlin").absolutePath
|
||||||
|
apiPackage = "org.openapitools.example.api"
|
||||||
|
invokerPackage = "org.openapitools.example.invoker"
|
||||||
|
modelPackage = "org.openapitools.example.model"
|
||||||
|
engine = "my-custom-engine"
|
||||||
|
}
|
||||||
|
""".trimIndent(), projectFiles)
|
||||||
|
|
||||||
|
// Act
|
||||||
|
val result = GradleRunner.create()
|
||||||
|
.withProjectDir(temp)
|
||||||
|
.withArguments("openApiGenerate", "--stacktrace")
|
||||||
|
.withPluginClasspath()
|
||||||
|
.buildAndFail()
|
||||||
|
|
||||||
|
// Assert
|
||||||
|
// as the custom generator doesn't exist, we'll just test that the configurator has set my-custom-engine as the engine.
|
||||||
|
assertTrue(result.output.contains("my-custom-engine"), "Build should have attempted to use my-custom-engine.")
|
||||||
|
assertEquals(TaskOutcome.FAILED, result.task(":openApiGenerate")?.outcome,
|
||||||
|
"Expected a failed run, but found ${result.task(":openApiGenerate")?.outcome}")
|
||||||
|
}
|
||||||
}
|
}
|
@ -334,6 +334,18 @@
|
|||||||
<artifactId>jackson-core</artifactId>
|
<artifactId>jackson-core</artifactId>
|
||||||
<version>${jackson-version}</version>
|
<version>${jackson-version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.tngtech.archunit</groupId>
|
||||||
|
<artifactId>archunit</artifactId>
|
||||||
|
<version>0.20.1</version>
|
||||||
|
<scope>test</scope>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.tngtech.archunit</groupId>
|
||||||
|
<artifactId>archunit-junit4</artifactId>
|
||||||
|
<version>0.20.1</version>
|
||||||
|
<scope>test</scope>
|
||||||
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.testng</groupId>
|
<groupId>org.testng</groupId>
|
||||||
<artifactId>testng</artifactId>
|
<artifactId>testng</artifactId>
|
||||||
@ -433,6 +445,7 @@
|
|||||||
<artifactId>caffeine</artifactId>
|
<artifactId>caffeine</artifactId>
|
||||||
<version>2.8.1</version>
|
<version>2.8.1</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
</dependencies>
|
</dependencies>
|
||||||
<repositories>
|
<repositories>
|
||||||
<repository>
|
<repository>
|
||||||
|
@ -34,6 +34,10 @@ import java.util.Map;
|
|||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
public interface CodegenConfig {
|
public interface CodegenConfig {
|
||||||
|
String getFilesMetadataFilename();
|
||||||
|
|
||||||
|
String getVersionMetadataFilename();
|
||||||
|
|
||||||
GeneratorMetadata getGeneratorMetadata();
|
GeneratorMetadata getGeneratorMetadata();
|
||||||
|
|
||||||
CodegenType getTag();
|
CodegenType getTag();
|
||||||
|
@ -27,7 +27,7 @@ import java.util.*;
|
|||||||
public class CodegenParameter implements IJsonSchemaValidationProperties {
|
public class CodegenParameter implements IJsonSchemaValidationProperties {
|
||||||
public boolean isFormParam, isQueryParam, isPathParam, isHeaderParam,
|
public boolean isFormParam, isQueryParam, isPathParam, isHeaderParam,
|
||||||
isCookieParam, isBodyParam, isContainer,
|
isCookieParam, isBodyParam, isContainer,
|
||||||
isCollectionFormatMulti, isPrimitiveType, isModel, isExplode, isDeepObject;
|
isCollectionFormatMulti, isPrimitiveType, isModel, isExplode, isDeepObject, isAllowEmptyValue;
|
||||||
public String baseName, paramName, dataType, datatypeWithEnum, dataFormat, contentType,
|
public String baseName, paramName, dataType, datatypeWithEnum, dataFormat, contentType,
|
||||||
collectionFormat, description, unescapedDescription, baseType, defaultValue, enumName, style;
|
collectionFormat, description, unescapedDescription, baseType, defaultValue, enumName, style;
|
||||||
|
|
||||||
@ -208,6 +208,7 @@ public class CodegenParameter implements IJsonSchemaValidationProperties {
|
|||||||
output.isExplode = this.isExplode;
|
output.isExplode = this.isExplode;
|
||||||
output.style = this.style;
|
output.style = this.style;
|
||||||
output.isDeepObject = this.isDeepObject;
|
output.isDeepObject = this.isDeepObject;
|
||||||
|
output.isAllowEmptyValue = this.isAllowEmptyValue;
|
||||||
output.contentType = this.contentType;
|
output.contentType = this.contentType;
|
||||||
|
|
||||||
return output;
|
return output;
|
||||||
@ -215,7 +216,7 @@ public class CodegenParameter implements IJsonSchemaValidationProperties {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int hashCode() {
|
public int hashCode() {
|
||||||
return Objects.hash(isFormParam, isQueryParam, isPathParam, isHeaderParam, isCookieParam, isBodyParam, isContainer, isCollectionFormatMulti, isPrimitiveType, isModel, isExplode, baseName, paramName, dataType, datatypeWithEnum, dataFormat, collectionFormat, description, unescapedDescription, baseType, defaultValue, enumName, style, isDeepObject, example, jsonSchema, isString, isNumeric, isInteger, isLong, isNumber, isFloat, isDouble, isDecimal, isByteArray, isBinary, isBoolean, isDate, isDateTime, isUuid, isUri, isEmail, isFreeFormObject, isAnyType, isArray, isMap, isFile, isEnum, _enum, allowableValues, items, mostInnerItems, additionalProperties, vars, requiredVars, vendorExtensions, hasValidation, getMaxProperties(), getMinProperties(), isNullable, isDeprecated, required, getMaximum(), getExclusiveMaximum(), getMinimum(), getExclusiveMinimum(), getMaxLength(), getMinLength(), getPattern(), getMaxItems(), getMinItems(), getUniqueItems(), contentType, multipleOf, isNull, additionalPropertiesIsAnyType, hasVars, hasRequired, isShort, isUnboundedInteger, hasDiscriminatorWithNonEmptyMapping);
|
return Objects.hash(isFormParam, isQueryParam, isPathParam, isHeaderParam, isCookieParam, isBodyParam, isContainer, isCollectionFormatMulti, isPrimitiveType, isModel, isExplode, baseName, paramName, dataType, datatypeWithEnum, dataFormat, collectionFormat, description, unescapedDescription, baseType, defaultValue, enumName, style, isDeepObject, isAllowEmptyValue, example, jsonSchema, isString, isNumeric, isInteger, isLong, isNumber, isFloat, isDouble, isDecimal, isByteArray, isBinary, isBoolean, isDate, isDateTime, isUuid, isUri, isEmail, isFreeFormObject, isAnyType, isArray, isMap, isFile, isEnum, _enum, allowableValues, items, mostInnerItems, additionalProperties, vars, requiredVars, vendorExtensions, hasValidation, getMaxProperties(), getMinProperties(), isNullable, isDeprecated, required, getMaximum(), getExclusiveMaximum(), getMinimum(), getExclusiveMinimum(), getMaxLength(), getMinLength(), getPattern(), getMaxItems(), getMinItems(), getUniqueItems(), contentType, multipleOf, isNull, additionalPropertiesIsAnyType, hasVars, hasRequired, isShort, isUnboundedInteger, hasDiscriminatorWithNonEmptyMapping);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -283,6 +284,7 @@ public class CodegenParameter implements IJsonSchemaValidationProperties {
|
|||||||
Objects.equals(enumName, that.enumName) &&
|
Objects.equals(enumName, that.enumName) &&
|
||||||
Objects.equals(style, that.style) &&
|
Objects.equals(style, that.style) &&
|
||||||
Objects.equals(isDeepObject, that.isDeepObject) &&
|
Objects.equals(isDeepObject, that.isDeepObject) &&
|
||||||
|
Objects.equals(isAllowEmptyValue, that.isAllowEmptyValue) &&
|
||||||
Objects.equals(example, that.example) &&
|
Objects.equals(example, that.example) &&
|
||||||
Objects.equals(jsonSchema, that.jsonSchema) &&
|
Objects.equals(jsonSchema, that.jsonSchema) &&
|
||||||
Objects.equals(_enum, that._enum) &&
|
Objects.equals(_enum, that._enum) &&
|
||||||
@ -333,6 +335,7 @@ public class CodegenParameter implements IJsonSchemaValidationProperties {
|
|||||||
sb.append(", enumName='").append(enumName).append('\'');
|
sb.append(", enumName='").append(enumName).append('\'');
|
||||||
sb.append(", style='").append(style).append('\'');
|
sb.append(", style='").append(style).append('\'');
|
||||||
sb.append(", deepObject='").append(isDeepObject).append('\'');
|
sb.append(", deepObject='").append(isDeepObject).append('\'');
|
||||||
|
sb.append(", allowEmptyValue='").append(isAllowEmptyValue).append('\'');
|
||||||
sb.append(", example='").append(example).append('\'');
|
sb.append(", example='").append(example).append('\'');
|
||||||
sb.append(", jsonSchema='").append(jsonSchema).append('\'');
|
sb.append(", jsonSchema='").append(jsonSchema).append('\'');
|
||||||
sb.append(", isString=").append(isString);
|
sb.append(", isString=").append(isString);
|
||||||
|
@ -152,6 +152,8 @@ public class DefaultCodegen implements CodegenConfig {
|
|||||||
protected String modelNamePrefix = "", modelNameSuffix = "";
|
protected String modelNamePrefix = "", modelNameSuffix = "";
|
||||||
protected String apiNamePrefix = "", apiNameSuffix = "Api";
|
protected String apiNamePrefix = "", apiNameSuffix = "Api";
|
||||||
protected String testPackage = "";
|
protected String testPackage = "";
|
||||||
|
protected String filesMetadataFilename = "FILES";
|
||||||
|
protected String versionMetadataFilename = "VERSION";
|
||||||
/*
|
/*
|
||||||
apiTemplateFiles are for API outputs only (controllers/handlers).
|
apiTemplateFiles are for API outputs only (controllers/handlers).
|
||||||
API templates may be written multiple times; APIs are grouped by tag and the file is written once per tag group.
|
API templates may be written multiple times; APIs are grouped by tag and the file is written once per tag group.
|
||||||
@ -1177,6 +1179,24 @@ public class DefaultCodegen implements CodegenConfig {
|
|||||||
this.inputSpec = inputSpec;
|
this.inputSpec = inputSpec;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getFilesMetadataFilename() {
|
||||||
|
return filesMetadataFilename;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setFilesMetadataFilename(String filesMetadataFilename) {
|
||||||
|
this.filesMetadataFilename = filesMetadataFilename;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getVersionMetadataFilename() {
|
||||||
|
return versionMetadataFilename;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setVersionMetadataFilename(String versionMetadataFilename) {
|
||||||
|
this.versionMetadataFilename = versionMetadataFilename;
|
||||||
|
}
|
||||||
|
|
||||||
public void setTemplateDir(String templateDir) {
|
public void setTemplateDir(String templateDir) {
|
||||||
this.templateDir = templateDir;
|
this.templateDir = templateDir;
|
||||||
}
|
}
|
||||||
@ -1560,6 +1580,7 @@ public class DefaultCodegen implements CodegenConfig {
|
|||||||
typeMapping.put("char", "String");
|
typeMapping.put("char", "String");
|
||||||
typeMapping.put("object", "Object");
|
typeMapping.put("object", "Object");
|
||||||
typeMapping.put("integer", "Integer");
|
typeMapping.put("integer", "Integer");
|
||||||
|
// FIXME: java specific type should be in Java Based Abstract Impl's
|
||||||
typeMapping.put("ByteArray", "byte[]");
|
typeMapping.put("ByteArray", "byte[]");
|
||||||
typeMapping.put("binary", "File");
|
typeMapping.put("binary", "File");
|
||||||
typeMapping.put("file", "File");
|
typeMapping.put("file", "File");
|
||||||
@ -2834,7 +2855,7 @@ public class DefaultCodegen implements CodegenConfig {
|
|||||||
"'{}' defines discriminator '{}', but the referenced OneOf schema '{}' is missing {}",
|
"'{}' defines discriminator '{}', but the referenced OneOf schema '{}' is missing {}",
|
||||||
composedSchemaName, discPropName, modelName, discPropName);
|
composedSchemaName, discPropName, modelName, discPropName);
|
||||||
}
|
}
|
||||||
if (cp.dataType == null) {
|
if (cp != null && cp.dataType == null) {
|
||||||
cp = thisCp;
|
cp = thisCp;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -3030,13 +3051,16 @@ public class DefaultCodegen implements CodegenConfig {
|
|||||||
MappedModel mm = new MappedModel(modelName, toModelName(modelName));
|
MappedModel mm = new MappedModel(modelName, toModelName(modelName));
|
||||||
descendentSchemas.add(mm);
|
descendentSchemas.add(mm);
|
||||||
Schema cs = ModelUtils.getSchema(openAPI, modelName);
|
Schema cs = ModelUtils.getSchema(openAPI, modelName);
|
||||||
Map<String, Object> vendorExtensions = cs.getExtensions();
|
if (cs == null) { // cannot lookup the model based on the name
|
||||||
if (vendorExtensions != null && !vendorExtensions.isEmpty() && vendorExtensions.containsKey("x-discriminator-value")) {
|
LOGGER.error("Failed to lookup the schema '{}' when processing oneOf/anyOf. Please check to ensure it's defined properly.", modelName);
|
||||||
String xDiscriminatorValue = (String) vendorExtensions.get("x-discriminator-value");
|
} else {
|
||||||
mm = new MappedModel(xDiscriminatorValue, toModelName(modelName));
|
Map<String, Object> vendorExtensions = cs.getExtensions();
|
||||||
descendentSchemas.add(mm);
|
if (vendorExtensions != null && !vendorExtensions.isEmpty() && vendorExtensions.containsKey("x-discriminator-value")) {
|
||||||
|
String xDiscriminatorValue = (String) vendorExtensions.get("x-discriminator-value");
|
||||||
|
mm = new MappedModel(xDiscriminatorValue, toModelName(modelName));
|
||||||
|
descendentSchemas.add(mm);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return descendentSchemas;
|
return descendentSchemas;
|
||||||
@ -4547,6 +4571,7 @@ public class DefaultCodegen implements CodegenConfig {
|
|||||||
|
|
||||||
if (parameter instanceof QueryParameter || "query".equalsIgnoreCase(parameter.getIn())) {
|
if (parameter instanceof QueryParameter || "query".equalsIgnoreCase(parameter.getIn())) {
|
||||||
codegenParameter.isQueryParam = true;
|
codegenParameter.isQueryParam = true;
|
||||||
|
codegenParameter.isAllowEmptyValue = parameter.getAllowEmptyValue() != null && parameter.getAllowEmptyValue();
|
||||||
} else if (parameter instanceof PathParameter || "path".equalsIgnoreCase(parameter.getIn())) {
|
} else if (parameter instanceof PathParameter || "path".equalsIgnoreCase(parameter.getIn())) {
|
||||||
codegenParameter.required = true;
|
codegenParameter.required = true;
|
||||||
codegenParameter.isPathParam = true;
|
codegenParameter.isPathParam = true;
|
||||||
|
@ -1427,7 +1427,7 @@ public class DefaultGenerator implements Generator {
|
|||||||
* @param files The list tracking generated files
|
* @param files The list tracking generated files
|
||||||
*/
|
*/
|
||||||
private void generateVersionMetadata(List<File> files) {
|
private void generateVersionMetadata(List<File> files) {
|
||||||
String versionMetadata = config.outputFolder() + File.separator + METADATA_DIR + File.separator + "VERSION";
|
String versionMetadata = config.outputFolder() + File.separator + METADATA_DIR + File.separator + config.getVersionMetadataFilename();
|
||||||
if (generateMetadata) {
|
if (generateMetadata) {
|
||||||
File versionMetadataFile = new File(versionMetadata);
|
File versionMetadataFile = new File(versionMetadata);
|
||||||
try {
|
try {
|
||||||
@ -1495,7 +1495,7 @@ public class DefaultGenerator implements Generator {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
String targetFile = config.outputFolder() + File.separator + METADATA_DIR + File.separator + "FILES";
|
String targetFile = config.outputFolder() + File.separator + METADATA_DIR + File.separator + config.getFilesMetadataFilename();
|
||||||
|
|
||||||
File filesFile = this.templateProcessor.writeToFile(targetFile, sb.toString().getBytes(StandardCharsets.UTF_8));
|
File filesFile = this.templateProcessor.writeToFile(targetFile, sb.toString().getBytes(StandardCharsets.UTF_8));
|
||||||
if (filesFile != null) {
|
if (filesFile != null) {
|
||||||
|
@ -26,7 +26,7 @@ import static org.openapitools.codegen.utils.StringUtils.*;
|
|||||||
|
|
||||||
public abstract class AbstractDartCodegen extends DefaultCodegen {
|
public abstract class AbstractDartCodegen extends DefaultCodegen {
|
||||||
|
|
||||||
private static final Logger LOGGER = LoggerFactory.getLogger(AbstractDartCodegen.class);
|
private final Logger LOGGER = LoggerFactory.getLogger(AbstractDartCodegen.class);
|
||||||
|
|
||||||
protected static final List<String> DEFAULT_SUPPORTED_CONTENT_TYPES = Arrays.asList(
|
protected static final List<String> DEFAULT_SUPPORTED_CONTENT_TYPES = Arrays.asList(
|
||||||
"application/json", "application/x-www-form-urlencoded", "multipart/form-data");
|
"application/json", "application/x-www-form-urlencoded", "multipart/form-data");
|
||||||
|
@ -350,6 +350,9 @@ public abstract class AbstractGoCodegen extends DefaultCodegen implements Codege
|
|||||||
} else {
|
} else {
|
||||||
typDecl = "interface{}";
|
typDecl = "interface{}";
|
||||||
}
|
}
|
||||||
|
if (inner != null && Boolean.TRUE.equals(inner.getNullable())) {
|
||||||
|
typDecl = "*" + typDecl;
|
||||||
|
}
|
||||||
return "[]" + typDecl;
|
return "[]" + typDecl;
|
||||||
} else if (ModelUtils.isMapSchema(p)) {
|
} else if (ModelUtils.isMapSchema(p)) {
|
||||||
Schema inner = getAdditionalProperties(p);
|
Schema inner = getAdditionalProperties(p);
|
||||||
|
@ -1001,7 +1001,7 @@ public abstract class AbstractJavaCodegen extends DefaultCodegen implements Code
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toDefaultParameterValue(final Schema<?> schema) {
|
public String toDefaultParameterValue(final Schema<?> schema) {
|
||||||
Object defaultValue = schema.getDefault();
|
Object defaultValue = schema.get$ref() != null ? ModelUtils.getReferencedSchema(openAPI, schema).getDefault() : schema.getDefault();
|
||||||
if (defaultValue == null) {
|
if (defaultValue == null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@ -1087,7 +1087,12 @@ public abstract class AbstractJavaCodegen extends DefaultCodegen implements Code
|
|||||||
public void setParameterExampleValue(CodegenParameter p) {
|
public void setParameterExampleValue(CodegenParameter p) {
|
||||||
String example;
|
String example;
|
||||||
|
|
||||||
if (p.defaultValue == null) {
|
boolean hasAllowableValues = p.allowableValues != null && !p.allowableValues.isEmpty();
|
||||||
|
if (hasAllowableValues) {
|
||||||
|
//support examples for inline enums
|
||||||
|
final List<Object> values = (List<Object>) p.allowableValues.get("values");
|
||||||
|
example = String.valueOf(values.get(0));
|
||||||
|
} else if (p.defaultValue == null) {
|
||||||
example = p.example;
|
example = p.example;
|
||||||
} else {
|
} else {
|
||||||
example = p.defaultValue;
|
example = p.defaultValue;
|
||||||
@ -1133,14 +1138,33 @@ public abstract class AbstractJavaCodegen extends DefaultCodegen implements Code
|
|||||||
example = "new File(\"" + escapeText(example) + "\")";
|
example = "new File(\"" + escapeText(example) + "\")";
|
||||||
} else if ("Date".equals(type)) {
|
} else if ("Date".equals(type)) {
|
||||||
example = "new Date()";
|
example = "new Date()";
|
||||||
|
} else if ("LocalDate".equals(type)) {
|
||||||
|
if (example == null) {
|
||||||
|
example = "LocalDate.now()";
|
||||||
|
} else {
|
||||||
|
example = "LocalDate.parse(\"" + example + "\")";
|
||||||
|
}
|
||||||
} else if ("OffsetDateTime".equals(type)) {
|
} else if ("OffsetDateTime".equals(type)) {
|
||||||
example = "OffsetDateTime.now()";
|
if (example == null) {
|
||||||
|
example = "OffsetDateTime.now()";
|
||||||
|
} else {
|
||||||
|
example = "OffsetDateTime.parse(\"" + example + "\")";
|
||||||
|
}
|
||||||
} else if ("BigDecimal".equals(type)) {
|
} else if ("BigDecimal".equals(type)) {
|
||||||
example = "new BigDecimal(78)";
|
if (example == null) {
|
||||||
} else if (p.allowableValues != null && !p.allowableValues.isEmpty()) {
|
example = "new BigDecimal(78)";
|
||||||
Map<String, Object> allowableValues = p.allowableValues;
|
} else {
|
||||||
List<Object> values = (List<Object>) allowableValues.get("values");
|
example = "new BigDecimal(\"" + example + "\")";
|
||||||
example = type + ".fromValue(\"" + String.valueOf(values.get(0)) + "\")";
|
}
|
||||||
|
} else if ("UUID".equals(type)) {
|
||||||
|
if (example == null) {
|
||||||
|
example = "UUID.randomUUID()";
|
||||||
|
} else {
|
||||||
|
example = "UUID.fromString(\"" + example + "\")";
|
||||||
|
}
|
||||||
|
} else if (hasAllowableValues) {
|
||||||
|
//parameter is enum defined as a schema component
|
||||||
|
example = type + ".fromValue(\"" + example + "\")";
|
||||||
} else if (!languageSpecificPrimitives.contains(type)) {
|
} else if (!languageSpecificPrimitives.contains(type)) {
|
||||||
// type is a model class, e.g. User
|
// type is a model class, e.g. User
|
||||||
example = "new " + type + "()";
|
example = "new " + type + "()";
|
||||||
|
@ -631,7 +631,7 @@ public abstract class AbstractPhpCodegen extends DefaultCodegen implements Codeg
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toEnumDefaultValue(String value, String datatype) {
|
public String toEnumDefaultValue(String value, String datatype) {
|
||||||
return datatype + "_" + value;
|
return "self::" + datatype + "_" + value;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -73,7 +73,8 @@ public abstract class AbstractScalaCodegen extends DefaultCodegen {
|
|||||||
"List",
|
"List",
|
||||||
"Seq",
|
"Seq",
|
||||||
"Map",
|
"Map",
|
||||||
"Array"));
|
"Array",
|
||||||
|
"Byte"));
|
||||||
|
|
||||||
reservedWords.addAll(Arrays.asList(
|
reservedWords.addAll(Arrays.asList(
|
||||||
"abstract",
|
"abstract",
|
||||||
@ -118,6 +119,10 @@ public abstract class AbstractScalaCodegen extends DefaultCodegen {
|
|||||||
"yield"
|
"yield"
|
||||||
));
|
));
|
||||||
|
|
||||||
|
// Scala specific openApi types mapping
|
||||||
|
typeMapping.put("ByteArray", "Array[Byte]");
|
||||||
|
|
||||||
|
|
||||||
importMapping = new HashMap<String, String>();
|
importMapping = new HashMap<String, String>();
|
||||||
importMapping.put("ListBuffer", "scala.collection.mutable.ListBuffer");
|
importMapping.put("ListBuffer", "scala.collection.mutable.ListBuffer");
|
||||||
// although Seq is a predef, before Scala 2.13, it _could_ refer to a mutable Seq in some cases.
|
// although Seq is a predef, before Scala 2.13, it _could_ refer to a mutable Seq in some cases.
|
||||||
@ -344,17 +349,11 @@ public abstract class AbstractScalaCodegen extends DefaultCodegen {
|
|||||||
if (ModelUtils.isSet(p)) {
|
if (ModelUtils.isSet(p)) {
|
||||||
openAPIType = "set";
|
openAPIType = "set";
|
||||||
}
|
}
|
||||||
|
// don't apply renaming on types from the typeMapping
|
||||||
String type;
|
|
||||||
if (typeMapping.containsKey(openAPIType)) {
|
if (typeMapping.containsKey(openAPIType)) {
|
||||||
type = typeMapping.get(openAPIType);
|
return typeMapping.get(openAPIType);
|
||||||
if (languageSpecificPrimitives.contains(type)) {
|
|
||||||
return toModelName(type);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
type = openAPIType;
|
|
||||||
}
|
}
|
||||||
return toModelName(type);
|
return toModelName(openAPIType);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -64,7 +64,7 @@ public class AspNetCoreServerCodegen extends AbstractCSharpCodegen {
|
|||||||
private String packageGuid = "{" + randomUUID().toString().toUpperCase(Locale.ROOT) + "}";
|
private String packageGuid = "{" + randomUUID().toString().toUpperCase(Locale.ROOT) + "}";
|
||||||
private String userSecretsGuid = randomUUID().toString();
|
private String userSecretsGuid = randomUUID().toString();
|
||||||
|
|
||||||
protected Logger LOGGER = LoggerFactory.getLogger(AspNetCoreServerCodegen.class);
|
protected final Logger LOGGER = LoggerFactory.getLogger(AspNetCoreServerCodegen.class);
|
||||||
|
|
||||||
private boolean useSwashbuckle = true;
|
private boolean useSwashbuckle = true;
|
||||||
protected int serverPort = 8080;
|
protected int serverPort = 8080;
|
||||||
|
@ -245,7 +245,12 @@ public class CLibcurlClientCodegen extends DefaultCodegen implements CodegenConf
|
|||||||
"final",
|
"final",
|
||||||
"override",
|
"override",
|
||||||
"transaction_safe",
|
"transaction_safe",
|
||||||
"transaction_safe_dynamic")
|
"transaction_safe_dynamic",
|
||||||
|
|
||||||
|
// VC++ reserved keywords
|
||||||
|
"stdin",
|
||||||
|
"stdout",
|
||||||
|
"stderr")
|
||||||
);
|
);
|
||||||
|
|
||||||
instantiationTypes.clear();
|
instantiationTypes.clear();
|
||||||
|
@ -56,7 +56,7 @@ public class CSharpNetCoreClientCodegen extends AbstractCSharpCodegen {
|
|||||||
protected static final String TARGET_FRAMEWORK_VERSION = "targetFrameworkVersion";
|
protected static final String TARGET_FRAMEWORK_VERSION = "targetFrameworkVersion";
|
||||||
|
|
||||||
@SuppressWarnings({"hiding"})
|
@SuppressWarnings({"hiding"})
|
||||||
private static final Logger LOGGER = LoggerFactory.getLogger(CSharpClientCodegen.class);
|
private final Logger LOGGER = LoggerFactory.getLogger(CSharpClientCodegen.class);
|
||||||
private static final List<FrameworkStrategy> frameworkStrategies = Arrays.asList(
|
private static final List<FrameworkStrategy> frameworkStrategies = Arrays.asList(
|
||||||
FrameworkStrategy.NETSTANDARD_1_3,
|
FrameworkStrategy.NETSTANDARD_1_3,
|
||||||
FrameworkStrategy.NETSTANDARD_1_4,
|
FrameworkStrategy.NETSTANDARD_1_4,
|
||||||
@ -973,6 +973,9 @@ public class CSharpNetCoreClientCodegen extends AbstractCSharpCodegen {
|
|||||||
// https://docs.microsoft.com/en-us/dotnet/standard/net-standard
|
// https://docs.microsoft.com/en-us/dotnet/standard/net-standard
|
||||||
@SuppressWarnings("Duplicates")
|
@SuppressWarnings("Duplicates")
|
||||||
private static abstract class FrameworkStrategy {
|
private static abstract class FrameworkStrategy {
|
||||||
|
|
||||||
|
private final Logger LOGGER = LoggerFactory.getLogger(CSharpClientCodegen.class);
|
||||||
|
|
||||||
static FrameworkStrategy NETSTANDARD_1_3 = new FrameworkStrategy("netstandard1.3", ".NET Standard 1.3 compatible", "netcoreapp2.0") {
|
static FrameworkStrategy NETSTANDARD_1_3 = new FrameworkStrategy("netstandard1.3", ".NET Standard 1.3 compatible", "netcoreapp2.0") {
|
||||||
};
|
};
|
||||||
static FrameworkStrategy NETSTANDARD_1_4 = new FrameworkStrategy("netstandard1.4", ".NET Standard 1.4 compatible", "netcoreapp2.0") {
|
static FrameworkStrategy NETSTANDARD_1_4 = new FrameworkStrategy("netstandard1.4", ".NET Standard 1.4 compatible", "netcoreapp2.0") {
|
||||||
|
@ -13,7 +13,8 @@ import org.slf4j.LoggerFactory;
|
|||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
||||||
public class CppQtAbstractCodegen extends AbstractCppCodegen implements CodegenConfig {
|
public abstract class CppQtAbstractCodegen extends AbstractCppCodegen implements CodegenConfig {
|
||||||
|
|
||||||
private final Logger LOGGER = LoggerFactory.getLogger(CppQtAbstractCodegen.class);
|
private final Logger LOGGER = LoggerFactory.getLogger(CppQtAbstractCodegen.class);
|
||||||
protected final String PREFIX = "OAI";
|
protected final String PREFIX = "OAI";
|
||||||
protected String apiVersion = "1.0.0";
|
protected String apiVersion = "1.0.0";
|
||||||
|
@ -23,7 +23,6 @@ import org.apache.commons.lang3.StringUtils;
|
|||||||
import org.openapitools.codegen.*;
|
import org.openapitools.codegen.*;
|
||||||
import org.openapitools.codegen.meta.features.*;
|
import org.openapitools.codegen.meta.features.*;
|
||||||
import org.openapitools.codegen.utils.ModelUtils;
|
import org.openapitools.codegen.utils.ModelUtils;
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
@ -33,8 +32,6 @@ import static org.openapitools.codegen.utils.StringUtils.camelize;
|
|||||||
|
|
||||||
public class CppRestbedServerCodegen extends AbstractCppCodegen {
|
public class CppRestbedServerCodegen extends AbstractCppCodegen {
|
||||||
|
|
||||||
private static final org.slf4j.Logger LOGGER = LoggerFactory.getLogger(CppRestbedServerCodegen.class);
|
|
||||||
|
|
||||||
public static final String DECLSPEC = "declspec";
|
public static final String DECLSPEC = "declspec";
|
||||||
public static final String DEFAULT_INCLUDE = "defaultInclude";
|
public static final String DEFAULT_INCLUDE = "defaultInclude";
|
||||||
|
|
||||||
|
@ -36,7 +36,7 @@ import org.slf4j.LoggerFactory;
|
|||||||
public class CppTinyClientCodegen extends AbstractCppCodegen implements CodegenConfig {
|
public class CppTinyClientCodegen extends AbstractCppCodegen implements CodegenConfig {
|
||||||
public static final String PROJECT_NAME = "TinyClient";
|
public static final String PROJECT_NAME = "TinyClient";
|
||||||
|
|
||||||
static final Logger LOGGER = LoggerFactory.getLogger(CppTinyClientCodegen.class);
|
final Logger LOGGER = LoggerFactory.getLogger(CppTinyClientCodegen.class);
|
||||||
|
|
||||||
public static final String MICROCONTROLLER = "controller";
|
public static final String MICROCONTROLLER = "controller";
|
||||||
public static final String rootFolder = "";
|
public static final String rootFolder = "";
|
||||||
@ -71,10 +71,9 @@ public class CppTinyClientCodegen extends AbstractCppCodegen implements CodegenC
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void addControllerToAdditionalProperties() {
|
public void addControllerToAdditionalProperties() {
|
||||||
Map<String, String> supportedControllers = new HashMap<String, String>() {{
|
Map<String, String> supportedControllers = new HashMap<String, String>();
|
||||||
put("esp32", "isESP32");
|
supportedControllers.put("esp32", "isESP32");
|
||||||
put("esp8266", "isESP8266");
|
supportedControllers.put("esp8266", "isESP8266");
|
||||||
}};
|
|
||||||
if (supportedControllers.containsKey(controller)) {
|
if (supportedControllers.containsKey(controller)) {
|
||||||
additionalProperties.put(supportedControllers.get(controller), true);
|
additionalProperties.put(supportedControllers.get(controller), true);
|
||||||
} else {
|
} else {
|
||||||
|
@ -37,7 +37,7 @@ import static org.openapitools.codegen.utils.StringUtils.underscore;
|
|||||||
|
|
||||||
public class DartDioNextClientCodegen extends AbstractDartCodegen {
|
public class DartDioNextClientCodegen extends AbstractDartCodegen {
|
||||||
|
|
||||||
private static final Logger LOGGER = LoggerFactory.getLogger(DartDioNextClientCodegen.class);
|
private final Logger LOGGER = LoggerFactory.getLogger(DartDioNextClientCodegen.class);
|
||||||
|
|
||||||
public static final String DATE_LIBRARY = "dateLibrary";
|
public static final String DATE_LIBRARY = "dateLibrary";
|
||||||
public static final String DATE_LIBRARY_CORE = "core";
|
public static final String DATE_LIBRARY_CORE = "core";
|
||||||
|
@ -50,7 +50,7 @@ public class FsharpGiraffeServerCodegen extends AbstractFSharpCodegen {
|
|||||||
private String packageGuid = "{" + randomUUID().toString().toUpperCase(Locale.ROOT) + "}";
|
private String packageGuid = "{" + randomUUID().toString().toUpperCase(Locale.ROOT) + "}";
|
||||||
|
|
||||||
@SuppressWarnings("hiding")
|
@SuppressWarnings("hiding")
|
||||||
protected Logger LOGGER = LoggerFactory.getLogger(FsharpGiraffeServerCodegen.class);
|
protected final Logger LOGGER = LoggerFactory.getLogger(FsharpGiraffeServerCodegen.class);
|
||||||
|
|
||||||
private boolean useSwashbuckle = false;
|
private boolean useSwashbuckle = false;
|
||||||
protected int serverPort = 8080;
|
protected int serverPort = 8080;
|
||||||
|
@ -544,6 +544,10 @@ public class GoClientCodegen extends AbstractGoCodegen {
|
|||||||
if (modelMaps.containsKey(dataType)) {
|
if (modelMaps.containsKey(dataType)) {
|
||||||
prefix = "[]" + goImportAlias + "." + dataType;
|
prefix = "[]" + goImportAlias + "." + dataType;
|
||||||
}
|
}
|
||||||
|
if (codegenProperty.items.isNullable) {
|
||||||
|
// We can't easily generate a pointer inline, so just use nil in that case
|
||||||
|
return prefix + "{nil}";
|
||||||
|
}
|
||||||
return prefix + "{" + constructExampleCode(codegenProperty.items, modelMaps, processedModelMap) + "}";
|
return prefix + "{" + constructExampleCode(codegenProperty.items, modelMaps, processedModelMap) + "}";
|
||||||
} else if (codegenProperty.isMap) { // map
|
} else if (codegenProperty.isMap) { // map
|
||||||
String prefix = codegenProperty.dataType;
|
String prefix = codegenProperty.dataType;
|
||||||
|
@ -17,19 +17,17 @@
|
|||||||
package org.openapitools.codegen.languages;
|
package org.openapitools.codegen.languages;
|
||||||
|
|
||||||
import org.openapitools.codegen.*;
|
import org.openapitools.codegen.*;
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
import java.util.*;
|
|
||||||
|
|
||||||
import org.openapitools.codegen.meta.features.*;
|
|
||||||
import org.openapitools.codegen.meta.GeneratorMetadata;
|
import org.openapitools.codegen.meta.GeneratorMetadata;
|
||||||
import org.openapitools.codegen.meta.Stability;
|
import org.openapitools.codegen.meta.Stability;
|
||||||
import org.slf4j.Logger;
|
import org.openapitools.codegen.meta.features.*;
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.EnumSet;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
public class GoEchoServerCodegen extends AbstractGoCodegen {
|
public class GoEchoServerCodegen extends AbstractGoCodegen {
|
||||||
static final Logger LOGGER = LoggerFactory.getLogger(GoEchoServerCodegen.class);
|
|
||||||
|
|
||||||
protected String apiVersion = "1.0.0";
|
protected String apiVersion = "1.0.0";
|
||||||
protected int serverPort = 8080;
|
protected int serverPort = 8080;
|
||||||
protected String projectName = "openapi-go-echo-server";
|
protected String projectName = "openapi-go-echo-server";
|
||||||
|
@ -51,6 +51,7 @@ public class HaskellHttpClientCodegen extends DefaultCodegen implements CodegenC
|
|||||||
protected String defaultDateFormat = "%Y-%m-%d";
|
protected String defaultDateFormat = "%Y-%m-%d";
|
||||||
protected String defaultCabalVersion = "0.1.0.0";
|
protected String defaultCabalVersion = "0.1.0.0";
|
||||||
protected String modulePath = null;
|
protected String modulePath = null;
|
||||||
|
protected String defaultQueryExtraUnreserved = null;
|
||||||
|
|
||||||
protected Boolean useKatip = true;
|
protected Boolean useKatip = true;
|
||||||
protected Boolean allowNonUniqueOperationIds = false;
|
protected Boolean allowNonUniqueOperationIds = false;
|
||||||
@ -74,6 +75,7 @@ public class HaskellHttpClientCodegen extends DefaultCodegen implements CodegenC
|
|||||||
public static final String PROP_GENERATE_MODEL_CONSTRUCTORS = "generateModelConstructors";
|
public static final String PROP_GENERATE_MODEL_CONSTRUCTORS = "generateModelConstructors";
|
||||||
public static final String PROP_INLINE_MIME_TYPES = "inlineMimeTypes";
|
public static final String PROP_INLINE_MIME_TYPES = "inlineMimeTypes";
|
||||||
public static final String PROP_MODEL_DERIVING = "modelDeriving";
|
public static final String PROP_MODEL_DERIVING = "modelDeriving";
|
||||||
|
public static final String PROP_QUERY_EXTRA_UNRESERVED = "queryExtraUnreserved";
|
||||||
public static final String PROP_REQUEST_TYPE = "requestType";
|
public static final String PROP_REQUEST_TYPE = "requestType";
|
||||||
public static final String PROP_STRICT_FIELDS = "strictFields";
|
public static final String PROP_STRICT_FIELDS = "strictFields";
|
||||||
public static final String PROP_USE_KATIP = "useKatip";
|
public static final String PROP_USE_KATIP = "useKatip";
|
||||||
@ -125,6 +127,7 @@ public class HaskellHttpClientCodegen extends DefaultCodegen implements CodegenC
|
|||||||
static final String X_MEDIA_IS_JSON = "x-mediaIsJson";
|
static final String X_MEDIA_IS_JSON = "x-mediaIsJson";
|
||||||
static final String X_MEDIA_IS_WILDCARD = "x-mediaIsWildcard";
|
static final String X_MEDIA_IS_WILDCARD = "x-mediaIsWildcard";
|
||||||
static final String X_STRICT_FIELDS = "x-strictFields";
|
static final String X_STRICT_FIELDS = "x-strictFields";
|
||||||
|
static final String X_PROP_QUERY_EXTRA_UNRESERVED = "x-queryExtraUnreserved";
|
||||||
static final String X_ALL_UNIQUE_IMPORT_PATHS = "x-allUniqueImportPaths";
|
static final String X_ALL_UNIQUE_IMPORT_PATHS = "x-allUniqueImportPaths";
|
||||||
static final String X_USE_KATIP = "x-useKatip";
|
static final String X_USE_KATIP = "x-useKatip";
|
||||||
static final String X_ALLOW_NONUNIQUE_OPERATION_IDS = "x-allowNonUniqueOperationIds";
|
static final String X_ALLOW_NONUNIQUE_OPERATION_IDS = "x-allowNonUniqueOperationIds";
|
||||||
@ -308,6 +311,7 @@ public class HaskellHttpClientCodegen extends DefaultCodegen implements CodegenC
|
|||||||
cliOptions.add(CliOption.newString(PROP_DATETIME_FORMAT, "format string used to parse/render a datetime"));
|
cliOptions.add(CliOption.newString(PROP_DATETIME_FORMAT, "format string used to parse/render a datetime"));
|
||||||
cliOptions.add(CliOption.newString(PROP_DATETIME_PARSE_FORMAT, "overrides the format string used to parse a datetime"));
|
cliOptions.add(CliOption.newString(PROP_DATETIME_PARSE_FORMAT, "overrides the format string used to parse a datetime"));
|
||||||
cliOptions.add(CliOption.newString(PROP_DATE_FORMAT, "format string used to parse/render a date").defaultValue(defaultDateFormat));
|
cliOptions.add(CliOption.newString(PROP_DATE_FORMAT, "format string used to parse/render a date").defaultValue(defaultDateFormat));
|
||||||
|
cliOptions.add(CliOption.newString(PROP_QUERY_EXTRA_UNRESERVED, "Configures additional querystring characters which must not be URI encoded, e.g. '+' or ':'"));
|
||||||
|
|
||||||
cliOptions.add(CliOption.newString(PROP_CUSTOM_TEST_INSTANCE_MODULE, "test module used to provide typeclass instances for types not known by the generator"));
|
cliOptions.add(CliOption.newString(PROP_CUSTOM_TEST_INSTANCE_MODULE, "test module used to provide typeclass instances for types not known by the generator"));
|
||||||
|
|
||||||
@ -371,6 +375,10 @@ public class HaskellHttpClientCodegen extends DefaultCodegen implements CodegenC
|
|||||||
setStringProp(PROP_CABAL_VERSION, value);
|
setStringProp(PROP_CABAL_VERSION, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setQueryExtraUnreserved(String value) {
|
||||||
|
additionalProperties.put(X_PROP_QUERY_EXTRA_UNRESERVED, value);
|
||||||
|
}
|
||||||
|
|
||||||
public void setBaseModule(String value) {
|
public void setBaseModule(String value) {
|
||||||
setStringProp(PROP_BASE_MODULE, value);
|
setStringProp(PROP_BASE_MODULE, value);
|
||||||
}
|
}
|
||||||
@ -505,6 +513,11 @@ public class HaskellHttpClientCodegen extends DefaultCodegen implements CodegenC
|
|||||||
} else {
|
} else {
|
||||||
setCabalVersion(defaultCabalVersion);
|
setCabalVersion(defaultCabalVersion);
|
||||||
}
|
}
|
||||||
|
if (additionalProperties.containsKey(PROP_QUERY_EXTRA_UNRESERVED)) {
|
||||||
|
setQueryExtraUnreserved(additionalProperties.get(PROP_QUERY_EXTRA_UNRESERVED).toString());
|
||||||
|
} else {
|
||||||
|
setQueryExtraUnreserved(defaultQueryExtraUnreserved);
|
||||||
|
}
|
||||||
if (additionalProperties.containsKey(PROP_BASE_MODULE)) {
|
if (additionalProperties.containsKey(PROP_BASE_MODULE)) {
|
||||||
setBaseModule(additionalProperties.get(PROP_BASE_MODULE).toString());
|
setBaseModule(additionalProperties.get(PROP_BASE_MODULE).toString());
|
||||||
}
|
}
|
||||||
|
@ -46,7 +46,7 @@ public class HaskellYesodServerCodegen extends DefaultCodegen implements Codegen
|
|||||||
|
|
||||||
private static final Pattern LEADING_UNDERSCORE = Pattern.compile("^_+");
|
private static final Pattern LEADING_UNDERSCORE = Pattern.compile("^_+");
|
||||||
|
|
||||||
static final Logger LOGGER = LoggerFactory.getLogger(HaskellYesodServerCodegen.class);
|
private final Logger LOGGER = LoggerFactory.getLogger(HaskellYesodServerCodegen.class);
|
||||||
|
|
||||||
protected String projectName;
|
protected String projectName;
|
||||||
protected String apiModuleName;
|
protected String apiModuleName;
|
||||||
|
@ -43,7 +43,7 @@ import static org.openapitools.codegen.utils.StringUtils.camelize;
|
|||||||
public class KotlinSpringServerCodegen extends AbstractKotlinCodegen
|
public class KotlinSpringServerCodegen extends AbstractKotlinCodegen
|
||||||
implements BeanValidationFeatures {
|
implements BeanValidationFeatures {
|
||||||
|
|
||||||
private static Logger LOGGER =
|
private final Logger LOGGER =
|
||||||
LoggerFactory.getLogger(KotlinSpringServerCodegen.class);
|
LoggerFactory.getLogger(KotlinSpringServerCodegen.class);
|
||||||
|
|
||||||
private static final HashSet<String> VARIABLE_RESERVED_WORDS =
|
private static final HashSet<String> VARIABLE_RESERVED_WORDS =
|
||||||
|
@ -39,7 +39,7 @@ import static org.openapitools.codegen.utils.StringUtils.*;
|
|||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
public class KtormSchemaCodegen extends AbstractKotlinCodegen {
|
public class KtormSchemaCodegen extends AbstractKotlinCodegen {
|
||||||
static Logger LOGGER = LoggerFactory.getLogger(KtormSchemaCodegen.class);
|
private final Logger LOGGER = LoggerFactory.getLogger(KtormSchemaCodegen.class);
|
||||||
|
|
||||||
public static final String VENDOR_EXTENSION_SCHEMA = "x-ktorm-schema";
|
public static final String VENDOR_EXTENSION_SCHEMA = "x-ktorm-schema";
|
||||||
public static final String DEFAULT_DATABASE_NAME = "defaultDatabaseName";
|
public static final String DEFAULT_DATABASE_NAME = "defaultDatabaseName";
|
||||||
|
@ -1195,7 +1195,11 @@ public class PythonClientCodegen extends PythonLegacyClientCodegen {
|
|||||||
|
|
||||||
// this seed makes it so if we have [a-z] we pick a
|
// this seed makes it so if we have [a-z] we pick a
|
||||||
Random random = new Random(18);
|
Random random = new Random(18);
|
||||||
example = rgxGen.generate(random);
|
if (rgxGen != null) {
|
||||||
|
example = rgxGen.generate(random);
|
||||||
|
} else {
|
||||||
|
throw new RuntimeException("rgxGen cannot be null. Please open an issue in the openapi-generator github repo.");
|
||||||
|
}
|
||||||
} else if (schema.getMinLength() != null) {
|
} else if (schema.getMinLength() != null) {
|
||||||
example = "";
|
example = "";
|
||||||
int len = schema.getMinLength().intValue();
|
int len = schema.getMinLength().intValue();
|
||||||
|
@ -395,8 +395,9 @@ public class RustServerCodegen extends DefaultCodegen implements CodegenConfig {
|
|||||||
|
|
||||||
// model name cannot use reserved keyword, e.g. return
|
// model name cannot use reserved keyword, e.g. return
|
||||||
if (isReservedWord(camelizedName)) {
|
if (isReservedWord(camelizedName)) {
|
||||||
camelizedName = "Model" + camelizedName;
|
final String modelName = "Model" + camelizedName;
|
||||||
LOGGER.warn("{} (reserved word) cannot be used as model name. Renamed to {}", camelizedName, camelizedName);
|
LOGGER.warn("{} (reserved word) cannot be used as model name. Renamed to {}", camelizedName, modelName);
|
||||||
|
return modelName;
|
||||||
}
|
}
|
||||||
|
|
||||||
// model name starts with number
|
// model name starts with number
|
||||||
|
@ -51,7 +51,7 @@ public class ScalaAkkaClientCodegen extends AbstractScalaCodegen implements Code
|
|||||||
protected boolean removeOAuthSecurities = true;
|
protected boolean removeOAuthSecurities = true;
|
||||||
|
|
||||||
@SuppressWarnings("hiding")
|
@SuppressWarnings("hiding")
|
||||||
protected Logger LOGGER = LoggerFactory.getLogger(ScalaAkkaClientCodegen.class);
|
protected final Logger LOGGER = LoggerFactory.getLogger(ScalaAkkaClientCodegen.class);
|
||||||
|
|
||||||
public ScalaAkkaClientCodegen() {
|
public ScalaAkkaClientCodegen() {
|
||||||
super();
|
super();
|
||||||
|
@ -50,7 +50,7 @@ public class ScalaAkkaHttpServerCodegen extends AbstractScalaCodegen implements
|
|||||||
public static final String GENERATE_AS_MANAGED_SOURCES_DESC = "Resulting files cab be used as managed resources. No build files or default controllers will be generated";
|
public static final String GENERATE_AS_MANAGED_SOURCES_DESC = "Resulting files cab be used as managed resources. No build files or default controllers will be generated";
|
||||||
public static final boolean DEFAULT_GENERATE_AS_MANAGED_SOURCES = false;
|
public static final boolean DEFAULT_GENERATE_AS_MANAGED_SOURCES = false;
|
||||||
|
|
||||||
static final Logger LOGGER = LoggerFactory.getLogger(ScalaAkkaHttpServerCodegen.class);
|
final Logger LOGGER = LoggerFactory.getLogger(ScalaAkkaHttpServerCodegen.class);
|
||||||
|
|
||||||
public CodegenType getTag() {
|
public CodegenType getTag() {
|
||||||
return CodegenType.SERVER;
|
return CodegenType.SERVER;
|
||||||
@ -305,7 +305,7 @@ public class ScalaAkkaHttpServerCodegen extends AbstractScalaCodegen implements
|
|||||||
.put("String", "Segment")
|
.put("String", "Segment")
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
protected static void addPathMatcher(CodegenOperation codegenOperation) {
|
protected void addPathMatcher(CodegenOperation codegenOperation) {
|
||||||
LinkedList<String> allPaths = new LinkedList<>(Arrays.asList(codegenOperation.path.split("/")));
|
LinkedList<String> allPaths = new LinkedList<>(Arrays.asList(codegenOperation.path.split("/")));
|
||||||
allPaths.removeIf(""::equals);
|
allPaths.removeIf(""::equals);
|
||||||
|
|
||||||
|
@ -125,6 +125,7 @@ public class ScalaSttpClientCodegen extends AbstractScalaCodegen implements Code
|
|||||||
importMapping.remove("Set");
|
importMapping.remove("Set");
|
||||||
importMapping.remove("Map");
|
importMapping.remove("Map");
|
||||||
|
|
||||||
|
// TODO: there is no specific sttp mapping. All Scala Type mappings should be in AbstractScala
|
||||||
typeMapping = new HashMap<>();
|
typeMapping = new HashMap<>();
|
||||||
typeMapping.put("array", "Seq");
|
typeMapping.put("array", "Seq");
|
||||||
typeMapping.put("set", "Set");
|
typeMapping.put("set", "Set");
|
||||||
@ -143,6 +144,7 @@ public class ScalaSttpClientCodegen extends AbstractScalaCodegen implements Code
|
|||||||
typeMapping.put("binary", "File");
|
typeMapping.put("binary", "File");
|
||||||
typeMapping.put("number", "Double");
|
typeMapping.put("number", "Double");
|
||||||
typeMapping.put("decimal", "BigDecimal");
|
typeMapping.put("decimal", "BigDecimal");
|
||||||
|
typeMapping.put("ByteArray", "Array[Byte]");
|
||||||
|
|
||||||
instantiationTypes.put("array", "ListBuffer");
|
instantiationTypes.put("array", "ListBuffer");
|
||||||
instantiationTypes.put("map", "Map");
|
instantiationTypes.put("map", "Map");
|
||||||
@ -217,6 +219,103 @@ public class ScalaSttpClientCodegen extends AbstractScalaCodegen implements Code
|
|||||||
return "`" + name + "`";
|
return "`" + name + "`";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Map<String, Object> postProcessModels(Map<String, Object> objs) {
|
||||||
|
return objs;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Invoked by {@link DefaultGenerator} after all models have been post-processed,
|
||||||
|
* allowing for a last pass of codegen-specific model cleanup.
|
||||||
|
*
|
||||||
|
* @param objs Current state of codegen object model.
|
||||||
|
* @return An in-place modified state of the codegen object model.
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public Map<String, Object> postProcessAllModels(Map<String, Object> objs) {
|
||||||
|
final Map<String, Object> processed = super.postProcessAllModels(objs);
|
||||||
|
postProcessUpdateImports(processed);
|
||||||
|
return processed;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Update/clean up model imports
|
||||||
|
*
|
||||||
|
* append '._" if the import is a Enum class, otherwise
|
||||||
|
* remove model imports to avoid warnings for importing class in the same package in Scala
|
||||||
|
*
|
||||||
|
* @param models processed models to be further processed
|
||||||
|
*/
|
||||||
|
@SuppressWarnings({"unchecked"})
|
||||||
|
private void postProcessUpdateImports(final Map<String, Object> models) {
|
||||||
|
final String prefix = modelPackage() + ".";
|
||||||
|
Map<String, Object> enumRefs = new HashMap<String, Object>();
|
||||||
|
for (Map.Entry<String, Object> entry : models.entrySet()) {
|
||||||
|
CodegenModel model = ModelUtils.getModelByName(entry.getKey(), models);
|
||||||
|
if (model.isEnum) {
|
||||||
|
Map<String, Object> objs = (Map<String, Object>)models.get(entry.getKey());
|
||||||
|
enumRefs.put(entry.getKey(), objs);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for (Map.Entry<String, Object> entry : models.entrySet()) {
|
||||||
|
String openAPIName = entry.getKey();
|
||||||
|
CodegenModel model = ModelUtils.getModelByName(openAPIName, models);
|
||||||
|
if (model == null) {
|
||||||
|
LOGGER.warn("Expected to retrieve model %s by name, but no model was found. Check your -Dmodels inclusions.", openAPIName);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
Map<String, Object> objs = (Map<String, Object>)models.get(openAPIName);
|
||||||
|
List<Map<String, String>> imports = (List<Map<String, String>>) objs.get("imports");
|
||||||
|
if (imports == null || imports.isEmpty()) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
List<Map<String, String>> newImports = new ArrayList<>();
|
||||||
|
Iterator<Map<String, String>> iterator = imports.iterator();
|
||||||
|
while (iterator.hasNext()) {
|
||||||
|
String importPath = iterator.next().get("import");
|
||||||
|
if (importPath.startsWith(prefix)) {
|
||||||
|
if (isEnumClass(importPath, (Map<String, Object>)enumRefs)) {
|
||||||
|
Map<String, String> item = new HashMap<>();
|
||||||
|
item.put("import", importPath.concat("._"));
|
||||||
|
newImports.add(item);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
Map<String, String> item = new HashMap<>();
|
||||||
|
item.put("import", importPath);
|
||||||
|
newImports.add(item);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
// reset imports
|
||||||
|
objs.put("imports", newImports);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
|
private boolean isEnumClass(final String importPath, final Map<String, Object> enumModels) {
|
||||||
|
if (enumModels == null || enumModels.isEmpty()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
for (Map.Entry<String, Object> entry : enumModels.entrySet()) {
|
||||||
|
String name = entry.getKey();
|
||||||
|
Map<String, Object> objs = (Map<String, Object>)enumModels.get(name);
|
||||||
|
List<Map<String, Object>> modles = (List<Map<String, Object>>) objs.get("models");
|
||||||
|
if (modles == null || modles.isEmpty()) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
Iterator<Map<String, Object>> iterator = modles.iterator();
|
||||||
|
while (iterator.hasNext()) {
|
||||||
|
String enumImportPath = (String)iterator.next().get("importPath");
|
||||||
|
if (enumImportPath != null && enumImportPath.equals(importPath)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Map<String, Object> postProcessOperationsWithModels(Map<String, Object> objs, List<Object> allModels) {
|
public Map<String, Object> postProcessOperationsWithModels(Map<String, Object> objs, List<Object> allModels) {
|
||||||
if (registerNonStandardStatusCodes) {
|
if (registerNonStandardStatusCodes) {
|
||||||
|
@ -488,6 +488,8 @@ public class SpringCodegen extends AbstractJavaCodegen
|
|||||||
}
|
}
|
||||||
|
|
||||||
// add lambda for mustache templates
|
// add lambda for mustache templates
|
||||||
|
additionalProperties.put("lambdaRemoveDoubleQuote",
|
||||||
|
(Mustache.Lambda) (fragment, writer) -> writer.write(fragment.execute().replaceAll("\"", Matcher.quoteReplacement(""))));
|
||||||
additionalProperties.put("lambdaEscapeDoubleQuote",
|
additionalProperties.put("lambdaEscapeDoubleQuote",
|
||||||
(Mustache.Lambda) (fragment, writer) -> writer.write(fragment.execute().replaceAll("\"", Matcher.quoteReplacement("\\\""))));
|
(Mustache.Lambda) (fragment, writer) -> writer.write(fragment.execute().replaceAll("\"", Matcher.quoteReplacement("\\\""))));
|
||||||
additionalProperties.put("lambdaRemoveLineBreak",
|
additionalProperties.put("lambdaRemoveLineBreak",
|
||||||
@ -838,6 +840,10 @@ public class SpringCodegen extends AbstractJavaCodegen
|
|||||||
if (property.isByteArray) {
|
if (property.isByteArray) {
|
||||||
model.imports.add("Arrays");
|
model.imports.add("Arrays");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (model.getVendorExtensions().containsKey("x-jackson-optional-nullable-helpers")) {
|
||||||
|
model.imports.add("Arrays");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -58,6 +58,7 @@ public class Swift5ClientCodegen extends DefaultCodegen implements CodegenConfig
|
|||||||
public static final String POD_SCREENSHOTS = "podScreenshots";
|
public static final String POD_SCREENSHOTS = "podScreenshots";
|
||||||
public static final String POD_DOCUMENTATION_URL = "podDocumentationURL";
|
public static final String POD_DOCUMENTATION_URL = "podDocumentationURL";
|
||||||
public static final String READONLY_PROPERTIES = "readonlyProperties";
|
public static final String READONLY_PROPERTIES = "readonlyProperties";
|
||||||
|
public static final String REMOVE_MIGRATION_PROJECT_NAME_CLASS = "removeMigrationProjectNameClass";
|
||||||
public static final String SWIFT_USE_API_NAMESPACE = "swiftUseApiNamespace";
|
public static final String SWIFT_USE_API_NAMESPACE = "swiftUseApiNamespace";
|
||||||
public static final String DEFAULT_POD_AUTHORS = "OpenAPI Generator";
|
public static final String DEFAULT_POD_AUTHORS = "OpenAPI Generator";
|
||||||
public static final String LENIENT_TYPE_CAST = "lenientTypeCast";
|
public static final String LENIENT_TYPE_CAST = "lenientTypeCast";
|
||||||
@ -81,6 +82,7 @@ public class Swift5ClientCodegen extends DefaultCodegen implements CodegenConfig
|
|||||||
protected boolean objcCompatible = false;
|
protected boolean objcCompatible = false;
|
||||||
protected boolean lenientTypeCast = false;
|
protected boolean lenientTypeCast = false;
|
||||||
protected boolean readonlyProperties = false;
|
protected boolean readonlyProperties = false;
|
||||||
|
protected boolean removeMigrationProjectNameClass = false;
|
||||||
protected boolean swiftUseApiNamespace = false;
|
protected boolean swiftUseApiNamespace = false;
|
||||||
protected boolean useSPMFileStructure = false;
|
protected boolean useSPMFileStructure = false;
|
||||||
protected String swiftPackagePath = "Classes" + File.separator + "OpenAPIs";
|
protected String swiftPackagePath = "Classes" + File.separator + "OpenAPIs";
|
||||||
@ -263,6 +265,8 @@ public class Swift5ClientCodegen extends DefaultCodegen implements CodegenConfig
|
|||||||
"Documentation URL used for Podspec"));
|
"Documentation URL used for Podspec"));
|
||||||
cliOptions.add(new CliOption(READONLY_PROPERTIES, "Make properties "
|
cliOptions.add(new CliOption(READONLY_PROPERTIES, "Make properties "
|
||||||
+ "readonly (default: false)"));
|
+ "readonly (default: false)"));
|
||||||
|
cliOptions.add(new CliOption(REMOVE_MIGRATION_PROJECT_NAME_CLASS, "Make properties "
|
||||||
|
+ "removeMigrationProjectNameClass (default: false)"));
|
||||||
cliOptions.add(new CliOption(SWIFT_USE_API_NAMESPACE,
|
cliOptions.add(new CliOption(SWIFT_USE_API_NAMESPACE,
|
||||||
"Flag to make all the API classes inner-class "
|
"Flag to make all the API classes inner-class "
|
||||||
+ "of {{projectName}}API"));
|
+ "of {{projectName}}API"));
|
||||||
@ -447,8 +451,14 @@ public class Swift5ClientCodegen extends DefaultCodegen implements CodegenConfig
|
|||||||
}
|
}
|
||||||
additionalProperties.put(READONLY_PROPERTIES, readonlyProperties);
|
additionalProperties.put(READONLY_PROPERTIES, readonlyProperties);
|
||||||
|
|
||||||
|
// Setup removeMigrationProjectNameClass option, which keeps or remove the projectName class
|
||||||
|
if (additionalProperties.containsKey(REMOVE_MIGRATION_PROJECT_NAME_CLASS)) {
|
||||||
|
setRemoveMigrationProjectNameClass(convertPropertyToBooleanAndWriteBack(REMOVE_MIGRATION_PROJECT_NAME_CLASS));
|
||||||
|
}
|
||||||
|
additionalProperties.put(REMOVE_MIGRATION_PROJECT_NAME_CLASS, removeMigrationProjectNameClass);
|
||||||
|
|
||||||
// Setup swiftUseApiNamespace option, which makes all the API
|
// Setup swiftUseApiNamespace option, which makes all the API
|
||||||
// classes inner-class of {{projectName}}
|
// classes inner-class of {{projectName}}API
|
||||||
if (additionalProperties.containsKey(SWIFT_USE_API_NAMESPACE)) {
|
if (additionalProperties.containsKey(SWIFT_USE_API_NAMESPACE)) {
|
||||||
setSwiftUseApiNamespace(convertPropertyToBooleanAndWriteBack(SWIFT_USE_API_NAMESPACE));
|
setSwiftUseApiNamespace(convertPropertyToBooleanAndWriteBack(SWIFT_USE_API_NAMESPACE));
|
||||||
}
|
}
|
||||||
@ -901,6 +911,10 @@ public class Swift5ClientCodegen extends DefaultCodegen implements CodegenConfig
|
|||||||
this.readonlyProperties = readonlyProperties;
|
this.readonlyProperties = readonlyProperties;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setRemoveMigrationProjectNameClass(boolean removeMigrationProjectNameClass) {
|
||||||
|
this.removeMigrationProjectNameClass = removeMigrationProjectNameClass;
|
||||||
|
}
|
||||||
|
|
||||||
public void setResponseAs(String[] responseAs) {
|
public void setResponseAs(String[] responseAs) {
|
||||||
this.responseAs = responseAs;
|
this.responseAs = responseAs;
|
||||||
}
|
}
|
||||||
|
@ -53,6 +53,7 @@ public class TypeScriptAngularClientCodegen extends AbstractTypeScriptClientCode
|
|||||||
public static final String PROVIDED_IN_ROOT = "providedInRoot";
|
public static final String PROVIDED_IN_ROOT = "providedInRoot";
|
||||||
public static final String PROVIDED_IN = "providedIn";
|
public static final String PROVIDED_IN = "providedIn";
|
||||||
public static final String ENFORCE_GENERIC_MODULE_WITH_PROVIDERS = "enforceGenericModuleWithProviders";
|
public static final String ENFORCE_GENERIC_MODULE_WITH_PROVIDERS = "enforceGenericModuleWithProviders";
|
||||||
|
public static final String HTTP_CONTEXT_IN_OPTIONS = "httpContextInOptions";
|
||||||
public static final String API_MODULE_PREFIX = "apiModulePrefix";
|
public static final String API_MODULE_PREFIX = "apiModulePrefix";
|
||||||
public static final String CONFIGURATION_PREFIX = "configurationPrefix";
|
public static final String CONFIGURATION_PREFIX = "configurationPrefix";
|
||||||
public static final String SERVICE_SUFFIX = "serviceSuffix";
|
public static final String SERVICE_SUFFIX = "serviceSuffix";
|
||||||
@ -64,7 +65,7 @@ public class TypeScriptAngularClientCodegen extends AbstractTypeScriptClientCode
|
|||||||
public static final String STRING_ENUMS_DESC = "Generate string enums instead of objects for enum values.";
|
public static final String STRING_ENUMS_DESC = "Generate string enums instead of objects for enum values.";
|
||||||
public static final String QUERY_PARAM_OBJECT_FORMAT = "queryParamObjectFormat";
|
public static final String QUERY_PARAM_OBJECT_FORMAT = "queryParamObjectFormat";
|
||||||
|
|
||||||
protected String ngVersion = "11.0.0";
|
protected String ngVersion = "12.0.0";
|
||||||
protected String npmRepository = null;
|
protected String npmRepository = null;
|
||||||
private boolean useSingleRequestParameter = false;
|
private boolean useSingleRequestParameter = false;
|
||||||
protected String serviceSuffix = "Service";
|
protected String serviceSuffix = "Service";
|
||||||
@ -143,7 +144,7 @@ public class TypeScriptAngularClientCodegen extends AbstractTypeScriptClientCode
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getHelp() {
|
public String getHelp() {
|
||||||
return "Generates a TypeScript Angular (6.x - 11.x) client library.";
|
return "Generates a TypeScript Angular (6.x - 12.x) client library.";
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -229,6 +230,12 @@ public class TypeScriptAngularClientCodegen extends AbstractTypeScriptClientCode
|
|||||||
additionalProperties.put(ENFORCE_GENERIC_MODULE_WITH_PROVIDERS, false);
|
additionalProperties.put(ENFORCE_GENERIC_MODULE_WITH_PROVIDERS, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (ngVersion.atLeast("12.0.0")) {
|
||||||
|
additionalProperties.put(HTTP_CONTEXT_IN_OPTIONS, true);
|
||||||
|
} else {
|
||||||
|
additionalProperties.put(HTTP_CONTEXT_IN_OPTIONS, false);
|
||||||
|
}
|
||||||
|
|
||||||
additionalProperties.put(NG_VERSION, ngVersion);
|
additionalProperties.put(NG_VERSION, ngVersion);
|
||||||
|
|
||||||
if (additionalProperties.containsKey(API_MODULE_PREFIX)) {
|
if (additionalProperties.containsKey(API_MODULE_PREFIX)) {
|
||||||
@ -285,7 +292,9 @@ public class TypeScriptAngularClientCodegen extends AbstractTypeScriptClientCode
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Set the typescript version compatible to the Angular version
|
// Set the typescript version compatible to the Angular version
|
||||||
if (ngVersion.atLeast("11.0.0")) {
|
if (ngVersion.atLeast("12.0.0")) {
|
||||||
|
additionalProperties.put("tsVersion", ">=4.2.3 <4.3.0");
|
||||||
|
} else if (ngVersion.atLeast("11.0.0")) {
|
||||||
additionalProperties.put("tsVersion", ">=4.0.0 <4.1.0");
|
additionalProperties.put("tsVersion", ">=4.0.0 <4.1.0");
|
||||||
} else if (ngVersion.atLeast("10.0.0")) {
|
} else if (ngVersion.atLeast("10.0.0")) {
|
||||||
additionalProperties.put("tsVersion", ">=3.9.2 <4.0.0");
|
additionalProperties.put("tsVersion", ">=3.9.2 <4.0.0");
|
||||||
@ -317,7 +326,10 @@ public class TypeScriptAngularClientCodegen extends AbstractTypeScriptClientCode
|
|||||||
supportingFiles.add(new SupportingFile("ng-package.mustache", getIndexDirectory(), "ng-package.json"));
|
supportingFiles.add(new SupportingFile("ng-package.mustache", getIndexDirectory(), "ng-package.json"));
|
||||||
|
|
||||||
// Specific ng-packagr configuration
|
// Specific ng-packagr configuration
|
||||||
if (ngVersion.atLeast("11.0.0")) {
|
if (ngVersion.atLeast("12.0.0")) {
|
||||||
|
additionalProperties.put("ngPackagrVersion", "12.2.1");
|
||||||
|
additionalProperties.put("tsickleVersion", "0.43.0");
|
||||||
|
} else if (ngVersion.atLeast("11.0.0")) {
|
||||||
additionalProperties.put("ngPackagrVersion", "11.0.2");
|
additionalProperties.put("ngPackagrVersion", "11.0.2");
|
||||||
additionalProperties.put("tsickleVersion", "0.39.1");
|
additionalProperties.put("tsickleVersion", "0.39.1");
|
||||||
} else if (ngVersion.atLeast("10.0.0")) {
|
} else if (ngVersion.atLeast("10.0.0")) {
|
||||||
@ -341,7 +353,9 @@ public class TypeScriptAngularClientCodegen extends AbstractTypeScriptClientCode
|
|||||||
}
|
}
|
||||||
|
|
||||||
// set zone.js version
|
// set zone.js version
|
||||||
if (ngVersion.atLeast("11.0.0")) {
|
if (ngVersion.atLeast("12.0.0")) {
|
||||||
|
additionalProperties.put("zonejsVersion", "0.11.4");
|
||||||
|
} else if (ngVersion.atLeast("11.0.0")) {
|
||||||
additionalProperties.put("zonejsVersion", "0.11.3");
|
additionalProperties.put("zonejsVersion", "0.11.3");
|
||||||
} else if (ngVersion.atLeast("9.0.0")) {
|
} else if (ngVersion.atLeast("9.0.0")) {
|
||||||
additionalProperties.put("zonejsVersion", "0.10.2");
|
additionalProperties.put("zonejsVersion", "0.10.2");
|
||||||
|
@ -1180,7 +1180,11 @@ public class TypeScriptClientCodegen extends DefaultCodegen implements CodegenCo
|
|||||||
|
|
||||||
// this seed makes it so if we have [a-z] we pick a
|
// this seed makes it so if we have [a-z] we pick a
|
||||||
Random random = new Random(18);
|
Random random = new Random(18);
|
||||||
example = rgxGen.generate(random);
|
if (rgxGen != null){
|
||||||
|
example = rgxGen.generate(random);
|
||||||
|
} else {
|
||||||
|
throw new RuntimeException("rgxGen cannot be null. Please open an issue in the openapi-generator github repo.");
|
||||||
|
}
|
||||||
} else if (schema.getMinLength() != null) {
|
} else if (schema.getMinLength() != null) {
|
||||||
example = "";
|
example = "";
|
||||||
int len = schema.getMinLength().intValue();
|
int len = schema.getMinLength().intValue();
|
||||||
|
@ -18,35 +18,17 @@ package org.openapitools.codegen.languages;
|
|||||||
|
|
||||||
import io.swagger.v3.oas.models.OpenAPI;
|
import io.swagger.v3.oas.models.OpenAPI;
|
||||||
import io.swagger.v3.oas.models.info.Info;
|
import io.swagger.v3.oas.models.info.Info;
|
||||||
|
import org.openapitools.codegen.*;
|
||||||
|
import org.openapitools.codegen.meta.GeneratorMetadata;
|
||||||
|
import org.openapitools.codegen.meta.Stability;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.text.Normalizer;
|
import java.text.Normalizer;
|
||||||
import java.util.List;
|
import java.util.*;
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Locale;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
import org.openapitools.codegen.CliOption;
|
|
||||||
import org.openapitools.codegen.CodegenConfig;
|
|
||||||
import org.openapitools.codegen.CodegenModel;
|
|
||||||
import org.openapitools.codegen.CodegenOperation;
|
|
||||||
import org.openapitools.codegen.CodegenParameter;
|
|
||||||
import org.openapitools.codegen.CodegenProperty;
|
|
||||||
import org.openapitools.codegen.CodegenType;
|
|
||||||
import org.openapitools.codegen.DefaultCodegen;
|
|
||||||
import org.openapitools.codegen.meta.GeneratorMetadata;
|
|
||||||
import org.openapitools.codegen.meta.Stability;
|
|
||||||
import org.openapitools.codegen.meta.features.*;
|
|
||||||
import org.openapitools.codegen.SupportingFile;
|
|
||||||
|
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
|
|
||||||
public class WsdlSchemaCodegen extends DefaultCodegen implements CodegenConfig {
|
public class WsdlSchemaCodegen extends DefaultCodegen implements CodegenConfig {
|
||||||
public static final String PROJECT_NAME = "projectName";
|
public static final String PROJECT_NAME = "projectName";
|
||||||
|
|
||||||
static final Logger LOGGER = LoggerFactory.getLogger(WsdlSchemaCodegen.class);
|
|
||||||
|
|
||||||
public CodegenType getTag() {
|
public CodegenType getTag() {
|
||||||
return CodegenType.SCHEMA;
|
return CodegenType.SCHEMA;
|
||||||
}
|
}
|
||||||
@ -143,9 +125,21 @@ public class WsdlSchemaCodegen extends DefaultCodegen implements CodegenConfig {
|
|||||||
|
|
||||||
// if param is enum, uppercase 'baseName' to have a reference to wsdl simpletype
|
// if param is enum, uppercase 'baseName' to have a reference to wsdl simpletype
|
||||||
if (param.isEnum) {
|
if (param.isEnum) {
|
||||||
char[] c = param.baseName.toCharArray();
|
param.baseName = param.baseName.substring(0, 1).toUpperCase(Locale.getDefault())
|
||||||
c[0] = Character.toUpperCase(c[0]);
|
+ param.baseName.substring(1);
|
||||||
param.baseName = new String(c);
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// handle case lowercase schema-name in openapi to have reference to wsdl complextype
|
||||||
|
for (CodegenResponse response : op.responses) {
|
||||||
|
if (response.isModel) {
|
||||||
|
response.dataType = response.dataType.substring(0, 1).toUpperCase(Locale.getDefault())
|
||||||
|
+ response.dataType.substring(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (response.isArray) {
|
||||||
|
response.baseType = response.baseType.substring(0, 1).toUpperCase(Locale.getDefault())
|
||||||
|
+ response.baseType.substring(1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -190,32 +184,18 @@ public class WsdlSchemaCodegen extends DefaultCodegen implements CodegenConfig {
|
|||||||
CodegenModel model = (CodegenModel) mod.get("model");
|
CodegenModel model = (CodegenModel) mod.get("model");
|
||||||
Map<String, Object> modelVendorExtensions = model.getVendorExtensions();
|
Map<String, Object> modelVendorExtensions = model.getVendorExtensions();
|
||||||
|
|
||||||
/* check if model is a model with no properties
|
|
||||||
* Used in the mustache template to ensure that no complextype is created
|
|
||||||
* if model is just a schema with an enum defined in the openapi specification
|
|
||||||
*/
|
|
||||||
if (model.allowableValues != null) {
|
|
||||||
modelVendorExtensions.put("x-is-openapimodel-enum", true);
|
|
||||||
} else {
|
|
||||||
modelVendorExtensions.put("x-is-openapimodel-enum", false);
|
|
||||||
}
|
|
||||||
|
|
||||||
for (CodegenProperty var : model.vars) {
|
for (CodegenProperty var : model.vars) {
|
||||||
Map<String, Object> propertyVendorExtensions = var.getVendorExtensions();
|
Map<String, Object> propertyVendorExtensions = var.getVendorExtensions();
|
||||||
|
|
||||||
// lowercase basetypes if openapitype is string
|
// lowercase basetypes if openapitype is string
|
||||||
if ("string".equals(var.openApiType)) {
|
if ("string".equals(var.openApiType)) {
|
||||||
char[] c = var.baseType.toCharArray();
|
var.baseType = var.baseType.substring(0, 1).toLowerCase(Locale.getDefault())
|
||||||
c[0] = Character.toLowerCase(c[0]);
|
+ var.baseType.substring(1);
|
||||||
var.baseType = new String(c);
|
|
||||||
}
|
}
|
||||||
// if string enum, uppercase 'name' to have a reference to wsdl simpletype
|
// if string enum, uppercase 'name' to have a reference to wsdl simpletype
|
||||||
if (var.isEnum) {
|
if (var.isEnum) {
|
||||||
char[] c = var.name.toCharArray();
|
var.name = var.name.substring(0, 1).toUpperCase(Locale.getDefault()) + var.name.substring(1);
|
||||||
c[0] = Character.toUpperCase(c[0]);
|
|
||||||
var.name = new String(c);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// prevent default="null" in wsdl-tag if no default was specified for a property
|
// prevent default="null" in wsdl-tag if no default was specified for a property
|
||||||
if ("null".equals(var.defaultValue) || var.defaultValue == null) {
|
if ("null".equals(var.defaultValue) || var.defaultValue == null) {
|
||||||
propertyVendorExtensions.put("x-prop-has-defaultvalue", false);
|
propertyVendorExtensions.put("x-prop-has-defaultvalue", false);
|
||||||
@ -232,6 +212,21 @@ public class WsdlSchemaCodegen extends DefaultCodegen implements CodegenConfig {
|
|||||||
} else {
|
} else {
|
||||||
propertyVendorExtensions.put("x-prop-has-minormax", false);
|
propertyVendorExtensions.put("x-prop-has-minormax", false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// specify appearing schema names in case of openapi array with oneOf elements
|
||||||
|
if ("array".equals(var.openApiType) && var.items.dataType.startsWith("oneOf<")) {
|
||||||
|
// get only comma separated names of schemas from oneOf<name1,name2...>
|
||||||
|
String schemaNamesString =
|
||||||
|
var.items.dataType.substring(6, var.items.dataType.length() - 1);
|
||||||
|
List<String> oneofSchemas =
|
||||||
|
new ArrayList<String>(Arrays.asList(schemaNamesString.split("\\s*,\\s*")));
|
||||||
|
|
||||||
|
for (int i = 0; i < oneofSchemas.size(); i++) {
|
||||||
|
oneofSchemas.set(i, lowerCaseStringExceptFirstLetter(oneofSchemas.get(i)));
|
||||||
|
}
|
||||||
|
|
||||||
|
propertyVendorExtensions.put("x-oneof-schemas", oneofSchemas);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return super.postProcessModelsEnum(objs);
|
return super.postProcessModelsEnum(objs);
|
||||||
@ -248,7 +243,8 @@ public class WsdlSchemaCodegen extends DefaultCodegen implements CodegenConfig {
|
|||||||
pathElements[i] = "";
|
pathElements[i] = "";
|
||||||
}
|
}
|
||||||
if (pathElements[i].length() > 0) {
|
if (pathElements[i].length() > 0) {
|
||||||
newOperationid = newOperationid + this.lowerCaseStringExceptFirstLetter(pathElements[i]);
|
newOperationid = newOperationid
|
||||||
|
+ this.lowerCaseStringExceptFirstLetter(pathElements[i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -6,6 +6,7 @@ cmake_policy(SET CMP0063 NEW)
|
|||||||
set(CMAKE_C_VISIBILITY_PRESET default)
|
set(CMAKE_C_VISIBILITY_PRESET default)
|
||||||
set(CMAKE_CXX_VISIBILITY_PRESET default)
|
set(CMAKE_CXX_VISIBILITY_PRESET default)
|
||||||
set(CMAKE_VISIBILITY_INLINES_HIDDEN OFF)
|
set(CMAKE_VISIBILITY_INLINES_HIDDEN OFF)
|
||||||
|
set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON)
|
||||||
|
|
||||||
option(BUILD_SHARED_LIBS "Build using shared libraries" ON)
|
option(BUILD_SHARED_LIBS "Build using shared libraries" ON)
|
||||||
|
|
||||||
@ -27,6 +28,7 @@ else()
|
|||||||
endif()
|
endif()
|
||||||
|
|
||||||
set(pkgName "{{projectName}}")
|
set(pkgName "{{projectName}}")
|
||||||
|
set(VERSION 0.0.1) # this default version can be overridden in PreTarget.cmake
|
||||||
|
|
||||||
find_package(CURL 7.58.0 REQUIRED)
|
find_package(CURL 7.58.0 REQUIRED)
|
||||||
if(CURL_FOUND)
|
if(CURL_FOUND)
|
||||||
@ -86,14 +88,64 @@ include(PreTarget.cmake OPTIONAL)
|
|||||||
add_library(${pkgName} ${SRCS} ${HDRS})
|
add_library(${pkgName} ${SRCS} ${HDRS})
|
||||||
# Link dependent libraries
|
# Link dependent libraries
|
||||||
if(NOT CMAKE_VERSION VERSION_LESS 3.4)
|
if(NOT CMAKE_VERSION VERSION_LESS 3.4)
|
||||||
target_link_libraries(${pkgName} OpenSSL::SSL OpenSSL::Crypto)
|
target_link_libraries(${pkgName} PRIVATE OpenSSL::SSL OpenSSL::Crypto)
|
||||||
endif()
|
endif()
|
||||||
target_link_libraries(${pkgName} ${CURL_LIBRARIES} )
|
target_link_libraries(${pkgName} PUBLIC ${CURL_LIBRARIES} )
|
||||||
|
target_include_directories(
|
||||||
|
${pkgName} PUBLIC $<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}>
|
||||||
|
$<INSTALL_INTERFACE:include>
|
||||||
|
)
|
||||||
|
|
||||||
include(PostTarget.cmake OPTIONAL)
|
include(PostTarget.cmake OPTIONAL)
|
||||||
|
|
||||||
#install library to destination
|
# installation of libraries, headers, and config files
|
||||||
install(TARGETS ${pkgName} DESTINATION ${CMAKE_INSTALL_PREFIX})
|
if (NOT EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/Config.cmake.in)
|
||||||
|
install(TARGETS ${pkgName} DESTINATION ${CMAKE_INSTALL_PREFIX})
|
||||||
|
else()
|
||||||
|
include(GNUInstallDirs)
|
||||||
|
install(TARGETS ${pkgName} DESTINATION ${CMAKE_INSTALL_PREFIX} EXPORT ${pkgName}Targets)
|
||||||
|
|
||||||
|
foreach(HDR_FILE ${HDRS})
|
||||||
|
get_filename_component(HDR_DIRECTORY ${HDR_FILE} DIRECTORY)
|
||||||
|
get_filename_component(ABSOLUTE_HDR_DIRECTORY ${HDR_DIRECTORY} ABSOLUTE)
|
||||||
|
file(RELATIVE_PATH RELATIVE_HDR_PATH ${CMAKE_CURRENT_SOURCE_DIR} ${ABSOLUTE_HDR_DIRECTORY})
|
||||||
|
install(FILES ${HDR_FILE} DESTINATION include/${RELATIVE_HDR_PATH})
|
||||||
|
endforeach()
|
||||||
|
|
||||||
|
include(CMakePackageConfigHelpers)
|
||||||
|
write_basic_package_version_file(
|
||||||
|
"${CMAKE_CURRENT_BINARY_DIR}/${pkgName}/${pkgName}ConfigVersion.cmake"
|
||||||
|
VERSION "${VERSION}"
|
||||||
|
COMPATIBILITY AnyNewerVersion
|
||||||
|
)
|
||||||
|
|
||||||
|
export(EXPORT ${pkgName}Targets
|
||||||
|
FILE "${CMAKE_CURRENT_BINARY_DIR}/${pkgName}/${pkgName}Targets.cmake"
|
||||||
|
NAMESPACE ${pkgName}::
|
||||||
|
)
|
||||||
|
|
||||||
|
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/Config.cmake.in
|
||||||
|
"${CMAKE_CURRENT_BINARY_DIR}/${pkgName}/${pkgName}Config.cmake"
|
||||||
|
@ONLY
|
||||||
|
)
|
||||||
|
|
||||||
|
set(ConfigPackageLocation lib/cmake/${pkgName})
|
||||||
|
install(EXPORT ${pkgName}Targets
|
||||||
|
FILE
|
||||||
|
${pkgName}Targets.cmake
|
||||||
|
NAMESPACE
|
||||||
|
${pkgName}::
|
||||||
|
DESTINATION
|
||||||
|
${ConfigPackageLocation}
|
||||||
|
)
|
||||||
|
install(
|
||||||
|
FILES
|
||||||
|
"${CMAKE_CURRENT_BINARY_DIR}/${pkgName}/${pkgName}Config.cmake"
|
||||||
|
"${CMAKE_CURRENT_BINARY_DIR}/${pkgName}/${pkgName}ConfigVersion.cmake"
|
||||||
|
DESTINATION
|
||||||
|
${ConfigPackageLocation}
|
||||||
|
)
|
||||||
|
endif()
|
||||||
|
|
||||||
# Setting file variables to null
|
# Setting file variables to null
|
||||||
set(SRCS "")
|
set(SRCS "")
|
||||||
|
@ -570,7 +570,7 @@ size_t writeDataCallback(void *buffer, size_t size, size_t nmemb, void *userp) {
|
|||||||
size_t size_this_time = nmemb * size;
|
size_t size_this_time = nmemb * size;
|
||||||
apiClient_t *apiClient = (apiClient_t *)userp;
|
apiClient_t *apiClient = (apiClient_t *)userp;
|
||||||
apiClient->dataReceived = (char *)realloc( apiClient->dataReceived, apiClient->dataReceivedLen + size_this_time + 1);
|
apiClient->dataReceived = (char *)realloc( apiClient->dataReceived, apiClient->dataReceivedLen + size_this_time + 1);
|
||||||
memcpy(apiClient->dataReceived + apiClient->dataReceivedLen, buffer, size_this_time);
|
memcpy((char *)apiClient->dataReceived + apiClient->dataReceivedLen, buffer, size_this_time);
|
||||||
apiClient->dataReceivedLen += size_this_time;
|
apiClient->dataReceivedLen += size_this_time;
|
||||||
((char*)apiClient->dataReceived)[apiClient->dataReceivedLen] = '\0'; // the space size of (apiClient->dataReceived) = dataReceivedLen + 1
|
((char*)apiClient->dataReceived)[apiClient->dataReceivedLen] = '\0'; // the space size of (apiClient->dataReceived) = dataReceivedLen + 1
|
||||||
if (apiClient->data_callback_func) {
|
if (apiClient->data_callback_func) {
|
||||||
|
@ -38,14 +38,14 @@ git add .
|
|||||||
git commit -m "$release_note"
|
git commit -m "$release_note"
|
||||||
|
|
||||||
# Sets the new remote
|
# Sets the new remote
|
||||||
git_remote=`git remote`
|
git_remote=$(git remote)
|
||||||
if [ "$git_remote" = "" ]; then # git remote not defined
|
if [ "$git_remote" = "" ]; then # git remote not defined
|
||||||
|
|
||||||
if [ "$GIT_TOKEN" = "" ]; then
|
if [ "$GIT_TOKEN" = "" ]; then
|
||||||
echo "[INFO] \$GIT_TOKEN (environment variable) is not set. Using the git credential in your environment."
|
echo "[INFO] \$GIT_TOKEN (environment variable) is not set. Using the git credential in your environment."
|
||||||
git remote add origin https://${git_host}/${git_user_id}/${git_repo_id}.git
|
git remote add origin https://${git_host}/${git_user_id}/${git_repo_id}.git
|
||||||
else
|
else
|
||||||
git remote add origin https://${git_user_id}:${GIT_TOKEN}@${git_host}/${git_user_id}/${git_repo_id}.git
|
git remote add origin https://${git_user_id}:"${GIT_TOKEN}"@${git_host}/${git_user_id}/${git_repo_id}.git
|
||||||
fi
|
fi
|
||||||
|
|
||||||
fi
|
fi
|
||||||
|
@ -526,7 +526,7 @@ public class ApiClient{{#jsr310}} extends JavaTimeFormatter{{/jsr310}} {
|
|||||||
* @return API client
|
* @return API client
|
||||||
*/
|
*/
|
||||||
public ApiClient setUserAgent(String userAgent) {
|
public ApiClient setUserAgent(String userAgent) {
|
||||||
userAgent = userAgent;
|
this.userAgent = userAgent;
|
||||||
addDefaultHeader("User-Agent", userAgent);
|
addDefaultHeader("User-Agent", userAgent);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
@ -287,7 +287,7 @@ public class {{classname}} {{#parent}}extends {{{.}}} {{/parent}}{{#vendorExtens
|
|||||||
}{{#vendorExtensions.x-jackson-optional-nullable-helpers}}
|
}{{#vendorExtensions.x-jackson-optional-nullable-helpers}}
|
||||||
|
|
||||||
private static <T> boolean equalsNullable(JsonNullable<T> a, JsonNullable<T> b) {
|
private static <T> boolean equalsNullable(JsonNullable<T> a, JsonNullable<T> b) {
|
||||||
return a == b || (a != null && b != null && a.isPresent() && b.isPresent() && a.get().getClass().isArray() ? Arrays.equals((T[])a.get(), (T[])b.get()) : Objects.equals(a.get(), b.get()));
|
return a == b || (a != null && b != null && a.isPresent() && b.isPresent() && Objects.deepEquals(a.get(), b.get()));
|
||||||
}{{/vendorExtensions.x-jackson-optional-nullable-helpers}}
|
}{{/vendorExtensions.x-jackson-optional-nullable-helpers}}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -304,9 +304,7 @@ public class {{classname}} {{#parent}}extends {{{.}}} {{/parent}}{{#vendorExtens
|
|||||||
if (a == null) {
|
if (a == null) {
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
return a.isPresent()
|
return a.isPresent() ? Arrays.deepHashCode(new Object[]{a.get()}) : 31;
|
||||||
? (a.get().getClass().isArray() ? Arrays.hashCode((T[])a.get()) : Objects.hashCode(a.get()))
|
|
||||||
: 31;
|
|
||||||
}{{/vendorExtensions.x-jackson-optional-nullable-helpers}}
|
}{{/vendorExtensions.x-jackson-optional-nullable-helpers}}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -290,7 +290,7 @@ public class {{classname}} {{#parent}}extends {{{.}}} {{/parent}}{{#vendorExtens
|
|||||||
}{{#vendorExtensions.x-jackson-optional-nullable-helpers}}
|
}{{#vendorExtensions.x-jackson-optional-nullable-helpers}}
|
||||||
|
|
||||||
private static <T> boolean equalsNullable(JsonNullable<T> a, JsonNullable<T> b) {
|
private static <T> boolean equalsNullable(JsonNullable<T> a, JsonNullable<T> b) {
|
||||||
return a == b || (a != null && b != null && a.isPresent() && b.isPresent() && a.get().getClass().isArray() ? Arrays.equals((T[])a.get(), (T[])b.get()) : Objects.equals(a.get(), b.get()));
|
return a == b || (a != null && b != null && a.isPresent() && b.isPresent() && Objects.deepEquals(a.get(), b.get()));
|
||||||
}{{/vendorExtensions.x-jackson-optional-nullable-helpers}}
|
}{{/vendorExtensions.x-jackson-optional-nullable-helpers}}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -307,9 +307,7 @@ public class {{classname}} {{#parent}}extends {{{.}}} {{/parent}}{{#vendorExtens
|
|||||||
if (a == null) {
|
if (a == null) {
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
return a.isPresent()
|
return a.isPresent() ? Arrays.deepHashCode(new Object[]{a.get()}) : 31;
|
||||||
? (a.get().getClass().isArray() ? Arrays.hashCode((T[])a.get()) : Objects.hashCode(a.get()))
|
|
||||||
: 31;
|
|
||||||
}{{/vendorExtensions.x-jackson-optional-nullable-helpers}}
|
}{{/vendorExtensions.x-jackson-optional-nullable-helpers}}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -479,6 +479,14 @@ public class ApiClient{{#jsr310}} extends JavaTimeFormatter{{/jsr310}} {
|
|||||||
collectionFormat = CollectionFormat.CSV;
|
collectionFormat = CollectionFormat.CSV;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (value instanceof Map) {
|
||||||
|
final Map<String, Object> valuesMap = (Map<String, Object>) value;
|
||||||
|
for (final Entry<String, Object> entry : valuesMap.entrySet()) {
|
||||||
|
params.add(entry.getKey(), parameterToString(entry.getValue()));
|
||||||
|
}
|
||||||
|
return params;
|
||||||
|
}
|
||||||
|
|
||||||
Collection<?> valueCollection = null;
|
Collection<?> valueCollection = null;
|
||||||
if (value instanceof Collection) {
|
if (value instanceof Collection) {
|
||||||
valueCollection = (Collection<?>) value;
|
valueCollection = (Collection<?>) value;
|
||||||
@ -619,7 +627,7 @@ public class ApiClient{{#jsr310}} extends JavaTimeFormatter{{/jsr310}} {
|
|||||||
/**
|
/**
|
||||||
* Include queryParams in uriParams taking into account the paramName
|
* Include queryParams in uriParams taking into account the paramName
|
||||||
*
|
*
|
||||||
* @param queryParam The query parameters
|
* @param queryParams The query parameters
|
||||||
* @param uriParams The path parameters
|
* @param uriParams The path parameters
|
||||||
* return templatized query string
|
* return templatized query string
|
||||||
*/
|
*/
|
||||||
|
@ -457,6 +457,14 @@ public class ApiClient{{#jsr310}} extends JavaTimeFormatter{{/jsr310}} {
|
|||||||
collectionFormat = CollectionFormat.CSV;
|
collectionFormat = CollectionFormat.CSV;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (value instanceof Map) {
|
||||||
|
final Map<String, Object> valuesMap = (Map<String, Object>) value;
|
||||||
|
for (final Entry<String, Object> entry : valuesMap.entrySet()) {
|
||||||
|
params.add(entry.getKey(), parameterToString(entry.getValue()));
|
||||||
|
}
|
||||||
|
return params;
|
||||||
|
}
|
||||||
|
|
||||||
Collection<?> valueCollection = null;
|
Collection<?> valueCollection = null;
|
||||||
if (value instanceof Collection) {
|
if (value instanceof Collection) {
|
||||||
valueCollection = (Collection<?>) value;
|
valueCollection = (Collection<?>) value;
|
||||||
@ -615,7 +623,7 @@ public class ApiClient{{#jsr310}} extends JavaTimeFormatter{{/jsr310}} {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Include queryParams in uriParams taking into account the paramName
|
* Include queryParams in uriParams taking into account the paramName
|
||||||
* @param queryParam The query parameters
|
* @param queryParams The query parameters
|
||||||
* @param uriParams The path parameters
|
* @param uriParams The path parameters
|
||||||
* return templatized query string
|
* return templatized query string
|
||||||
*/
|
*/
|
||||||
@ -724,7 +732,7 @@ public class ApiClient{{#jsr310}} extends JavaTimeFormatter{{/jsr310}} {
|
|||||||
* @param headerParams The header parameters
|
* @param headerParams The header parameters
|
||||||
* @param cookieParams the cookie parameters
|
* @param cookieParams the cookie parameters
|
||||||
*/
|
*/
|
||||||
private void updateParamsForAuth(String[] authNames, MultiValueMap<String, String> queryParams, HttpHeaders headerParams, MultiValueMap<String, String> cookieParams) {
|
protected void updateParamsForAuth(String[] authNames, MultiValueMap<String, String> queryParams, HttpHeaders headerParams, MultiValueMap<String, String> cookieParams) {
|
||||||
for (String authName : authNames) {
|
for (String authName : authNames) {
|
||||||
Authentication auth = authentications.get(authName);
|
Authentication auth = authentications.get(authName);
|
||||||
if (auth == null) {
|
if (auth == null) {
|
||||||
|
@ -263,7 +263,7 @@ public class {{classname}} {{#parent}}extends {{{.}}} {{/parent}}{{#vendorExtens
|
|||||||
}{{#vendorExtensions.x-jackson-optional-nullable-helpers}}
|
}{{#vendorExtensions.x-jackson-optional-nullable-helpers}}
|
||||||
|
|
||||||
private static <T> boolean equalsNullable(JsonNullable<T> a, JsonNullable<T> b) {
|
private static <T> boolean equalsNullable(JsonNullable<T> a, JsonNullable<T> b) {
|
||||||
return a == b || (a != null && b != null && a.isPresent() && b.isPresent() && a.get().getClass().isArray() ? Arrays.equals((T[])a.get(), (T[])b.get()) : Objects.equals(a.get(), b.get()));
|
return a == b || (a != null && b != null && a.isPresent() && b.isPresent() && Objects.deepEquals(a.get(), b.get()));
|
||||||
}{{/vendorExtensions.x-jackson-optional-nullable-helpers}}
|
}{{/vendorExtensions.x-jackson-optional-nullable-helpers}}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -280,9 +280,7 @@ public class {{classname}} {{#parent}}extends {{{.}}} {{/parent}}{{#vendorExtens
|
|||||||
if (a == null) {
|
if (a == null) {
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
return a.isPresent()
|
return a.isPresent() ? Arrays.deepHashCode(new Object[]{a.get()}) : 31;
|
||||||
? (a.get().getClass().isArray() ? Arrays.hashCode((T[])a.get()) : Objects.hashCode(a.get()))
|
|
||||||
: 31;
|
|
||||||
}{{/vendorExtensions.x-jackson-optional-nullable-helpers}}
|
}{{/vendorExtensions.x-jackson-optional-nullable-helpers}}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -47,6 +47,7 @@ import com.fasterxml.jackson.annotation.JsonValue;
|
|||||||
return {{name}};
|
return {{name}};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@JsonProperty("{{baseName}}")
|
||||||
public void {{setter}}({{{datatypeWithEnum}}} {{name}}) {
|
public void {{setter}}({{{datatypeWithEnum}}} {{name}}) {
|
||||||
this.{{name}} = {{name}};
|
this.{{name}} = {{name}};
|
||||||
}
|
}
|
||||||
|
@ -37,6 +37,11 @@ import javax.validation.Valid;
|
|||||||
{{#jdk8}}
|
{{#jdk8}}
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
{{/jdk8}}
|
{{/jdk8}}
|
||||||
|
{{^jdk8}}
|
||||||
|
{{#useOptional}}
|
||||||
|
import java.util.Optional;
|
||||||
|
{{/useOptional}}
|
||||||
|
{{/jdk8}}
|
||||||
{{^jdk8}}
|
{{^jdk8}}
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
@ -2,7 +2,10 @@ package {{apiPackage}};
|
|||||||
|
|
||||||
{{#reactive}}
|
{{#reactive}}
|
||||||
import java.nio.charset.StandardCharsets;
|
import java.nio.charset.StandardCharsets;
|
||||||
|
import org.springframework.core.io.buffer.DefaultDataBuffer;
|
||||||
import org.springframework.core.io.buffer.DefaultDataBufferFactory;
|
import org.springframework.core.io.buffer.DefaultDataBufferFactory;
|
||||||
|
import org.springframework.http.MediaType;
|
||||||
|
import org.springframework.http.server.reactive.ServerHttpResponse;
|
||||||
import org.springframework.web.server.ServerWebExchange;
|
import org.springframework.web.server.ServerWebExchange;
|
||||||
import reactor.core.publisher.Mono;
|
import reactor.core.publisher.Mono;
|
||||||
{{/reactive}}
|
{{/reactive}}
|
||||||
@ -27,8 +30,13 @@ public class ApiUtil {
|
|||||||
}
|
}
|
||||||
{{/reactive}}
|
{{/reactive}}
|
||||||
{{#reactive}}
|
{{#reactive}}
|
||||||
public static Mono<Void> getExampleResponse(ServerWebExchange exchange, String example) {
|
public static Mono<Void> getExampleResponse(ServerWebExchange exchange, MediaType mediaType, String example) {
|
||||||
return exchange.getResponse().writeWith(Mono.just(new DefaultDataBufferFactory().wrap(example.getBytes(StandardCharsets.UTF_8))));
|
ServerHttpResponse response = exchange.getResponse();
|
||||||
|
response.getHeaders().setContentType(mediaType);
|
||||||
|
|
||||||
|
byte[] exampleBytes = example.getBytes(StandardCharsets.UTF_8);
|
||||||
|
DefaultDataBuffer data = new DefaultDataBufferFactory().wrap(exampleBytes);
|
||||||
|
return response.writeWith(Mono.just(data));
|
||||||
}
|
}
|
||||||
{{/reactive}}
|
{{/reactive}}
|
||||||
}
|
}
|
||||||
|
@ -38,7 +38,7 @@ Mono<Void> result = Mono.empty();
|
|||||||
{{/-first}}
|
{{/-first}}
|
||||||
if (mediaType.isCompatibleWith(MediaType.valueOf("{{{contentType}}}"))) {
|
if (mediaType.isCompatibleWith(MediaType.valueOf("{{{contentType}}}"))) {
|
||||||
String exampleString = {{>exampleString}};
|
String exampleString = {{>exampleString}};
|
||||||
result = ApiUtil.getExampleResponse(exchange, exampleString);
|
result = ApiUtil.getExampleResponse(exchange, mediaType, exampleString);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
{{#-last}}
|
{{#-last}}
|
||||||
|
@ -1 +1 @@
|
|||||||
{{#isPathParam}}{{#useBeanValidation}}{{>beanValidationPathParams}}{{/useBeanValidation}}@ApiParam(value = "{{{description}}}"{{#required}}, required = true{{/required}}{{#allowableValues}}, allowableValues = "{{#enumVars}}{{#lambdaEscapeDoubleQuote}}{{{value}}}{{/lambdaEscapeDoubleQuote}}{{^-last}}, {{/-last}}{{#-last}}{{/-last}}{{/enumVars}}"{{/allowableValues}}{{^isContainer}}{{#defaultValue}}, defaultValue = "{{{.}}}"{{/defaultValue}}{{/isContainer}}) @PathVariable("{{baseName}}") {{>optionalDataType}} {{paramName}}{{/isPathParam}}
|
{{#isPathParam}}{{#useBeanValidation}}{{>beanValidationPathParams}}{{/useBeanValidation}}@ApiParam(value = "{{{description}}}"{{#required}}, required = true{{/required}}{{#allowableValues}}, allowableValues = "{{#enumVars}}{{#lambdaRemoveDoubleQuote}}{{{value}}}{{/lambdaRemoveDoubleQuote}}{{^-last}}, {{/-last}}{{#-last}}{{/-last}}{{/enumVars}}"{{/allowableValues}}{{^isContainer}}{{#defaultValue}}, defaultValue = "{{{.}}}"{{/defaultValue}}{{/isContainer}}) @PathVariable("{{baseName}}") {{>optionalDataType}} {{paramName}}{{/isPathParam}}
|
@ -139,7 +139,7 @@ public class {{classname}} {{#parent}}extends {{{.}}}{{/parent}}{{^parent}}{{#ha
|
|||||||
}{{#vendorExtensions.x-jackson-optional-nullable-helpers}}
|
}{{#vendorExtensions.x-jackson-optional-nullable-helpers}}
|
||||||
|
|
||||||
private static <T> boolean equalsNullable(JsonNullable<T> a, JsonNullable<T> b) {
|
private static <T> boolean equalsNullable(JsonNullable<T> a, JsonNullable<T> b) {
|
||||||
return a == b || (a != null && b != null && a.isPresent() && b.isPresent() && a.get().getClass().isArray() ? Arrays.equals((T[])a.get(), (T[])b.get()) : Objects.equals(a.get(), b.get()));
|
return a == b || (a != null && b != null && a.isPresent() && b.isPresent() && Objects.deepEquals(a.get(), b.get()));
|
||||||
}{{/vendorExtensions.x-jackson-optional-nullable-helpers}}
|
}{{/vendorExtensions.x-jackson-optional-nullable-helpers}}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -151,9 +151,7 @@ public class {{classname}} {{#parent}}extends {{{.}}}{{/parent}}{{^parent}}{{#ha
|
|||||||
if (a == null) {
|
if (a == null) {
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
return a.isPresent()
|
return a.isPresent() ? Arrays.deepHashCode(new Object[]{a.get()}) : 31;
|
||||||
? (a.get().getClass().isArray() ? Arrays.hashCode((T[])a.get()) : Objects.hashCode(a.get()))
|
|
||||||
: 31;
|
|
||||||
}{{/vendorExtensions.x-jackson-optional-nullable-helpers}}
|
}{{/vendorExtensions.x-jackson-optional-nullable-helpers}}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -38,14 +38,14 @@ git add .
|
|||||||
git commit -m "$release_note"
|
git commit -m "$release_note"
|
||||||
|
|
||||||
# Sets the new remote
|
# Sets the new remote
|
||||||
git_remote=`git remote`
|
git_remote=$(git remote)
|
||||||
if [ "$git_remote" = "" ]; then # git remote not defined
|
if [ "$git_remote" = "" ]; then # git remote not defined
|
||||||
|
|
||||||
if [ "$GIT_TOKEN" = "" ]; then
|
if [ "$GIT_TOKEN" = "" ]; then
|
||||||
echo "[INFO] \$GIT_TOKEN (environment variable) is not set. Using the git credential in your environment."
|
echo "[INFO] \$GIT_TOKEN (environment variable) is not set. Using the git credential in your environment."
|
||||||
git remote add origin https://${git_host}/${git_user_id}/${git_repo_id}.git
|
git remote add origin https://${git_host}/${git_user_id}/${git_repo_id}.git
|
||||||
else
|
else
|
||||||
git remote add origin https://${git_user_id}:${GIT_TOKEN}@${git_host}/${git_user_id}/${git_repo_id}.git
|
git remote add origin https://${git_user_id}:"${GIT_TOKEN}"@${git_host}/${git_user_id}/${git_repo_id}.git
|
||||||
fi
|
fi
|
||||||
|
|
||||||
fi
|
fi
|
||||||
|
@ -38,14 +38,14 @@ git add .
|
|||||||
git commit -m "$release_note"
|
git commit -m "$release_note"
|
||||||
|
|
||||||
# Sets the new remote
|
# Sets the new remote
|
||||||
git_remote=`git remote`
|
git_remote=$(git remote)
|
||||||
if [ "$git_remote" = "" ]; then # git remote not defined
|
if [ "$git_remote" = "" ]; then # git remote not defined
|
||||||
|
|
||||||
if [ "$GIT_TOKEN" = "" ]; then
|
if [ "$GIT_TOKEN" = "" ]; then
|
||||||
echo "[INFO] \$GIT_TOKEN (environment variable) is not set. Using the git credential in your environment."
|
echo "[INFO] \$GIT_TOKEN (environment variable) is not set. Using the git credential in your environment."
|
||||||
git remote add origin https://${git_host}/${git_user_id}/${git_repo_id}.git
|
git remote add origin https://${git_host}/${git_user_id}/${git_repo_id}.git
|
||||||
else
|
else
|
||||||
git remote add origin https://${git_user_id}:${GIT_TOKEN}@${git_host}/${git_user_id}/${git_repo_id}.git
|
git remote add origin https://${git_user_id}:"${GIT_TOKEN}"@${git_host}/${git_user_id}/${git_repo_id}.git
|
||||||
fi
|
fi
|
||||||
|
|
||||||
fi
|
fi
|
||||||
|
@ -38,14 +38,14 @@ git add .
|
|||||||
git commit -m "$release_note"
|
git commit -m "$release_note"
|
||||||
|
|
||||||
# Sets the new remote
|
# Sets the new remote
|
||||||
git_remote=`git remote`
|
git_remote=$(git remote)
|
||||||
if [ "$git_remote" = "" ]; then # git remote not defined
|
if [ "$git_remote" = "" ]; then # git remote not defined
|
||||||
|
|
||||||
if [ "$GIT_TOKEN" = "" ]; then
|
if [ "$GIT_TOKEN" = "" ]; then
|
||||||
echo "[INFO] \$GIT_TOKEN (environment variable) is not set. Using the git credential in your environment."
|
echo "[INFO] \$GIT_TOKEN (environment variable) is not set. Using the git credential in your environment."
|
||||||
git remote add origin https://${git_host}/${git_user_id}/${git_repo_id}.git
|
git remote add origin https://${git_host}/${git_user_id}/${git_repo_id}.git
|
||||||
else
|
else
|
||||||
git remote add origin https://${git_user_id}:${GIT_TOKEN}@${git_host}/${git_user_id}/${git_repo_id}.git
|
git remote add origin https://${git_user_id}:"${GIT_TOKEN}"@${git_host}/${git_user_id}/${git_repo_id}.git
|
||||||
fi
|
fi
|
||||||
|
|
||||||
fi
|
fi
|
||||||
|
@ -38,14 +38,14 @@ git add .
|
|||||||
git commit -m "$release_note"
|
git commit -m "$release_note"
|
||||||
|
|
||||||
# Sets the new remote
|
# Sets the new remote
|
||||||
git_remote=`git remote`
|
git_remote=$(git remote)
|
||||||
if [ "$git_remote" = "" ]; then # git remote not defined
|
if [ "$git_remote" = "" ]; then # git remote not defined
|
||||||
|
|
||||||
if [ "$GIT_TOKEN" = "" ]; then
|
if [ "$GIT_TOKEN" = "" ]; then
|
||||||
echo "[INFO] \$GIT_TOKEN (environment variable) is not set. Using the git credential in your environment."
|
echo "[INFO] \$GIT_TOKEN (environment variable) is not set. Using the git credential in your environment."
|
||||||
git remote add origin https://${git_host}/${git_user_id}/${git_repo_id}.git
|
git remote add origin https://${git_host}/${git_user_id}/${git_repo_id}.git
|
||||||
else
|
else
|
||||||
git remote add origin https://${git_user_id}:${GIT_TOKEN}@${git_host}/${git_user_id}/${git_repo_id}.git
|
git remote add origin https://${git_user_id}:"${GIT_TOKEN}"@${git_host}/${git_user_id}/${git_repo_id}.git
|
||||||
fi
|
fi
|
||||||
|
|
||||||
fi
|
fi
|
||||||
|
@ -38,14 +38,14 @@ git add .
|
|||||||
git commit -m "$release_note"
|
git commit -m "$release_note"
|
||||||
|
|
||||||
# Sets the new remote
|
# Sets the new remote
|
||||||
git_remote=`git remote`
|
git_remote=$(git remote)
|
||||||
if [ "$git_remote" = "" ]; then # git remote not defined
|
if [ "$git_remote" = "" ]; then # git remote not defined
|
||||||
|
|
||||||
if [ "$GIT_TOKEN" = "" ]; then
|
if [ "$GIT_TOKEN" = "" ]; then
|
||||||
echo "[INFO] \$GIT_TOKEN (environment variable) is not set. Using the git credential in your environment."
|
echo "[INFO] \$GIT_TOKEN (environment variable) is not set. Using the git credential in your environment."
|
||||||
git remote add origin https://${git_host}/${git_user_id}/${git_repo_id}.git
|
git remote add origin https://${git_host}/${git_user_id}/${git_repo_id}.git
|
||||||
else
|
else
|
||||||
git remote add origin https://${git_user_id}:${GIT_TOKEN}@${git_host}/${git_user_id}/${git_repo_id}.git
|
git remote add origin https://${git_user_id}:"${GIT_TOKEN}"@${git_host}/${git_user_id}/${git_repo_id}.git
|
||||||
fi
|
fi
|
||||||
|
|
||||||
fi
|
fi
|
||||||
|
@ -38,14 +38,14 @@ git add .
|
|||||||
git commit -m "$release_note"
|
git commit -m "$release_note"
|
||||||
|
|
||||||
# Sets the new remote
|
# Sets the new remote
|
||||||
git_remote=`git remote`
|
git_remote=$(git remote)
|
||||||
if [ "$git_remote" = "" ]; then # git remote not defined
|
if [ "$git_remote" = "" ]; then # git remote not defined
|
||||||
|
|
||||||
if [ "$GIT_TOKEN" = "" ]; then
|
if [ "$GIT_TOKEN" = "" ]; then
|
||||||
echo "[INFO] \$GIT_TOKEN (environment variable) is not set. Using the git credential in your environment."
|
echo "[INFO] \$GIT_TOKEN (environment variable) is not set. Using the git credential in your environment."
|
||||||
git remote add origin https://${git_host}/${git_user_id}/${git_repo_id}.git
|
git remote add origin https://${git_host}/${git_user_id}/${git_repo_id}.git
|
||||||
else
|
else
|
||||||
git remote add origin https://${git_user_id}:${GIT_TOKEN}@${git_host}/${git_user_id}/${git_repo_id}.git
|
git remote add origin https://${git_user_id}:"${GIT_TOKEN}"@${git_host}/${git_user_id}/${git_repo_id}.git
|
||||||
fi
|
fi
|
||||||
|
|
||||||
fi
|
fi
|
||||||
|
@ -38,14 +38,14 @@ git add .
|
|||||||
git commit -m "$release_note"
|
git commit -m "$release_note"
|
||||||
|
|
||||||
# Sets the new remote
|
# Sets the new remote
|
||||||
git_remote=`git remote`
|
git_remote=$(git remote)
|
||||||
if [ "$git_remote" = "" ]; then # git remote not defined
|
if [ "$git_remote" = "" ]; then # git remote not defined
|
||||||
|
|
||||||
if [ "$GIT_TOKEN" = "" ]; then
|
if [ "$GIT_TOKEN" = "" ]; then
|
||||||
echo "[INFO] \$GIT_TOKEN (environment variable) is not set. Using the git credential in your environment."
|
echo "[INFO] \$GIT_TOKEN (environment variable) is not set. Using the git credential in your environment."
|
||||||
git remote add origin https://${git_host}/${git_user_id}/${git_repo_id}.git
|
git remote add origin https://${git_host}/${git_user_id}/${git_repo_id}.git
|
||||||
else
|
else
|
||||||
git remote add origin https://${git_user_id}:${GIT_TOKEN}@${git_host}/${git_user_id}/${git_repo_id}.git
|
git remote add origin https://${git_user_id}:"${GIT_TOKEN}"@${git_host}/${git_user_id}/${git_repo_id}.git
|
||||||
fi
|
fi
|
||||||
|
|
||||||
fi
|
fi
|
||||||
|
@ -4,9 +4,11 @@
|
|||||||
*/
|
*/
|
||||||
#ifndef {{prefix}}_SERVERVCONFIGURATION_H
|
#ifndef {{prefix}}_SERVERVCONFIGURATION_H
|
||||||
#define {{prefix}}_SERVERVCONFIGURATION_H
|
#define {{prefix}}_SERVERVCONFIGURATION_H
|
||||||
|
|
||||||
#include <QString>
|
#include <QString>
|
||||||
#include <QMap>
|
#include <QMap>
|
||||||
#include <QRegularExpression>
|
#include <QRegularExpression>
|
||||||
|
#include <QUrl>
|
||||||
#include <stdexcept>
|
#include <stdexcept>
|
||||||
#include "{{prefix}}ServerVariable.h"
|
#include "{{prefix}}ServerVariable.h"
|
||||||
|
|
||||||
|
@ -11,19 +11,21 @@ namespace {{this}} {
|
|||||||
{{classname}}::{{classname}}(const int timeOut)
|
{{classname}}::{{classname}}(const int timeOut)
|
||||||
: _timeOut(timeOut),
|
: _timeOut(timeOut),
|
||||||
_manager(nullptr),
|
_manager(nullptr),
|
||||||
isResponseCompressionEnabled(false),
|
_isResponseCompressionEnabled(false),
|
||||||
isRequestCompressionEnabled(false) {
|
_isRequestCompressionEnabled(false) {
|
||||||
initializeServerConfigs();
|
initializeServerConfigs();
|
||||||
}
|
}
|
||||||
|
|
||||||
{{classname}}::~{{classname}}() {
|
{{classname}}::~{{classname}}() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void {{classname}}::initializeServerConfigs(){
|
void {{classname}}::initializeServerConfigs() {
|
||||||
//Default server
|
//Default server
|
||||||
QList<{{prefix}}ServerConfiguration> defaultConf = QList<{{prefix}}ServerConfiguration>();
|
QList<{{prefix}}ServerConfiguration> defaultConf = QList<{{prefix}}ServerConfiguration>();
|
||||||
//varying endpoint server
|
//varying endpoint server
|
||||||
|
{{#servers}}
|
||||||
QList<{{prefix}}ServerConfiguration> serverConf = QList<{{prefix}}ServerConfiguration>();
|
QList<{{prefix}}ServerConfiguration> serverConf = QList<{{prefix}}ServerConfiguration>();
|
||||||
|
{{/servers}}
|
||||||
{{#vendorExtensions.x-cpp-global-server-list}}
|
{{#vendorExtensions.x-cpp-global-server-list}}
|
||||||
defaultConf.append({{prefix}}ServerConfiguration(
|
defaultConf.append({{prefix}}ServerConfiguration(
|
||||||
QUrl("{{{url}}}"),
|
QUrl("{{{url}}}"),
|
||||||
@ -58,23 +60,24 @@ void {{classname}}::initializeServerConfigs(){
|
|||||||
* returns 0 on success and -1, -2 or -3 on failure.
|
* returns 0 on success and -1, -2 or -3 on failure.
|
||||||
* -1 when the variable does not exist and -2 if the value is not defined in the enum and -3 if the operation or server index is not found
|
* -1 when the variable does not exist and -2 if the value is not defined in the enum and -3 if the operation or server index is not found
|
||||||
*/
|
*/
|
||||||
int {{classname}}::setDefaultServerValue(int serverIndex, const QString &operation, const QString &variable, const QString &value){
|
int {{classname}}::setDefaultServerValue(int serverIndex, const QString &operation, const QString &variable, const QString &value) {
|
||||||
auto it = _serverConfigs.find(operation);
|
auto it = _serverConfigs.find(operation);
|
||||||
if(it != _serverConfigs.end() && serverIndex < it.value().size() ){
|
if (it != _serverConfigs.end() && serverIndex < it.value().size()) {
|
||||||
return _serverConfigs[operation][serverIndex].setDefaultValue(variable,value);
|
return _serverConfigs[operation][serverIndex].setDefaultValue(variable,value);
|
||||||
}
|
}
|
||||||
return -3;
|
return -3;
|
||||||
}
|
}
|
||||||
void {{classname}}::setServerIndex(const QString &operation, int serverIndex){
|
void {{classname}}::setServerIndex(const QString &operation, int serverIndex) {
|
||||||
if(_serverIndices.contains(operation) && serverIndex < _serverConfigs.find(operation).value().size() )
|
if (_serverIndices.contains(operation) && serverIndex < _serverConfigs.find(operation).value().size()) {
|
||||||
_serverIndices[operation] = serverIndex;
|
_serverIndices[operation] = serverIndex;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void {{classname}}::setApiKey(const QString &apiKeyName, const QString &apiKey){
|
void {{classname}}::setApiKey(const QString &apiKeyName, const QString &apiKey) {
|
||||||
_apiKeys.insert(apiKeyName,apiKey);
|
_apiKeys.insert(apiKeyName,apiKey);
|
||||||
}
|
}
|
||||||
|
|
||||||
void {{classname}}::setBearerToken(const QString &token){
|
void {{classname}}::setBearerToken(const QString &token) {
|
||||||
_bearerToken = token;
|
_bearerToken = token;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -107,14 +110,14 @@ void {{classname}}::setNetworkAccessManager(QNetworkAccessManager* manager) {
|
|||||||
* @param variables A map between a variable name and its value. The value is used for substitution in the server's URL template.
|
* @param variables A map between a variable name and its value. The value is used for substitution in the server's URL template.
|
||||||
* returns the index of the new server config on success and -1 if the operation is not found
|
* returns the index of the new server config on success and -1 if the operation is not found
|
||||||
*/
|
*/
|
||||||
int {{classname}}::addServerConfiguration(const QString &operation, const QUrl &url, const QString &description, const QMap<QString, {{prefix}}ServerVariable> &variables){
|
int {{classname}}::addServerConfiguration(const QString &operation, const QUrl &url, const QString &description, const QMap<QString, {{prefix}}ServerVariable> &variables) {
|
||||||
if(_serverConfigs.contains(operation)){
|
if (_serverConfigs.contains(operation)) {
|
||||||
_serverConfigs[operation].append({{prefix}}ServerConfiguration(
|
_serverConfigs[operation].append({{prefix}}ServerConfiguration(
|
||||||
url,
|
url,
|
||||||
description,
|
description,
|
||||||
variables));
|
variables));
|
||||||
return _serverConfigs[operation].size()-1;
|
return _serverConfigs[operation].size()-1;
|
||||||
}else{
|
} else {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -125,10 +128,16 @@ int {{classname}}::addServerConfiguration(const QString &operation, const QUrl &
|
|||||||
* @param description A String that describes the server
|
* @param description A String that describes the server
|
||||||
* @param variables A map between a variable name and its value. The value is used for substitution in the server's URL template.
|
* @param variables A map between a variable name and its value. The value is used for substitution in the server's URL template.
|
||||||
*/
|
*/
|
||||||
void {{classname}}::setNewServerForAllOperations(const QUrl &url, const QString &description, const QMap<QString, {{prefix}}ServerVariable> &variables){
|
void {{classname}}::setNewServerForAllOperations(const QUrl &url, const QString &description, const QMap<QString, {{prefix}}ServerVariable> &variables) {
|
||||||
for(auto e : _serverIndices.keys()){
|
#if QT_VERSION >= QT_VERSION_CHECK(5, 12, 0)
|
||||||
|
for (auto keyIt = _serverIndices.keyBegin(); keyIt != _serverIndices.keyEnd(); keyIt++) {
|
||||||
|
setServerIndex(*keyIt, addServerConfiguration(*keyIt, url, description, variables));
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
for (auto &e : _serverIndices.keys()) {
|
||||||
setServerIndex(e, addServerConfiguration(e, url, description, variables));
|
setServerIndex(e, addServerConfiguration(e, url, description, variables));
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -137,85 +146,85 @@ void {{classname}}::setNewServerForAllOperations(const QUrl &url, const QString
|
|||||||
* @param description A String that describes the server
|
* @param description A String that describes the server
|
||||||
* @param variables A map between a variable name and its value. The value is used for substitution in the server's URL template.
|
* @param variables A map between a variable name and its value. The value is used for substitution in the server's URL template.
|
||||||
*/
|
*/
|
||||||
void {{classname}}::setNewServer(const QString &operation, const QUrl &url, const QString &description, const QMap<QString, {{prefix}}ServerVariable> &variables){
|
void {{classname}}::setNewServer(const QString &operation, const QUrl &url, const QString &description, const QMap<QString, {{prefix}}ServerVariable> &variables) {
|
||||||
setServerIndex(operation, addServerConfiguration(operation, url, description, variables));
|
setServerIndex(operation, addServerConfiguration(operation, url, description, variables));
|
||||||
}
|
}
|
||||||
|
|
||||||
void {{classname}}::addHeaders(const QString &key, const QString &value) {
|
void {{classname}}::addHeaders(const QString &key, const QString &value) {
|
||||||
defaultHeaders.insert(key, value);
|
_defaultHeaders.insert(key, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
void {{classname}}::enableRequestCompression() {
|
void {{classname}}::enableRequestCompression() {
|
||||||
isRequestCompressionEnabled = true;
|
_isRequestCompressionEnabled = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void {{classname}}::enableResponseCompression() {
|
void {{classname}}::enableResponseCompression() {
|
||||||
isResponseCompressionEnabled = true;
|
_isResponseCompressionEnabled = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void {{classname}}::abortRequests(){
|
void {{classname}}::abortRequests() {
|
||||||
emit abortRequestsSignal();
|
emit abortRequestsSignal();
|
||||||
}
|
}
|
||||||
|
|
||||||
QString {{classname}}::getParamStylePrefix(QString style){
|
QString {{classname}}::getParamStylePrefix(const QString &style) {
|
||||||
if(style == "matrix"){
|
if (style == "matrix") {
|
||||||
return ";";
|
return ";";
|
||||||
}else if(style == "label"){
|
} else if (style == "label") {
|
||||||
return ".";
|
return ".";
|
||||||
}else if(style == "form"){
|
} else if (style == "form") {
|
||||||
return "&";
|
return "&";
|
||||||
}else if(style == "simple"){
|
} else if (style == "simple") {
|
||||||
return "";
|
return "";
|
||||||
}else if(style == "spaceDelimited"){
|
} else if (style == "spaceDelimited") {
|
||||||
return "&";
|
return "&";
|
||||||
}else if(style == "pipeDelimited"){
|
} else if (style == "pipeDelimited") {
|
||||||
return "&";
|
return "&";
|
||||||
}else{
|
} else {
|
||||||
return "none";
|
return "none";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
QString {{classname}}::getParamStyleSuffix(QString style){
|
QString {{classname}}::getParamStyleSuffix(const QString &style) {
|
||||||
if(style == "matrix"){
|
if (style == "matrix") {
|
||||||
return "=";
|
return "=";
|
||||||
}else if(style == "label"){
|
} else if (style == "label") {
|
||||||
return "";
|
return "";
|
||||||
}else if(style == "form"){
|
} else if (style == "form") {
|
||||||
return "=";
|
return "=";
|
||||||
}else if(style == "simple"){
|
} else if (style == "simple") {
|
||||||
return "";
|
return "";
|
||||||
}else if(style == "spaceDelimited"){
|
} else if (style == "spaceDelimited") {
|
||||||
return "=";
|
return "=";
|
||||||
}else if(style == "pipeDelimited"){
|
} else if (style == "pipeDelimited") {
|
||||||
return "=";
|
return "=";
|
||||||
}else{
|
} else {
|
||||||
return "none";
|
return "none";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
QString {{classname}}::getParamStyleDelimiter(QString style, QString name, bool isExplode){
|
QString {{classname}}::getParamStyleDelimiter(const QString &style, const QString &name, bool isExplode) {
|
||||||
|
|
||||||
if(style == "matrix"){
|
if (style == "matrix") {
|
||||||
return (isExplode) ? ";" + name + "=" : ",";
|
return (isExplode) ? ";" + name + "=" : ",";
|
||||||
|
|
||||||
}else if(style == "label"){
|
} else if (style == "label") {
|
||||||
return (isExplode) ? "." : ",";
|
return (isExplode) ? "." : ",";
|
||||||
|
|
||||||
}else if(style == "form"){
|
} else if (style == "form") {
|
||||||
return (isExplode) ? "&" + name + "=" : ",";
|
return (isExplode) ? "&" + name + "=" : ",";
|
||||||
|
|
||||||
}else if(style == "simple"){
|
} else if (style == "simple") {
|
||||||
return ",";
|
return ",";
|
||||||
}else if(style == "spaceDelimited"){
|
} else if (style == "spaceDelimited") {
|
||||||
return (isExplode) ? "&" + name + "=" : " ";
|
return (isExplode) ? "&" + name + "=" : " ";
|
||||||
|
|
||||||
}else if(style == "pipeDelimited"){
|
} else if (style == "pipeDelimited") {
|
||||||
return (isExplode) ? "&" + name + "=" : "|";
|
return (isExplode) ? "&" + name + "=" : "|";
|
||||||
|
|
||||||
}else if(style == "deepObject"){
|
} else if (style == "deepObject") {
|
||||||
return (isExplode) ? "&" : "none";
|
return (isExplode) ? "&" : "none";
|
||||||
|
|
||||||
}else {
|
} else {
|
||||||
return "none";
|
return "none";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -225,11 +234,11 @@ QString {{classname}}::getParamStyleDelimiter(QString style, QString name, bool
|
|||||||
void {{classname}}::{{nickname}}({{#allParams}}{{#required}}const {{{dataType}}} &{{/required}}{{^required}}const ::{{cppNamespace}}::OptionalParam<{{{dataType}}}> &{{/required}}{{paramName}}{{^-last}}, {{/-last}}{{/allParams}}) {
|
void {{classname}}::{{nickname}}({{#allParams}}{{#required}}const {{{dataType}}} &{{/required}}{{^required}}const ::{{cppNamespace}}::OptionalParam<{{{dataType}}}> &{{/required}}{{paramName}}{{^-last}}, {{/-last}}{{/allParams}}) {
|
||||||
QString fullPath = QString(_serverConfigs["{{nickname}}"][_serverIndices.value("{{nickname}}")].URL()+"{{{path}}}");
|
QString fullPath = QString(_serverConfigs["{{nickname}}"][_serverIndices.value("{{nickname}}")].URL()+"{{{path}}}");
|
||||||
{{#authMethods}}{{#isApiKey}}{{#isKeyInHeader}}
|
{{#authMethods}}{{#isApiKey}}{{#isKeyInHeader}}
|
||||||
if(_apiKeys.contains("{{name}}")){
|
if (_apiKeys.contains("{{name}}")) {
|
||||||
addHeaders("{{name}}",_apiKeys.find("{{name}}").value());
|
addHeaders("{{name}}",_apiKeys.find("{{name}}").value());
|
||||||
}
|
}
|
||||||
{{/isKeyInHeader}}{{#isKeyInQuery}}
|
{{/isKeyInHeader}}{{#isKeyInQuery}}
|
||||||
if(_apiKeys.contains("{{name}}")){
|
if (_apiKeys.contains("{{name}}")) {
|
||||||
if (fullPath.indexOf("?") > 0)
|
if (fullPath.indexOf("?") > 0)
|
||||||
fullPath.append("&");
|
fullPath.append("&");
|
||||||
else
|
else
|
||||||
@ -237,22 +246,22 @@ void {{classname}}::{{nickname}}({{#allParams}}{{#required}}const {{{dataType}}}
|
|||||||
fullPath.append("{{{name}}}=").append(_apiKeys.find("{{name}}").value());
|
fullPath.append("{{{name}}}=").append(_apiKeys.find("{{name}}").value());
|
||||||
}
|
}
|
||||||
{{/isKeyInQuery}}{{/isApiKey}}{{#isBasicBearer}}
|
{{/isKeyInQuery}}{{/isApiKey}}{{#isBasicBearer}}
|
||||||
if(!_bearerToken.isEmpty())
|
if (!_bearerToken.isEmpty())
|
||||||
addHeaders("Authorization", "Bearer " + _bearerToken);
|
addHeaders("Authorization", "Bearer " + _bearerToken);
|
||||||
{{/isBasicBearer}}{{#isBasicBasic}}
|
{{/isBasicBearer}}{{#isBasicBasic}}
|
||||||
if(!_username.isEmpty() && !_password.isEmpty()){
|
if (!_username.isEmpty() && !_password.isEmpty()) {
|
||||||
QByteArray b64;
|
QByteArray b64;
|
||||||
b64.append(_username.toUtf8() + ":" + _password.toUtf8());
|
b64.append(_username.toUtf8() + ":" + _password.toUtf8());
|
||||||
addHeaders("Authorization","Basic " + b64.toBase64());
|
addHeaders("Authorization","Basic " + b64.toBase64());
|
||||||
}{{/isBasicBasic}}{{/authMethods}}
|
}{{/isBasicBasic}}{{/authMethods}}
|
||||||
{{#pathParams}}
|
{{#pathParams}}
|
||||||
{{^required}}if({{paramName}}.hasValue()){{/required}}
|
{{^required}}if ({{paramName}}.hasValue()) {{/required}}
|
||||||
{
|
{
|
||||||
QString {{paramName}}PathParam("{");
|
QString {{paramName}}PathParam("{");
|
||||||
{{paramName}}PathParam.append("{{baseName}}").append("}");
|
{{paramName}}PathParam.append("{{baseName}}").append("}");
|
||||||
QString pathPrefix, pathSuffix, pathDelimiter;
|
QString pathPrefix, pathSuffix, pathDelimiter;
|
||||||
QString pathStyle = "{{style}}";
|
QString pathStyle = "{{style}}";
|
||||||
if(pathStyle == "")
|
if (pathStyle == "")
|
||||||
pathStyle = "simple";
|
pathStyle = "simple";
|
||||||
pathPrefix = getParamStylePrefix(pathStyle);
|
pathPrefix = getParamStylePrefix(pathStyle);
|
||||||
pathSuffix = getParamStyleSuffix(pathStyle);
|
pathSuffix = getParamStyleSuffix(pathStyle);
|
||||||
@ -308,7 +317,7 @@ void {{classname}}::{{nickname}}({{#allParams}}{{#required}}const {{{dataType}}}
|
|||||||
{{/isPrimitiveType}}
|
{{/isPrimitiveType}}
|
||||||
{{/collectionFormat}}
|
{{/collectionFormat}}
|
||||||
{{#collectionFormat}}
|
{{#collectionFormat}}
|
||||||
if({{{paramName}}}{{^required}}.value(){{/required}}.size() > 0) {
|
if ({{{paramName}}}{{^required}}.value(){{/required}}.size() > 0) {
|
||||||
QString paramString = (pathStyle == "matrix") ? pathPrefix+"{{baseName}}"+pathSuffix : pathPrefix;
|
QString paramString = (pathStyle == "matrix") ? pathPrefix+"{{baseName}}"+pathSuffix : pathPrefix;
|
||||||
qint32 count = 0;
|
qint32 count = 0;
|
||||||
foreach ({{{baseType}}} t, {{paramName}}{{^required}}.value(){{/required}}) {
|
foreach ({{{baseType}}} t, {{paramName}}{{^required}}.value(){{/required}}) {
|
||||||
@ -327,10 +336,10 @@ void {{classname}}::{{nickname}}({{#allParams}}{{#required}}const {{{dataType}}}
|
|||||||
QString queryPrefix, querySuffix, queryDelimiter, queryStyle;
|
QString queryPrefix, querySuffix, queryDelimiter, queryStyle;
|
||||||
{{/hasQueryParams}}
|
{{/hasQueryParams}}
|
||||||
{{#queryParams}}
|
{{#queryParams}}
|
||||||
{{^required}}if({{paramName}}.hasValue()){{/required}}
|
{{^required}}if ({{paramName}}.hasValue()){{/required}}
|
||||||
{
|
{
|
||||||
queryStyle = "{{style}}";
|
queryStyle = "{{style}}";
|
||||||
if(queryStyle == "")
|
if (queryStyle == "")
|
||||||
queryStyle = "form";
|
queryStyle = "form";
|
||||||
queryPrefix = getParamStylePrefix(queryStyle);
|
queryPrefix = getParamStylePrefix(queryStyle);
|
||||||
querySuffix = getParamStyleSuffix(queryStyle);
|
querySuffix = getParamStyleSuffix(queryStyle);
|
||||||
@ -392,7 +401,7 @@ void {{classname}}::{{nickname}}({{#allParams}}{{#required}}const {{{dataType}}}
|
|||||||
{{/isPrimitiveType}}
|
{{/isPrimitiveType}}
|
||||||
{{/collectionFormat}}
|
{{/collectionFormat}}
|
||||||
{{#collectionFormat}}
|
{{#collectionFormat}}
|
||||||
if({{{paramName}}}{{^required}}.value(){{/required}}.size() > 0) {
|
if ({{{paramName}}}{{^required}}.value(){{/required}}.size() > 0) {
|
||||||
if (QString("{{collectionFormat}}").indexOf("multi") == 0) {
|
if (QString("{{collectionFormat}}").indexOf("multi") == 0) {
|
||||||
foreach ({{{baseType}}} t, {{paramName}}{{^required}}.value(){{/required}}) {
|
foreach ({{{baseType}}} t, {{paramName}}{{^required}}.value(){{/required}}) {
|
||||||
if (fullPath.indexOf("?") > 0)
|
if (fullPath.indexOf("?") > 0)
|
||||||
@ -474,21 +483,21 @@ void {{classname}}::{{nickname}}({{#allParams}}{{#required}}const {{{dataType}}}
|
|||||||
{{prefix}}HttpRequestWorker *worker = new {{prefix}}HttpRequestWorker(this, _manager);
|
{{prefix}}HttpRequestWorker *worker = new {{prefix}}HttpRequestWorker(this, _manager);
|
||||||
worker->setTimeOut(_timeOut);
|
worker->setTimeOut(_timeOut);
|
||||||
worker->setWorkingDirectory(_workingDirectory);{{#contentCompression}}
|
worker->setWorkingDirectory(_workingDirectory);{{#contentCompression}}
|
||||||
worker->setResponseCompressionEnabled(isResponseCompressionEnabled);
|
worker->setResponseCompressionEnabled(_isResponseCompressionEnabled);
|
||||||
worker->setRequestCompressionEnabled(isRequestCompressionEnabled);{{/contentCompression}}
|
worker->setRequestCompressionEnabled(_isRequestCompressionEnabled);{{/contentCompression}}
|
||||||
{{prefix}}HttpRequestInput input(fullPath, "{{httpMethod}}");
|
{{prefix}}HttpRequestInput input(fullPath, "{{httpMethod}}");
|
||||||
|
|
||||||
{{#formParams}}
|
{{#formParams}}
|
||||||
{{#first}}
|
{{#first}}
|
||||||
QString formPrefix,formSuffix, formDelimiter;
|
QString formPrefix,formSuffix, formDelimiter;
|
||||||
QString formStyle = "{{style}}";
|
QString formStyle = "{{style}}";
|
||||||
if(formStyle == "")
|
if (formStyle == "")
|
||||||
formStyle = "form";
|
formStyle = "form";
|
||||||
formPrefix = getParamStylePrefix(formStyle);
|
formPrefix = getParamStylePrefix(formStyle);
|
||||||
formSuffix = getParamStyleSuffix(formStyle);
|
formSuffix = getParamStyleSuffix(formStyle);
|
||||||
formDelimiter = getParamStyleDelimiter(formStyle, "{{baseName}}", {{isExplode}});
|
formDelimiter = getParamStyleDelimiter(formStyle, "{{baseName}}", {{isExplode}});
|
||||||
{{/first}}
|
{{/first}}
|
||||||
{{^required}}if({{paramName}}.hasValue()){{/required}}
|
{{^required}}if ({{paramName}}.hasValue()){{/required}}
|
||||||
{
|
{
|
||||||
{{^isFile}}
|
{{^isFile}}
|
||||||
input.add_var("{{baseName}}", ::{{cppNamespace}}::toStringValue({{paramName}}{{^required}}.value(){{/required}}));
|
input.add_var("{{baseName}}", ::{{cppNamespace}}::toStringValue({{paramName}}{{^required}}.value(){{/required}}));
|
||||||
@ -499,7 +508,7 @@ void {{classname}}::{{nickname}}({{#allParams}}{{#required}}const {{{dataType}}}
|
|||||||
}
|
}
|
||||||
{{/formParams}}
|
{{/formParams}}
|
||||||
{{#bodyParams}}
|
{{#bodyParams}}
|
||||||
{{^required}}if({{paramName}}.hasValue()){{/required}}{
|
{{^required}}if ({{paramName}}.hasValue()){{/required}}{
|
||||||
{{#isContainer}}
|
{{#isContainer}}
|
||||||
{{#isArray}}
|
{{#isArray}}
|
||||||
QJsonDocument doc(::{{cppNamespace}}::toJsonValue({{paramName}}{{^required}}.value(){{/required}}).toArray());{{/isArray}}{{#isMap}}
|
QJsonDocument doc(::{{cppNamespace}}::toJsonValue({{paramName}}{{^required}}.value(){{/required}}).toArray());{{/isArray}}{{#isMap}}
|
||||||
@ -514,7 +523,7 @@ void {{classname}}::{{nickname}}({{#allParams}}{{#required}}const {{{dataType}}}
|
|||||||
{{/isContainer}}
|
{{/isContainer}}
|
||||||
}{{/bodyParams}}
|
}{{/bodyParams}}
|
||||||
{{#headerParams}}
|
{{#headerParams}}
|
||||||
{{^required}}if({{paramName}}.hasValue()){{/required}}
|
{{^required}}if ({{paramName}}.hasValue()){{/required}}
|
||||||
{
|
{
|
||||||
{{^collectionFormat}}
|
{{^collectionFormat}}
|
||||||
{{^isPrimitiveType}}
|
{{^isPrimitiveType}}
|
||||||
@ -581,9 +590,9 @@ void {{classname}}::{{nickname}}({{#allParams}}{{#required}}const {{{dataType}}}
|
|||||||
}
|
}
|
||||||
{{/headerParams}}
|
{{/headerParams}}
|
||||||
{{#cookieParams}}
|
{{#cookieParams}}
|
||||||
{{^required}}if({{paramName}}.hasValue()){{/required}}
|
{{^required}}if ({{paramName}}.hasValue()){{/required}}
|
||||||
{
|
{
|
||||||
if(QString("{{style}}").indexOf("form") == 0){
|
if (QString("{{style}}").indexOf("form") == 0) {
|
||||||
{{^collectionFormat}}
|
{{^collectionFormat}}
|
||||||
{{^isPrimitiveType}}
|
{{^isPrimitiveType}}
|
||||||
{{^isExplode}}
|
{{^isExplode}}
|
||||||
@ -630,7 +639,7 @@ void {{classname}}::{{nickname}}({{#allParams}}{{#required}}const {{{dataType}}}
|
|||||||
{{/isExplode}}
|
{{/isExplode}}
|
||||||
{{/isPrimitiveType}}
|
{{/isPrimitiveType}}
|
||||||
{{#isPrimitiveType}}
|
{{#isPrimitiveType}}
|
||||||
if(!::{{cppNamespace}}::toStringValue({{paramName}}{{^required}}.value(){{/required}}).isEmpty()) {
|
if (!::{{cppNamespace}}::toStringValue({{paramName}}{{^required}}.value(){{/required}}).isEmpty()) {
|
||||||
input.headers.insert("Cookie", "{{baseName}}="+::{{cppNamespace}}::toStringValue({{paramName}}{{^required}}.value(){{/required}}));
|
input.headers.insert("Cookie", "{{baseName}}="+::{{cppNamespace}}::toStringValue({{paramName}}{{^required}}.value(){{/required}}));
|
||||||
}
|
}
|
||||||
{{/isPrimitiveType}}
|
{{/isPrimitiveType}}
|
||||||
@ -653,12 +662,20 @@ void {{classname}}::{{nickname}}({{#allParams}}{{#required}}const {{{dataType}}}
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
{{/cookieParams}}
|
{{/cookieParams}}
|
||||||
foreach (QString key, this->defaultHeaders.keys()) { input.headers.insert(key, this->defaultHeaders.value(key)); }
|
#if QT_VERSION >= QT_VERSION_CHECK(5, 15, 0)
|
||||||
|
for (auto keyValueIt = _defaultHeaders.keyValueBegin(); keyValueIt != _defaultHeaders.keyValueEnd(); keyValueIt++) {
|
||||||
|
input.headers.insert(keyValueIt->first, keyValueIt->second);
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
for (auto key : _defaultHeaders.keys()) {
|
||||||
|
input.headers.insert(key, _defaultHeaders[key]);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
connect(worker, &{{prefix}}HttpRequestWorker::on_execution_finished, this, &{{classname}}::{{nickname}}Callback);
|
connect(worker, &{{prefix}}HttpRequestWorker::on_execution_finished, this, &{{classname}}::{{nickname}}Callback);
|
||||||
connect(this, &{{classname}}::abortRequestsSignal, worker, &QObject::deleteLater);
|
connect(this, &{{classname}}::abortRequestsSignal, worker, &QObject::deleteLater);
|
||||||
connect(worker, &QObject::destroyed, [this](){
|
connect(worker, &QObject::destroyed, this, [this]() {
|
||||||
if(findChildren<{{prefix}}HttpRequestWorker*>().count() == 0){
|
if (findChildren<{{prefix}}HttpRequestWorker*>().count() == 0) {
|
||||||
emit allPendingRequestsCompleted();
|
emit allPendingRequestsCompleted();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -667,15 +684,11 @@ void {{classname}}::{{nickname}}({{#allParams}}{{#required}}const {{{dataType}}}
|
|||||||
}
|
}
|
||||||
|
|
||||||
void {{classname}}::{{nickname}}Callback({{prefix}}HttpRequestWorker *worker) {
|
void {{classname}}::{{nickname}}Callback({{prefix}}HttpRequestWorker *worker) {
|
||||||
QString msg;
|
|
||||||
QString error_str = worker->error_str;
|
QString error_str = worker->error_str;
|
||||||
QNetworkReply::NetworkError error_type = worker->error_type;
|
QNetworkReply::NetworkError error_type = worker->error_type;
|
||||||
|
|
||||||
if (worker->error_type == QNetworkReply::NoError) {
|
if (worker->error_type != QNetworkReply::NoError) {
|
||||||
msg = QString("Success! %1 bytes").arg(worker->response.length());
|
error_str = QString("%1, %2").arg(worker->error_str, QString(worker->response));
|
||||||
} else {
|
|
||||||
msg = "Error: " + worker->error_str;
|
|
||||||
error_str = QString("%1, %2").arg(worker->error_str).arg(QString(worker->response));
|
|
||||||
}
|
}
|
||||||
{{#returnType}}
|
{{#returnType}}
|
||||||
{{#isArray}}
|
{{#isArray}}
|
||||||
|
@ -43,9 +43,9 @@ public:
|
|||||||
void enableRequestCompression();
|
void enableRequestCompression();
|
||||||
void enableResponseCompression();
|
void enableResponseCompression();
|
||||||
void abortRequests();
|
void abortRequests();
|
||||||
QString getParamStylePrefix(QString style);
|
QString getParamStylePrefix(const QString &style);
|
||||||
QString getParamStyleSuffix(QString style);
|
QString getParamStyleSuffix(const QString &style);
|
||||||
QString getParamStyleDelimiter(QString style, QString name, bool isExplode);
|
QString getParamStyleDelimiter(const QString &style, const QString &name, bool isExplode);
|
||||||
{{#operations}}{{#operation}}
|
{{#operations}}{{#operation}}
|
||||||
{{#hasParams}} /**
|
{{#hasParams}} /**
|
||||||
{{#allParams}}
|
{{#allParams}}
|
||||||
@ -70,9 +70,9 @@ private:
|
|||||||
int _timeOut;
|
int _timeOut;
|
||||||
QString _workingDirectory;
|
QString _workingDirectory;
|
||||||
QNetworkAccessManager* _manager;
|
QNetworkAccessManager* _manager;
|
||||||
QMap<QString, QString> defaultHeaders;
|
QMap<QString, QString> _defaultHeaders;
|
||||||
bool isResponseCompressionEnabled;
|
bool _isResponseCompressionEnabled;
|
||||||
bool isRequestCompressionEnabled;
|
bool _isRequestCompressionEnabled;
|
||||||
{{#operations}}{{#operation}}
|
{{#operations}}{{#operation}}
|
||||||
void {{nickname}}Callback({{prefix}}HttpRequestWorker *worker);{{/operation}}{{/operations}}
|
void {{nickname}}Callback({{prefix}}HttpRequestWorker *worker);{{/operation}}{{/operations}}
|
||||||
|
|
||||||
|
@ -38,14 +38,14 @@ git add .
|
|||||||
git commit -m "$release_note"
|
git commit -m "$release_note"
|
||||||
|
|
||||||
# Sets the new remote
|
# Sets the new remote
|
||||||
git_remote=`git remote`
|
git_remote=$(git remote)
|
||||||
if [ "$git_remote" = "" ]; then # git remote not defined
|
if [ "$git_remote" = "" ]; then # git remote not defined
|
||||||
|
|
||||||
if [ "$GIT_TOKEN" = "" ]; then
|
if [ "$GIT_TOKEN" = "" ]; then
|
||||||
echo "[INFO] \$GIT_TOKEN (environment variable) is not set. Using the git credential in your environment."
|
echo "[INFO] \$GIT_TOKEN (environment variable) is not set. Using the git credential in your environment."
|
||||||
git remote add origin https://${git_host}/${git_user_id}/${git_repo_id}.git
|
git remote add origin https://${git_host}/${git_user_id}/${git_repo_id}.git
|
||||||
else
|
else
|
||||||
git remote add origin https://${git_user_id}:${GIT_TOKEN}@${git_host}/${git_user_id}/${git_repo_id}.git
|
git remote add origin https://${git_user_id}:"${GIT_TOKEN}"@${git_host}/${git_user_id}/${git_repo_id}.git
|
||||||
fi
|
fi
|
||||||
|
|
||||||
fi
|
fi
|
||||||
|
@ -264,7 +264,7 @@ bool ModelBase::fromJson( const web::json::value& val, int32_t & outVal )
|
|||||||
}
|
}
|
||||||
bool ModelBase::fromJson( const web::json::value& val, int64_t & outVal )
|
bool ModelBase::fromJson( const web::json::value& val, int64_t & outVal )
|
||||||
{
|
{
|
||||||
outVal = !val.is_null() ? std::numeric_limits<int64_t>::quiet_NaN() : val.as_number().to_int64();
|
outVal = !val.is_number() ? std::numeric_limits<int64_t>::quiet_NaN() : val.as_number().to_int64();
|
||||||
return val.is_number();
|
return val.is_number();
|
||||||
}
|
}
|
||||||
bool ModelBase::fromJson( const web::json::value& val, utility::string_t & outVal )
|
bool ModelBase::fromJson( const web::json::value& val, utility::string_t & outVal )
|
||||||
|
@ -38,14 +38,14 @@ git add .
|
|||||||
git commit -m "$release_note"
|
git commit -m "$release_note"
|
||||||
|
|
||||||
# Sets the new remote
|
# Sets the new remote
|
||||||
git_remote=`git remote`
|
git_remote=$(git remote)
|
||||||
if [ "$git_remote" = "" ]; then # git remote not defined
|
if [ "$git_remote" = "" ]; then # git remote not defined
|
||||||
|
|
||||||
if [ "$GIT_TOKEN" = "" ]; then
|
if [ "$GIT_TOKEN" = "" ]; then
|
||||||
echo "[INFO] \$GIT_TOKEN (environment variable) is not set. Using the git credential in your environment."
|
echo "[INFO] \$GIT_TOKEN (environment variable) is not set. Using the git credential in your environment."
|
||||||
git remote add origin https://${git_host}/${git_user_id}/${git_repo_id}.git
|
git remote add origin https://${git_host}/${git_user_id}/${git_repo_id}.git
|
||||||
else
|
else
|
||||||
git remote add origin https://${git_user_id}:${GIT_TOKEN}@${git_host}/${git_user_id}/${git_repo_id}.git
|
git remote add origin https://${git_user_id}:"${GIT_TOKEN}"@${git_host}/${git_user_id}/${git_repo_id}.git
|
||||||
fi
|
fi
|
||||||
|
|
||||||
fi
|
fi
|
||||||
|
@ -38,14 +38,14 @@ git add .
|
|||||||
git commit -m "$release_note"
|
git commit -m "$release_note"
|
||||||
|
|
||||||
# Sets the new remote
|
# Sets the new remote
|
||||||
git_remote=`git remote`
|
git_remote=$(git remote)
|
||||||
if [ "$git_remote" = "" ]; then # git remote not defined
|
if [ "$git_remote" = "" ]; then # git remote not defined
|
||||||
|
|
||||||
if [ "$GIT_TOKEN" = "" ]; then
|
if [ "$GIT_TOKEN" = "" ]; then
|
||||||
echo "[INFO] \$GIT_TOKEN (environment variable) is not set. Using the git credential in your environment."
|
echo "[INFO] \$GIT_TOKEN (environment variable) is not set. Using the git credential in your environment."
|
||||||
git remote add origin https://${git_host}/${git_user_id}/${git_repo_id}.git
|
git remote add origin https://${git_host}/${git_user_id}/${git_repo_id}.git
|
||||||
else
|
else
|
||||||
git remote add origin https://${git_user_id}:${GIT_TOKEN}@${git_host}/${git_user_id}/${git_repo_id}.git
|
git remote add origin https://${git_user_id}:"${GIT_TOKEN}"@${git_host}/${git_user_id}/${git_repo_id}.git
|
||||||
fi
|
fi
|
||||||
|
|
||||||
fi
|
fi
|
||||||
|
@ -38,14 +38,14 @@ git add .
|
|||||||
git commit -m "$release_note"
|
git commit -m "$release_note"
|
||||||
|
|
||||||
# Sets the new remote
|
# Sets the new remote
|
||||||
git_remote=`git remote`
|
git_remote=$(git remote)
|
||||||
if [ "$git_remote" = "" ]; then # git remote not defined
|
if [ "$git_remote" = "" ]; then # git remote not defined
|
||||||
|
|
||||||
if [ "$GIT_TOKEN" = "" ]; then
|
if [ "$GIT_TOKEN" = "" ]; then
|
||||||
echo "[INFO] \$GIT_TOKEN (environment variable) is not set. Using the git credential in your environment."
|
echo "[INFO] \$GIT_TOKEN (environment variable) is not set. Using the git credential in your environment."
|
||||||
git remote add origin https://${git_host}/${git_user_id}/${git_repo_id}.git
|
git remote add origin https://${git_host}/${git_user_id}/${git_repo_id}.git
|
||||||
else
|
else
|
||||||
git remote add origin https://${git_user_id}:${GIT_TOKEN}@${git_host}/${git_user_id}/${git_repo_id}.git
|
git remote add origin https://${git_user_id}:"${GIT_TOKEN}"@${git_host}/${git_user_id}/${git_repo_id}.git
|
||||||
fi
|
fi
|
||||||
|
|
||||||
fi
|
fi
|
||||||
|
@ -132,7 +132,10 @@
|
|||||||
{{^conditionalSerialization}}
|
{{^conditionalSerialization}}
|
||||||
{{^vendorExtensions.x-csharp-value-type}}
|
{{^vendorExtensions.x-csharp-value-type}}
|
||||||
// to ensure "{{#lambda.camelcase_param}}{{name}}{{/lambda.camelcase_param}}" is required (not null)
|
// to ensure "{{#lambda.camelcase_param}}{{name}}{{/lambda.camelcase_param}}" is required (not null)
|
||||||
this.{{name}} = {{#lambda.camelcase_param}}{{name}}{{/lambda.camelcase_param}} ?? throw new ArgumentNullException("{{#lambda.camelcase_param}}{{name}}{{/lambda.camelcase_param}} is a required property for {{classname}} and cannot be null");
|
if ({{#lambda.camelcase_param}}{{name}}{{/lambda.camelcase_param}} == null) {
|
||||||
|
throw new ArgumentNullException("{{#lambda.camelcase_param}}{{name}}{{/lambda.camelcase_param}} is a required property for {{classname}} and cannot be null");
|
||||||
|
}
|
||||||
|
this.{{name}} = {{#lambda.camelcase_param}}{{name}}{{/lambda.camelcase_param}};
|
||||||
{{/vendorExtensions.x-csharp-value-type}}
|
{{/vendorExtensions.x-csharp-value-type}}
|
||||||
{{#vendorExtensions.x-csharp-value-type}}
|
{{#vendorExtensions.x-csharp-value-type}}
|
||||||
this.{{name}} = {{#lambda.camelcase_param}}{{name}}{{/lambda.camelcase_param}};
|
this.{{name}} = {{#lambda.camelcase_param}}{{name}}{{/lambda.camelcase_param}};
|
||||||
@ -141,7 +144,10 @@
|
|||||||
{{#conditionalSerialization}}
|
{{#conditionalSerialization}}
|
||||||
{{^vendorExtensions.x-csharp-value-type}}
|
{{^vendorExtensions.x-csharp-value-type}}
|
||||||
// to ensure "{{#lambda.camelcase_param}}{{name}}{{/lambda.camelcase_param}}" is required (not null)
|
// to ensure "{{#lambda.camelcase_param}}{{name}}{{/lambda.camelcase_param}}" is required (not null)
|
||||||
this._{{name}} = {{#lambda.camelcase_param}}{{name}}{{/lambda.camelcase_param}} ?? throw new ArgumentNullException("{{#lambda.camelcase_param}}{{name}}{{/lambda.camelcase_param}} is a required property for {{classname}} and cannot be null");
|
if ({{#lambda.camelcase_param}}{{name}}{{/lambda.camelcase_param}} == null) {
|
||||||
|
throw new ArgumentNullException("{{#lambda.camelcase_param}}{{name}}{{/lambda.camelcase_param}} is a required property for {{classname}} and cannot be null");
|
||||||
|
}
|
||||||
|
this._{{name}} = {{#lambda.camelcase_param}}{{name}}{{/lambda.camelcase_param}};
|
||||||
{{/vendorExtensions.x-csharp-value-type}}
|
{{/vendorExtensions.x-csharp-value-type}}
|
||||||
{{#vendorExtensions.x-csharp-value-type}}
|
{{#vendorExtensions.x-csharp-value-type}}
|
||||||
this._{{name}} = {{#lambda.camelcase_param}}{{name}}{{/lambda.camelcase_param}};
|
this._{{name}} = {{#lambda.camelcase_param}}{{name}}{{/lambda.camelcase_param}};
|
||||||
@ -390,7 +396,7 @@
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="validationContext">Validation context</param>
|
/// <param name="validationContext">Validation context</param>
|
||||||
/// <returns>Validation Result</returns>
|
/// <returns>Validation Result</returns>
|
||||||
IEnumerable<System.ComponentModel.DataAnnotations.ValidationResult> IValidatableObject.Validate(ValidationContext validationContext)
|
public IEnumerable<System.ComponentModel.DataAnnotations.ValidationResult> Validate(ValidationContext validationContext)
|
||||||
{
|
{
|
||||||
return this.BaseValidate(validationContext);
|
return this.BaseValidate(validationContext);
|
||||||
}
|
}
|
||||||
@ -409,7 +415,7 @@
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="validationContext">Validation context</param>
|
/// <param name="validationContext">Validation context</param>
|
||||||
/// <returns>Validation Result</returns>
|
/// <returns>Validation Result</returns>
|
||||||
IEnumerable<System.ComponentModel.DataAnnotations.ValidationResult> IValidatableObject.Validate(ValidationContext validationContext)
|
public IEnumerable<System.ComponentModel.DataAnnotations.ValidationResult> Validate(ValidationContext validationContext)
|
||||||
{
|
{
|
||||||
{{/discriminator}}
|
{{/discriminator}}
|
||||||
{{#parent}}
|
{{#parent}}
|
||||||
|
@ -38,14 +38,14 @@ git add .
|
|||||||
git commit -m "$release_note"
|
git commit -m "$release_note"
|
||||||
|
|
||||||
# Sets the new remote
|
# Sets the new remote
|
||||||
git_remote=`git remote`
|
git_remote=$(git remote)
|
||||||
if [ "$git_remote" = "" ]; then # git remote not defined
|
if [ "$git_remote" = "" ]; then # git remote not defined
|
||||||
|
|
||||||
if [ "$GIT_TOKEN" = "" ]; then
|
if [ "$GIT_TOKEN" = "" ]; then
|
||||||
echo "[INFO] \$GIT_TOKEN (environment variable) is not set. Using the git credential in your environment."
|
echo "[INFO] \$GIT_TOKEN (environment variable) is not set. Using the git credential in your environment."
|
||||||
git remote add origin https://${git_host}/${git_user_id}/${git_repo_id}.git
|
git remote add origin https://${git_host}/${git_user_id}/${git_repo_id}.git
|
||||||
else
|
else
|
||||||
git remote add origin https://${git_user_id}:${GIT_TOKEN}@${git_host}/${git_user_id}/${git_repo_id}.git
|
git remote add origin https://${git_user_id}:"${GIT_TOKEN}"@${git_host}/${git_user_id}/${git_repo_id}.git
|
||||||
fi
|
fi
|
||||||
|
|
||||||
fi
|
fi
|
||||||
|
@ -38,14 +38,14 @@ git add .
|
|||||||
git commit -m "$release_note"
|
git commit -m "$release_note"
|
||||||
|
|
||||||
# Sets the new remote
|
# Sets the new remote
|
||||||
git_remote=`git remote`
|
git_remote=$(git remote)
|
||||||
if [ "$git_remote" = "" ]; then # git remote not defined
|
if [ "$git_remote" = "" ]; then # git remote not defined
|
||||||
|
|
||||||
if [ "$GIT_TOKEN" = "" ]; then
|
if [ "$GIT_TOKEN" = "" ]; then
|
||||||
echo "[INFO] \$GIT_TOKEN (environment variable) is not set. Using the git credential in your environment."
|
echo "[INFO] \$GIT_TOKEN (environment variable) is not set. Using the git credential in your environment."
|
||||||
git remote add origin https://${git_host}/${git_user_id}/${git_repo_id}.git
|
git remote add origin https://${git_host}/${git_user_id}/${git_repo_id}.git
|
||||||
else
|
else
|
||||||
git remote add origin https://${git_user_id}:${GIT_TOKEN}@${git_host}/${git_user_id}/${git_repo_id}.git
|
git remote add origin https://${git_user_id}:"${GIT_TOKEN}"@${git_host}/${git_user_id}/${git_repo_id}.git
|
||||||
fi
|
fi
|
||||||
|
|
||||||
fi
|
fi
|
||||||
|
@ -10,7 +10,7 @@ class OAuthInterceptor extends AuthInterceptor {
|
|||||||
RequestOptions options,
|
RequestOptions options,
|
||||||
RequestInterceptorHandler handler,
|
RequestInterceptorHandler handler,
|
||||||
) {
|
) {
|
||||||
final authInfo = getAuthInfo(options, (secure) => secure['type'] == 'oauth' && secure['type'] == 'oauth2');
|
final authInfo = getAuthInfo(options, (secure) => secure['type'] == 'oauth' || secure['type'] == 'oauth2');
|
||||||
for (final info in authInfo) {
|
for (final info in authInfo) {
|
||||||
final token = tokens[info['name']];
|
final token = tokens[info['name']];
|
||||||
if (token != null) {
|
if (token != null) {
|
||||||
|
@ -1,3 +0,0 @@
|
|||||||
analyzer:
|
|
||||||
strong-mode:
|
|
||||||
implicit-casts: true
|
|
@ -49,7 +49,7 @@ class {{{classname}}} {
|
|||||||
///
|
///
|
||||||
{{/-last}}
|
{{/-last}}
|
||||||
{{/allParams}}
|
{{/allParams}}
|
||||||
Future<Response> {{{nickname}}}WithHttpInfo({{#allParams}}{{#required}}{{{dataType}}} {{{paramName}}}{{^-last}}, {{/-last}}{{/required}}{{/allParams}}{{#hasOptionalParams}}{ {{#allParams}}{{^required}}{{{dataType}}} {{{paramName}}}{{^-last}}, {{/-last}}{{/required}}{{/allParams}} }{{/hasOptionalParams}}) async {
|
Future<Response> {{{nickname}}}WithHttpInfo({{#allParams}}{{#required}}{{{dataType}}} {{{paramName}}},{{^-last}} {{/-last}}{{/required}}{{/allParams}}{{#hasOptionalParams}}{ {{#allParams}}{{^required}}{{{dataType}}} {{{paramName}}},{{^-last}} {{/-last}}{{/required}}{{/allParams}} }{{/hasOptionalParams}}) async {
|
||||||
{{#hasParams}}
|
{{#hasParams}}
|
||||||
// Verify required params are set.
|
// Verify required params are set.
|
||||||
{{#allParams}}
|
{{#allParams}}
|
||||||
@ -61,9 +61,11 @@ class {{{classname}}} {
|
|||||||
{{/allParams}}
|
{{/allParams}}
|
||||||
|
|
||||||
{{/hasParams}}
|
{{/hasParams}}
|
||||||
|
// ignore: prefer_const_declarations
|
||||||
final path = r'{{{path}}}'{{#pathParams}}
|
final path = r'{{{path}}}'{{#pathParams}}
|
||||||
.replaceAll('{' + '{{{baseName}}}' + '}', {{{paramName}}}.toString()){{/pathParams}};
|
.replaceAll({{=<% %>=}}'{<% baseName %>}'<%={{ }}=%>, {{{paramName}}}{{^isString}}.toString(){{/isString}}){{/pathParams}};
|
||||||
|
|
||||||
|
// ignore: prefer_final_locals
|
||||||
Object postBody{{#bodyParam}} = {{{paramName}}}{{/bodyParam}};
|
Object postBody{{#bodyParam}} = {{{paramName}}}{{/bodyParam}};
|
||||||
|
|
||||||
final queryParams = <QueryParam>[];
|
final queryParams = <QueryParam>[];
|
||||||
@ -95,9 +97,8 @@ class {{{classname}}} {
|
|||||||
{{/headerParams}}
|
{{/headerParams}}
|
||||||
{{/hasHeaderParams}}
|
{{/hasHeaderParams}}
|
||||||
|
|
||||||
final contentTypes = <String>[{{#prioritizedContentTypes}}'{{{mediaType}}}'{{^-last}}, {{/-last}}{{/prioritizedContentTypes}}];
|
const authNames = <String>[{{#authMethods}}'{{{name}}}'{{^-last}}, {{/-last}}{{/authMethods}}];
|
||||||
final nullableContentType = contentTypes.isNotEmpty ? contentTypes[0] : null;
|
const contentTypes = <String>[{{#prioritizedContentTypes}}'{{{mediaType}}}'{{^-last}}, {{/-last}}{{/prioritizedContentTypes}}];
|
||||||
final authNames = <String>[{{#authMethods}}'{{{name}}}'{{^-last}}, {{/-last}}{{/authMethods}}];
|
|
||||||
|
|
||||||
{{#isMultipart}}
|
{{#isMultipart}}
|
||||||
bool hasFields = false;
|
bool hasFields = false;
|
||||||
@ -131,14 +132,14 @@ class {{{classname}}} {
|
|||||||
{{/formParams}}
|
{{/formParams}}
|
||||||
{{/isMultipart}}
|
{{/isMultipart}}
|
||||||
|
|
||||||
return await apiClient.invokeAPI(
|
return apiClient.invokeAPI(
|
||||||
path,
|
path,
|
||||||
'{{{httpMethod}}}',
|
'{{{httpMethod}}}',
|
||||||
queryParams,
|
queryParams,
|
||||||
postBody,
|
postBody,
|
||||||
headerParams,
|
headerParams,
|
||||||
formParams,
|
formParams,
|
||||||
nullableContentType,
|
contentTypes.isEmpty ? null : contentTypes[0],
|
||||||
authNames,
|
authNames,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -173,8 +174,8 @@ class {{{classname}}} {
|
|||||||
///
|
///
|
||||||
{{/-last}}
|
{{/-last}}
|
||||||
{{/allParams}}
|
{{/allParams}}
|
||||||
Future<{{{returnType}}}{{^returnType}}void{{/returnType}}> {{{nickname}}}({{#allParams}}{{#required}}{{{dataType}}} {{{paramName}}}{{^-last}}, {{/-last}}{{/required}}{{/allParams}}{{#hasOptionalParams}}{ {{#allParams}}{{^required}}{{{dataType}}} {{{paramName}}}{{^-last}}, {{/-last}}{{/required}}{{/allParams}} }{{/hasOptionalParams}}) async {
|
Future<{{{returnType}}}{{^returnType}}void{{/returnType}}> {{{nickname}}}({{#allParams}}{{#required}}{{{dataType}}} {{{paramName}}},{{^-last}} {{/-last}}{{/required}}{{/allParams}}{{#hasOptionalParams}}{ {{#allParams}}{{^required}}{{{dataType}}} {{{paramName}}},{{^-last}} {{/-last}}{{/required}}{{/allParams}} }{{/hasOptionalParams}}) async {
|
||||||
final response = await {{{nickname}}}WithHttpInfo({{#allParams}}{{#required}}{{{paramName}}}{{^-last}}, {{/-last}}{{/required}}{{/allParams}}{{#hasOptionalParams}} {{#allParams}}{{^required}}{{{paramName}}}: {{{paramName}}}{{^-last}}, {{/-last}}{{/required}}{{/allParams}} {{/hasOptionalParams}});
|
final response = await {{{nickname}}}WithHttpInfo({{#allParams}}{{#required}}{{{paramName}}},{{^-last}} {{/-last}}{{/required}}{{/allParams}}{{#hasOptionalParams}} {{#allParams}}{{^required}}{{{paramName}}}: {{{paramName}}},{{^-last}} {{/-last}}{{/required}}{{/allParams}} {{/hasOptionalParams}});
|
||||||
if (response.statusCode >= HttpStatus.badRequest) {
|
if (response.statusCode >= HttpStatus.badRequest) {
|
||||||
throw ApiException(response.statusCode, await _decodeBodyBytes(response));
|
throw ApiException(response.statusCode, await _decodeBodyBytes(response));
|
||||||
}
|
}
|
||||||
@ -185,7 +186,8 @@ class {{{classname}}} {
|
|||||||
if (response.body != null && response.statusCode != HttpStatus.noContent) {
|
if (response.body != null && response.statusCode != HttpStatus.noContent) {
|
||||||
{{#native_serialization}}
|
{{#native_serialization}}
|
||||||
{{#isArray}}
|
{{#isArray}}
|
||||||
return (await apiClient.deserializeAsync(await _decodeBodyBytes(response), '{{{returnType}}}') as List)
|
final responseBody = await _decodeBodyBytes(response);
|
||||||
|
return (await apiClient.deserializeAsync(responseBody, '{{{returnType}}}') as List)
|
||||||
.cast<{{{returnBaseType}}}>()
|
.cast<{{{returnBaseType}}}>()
|
||||||
.{{#uniqueItems}}toSet(){{/uniqueItems}}{{^uniqueItems}}toList(growable: false){{/uniqueItems}};
|
.{{#uniqueItems}}toSet(){{/uniqueItems}}{{^uniqueItems}}toList(growable: false){{/uniqueItems}};
|
||||||
{{/isArray}}
|
{{/isArray}}
|
||||||
@ -223,7 +225,7 @@ class {{{classname}}} {
|
|||||||
{{/isArray}}
|
{{/isArray}}
|
||||||
{{/json_serializable}}
|
{{/json_serializable}}
|
||||||
}
|
}
|
||||||
return Future<{{{returnType}}}>.value(null);
|
return Future<{{{returnType}}}>.value();
|
||||||
{{/returnType}}
|
{{/returnType}}
|
||||||
}
|
}
|
||||||
{{/operation}}
|
{{/operation}}
|
||||||
|
@ -84,7 +84,7 @@ class ApiClient {
|
|||||||
? '?${urlEncodedQueryParams.join('&')}'
|
? '?${urlEncodedQueryParams.join('&')}'
|
||||||
: '';
|
: '';
|
||||||
|
|
||||||
final Uri uri = Uri.parse('$basePath$path$queryString');
|
final uri = Uri.parse('$basePath$path$queryString');
|
||||||
|
|
||||||
if (nullableContentType != null) {
|
if (nullableContentType != null) {
|
||||||
headerParams['Content-Type'] = nullableContentType;
|
headerParams['Content-Type'] = nullableContentType;
|
||||||
@ -102,7 +102,8 @@ class ApiClient {
|
|||||||
body.finalize().listen(
|
body.finalize().listen(
|
||||||
request.sink.add,
|
request.sink.add,
|
||||||
onDone: request.sink.close,
|
onDone: request.sink.close,
|
||||||
onError: (error, trace) => request.sink.close(),
|
// ignore: avoid_types_on_closure_parameters
|
||||||
|
onError: (Object error, StackTrace trace) => request.sink.close(),
|
||||||
cancelOnError: true,
|
cancelOnError: true,
|
||||||
);
|
);
|
||||||
final response = await _client.send(request);
|
final response = await _client.send(request);
|
||||||
@ -191,18 +192,17 @@ class ApiClient {
|
|||||||
try {
|
try {
|
||||||
switch (targetType) {
|
switch (targetType) {
|
||||||
case 'String':
|
case 'String':
|
||||||
return '$value';
|
return value is String ? value : value.toString();
|
||||||
case 'int':
|
case 'int':
|
||||||
return value is int ? value : int.parse('$value');
|
return value is int ? value : int.parse('$value');
|
||||||
|
case 'double':
|
||||||
|
return value is double ? value : double.parse('$value');
|
||||||
case 'bool':
|
case 'bool':
|
||||||
if (value is bool) {
|
if (value is bool) {
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
final valueString = '$value'.toLowerCase();
|
final valueString = '$value'.toLowerCase();
|
||||||
return valueString == 'true' || valueString == '1';
|
return valueString == 'true' || valueString == '1';
|
||||||
break;
|
|
||||||
case 'double':
|
|
||||||
return value is double ? value : double.parse('$value');
|
|
||||||
{{#models}}
|
{{#models}}
|
||||||
{{#model}}
|
{{#model}}
|
||||||
case '{{{classname}}}':
|
case '{{{classname}}}':
|
||||||
@ -220,25 +220,24 @@ class ApiClient {
|
|||||||
if (value is List && (match = _regList.firstMatch(targetType)) != null) {
|
if (value is List && (match = _regList.firstMatch(targetType)) != null) {
|
||||||
targetType = match[1]; // ignore: parameter_assignments
|
targetType = match[1]; // ignore: parameter_assignments
|
||||||
return value
|
return value
|
||||||
.map((v) => _deserialize(v, targetType, growable: growable))
|
.map<dynamic>((dynamic v) => _deserialize(v, targetType, growable: growable))
|
||||||
.toList(growable: growable);
|
.toList(growable: growable);
|
||||||
}
|
}
|
||||||
if (value is Set && (match = _regSet.firstMatch(targetType)) != null) {
|
if (value is Set && (match = _regSet.firstMatch(targetType)) != null) {
|
||||||
targetType = match[1]; // ignore: parameter_assignments
|
targetType = match[1]; // ignore: parameter_assignments
|
||||||
return value
|
return value
|
||||||
.map((v) => _deserialize(v, targetType, growable: growable))
|
.map<dynamic>((dynamic v) => _deserialize(v, targetType, growable: growable))
|
||||||
.toSet();
|
.toSet();
|
||||||
}
|
}
|
||||||
if (value is Map && (match = _regMap.firstMatch(targetType)) != null) {
|
if (value is Map && (match = _regMap.firstMatch(targetType)) != null) {
|
||||||
targetType = match[1]; // ignore: parameter_assignments
|
targetType = match[1]; // ignore: parameter_assignments
|
||||||
return Map.fromIterables(
|
return Map<String, dynamic>.fromIterables(
|
||||||
value.keys,
|
value.keys.cast<String>(),
|
||||||
value.values.map((v) => _deserialize(v, targetType, growable: growable)),
|
value.values.map<dynamic>((dynamic v) => _deserialize(v, targetType, growable: growable)),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
} catch (error, trace) {
|
} on Exception catch (error, trace) {
|
||||||
throw ApiException.withInner(HttpStatus.internalServerError, 'Exception during deserialization.', error, trace,);
|
throw ApiException.withInner(HttpStatus.internalServerError, 'Exception during deserialization.', error, trace,);
|
||||||
}
|
}
|
||||||
throw ApiException(HttpStatus.internalServerError, 'Could not find a suitable class for deserialization',);
|
throw ApiException(HttpStatus.internalServerError, 'Could not find a suitable class for deserialization',);
|
||||||
|
@ -21,20 +21,21 @@ Iterable<QueryParam> _convertParametersForCollectionFormat(
|
|||||||
// preconditions
|
// preconditions
|
||||||
if (name != null && name.isNotEmpty && value != null) {
|
if (name != null && name.isNotEmpty && value != null) {
|
||||||
if (value is List) {
|
if (value is List) {
|
||||||
// get the collection format, default: csv
|
|
||||||
collectionFormat = (collectionFormat == null || collectionFormat.isEmpty)
|
|
||||||
? 'csv'
|
|
||||||
: collectionFormat;
|
|
||||||
|
|
||||||
if (collectionFormat == 'multi') {
|
if (collectionFormat == 'multi') {
|
||||||
return value.map((v) => QueryParam(name, parameterToString(v)));
|
return value.map((dynamic v) => QueryParam(name, parameterToString(v)),);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Default collection format is 'csv'.
|
||||||
|
if (collectionFormat == null || collectionFormat.isEmpty) {
|
||||||
|
// ignore: parameter_assignments
|
||||||
|
collectionFormat = 'csv';
|
||||||
}
|
}
|
||||||
|
|
||||||
final delimiter = _delimiters[collectionFormat] ?? ',';
|
final delimiter = _delimiters[collectionFormat] ?? ',';
|
||||||
|
|
||||||
params.add(QueryParam(name, value.map((v) => parameterToString(v)).join(delimiter)));
|
params.add(QueryParam(name, value.map<dynamic>(parameterToString).join(delimiter)),);
|
||||||
} else {
|
} else {
|
||||||
params.add(QueryParam(name, parameterToString(value)));
|
params.add(QueryParam(name, parameterToString(value),));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -69,3 +70,36 @@ Future<String> _decodeBodyBytes(Response response) async {
|
|||||||
? response.bodyBytes == null ? null : utf8.decode(response.bodyBytes)
|
? response.bodyBytes == null ? null : utf8.decode(response.bodyBytes)
|
||||||
: response.body;
|
: response.body;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Returns a valid [T] value found at the specified Map [key], null otherwise.
|
||||||
|
T mapValueOfType<T>(dynamic map, String key) {
|
||||||
|
final dynamic value = map is Map ? map[key] : null;
|
||||||
|
return value is T ? value : null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Returns a valid Map<K, V> found at the specified Map [key], null otherwise.
|
||||||
|
Map<K, V> mapCastOfType<K, V>(dynamic map, String key) {
|
||||||
|
final dynamic value = map is Map ? map[key] : null;
|
||||||
|
return value is Map ? value.cast<K, V>() : null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Returns a valid [DateTime] found at the specified Map [key], null otherwise.
|
||||||
|
DateTime mapDateTime(dynamic map, String key, [String pattern]) {
|
||||||
|
final dynamic value = map is Map ? map[key] : null;
|
||||||
|
if (value != null) {
|
||||||
|
int millis;
|
||||||
|
if (value is int) {
|
||||||
|
millis = value;
|
||||||
|
} else if (value is String) {
|
||||||
|
if (pattern == _dateEpochMarker) {
|
||||||
|
millis = int.tryParse(value);
|
||||||
|
} else {
|
||||||
|
return DateTime.tryParse(value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (millis != null) {
|
||||||
|
return DateTime.fromMillisecondsSinceEpoch(millis, isUtc: true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
@ -18,9 +18,11 @@ class ApiKeyAuth implements Authentication {
|
|||||||
} else if (location == 'header' && value != null) {
|
} else if (location == 'header' && value != null) {
|
||||||
headerParams[paramName] = value;
|
headerParams[paramName] = value;
|
||||||
} else if (location == 'cookie' && value != null) {
|
} else if (location == 'cookie' && value != null) {
|
||||||
headerParams.update('Cookie', (String existingCookie) {
|
headerParams.update(
|
||||||
return '$existingCookie; $paramName=$value';
|
'Cookie',
|
||||||
}, ifAbsent: () => '$paramName=$value');
|
(existingCookie) => '$existingCookie; $paramName=$value',
|
||||||
|
ifAbsent: () => '$paramName=$value',
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
{{>header}}
|
{{>header}}
|
||||||
{{>part_of}}
|
{{>part_of}}
|
||||||
|
// ignore: one_member_abstracts
|
||||||
abstract class Authentication {
|
abstract class Authentication {
|
||||||
/// Apply authentication settings to header and query params.
|
/// Apply authentication settings to header and query params.
|
||||||
void applyToParams(List<QueryParam> queryParams, Map<String, String> headerParams);
|
void applyToParams(List<QueryParam> queryParams, Map<String, String> headerParams);
|
||||||
|
@ -5,4 +5,5 @@
|
|||||||
|
|
||||||
// ignore_for_file: unused_element, unused_import
|
// ignore_for_file: unused_element, unused_import
|
||||||
// ignore_for_file: always_put_required_named_parameters_first
|
// ignore_for_file: always_put_required_named_parameters_first
|
||||||
|
// ignore_for_file: constant_identifier_names
|
||||||
// ignore_for_file: lines_longer_than_80_chars
|
// ignore_for_file: lines_longer_than_80_chars
|
||||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user