forked from loafle/openapi-generator-original
Compare commits
91 Commits
fix-enum-s
...
enable-has
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
fa3d863c8c | ||
|
|
c93fcd7514 | ||
|
|
b2293cc363 | ||
|
|
e12009907e | ||
|
|
6621f46d70 | ||
|
|
0494d27f73 | ||
|
|
472ff9c657 | ||
|
|
720f864b64 | ||
|
|
8a3994e000 | ||
|
|
4e59122264 | ||
|
|
f64a4d1a4f | ||
|
|
789b158cd4 | ||
|
|
0c173fb519 | ||
|
|
fdc0b5b0e2 | ||
|
|
adc3fef247 | ||
|
|
798ad2f87d | ||
|
|
fa75469828 | ||
|
|
86eb1b9112 | ||
|
|
1cb34be8fe | ||
|
|
321ad3c820 | ||
|
|
ee0686e13f | ||
|
|
2743242ef4 | ||
|
|
39c4a123b3 | ||
|
|
312082c168 | ||
|
|
08612d8e52 | ||
|
|
8d63f75966 | ||
|
|
9bfd9545cc | ||
|
|
dba14f5ac6 | ||
|
|
9592754e57 | ||
|
|
468d80be4b | ||
|
|
a00521f260 | ||
|
|
04c41d47a2 | ||
|
|
9139f91b48 | ||
|
|
5f8e28a39d | ||
|
|
276a983fe8 | ||
|
|
1897f6f96c | ||
|
|
83f64dbc15 | ||
|
|
8e150ab94e | ||
|
|
03e8aee8ea | ||
|
|
3199ddc615 | ||
|
|
d1fe2e17f1 | ||
|
|
1bfd86a350 | ||
|
|
90d8c32906 | ||
|
|
d6549f78b4 | ||
|
|
9899315aab | ||
|
|
6e21ca5930 | ||
|
|
763b8fbe3e | ||
|
|
e9c231b50a | ||
|
|
df2c927dcb | ||
|
|
454ceb45fa | ||
|
|
a59e506c9e | ||
|
|
3784f459e9 | ||
|
|
5e2306446f | ||
|
|
b1dcf65c5b | ||
|
|
2ab35e0386 | ||
|
|
6053f7b17b | ||
|
|
3305ac962a | ||
|
|
0a394bc883 | ||
|
|
95bd845f79 | ||
|
|
383b1e9db8 | ||
|
|
1cfa8141a8 | ||
|
|
0e0f8eb74c | ||
|
|
ed84280108 | ||
|
|
44d3f717f8 | ||
|
|
968f32b55e | ||
|
|
8a774f636b | ||
|
|
dd6e8ccc3d | ||
|
|
0707b4bb20 | ||
|
|
49f088ec8e | ||
|
|
da50523f3b | ||
|
|
d2161c8ad1 | ||
|
|
ffdd7000a4 | ||
|
|
8cd52033e4 | ||
|
|
9318833fa5 | ||
|
|
7cb8766a5c | ||
|
|
fce74884f8 | ||
|
|
a348f5a170 | ||
|
|
02a8207b91 | ||
|
|
cef1bec466 | ||
|
|
38368c9bda | ||
|
|
9d76ca291e | ||
|
|
b86a51ae17 | ||
|
|
5980c420e3 | ||
|
|
dad931a25a | ||
|
|
29183e0280 | ||
|
|
1044c30293 | ||
|
|
a7446983e8 | ||
|
|
53950f8aff | ||
|
|
6a49c4ec02 | ||
|
|
57bf9e85a1 | ||
|
|
47b4e16420 |
2
.github/PULL_REQUEST_TEMPLATE.md
vendored
2
.github/PULL_REQUEST_TEMPLATE.md
vendored
@@ -5,6 +5,6 @@
|
||||
|
||||
- [ ] Read the [contribution guidelines](https://github.com/openapitools/openapi-generator/blob/master/CONTRIBUTING.md).
|
||||
- [ ] If contributing template-only or documentation-only changes which will change sample output, [build the project](https://github.com/OpenAPITools/openapi-generator#14---build-projects) beforehand.
|
||||
- [ ] Run the shell script `./bin/generate-samples.sh`to update all Petstore samples related to your fix. This is important, as CI jobs will verify _all_ generator outputs of your HEAD commit as it would merge with master. These must match the expectations made by your contribution. You may regenerate an individual generator by passing the relevant config(s) as an argument to the script, for example `./bin/generate-samples.sh bin/config/java*`. For Windows users, please run the script in [Git BASH](https://gitforwindows.org/).
|
||||
- [ ] Run the shell script `./bin/generate-samples.sh`to update all Petstore samples related to your fix. This is important, as CI jobs will verify _all_ generator outputs of your HEAD commit as it would merge with master. These must match the expectations made by your contribution. You may regenerate an individual generator by passing the relevant config(s) as an argument to the script, for example `./bin/generate-samples.sh bin/configs/java*`. For Windows users, please run the script in [Git BASH](https://gitforwindows.org/).
|
||||
- [ ] File the PR against the [correct branch](https://github.com/OpenAPITools/openapi-generator/wiki/Git-Branches): `master`
|
||||
- [ ] Copy the [technical committee](https://github.com/openapitools/openapi-generator/#62---openapi-generator-technical-committee) to review the pull request if your PR is targeting a particular programming language.
|
||||
|
||||
1
.gitignore
vendored
1
.gitignore
vendored
@@ -177,6 +177,7 @@ samples/client/petstore/python-tornado/.venv/
|
||||
samples/client/petstore/typescript-angular2/npm/npm-debug.log
|
||||
samples/client/petstore/typescript-node/npm/npm-debug.log
|
||||
samples/client/petstore/typescript-angular/tsd-debug.log
|
||||
samples/client/petstore/typescript-axios/tests/**/dist/
|
||||
samples/client/petstore/typescript-fetch/tests/**/dist/
|
||||
|
||||
# aspnetcore
|
||||
|
||||
@@ -17,15 +17,11 @@ trap cleanup EXIT
|
||||
if [ "$NODE_INDEX" = "1" ]; then
|
||||
echo "Running node $NODE_INDEX to test 'samples.circleci' defined in pom.xml ..."
|
||||
java -version
|
||||
# Install golang version 1.14
|
||||
go version
|
||||
sudo mkdir /usr/local/go1.14
|
||||
wget -c https://dl.google.com/go/go1.14.linux-amd64.tar.gz -O - | sudo tar -xz -C /usr/local/go1.14
|
||||
export PATH="/usr/local/go1.14/go/bin:$PATH"
|
||||
go version
|
||||
|
||||
mvn --no-snapshot-updates --quiet verify -Psamples.circleci -Dorg.slf4j.simpleLogger.defaultLogLevel=error
|
||||
mvn --no-snapshot-updates --quiet javadoc:javadoc -Psamples.circleci -Dorg.slf4j.simpleLogger.defaultLogLevel=error
|
||||
|
||||
echo "show ivy2 cache"
|
||||
ls -l /home/circleci/.ivy2/cache
|
||||
|
||||
elif [ "$NODE_INDEX" = "2" ]; then
|
||||
# run ensure-up-to-date sample script on SNAPSHOT version only
|
||||
@@ -40,7 +36,6 @@ elif [ "$NODE_INDEX" = "2" ]; then
|
||||
# look for outdated samples
|
||||
./bin/utils/ensure-up-to-date
|
||||
fi
|
||||
#elif [ "$NODE_INDEX" = "3" ]; then
|
||||
echo "Running node $NODE_INDEX to test haskell"
|
||||
# install haskell
|
||||
curl -sSL https://get.haskellstack.org/ | sh
|
||||
@@ -60,10 +55,17 @@ elif [ "$NODE_INDEX" = "2" ]; then
|
||||
# run integration tests
|
||||
mvn --no-snapshot-updates --quiet verify -Psamples.misc -Dorg.slf4j.simpleLogger.defaultLogLevel=error
|
||||
else
|
||||
echo "Running node $NODE_INDEX to test 'samples.circleci.jdk7' defined in pom.xml ..."
|
||||
sudo update-java-alternatives -s java-1.7.0-openjdk-amd64
|
||||
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
|
||||
java -version
|
||||
|
||||
# Install golang version 1.14
|
||||
go version
|
||||
sudo mkdir /usr/local/go1.14
|
||||
wget -c https://dl.google.com/go/go1.14.linux-amd64.tar.gz -O - | sudo tar -xz -C /usr/local/go1.14
|
||||
export PATH="/usr/local/go1.14/go/bin:$PATH"
|
||||
go version
|
||||
|
||||
# install dart2
|
||||
sudo apt-get update
|
||||
sudo apt-get install apt-transport-https
|
||||
@@ -73,7 +75,8 @@ else
|
||||
sudo apt-get install dart
|
||||
export PATH="$PATH:/usr/lib/dart/bin"
|
||||
|
||||
mvn --no-snapshot-updates --quiet verify -Psamples.circleci.jdk7 -Dorg.slf4j.simpleLogger.defaultLogLevel=error
|
||||
mvn --no-snapshot-updates --quiet verify -Psamples.circleci.others -Dorg.slf4j.simpleLogger.defaultLogLevel=error
|
||||
mvn --no-snapshot-updates --quiet javadoc:javadoc -Psamples.circleci -Dorg.slf4j.simpleLogger.defaultLogLevel=error
|
||||
fi
|
||||
|
||||
|
||||
|
||||
@@ -110,7 +110,8 @@ See [OpenAPI Tools wiki](https://github.com/OpenAPITools/openapi-generator/wiki/
|
||||
- Add test case(s) to cover the change
|
||||
- Document the fix in the code to make the code more readable
|
||||
- Make sure test cases passed after the change (one way is to leverage https://travis-ci.org/ to run the CI tests)
|
||||
- File a PR with meaningful title, description and commit messages.
|
||||
- File a PR with meaningful title, description and commit messages
|
||||
- Make sure the option "Allow edits from maintainers" in the PR is selected so that the maintainers can update your PRs with minor fixes, if needed.
|
||||
- Recommended git settings
|
||||
- `git config core.autocrlf input` to tell Git convert CRLF to LF on commit but not the other way around
|
||||
- To close an issue (e.g. issue 1542) automatically after a PR is merged, use keywords "fix", "close", "resolve" in the PR description, e.g. `fix #1542`. (Ref: [closing issues using keywords](https://help.github.com/articles/closing-issues-using-keywords/))
|
||||
|
||||
10
README.md
10
README.md
@@ -578,6 +578,7 @@ Here are some companies/projects (alphabetical order) using OpenAPI Generator in
|
||||
- [Camptocamp](https://www.camptocamp.com/en)
|
||||
- [Cisco](https://www.cisco.com/)
|
||||
- [codecentric AG](https://www.codecentric.de/)
|
||||
- [CoinAPI](https://www.coinapi.io/)
|
||||
- [Commencis](https://www.commencis.com/)
|
||||
- [Crossover Health](https://crossoverhealth.com/)
|
||||
- [Cupix](https://www.cupix.com/)
|
||||
@@ -614,6 +615,8 @@ Here are some companies/projects (alphabetical order) using OpenAPI Generator in
|
||||
- [MoonVision](https://www.moonvision.io/)
|
||||
- [Myworkout](https://myworkout.com)
|
||||
- [NamSor](https://www.namsor.com/)
|
||||
- [Nokia](https://www.nokia.com/)
|
||||
- [Options Clearing Corporation (OCC)](https://www.theocc.com/)
|
||||
- [Openet](https://www.openet.com/)
|
||||
- [openVALIDATION](https://openvalidation.io/)
|
||||
- [Oracle](https://www.oracle.com/)
|
||||
@@ -756,7 +759,14 @@ Here are some companies/projects (alphabetical order) using OpenAPI Generator in
|
||||
- 2020-05-19 - [Dead Simple APIs with Open API](https://www.youtube.com/watch?v=sIaXmR6xRAw) by [Chris Tankersley](https://github.com/dragonmantank) at [Nexmo](https://developer.nexmo.com/)
|
||||
- 2020-05-22 - [TypeScript REST API Client](https://dev.to/unhurried/typescript-rest-api-client-4in3) by ["unhurried"](https://dev.to/unhurried)
|
||||
- 2020-05-28 - [【使用 lotify + Swagger 建置可共用的 LINE Notify bot】 - #NiJia @ Chatbot Developer Taiwan 第 #19 小聚](https://www.youtube.com/watch?v=agYVz6dzh1I) by [Chatbot Developer Taiwan](https://www.youtube.com/channel/UCxeYUyZNnHmpX23YNF-ewvw)
|
||||
- 2020-05-28 - [Building APIs with Laravel using OpenAPI](https://www.youtube.com/watch?v=xexLvQqAhiA) by [Chris Tankersley](https://github.com/dragonmantank) at [Laracon EU](https://laracon.eu/)
|
||||
- 2020-06-23 - [新規サーバーアプリケーションにTypeScriptを採用してみた](https://www.cam-inc.co.jp/news/20200623) at [CAM Tech Blog](https://www.cam-inc.co.jp/news/tech-blog/)
|
||||
- 2020-06-29 - [Artifact Abstract: Deployment of APIs on Android Mobile Devices and Microcontrollers](https://ieeexplore.ieee.org/document/9127353) by [Sergio Laso ; Marino Linaje ; Jose Garcia-Alonso ; Juan M. Murillo ; Javier Berrocal](https://ieeexplore.ieee.org/document/9127353/authors#authors) at [2020 IEEE International Conference on Pervasive Computing and Communications (PerCom)](https://ieeexplore.ieee.org/xpl/conhome/9125449/proceeding)
|
||||
- 2020-07-07 - [5 Best API Documentation Tools](https://blog.dreamfactory.com/5-best-api-documentation-tools/) by Susanna Bouse at [DreamFactory Blog](https://blog.dreamfactory.com/)
|
||||
- 2020-07-12 - [Open API 3.0の定義からgolangのサーバコードのスケルトンを作成する](https://qiita.com/professor/items/4cbd04ec084d13057bc2) by [@professor (Qiita Blog)](https://qiita.com/professor)
|
||||
- 2020-07-20 - [Datadog API client libraries now available for Java and Go](https://www.datadoghq.com/blog/java-go-libraries/) by Jordan Obey at [Datadog Blog](https://www.datadoghq.com/blog)
|
||||
- 2020-07-23 - [Generate Client SDK for .NET Core using Open Api](https://dev.to/no0law1/generate-client-sdk-for-net-core-using-open-api-2dgh) by [Nuno Reis](https://dev.to/no0law1)
|
||||
- 2020-07-26 - [Dartのhttp_interceptorライブラリを使うと配列のクエリパラメータが消えてしまう件の応急処置](https://qiita.com/gyamoto/items/eeeff81b6770487319ed) by [@gyamoto](https://qiita.com/gyamoto)
|
||||
|
||||
## [6 - About Us](#table-of-contents)
|
||||
|
||||
|
||||
@@ -5,3 +5,4 @@ templateDir: modules/openapi-generator/src/main/resources/go-experimental
|
||||
additionalProperties:
|
||||
enumClassPrefix: "true"
|
||||
packageName: petstore
|
||||
disallowAdditionalPropertiesIfNotPresent: false
|
||||
|
||||
15
bin/configs/java-jersey2-special-characters.yaml
Normal file
15
bin/configs/java-jersey2-special-characters.yaml
Normal file
@@ -0,0 +1,15 @@
|
||||
generatorName: java
|
||||
outputDir: samples/openapi3/client/petstore/java/jersey2-java8-special-characters
|
||||
library: jersey2
|
||||
inputSpec: modules/openapi-generator/src/test/resources/3_0/schema-with-special-characters.yaml
|
||||
templateDir: modules/openapi-generator/src/main/resources/Java
|
||||
additionalProperties:
|
||||
artifactId: petstore-openapi3-jersey2-java8-special-characters
|
||||
hideGenerationTimestamp: true
|
||||
serverPort: "8082"
|
||||
dateLibrary: java8
|
||||
useOneOfDiscriminatorLookup: true
|
||||
disallowAdditionalPropertiesIfNotPresent: false
|
||||
systemProperties:
|
||||
skipValidateSpec: "false"
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
generatorName: typescript-angular
|
||||
outputDir: samples/client/petstore/typescript-angular-v10-provided-in-root/builds/with-npm
|
||||
inputSpec: modules/openapi-generator/src/test/resources/2_0/petstore.yaml
|
||||
additionalProperties:
|
||||
ngVersion: 10.0.0
|
||||
npmVersion: 1.0.0
|
||||
npmName: '@openapitools/typescript-angular-petstore'
|
||||
npmRepository: https://skimdb.npmjs.com/registry
|
||||
snapshot: false
|
||||
5
bin/configs/typescript-angular-v10-provided-in-root.yaml
Normal file
5
bin/configs/typescript-angular-v10-provided-in-root.yaml
Normal file
@@ -0,0 +1,5 @@
|
||||
generatorName: typescript-angular
|
||||
outputDir: samples/client/petstore/typescript-angular-v10-provided-in-root/builds/default
|
||||
inputSpec: modules/openapi-generator/src/test/resources/2_0/petstore.yaml
|
||||
additionalProperties:
|
||||
ngVersion: 10.0.0
|
||||
@@ -0,0 +1,9 @@
|
||||
generatorName: typescript-angular
|
||||
outputDir: samples/client/petstore/typescript-angular-v9-provided-in-root/builds/with-npm
|
||||
inputSpec: modules/openapi-generator/src/test/resources/2_0/petstore.yaml
|
||||
additionalProperties:
|
||||
ngVersion: 9.0.0
|
||||
npmVersion: 1.0.0
|
||||
npmName: '@openapitools/typescript-angular-petstore'
|
||||
npmRepository: https://skimdb.npmjs.com/registry
|
||||
snapshot: false
|
||||
5
bin/configs/typescript-angular-v9-provided-in-root.yaml
Normal file
5
bin/configs/typescript-angular-v9-provided-in-root.yaml
Normal file
@@ -0,0 +1,5 @@
|
||||
generatorName: typescript-angular
|
||||
outputDir: samples/client/petstore/typescript-angular-v9-provided-in-root/builds/default
|
||||
inputSpec: modules/openapi-generator/src/test/resources/2_0/petstore.yaml
|
||||
additionalProperties:
|
||||
ngVersion: 9.0.0
|
||||
6
bin/configs/typescript-consolidated-deno.yaml
Normal file
6
bin/configs/typescript-consolidated-deno.yaml
Normal file
@@ -0,0 +1,6 @@
|
||||
generatorName: typescript
|
||||
outputDir: samples/openapi3/client/petstore/typescript/builds/deno
|
||||
inputSpec: modules/openapi-generator/src/test/resources/3_0/petstore.yaml
|
||||
additionalProperties:
|
||||
platform: deno
|
||||
npmName: ts-petstore-client
|
||||
7
bin/configs/typescript-consolidated-inversify.yaml
Normal file
7
bin/configs/typescript-consolidated-inversify.yaml
Normal file
@@ -0,0 +1,7 @@
|
||||
generatorName: typescript
|
||||
outputDir: samples/openapi3/client/petstore/typescript/builds/inversify
|
||||
inputSpec: modules/openapi-generator/src/test/resources/3_0/petstore.yaml
|
||||
additionalProperties:
|
||||
platform: node
|
||||
npmName: ts-petstore-client
|
||||
useInversify: true
|
||||
6
bin/configs/typescript-consolidated-jquery.yaml
Normal file
6
bin/configs/typescript-consolidated-jquery.yaml
Normal file
@@ -0,0 +1,6 @@
|
||||
generatorName: typescript
|
||||
outputDir: samples/openapi3/client/petstore/typescript/builds/jquery
|
||||
inputSpec: modules/openapi-generator/src/test/resources/3_0/petstore.yaml
|
||||
additionalProperties:
|
||||
framework: jquery
|
||||
npmName: ts-petstore-client
|
||||
@@ -0,0 +1,7 @@
|
||||
generatorName: typescript
|
||||
outputDir: samples/openapi3/client/petstore/typescript/builds/object_params
|
||||
inputSpec: modules/openapi-generator/src/test/resources/3_0/petstore.yaml
|
||||
additionalProperties:
|
||||
platform: node
|
||||
npmName: ts-petstore-client
|
||||
useObjectParameters: true
|
||||
6
bin/configs/typescript-consolidated-node.yaml
Normal file
6
bin/configs/typescript-consolidated-node.yaml
Normal file
@@ -0,0 +1,6 @@
|
||||
generatorName: typescript
|
||||
outputDir: samples/openapi3/client/petstore/typescript/builds/default
|
||||
inputSpec: modules/openapi-generator/src/test/resources/3_0/petstore.yaml
|
||||
additionalProperties:
|
||||
platform: node
|
||||
npmName: ts-petstore-client
|
||||
@@ -1,51 +0,0 @@
|
||||
#!/bin/sh
|
||||
|
||||
SCRIPT="$0"
|
||||
echo "# START SCRIPT: $SCRIPT"
|
||||
|
||||
while [ -h "$SCRIPT" ] ; do
|
||||
ls=`ls -ld "$SCRIPT"`
|
||||
link=`expr "$ls" : '.*-> \(.*\)$'`
|
||||
if expr "$link" : '/.*' > /dev/null; then
|
||||
SCRIPT="$link"
|
||||
else
|
||||
SCRIPT=`dirname "$SCRIPT"`/"$link"
|
||||
fi
|
||||
done
|
||||
|
||||
if [ ! -d "${APP_DIR}" ]; then
|
||||
APP_DIR=`dirname "$SCRIPT"`/..
|
||||
APP_DIR=`cd "${APP_DIR}"; pwd`
|
||||
fi
|
||||
|
||||
executable="./modules/openapi-generator-cli/target/openapi-generator-cli.jar"
|
||||
common_args="generate -i modules/openapi-generator/src/test/resources/3_0/petstore.yaml -g typescript"
|
||||
samples="samples/openapi3/client/petstore/typescript/builds"
|
||||
|
||||
if [ ! -f "$executable" ]
|
||||
then
|
||||
mvn -B clean package
|
||||
fi
|
||||
|
||||
# if you've executed sbt assembly previously it will use that instead.
|
||||
export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties"
|
||||
|
||||
printf "\033[32m## Creating default (fetch) client!\033[0m\n"
|
||||
args="-o $samples/default --additional-properties=platform=node,npmName=ts-petstore-client $@"
|
||||
java $JAVA_OPTS -jar $executable $common_args $args
|
||||
|
||||
printf "\033[32m## Creating jquery client!\033[0m\n"
|
||||
args="-o $samples/jquery --additional-properties=framework=jquery,npmName=ts-petstore-client $@"
|
||||
java $JAVA_OPTS -jar $executable $common_args $args
|
||||
|
||||
printf "\033[32m## Creating fetch object client!\033[0m\n"
|
||||
args="-o $samples/object_params --additional-properties=platform=node,npmName=ts-petstore-client,useObjectParameters=true $@"
|
||||
java $JAVA_OPTS -jar $executable $common_args $args
|
||||
|
||||
printf "\033[32m## Creating fetch client with InversifyJS support!\033[0m\n"
|
||||
args="-o $samples/inversify --additional-properties=platform=node,npmName=ts-petstore-client,useInversify=true $@"
|
||||
java $JAVA_OPTS -jar $executable $common_args $args
|
||||
|
||||
printf "\033[32m## Creating Deno (fetch) client!\033[0m\n"
|
||||
args="-o $samples/deno --additional-properties=platform=deno $@"
|
||||
java $JAVA_OPTS -jar $executable $common_args $args
|
||||
@@ -22,9 +22,9 @@ jobs:
|
||||
- restore_cache:
|
||||
keys:
|
||||
# Default branch if not
|
||||
- source-v1-{{ .Branch }}-{{ .Revision }}
|
||||
- source-v1-{{ .Branch }}-
|
||||
- source-v1-
|
||||
- source-v2-{{ .Branch }}-{{ .Revision }}
|
||||
- source-v2-{{ .Branch }}-
|
||||
- source-v2-
|
||||
# Machine Setup
|
||||
# If you break your build into multiple jobs with workflows, you will probably want to do the parts of this that are relevant in each
|
||||
# The following `checkout` command checks out your code to your working directory. In 1.0 we did this implicitly. In 2.0 you can choose where in the course of a job your code should be checked out.
|
||||
@@ -70,7 +70,7 @@ jobs:
|
||||
- run: ./CI/circle_parallel.sh
|
||||
# Save dependency cache
|
||||
- save_cache:
|
||||
key: source-v1-{{ .Branch }}-{{ .Revision }}
|
||||
key: source-v2-{{ .Branch }}-{{ .Revision }}
|
||||
paths:
|
||||
# This is a broad list of cache paths to include many possible development environments
|
||||
# You can probably delete some of these entries
|
||||
@@ -78,6 +78,7 @@ jobs:
|
||||
- ~/virtualenvs
|
||||
- ~/.m2
|
||||
- ~/.ivy2
|
||||
- ~/.sbt
|
||||
- ~/.bundle
|
||||
- ~/.go_workspace
|
||||
- ~/.gradle
|
||||
|
||||
@@ -114,7 +114,8 @@ See [OpenAPI Tools wiki](https://github.com/OpenAPITools/openapi-generator/wiki/
|
||||
- Add test case(s) to cover the change
|
||||
- Document the fix in the code to make the code more readable
|
||||
- Make sure test cases passed after the change (one way is to leverage https://travis-ci.org/ to run the CI tests)
|
||||
- File a PR with meaningful title, description and commit messages.
|
||||
- File a PR with meaningful title, description and commit messages
|
||||
- Make sure the option "Allow edits from maintainers" in the PR is selected so that the maintainers can update your PRs with minor fixes, if needed.
|
||||
- Recommended git settings
|
||||
- `git config core.autocrlf input` to tell Git convert CRLF to LF on commit but not the other way around
|
||||
- To close an issue (e.g. issue 1542) automatically after a PR is merged, use keywords "fix", "close", "resolve" in the PR description, e.g. `fix #1542`. (Ref: [closing issues using keywords](https://help.github.com/articles/closing-issues-using-keywords/))
|
||||
|
||||
@@ -5,6 +5,7 @@ sidebar_label: go-experimental
|
||||
|
||||
| Option | Description | Values | Default |
|
||||
| ------ | ----------- | ------ | ------- |
|
||||
|disallowAdditionalPropertiesIfNotPresent|Specify the behavior when the 'additionalProperties' keyword is not present in the OAS document. If false: the 'additionalProperties' implementation is compliant with the OAS and JSON schema specifications. If true: when the 'additionalProperties' keyword is not present in a schema, the value of 'additionalProperties' is set to false, i.e. no additional properties are allowed. Note: this mode is not compliant with the JSON schema specification. This is the original openapi-generator behavior.This setting is currently ignored for OAS 2.0 documents: 1) When the 'additionalProperties' keyword is not present in a 2.0 schema, additional properties are NOT allowed. 2) Boolean values of the 'additionalProperties' keyword are ignored. It's as if additional properties are NOT allowed.Note: the root cause are issues #1369 and #1371, which must be resolved in the swagger-parser project.|<dl><dt>**false**</dt><dd>The 'additionalProperties' implementation is compliant with the OAS and JSON schema specifications.</dd><dt>**true**</dt><dd>when the 'additionalProperties' keyword is not present in a schema, the value of 'additionalProperties' is automatically set to false, i.e. no additional properties are allowed. Note: this mode is not compliant with the JSON schema specification. This is the original openapi-generator behavior.</dd></dl>|true|
|
||||
|enumClassPrefix|Prefix enum with class name| |false|
|
||||
|hideGenerationTimestamp|Hides the generation timestamp when files are generated.| |true|
|
||||
|isGoSubmodule|whether the generated Go module is a submodule| |false|
|
||||
|
||||
@@ -31,7 +31,7 @@ sidebar_label: java
|
||||
|invokerPackage|root package for generated code| |org.openapitools.client|
|
||||
|java8|Use Java8 classes instead of third party equivalents. Starting in 5.x, JDK8 is the default and the support for JDK7, JDK6 has been dropped|<dl><dt>**true**</dt><dd>Use Java 8 classes such as Base64</dd><dt>**false**</dt><dd>Various third party libraries as needed</dd></dl>|true|
|
||||
|legacyDiscriminatorBehavior|This flag is used by OpenAPITools codegen to influence the processing of the discriminator attribute in OpenAPI documents. This flag has no impact if the OAS document does not use the discriminator attribute. The default value of this flag is set in each language-specific code generator (e.g. Python, Java, go...)using the method toModelName. Note to developers supporting a language generator in OpenAPITools; to fully support the discriminator attribute as defined in the OAS specification 3.x, language generators should set this flag to true by default; however this requires updating the mustache templates to generate a language-specific discriminator lookup function that iterates over {{#mappedModels}} and does not iterate over {{children}}, {{#anyOf}}, or {{#oneOf}}.|<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|
|
||||
|library|library template (sub-template) to use|<dl><dt>**jersey1**</dt><dd>HTTP client: Jersey client 1.19.x. JSON processing: Jackson 2.9.x. Enable Java6 support using '-DsupportJava6=true'. Enable gzip request encoding using '-DuseGzipFeature=true'. IMPORTANT NOTE: jersey 1.x is no longer actively maintained so please upgrade to 'jersey2' or other HTTP libaries instead.</dd><dt>**jersey2**</dt><dd>HTTP client: Jersey client 2.25.1. JSON processing: Jackson 2.9.x</dd><dt>**feign**</dt><dd>HTTP client: OpenFeign 11.x. JSON processing: Jackson 2.9.x.</dd><dt>**okhttp-gson**</dt><dd>[DEFAULT] HTTP client: OkHttp 3.x. JSON processing: Gson 2.8.x. Enable Parcelable models on Android using '-DparcelableModel=true'. Enable gzip request encoding using '-DuseGzipFeature=true'.</dd><dt>**retrofit2**</dt><dd>HTTP client: OkHttp 3.x. JSON processing: Gson 2.x (Retrofit 2.3.0). Enable the RxJava adapter using '-DuseRxJava[2/3]=true'. (RxJava 1.x or 2.x or 3.x)</dd><dt>**resttemplate**</dt><dd>HTTP client: Spring RestTemplate 4.x. JSON processing: Jackson 2.9.x</dd><dt>**webclient**</dt><dd>HTTP client: Spring WebClient 5.x. JSON processing: Jackson 2.9.x</dd><dt>**resteasy**</dt><dd>HTTP client: Resteasy client 3.x. JSON processing: Jackson 2.9.x</dd><dt>**vertx**</dt><dd>HTTP client: VertX client 3.x. JSON processing: Jackson 2.9.x</dd><dt>**google-api-client**</dt><dd>HTTP client: Google API client 1.x. JSON processing: Jackson 2.9.x</dd><dt>**rest-assured**</dt><dd>HTTP client: rest-assured : 4.x. JSON processing: Gson 2.x or Jackson 2.10.x. Only for Java 8</dd><dt>**native**</dt><dd>HTTP client: Java native HttpClient. JSON processing: Jackson 2.9.x. Only for Java11+</dd><dt>**microprofile**</dt><dd>HTTP client: Microprofile client 1.x. JSON processing: Jackson 2.9.x</dd></dl>|okhttp-gson|
|
||||
|library|library template (sub-template) to use|<dl><dt>**jersey1**</dt><dd>HTTP client: Jersey client 1.19.x. JSON processing: Jackson 2.9.x. Enable Java6 support using '-DsupportJava6=true'. Enable gzip request encoding using '-DuseGzipFeature=true'. IMPORTANT NOTE: jersey 1.x is no longer actively maintained so please upgrade to 'jersey2' or other HTTP libaries instead.</dd><dt>**jersey2**</dt><dd>HTTP client: Jersey client 2.25.1. JSON processing: Jackson 2.9.x</dd><dt>**feign**</dt><dd>HTTP client: OpenFeign 10.x. JSON processing: Jackson 2.9.x.</dd><dt>**okhttp-gson**</dt><dd>[DEFAULT] HTTP client: OkHttp 3.x. JSON processing: Gson 2.8.x. Enable Parcelable models on Android using '-DparcelableModel=true'. Enable gzip request encoding using '-DuseGzipFeature=true'.</dd><dt>**retrofit2**</dt><dd>HTTP client: OkHttp 3.x. JSON processing: Gson 2.x (Retrofit 2.3.0). Enable the RxJava adapter using '-DuseRxJava[2/3]=true'. (RxJava 1.x or 2.x or 3.x)</dd><dt>**resttemplate**</dt><dd>HTTP client: Spring RestTemplate 4.x. JSON processing: Jackson 2.9.x</dd><dt>**webclient**</dt><dd>HTTP client: Spring WebClient 5.x. JSON processing: Jackson 2.9.x</dd><dt>**resteasy**</dt><dd>HTTP client: Resteasy client 3.x. JSON processing: Jackson 2.9.x</dd><dt>**vertx**</dt><dd>HTTP client: VertX client 3.x. JSON processing: Jackson 2.9.x</dd><dt>**google-api-client**</dt><dd>HTTP client: Google API client 1.x. JSON processing: Jackson 2.9.x</dd><dt>**rest-assured**</dt><dd>HTTP client: rest-assured : 4.x. JSON processing: Gson 2.x or Jackson 2.10.x. Only for Java 8</dd><dt>**native**</dt><dd>HTTP client: Java native HttpClient. JSON processing: Jackson 2.9.x. Only for Java11+</dd><dt>**microprofile**</dt><dd>HTTP client: Microprofile client 1.x. JSON processing: Jackson 2.9.x</dd></dl>|okhttp-gson|
|
||||
|licenseName|The name of the license| |Unlicense|
|
||||
|licenseUrl|The URL of the license| |http://unlicense.org|
|
||||
|modelPackage|package for generated models| |org.openapitools.client.model|
|
||||
@@ -52,6 +52,7 @@ sidebar_label: java
|
||||
|sortParamsByRequiredFlag|Sort method arguments to place required parameters before optional parameters.| |true|
|
||||
|sourceFolder|source folder for generated code| |src/main/java|
|
||||
|supportJava6|Whether to support Java6 with the Jersey1 library. This option has been deprecated and will be removed in the 5.x release| |false|
|
||||
|useAbstractionForFiles|Use alternative types instead of java.io.File to allow passing bytes without a file on disk. Available on resttemplate library| |false|
|
||||
|useBeanValidation|Use BeanValidation API annotations| |false|
|
||||
|useGzipFeature|Send gzip-encoded requests| |false|
|
||||
|usePlayWS|Use Play! Async HTTP client (Play WS API)| |false|
|
||||
|
||||
@@ -7,6 +7,7 @@ sidebar_label: powershell
|
||||
| ------ | ----------- | ------ | ------- |
|
||||
|apiNamePrefix|Prefix that will be appended to all PS objects. Default: empty string. e.g. Pet => PSPet.| |null|
|
||||
|commonVerbs|PS common verb mappings. e.g. Delete=Remove:Patch=Update to map Delete with Remove and Patch with Update accordingly.| |null|
|
||||
|disallowAdditionalPropertiesIfNotPresent|Specify the behavior when the 'additionalProperties' keyword is not present in the OAS document. If false: the 'additionalProperties' implementation is compliant with the OAS and JSON schema specifications. If true: when the 'additionalProperties' keyword is not present in a schema, the value of 'additionalProperties' is set to false, i.e. no additional properties are allowed. Note: this mode is not compliant with the JSON schema specification. This is the original openapi-generator behavior.This setting is currently ignored for OAS 2.0 documents: 1) When the 'additionalProperties' keyword is not present in a 2.0 schema, additional properties are NOT allowed. 2) Boolean values of the 'additionalProperties' keyword are ignored. It's as if additional properties are NOT allowed.Note: the root cause are issues #1369 and #1371, which must be resolved in the swagger-parser project.|<dl><dt>**false**</dt><dd>The 'additionalProperties' implementation is compliant with the OAS and JSON schema specifications.</dd><dt>**true**</dt><dd>when the 'additionalProperties' keyword is not present in a schema, the value of 'additionalProperties' is automatically set to false, i.e. no additional properties are allowed. Note: this mode is not compliant with the JSON schema specification. This is the original openapi-generator behavior.</dd></dl>|true|
|
||||
|discardReadOnly|Set discardReadonly to true to generate the Initialize cmdlet without readonly parameters| |null|
|
||||
|packageGuid|GUID for PowerShell module (e.g. a27b908d-2a20-467f-bc32-af6f3a654ac5). A random GUID will be generated by default.| |null|
|
||||
|packageName|Client package name (e.g. PSTwitter).| |PSOpenAPITools|
|
||||
|
||||
@@ -16,7 +16,7 @@ sidebar_label: typescript-angular
|
||||
|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|
|
||||
|modelSuffix|The suffix of the generated model.| |null|
|
||||
|ngVersion|The version of Angular. (At least 6.0.0)| |9.0.0|
|
||||
|ngVersion|The version of Angular. (At least 6.0.0)| |10.0.0|
|
||||
|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|
|
||||
|npmVersion|The version of your npm package. If not provided, using the version from the OpenAPI specification file.| |1.0.0|
|
||||
@@ -64,6 +64,7 @@ sidebar_label: typescript-angular
|
||||
<li>Map</li>
|
||||
<li>Object</li>
|
||||
<li>ReadonlyArray</li>
|
||||
<li>Set</li>
|
||||
<li>String</li>
|
||||
<li>any</li>
|
||||
<li>boolean</li>
|
||||
|
||||
@@ -46,6 +46,7 @@ sidebar_label: typescript-angularjs-deprecated
|
||||
<li>Map</li>
|
||||
<li>Object</li>
|
||||
<li>ReadonlyArray</li>
|
||||
<li>Set</li>
|
||||
<li>String</li>
|
||||
<li>any</li>
|
||||
<li>boolean</li>
|
||||
|
||||
@@ -47,6 +47,7 @@ sidebar_label: typescript-angularjs
|
||||
<li>Object</li>
|
||||
<li>ReadonlyArray</li>
|
||||
<li>String</li>
|
||||
<li>Set</li>
|
||||
<li>any</li>
|
||||
<li>boolean</li>
|
||||
<li>number</li>
|
||||
|
||||
@@ -49,6 +49,7 @@ sidebar_label: typescript-aurelia
|
||||
<li>Map</li>
|
||||
<li>Object</li>
|
||||
<li>ReadonlyArray</li>
|
||||
<li>Set</li>
|
||||
<li>String</li>
|
||||
<li>any</li>
|
||||
<li>boolean</li>
|
||||
|
||||
@@ -54,6 +54,7 @@ sidebar_label: typescript-axios
|
||||
<li>Map</li>
|
||||
<li>Object</li>
|
||||
<li>ReadonlyArray</li>
|
||||
<li>Set</li>
|
||||
<li>String</li>
|
||||
<li>any</li>
|
||||
<li>boolean</li>
|
||||
|
||||
@@ -54,6 +54,7 @@ sidebar_label: typescript-fetch
|
||||
<li>Map</li>
|
||||
<li>Object</li>
|
||||
<li>ReadonlyArray</li>
|
||||
<li>Set</li>
|
||||
<li>String</li>
|
||||
<li>any</li>
|
||||
<li>boolean</li>
|
||||
|
||||
@@ -55,6 +55,7 @@ sidebar_label: typescript-inversify
|
||||
<li>Map</li>
|
||||
<li>Object</li>
|
||||
<li>ReadonlyArray</li>
|
||||
<li>Set</li>
|
||||
<li>String</li>
|
||||
<li>any</li>
|
||||
<li>boolean</li>
|
||||
|
||||
@@ -51,6 +51,7 @@ sidebar_label: typescript-jquery
|
||||
<li>Map</li>
|
||||
<li>Object</li>
|
||||
<li>ReadonlyArray</li>
|
||||
<li>Set</li>
|
||||
<li>String</li>
|
||||
<li>any</li>
|
||||
<li>boolean</li>
|
||||
|
||||
@@ -54,6 +54,7 @@ sidebar_label: typescript-node
|
||||
<li>ReadonlyArray</li>
|
||||
<li>RequestDetailedFile</li>
|
||||
<li>RequestFile</li>
|
||||
<li>Set</li>
|
||||
<li>String</li>
|
||||
<li>any</li>
|
||||
<li>boolean</li>
|
||||
|
||||
@@ -52,6 +52,7 @@ sidebar_label: typescript-redux-query
|
||||
<li>Map</li>
|
||||
<li>Object</li>
|
||||
<li>ReadonlyArray</li>
|
||||
<li>Set</li>
|
||||
<li>String</li>
|
||||
<li>any</li>
|
||||
<li>boolean</li>
|
||||
|
||||
@@ -52,6 +52,7 @@ sidebar_label: typescript-rxjs
|
||||
<li>Map</li>
|
||||
<li>Object</li>
|
||||
<li>ReadonlyArray</li>
|
||||
<li>Set</li>
|
||||
<li>String</li>
|
||||
<li>any</li>
|
||||
<li>boolean</li>
|
||||
|
||||
@@ -27,6 +27,10 @@ Please refer to https://github.com/upstart-commerce/sbt-openapi-generator
|
||||
|
||||
Please refer to https://github.com/OpenAPITools/openapi-generator-bazel
|
||||
|
||||
### Cake Addin
|
||||
|
||||
3rd-party Cake Addin provided by [Lukas Körfer](https://github.com/lukoerfer): https://github.com/lukoerfer/cake-openapi-generator
|
||||
|
||||
### GitHub Integration
|
||||
|
||||
To push the auto-generated SDK to GitHub, we provide `git_push.sh` to streamline the process. For example:
|
||||
|
||||
@@ -185,7 +185,7 @@
|
||||
<properties>
|
||||
<swagger-annotations-version>1.5.8</swagger-annotations-version>
|
||||
<jersey-version>2.27</jersey-version>
|
||||
<jackson-version>2.8.9</jackson-version>
|
||||
<jackson-version>2.9.10</jackson-version>
|
||||
<jackson-databind-nullable-version>0.2.0</jackson-databind-nullable-version>
|
||||
<jodatime-version>2.7</jodatime-version>
|
||||
<maven-plugin-version>1.0.0</maven-plugin-version>
|
||||
|
||||
@@ -224,7 +224,7 @@
|
||||
<properties>
|
||||
<swagger-annotations-version>1.5.8</swagger-annotations-version>
|
||||
<jersey-version>2.27</jersey-version>
|
||||
<jackson-version>2.8.9</jackson-version>
|
||||
<jackson-version>2.9.10</jackson-version>
|
||||
<jackson-databind-nullable-version>0.2.0</jackson-databind-nullable-version>
|
||||
<jodatime-version>2.7</jodatime-version>
|
||||
<maven-plugin-version>1.0.0</maven-plugin-version>
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
<properties>
|
||||
<swagger-annotations-version>1.5.8</swagger-annotations-version>
|
||||
<jersey-version>2.27</jersey-version>
|
||||
<jackson-version>2.8.9</jackson-version>
|
||||
<jackson-version>2.9.10</jackson-version>
|
||||
<jackson-databind-nullable-version>0.2.0</jackson-databind-nullable-version>
|
||||
<jodatime-version>2.7</jodatime-version>
|
||||
<maven-plugin-version>1.0.0</maven-plugin-version>
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
<groupId>org.openapitools</groupId>
|
||||
<artifactId>openapi-generator-maven-plugin</artifactId>
|
||||
<!-- RELEASE_VERSION -->
|
||||
<version>4.3.1-SNAPSHOT</version>
|
||||
<version>5.0.0-SNAPSHOT</version>
|
||||
<!-- /RELEASE_VERSION -->
|
||||
<executions>
|
||||
<execution>
|
||||
|
||||
@@ -49,9 +49,11 @@ public class CodegenModel implements IJsonSchemaValidationProperties {
|
||||
public Set<String> oneOf = new TreeSet<String>();
|
||||
public Set<String> allOf = new TreeSet<String>();
|
||||
|
||||
// The schema name as written in the OpenAPI document.
|
||||
public String name;
|
||||
// The language-specific name of the class that implements this schema.
|
||||
// The name of the class is derived from the OpenAPI schema name with formatting rules applied.
|
||||
// The classname is derived from the OpenAPI schema name, with sanitization and escaping rules applied.
|
||||
public String classname;
|
||||
// The value of the 'title' attribute in the OpenAPI document.
|
||||
public String title;
|
||||
@@ -220,6 +222,17 @@ public class CodegenModel implements IJsonSchemaValidationProperties {
|
||||
this.classVarName = classVarName;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return true if the classname property is sanitized, false if it is the same as the OpenAPI schema name.
|
||||
* The OpenAPI schema name may be any valid JSON schema name, including non-ASCII characters.
|
||||
* The name of the class may have to be sanitized with character escaping.
|
||||
*
|
||||
* @return true if the classname property is sanitized
|
||||
*/
|
||||
public boolean getIsClassnameSanitized() {
|
||||
return !classname.equals(name);
|
||||
}
|
||||
|
||||
public String getClassname() {
|
||||
return classname;
|
||||
}
|
||||
|
||||
@@ -1768,7 +1768,7 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
if (encoding != null) {
|
||||
codegenParameter.contentType = encoding.getContentType();
|
||||
} else {
|
||||
LOGGER.debug("encoding not specified for " + codegenParameter.baseName);
|
||||
LOGGER.debug("encoding not specified for {}", codegenParameter.baseName);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1790,6 +1790,9 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
/**
|
||||
* Return the default value of the property
|
||||
*
|
||||
* Return null if you do NOT want a default value.
|
||||
* Any non-null value will cause {{#defaultValue} check to pass.
|
||||
*
|
||||
* @param schema Property schema
|
||||
* @return string presentation of the default value of the property
|
||||
*/
|
||||
@@ -1810,7 +1813,7 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
*/
|
||||
@SuppressWarnings("squid:S3923")
|
||||
private String getPropertyDefaultValue(Schema schema) {
|
||||
/**
|
||||
/*
|
||||
* Although all branches return null, this is left intentionally as examples for new contributors
|
||||
*/
|
||||
if (ModelUtils.isBooleanSchema(schema)) {
|
||||
@@ -1960,10 +1963,10 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
/**
|
||||
* Return a string representation of the schema type, resolving aliasing and references if necessary.
|
||||
*
|
||||
* @param schema
|
||||
* @param schema input
|
||||
* @return the string representation of the schema type.
|
||||
*/
|
||||
private String getSingleSchemaType(Schema schema) {
|
||||
protected String getSingleSchemaType(Schema schema) {
|
||||
Schema unaliasSchema = ModelUtils.unaliasSchema(this.openAPI, schema, importMapping);
|
||||
|
||||
if (StringUtils.isNotBlank(unaliasSchema.get$ref())) { // reference to another definition/schema
|
||||
@@ -2514,7 +2517,11 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
|
||||
// process 'additionalProperties'
|
||||
if (schema.getAdditionalProperties() == null) {
|
||||
m.isAdditionalPropertiesTrue = false; // TODO fix the old (incorrect) behaviour (likely with an option)
|
||||
if (disallowAdditionalPropertiesIfNotPresent) {
|
||||
m.isAdditionalPropertiesTrue = false;
|
||||
} else {
|
||||
m.isAdditionalPropertiesTrue = true;
|
||||
}
|
||||
} else if (schema.getAdditionalProperties() instanceof Boolean) {
|
||||
if (Boolean.TRUE.equals(schema.getAdditionalProperties())) {
|
||||
m.isAdditionalPropertiesTrue = true;
|
||||
@@ -5902,7 +5909,7 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
|
||||
if (ModelUtils.isMapSchema(schema)) {
|
||||
// Schema with additionalproperties: true (including composed schemas with additionalproperties: true)
|
||||
if (ModelUtils.isGenerateAliasAsModel() && StringUtils.isNotBlank(name)) {
|
||||
if (ModelUtils.isGenerateAliasAsModel(schema) && StringUtils.isNotBlank(name)) {
|
||||
this.addBodyModelSchema(codegenParameter, name, schema, imports, bodyParameterName, true);
|
||||
} else {
|
||||
Schema inner = getAdditionalProperties(schema);
|
||||
@@ -5943,7 +5950,7 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
setParameterNullable(codegenParameter, codegenProperty);
|
||||
}
|
||||
} else if (ModelUtils.isArraySchema(schema)) {
|
||||
if (ModelUtils.isGenerateAliasAsModel() && StringUtils.isNotBlank(name)) {
|
||||
if (ModelUtils.isGenerateAliasAsModel(schema) && StringUtils.isNotBlank(name)) {
|
||||
this.addBodyModelSchema(codegenParameter, name, schema, imports, bodyParameterName, true);
|
||||
} else {
|
||||
final ArraySchema arraySchema = (ArraySchema) schema;
|
||||
|
||||
@@ -452,13 +452,13 @@ public class DefaultGenerator implements Generator {
|
||||
// A composed schema (allOf, oneOf, anyOf) is considered a Map schema if the additionalproperties attribute is set
|
||||
// for that composed schema. However, in the case of a composed schema, the properties are defined or referenced
|
||||
// in the inner schemas, and the outer schema does not have properties.
|
||||
if (!ModelUtils.isGenerateAliasAsModel() && !ModelUtils.isComposedSchema(schema) && (schema.getProperties() == null || schema.getProperties().isEmpty())) {
|
||||
if (!ModelUtils.isGenerateAliasAsModel(schema) && !ModelUtils.isComposedSchema(schema) && (schema.getProperties() == null || schema.getProperties().isEmpty())) {
|
||||
// schema without property, i.e. alias to map
|
||||
LOGGER.info("Model {} not generated since it's an alias to map (without property) and `generateAliasAsModel` is set to false (default)", name);
|
||||
continue;
|
||||
}
|
||||
} else if (ModelUtils.isArraySchema(schema)) { // check to see if it's an "array" model
|
||||
if (!ModelUtils.isGenerateAliasAsModel() && (schema.getProperties() == null || schema.getProperties().isEmpty())) {
|
||||
if (!ModelUtils.isGenerateAliasAsModel(schema) && (schema.getProperties() == null || schema.getProperties().isEmpty())) {
|
||||
// schema without property, i.e. alias to array
|
||||
LOGGER.info("Model {} not generated since it's an alias to array (without property) and `generateAliasAsModel` is set to false (default)", name);
|
||||
continue;
|
||||
|
||||
@@ -469,6 +469,7 @@ public abstract class AbstractJavaCodegen extends DefaultCodegen implements Code
|
||||
importMapping.put("JsonProperty", "com.fasterxml.jackson.annotation.JsonProperty");
|
||||
importMapping.put("JsonSubTypes", "com.fasterxml.jackson.annotation.JsonSubTypes");
|
||||
importMapping.put("JsonTypeInfo", "com.fasterxml.jackson.annotation.JsonTypeInfo");
|
||||
importMapping.put("JsonTypeName", "com.fasterxml.jackson.annotation.JsonTypeName");
|
||||
importMapping.put("JsonCreator", "com.fasterxml.jackson.annotation.JsonCreator");
|
||||
importMapping.put("JsonValue", "com.fasterxml.jackson.annotation.JsonValue");
|
||||
importMapping.put("JsonIgnore", "com.fasterxml.jackson.annotation.JsonIgnore");
|
||||
|
||||
@@ -43,8 +43,8 @@ import java.util.*;
|
||||
import static org.openapitools.codegen.utils.StringUtils.camelize;
|
||||
import static org.openapitools.codegen.utils.StringUtils.underscore;
|
||||
|
||||
public class PythonAbstractConnexionServerCodegen extends DefaultCodegen implements CodegenConfig {
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(PythonAbstractConnexionServerCodegen.class);
|
||||
public abstract class AbstractPythonConnexionServerCodegen extends DefaultCodegen implements CodegenConfig {
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(AbstractPythonConnexionServerCodegen.class);
|
||||
|
||||
public static final String CONTROLLER_PACKAGE = "controllerPackage";
|
||||
public static final String DEFAULT_CONTROLLER = "defaultController";
|
||||
@@ -64,7 +64,7 @@ public class PythonAbstractConnexionServerCodegen extends DefaultCodegen impleme
|
||||
protected boolean useNose = Boolean.FALSE;
|
||||
protected String pythonSrcRoot;
|
||||
|
||||
public PythonAbstractConnexionServerCodegen(String templateDirectory, boolean fixBodyNameValue) {
|
||||
public AbstractPythonConnexionServerCodegen(String templateDirectory, boolean fixBodyNameValue) {
|
||||
super();
|
||||
|
||||
modifyFeatureSet(features -> features.includeDocumentationFeatures(DocumentationFeature.Readme));
|
||||
@@ -248,7 +248,7 @@ public class PythonAbstractConnexionServerCodegen extends DefaultCodegen impleme
|
||||
pySrcRoot = val.replaceAll("[/\\\\]+$", "");
|
||||
}
|
||||
|
||||
if (pySrcRoot.isEmpty() || pySrcRoot == ".") {
|
||||
if (pySrcRoot.isEmpty() || ".".equals(pySrcRoot)) {
|
||||
this.pythonSrcRoot = "";
|
||||
} else {
|
||||
this.pythonSrcRoot = pySrcRoot + File.separator;
|
||||
@@ -130,7 +130,8 @@ public abstract class AbstractTypeScriptClientCodegen extends DefaultCodegen imp
|
||||
"File",
|
||||
"Error",
|
||||
"Map",
|
||||
"object"
|
||||
"object",
|
||||
"Set"
|
||||
));
|
||||
|
||||
languageGenericTypes = new HashSet<>(Collections.singletonList(
|
||||
@@ -140,6 +141,8 @@ public abstract class AbstractTypeScriptClientCodegen extends DefaultCodegen imp
|
||||
instantiationTypes.put("array", "Array");
|
||||
|
||||
typeMapping = new HashMap<String, String>();
|
||||
typeMapping.put("Set", "Set");
|
||||
typeMapping.put("set", "Set");
|
||||
typeMapping.put("Array", "Array");
|
||||
typeMapping.put("array", "Array");
|
||||
typeMapping.put("boolean", "boolean");
|
||||
@@ -846,7 +849,7 @@ public abstract class AbstractTypeScriptClientCodegen extends DefaultCodegen imp
|
||||
*/
|
||||
protected List<String> getTypesFromSchemas(List<Schema> schemas) {
|
||||
List<Schema> filteredSchemas = schemas.size() > 1
|
||||
? schemas.stream().filter(schema -> super.getSchemaType(schema) != "AnyType").collect(Collectors.toList())
|
||||
? schemas.stream().filter(schema -> !"AnyType".equals(super.getSchemaType(schema))).collect(Collectors.toList())
|
||||
: schemas;
|
||||
|
||||
return filteredSchemas.stream().map(schema -> {
|
||||
|
||||
@@ -335,7 +335,7 @@ public class CppUE4ClientCodegen extends AbstractCppCodegen {
|
||||
public String modelFilename(String templateName, String modelName) {
|
||||
String suffix = modelTemplateFiles().get(templateName);
|
||||
String folder = privateFolder;
|
||||
if (suffix == ".h") {
|
||||
if (".h".equals(suffix)) {
|
||||
folder = publicFolder;
|
||||
}
|
||||
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
|
||||
package org.openapitools.codegen.languages;
|
||||
|
||||
import com.google.common.collect.Sets;
|
||||
import io.swagger.v3.oas.models.media.ArraySchema;
|
||||
import io.swagger.v3.oas.models.media.Schema;
|
||||
|
||||
@@ -30,9 +31,8 @@ import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.nio.charset.Charset;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.*;
|
||||
|
||||
import static org.openapitools.codegen.utils.StringUtils.camelize;
|
||||
@@ -50,6 +50,7 @@ public class DartClientCodegen extends DefaultCodegen implements CodegenConfig {
|
||||
public static final String PUB_HOMEPAGE = "pubHomepage";
|
||||
public static final String USE_ENUM_EXTENSION = "useEnumExtension";
|
||||
public static final String SUPPORT_DART2 = "supportDart2";
|
||||
|
||||
protected boolean browserClient = true;
|
||||
protected String pubName = "openapi";
|
||||
protected String pubVersion = "1.0.0";
|
||||
@@ -106,9 +107,11 @@ public class DartClientCodegen extends DefaultCodegen implements CodegenConfig {
|
||||
modelTestTemplateFiles.put("model_test.mustache", ".dart");
|
||||
apiTestTemplateFiles.put("api_test.mustache", ".dart");
|
||||
|
||||
List<String> reservedWordsList = new ArrayList<String>();
|
||||
List<String> reservedWordsList = new ArrayList<>();
|
||||
try {
|
||||
BufferedReader reader = new BufferedReader(new InputStreamReader(DartClientCodegen.class.getResourceAsStream("/dart/dart-keywords.txt"), Charset.forName("UTF-8")));
|
||||
BufferedReader reader = new BufferedReader(
|
||||
new InputStreamReader(DartClientCodegen.class.getResourceAsStream("/dart/dart-keywords.txt"),
|
||||
StandardCharsets.UTF_8));
|
||||
while (reader.ready()) {
|
||||
reservedWordsList.add(reader.readLine());
|
||||
}
|
||||
@@ -118,18 +121,17 @@ public class DartClientCodegen extends DefaultCodegen implements CodegenConfig {
|
||||
}
|
||||
setReservedWordsLowerCase(reservedWordsList);
|
||||
|
||||
languageSpecificPrimitives = new HashSet<String>(
|
||||
Arrays.asList(
|
||||
"String",
|
||||
"bool",
|
||||
"int",
|
||||
"num",
|
||||
"double")
|
||||
languageSpecificPrimitives = Sets.newHashSet(
|
||||
"String",
|
||||
"bool",
|
||||
"int",
|
||||
"num",
|
||||
"double"
|
||||
);
|
||||
instantiationTypes.put("array", "List");
|
||||
instantiationTypes.put("map", "Map");
|
||||
|
||||
typeMapping = new HashMap<String, String>();
|
||||
typeMapping = new HashMap<>();
|
||||
typeMapping.put("Array", "List");
|
||||
typeMapping.put("array", "List");
|
||||
typeMapping.put("List", "List");
|
||||
@@ -329,7 +331,7 @@ public class DartClientCodegen extends DefaultCodegen implements CodegenConfig {
|
||||
// replace - with _ e.g. created-at => created_at
|
||||
name = name.replaceAll("-", "_");
|
||||
|
||||
// if it's all uppper case, do nothing
|
||||
// if it's all upper case, do nothing
|
||||
if (name.matches("^[A-Z_]*$")) {
|
||||
return name;
|
||||
}
|
||||
@@ -403,9 +405,9 @@ public class DartClientCodegen extends DefaultCodegen implements CodegenConfig {
|
||||
@Override
|
||||
public String toDefaultValue(Schema schema) {
|
||||
if (ModelUtils.isMapSchema(schema)) {
|
||||
return "{}";
|
||||
return "const {}";
|
||||
} else if (ModelUtils.isArraySchema(schema)) {
|
||||
return "[]";
|
||||
return "const []";
|
||||
}
|
||||
|
||||
if (schema.getDefault() != null) {
|
||||
@@ -414,7 +416,7 @@ public class DartClientCodegen extends DefaultCodegen implements CodegenConfig {
|
||||
}
|
||||
return schema.getDefault().toString();
|
||||
} else {
|
||||
return "null";
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -435,7 +437,7 @@ public class DartClientCodegen extends DefaultCodegen implements CodegenConfig {
|
||||
@Override
|
||||
public String getSchemaType(Schema p) {
|
||||
String openAPIType = super.getSchemaType(p);
|
||||
String type = null;
|
||||
String type;
|
||||
if (typeMapping.containsKey(openAPIType)) {
|
||||
type = typeMapping.get(openAPIType);
|
||||
if (languageSpecificPrimitives.contains(type)) {
|
||||
@@ -495,19 +497,16 @@ public class DartClientCodegen extends DefaultCodegen implements CodegenConfig {
|
||||
return false;
|
||||
}
|
||||
Object extension = cm.vendorExtensions.get("x-enum-values");
|
||||
List<Map<String, Object>> values =
|
||||
(List<Map<String, Object>>) extension;
|
||||
List<Map<String, String>> enumVars =
|
||||
new ArrayList<Map<String, String>>();
|
||||
List<Map<String, Object>> values = (List<Map<String, Object>>) extension;
|
||||
List<Map<String, String>> enumVars = new ArrayList<>();
|
||||
for (Map<String, Object> value : values) {
|
||||
Map<String, String> enumVar = new HashMap<String, String>();
|
||||
Map<String, String> enumVar = new HashMap<>();
|
||||
String name = camelize((String) value.get("identifier"), true);
|
||||
if (isReservedWord(name)) {
|
||||
name = escapeReservedWord(name);
|
||||
}
|
||||
enumVar.put("name", name);
|
||||
enumVar.put("value", toEnumValue(
|
||||
value.get("numericValue").toString(), cm.dataType));
|
||||
enumVar.put("value", toEnumValue(value.get("numericValue").toString(), cm.dataType));
|
||||
if (value.containsKey("description")) {
|
||||
enumVar.put("description", value.get("description").toString());
|
||||
}
|
||||
@@ -611,13 +610,12 @@ public class DartClientCodegen extends DefaultCodegen implements CodegenConfig {
|
||||
}
|
||||
|
||||
// only procees the following type (or we can simply rely on the file extension to check if it's a Dart file)
|
||||
Set<String> supportedFileType = new HashSet<String>(
|
||||
Arrays.asList(
|
||||
"supporting-mustache",
|
||||
"model-test",
|
||||
"model",
|
||||
"api-test",
|
||||
"api"));
|
||||
Set<String> supportedFileType = Sets.newHashSet(
|
||||
"supporting-mustache",
|
||||
"model-test",
|
||||
"model",
|
||||
"api-test",
|
||||
"api");
|
||||
if (!supportedFileType.contains(fileType)) {
|
||||
return;
|
||||
}
|
||||
@@ -632,7 +630,7 @@ public class DartClientCodegen extends DefaultCodegen implements CodegenConfig {
|
||||
if (exitValue != 0) {
|
||||
LOGGER.error("Error running the command ({}). Exit code: {}", command, exitValue);
|
||||
} else {
|
||||
LOGGER.info("Successfully executed: " + command);
|
||||
LOGGER.info("Successfully executed: {}", command);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
LOGGER.error("Error running the command ({}). Exception: {}", command, e.getMessage());
|
||||
|
||||
@@ -130,13 +130,21 @@ public class DartDioClientCodegen extends DartClientCodegen {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toDefaultValue(Schema p) {
|
||||
if (ModelUtils.isMapSchema(p)) {
|
||||
public String toDefaultValue(Schema schema) {
|
||||
if (ModelUtils.isMapSchema(schema)) {
|
||||
return "const {}";
|
||||
} else if (ModelUtils.isArraySchema(p)) {
|
||||
} else if (ModelUtils.isArraySchema(schema)) {
|
||||
return "const []";
|
||||
}
|
||||
return super.toDefaultValue(p);
|
||||
|
||||
if (schema.getDefault() != null) {
|
||||
if (ModelUtils.isStringSchema(schema)) {
|
||||
return "\"" + schema.getDefault().toString().replaceAll("\"", "\\\"") + "\"";
|
||||
}
|
||||
return schema.getDefault().toString();
|
||||
} else {
|
||||
return "null";
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -132,13 +132,21 @@ public class DartJaguarClientCodegen extends DartClientCodegen {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toDefaultValue(Schema p) {
|
||||
if (ModelUtils.isMapSchema(p)) {
|
||||
public String toDefaultValue(Schema schema) {
|
||||
if (ModelUtils.isMapSchema(schema)) {
|
||||
return "const {}";
|
||||
} else if (ModelUtils.isArraySchema(p)) {
|
||||
} else if (ModelUtils.isArraySchema(schema)) {
|
||||
return "const []";
|
||||
}
|
||||
return super.toDefaultValue(p);
|
||||
|
||||
if (schema.getDefault() != null) {
|
||||
if (ModelUtils.isStringSchema(schema)) {
|
||||
return "\"" + schema.getDefault().toString().replaceAll("\"", "\\\"") + "\"";
|
||||
}
|
||||
return schema.getDefault().toString();
|
||||
} else {
|
||||
return "null";
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -47,6 +47,21 @@ public class GoClientExperimentalCodegen extends GoClientCodegen {
|
||||
generatorMetadata = GeneratorMetadata.newBuilder(generatorMetadata).stability(Stability.EXPERIMENTAL).build();
|
||||
|
||||
cliOptions.add(new CliOption(CodegenConstants.USE_ONEOF_DISCRIMINATOR_LOOKUP, CodegenConstants.USE_ONEOF_DISCRIMINATOR_LOOKUP_DESC).defaultValue("false"));
|
||||
// option to change how we process + set the data in the 'additionalProperties' keyword.
|
||||
CliOption disallowAdditionalPropertiesIfNotPresentOpt = CliOption.newBoolean(
|
||||
CodegenConstants.DISALLOW_ADDITIONAL_PROPERTIES_IF_NOT_PRESENT,
|
||||
CodegenConstants.DISALLOW_ADDITIONAL_PROPERTIES_IF_NOT_PRESENT_DESC).defaultValue(Boolean.TRUE.toString());
|
||||
Map<String, String> disallowAdditionalPropertiesIfNotPresentOpts = new HashMap<>();
|
||||
disallowAdditionalPropertiesIfNotPresentOpts.put("false",
|
||||
"The 'additionalProperties' implementation is compliant with the OAS and JSON schema specifications.");
|
||||
disallowAdditionalPropertiesIfNotPresentOpts.put("true",
|
||||
"when the 'additionalProperties' keyword is not present in a schema, " +
|
||||
"the value of 'additionalProperties' is automatically set to false, i.e. no additional properties are allowed. " +
|
||||
"Note: this mode is not compliant with the JSON schema specification. " +
|
||||
"This is the original openapi-generator behavior.");
|
||||
disallowAdditionalPropertiesIfNotPresentOpt.setEnum(disallowAdditionalPropertiesIfNotPresentOpts);
|
||||
cliOptions.add(disallowAdditionalPropertiesIfNotPresentOpt);
|
||||
this.setDisallowAdditionalPropertiesIfNotPresent(true);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -102,6 +117,11 @@ public class GoClientExperimentalCodegen extends GoClientCodegen {
|
||||
additionalProperties.put(CodegenConstants.USE_ONEOF_DISCRIMINATOR_LOOKUP, useOneOfDiscriminatorLookup);
|
||||
}
|
||||
|
||||
if (additionalProperties.containsKey(CodegenConstants.DISALLOW_ADDITIONAL_PROPERTIES_IF_NOT_PRESENT)) {
|
||||
this.setDisallowAdditionalPropertiesIfNotPresent(Boolean.valueOf(additionalProperties
|
||||
.get(CodegenConstants.DISALLOW_ADDITIONAL_PROPERTIES_IF_NOT_PRESENT).toString()));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void setUseOneOfDiscriminatorLookup(boolean useOneOfDiscriminatorLookup) {
|
||||
@@ -222,6 +242,13 @@ public class GoClientExperimentalCodegen extends GoClientCodegen {
|
||||
if (model.anyOf != null && !model.anyOf.isEmpty()) {
|
||||
imports.add(createMapping("import", "fmt"));
|
||||
}
|
||||
|
||||
// additionalProperties: true and parent
|
||||
if (model.isAdditionalPropertiesTrue && model.parent != null && Boolean.FALSE.equals(model.isMapModel)) {
|
||||
imports.add(createMapping("import", "reflect"));
|
||||
imports.add(createMapping("import", "strings"));
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
return objs;
|
||||
|
||||
@@ -1400,7 +1400,7 @@ public class JavaCXFExtServerCodegen extends JavaCXFServerCodegen implements CXF
|
||||
|
||||
@Override
|
||||
public String toDefaultValue(Schema p) {
|
||||
if (ModelUtils.isGenerateAliasAsModel() && StringUtils.isNotEmpty(p.get$ref())) {
|
||||
if (ModelUtils.isGenerateAliasAsModel(p) && StringUtils.isNotEmpty(p.get$ref())) {
|
||||
Schema<?> ref = ModelUtils.getReferencedSchema(this.openAPI, p);
|
||||
if (ModelUtils.isArraySchema(ref) || ModelUtils.isMapSchema(ref)) {
|
||||
String typeDeclaration = getTypeDeclaration(p);
|
||||
|
||||
@@ -60,6 +60,7 @@ public class JavaClientCodegen extends AbstractJavaCodegen
|
||||
public static final String USE_RUNTIME_EXCEPTION = "useRuntimeException";
|
||||
public static final String USE_REFLECTION_EQUALS_HASHCODE = "useReflectionEqualsHashCode";
|
||||
public static final String CASE_INSENSITIVE_RESPONSE_HEADERS = "caseInsensitiveResponseHeaders";
|
||||
public static final String USE_ABSTRACTION_FOR_FILES = "useAbstractionForFiles";
|
||||
|
||||
public static final String PLAY_24 = "play24";
|
||||
public static final String PLAY_25 = "play25";
|
||||
@@ -99,6 +100,7 @@ public class JavaClientCodegen extends AbstractJavaCodegen
|
||||
protected boolean useRuntimeException = false;
|
||||
protected boolean useReflectionEqualsHashCode = false;
|
||||
protected boolean caseInsensitiveResponseHeaders = false;
|
||||
protected boolean useAbstractionForFiles = false;
|
||||
protected String authFolder;
|
||||
protected String serializationLibrary = null;
|
||||
|
||||
@@ -140,10 +142,11 @@ public class JavaClientCodegen extends AbstractJavaCodegen
|
||||
cliOptions.add(CliOption.newBoolean(ASYNC_NATIVE, "If true, async handlers will be used, instead of the sync version"));
|
||||
cliOptions.add(CliOption.newBoolean(USE_REFLECTION_EQUALS_HASHCODE, "Use org.apache.commons.lang3.builder for equals and hashCode in the models. WARNING: This will fail under a security manager, unless the appropriate permissions are set up correctly and also there's potential performance impact."));
|
||||
cliOptions.add(CliOption.newBoolean(CASE_INSENSITIVE_RESPONSE_HEADERS, "Make API response's headers case-insensitive. Available on " + OKHTTP_GSON + ", " + JERSEY2 + " libraries"));
|
||||
cliOptions.add(CliOption.newBoolean(USE_ABSTRACTION_FOR_FILES, "Use alternative types instead of java.io.File to allow passing bytes without a file on disk. Available on " + RESTTEMPLATE + " library"));
|
||||
|
||||
supportedLibraries.put(JERSEY1, "HTTP client: Jersey client 1.19.x. JSON processing: Jackson 2.9.x. Enable Java6 support using '-DsupportJava6=true'. Enable gzip request encoding using '-DuseGzipFeature=true'. IMPORTANT NOTE: jersey 1.x is no longer actively maintained so please upgrade to 'jersey2' or other HTTP libaries instead.");
|
||||
supportedLibraries.put(JERSEY2, "HTTP client: Jersey client 2.25.1. JSON processing: Jackson 2.9.x");
|
||||
supportedLibraries.put(FEIGN, "HTTP client: OpenFeign 11.x. JSON processing: Jackson 2.9.x.");
|
||||
supportedLibraries.put(FEIGN, "HTTP client: OpenFeign 10.x. JSON processing: Jackson 2.9.x.");
|
||||
supportedLibraries.put(OKHTTP_GSON, "[DEFAULT] HTTP client: OkHttp 3.x. JSON processing: Gson 2.8.x. Enable Parcelable models on Android using '-DparcelableModel=true'. Enable gzip request encoding using '-DuseGzipFeature=true'.");
|
||||
supportedLibraries.put(RETROFIT_2, "HTTP client: OkHttp 3.x. JSON processing: Gson 2.x (Retrofit 2.3.0). Enable the RxJava adapter using '-DuseRxJava[2/3]=true'. (RxJava 1.x or 2.x or 3.x)");
|
||||
supportedLibraries.put(RESTTEMPLATE, "HTTP client: Spring RestTemplate 4.x. JSON processing: Jackson 2.9.x");
|
||||
@@ -285,6 +288,10 @@ public class JavaClientCodegen extends AbstractJavaCodegen
|
||||
this.setUseReflectionEqualsHashCode(convertPropertyToBooleanAndWriteBack(CASE_INSENSITIVE_RESPONSE_HEADERS));
|
||||
}
|
||||
|
||||
if (additionalProperties.containsKey(USE_ABSTRACTION_FOR_FILES)) {
|
||||
this.setUseAbstractionForFiles(convertPropertyToBooleanAndWriteBack(USE_ABSTRACTION_FOR_FILES));
|
||||
}
|
||||
|
||||
final String invokerFolder = (sourceFolder + '/' + invokerPackage).replace(".", "/");
|
||||
final String apiFolder = (sourceFolder + '/' + apiPackage).replace(".", "/");
|
||||
authFolder = (sourceFolder + '/' + invokerPackage + ".auth").replace(".", "/");
|
||||
@@ -392,9 +399,7 @@ public class JavaClientCodegen extends AbstractJavaCodegen
|
||||
} else if (NATIVE.equals(getLibrary())) {
|
||||
setJava8Mode(true);
|
||||
additionalProperties.put("java8", "true");
|
||||
if (!asyncNative) {
|
||||
supportingFiles.add(new SupportingFile("ApiResponse.mustache", invokerFolder, "ApiResponse.java"));
|
||||
}
|
||||
supportingFiles.add(new SupportingFile("ApiResponse.mustache", invokerFolder, "ApiResponse.java"));
|
||||
forceSerializationLibrary(SERIALIZATION_LIBRARY_JACKSON);
|
||||
} else if (RESTEASY.equals(getLibrary())) {
|
||||
supportingFiles.add(new SupportingFile("JSON.mustache", invokerFolder, "JSON.java"));
|
||||
@@ -682,6 +687,7 @@ public class JavaClientCodegen extends AbstractJavaCodegen
|
||||
model.imports.add("JsonProperty");
|
||||
model.imports.add("JsonValue");
|
||||
model.imports.add("JsonInclude");
|
||||
model.imports.add("JsonTypeName");
|
||||
}
|
||||
if (additionalProperties.containsKey(SERIALIZATION_LIBRARY_GSON)) {
|
||||
model.imports.add("SerializedName");
|
||||
@@ -865,6 +871,10 @@ public class JavaClientCodegen extends AbstractJavaCodegen
|
||||
this.caseInsensitiveResponseHeaders = caseInsensitiveResponseHeaders;
|
||||
}
|
||||
|
||||
public void setUseAbstractionForFiles(boolean useAbstractionForFiles) {
|
||||
this.useAbstractionForFiles = useAbstractionForFiles;
|
||||
}
|
||||
|
||||
/**
|
||||
* Serialization library.
|
||||
*
|
||||
|
||||
@@ -203,4 +203,16 @@ public class PlantumlDocumentationCodegen extends DefaultCodegen implements Code
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String escapeQuotationMark(String input) {
|
||||
// to surpress the warning message
|
||||
return input;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String escapeUnsafeCharacters(String input) {
|
||||
// to surpress the warning message
|
||||
return input;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -501,6 +501,21 @@ public class PowerShellClientCodegen extends DefaultCodegen implements CodegenCo
|
||||
cliOptions.add(new CliOption("commonVerbs", "PS common verb mappings. e.g. Delete=Remove:Patch=Update to map Delete with Remove and Patch with Update accordingly."));
|
||||
cliOptions.add(new CliOption(CodegenConstants.USE_ONEOF_DISCRIMINATOR_LOOKUP, CodegenConstants.USE_ONEOF_DISCRIMINATOR_LOOKUP_DESC));
|
||||
cliOptions.add(new CliOption("discardReadOnly", "Set discardReadonly to true to generate the Initialize cmdlet without readonly parameters"));
|
||||
// option to change how we process + set the data in the 'additionalProperties' keyword.
|
||||
CliOption disallowAdditionalPropertiesIfNotPresentOpt = CliOption.newBoolean(
|
||||
CodegenConstants.DISALLOW_ADDITIONAL_PROPERTIES_IF_NOT_PRESENT,
|
||||
CodegenConstants.DISALLOW_ADDITIONAL_PROPERTIES_IF_NOT_PRESENT_DESC).defaultValue(Boolean.TRUE.toString());
|
||||
Map<String, String> disallowAdditionalPropertiesIfNotPresentOpts = new HashMap<>();
|
||||
disallowAdditionalPropertiesIfNotPresentOpts.put("false",
|
||||
"The 'additionalProperties' implementation is compliant with the OAS and JSON schema specifications.");
|
||||
disallowAdditionalPropertiesIfNotPresentOpts.put("true",
|
||||
"when the 'additionalProperties' keyword is not present in a schema, " +
|
||||
"the value of 'additionalProperties' is automatically set to false, i.e. no additional properties are allowed. " +
|
||||
"Note: this mode is not compliant with the JSON schema specification. " +
|
||||
"This is the original openapi-generator behavior.");
|
||||
disallowAdditionalPropertiesIfNotPresentOpt.setEnum(disallowAdditionalPropertiesIfNotPresentOpts);
|
||||
cliOptions.add(disallowAdditionalPropertiesIfNotPresentOpt);
|
||||
this.setDisallowAdditionalPropertiesIfNotPresent(true);
|
||||
|
||||
// default value in the template
|
||||
additionalProperties.put("powershellVersion", "6.2"); // minimal PS version
|
||||
@@ -550,7 +565,7 @@ public class PowerShellClientCodegen extends DefaultCodegen implements CodegenCo
|
||||
public boolean getUseOneOfDiscriminatorLookup() {
|
||||
return this.useOneOfDiscriminatorLookup;
|
||||
}
|
||||
|
||||
|
||||
public void setDiscardReadOnly(boolean discardReadOnly) {
|
||||
this.discardReadOnly = discardReadOnly;
|
||||
}
|
||||
@@ -632,6 +647,11 @@ public class PowerShellClientCodegen extends DefaultCodegen implements CodegenCo
|
||||
LOGGER.warn(CodegenConstants.API_PACKAGE + " with " + this.getName() + " generator is ignored. Setting this value independently of " + CodegenConstants.PACKAGE_NAME + " is not currently supported.");
|
||||
}
|
||||
|
||||
if (additionalProperties.containsKey(CodegenConstants.DISALLOW_ADDITIONAL_PROPERTIES_IF_NOT_PRESENT)) {
|
||||
this.setDisallowAdditionalPropertiesIfNotPresent(Boolean.valueOf(additionalProperties
|
||||
.get(CodegenConstants.DISALLOW_ADDITIONAL_PROPERTIES_IF_NOT_PRESENT).toString()));
|
||||
}
|
||||
|
||||
additionalProperties.put(CodegenConstants.API_PACKAGE, apiPackage());
|
||||
additionalProperties.put(CodegenConstants.MODEL_PACKAGE, modelPackage());
|
||||
|
||||
@@ -931,13 +951,13 @@ public class PowerShellClientCodegen extends DefaultCodegen implements CodegenCo
|
||||
|
||||
for (CodegenProperty cp : model.allVars) {
|
||||
cp.vendorExtensions.put("x-powershell-data-type", getPSDataType(cp));
|
||||
if(this.discardReadOnly && !cp.isReadOnly) {
|
||||
if (this.discardReadOnly && !cp.isReadOnly) {
|
||||
lastWritableProperty = cp;
|
||||
}
|
||||
}
|
||||
|
||||
// Mark the last readonly false property
|
||||
if(this.discardReadOnly && lastWritableProperty != null) {
|
||||
if (this.discardReadOnly && lastWritableProperty != null) {
|
||||
lastWritableProperty.vendorExtensions.put("x-powershell-last-writable", true);
|
||||
model.allVars.set(model.allVars.indexOf(lastWritableProperty), lastWritableProperty);
|
||||
}
|
||||
@@ -1181,4 +1201,29 @@ public class PowerShellClientCodegen extends DefaultCodegen implements CodegenCo
|
||||
return escapeText(pattern);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toDefaultValue(Schema p) {
|
||||
if (p.getDefault() != null) {
|
||||
if (ModelUtils.isBooleanSchema(p)) {
|
||||
if (Boolean.valueOf(p.getDefault().toString())) {
|
||||
return "$true";
|
||||
} else {
|
||||
return "$false";
|
||||
}
|
||||
} else if (ModelUtils.isDateSchema(p)) {
|
||||
LOGGER.warn("Default value for `date` not yet supported. Please open an issue with https://github.com/openapitools/openapi-generator");
|
||||
} else if (ModelUtils.isDateTimeSchema(p)) {
|
||||
LOGGER.warn("Default value for `datetime` not yet supported. Please open an issue with https://github.com/openapitools/openapi-generator");
|
||||
} else if (ModelUtils.isNumberSchema(p)) {
|
||||
return p.getDefault().toString();
|
||||
} else if (ModelUtils.isIntegerSchema(p)) {
|
||||
return p.getDefault().toString();
|
||||
} else if (ModelUtils.isStringSchema(p)) {
|
||||
return "\"" + p.getDefault() + "\"";
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -28,7 +28,6 @@ import org.openapitools.codegen.meta.Stability;
|
||||
import org.openapitools.codegen.meta.features.DocumentationFeature;
|
||||
import org.openapitools.codegen.meta.features.SecurityFeature;
|
||||
import org.openapitools.codegen.meta.features.WireFormatFeature;
|
||||
import org.openapitools.codegen.utils.ProcessUtils;
|
||||
import org.openapitools.codegen.utils.ModelUtils;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
@@ -216,13 +215,12 @@ public class ProtobufSchemaCodegen extends DefaultCodegen implements CodegenConf
|
||||
public Map<String, Object> postProcessModels(Map<String, Object> objs) {
|
||||
objs = postProcessModelsEnum(objs);
|
||||
List<Object> models = (List<Object>) objs.get("models");
|
||||
// add x-index to properties
|
||||
ProcessUtils.addIndexToProperties(models, 1);
|
||||
|
||||
for (Object _mo : models) {
|
||||
Map<String, Object> mo = (Map<String, Object>) _mo;
|
||||
CodegenModel cm = (CodegenModel) mo.get("model");
|
||||
|
||||
int index = 1;
|
||||
for (CodegenProperty var : cm.vars) {
|
||||
// add x-protobuf-type: repeated if it's an array
|
||||
if (Boolean.TRUE.equals(var.isListContainer)) {
|
||||
@@ -247,6 +245,10 @@ public class ProtobufSchemaCodegen extends DefaultCodegen implements CodegenConf
|
||||
enumIndex++;
|
||||
}
|
||||
}
|
||||
|
||||
// Add x-protobuf-index, unless already specified
|
||||
var.vendorExtensions.putIfAbsent("x-protobuf-index", index);
|
||||
index++;
|
||||
}
|
||||
}
|
||||
return objs;
|
||||
@@ -422,7 +424,7 @@ public class ProtobufSchemaCodegen extends DefaultCodegen implements CodegenConf
|
||||
}
|
||||
}
|
||||
|
||||
p.vendorExtensions.put("x-index", index);
|
||||
p.vendorExtensions.putIfAbsent("x-protobuf-index", index);
|
||||
index++;
|
||||
}
|
||||
|
||||
|
||||
@@ -22,7 +22,7 @@ import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.util.EnumSet;
|
||||
|
||||
public class PythonAiohttpConnexionServerCodegen extends PythonAbstractConnexionServerCodegen {
|
||||
public class PythonAiohttpConnexionServerCodegen extends AbstractPythonConnexionServerCodegen {
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(PythonAiohttpConnexionServerCodegen.class);
|
||||
|
||||
public PythonAiohttpConnexionServerCodegen() {
|
||||
|
||||
@@ -24,7 +24,7 @@ import org.slf4j.LoggerFactory;
|
||||
import java.io.File;
|
||||
import java.util.EnumSet;
|
||||
|
||||
public class PythonBluePlanetServerCodegen extends PythonAbstractConnexionServerCodegen {
|
||||
public class PythonBluePlanetServerCodegen extends AbstractPythonConnexionServerCodegen {
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(PythonBluePlanetServerCodegen.class);
|
||||
|
||||
protected String modelDocPath = "";
|
||||
|
||||
@@ -140,6 +140,20 @@ public class PythonClientExperimentalCodegen extends PythonClientCodegen {
|
||||
supportingFiles.remove(new SupportingFile("__init__model.mustache", packagePath() + File.separatorChar + "models", "__init__.py"));
|
||||
supportingFiles.add(new SupportingFile("python-experimental/__init__model.mustache", packagePath() + File.separatorChar + "model", "__init__.py"));
|
||||
|
||||
supportingFiles.remove(new SupportingFile("configuration.mustache", packagePath(), "configuration.py"));
|
||||
supportingFiles.add(new SupportingFile("python-experimental/configuration.mustache", packagePath(), "configuration.py"));
|
||||
|
||||
supportingFiles.remove(new SupportingFile("__init__api.mustache", packagePath() + File.separatorChar + "api", "__init__.py"));
|
||||
supportingFiles.add(new SupportingFile("python-experimental/__init__api.mustache", packagePath() + File.separatorChar + "api", "__init__.py"));
|
||||
|
||||
supportingFiles.remove(new SupportingFile("exceptions.mustache", packagePath(), "exceptions.py"));
|
||||
supportingFiles.add(new SupportingFile("python-experimental/exceptions.mustache", packagePath(), "exceptions.py"));
|
||||
|
||||
if ("urllib3".equals(getLibrary())) {
|
||||
supportingFiles.remove(new SupportingFile("rest.mustache", packagePath(), "rest.py"));
|
||||
supportingFiles.add(new SupportingFile("python-experimental/rest.mustache", packagePath(), "rest.py"));
|
||||
}
|
||||
|
||||
supportingFiles.remove(new SupportingFile("__init__package.mustache", packagePath(), "__init__.py"));
|
||||
supportingFiles.add(new SupportingFile("python-experimental/__init__package.mustache", packagePath(), "__init__.py"));
|
||||
|
||||
@@ -176,12 +190,18 @@ public class PythonClientExperimentalCodegen extends PythonClientCodegen {
|
||||
supportingFiles.add(new SupportingFile(readmeTemplate, "", readmePath));
|
||||
|
||||
if (!generateSourceCodeOnly) {
|
||||
supportingFiles.remove(new SupportingFile("setup.mustache", "", "setup.py"));
|
||||
supportingFiles.add(new SupportingFile("python-experimental/setup.mustache", "", "setup.py"));
|
||||
supportingFiles.remove(new SupportingFile("requirements.mustache", "", "requirements.txt"));
|
||||
supportingFiles.add(new SupportingFile("python-experimental/requirements.mustache", "", "requirements.txt"));
|
||||
supportingFiles.remove(new SupportingFile("test-requirements.mustache", "", "test-requirements.txt"));
|
||||
supportingFiles.add(new SupportingFile("python-experimental/test-requirements.mustache", "", "test-requirements.txt"));
|
||||
supportingFiles.remove(new SupportingFile("travis.mustache", "", ".travis.yml"));
|
||||
supportingFiles.add(new SupportingFile("python-experimental/travis.mustache", "", ".travis.yml"));
|
||||
supportingFiles.remove(new SupportingFile("gitlab-ci.mustache", "", ".gitlab-ci.yml"));
|
||||
supportingFiles.add(new SupportingFile("python-experimental/gitlab-ci.mustache", "", ".gitlab-ci.yml"));
|
||||
supportingFiles.remove(new SupportingFile("tox.mustache", "", "tox.ini"));
|
||||
supportingFiles.add(new SupportingFile("python-experimental/tox.mustache", "", "tox.ini"));
|
||||
supportingFiles.remove(new SupportingFile("setup.mustache", "", "setup.py"));
|
||||
supportingFiles.add(new SupportingFile("python-experimental/setup.mustache", "", "setup.py"));
|
||||
supportingFiles.remove(new SupportingFile("requirements.mustache", "", "requirements.txt"));
|
||||
supportingFiles.add(new SupportingFile("python-experimental/requirements.mustache", "", "requirements.txt"));
|
||||
supportingFiles.remove(new SupportingFile("test-requirements.mustache", "", "test-requirements.txt"));
|
||||
supportingFiles.add(new SupportingFile("python-experimental/test-requirements.mustache", "", "test-requirements.txt"));
|
||||
}
|
||||
|
||||
// default this to true so the python ModelSimple models will be generated
|
||||
@@ -309,133 +329,72 @@ public class PythonClientExperimentalCodegen extends PythonClientCodegen {
|
||||
|
||||
@Override
|
||||
public String toModelImport(String name) {
|
||||
// name looks like cat.Cat
|
||||
String moduleName = name.split("\\.")[0];
|
||||
// https://exceptionshub.com/circular-or-cyclic-imports-in-python.html
|
||||
return "from " + modelPackage() + " import "+ moduleName;
|
||||
}
|
||||
|
||||
private String robustImport(String name) {
|
||||
// name looks like cat.Cat
|
||||
String moduleName = name.split("\\.")[0];
|
||||
// https://exceptionshub.com/circular-or-cyclic-imports-in-python.html
|
||||
String modelImport = "try:\n from " + modelPackage() +
|
||||
" import " + moduleName+ "\nexcept ImportError:\n " +
|
||||
moduleName + " = sys.modules[\n '" + modelPackage() + "." + moduleName + "']";
|
||||
return modelImport;
|
||||
}
|
||||
|
||||
private String getPythonClassName(String name) {
|
||||
// name looks like cat.Cat or Cat
|
||||
String[] pieces = name.split("\\.");
|
||||
if (pieces.length == 1) {
|
||||
return pieces[0];
|
||||
}
|
||||
return pieces[1];
|
||||
}
|
||||
|
||||
private void fixOperationImports(Set<String> imports) {
|
||||
if (imports.size() == 0) {
|
||||
return;
|
||||
}
|
||||
String[] modelNames = imports.toArray(new String[0]);
|
||||
imports.clear();
|
||||
// loops through imports and converts them all from 'module.Class' to 'from models.module import module'
|
||||
for (String modelName : modelNames) {
|
||||
// if a modelName lacks the module (Pet) then we convert it to pet.Pet
|
||||
if (modelName.indexOf(".") == -1) {
|
||||
modelName = toModelName(modelName);
|
||||
}
|
||||
imports.add(toModelImport(modelName));
|
||||
}
|
||||
// name looks like Cat
|
||||
return "from " + modelPackage() + "." + toModelFilename(name) + " import "+ name;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("static-method")
|
||||
public Map<String, Object> postProcessOperationsWithModels(Map<String, Object> objs, List<Object> allModels) {
|
||||
// fix the imports that each model has, add the module reference to the model
|
||||
// loops through imports and converts them all
|
||||
// from 'Pet' to 'from petstore_api.model.pet import Pet'
|
||||
|
||||
HashMap<String, Object> val = (HashMap<String, Object>)objs.get("operations");
|
||||
ArrayList<CodegenOperation> operations = (ArrayList<CodegenOperation>) val.get("operation");
|
||||
ArrayList<HashMap<String, String>> imports = (ArrayList<HashMap<String, String>>)objs.get("imports");
|
||||
imports.clear();
|
||||
for (CodegenOperation operation : operations) {
|
||||
fixOperationImports(operation.imports);
|
||||
for (String thisImport : operation.imports) {
|
||||
HashMap<String, String> higherImport = new HashMap<String, String>();
|
||||
higherImport.put("import", thisImport);
|
||||
if (!imports.contains(higherImport)) {
|
||||
imports.add(higherImport);
|
||||
}
|
||||
if (operation.imports.size() == 0) {
|
||||
continue;
|
||||
}
|
||||
String[] modelNames = operation.imports.toArray(new String[0]);
|
||||
operation.imports.clear();
|
||||
for (String modelName : modelNames) {
|
||||
operation.imports.add(toModelImport(modelName));
|
||||
}
|
||||
}
|
||||
return objs;
|
||||
}
|
||||
|
||||
private void fixModelImports(Set<String> imports) {
|
||||
// loops through imports and converts them all from 'module.Class' to 'import models.module as module'
|
||||
if (imports.size() == 0) {
|
||||
return;
|
||||
}
|
||||
String[] modelNames = imports.toArray(new String[0]);
|
||||
imports.clear();
|
||||
for (String modelName : modelNames) {
|
||||
imports.add(robustImport(modelName));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Override with special post-processing for all models.
|
||||
*/
|
||||
@SuppressWarnings({"static-method", "unchecked"})
|
||||
public Map<String, Object> postProcessAllModels(Map<String, Object> objs) {
|
||||
super.postProcessAllModels(objs);
|
||||
|
||||
// loop through all models and delete ones where type!=object and the model has no validations and enums
|
||||
// we will remove them because they are not needed
|
||||
Map<String, Schema> modelSchemasToRemove = new HashMap<String, Schema>();
|
||||
for (Map.Entry<String, Object> entry : objs.entrySet()) {
|
||||
Map<String, Object> inner = (Map<String, Object>) entry.getValue();
|
||||
List<Map<String, Object>> models = (List<Map<String, Object>>) inner.get("models");
|
||||
for (Map<String, Object> mo : models) {
|
||||
CodegenModel cm = (CodegenModel) mo.get("model");
|
||||
|
||||
// make sure discriminator models are included in imports
|
||||
CodegenDiscriminator discriminator = cm.discriminator;
|
||||
if (discriminator != null) {
|
||||
Set<CodegenDiscriminator.MappedModel> mappedModels = discriminator.getMappedModels();
|
||||
for (CodegenDiscriminator.MappedModel mappedModel : mappedModels) {
|
||||
String otherModelName = mappedModel.getModelName();
|
||||
cm.imports.add(otherModelName);
|
||||
}
|
||||
}
|
||||
|
||||
// add imports for anyOf, allOf, oneOf
|
||||
ArrayList<Set<String>> composedSchemaSets = new ArrayList<Set<String>>();
|
||||
composedSchemaSets.add(cm.allOf);
|
||||
composedSchemaSets.add(cm.anyOf);
|
||||
composedSchemaSets.add(cm.oneOf);
|
||||
for (Set<String> importSet : composedSchemaSets) {
|
||||
for (String otherModelName : importSet) {
|
||||
if (!languageSpecificPrimitives.contains(otherModelName)) {
|
||||
cm.imports.add(otherModelName);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Schema modelSchema = ModelUtils.getSchema(this.openAPI, cm.name);
|
||||
CodegenProperty modelProperty = fromProperty("value", modelSchema);
|
||||
|
||||
// import complex type from additional properties
|
||||
if (cm.additionalPropertiesType != null && modelProperty.items != null && modelProperty.items.complexType != null) {
|
||||
cm.imports.add(modelProperty.items.complexType);
|
||||
}
|
||||
|
||||
// fix the imports that each model has, change them to absolute
|
||||
fixModelImports(cm.imports);
|
||||
for (Object objModel: objs.values()) {
|
||||
HashMap<String, Object> hmModel = (HashMap<String, Object>) objModel;
|
||||
List<Map<String, Object>> models = (List<Map<String, Object>>) hmModel.get("models");
|
||||
for (Map<String, Object> model : models) {
|
||||
CodegenModel cm = (CodegenModel) model.get("model");
|
||||
|
||||
// remove model if it is a primitive with no validations
|
||||
if (cm.isEnum || cm.isAlias) {
|
||||
Schema modelSchema = ModelUtils.getSchema(this.openAPI, cm.name);
|
||||
CodegenProperty modelProperty = fromProperty("_value", modelSchema);
|
||||
if (!modelProperty.isEnum && !modelProperty.hasValidation && !cm.isArrayModel) {
|
||||
// remove these models because they are aliases and do not have any enums or validations
|
||||
modelSchemasToRemove.put(cm.name, modelSchema);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
// fix model imports
|
||||
if (cm.imports.size() == 0) {
|
||||
continue;
|
||||
}
|
||||
String[] modelNames = cm.imports.toArray(new String[0]);
|
||||
cm.imports.clear();
|
||||
for (String modelName : modelNames) {
|
||||
cm.imports.add(toModelImport(modelName));
|
||||
String globalImportFixer = "globals()['" + modelName + "'] = " + modelName;
|
||||
cm.imports.add(globalImportFixer);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -529,9 +488,7 @@ public class PythonClientExperimentalCodegen extends PythonClientCodegen {
|
||||
if (modelProp.isPrimitiveType && (modelProp.hasValidation || modelProp.isEnum)) {
|
||||
String simpleDataType = result.dataType;
|
||||
result.dataType = toModelName(modelName);
|
||||
result.baseType = getPythonClassName(result.dataType);
|
||||
imports.remove(modelName);
|
||||
imports.add(result.dataType);
|
||||
result.baseType = result.dataType;
|
||||
// set the example value
|
||||
if (modelProp.isEnum) {
|
||||
String value = modelProp._enum.get(0).toString();
|
||||
@@ -539,9 +496,6 @@ public class PythonClientExperimentalCodegen extends PythonClientCodegen {
|
||||
} else {
|
||||
result.example = result.dataType + "(" + result.example + ")";
|
||||
}
|
||||
} else if (!result.isPrimitiveType) {
|
||||
// fix the baseType for the api docs so the .md link to the class's documentation file is correct
|
||||
result.baseType = getPythonClassName(result.baseType);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
@@ -570,7 +524,7 @@ public class PythonClientExperimentalCodegen extends PythonClientCodegen {
|
||||
if (responseSchema != null) {
|
||||
CodegenProperty cp = fromProperty("response", responseSchema);
|
||||
if (cp.complexType != null) {
|
||||
String modelName = getPythonClassName(cp.complexType);
|
||||
String modelName = cp.complexType;
|
||||
Schema modelSchema = ModelUtils.getSchema(this.openAPI, modelName);
|
||||
if (modelSchema != null && !"object".equals(modelSchema.getType())) {
|
||||
CodegenProperty modelProp = fromProperty("response", modelSchema);
|
||||
@@ -583,19 +537,16 @@ public class PythonClientExperimentalCodegen extends PythonClientCodegen {
|
||||
if (cp.isEnum == true || cp.hasValidation == true) {
|
||||
// this model has validations and/or enums so we will generate it
|
||||
Schema sc = ModelUtils.getSchemaFromResponse(response);
|
||||
newBaseType = ModelUtils.getSimpleRef(sc.get$ref());
|
||||
newBaseType = toModelName(ModelUtils.getSimpleRef(sc.get$ref()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
CodegenResponse result = super.fromResponse(responseCode, response);
|
||||
if (newBaseType != null) {
|
||||
result.dataType = toModelName(newBaseType);
|
||||
result.dataType = newBaseType;
|
||||
// baseType is used to set the link to the model .md documentation
|
||||
result.baseType = getPythonClassName(newBaseType);
|
||||
} else if (!result.primitiveType) {
|
||||
// fix the baseType for the api docs so the .md link to the class's documentation file is correct
|
||||
result.baseType = getPythonClassName(result.baseType);
|
||||
result.baseType = newBaseType;
|
||||
}
|
||||
|
||||
return result;
|
||||
@@ -713,28 +664,18 @@ public class PythonClientExperimentalCodegen extends PythonClientCodegen {
|
||||
public void postProcessModelProperty(CodegenModel model, CodegenProperty p) {
|
||||
postProcessPattern(p.pattern, p.vendorExtensions);
|
||||
// set property.complexType so the model docs will link to the ClassName.md
|
||||
if (p.complexType != null && !languageSpecificPrimitives.contains(p.complexType)) {
|
||||
p.complexType = getPythonClassName(p.complexType);
|
||||
} else if (p.isListContainer && p.mostInnerItems.complexType != null && !languageSpecificPrimitives.contains(p.mostInnerItems.complexType)) {
|
||||
if (p.complexType == null && p.isListContainer && p.mostInnerItems.complexType != null && !languageSpecificPrimitives.contains(p.mostInnerItems.complexType)) {
|
||||
// fix ListContainers
|
||||
p.complexType = getPythonClassName(p.mostInnerItems.complexType);
|
||||
}
|
||||
// if a model has a property that is of type self, remove the module name from the dataType
|
||||
if (p.complexType != null && p.dataType.contains(model.classname)) {
|
||||
String classNameNoModule = getPythonClassName(model.classname);
|
||||
p.dataType = p.dataType.replace(model.classname, classNameNoModule);
|
||||
p.complexType = p.mostInnerItems.complexType;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void postProcessParameter(CodegenParameter p) {
|
||||
postProcessPattern(p.pattern, p.vendorExtensions);
|
||||
// set baseType to null so the api docs will not point to a model for languageSpecificPrimitives
|
||||
if (p.baseType != null && languageSpecificPrimitives.contains(p.baseType)){
|
||||
// set baseType to null so the api docs will not point to a model for languageSpecificPrimitives
|
||||
p.baseType = null;
|
||||
} else if (p.isListContainer && p.mostInnerItems.complexType != null && !languageSpecificPrimitives.contains(p.mostInnerItems.complexType)) {
|
||||
// fix ListContainers
|
||||
p.baseType = getPythonClassName(p.mostInnerItems.complexType);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -789,6 +730,18 @@ public class PythonClientExperimentalCodegen extends PythonClientCodegen {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the value of the 'model.parent' property in CodegenModel
|
||||
* We have a custom version of this function so we can add the dataType on the ArrayModel
|
||||
*/
|
||||
@Override
|
||||
protected void addParentContainer(CodegenModel model, String name, Schema schema) {
|
||||
super.addParentContainer(model, name, schema);
|
||||
|
||||
List<String> referencedModelNames = new ArrayList<String>();
|
||||
model.dataType = getTypeString(schema, "", "", referencedModelNames);
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert OAS Model object to Codegen Model object
|
||||
*
|
||||
@@ -800,9 +753,11 @@ public class PythonClientExperimentalCodegen extends PythonClientCodegen {
|
||||
public CodegenModel fromModel(String name, Schema schema) {
|
||||
// we have a custom version of this function so we can produce
|
||||
// models for components whose type != object and which have validations and enums
|
||||
// this ensures that endpoint (operation) responses with validations and enums
|
||||
// will generate models, and when those endpoint responses are received in python
|
||||
// the response is cast as a model, and the model will validate the response using the enums and validations
|
||||
// this ensures that:
|
||||
// - endpoint (operation) responses with validations and type!=(object or array)
|
||||
// - oneOf $ref components with validations and type!=(object or array)
|
||||
// when endpoints receive payloads of these models
|
||||
// that they will be converted into instances of these models
|
||||
Map<String, String> propertyToModelName = new HashMap<String, String>();
|
||||
Map<String, Schema> propertiesMap = schema.getProperties();
|
||||
if (propertiesMap != null) {
|
||||
@@ -820,7 +775,7 @@ public class PythonClientExperimentalCodegen extends PythonClientCodegen {
|
||||
continue;
|
||||
}
|
||||
CodegenProperty modelProperty = fromProperty("_fake_name", refSchema);
|
||||
if (modelProperty.isEnum == false && modelProperty.hasValidation == false) {
|
||||
if (modelProperty.isEnum == true || modelProperty.hasValidation == false) {
|
||||
continue;
|
||||
}
|
||||
String modelName = ModelUtils.getSimpleRef(ref);
|
||||
@@ -828,37 +783,94 @@ public class PythonClientExperimentalCodegen extends PythonClientCodegen {
|
||||
}
|
||||
}
|
||||
CodegenModel result = super.fromModel(name, schema);
|
||||
// use this to store the model name like Cat
|
||||
// we can't use result.name because that is used to lookup models in the spec
|
||||
// we can't use result.classname because that stores cat.Cat
|
||||
// we can't use result.classVarName because that stores the variable for making example instances
|
||||
result.unescapedDescription = simpleModelName(name);
|
||||
|
||||
// make non-object type models have one property so we can use it to store enums and validations
|
||||
if (result.isAlias || result.isEnum || result.isArrayModel) {
|
||||
Schema modelSchema = ModelUtils.getSchema(this.openAPI, result.name);
|
||||
CodegenProperty modelProperty = fromProperty("value", modelSchema);
|
||||
if (modelProperty.isEnum == true || modelProperty.hasValidation == true || result.isArrayModel) {
|
||||
// these models are non-object models with enums and/or validations
|
||||
// add a single property to the model so we can have a way to access validations
|
||||
result.isAlias = true;
|
||||
modelProperty.required = true;
|
||||
List<CodegenProperty> theProperties = Arrays.asList(modelProperty);
|
||||
result.setAllVars(theProperties);
|
||||
result.setVars(theProperties);
|
||||
result.setRequiredVars(theProperties);
|
||||
// post process model properties
|
||||
if (result.vars != null) {
|
||||
for (CodegenProperty prop : result.vars) {
|
||||
postProcessModelProperty(result, prop);
|
||||
// have oneOf point to the correct model
|
||||
if (ModelUtils.isComposedSchema(schema)) {
|
||||
ComposedSchema cs = (ComposedSchema) schema;
|
||||
Map<String, Integer> importCounts = new HashMap<String, Integer>();
|
||||
List<Schema> oneOfSchemas = cs.getOneOf();
|
||||
if (oneOfSchemas != null) {
|
||||
for (int i = 0; i < oneOfSchemas.size(); i++) {
|
||||
Schema oneOfSchema = oneOfSchemas.get(i);
|
||||
String languageType = getTypeDeclaration(oneOfSchema);
|
||||
String ref = oneOfSchema.get$ref();
|
||||
if (ref == null) {
|
||||
Integer currVal = importCounts.getOrDefault(languageType, 0);
|
||||
importCounts.put(languageType, currVal+1);
|
||||
continue;
|
||||
}
|
||||
Schema refSchema = ModelUtils.getReferencedSchema(this.openAPI, oneOfSchema);
|
||||
String refType = refSchema.getType();
|
||||
if (refType == null || refType.equals("object")) {
|
||||
Integer currVal = importCounts.getOrDefault(languageType, 0);
|
||||
importCounts.put(languageType, currVal+1);
|
||||
continue;
|
||||
}
|
||||
|
||||
CodegenProperty modelProperty = fromProperty("_oneOfSchema", refSchema);
|
||||
if (modelProperty.isEnum == true) {
|
||||
Integer currVal = importCounts.getOrDefault(languageType, 0);
|
||||
importCounts.put(languageType, currVal+1);
|
||||
continue;
|
||||
}
|
||||
|
||||
languageType = getTypeDeclaration(refSchema);
|
||||
if (modelProperty.hasValidation == false) {
|
||||
Integer currVal = importCounts.getOrDefault(languageType, 0);
|
||||
importCounts.put(languageType, currVal+1);
|
||||
continue;
|
||||
}
|
||||
Integer currVal = importCounts.getOrDefault(languageType, 0);
|
||||
importCounts.put(languageType, currVal);
|
||||
String modelName = toModelName(ModelUtils.getSimpleRef(ref));
|
||||
result.imports.add(modelName);
|
||||
result.oneOf.add(modelName);
|
||||
currVal = importCounts.getOrDefault(modelName, 0);
|
||||
importCounts.put(modelName, currVal+1);
|
||||
}
|
||||
}
|
||||
for (Map.Entry<String, Integer> entry : importCounts.entrySet()) {
|
||||
String importName = entry.getKey();
|
||||
Integer importCount = entry.getValue();
|
||||
if (importCount == 0) {
|
||||
result.oneOf.remove(importName);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// set regex values, before it was only done on model.vars
|
||||
// fix all property references to non-object models, make those properties non-primitive and
|
||||
// this block handles models which have the python base class ModelSimple
|
||||
// which are responsible for storing validations, enums, and an unnamed value
|
||||
Schema modelSchema = ModelUtils.getSchema(this.openAPI, result.name);
|
||||
CodegenProperty modelProperty = fromProperty("_value", modelSchema);
|
||||
|
||||
Boolean isPythonModelSimpleModel = (result.isEnum || result.isArrayModel || result.isAlias && modelProperty.hasValidation);
|
||||
if (isPythonModelSimpleModel) {
|
||||
// In python, classes which inherit from our ModelSimple class store one value,
|
||||
// like a str, int, list and extra data about that value like validations and enums
|
||||
|
||||
if (result.isEnum) {
|
||||
// if there is only one allowed value then we know that it should be set, so value is optional
|
||||
// -> hasRequired = false
|
||||
// if there are more than one allowed value then value is positional and required so
|
||||
// -> hasRequired = true
|
||||
ArrayList values = (ArrayList) result.allowableValues.get("values");
|
||||
if (values != null && values.size() > 1) {
|
||||
result.hasRequired = true;
|
||||
}
|
||||
|
||||
if (modelProperty.defaultValue != null && result.defaultValue == null) {
|
||||
result.defaultValue = modelProperty.defaultValue;
|
||||
}
|
||||
} else {
|
||||
if (result.defaultValue == null) {
|
||||
result.hasRequired = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
// fix all property references to ModelSimple models, make those properties non-primitive and
|
||||
// set their dataType and complexType to the model name, so documentation will refer to the correct model
|
||||
// set regex values, before it was only done on model.vars
|
||||
// NOTE: this is done for models of type != object which are not enums and have validations
|
||||
ArrayList<List<CodegenProperty>> listOfLists = new ArrayList<List<CodegenProperty>>();
|
||||
listOfLists.add(result.vars);
|
||||
listOfLists.add(result.allVars);
|
||||
@@ -876,13 +888,14 @@ public class PythonClientExperimentalCodegen extends PythonClientCodegen {
|
||||
}
|
||||
cp.isPrimitiveType = false;
|
||||
String modelName = propertyToModelName.get(cp.name);
|
||||
cp.complexType = getPythonClassName(modelName);
|
||||
cp.complexType = modelName;
|
||||
cp.dataType = modelName;
|
||||
cp.isEnum = false;
|
||||
cp.hasValidation = false;
|
||||
result.imports.add(modelName);
|
||||
}
|
||||
}
|
||||
|
||||
// if a class has a property of type self, remove the self import from imports
|
||||
if (result.imports.contains(result.classname)) {
|
||||
result.imports.remove(result.classname);
|
||||
@@ -895,6 +908,60 @@ public class PythonClientExperimentalCodegen extends PythonClientCodegen {
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* returns the OpenAPI type for the property. Use getAlias to handle $ref of primitive type
|
||||
* We have a custom version of this function because for composed schemas we also want to return the model name
|
||||
* In DefaultCodegen.java it returns a name built off of individual allOf/anyOf/oneOf which is not what
|
||||
* python-experimental needs. Python-experimental needs the name of the composed schema
|
||||
*
|
||||
* @param schema property schema
|
||||
* @return string presentation of the type
|
||||
**/
|
||||
@SuppressWarnings("static-method")
|
||||
@Override
|
||||
public String getSchemaType(Schema schema) {
|
||||
if (schema instanceof ComposedSchema) { // composed schema
|
||||
Schema unaliasSchema = ModelUtils.unaliasSchema(this.openAPI, schema, importMapping);
|
||||
String ref = unaliasSchema.get$ref();
|
||||
if (ref != null) {
|
||||
String schemaName = ModelUtils.getSimpleRef(unaliasSchema.get$ref());
|
||||
if (StringUtils.isNotEmpty(schemaName) && importMapping.containsKey(schemaName)) {
|
||||
return schemaName;
|
||||
}
|
||||
return getAlias(schemaName);
|
||||
} else {
|
||||
// we may have be processing the component schema rather than a schema with a $ref
|
||||
// to a component schema
|
||||
// so loop through component schemas and use the found one's name if we match
|
||||
Map<String, Schema> schemas = ModelUtils.getSchemas(openAPI);
|
||||
for (String thisSchemaName : schemas.keySet()) {
|
||||
Schema thisSchema = schemas.get(thisSchemaName);
|
||||
if (!ModelUtils.isComposedSchema(thisSchema)) {
|
||||
continue;
|
||||
}
|
||||
if (thisSchema == unaliasSchema) {
|
||||
if (importMapping.containsKey(thisSchemaName)) {
|
||||
return thisSchemaName;
|
||||
}
|
||||
return getAlias(thisSchemaName);
|
||||
}
|
||||
}
|
||||
LOGGER.warn("Error obtaining the datatype from ref:" + unaliasSchema.get$ref() + ". Default to 'object'");
|
||||
return "object";
|
||||
}
|
||||
}
|
||||
String openAPIType = getSingleSchemaType(schema);
|
||||
if (typeMapping.containsKey(openAPIType)) {
|
||||
String type = typeMapping.get(openAPIType);
|
||||
if (languageSpecificPrimitives.contains(type)) {
|
||||
return type;
|
||||
}
|
||||
} else {
|
||||
return toModelName(openAPIType);
|
||||
}
|
||||
return openAPIType;
|
||||
}
|
||||
|
||||
/**
|
||||
* Output the type declaration of the property
|
||||
*
|
||||
@@ -909,6 +976,18 @@ public class PythonClientExperimentalCodegen extends PythonClientCodegen {
|
||||
return oasType;
|
||||
}
|
||||
|
||||
public Boolean modelWillBeMade(Schema s) {
|
||||
// only invoke this on $refed schemas
|
||||
if (ModelUtils.isComposedSchema(s) || ModelUtils.isArraySchema(s) || ModelUtils.isObjectSchema(s)) {
|
||||
return true;
|
||||
}
|
||||
CodegenProperty cp = fromProperty("_model", s);
|
||||
if (cp.isEnum || cp.hasValidation) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a string representation of the Python types for the specified OAS schema.
|
||||
* Primitive types in the OAS specification are implemented in Python using the corresponding
|
||||
@@ -939,12 +1018,12 @@ public class PythonClientExperimentalCodegen extends PythonClientCodegen {
|
||||
// The input schema is a reference. If the resolved schema is
|
||||
// a composed schema, convert the name to a Python class.
|
||||
Schema s = ModelUtils.getReferencedSchema(this.openAPI, p);
|
||||
if (s instanceof ComposedSchema) {
|
||||
String modelName = ModelUtils.getSimpleRef(p.get$ref());
|
||||
if (modelWillBeMade(s)) {
|
||||
String modelName = toModelName(ModelUtils.getSimpleRef(p.get$ref()));
|
||||
if (referencedModelNames != null) {
|
||||
referencedModelNames.add(modelName);
|
||||
}
|
||||
return prefix + toModelName(modelName) + fullSuffix;
|
||||
return prefix + modelName + fullSuffix;
|
||||
}
|
||||
}
|
||||
if (isAnyTypeSchema(p)) {
|
||||
@@ -1094,55 +1173,4 @@ public class PythonClientExperimentalCodegen extends PythonClientCodegen {
|
||||
|
||||
p.example = example;
|
||||
}
|
||||
|
||||
private String simpleModelName(String name) {
|
||||
// this returns a model name like Cat
|
||||
String modelName = sanitizeName(name);
|
||||
// remove dollar sign
|
||||
modelName = modelName.replaceAll("$", "");
|
||||
|
||||
// model name cannot use reserved keyword, e.g. return
|
||||
if (isReservedWord(modelName)) {
|
||||
LOGGER.warn(modelName + " (reserved word) cannot be used as model name. Renamed to " + camelize("model_" + modelName));
|
||||
modelName = "model_" + modelName; // e.g. return => ModelReturn (after camelize)
|
||||
}
|
||||
|
||||
// model name starts with number
|
||||
if (modelName.matches("^\\d.*")) {
|
||||
LOGGER.warn(modelName + " (model name starts with number) cannot be used as model name. Renamed to " + camelize("model_" + modelName));
|
||||
modelName = "model_" + modelName; // e.g. 200Response => Model200Response (after camelize)
|
||||
}
|
||||
|
||||
if (!StringUtils.isEmpty(modelNamePrefix)) {
|
||||
modelName = modelNamePrefix + "_" + modelName;
|
||||
}
|
||||
|
||||
if (!StringUtils.isEmpty(modelNameSuffix)) {
|
||||
modelName = modelName + "_" + modelNameSuffix;
|
||||
}
|
||||
|
||||
// camelize the model name
|
||||
// phone_number => PhoneNumber
|
||||
return camelize(modelName);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String toModelFilename(String name) {
|
||||
// underscore the model file name
|
||||
// PhoneNumber => phone_number
|
||||
return underscore(dropDots(simpleModelName(name)));
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toModelName(String name) {
|
||||
// we have a custom version of this function so we can support circular references in python 2 and 3
|
||||
return toModelFilename(name)+"."+simpleModelName(name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toModelDocFilename(String name) {
|
||||
// this is used to generate the model's .md documentation file
|
||||
return simpleModelName(name);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,7 +22,7 @@ import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
public class PythonFlaskConnexionServerCodegen extends PythonAbstractConnexionServerCodegen {
|
||||
public class PythonFlaskConnexionServerCodegen extends AbstractPythonConnexionServerCodegen {
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(PythonFlaskConnexionServerCodegen.class);
|
||||
|
||||
public PythonFlaskConnexionServerCodegen() {
|
||||
|
||||
@@ -34,6 +34,10 @@ import java.io.File;
|
||||
import java.util.*;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
import java.time.OffsetDateTime;
|
||||
import java.time.Instant;
|
||||
import java.time.temporal.ChronoField;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import static org.openapitools.codegen.utils.StringUtils.camelize;
|
||||
|
||||
@@ -620,14 +624,19 @@ public class Swift5ClientCodegen extends DefaultCodegen implements CodegenConfig
|
||||
}
|
||||
}
|
||||
}
|
||||
if (ModelUtils.isIntegerSchema(p) || ModelUtils.isNumberSchema(p) || ModelUtils.isBooleanSchema(p)) {
|
||||
if (p.getDefault() != null) {
|
||||
if (p.getDefault() != null) {
|
||||
if (ModelUtils.isIntegerSchema(p) || ModelUtils.isNumberSchema(p) || ModelUtils.isBooleanSchema(p)) {
|
||||
return p.getDefault().toString();
|
||||
}
|
||||
} else if (ModelUtils.isStringSchema(p)) {
|
||||
if (p.getDefault() != null) {
|
||||
} else if (ModelUtils.isDateTimeSchema(p)) {
|
||||
// Datetime time stamps in Swift are expressed as Seconds with Microsecond precision.
|
||||
// In Java, we need to be creative to get the Timestamp in Microseconds as a long.
|
||||
Instant instant = ((OffsetDateTime) p.getDefault()).toInstant();
|
||||
long epochMicro = TimeUnit.SECONDS.toMicros(instant.getEpochSecond()) + ((long) instant.get(ChronoField.MICRO_OF_SECOND));
|
||||
return "Date(timeIntervalSince1970: " + String.valueOf(epochMicro) + ".0 / 1_000_000)";
|
||||
} else if (ModelUtils.isStringSchema(p)) {
|
||||
return "\"" + escapeText((String) p.getDefault()) + "\"";
|
||||
}
|
||||
// TODO: Handle more cases from `ModelUtils`, such as Date
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -61,7 +61,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 QUERY_PARAM_OBJECT_FORMAT = "queryParamObjectFormat";
|
||||
|
||||
protected String ngVersion = "9.0.0";
|
||||
protected String ngVersion = "10.0.0";
|
||||
protected String npmRepository = null;
|
||||
private boolean useSingleRequestParameter = false;
|
||||
protected String serviceSuffix = "Service";
|
||||
@@ -129,7 +129,7 @@ public class TypeScriptAngularClientCodegen extends AbstractTypeScriptClientCode
|
||||
|
||||
@Override
|
||||
public String getHelp() {
|
||||
return "Generates a TypeScript Angular (6.x - 9.x) client library.";
|
||||
return "Generates a TypeScript Angular (6.x - 10.x) client library.";
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -246,7 +246,9 @@ public class TypeScriptAngularClientCodegen extends AbstractTypeScriptClientCode
|
||||
}
|
||||
|
||||
// Set the typescript version compatible to the Angular version
|
||||
if (ngVersion.atLeast("9.0.0")) {
|
||||
if (ngVersion.atLeast("10.0.0")) {
|
||||
additionalProperties.put("tsVersion", ">=3.9.2 <4.0.0");
|
||||
} else if (ngVersion.atLeast("9.0.0")) {
|
||||
additionalProperties.put("tsVersion", ">=3.6.0 <3.8.0");
|
||||
} else if (ngVersion.atLeast("8.0.0")) {
|
||||
additionalProperties.put("tsVersion", ">=3.4.0 <3.6.0");
|
||||
@@ -258,7 +260,9 @@ public class TypeScriptAngularClientCodegen extends AbstractTypeScriptClientCode
|
||||
}
|
||||
|
||||
// Set the rxJS version compatible to the Angular version
|
||||
if (ngVersion.atLeast("9.0.0")) {
|
||||
if (ngVersion.atLeast("10.0.0")) {
|
||||
additionalProperties.put("rxjsVersion", "6.6.0");
|
||||
} else if (ngVersion.atLeast("9.0.0")) {
|
||||
additionalProperties.put("rxjsVersion", "6.5.3");
|
||||
} else if (ngVersion.atLeast("8.0.0")) {
|
||||
additionalProperties.put("rxjsVersion", "6.5.0");
|
||||
@@ -272,7 +276,10 @@ public class TypeScriptAngularClientCodegen extends AbstractTypeScriptClientCode
|
||||
supportingFiles.add(new SupportingFile("ng-package.mustache", getIndexDirectory(), "ng-package.json"));
|
||||
|
||||
// Specific ng-packagr configuration
|
||||
if (ngVersion.atLeast("9.0.0")) {
|
||||
if (ngVersion.atLeast("10.0.0")) {
|
||||
additionalProperties.put("ngPackagrVersion", "10.0.3");
|
||||
additionalProperties.put("tsickleVersion", "0.39.1");
|
||||
} else if (ngVersion.atLeast("9.0.0")) {
|
||||
additionalProperties.put("ngPackagrVersion", "9.0.1");
|
||||
additionalProperties.put("tsickleVersion", "0.38.0");
|
||||
} else if (ngVersion.atLeast("8.0.0")) {
|
||||
|
||||
@@ -839,10 +839,10 @@ public class TypeScriptClientCodegen extends DefaultCodegen implements CodegenCo
|
||||
Schema inner;
|
||||
if (ModelUtils.isArraySchema(p)) {
|
||||
inner = ((ArraySchema) p).getItems();
|
||||
return this.getSchemaType(p) + "<" + this.getTypeDeclaration(inner) + ">";
|
||||
return this.getSchemaType(p) + "<" + this.getTypeDeclaration(ModelUtils.unaliasSchema(this.openAPI, inner)) + ">";
|
||||
} else if (ModelUtils.isMapSchema(p)) {
|
||||
inner = (Schema) p.getAdditionalProperties();
|
||||
return "{ [key: string]: " + this.getTypeDeclaration(inner) + "; }";
|
||||
return "{ [key: string]: " + this.getTypeDeclaration(ModelUtils.unaliasSchema(this.openAPI, inner)) + "; }";
|
||||
} else if (ModelUtils.isFileSchema(p)) {
|
||||
return "HttpFile";
|
||||
} else if (ModelUtils.isBinarySchema(p)) {
|
||||
|
||||
@@ -88,6 +88,10 @@ public class ModelUtils {
|
||||
return Boolean.parseBoolean(GlobalSettings.getProperty(generateAliasAsModelKey, "false"));
|
||||
}
|
||||
|
||||
public static boolean isGenerateAliasAsModel(Schema schema) {
|
||||
return isGenerateAliasAsModel() || (schema.getExtensions() != null && schema.getExtensions().getOrDefault("x-generate-alias-as-model", false).equals(true));
|
||||
}
|
||||
|
||||
/**
|
||||
* Searches for the model by name in the map of models and returns it
|
||||
*
|
||||
@@ -1037,7 +1041,7 @@ public class ModelUtils {
|
||||
// top-level enum class
|
||||
return schema;
|
||||
} else if (isArraySchema(ref)) {
|
||||
if (isGenerateAliasAsModel()) {
|
||||
if (isGenerateAliasAsModel(ref)) {
|
||||
return schema; // generate a model extending array
|
||||
} else {
|
||||
return unaliasSchema(openAPI, allSchemas.get(ModelUtils.getSimpleRef(schema.get$ref())),
|
||||
@@ -1049,7 +1053,7 @@ public class ModelUtils {
|
||||
if (ref.getProperties() != null && !ref.getProperties().isEmpty()) // has at least one property
|
||||
return schema; // treat it as model
|
||||
else {
|
||||
if (isGenerateAliasAsModel()) {
|
||||
if (isGenerateAliasAsModel(ref)) {
|
||||
return schema; // generate a model extending map
|
||||
} else {
|
||||
// treat it as a typical map
|
||||
|
||||
@@ -126,7 +126,7 @@ ext {
|
||||
{{#threetenbp}}
|
||||
jackson_threetenbp_version = "2.9.10"
|
||||
{{/threetenbp}}
|
||||
feign_version = "11.0"
|
||||
feign_version = "10.11"
|
||||
feign_form_version = "3.8.0"
|
||||
junit_version = "4.13"
|
||||
oltu_version = "1.0.1"
|
||||
|
||||
@@ -10,9 +10,9 @@ lazy val root = (project in file(".")).
|
||||
resolvers += Resolver.mavenLocal,
|
||||
libraryDependencies ++= Seq(
|
||||
"io.swagger" % "swagger-annotations" % "1.5.24" % "compile",
|
||||
"io.github.openfeign" % "feign-core" % "11.0" % "compile",
|
||||
"io.github.openfeign" % "feign-jackson" % "11.0" % "compile",
|
||||
"io.github.openfeign" % "feign-slf4j" % "11.0" % "compile",
|
||||
"io.github.openfeign" % "feign-core" % "10.11" % "compile",
|
||||
"io.github.openfeign" % "feign-jackson" % "10.11" % "compile",
|
||||
"io.github.openfeign" % "feign-slf4j" % "10.11" % "compile",
|
||||
"io.github.openfeign.form" % "feign-form" % "3.8.0" % "compile",
|
||||
"com.fasterxml.jackson.core" % "jackson-core" % "2.10.3" % "compile",
|
||||
"com.fasterxml.jackson.core" % "jackson-annotations" % "2.10.3" % "compile",
|
||||
|
||||
@@ -348,7 +348,7 @@
|
||||
<maven.compiler.source>${java.version}</maven.compiler.source>
|
||||
<maven.compiler.target>${java.version}</maven.compiler.target>
|
||||
<swagger-annotations-version>1.5.24</swagger-annotations-version>
|
||||
<feign-version>11.0</feign-version>
|
||||
<feign-version>10.11</feign-version>
|
||||
<feign-form-version>3.8.0</feign-form-version>
|
||||
<jackson-version>2.10.3</jackson-version>
|
||||
<jackson-databind-nullable-version>0.2.1</jackson-databind-nullable-version>
|
||||
|
||||
@@ -874,9 +874,17 @@ public class ApiClient {
|
||||
} else {
|
||||
// We let jersey handle the serialization
|
||||
if (isBodyNullable) { // payload is nullable
|
||||
entity = Entity.entity(obj == null ? Entity.text("null") : obj, contentType);
|
||||
if (obj instanceof String) {
|
||||
entity = Entity.entity(obj == null ? "null" : "\"" + ((String)obj).replaceAll("\"", Matcher.quoteReplacement("\\\"")) + "\"", contentType);
|
||||
} else {
|
||||
entity = Entity.entity(obj == null ? "null" : obj, contentType);
|
||||
}
|
||||
} else {
|
||||
entity = Entity.entity(obj == null ? Entity.text("") : obj, contentType);
|
||||
if (obj instanceof String) {
|
||||
entity = Entity.entity(obj == null ? "" : "\"" + ((String)obj).replaceAll("\"", Matcher.quoteReplacement("\\\"")) + "\"", contentType);
|
||||
} else {
|
||||
entity = Entity.entity(obj == null ? "" : obj, contentType);
|
||||
}
|
||||
}
|
||||
}
|
||||
return entity;
|
||||
@@ -888,7 +896,7 @@ public class ApiClient {
|
||||
* @param obj Object
|
||||
* @param formParams Form parameters
|
||||
* @param contentType Context type
|
||||
* @param isBodyNulalble True if the body is nullable
|
||||
* @param isBodyNullable True if the body is nullable
|
||||
* @return String
|
||||
* @throws ApiException API exception
|
||||
*/
|
||||
@@ -911,7 +919,7 @@ public class ApiClient {
|
||||
if (isBodyNullable) {
|
||||
return obj == null ? "null" : json.getMapper().writeValueAsString(obj);
|
||||
} else {
|
||||
return json.getMapper().writeValueAsString(obj);
|
||||
return obj == null ? "" : json.getMapper().writeValueAsString(obj);
|
||||
}
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
|
||||
@@ -34,6 +34,7 @@ public class JSON implements ContextResolver<ObjectMapper> {
|
||||
public JSON() {
|
||||
mapper = new ObjectMapper();
|
||||
mapper.setSerializationInclusion(JsonInclude.Include.NON_NULL);
|
||||
mapper.configure(MapperFeature.ALLOW_COERCION_OF_SCALARS, false);
|
||||
mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, true);
|
||||
mapper.configure(DeserializationFeature.FAIL_ON_INVALID_SUBTYPE, true);
|
||||
mapper.disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS);
|
||||
|
||||
@@ -33,7 +33,7 @@ import {{{invokerPackage}}}.ApiClient;
|
||||
import {{{invokerPackage}}}.ApiException;
|
||||
import {{{invokerPackage}}}.Configuration;{{#hasAuthMethods}}
|
||||
import {{{invokerPackage}}}.auth.*;{{/hasAuthMethods}}
|
||||
import {{{invokerPackage}}}.models.*;
|
||||
import {{{invokerPackage}}}.model.*;
|
||||
import {{{package}}}.{{{classname}}};
|
||||
|
||||
public class Example {
|
||||
|
||||
@@ -12,10 +12,12 @@ import java.security.Key;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Base64;
|
||||
import java.util.Calendar;
|
||||
import java.util.Date;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.List;
|
||||
import java.util.TimeZone;
|
||||
import java.security.spec.AlgorithmParameterSpec;
|
||||
import java.security.InvalidKeyException;
|
||||
|
||||
@@ -236,7 +238,9 @@ public class HttpSignatureAuth implements Authentication {
|
||||
}
|
||||
|
||||
if (headers.contains("date")) {
|
||||
headerParams.put("date", new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss zzz", Locale.US).format(new Date()));
|
||||
SimpleDateFormat dateFormat = new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss z", Locale.US);
|
||||
dateFormat.setTimeZone(TimeZone.getTimeZone("GMT"));
|
||||
headerParams.put("date", dateFormat.format(Calendar.getInstance().getTime()));
|
||||
}
|
||||
|
||||
if (headers.contains("digest")) {
|
||||
@@ -253,7 +257,7 @@ public class HttpSignatureAuth implements Authentication {
|
||||
// Calling getRawPath and getRawQuery ensures the path is URL-encoded as it will be serialized
|
||||
// on the wire. The HTTP signature must use the encode URL as it is sent on the wire.
|
||||
String path = uri.getRawPath();
|
||||
if (uri.getRawQuery() != "") {
|
||||
if (uri.getRawQuery() != null && !"".equals(uri.getRawQuery())) {
|
||||
path += "?" + uri.getRawQuery();
|
||||
}
|
||||
|
||||
|
||||
@@ -10,10 +10,12 @@ import java.util.HashSet;
|
||||
import com.fasterxml.jackson.core.JsonGenerator;
|
||||
import com.fasterxml.jackson.core.JsonParser;
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
import com.fasterxml.jackson.core.JsonToken;
|
||||
import com.fasterxml.jackson.core.type.TypeReference;
|
||||
import com.fasterxml.jackson.databind.DeserializationContext;
|
||||
import com.fasterxml.jackson.databind.JsonMappingException;
|
||||
import com.fasterxml.jackson.databind.JsonNode;
|
||||
import com.fasterxml.jackson.databind.MapperFeature;
|
||||
import com.fasterxml.jackson.databind.SerializerProvider;
|
||||
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
|
||||
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
|
||||
@@ -73,16 +75,34 @@ public class {{classname}} extends AbstractOpenApiSchema{{#vendorExtensions.x-im
|
||||
|
||||
{{/discriminator}}
|
||||
{{/useOneOfDiscriminatorLookup}}
|
||||
boolean typeCoercion = ctxt.isEnabled(MapperFeature.ALLOW_COERCION_OF_SCALARS);
|
||||
int match = 0;
|
||||
JsonToken token = tree.traverse(jp.getCodec()).nextToken();
|
||||
{{#oneOf}}
|
||||
// deserialize {{{.}}}
|
||||
try {
|
||||
deserialized = tree.traverse(jp.getCodec()).readValueAs({{{.}}}.class);
|
||||
// TODO: there is no validation against JSON schema constraints
|
||||
// (min, max, enum, pattern...), this does not perform a strict JSON
|
||||
// validation, which means the 'match' count may be higher than it should be.
|
||||
match++;
|
||||
log.log(Level.FINER, "Input data matches schema '{{{.}}}'");
|
||||
boolean attemptParsing = true;
|
||||
// ensure that we respect type coercion as set on the client ObjectMapper
|
||||
if ({{{.}}}.class.equals(Integer.class) || {{{.}}}.class.equals(Long.class) || {{{.}}}.class.equals(Float.class) || {{{.}}}.class.equals(Double.class) || {{{.}}}.class.equals(Boolean.class) || {{{.}}}.class.equals(String.class)) {
|
||||
attemptParsing = typeCoercion;
|
||||
if (!attemptParsing) {
|
||||
attemptParsing |= (({{{.}}}.class.equals(Integer.class) || {{{.}}}.class.equals(Long.class)) && token == JsonToken.VALUE_NUMBER_INT);
|
||||
attemptParsing |= (({{{.}}}.class.equals(Float.class) || {{{.}}}.class.equals(Double.class)) && token == JsonToken.VALUE_NUMBER_FLOAT);
|
||||
attemptParsing |= ({{{.}}}.class.equals(Boolean.class) && (token == JsonToken.VALUE_FALSE || token == JsonToken.VALUE_TRUE));
|
||||
attemptParsing |= ({{{.}}}.class.equals(String.class) && token == JsonToken.VALUE_STRING);
|
||||
{{#isNullable}}
|
||||
attemptParsing |= (token == JsonToken.VALUE_NULL);
|
||||
{{/isNullable}}
|
||||
}
|
||||
}
|
||||
if (attemptParsing) {
|
||||
deserialized = tree.traverse(jp.getCodec()).readValueAs({{{.}}}.class);
|
||||
// TODO: there is no validation against JSON schema constraints
|
||||
// (min, max, enum, pattern...), this does not perform a strict JSON
|
||||
// validation, which means the 'match' count may be higher than it should be.
|
||||
match++;
|
||||
log.log(Level.FINER, "Input data matches schema '{{{.}}}'");
|
||||
}
|
||||
} catch (Exception e) {
|
||||
// deserialization failed, continue
|
||||
log.log(Level.FINER, "Input data does not match schema '{{{.}}}'", e);
|
||||
|
||||
@@ -33,6 +33,7 @@ import javax.json.bind.annotation.JsonbProperty;
|
||||
* {{{description}}}
|
||||
**/
|
||||
{{/description}}
|
||||
{{>additionalModelTypeAnnotations}}
|
||||
public class {{classname}} {{#parent}}extends {{{parent}}}{{/parent}}{{#serializableModel}} implements Serializable{{/serializableModel}} {
|
||||
{{#vars}}{{#isEnum}}{{^isContainer}}
|
||||
{{>enumClass}}{{/isContainer}}{{#isContainer}}{{#mostInnerItems}}
|
||||
|
||||
@@ -99,12 +99,19 @@ public class {{{classname}}}Example {
|
||||
{{/allParams}}
|
||||
try {
|
||||
{{^vendorExtensions.x-group-parameters}}
|
||||
{{#returnType}}{{#asyncNative}}CompletableFuture<{{{returnType}}}>{{/asyncNative}}{{^asyncNative}}{{{returnType}}}{{/asyncNative}} result = {{/returnType}}{{^returnType}}{{#asyncNative}}CompletableFuture<Void> result = {{/asyncNative}}{{/returnType}}apiInstance.{{{operationId}}}({{#allParams}}{{{paramName}}}{{#hasMore}}, {{/hasMore}}{{/allParams}});{{/vendorExtensions.x-group-parameters}}{{#vendorExtensions.x-group-parameters}}{{#hasParams}}
|
||||
{{#returnType}}{{#asyncNative}}CompletableFuture<{{{returnType}}}>{{/asyncNative}}{{^asyncNative}}{{{returnType}}}{{/asyncNative}} result = {{/returnType}}{{^returnType}}{{#asyncNative}}CompletableFuture<Void> result = {{/asyncNative}}{{/returnType}}apiInstance.{{{operationId}}}({{#allParams}}{{{paramName}}}{{#hasMore}}, {{/hasMore}}{{/allParams}});
|
||||
{{/vendorExtensions.x-group-parameters}}
|
||||
{{#vendorExtensions.x-group-parameters}}
|
||||
{{#hasParams}}
|
||||
API{{operationId}}Request request = API{{operationId}}Request.newBuilder(){{#allParams}}
|
||||
.{{paramName}}({{paramName}}){{/allParams}}
|
||||
.build();{{/hasParams}}
|
||||
{{#returnType}}{{#asyncNative}}CompletableFuture<{{{returnType}}}>{{/asyncNative}}{{^asyncNative}}{{{returnType}}}{{/asyncNative}} result = {{/returnType}}{{^returnType}}{{#asyncNative}}CompletableFuture<Void> result = {{/asyncNative}}{{/returnType}}apiInstance.{{operationId}}({{#hasParams}}request{{/hasParams}});{{/vendorExtensions.x-group-parameters}}{{#returnType}}
|
||||
System.out.println(result);{{/returnType}}
|
||||
.build();
|
||||
{{/hasParams}}
|
||||
{{#returnType}}{{#asyncNative}}CompletableFuture<{{{returnType}}}>{{/asyncNative}}{{^asyncNative}}{{{returnType}}}{{/asyncNative}} result = {{/returnType}}{{^returnType}}{{#asyncNative}}CompletableFuture<Void> result = {{/asyncNative}}{{/returnType}}apiInstance.{{operationId}}({{#hasParams}}request{{/hasParams}});
|
||||
{{/vendorExtensions.x-group-parameters}}
|
||||
{{#returnType}}
|
||||
System.out.println(result{{#asyncNative}}.get(){{/asyncNative}});
|
||||
{{/returnType}}
|
||||
} catch (ApiException e) {
|
||||
System.err.println("Exception when calling {{{classname}}}#{{{operationId}}}");
|
||||
System.err.println("Status code: " + e.getCode());
|
||||
@@ -124,6 +131,7 @@ All URIs are relative to *{{basePath}}*
|
||||
Class | Method | HTTP request | Description
|
||||
------------ | ------------- | ------------- | -------------
|
||||
{{#apiInfo}}{{#apis}}{{#operations}}{{#operation}}*{{classname}}* | [**{{operationId}}**]({{apiDocPath}}{{classname}}.md#{{operationId}}) | **{{httpMethod}}** {{path}} | {{#summary}}{{summary}}{{/summary}}
|
||||
*{{classname}}* | [**{{operationId}}WithHttpInfo**]({{apiDocPath}}{{classname}}.md#{{operationId}}WithHttpInfo) | **{{httpMethod}}** {{path}} | {{#summary}}{{summary}}{{/summary}}
|
||||
{{/operation}}{{/operations}}{{/apis}}{{/apiInfo}}
|
||||
|
||||
## Documentation for Models
|
||||
|
||||
@@ -3,9 +3,7 @@ package {{package}};
|
||||
|
||||
import {{invokerPackage}}.ApiClient;
|
||||
import {{invokerPackage}}.ApiException;
|
||||
{{^asyncNative}}
|
||||
import {{invokerPackage}}.ApiResponse;
|
||||
{{/asyncNative}}
|
||||
import {{invokerPackage}}.Pair;
|
||||
|
||||
{{#imports}}
|
||||
@@ -57,6 +55,15 @@ public class {{classname}} {
|
||||
memberVarReadTimeout = apiClient.getReadTimeout();
|
||||
memberVarResponseInterceptor = apiClient.getResponseInterceptor();
|
||||
}
|
||||
{{#asyncNative}}
|
||||
|
||||
private ApiException getApiException(String operationId, HttpResponse<String>localVarResponse) {
|
||||
return new ApiException(localVarResponse.statusCode(),
|
||||
operationId + " call received non-success response",
|
||||
localVarResponse.headers(),
|
||||
localVarResponse.body());
|
||||
}
|
||||
{{/asyncNative}}
|
||||
|
||||
{{#operation}}
|
||||
{{#vendorExtensions.x-group-parameters}}
|
||||
@@ -66,7 +73,7 @@ public class {{classname}} {
|
||||
* {{notes}}
|
||||
* @param {{operationId}}Request {@link API{{operationId}}Request}
|
||||
{{#returnType}}
|
||||
* @return {{returnType}}
|
||||
* @return {{#asyncNative}}CompletableFuture<{{/asyncNative}}{{returnType}}{{#asyncNative}}>{{/asyncNative}}
|
||||
{{/returnType}}
|
||||
* @throws ApiException if fails to make API call
|
||||
{{#isDeprecated}}
|
||||
@@ -86,13 +93,12 @@ public class {{classname}} {
|
||||
{{/allParams}}
|
||||
{{#returnType}}return {{/returnType}}{{^returnType}}{{#asyncNative}}return {{/asyncNative}}{{/returnType}}{{operationId}}({{#allParams}}{{paramName}}{{#hasMore}}, {{/hasMore}}{{/allParams}});
|
||||
}
|
||||
{{^asyncNative}}
|
||||
|
||||
/**
|
||||
* {{summary}}
|
||||
* {{notes}}
|
||||
* @param {{operationId}}Request {@link API{{operationId}}Request}
|
||||
* @return ApiResponse<{{#returnType}}{{returnType}}{{/returnType}}{{^returnType}}Void{{/returnType}}>
|
||||
* @return {{#asyncNative}}CompletableFuture<{{/asyncNative}}ApiResponse<{{#returnType}}{{returnType}}{{/returnType}}{{^returnType}}Void{{/returnType}}>{{#asyncNative}}>{{/asyncNative}}
|
||||
* @throws ApiException if fails to make API call
|
||||
{{#isDeprecated}}
|
||||
* @deprecated
|
||||
@@ -105,13 +111,12 @@ public class {{classname}} {
|
||||
{{#isDeprecated}}
|
||||
@Deprecated
|
||||
{{/isDeprecated}}
|
||||
public ApiResponse<{{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}Void{{/returnType}}> {{operationId}}WithHttpInfo(API{{operationId}}Request {{operationId}}Request) throws ApiException {
|
||||
public {{#asyncNative}}CompletableFuture<{{/asyncNative}}ApiResponse<{{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}Void{{/returnType}}>{{#asyncNative}}>{{/asyncNative}} {{operationId}}WithHttpInfo(API{{operationId}}Request {{operationId}}Request) throws ApiException {
|
||||
{{#allParams}}
|
||||
{{{dataType}}} {{paramName}} = {{operationId}}Request.{{paramName}}();
|
||||
{{/allParams}}
|
||||
return {{operationId}}WithHttpInfo({{#allParams}}{{paramName}}{{#hasMore}}, {{/hasMore}}{{/allParams}});
|
||||
}
|
||||
{{/asyncNative}}
|
||||
|
||||
{{/hasParams}}
|
||||
{{/vendorExtensions.x-group-parameters}}
|
||||
@@ -122,7 +127,7 @@ public class {{classname}} {
|
||||
* @param {{paramName}} {{description}}{{#required}} (required){{/required}}{{^required}} (optional{{^isContainer}}{{#defaultValue}}, default to {{.}}{{/defaultValue}}){{/isContainer}}{{/required}}
|
||||
{{/allParams}}
|
||||
{{#returnType}}
|
||||
* @return {{returnType}}
|
||||
* @return {{#asyncNative}}CompletableFuture<{{/asyncNative}}{{returnType}}{{#asyncNative}}>{{/asyncNative}}
|
||||
{{/returnType}}
|
||||
* @throws ApiException if fails to make API call
|
||||
{{#isDeprecated}}
|
||||
@@ -147,28 +152,23 @@ public class {{classname}} {
|
||||
try {
|
||||
HttpRequest.Builder localVarRequestBuilder = {{operationId}}RequestBuilder({{#allParams}}{{paramName}}{{#hasMore}}, {{/hasMore}}{{/allParams}});
|
||||
return memberVarHttpClient.sendAsync(
|
||||
localVarRequestBuilder.build(),
|
||||
HttpResponse.BodyHandlers.ofString()).thenComposeAsync(localVarResponse -> {
|
||||
if (localVarResponse.statusCode()/ 100 != 2) {
|
||||
return CompletableFuture.failedFuture(new ApiException(localVarResponse.statusCode(),
|
||||
"{{operationId}} call received non-success response",
|
||||
localVarResponse.headers(),
|
||||
localVarResponse.body())
|
||||
localVarRequestBuilder.build(),
|
||||
HttpResponse.BodyHandlers.ofString()).thenComposeAsync(localVarResponse -> {
|
||||
if (localVarResponse.statusCode()/ 100 != 2) {
|
||||
return CompletableFuture.failedFuture(getApiException("{{operationId}}", localVarResponse));
|
||||
}
|
||||
{{#returnType}}
|
||||
try {
|
||||
return CompletableFuture.completedFuture(
|
||||
memberVarObjectMapper.readValue(localVarResponse.body(), new TypeReference<{{{returnType}}}>() {})
|
||||
);
|
||||
} else {
|
||||
{{#returnType}}
|
||||
try {
|
||||
return CompletableFuture.completedFuture(
|
||||
memberVarObjectMapper.readValue(localVarResponse.body(), new TypeReference<{{{returnType}}}>() {})
|
||||
);
|
||||
} catch (IOException e) {
|
||||
return CompletableFuture.failedFuture(new ApiException(e));
|
||||
}
|
||||
{{/returnType}}
|
||||
{{^returnType}}
|
||||
return CompletableFuture.completedFuture(null);
|
||||
{{/returnType}}
|
||||
}
|
||||
} catch (IOException e) {
|
||||
return CompletableFuture.failedFuture(new ApiException(e));
|
||||
}
|
||||
{{/returnType}}
|
||||
{{^returnType}}
|
||||
return CompletableFuture.completedFuture(null);
|
||||
{{/returnType}}
|
||||
});
|
||||
}
|
||||
catch (ApiException e) {
|
||||
@@ -176,7 +176,6 @@ public class {{classname}} {
|
||||
}
|
||||
{{/asyncNative}}
|
||||
}
|
||||
{{^asyncNative}}
|
||||
|
||||
/**
|
||||
* {{summary}}
|
||||
@@ -184,7 +183,7 @@ public class {{classname}} {
|
||||
{{#allParams}}
|
||||
* @param {{paramName}} {{description}}{{#required}} (required){{/required}}{{^required}} (optional{{^isContainer}}{{#defaultValue}}, default to {{.}}{{/defaultValue}}){{/isContainer}}{{/required}}
|
||||
{{/allParams}}
|
||||
* @return ApiResponse<{{#returnType}}{{returnType}}{{/returnType}}{{^returnType}}Void{{/returnType}}>
|
||||
* @return {{#asyncNative}}CompletableFuture<{{/asyncNative}}ApiResponse<{{#returnType}}{{returnType}}{{/returnType}}{{^returnType}}Void{{/returnType}}>{{#asyncNative}}>{{/asyncNative}}
|
||||
* @throws ApiException if fails to make API call
|
||||
{{#isDeprecated}}
|
||||
* @deprecated
|
||||
@@ -197,7 +196,8 @@ public class {{classname}} {
|
||||
{{#isDeprecated}}
|
||||
@Deprecated
|
||||
{{/isDeprecated}}
|
||||
public ApiResponse<{{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}Void{{/returnType}}> {{operationId}}WithHttpInfo({{#allParams}}{{{dataType}}} {{paramName}}{{#hasMore}}, {{/hasMore}}{{/allParams}}) throws ApiException {
|
||||
public {{#asyncNative}}CompletableFuture<{{/asyncNative}}ApiResponse<{{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}Void{{/returnType}}>{{#asyncNative}}>{{/asyncNative}} {{operationId}}WithHttpInfo({{#allParams}}{{{dataType}}} {{paramName}}{{#hasMore}}, {{/hasMore}}{{/allParams}}) throws ApiException {
|
||||
{{^asyncNative}}
|
||||
HttpRequest.Builder localVarRequestBuilder = {{operationId}}RequestBuilder({{#allParams}}{{paramName}}{{#hasMore}}, {{/hasMore}}{{/allParams}});
|
||||
try {
|
||||
HttpResponse<InputStream> localVarResponse = memberVarHttpClient.send(
|
||||
@@ -224,8 +224,41 @@ public class {{classname}} {
|
||||
Thread.currentThread().interrupt();
|
||||
throw new ApiException(e);
|
||||
}
|
||||
{{/asyncNative}}
|
||||
{{#asyncNative}}
|
||||
try {
|
||||
HttpRequest.Builder localVarRequestBuilder = {{operationId}}RequestBuilder({{#allParams}}{{paramName}}{{#hasMore}}, {{/hasMore}}{{/allParams}});
|
||||
return memberVarHttpClient.sendAsync(
|
||||
localVarRequestBuilder.build(),
|
||||
HttpResponse.BodyHandlers.ofString()).thenComposeAsync(localVarResponse -> {
|
||||
if (localVarResponse.statusCode()/ 100 != 2) {
|
||||
return CompletableFuture.failedFuture(getApiException("{{operationId}}", localVarResponse));
|
||||
}
|
||||
{{#returnType}}
|
||||
try {
|
||||
return CompletableFuture.completedFuture(
|
||||
new ApiResponse<{{{returnType}}}>(
|
||||
localVarResponse.statusCode(),
|
||||
localVarResponse.headers().map(),
|
||||
memberVarObjectMapper.readValue(localVarResponse.body(), new TypeReference<{{{returnType}}}>() {}))
|
||||
);
|
||||
} catch (IOException e) {
|
||||
return CompletableFuture.failedFuture(new ApiException(e));
|
||||
}
|
||||
{{/returnType}}
|
||||
{{^returnType}}
|
||||
return CompletableFuture.completedFuture(
|
||||
new ApiResponse<Void>(localVarResponse.statusCode(), localVarResponse.headers().map(), null)
|
||||
);
|
||||
{{/returnType}}
|
||||
}
|
||||
);
|
||||
}
|
||||
catch (ApiException e) {
|
||||
return CompletableFuture.failedFuture(e);
|
||||
}
|
||||
{{/asyncNative}}
|
||||
}
|
||||
{{/asyncNative}}
|
||||
|
||||
private HttpRequest.Builder {{operationId}}RequestBuilder({{#allParams}}{{{dataType}}} {{paramName}}{{#hasMore}}, {{/hasMore}}{{/allParams}}) throws ApiException {
|
||||
{{#allParams}}
|
||||
|
||||
@@ -7,9 +7,7 @@ All URIs are relative to *{{basePath}}*
|
||||
Method | HTTP request | Description
|
||||
------------- | ------------- | -------------
|
||||
{{#operations}}{{#operation}}[**{{operationId}}**]({{classname}}.md#{{operationId}}) | **{{httpMethod}}** {{path}} | {{#summary}}{{summary}}{{/summary}}
|
||||
{{^asyncNative}}
|
||||
[**{{operationId}}WithHttpInfo**]({{classname}}.md#{{operationId}}) | **{{httpMethod}}** {{path}} | {{#summary}}{{summary}}{{/summary}}
|
||||
{{/asyncNative}}
|
||||
[**{{operationId}}WithHttpInfo**]({{classname}}.md#{{operationId}}WithHttpInfo) | **{{httpMethod}}** {{path}} | {{#summary}}{{summary}}{{/summary}}
|
||||
{{/operation}}{{/operations}}
|
||||
|
||||
{{#operations}}
|
||||
@@ -81,8 +79,11 @@ public class Example {
|
||||
.{{paramName}}({{paramName}}){{/allParams}}
|
||||
.build();
|
||||
{{/hasParams}}
|
||||
{{#returnType}}{{#asyncNative}}CompletableFuture<{{{returnType}}}>{{/asyncNative}}{{^asyncNative}}{{{returnType}}}{{/asyncNative}} result = {{/returnType}}{{^returnType}}{{#asyncNative}}CompletableFuture<Void> result = {{/asyncNative}}{{/returnType}}apiInstance.{{operationId}}({{#hasParams}}request{{/hasParams}});{{/vendorExtensions.x-group-parameters}}{{#returnType}}
|
||||
System.out.println(result);{{/returnType}}
|
||||
{{#returnType}}{{#asyncNative}}CompletableFuture<{{{returnType}}}>{{/asyncNative}}{{^asyncNative}}{{{returnType}}}{{/asyncNative}} result = {{/returnType}}{{^returnType}}{{#asyncNative}}CompletableFuture<Void> result = {{/asyncNative}}{{/returnType}}apiInstance.{{operationId}}({{#hasParams}}request{{/hasParams}});
|
||||
{{/vendorExtensions.x-group-parameters}}
|
||||
{{#returnType}}
|
||||
System.out.println(result{{#asyncNative}}.get(){{/asyncNative}});
|
||||
{{/returnType}}
|
||||
} catch (ApiException e) {
|
||||
System.err.println("Exception when calling {{{classname}}}#{{{operationId}}}");
|
||||
System.err.println("Status code: " + e.getCode());
|
||||
@@ -131,15 +132,14 @@ Name | Type | Description | Notes
|
||||
| **{{code}}** | {{message}} | {{#headers}} * {{baseName}} - {{description}} <br> {{/headers}}{{^headers.0}} - {{/headers.0}} |
|
||||
{{/responses}}
|
||||
{{/responses.0}}
|
||||
{{^asyncNative}}
|
||||
|
||||
## {{operationId}}WithHttpInfo
|
||||
|
||||
{{^vendorExtensions.x-group-parameters}}
|
||||
> ApiResponse<{{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}Void{{/returnType}}> {{operationId}} {{operationId}}WithHttpInfo({{#allParams}}{{{paramName}}}{{#hasMore}}, {{/hasMore}}{{/allParams}})
|
||||
> {{#asyncNative}}CompletableFuture<{{/asyncNative}}ApiResponse<{{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}Void{{/returnType}}>{{#asyncNative}}>{{/asyncNative}} {{operationId}} {{operationId}}WithHttpInfo({{#allParams}}{{{paramName}}}{{#hasMore}}, {{/hasMore}}{{/allParams}})
|
||||
{{/vendorExtensions.x-group-parameters}}
|
||||
{{#vendorExtensions.x-group-parameters}}
|
||||
> ApiResponse<{{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}Void{{/returnType}}> {{operationId}} {{operationId}}WithHttpInfo({{#hasParams}}{{operationId}}Request{{/hasParams}})
|
||||
> {{#asyncNative}}CompletableFuture<{{/asyncNative}}ApiResponse<{{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}Void{{/returnType}}>{{#asyncNative}}>{{/asyncNative}} {{operationId}} {{operationId}}WithHttpInfo({{#hasParams}}{{operationId}}Request{{/hasParams}})
|
||||
{{/vendorExtensions.x-group-parameters}}
|
||||
|
||||
{{summary}}{{#notes}}
|
||||
@@ -158,6 +158,9 @@ import {{{invokerPackage}}}.auth.*;{{/hasAuthMethods}}
|
||||
import {{{invokerPackage}}}.models.*;
|
||||
import {{{package}}}.{{{classname}}};{{#vendorExtensions.x-group-parameters}}
|
||||
import {{{package}}}.{{{classname}}}.*;{{/vendorExtensions.x-group-parameters}}
|
||||
{{#asyncNative}}
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
{{/asyncNative}}
|
||||
|
||||
public class Example {
|
||||
public static void main(String[] args) {
|
||||
@@ -189,7 +192,7 @@ public class Example {
|
||||
{{/allParams}}
|
||||
try {
|
||||
{{^vendorExtensions.x-group-parameters}}
|
||||
ApiResponse<{{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}Void{{/returnType}}> response = apiInstance.{{{operationId}}}WithHttpInfo({{#allParams}}{{{paramName}}}{{#hasMore}}, {{/hasMore}}{{/allParams}});
|
||||
{{#asyncNative}}CompletableFuture<{{/asyncNative}}ApiResponse<{{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}Void{{/returnType}}>{{#asyncNative}}>{{/asyncNative}} response = apiInstance.{{{operationId}}}WithHttpInfo({{#allParams}}{{{paramName}}}{{#hasMore}}, {{/hasMore}}{{/allParams}});
|
||||
{{/vendorExtensions.x-group-parameters}}
|
||||
{{#vendorExtensions.x-group-parameters}}
|
||||
{{#hasParams}}
|
||||
@@ -197,18 +200,27 @@ public class Example {
|
||||
.{{paramName}}({{paramName}}){{/allParams}}
|
||||
.build();
|
||||
{{/hasParams}}
|
||||
ApiResponse<{{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}Void{{/returnType}}> response = apiInstance.{{{operationId}}}WithHttpInfo({{#hasParams}}request{{/hasParams}});
|
||||
{{#asyncNative}}CompletableFuture<{{/asyncNative}}ApiResponse<{{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}Void{{/returnType}}>{{#asyncNative}}>{{/asyncNative}} response = apiInstance.{{{operationId}}}WithHttpInfo({{#hasParams}}request{{/hasParams}});
|
||||
{{/vendorExtensions.x-group-parameters}}
|
||||
System.out.println("Status code: " + response.getStatusCode());
|
||||
System.out.println("Response headers: " + response.getHeaders().toString());
|
||||
System.out.println("Status code: " + response{{#asyncNative}}.get(){{/asyncNative}}.getStatusCode());
|
||||
System.out.println("Response headers: " + response{{#asyncNative}}.get(){{/asyncNative}}.getHeaders());
|
||||
{{#returnType}}
|
||||
System.out.println("Response body: " + response.getData().toString());
|
||||
System.out.println("Response body: " + response{{#asyncNative}}.get(){{/asyncNative}}.getData());
|
||||
{{/returnType}}
|
||||
{{#asyncNative}}
|
||||
} catch (InterruptedException | ExecutionException e) {
|
||||
ApiException apiException = (ApiException)e.getCause();
|
||||
System.err.println("Exception when calling {{{classname}}}#{{{operationId}}}");
|
||||
System.err.println("Status code: " + apiException.getCode());
|
||||
System.err.println("Response headers: " + apiException.getResponseHeaders());
|
||||
System.err.println("Reason: " + apiException.getResponseBody());
|
||||
e.printStackTrace();
|
||||
{{/asyncNative}}
|
||||
} catch (ApiException e) {
|
||||
System.err.println("Exception when calling {{{classname}}}#{{{operationId}}}");
|
||||
System.err.println("Status code: " + e.getCode());
|
||||
System.err.println("Reason: " + e.getResponseBody());
|
||||
System.err.println("Response headers: " + e.getResponseHeaders());
|
||||
System.err.println("Reason: " + e.getResponseBody());
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
@@ -232,8 +244,8 @@ Name | Type | Description | Notes
|
||||
|
||||
### Return type
|
||||
|
||||
{{#returnType}}ApiResponse<{{#returnTypeIsPrimitive}}**{{returnType}}**{{/returnTypeIsPrimitive}}{{^returnTypeIsPrimitive}}[**{{returnType}}**]({{returnBaseType}}.md){{/returnTypeIsPrimitive}}>{{/returnType}}
|
||||
{{^returnType}}ApiResponse<Void>{{/returnType}}
|
||||
{{#returnType}}{{#asyncNative}}CompletableFuture<{{/asyncNative}}ApiResponse<{{#returnTypeIsPrimitive}}**{{returnType}}**{{/returnTypeIsPrimitive}}{{^returnTypeIsPrimitive}}[**{{returnType}}**]({{returnBaseType}}.md){{/returnTypeIsPrimitive}}>{{#asyncNative}}>{{/asyncNative}}{{/returnType}}
|
||||
{{^returnType}}{{#asyncNative}}CompletableFuture<{{/asyncNative}}ApiResponse<Void>{{#asyncNative}}>{{/asyncNative}}{{/returnType}}
|
||||
|
||||
### Authorization
|
||||
|
||||
@@ -252,7 +264,6 @@ Name | Type | Description | Notes
|
||||
| **{{code}}** | {{message}} | {{#headers}} * {{baseName}} - {{description}} <br> {{/headers}}{{^headers.0}} - {{/headers.0}} |
|
||||
{{/responses}}
|
||||
{{/responses.0}}
|
||||
{{/asyncNative}}
|
||||
{{#vendorExtensions.x-group-parameters}}{{#hasParams}}
|
||||
|
||||
<a name="API{{operationId}}Request"></a>
|
||||
|
||||
@@ -530,7 +530,9 @@ public class ApiClient {
|
||||
loggingInterceptor.setLevel(Level.BODY);
|
||||
httpClient = httpClient.newBuilder().addInterceptor(loggingInterceptor).build();
|
||||
} else {
|
||||
httpClient.interceptors().remove(loggingInterceptor);
|
||||
final OkHttpClient.Builder builder = httpClient.newBuilder();
|
||||
builder.interceptors().remove(loggingInterceptor);
|
||||
httpClient = builder.build();
|
||||
loggingInterceptor = null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -73,7 +73,7 @@ public class {{classname}} {
|
||||
{{#isDeprecated}}
|
||||
@Deprecated
|
||||
{{/isDeprecated}}
|
||||
public {{#returnType}}{{{returnType}}} {{/returnType}}{{^returnType}}void {{/returnType}}{{operationId}}({{#allParams}}{{{dataType}}} {{paramName}}{{#hasMore}}, {{/hasMore}}{{/allParams}}) throws RestClientException {
|
||||
public {{#returnType}}{{{returnType}}} {{/returnType}}{{^returnType}}void {{/returnType}}{{operationId}}({{#allParams}}{{#isFile}}{{#useAbstractionForFiles}}{{#collectionFormat}}java.util.Collection<org.springframework.core.io.Resource>{{/collectionFormat}}{{^collectionFormat}}org.springframework.core.io.Resource{{/collectionFormat}}{{/useAbstractionForFiles}}{{^useAbstractionForFiles}}{{{dataType}}}{{/useAbstractionForFiles}}{{/isFile}}{{^isFile}}{{{dataType}}}{{/isFile}} {{paramName}}{{#hasMore}}, {{/hasMore}}{{/allParams}}) throws RestClientException {
|
||||
{{#returnType}}
|
||||
return {{operationId}}WithHttpInfo({{#allParams}}{{paramName}}{{#hasMore}}, {{/hasMore}}{{/allParams}}).getBody();
|
||||
{{/returnType}}
|
||||
@@ -101,7 +101,7 @@ public class {{classname}} {
|
||||
{{#isDeprecated}}
|
||||
@Deprecated
|
||||
{{/isDeprecated}}
|
||||
public ResponseEntity<{{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}Void{{/returnType}}> {{operationId}}WithHttpInfo({{#allParams}}{{{dataType}}} {{paramName}}{{#hasMore}}, {{/hasMore}}{{/allParams}}) throws RestClientException {
|
||||
public ResponseEntity<{{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}Void{{/returnType}}> {{operationId}}WithHttpInfo({{#allParams}}{{#isFile}}{{#useAbstractionForFiles}}{{#collectionFormat}}java.util.Collection<org.springframework.core.io.Resource>{{/collectionFormat}}{{^collectionFormat}}org.springframework.core.io.Resource{{/collectionFormat}}{{/useAbstractionForFiles}}{{^useAbstractionForFiles}}{{{dataType}}}{{/useAbstractionForFiles}}{{/isFile}}{{^isFile}}{{{dataType}}}{{/isFile}} {{paramName}}{{#hasMore}}, {{/hasMore}}{{/allParams}}) throws RestClientException {
|
||||
Object postBody = {{#bodyParam}}{{paramName}}{{/bodyParam}}{{^bodyParam}}null{{/bodyParam}};
|
||||
{{#allParams}}{{#required}}
|
||||
// verify the required parameter '{{paramName}}' is set
|
||||
@@ -131,7 +131,7 @@ public class {{classname}} {
|
||||
{{/hasMore}}{{/cookieParams}}{{/hasCookieParams}}{{#hasFormParams}}
|
||||
|
||||
{{#formParams}}if ({{paramName}} != null)
|
||||
formParams.{{^collectionFormat}}add{{/collectionFormat}}{{#collectionFormat}}put{{/collectionFormat}}("{{baseName}}", {{#isFile}}{{^collectionFormat}}new FileSystemResource({{paramName}}){{/collectionFormat}}{{/isFile}}{{#isFile}}{{#collectionFormat}}{{paramName}}.stream().map(FileSystemResource::new).collect(Collectors.toList()){{/collectionFormat}}{{/isFile}}{{^isFile}}{{paramName}}{{/isFile}});{{#hasMore}}
|
||||
formParams.{{^collectionFormat}}add{{/collectionFormat}}{{#collectionFormat}}put{{/collectionFormat}}("{{baseName}}", {{#isFile}}{{^collectionFormat}}{{#useAbstractionForFiles}}{{paramName}}{{/useAbstractionForFiles}}{{^useAbstractionForFiles}}new FileSystemResource({{paramName}}){{/useAbstractionForFiles}}{{/collectionFormat}}{{/isFile}}{{#isFile}}{{#collectionFormat}}{{paramName}}.stream(){{^useAbstractionForFiles}}.map(FileSystemResource::new){{/useAbstractionForFiles}}.collect(Collectors.toList()){{/collectionFormat}}{{/isFile}}{{^isFile}}{{paramName}}{{/isFile}});{{#hasMore}}
|
||||
{{/hasMore}}{{/formParams}}{{/hasFormParams}}
|
||||
|
||||
final String[] accepts = { {{#hasProduces}}
|
||||
|
||||
@@ -34,7 +34,7 @@ public class {{classname}}Test {
|
||||
@Test
|
||||
public void {{operationId}}Test() {
|
||||
{{#allParams}}
|
||||
{{{dataType}}} {{paramName}} = null;
|
||||
{{#isFile}}{{#useAbstractionForFiles}}{{#collectionFormat}}java.util.Collection<org.springframework.core.io.Resource>{{/collectionFormat}}{{^collectionFormat}}org.springframework.core.io.Resource{{/collectionFormat}}{{/useAbstractionForFiles}}{{^useAbstractionForFiles}}{{{dataType}}}{{/useAbstractionForFiles}}{{/isFile}}{{^isFile}}{{{dataType}}}{{/isFile}} {{paramName}} = null;
|
||||
{{/allParams}}
|
||||
{{#returnType}}{{{returnType}}} response = {{/returnType}}api.{{operationId}}({{#allParams}}{{paramName}}{{#hasMore}}, {{/hasMore}}{{/allParams}});
|
||||
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
{{classname}}.JSON_PROPERTY_{{nameInSnakeCase}}{{^-last}},{{/-last}}
|
||||
{{/vars}}
|
||||
})
|
||||
@JsonTypeName("{{name}}")
|
||||
{{/jackson}}
|
||||
{{>additionalModelTypeAnnotations}}{{>generatedAnnotation}}{{#discriminator}}{{>typeInfoAnnotation}}{{/discriminator}}{{>xmlAnnotation}}
|
||||
public class {{classname}} {{#parent}}extends {{{parent}}} {{/parent}}{{#vendorExtensions.x-implements}}{{#-first}}implements {{{.}}}{{/-first}}{{^-first}}, {{{.}}}{{/-first}}{{#-last}} {{/-last}}{{/vendorExtensions.x-implements}}{
|
||||
|
||||
@@ -1,8 +1,16 @@
|
||||
{{#jackson}}
|
||||
|
||||
@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, include = JsonTypeInfo.As.EXISTING_PROPERTY, property = "{{{discriminator.propertyBaseName}}}", visible = true)
|
||||
{{#discriminator.mappedModels}}
|
||||
{{#-first}}
|
||||
@JsonSubTypes({
|
||||
{{#discriminator.mappedModels}}
|
||||
{{/-first}}
|
||||
@JsonSubTypes.Type(value = {{modelName}}.class, name = "{{^vendorExtensions.x-discriminator-value}}{{mappingName}}{{/vendorExtensions.x-discriminator-value}}{{#vendorExtensions.x-discriminator-value}}{{{vendorExtensions.x-discriminator-value}}}{{/vendorExtensions.x-discriminator-value}}"),
|
||||
{{/discriminator.mappedModels}}
|
||||
}){{/jackson}}
|
||||
{{#-last}}
|
||||
})
|
||||
{{/-last}}
|
||||
{{/discriminator.mappedModels}}
|
||||
{{#isClassnameSanitized}}
|
||||
@JsonTypeName("{{name}}")
|
||||
{{/isClassnameSanitized}}
|
||||
{{/jackson}}
|
||||
|
||||
@@ -38,6 +38,7 @@ import org.springframework.web.multipart.MultipartFile;
|
||||
import org.springframework.web.server.ServerWebExchange;
|
||||
import reactor.core.publisher.Flux;
|
||||
import reactor.core.publisher.Mono;
|
||||
import org.springframework.http.codec.multipart.Part;
|
||||
{{/reactive}}
|
||||
|
||||
{{#useBeanValidation}}
|
||||
@@ -135,7 +136,7 @@ public interface {{classname}} {
|
||||
}
|
||||
|
||||
// Override this method
|
||||
{{#jdk8-default-interface}}default {{/jdk8-default-interface}} {{#responseWrapper}}{{.}}<{{/responseWrapper}}ResponseEntity<{{>returnTypes}}>{{#responseWrapper}}>{{/responseWrapper}} {{operationId}}({{#allParams}}{{^isFile}}{{^isBodyParam}}{{>optionalDataType}}{{/isBodyParam}}{{#isBodyParam}}{{^reactive}}{{{dataType}}}{{/reactive}}{{#reactive}}{{^isListContainer}}Mono{{/isListContainer}}{{#isListContainer}}Flux{{/isListContainer}}<{{{baseType}}}>{{/reactive}}{{/isBodyParam}}{{/isFile}}{{#isFile}}MultipartFile{{/isFile}} {{paramName}}{{#hasMore}}, {{/hasMore}}{{/allParams}}{{#reactive}}{{#hasParams}}, {{/hasParams}}ServerWebExchange exchange{{/reactive}}){{#unhandledException}} throws Exception{{/unhandledException}} {
|
||||
{{#jdk8-default-interface}}default {{/jdk8-default-interface}} {{#responseWrapper}}{{.}}<{{/responseWrapper}}ResponseEntity<{{>returnTypes}}>{{#responseWrapper}}>{{/responseWrapper}} {{operationId}}({{#allParams}}{{^isFile}}{{^isBodyParam}}{{>optionalDataType}}{{/isBodyParam}}{{#isBodyParam}}{{^reactive}}{{{dataType}}}{{/reactive}}{{#reactive}}{{^isListContainer}}Mono{{/isListContainer}}{{#isListContainer}}Flux{{/isListContainer}}<{{{baseType}}}>{{/reactive}}{{/isBodyParam}}{{/isFile}}{{#isFile}}{{#reactive}}Flux<Part>{{/reactive}}{{^reactive}}MultipartFile{{/reactive}}{{/isFile}} {{paramName}}{{#hasMore}}, {{/hasMore}}{{/allParams}}{{#reactive}}{{#hasParams}}, {{/hasParams}}ServerWebExchange exchange{{/reactive}}){{#unhandledException}} throws Exception{{/unhandledException}} {
|
||||
{{/delegate-method}}
|
||||
{{^isDelegate}}
|
||||
{{>methodBody}}
|
||||
|
||||
@@ -16,6 +16,7 @@ import org.springframework.web.multipart.MultipartFile;
|
||||
import org.springframework.web.server.ServerWebExchange;
|
||||
import reactor.core.publisher.Flux;
|
||||
import reactor.core.publisher.Mono;
|
||||
import org.springframework.http.codec.multipart.Part;
|
||||
{{/reactive}}
|
||||
|
||||
import java.util.List;
|
||||
@@ -67,7 +68,7 @@ public interface {{classname}}Delegate {
|
||||
{{/externalDocs}}
|
||||
* @see {{classname}}#{{operationId}}
|
||||
*/
|
||||
{{#jdk8-default-interface}}default {{/jdk8-default-interface}}{{#responseWrapper}}{{.}}<{{/responseWrapper}}ResponseEntity<{{>returnTypes}}>{{#responseWrapper}}>{{/responseWrapper}} {{operationId}}({{#allParams}}{{^isFile}}{{^isBodyParam}}{{>optionalDataType}}{{/isBodyParam}}{{#isBodyParam}}{{^reactive}}{{{dataType}}}{{/reactive}}{{#reactive}}{{^isListContainer}}Mono{{/isListContainer}}{{#isListContainer}}Flux{{/isListContainer}}<{{{baseType}}}>{{/reactive}}{{/isBodyParam}}{{/isFile}}{{#isFile}}{{#isListContainer}}List<{{/isListContainer}}MultipartFile{{#isListContainer}}>{{/isListContainer}}{{/isFile}} {{paramName}}{{#hasMore}},
|
||||
{{#jdk8-default-interface}}default {{/jdk8-default-interface}}{{#responseWrapper}}{{.}}<{{/responseWrapper}}ResponseEntity<{{>returnTypes}}>{{#responseWrapper}}>{{/responseWrapper}} {{operationId}}({{#allParams}}{{^isFile}}{{^isBodyParam}}{{>optionalDataType}}{{/isBodyParam}}{{#isBodyParam}}{{^reactive}}{{{dataType}}}{{/reactive}}{{#reactive}}{{^isListContainer}}Mono{{/isListContainer}}{{#isListContainer}}Flux{{/isListContainer}}<{{{baseType}}}>{{/reactive}}{{/isBodyParam}}{{/isFile}}{{#isFile}}{{#isListContainer}}List<{{/isListContainer}}{{#reactive}}Flux<Part>{{/reactive}}{{^reactive}}MultipartFile{{/reactive}}{{#isListContainer}}>{{/isListContainer}}{{/isFile}} {{paramName}}{{#hasMore}},
|
||||
{{/hasMore}}{{/allParams}}{{#reactive}}{{#hasParams}},
|
||||
{{/hasParams}}ServerWebExchange exchange{{/reactive}}){{#unhandledException}} throws Exception{{/unhandledException}}{{^jdk8-default-interface}};{{/jdk8-default-interface}}{{#jdk8-default-interface}} {
|
||||
{{>methodBody}}
|
||||
|
||||
@@ -1 +1 @@
|
||||
{{#isFormParam}}{{^isFile}}@ApiParam(value = "{{{description}}}"{{#required}}, required=true{{/required}}{{#allowableValues}}, allowableValues="{{#values}}{{{.}}}{{^-last}}, {{/-last}}{{#-last}}{{/-last}}{{/values}}"{{/allowableValues}}{{^isContainer}}{{#defaultValue}}, defaultValue={{^isString}}"{{/isString}}{{#isString}}{{#isEnum}}"{{/isEnum}}{{/isString}}{{{defaultValue}}}{{^isString}}"{{/isString}}{{#isString}}{{#isEnum}}"{{/isEnum}}{{/isString}}{{/defaultValue}}{{/isContainer}}) {{#useBeanValidation}}@Valid{{/useBeanValidation}} @RequestPart(value = "{{baseName}}"{{#required}}, required = true{{/required}}{{^required}}, required = false{{/required}}) {{{dataType}}} {{paramName}}{{/isFile}}{{#isFile}}@ApiParam(value = "{{{description}}}") {{#useBeanValidation}}@Valid{{/useBeanValidation}} @RequestPart(value = "{{baseName}}"{{#required}}, required = true{{/required}}{{^required}}, required = false{{/required}}) {{#isListContainer}}List<{{/isListContainer}}MultipartFile{{#isListContainer}}>{{/isListContainer}} {{baseName}}{{/isFile}}{{/isFormParam}}
|
||||
{{#isFormParam}}{{^isFile}}@ApiParam(value = "{{{description}}}"{{#required}}, required=true{{/required}}{{#allowableValues}}, allowableValues="{{#values}}{{{.}}}{{^-last}}, {{/-last}}{{#-last}}{{/-last}}{{/values}}"{{/allowableValues}}{{^isContainer}}{{#defaultValue}}, defaultValue={{^isString}}"{{/isString}}{{#isString}}{{#isEnum}}"{{/isEnum}}{{/isString}}{{{defaultValue}}}{{^isString}}"{{/isString}}{{#isString}}{{#isEnum}}"{{/isEnum}}{{/isString}}{{/defaultValue}}{{/isContainer}}) {{#useBeanValidation}}@Valid{{/useBeanValidation}} @RequestPart(value = "{{baseName}}"{{#required}}, required = true{{/required}}{{^required}}, required = false{{/required}}) {{{dataType}}} {{paramName}}{{/isFile}}{{#isFile}}@ApiParam(value = "{{{description}}}") {{#useBeanValidation}}@Valid{{/useBeanValidation}} @RequestPart(value = "{{baseName}}"{{#required}}, required = true{{/required}}{{^required}}, required = false{{/required}}) {{#isListContainer}}List<{{/isListContainer}}{{#reactive}}Flux<Part>{{/reactive}}{{^reactive}}MultipartFile{{/reactive}}{{#isListContainer}}>{{/isListContainer}} {{baseName}}{{/isFile}}{{/isFormParam}}
|
||||
@@ -1 +1 @@
|
||||
{{#isFormParam}}{{^isFile}}@ApiParam(value = "{{{description}}}"{{#required}}, required=true{{/required}} {{#allowableValues}}, allowableValues="{{{allowableValues}}}"{{/allowableValues}}{{^isContainer}}{{#defaultValue}}, defaultValue={{^isString}}"{{/isString}}{{#isString}}{{#isEnum}}"{{/isEnum}}{{/isString}}{{{defaultValue}}}{{^isString}}"{{/isString}}{{#isString}}{{#isEnum}}"{{/isEnum}}{{/isString}}{{/defaultValue}}{{/isContainer}}) @RequestParam(value="{{baseName}}"{{#required}}, required=true{{/required}}{{^required}}, required=false{{/required}}) {{{dataType}}} {{paramName}}{{/isFile}}{{#isFile}}@ApiParam(value = "{{{description}}}") @RequestParam("{{baseName}}") {{#isListContainer}}List<{{/isListContainer}}MultipartFile{{#isListContainer}}>{{/isListContainer}} {{paramName}}{{/isFile}}{{/isFormParam}}
|
||||
{{#isFormParam}}{{^isFile}}@ApiParam(value = "{{{description}}}"{{#required}}, required=true{{/required}} {{#allowableValues}}, allowableValues="{{{allowableValues}}}"{{/allowableValues}}{{^isContainer}}{{#defaultValue}}, defaultValue={{^isString}}"{{/isString}}{{#isString}}{{#isEnum}}"{{/isEnum}}{{/isString}}{{{defaultValue}}}{{^isString}}"{{/isString}}{{#isString}}{{#isEnum}}"{{/isEnum}}{{/isString}}{{/defaultValue}}{{/isContainer}}) @RequestParam(value="{{baseName}}"{{#required}}, required=true{{/required}}{{^required}}, required=false{{/required}}) {{{dataType}}} {{paramName}}{{/isFile}}{{#isFile}}@ApiParam(value = "{{{description}}}") @RequestParam("{{baseName}}") {{#isListContainer}}List<{{/isListContainer}}{{#reactive}}Flux<Part>{{/reactive}}{{^reactive}}MultipartFile{{/reactive}}{{#isListContainer}}>{{/isListContainer}} {{paramName}}{{/isFile}}{{/isFormParam}}
|
||||
@@ -3,7 +3,8 @@
|
||||
{
|
||||
"name": "{{baseName}}",
|
||||
"type": {{^required}}["null", {{/required}}{{>typeProperty}}{{^required}}]{{/required}},
|
||||
"doc": "{{{description}}}"
|
||||
"doc": "{{{description}}}"{{^required}},
|
||||
"default": null{{/required}}
|
||||
}{{^-last}},{{/-last}}
|
||||
{{/vars}}
|
||||
]
|
||||
]
|
||||
|
||||
@@ -20,6 +20,10 @@
|
||||
namespace {{this}} {
|
||||
{{/modelNamespaceDeclarations}}
|
||||
|
||||
{{#vendorExtensions.x-has-forward-declarations}}
|
||||
{{#vendorExtensions.x-forward-declarations}}{{.}}
|
||||
{{/vendorExtensions.x-forward-declarations}}
|
||||
{{/vendorExtensions.x-has-forward-declarations}}
|
||||
{{#isEnum}}
|
||||
class {{declspec}} {{classname}}
|
||||
: public {{#parent}}{{{parent}}}{{/parent}}{{^parent}}ModelBase{{/parent}}
|
||||
|
||||
@@ -418,12 +418,13 @@ namespace {{packageName}}.{{apiPackage}}
|
||||
"{{{mediaType}}}"{{#hasMore}},{{/hasMore}}
|
||||
{{/produces}}
|
||||
};
|
||||
|
||||
foreach (var _contentType in _contentTypes)
|
||||
localVarRequestOptions.HeaderParameters.Add("Content-Type", _contentType);
|
||||
|
||||
foreach (var _accept in _accepts)
|
||||
localVarRequestOptions.HeaderParameters.Add("Accept", _accept);
|
||||
|
||||
|
||||
var localVarContentType = {{packageName}}.Client.ClientUtils.SelectHeaderContentType(_contentTypes);
|
||||
if (localVarContentType != null) localVarRequestOptions.HeaderParameters.Add("Content-Type", localVarContentType);
|
||||
|
||||
var localVarAccept = {{packageName}}.Client.ClientUtils.SelectHeaderAccept(_accepts);
|
||||
if (localVarAccept != null) localVarRequestOptions.HeaderParameters.Add("Accept", localVarAccept);
|
||||
|
||||
{{#pathParams}}
|
||||
{{#required}}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
class {{classname}} {
|
||||
{{#vars}}
|
||||
{{#description}}/* {{{description}}} */{{/description}}
|
||||
{{{dataType}}} {{name}} = {{{defaultValue}}};
|
||||
{{^defaultValue}}{{{dataType}}} {{name}} = null;{{/defaultValue}}{{#defaultValue}}{{{dataType}}} {{name}} = {{defaultValue}};{{/defaultValue}}
|
||||
{{#allowableValues}}
|
||||
{{#min}} // range from {{min}} to {{max}}{{/min}}//{{^min}}enum {{name}}Enum { {{#values}} {{.}}, {{/values}} };{{/min}}{
|
||||
{{/allowableValues}}
|
||||
@@ -58,14 +58,24 @@ class {{classname}} {
|
||||
return {
|
||||
{{#vars}}
|
||||
{{#isDateTime}}
|
||||
'{{baseName}}': {{name}} == null ? '' : {{name}}.toUtc().toIso8601String(){{^-last}},{{/-last}}
|
||||
'{{baseName}}': {{name}} == null ? '' : {{name}}.toUtc().toIso8601String(){{^-last}},{{/-last}}
|
||||
{{/isDateTime}}
|
||||
{{#isDate}}
|
||||
'{{baseName}}': {{name}} == null ? '' : {{name}}.toUtc().toIso8601String(){{^-last}},{{/-last}}
|
||||
'{{baseName}}': {{name}} == null ? '' : {{name}}.toUtc().toIso8601String(){{^-last}},{{/-last}}
|
||||
{{/isDate}}
|
||||
{{^isDateTime}}
|
||||
{{^isDate}}
|
||||
'{{baseName}}': {{name}}{{^-last}},{{/-last}}
|
||||
{{#complexType}}
|
||||
{{#isListContainer}}
|
||||
'{{baseName}}': {{name}} == null ? null : {{name}}.map((item) => item.toJson()).toList(){{^-last}},{{/-last}}
|
||||
{{/isListContainer}}
|
||||
{{^isListContainer}}
|
||||
'{{baseName}}': {{name}} == null ? null : {{name}}.toJson(){{^-last}},{{/-last}}
|
||||
{{/isListContainer}}
|
||||
{{/complexType}}
|
||||
{{^complexType}}
|
||||
'{{baseName}}': {{name}}{{^-last}},{{/-last}}
|
||||
{{/complexType}}
|
||||
{{/isDate}}
|
||||
{{/isDateTime}}
|
||||
{{/vars}}
|
||||
|
||||
@@ -3,6 +3,7 @@ library {{pubName}}.api;
|
||||
import 'dart:async';
|
||||
import 'dart:convert';
|
||||
import 'package:http/http.dart';
|
||||
import 'package:meta/meta.dart';
|
||||
|
||||
part 'api_client.dart';
|
||||
part 'api_helper.dart';
|
||||
|
||||
@@ -1,15 +1,19 @@
|
||||
class {{classname}} {
|
||||
{{#vars}}
|
||||
{{#description}}/* {{{description}}} */{{/description}}
|
||||
{{{dataType}}} {{name}} = {{{defaultValue}}};
|
||||
{{#description}}/// {{{description}}}{{/description}}
|
||||
{{^isEnum}}
|
||||
{{^defaultValue}}{{{dataType}}} {{name}};{{/defaultValue}}{{#defaultValue}}{{{dataType}}} {{name}} = {{defaultValue}};{{/defaultValue}}
|
||||
{{/isEnum}}
|
||||
{{#isEnum}}
|
||||
{{#allowableValues}}
|
||||
{{#min}} // range from {{min}} to {{max}}{{/min}}//{{^min}}enum {{name}}Enum { {{#values}} {{.}}, {{/values}} };{{/min}}{
|
||||
{{#min}} // range from {{min}} to {{max}}{{/min}}{{classname}}{{{enumName}}} {{name}}{{#required}} = {{{defaultValue}}}{{/required}}{{^required}}{{/required}};
|
||||
{{/allowableValues}}
|
||||
{{/isEnum}}
|
||||
{{/vars}}
|
||||
|
||||
{{classname}}({
|
||||
{{#vars}}
|
||||
this.{{name}},
|
||||
{{#required}}@required this.{{name}}{{/required}}{{^required}}this.{{name}}{{#defaultValue}} = {{defaultValue}}{{/defaultValue}}{{/required}},
|
||||
{{/vars}}
|
||||
});
|
||||
|
||||
@@ -37,7 +41,20 @@ class {{classname}} {
|
||||
{{#isListContainer}}
|
||||
{{name}} = (json['{{baseName}}'] == null) ?
|
||||
null :
|
||||
{{#items.isListContainer}}
|
||||
(json['{{baseName}}'] as List).map(
|
||||
(e) => e == null ? null :
|
||||
{{#items.complexType}}
|
||||
{{items.complexType}}.listFromJson(json['{{baseName}}'])
|
||||
{{/items.complexType}}
|
||||
{{^items.complexType}}
|
||||
(e as List).cast<{{items.items.dataType}}>()
|
||||
{{/items.complexType}}
|
||||
).toList();
|
||||
{{/items.isListContainer}}
|
||||
{{^items.isListContainer}}
|
||||
{{complexType}}.listFromJson(json['{{baseName}}']);
|
||||
{{/items.isListContainer}}
|
||||
{{/isListContainer}}
|
||||
{{^isListContainer}}
|
||||
{{#isMapContainer}}
|
||||
@@ -78,7 +95,12 @@ class {{classname}} {
|
||||
json['{{baseName}}'].toDouble();
|
||||
{{/isDouble}}
|
||||
{{^isDouble}}
|
||||
{{^isEnum}}
|
||||
{{name}} = json['{{baseName}}'];
|
||||
{{/isEnum}}
|
||||
{{#isEnum}}
|
||||
{{name}} = {{classname}}{{{enumName}}}.fromJson(json['{{baseName}}']);
|
||||
{{/isEnum}}
|
||||
{{/isDouble}}
|
||||
{{/isMapContainer}}
|
||||
{{/isListContainer}}
|
||||
@@ -89,7 +111,7 @@ class {{classname}} {
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
Map <String, dynamic> json = {};
|
||||
Map<String, dynamic> json = {};
|
||||
{{#vars}}
|
||||
{{^isNullable}}
|
||||
if ({{name}} != null)
|
||||
@@ -102,7 +124,12 @@ class {{classname}} {
|
||||
{{/isDate}}
|
||||
{{^isDateTime}}
|
||||
{{^isDate}}
|
||||
{{^isEnum}}
|
||||
json['{{baseName}}'] = {{name}};
|
||||
{{/isEnum}}
|
||||
{{#isEnum}}
|
||||
json['{{baseName}}'] = {{name}}.value;
|
||||
{{/isEnum}}
|
||||
{{/isDate}}
|
||||
{{/isDateTime}}
|
||||
{{/vars}}
|
||||
@@ -114,7 +141,7 @@ class {{classname}} {
|
||||
}
|
||||
|
||||
static Map<String, {{classname}}> mapFromJson(Map<String, dynamic> json) {
|
||||
var map = Map<String, {{classname}}>();
|
||||
final map = Map<String, {{classname}}>();
|
||||
if (json != null && json.isNotEmpty) {
|
||||
json.forEach((String key, dynamic value) => map[key] = {{classname}}.fromJson(value));
|
||||
}
|
||||
@@ -123,12 +150,17 @@ class {{classname}} {
|
||||
|
||||
// maps a json object with a list of {{classname}}-objects as value to a dart map
|
||||
static Map<String, List<{{classname}}>> mapListFromJson(Map<String, dynamic> json) {
|
||||
var map = Map<String, List<{{classname}}>>();
|
||||
if (json != null && json.isNotEmpty) {
|
||||
json.forEach((String key, dynamic value) {
|
||||
map[key] = {{classname}}.listFromJson(value);
|
||||
});
|
||||
}
|
||||
return map;
|
||||
final map = Map<String, List<{{classname}}>>();
|
||||
if (json != null && json.isNotEmpty) {
|
||||
json.forEach((String key, dynamic value) {
|
||||
map[key] = {{classname}}.listFromJson(value);
|
||||
});
|
||||
}
|
||||
return map;
|
||||
}
|
||||
}
|
||||
{{#vars}}
|
||||
{{#isEnum}}
|
||||
{{>enum_inline}}
|
||||
{{/isEnum}}
|
||||
{{/vars}}
|
||||
|
||||
@@ -9,20 +9,27 @@ class {{classname}} {
|
||||
{{#description}}
|
||||
/// {{description}}
|
||||
{{/description}}
|
||||
static const {{classname}} {{{name}}} = const {{classname}}._internal({{{value}}});
|
||||
static const {{classname}} {{{name}}} = {{classname}}._internal({{value}});
|
||||
{{/enumVars}}
|
||||
{{/allowableValues}}
|
||||
|
||||
{{dataType}} toJson (){
|
||||
return this.value;
|
||||
{{dataType}} toJson () {
|
||||
return value;
|
||||
}
|
||||
|
||||
@override
|
||||
String toString () {
|
||||
return value;
|
||||
}
|
||||
|
||||
static {{classname}} fromJson({{dataType}} value) {
|
||||
return new {{classname}}TypeTransformer().decode(value);
|
||||
return {{classname}}TypeTransformer().decode(value);
|
||||
}
|
||||
|
||||
static List<{{classname}}> listFromJson(List<dynamic> json) {
|
||||
return json == null ? new List<{{classname}}>() : json.map((value) => {{classname}}.fromJson(value)).toList();
|
||||
return json == null
|
||||
? List<{{classname}}>()
|
||||
: json.map((value) => {{classname}}.fromJson(value)).toList();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
52
modules/openapi-generator/src/main/resources/dart2/enum_inline.mustache
vendored
Normal file
52
modules/openapi-generator/src/main/resources/dart2/enum_inline.mustache
vendored
Normal file
@@ -0,0 +1,52 @@
|
||||
class {{classname}}{{enumName}} {
|
||||
/// The underlying value of this enum member.
|
||||
final {{{dataType}}} value;
|
||||
|
||||
const {{classname}}{{enumName}}._internal(this.value);
|
||||
|
||||
{{#allowableValues}}
|
||||
{{#enumVars}}
|
||||
{{#description}}
|
||||
/// {{description}}
|
||||
{{/description}}
|
||||
static const {{classname}}{{enumName}} {{name}} = {{classname}}{{enumName}}._internal({{{value}}});
|
||||
{{/enumVars}}
|
||||
{{/allowableValues}}
|
||||
|
||||
{{{dataType}}} toJson () {
|
||||
return value;
|
||||
}
|
||||
|
||||
@override
|
||||
String toString () {
|
||||
return value;
|
||||
}
|
||||
|
||||
static {{classname}}{{enumName}} fromJson({{{dataType}}} value) {
|
||||
return {{classname}}{{enumName}}TypeTransformer().decode(value);
|
||||
}
|
||||
|
||||
static List<{{classname}}{{enumName}}> listFromJson(List<dynamic> json) {
|
||||
return json == null
|
||||
? List<{{classname}}{{enumName}}>()
|
||||
: json.map((value) => {{classname}}{{enumName}}.fromJson(value)).toList();
|
||||
}
|
||||
}
|
||||
|
||||
class {{classname}}{{enumName}}TypeTransformer {
|
||||
|
||||
dynamic encode({{classname}}{{enumName}} data) {
|
||||
return data.value;
|
||||
}
|
||||
|
||||
{{classname}}{{enumName}} decode(dynamic data) {
|
||||
switch (data) {
|
||||
{{#allowableValues}}
|
||||
{{#enumVars}}
|
||||
case {{{value}}}: return {{classname}}{{enumName}}.{{{name}}};
|
||||
{{/enumVars}}
|
||||
{{/allowableValues}}
|
||||
default: return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -8,5 +8,6 @@ environment:
|
||||
sdk: '>=2.0.0 <3.0.0'
|
||||
dependencies:
|
||||
http: '>=0.12.0 <0.13.0'
|
||||
meta: ^1.1.8
|
||||
dev_dependencies:
|
||||
test: ^1.3.0
|
||||
|
||||
@@ -2,8 +2,13 @@
|
||||
type {{classname}} struct {
|
||||
{{#parent}}
|
||||
{{^isMapModel}}
|
||||
{{^isArrayModel}}
|
||||
{{{parent}}}
|
||||
{{/isArrayModel}}
|
||||
{{/isMapModel}}
|
||||
{{#isArrayModel}}
|
||||
Items {{{parent}}}
|
||||
{{/isArrayModel}}
|
||||
{{/parent}}
|
||||
{{#vars}}
|
||||
{{^-first}}
|
||||
@@ -218,9 +223,10 @@ func (o *{{classname}}) Unset{{name}}() {
|
||||
{{/required}}
|
||||
{{/vars}}
|
||||
func (o {{classname}}) MarshalJSON() ([]byte, error) {
|
||||
toSerialize := map[string]interface{}{}
|
||||
toSerialize := {{#isArrayModel}}make([]interface{}, len(o.Items)){{/isArrayModel}}{{^isArrayModel}}map[string]interface{}{}{{/isArrayModel}}
|
||||
{{#parent}}
|
||||
{{^isMapModel}}
|
||||
{{^isArrayModel}}
|
||||
serialized{{parent}}, err{{parent}} := json.Marshal(o.{{parent}})
|
||||
if err{{parent}} != nil {
|
||||
return []byte{}, err{{parent}}
|
||||
@@ -229,7 +235,13 @@ func (o {{classname}}) MarshalJSON() ([]byte, error) {
|
||||
if err{{parent}} != nil {
|
||||
return []byte{}, err{{parent}}
|
||||
}
|
||||
{{/isArrayModel}}
|
||||
{{/isMapModel}}
|
||||
{{#isArrayModel}}
|
||||
for i, item := range o.Items {
|
||||
toSerialize[i] = item
|
||||
}
|
||||
{{/isArrayModel}}
|
||||
{{/parent}}
|
||||
{{#vars}}
|
||||
{{! if argument is nullable, only serialize it if it is set}}
|
||||
@@ -265,6 +277,72 @@ func (o {{classname}}) MarshalJSON() ([]byte, error) {
|
||||
|
||||
{{#isAdditionalPropertiesTrue}}
|
||||
func (o *{{{classname}}}) UnmarshalJSON(bytes []byte) (err error) {
|
||||
{{#parent}}
|
||||
{{^isMapModel}}
|
||||
type {{classname}}WithoutEmbeddedStruct struct {
|
||||
{{#vars}}
|
||||
{{^-first}}
|
||||
{{/-first}}
|
||||
{{#description}}
|
||||
// {{{description}}}
|
||||
{{/description}}
|
||||
{{name}} {{^required}}{{^isNullable}}*{{/isNullable}}{{/required}}{{{dataType}}} `json:"{{baseName}}{{^required}},omitempty{{/required}}"{{#withXml}} xml:"{{baseName}}{{#isXmlAttribute}},attr{{/isXmlAttribute}}"{{/withXml}}{{#vendorExtensions.x-go-custom-tag}} {{{.}}}{{/vendorExtensions.x-go-custom-tag}}`
|
||||
{{/vars}}
|
||||
}
|
||||
|
||||
var{{{classname}}}WithoutEmbeddedStruct := {{{classname}}}WithoutEmbeddedStruct{}
|
||||
|
||||
err = json.Unmarshal(bytes, &var{{{classname}}}WithoutEmbeddedStruct)
|
||||
if err == nil {
|
||||
var{{{classname}}} := _{{{classname}}}{}
|
||||
{{#vars}}
|
||||
var{{{classname}}}.{{{name}}} = var{{{classname}}}WithoutEmbeddedStruct.{{{name}}}
|
||||
{{/vars}}
|
||||
*o = {{{classname}}}(var{{{classname}}})
|
||||
} else {
|
||||
return err
|
||||
}
|
||||
|
||||
var{{{classname}}} := _{{{classname}}}{}
|
||||
|
||||
err = json.Unmarshal(bytes, &var{{{classname}}})
|
||||
if err == nil {
|
||||
o.{{{parent}}} = var{{{classname}}}.{{{parent}}}
|
||||
} else {
|
||||
return err
|
||||
}
|
||||
|
||||
additionalProperties := make(map[string]interface{})
|
||||
|
||||
if err = json.Unmarshal(bytes, &additionalProperties); err == nil {
|
||||
{{#vars}}
|
||||
delete(additionalProperties, "{{{baseName}}}")
|
||||
{{/vars}}
|
||||
|
||||
// remove fields from embedded structs
|
||||
reflect{{{parent}}} := reflect.ValueOf(o.{{{parent}}})
|
||||
for i := 0; i < reflect{{{parent}}}.Type().NumField(); i++ {
|
||||
t := reflect{{{parent}}}.Type().Field(i)
|
||||
|
||||
if jsonTag := t.Tag.Get("json"); jsonTag != "" {
|
||||
fieldName := ""
|
||||
if commaIdx := strings.Index(jsonTag, ","); commaIdx > 0 {
|
||||
fieldName = jsonTag[:commaIdx]
|
||||
} else {
|
||||
fieldName = jsonTag
|
||||
}
|
||||
if fieldName != "AdditionalProperties" {
|
||||
delete(additionalProperties, fieldName)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
o.AdditionalProperties = additionalProperties
|
||||
}
|
||||
|
||||
return err
|
||||
{{/isMapModel}}
|
||||
{{#isMapModel}}
|
||||
var{{{classname}}} := _{{{classname}}}{}
|
||||
|
||||
if err = json.Unmarshal(bytes, &var{{{classname}}}); err == nil {
|
||||
@@ -281,7 +359,33 @@ func (o *{{{classname}}}) UnmarshalJSON(bytes []byte) (err error) {
|
||||
}
|
||||
|
||||
return err
|
||||
{{/isMapModel}}
|
||||
{{/parent}}
|
||||
{{^parent}}
|
||||
var{{{classname}}} := _{{{classname}}}{}
|
||||
|
||||
if err = json.Unmarshal(bytes, &var{{{classname}}}); err == nil {
|
||||
*o = {{{classname}}}(var{{{classname}}})
|
||||
}
|
||||
|
||||
additionalProperties := make(map[string]interface{})
|
||||
|
||||
if err = json.Unmarshal(bytes, &additionalProperties); err == nil {
|
||||
{{#vars}}
|
||||
delete(additionalProperties, "{{{baseName}}}")
|
||||
{{/vars}}
|
||||
o.AdditionalProperties = additionalProperties
|
||||
}
|
||||
|
||||
return err
|
||||
{{/parent}}
|
||||
}
|
||||
|
||||
{{/isAdditionalPropertiesTrue}}
|
||||
{{#isArrayModel}}
|
||||
func (o *{{{classname}}}) UnmarshalJSON(bytes []byte) (err error) {
|
||||
return json.Unmarshal(bytes, &o.Items)
|
||||
}
|
||||
|
||||
{{/isArrayModel}}
|
||||
{{>nullable_model}}
|
||||
|
||||
@@ -32,7 +32,7 @@ import (
|
||||
)
|
||||
|
||||
var (
|
||||
jsonCheck = regexp.MustCompile(`(?i:(?:application|text)/(?:vnd\.[^;]+\+)?json)`)
|
||||
jsonCheck = regexp.MustCompile(`(?i:(?:application|text)/(?:vnd\.[^;]+\+)?(?:problem\+)?json)`)
|
||||
xmlCheck = regexp.MustCompile(`(?i:(?:application|text)/xml)`)
|
||||
)
|
||||
|
||||
|
||||
@@ -70,7 +70,7 @@ public class HttpLoggingFilter implements Filter {
|
||||
chain.doFilter(bufferedRequest, bufferedResponse);
|
||||
long elapsedTime = System.currentTimeMillis() - start;
|
||||
String respContent = null;
|
||||
if (bufferedResponse.getContent() == null || bufferedResponse.getContent() == "") {
|
||||
if (bufferedResponse.getContent() == null || "".equals(bufferedResponse.getContent())) {
|
||||
respContent = "No data";
|
||||
} else {
|
||||
respContent = bufferedResponse.getContent();
|
||||
|
||||
@@ -46,7 +46,7 @@ import {{packageName}}.auth.*
|
||||
val clientConfig: (HttpClientConfig<*>) -> Unit = { it.install(JsonFeature, jsonConfig) }
|
||||
httpClientEngine?.let { HttpClient(it, clientConfig) } ?: HttpClient(clientConfig)
|
||||
}
|
||||
|
||||
{{#hasAuthMethods}}
|
||||
private val authentications: kotlin.collections.Map<String, Authentication> by lazy {
|
||||
mapOf({{#authMethods}}{{#isBasic}}{{#isBasicBasic}}
|
||||
"{{name}}" to HttpBasicAuth(){{/isBasicBasic}}{{^isBasicBasic}}
|
||||
@@ -54,6 +54,10 @@ import {{packageName}}.auth.*
|
||||
"{{name}}" to ApiKeyAuth({{#isKeyInHeader}}"header"{{/isKeyInHeader}}{{^isKeyInHeader}}"query"{{/isKeyInHeader}}, "{{keyParamName}}"){{/isApiKey}}{{#isOAuth}}
|
||||
"{{name}}" to OAuth(){{/isOAuth}}{{#hasMore}}, {{/hasMore}}{{/authMethods}})
|
||||
}
|
||||
{{/hasAuthMethods}}
|
||||
{{^hasAuthMethods}}
|
||||
private val authentications: kotlin.collections.Map<String, Authentication>? = null
|
||||
{{/hasAuthMethods}}
|
||||
|
||||
{{#nonPublicApi}}internal {{/nonPublicApi}}companion object {
|
||||
protected val UNSAFE_HEADERS = listOf(HttpHeaders.ContentType)
|
||||
@@ -74,7 +78,7 @@ import {{packageName}}.auth.*
|
||||
* @param username Username
|
||||
*/
|
||||
fun setUsername(username: String) {
|
||||
val auth = authentications.values.firstOrNull { it is HttpBasicAuth } as HttpBasicAuth?
|
||||
val auth = authentications?.values?.firstOrNull { it is HttpBasicAuth } as HttpBasicAuth?
|
||||
?: throw Exception("No HTTP basic authentication configured")
|
||||
auth.username = username
|
||||
}
|
||||
@@ -85,7 +89,7 @@ import {{packageName}}.auth.*
|
||||
* @param password Password
|
||||
*/
|
||||
fun setPassword(password: String) {
|
||||
val auth = authentications.values.firstOrNull { it is HttpBasicAuth } as HttpBasicAuth?
|
||||
val auth = authentications?.values?.firstOrNull { it is HttpBasicAuth } as HttpBasicAuth?
|
||||
?: throw Exception("No HTTP basic authentication configured")
|
||||
auth.password = password
|
||||
}
|
||||
@@ -97,7 +101,7 @@ import {{packageName}}.auth.*
|
||||
* @param paramName The name of the API key parameter, or null or set the first key.
|
||||
*/
|
||||
fun setApiKey(apiKey: String, paramName: String? = null) {
|
||||
val auth = authentications.values.firstOrNull { it is ApiKeyAuth && (paramName == null || paramName == it.paramName)} as ApiKeyAuth?
|
||||
val auth = authentications?.values?.firstOrNull { it is ApiKeyAuth && (paramName == null || paramName == it.paramName)} as ApiKeyAuth?
|
||||
?: throw Exception("No API key authentication configured")
|
||||
auth.apiKey = apiKey
|
||||
}
|
||||
@@ -109,7 +113,7 @@ import {{packageName}}.auth.*
|
||||
* @param paramName The name of the API key parameter, or null or set the first key.
|
||||
*/
|
||||
fun setApiKeyPrefix(apiKeyPrefix: String, paramName: String? = null) {
|
||||
val auth = authentications.values.firstOrNull { it is ApiKeyAuth && (paramName == null || paramName == it.paramName) } as ApiKeyAuth?
|
||||
val auth = authentications?.values?.firstOrNull { it is ApiKeyAuth && (paramName == null || paramName == it.paramName) } as ApiKeyAuth?
|
||||
?: throw Exception("No API key authentication configured")
|
||||
auth.apiKeyPrefix = apiKeyPrefix
|
||||
}
|
||||
@@ -120,7 +124,7 @@ import {{packageName}}.auth.*
|
||||
* @param accessToken Access token
|
||||
*/
|
||||
fun setAccessToken(accessToken: String) {
|
||||
val auth = authentications.values.firstOrNull { it is OAuth } as OAuth?
|
||||
val auth = authentications?.values?.firstOrNull { it is OAuth } as OAuth?
|
||||
?: throw Exception("No OAuth2 authentication configured")
|
||||
auth.accessToken = accessToken
|
||||
}
|
||||
@@ -131,7 +135,7 @@ import {{packageName}}.auth.*
|
||||
* @param bearerToken The bearer token.
|
||||
*/
|
||||
fun setBearerToken(bearerToken: String) {
|
||||
val auth = authentications.values.firstOrNull { it is HttpBearerAuth } as HttpBearerAuth?
|
||||
val auth = authentications?.values?.firstOrNull { it is HttpBearerAuth } as HttpBearerAuth?
|
||||
?: throw Exception("No Bearer authentication configured")
|
||||
auth.bearerToken = bearerToken
|
||||
}
|
||||
@@ -175,7 +179,7 @@ import {{packageName}}.auth.*
|
||||
|
||||
private fun RequestConfig.updateForAuth(authNames: kotlin.collections.List<String>) {
|
||||
for (authName in authNames) {
|
||||
val auth = authentications[authName] ?: throw Exception("Authentication undefined: $authName")
|
||||
val auth = authentications?.get(authName) ?: throw Exception("Authentication undefined: $authName")
|
||||
auth.apply(query, headers)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -37,7 +37,7 @@ class ExpressServer {
|
||||
//Send the openapi document *AS GENERATED BY THE GENERATOR*
|
||||
this.app.get('/openapi', (req, res) => res.sendFile((path.join(__dirname, 'api', 'openapi.yaml'))));
|
||||
//View the openapi document in a visual interface. Should be able to test from this page
|
||||
this.app.use('/api-doc', swaggerUI.serve, swaggerUI.setup(this.schema));
|
||||
this.app.use('/api-docs', swaggerUI.serve, swaggerUI.setup(this.schema));
|
||||
this.app.get('/login-redirect', (req, res) => {
|
||||
res.status(200);
|
||||
res.json(req.query);
|
||||
|
||||
@@ -533,7 +533,14 @@ use {{invokerPackage}}\ObjectSerializer;
|
||||
if (${{paramName}} !== null) {
|
||||
{{#isFile}}
|
||||
$multipart = true;
|
||||
$formParams['{{baseName}}'] = \GuzzleHttp\Psr7\try_fopen(ObjectSerializer::toFormValue(${{paramName}}), 'rb');
|
||||
$formParams['{{baseName}}'] = [];
|
||||
$paramFiles = is_array(${{paramName}}) ? ${{paramName}} : [${{paramName}}];
|
||||
foreach ($paramFiles as $paramFile) {
|
||||
$formParams['{{baseName}}'][] = \GuzzleHttp\Psr7\try_fopen(
|
||||
ObjectSerializer::toFormValue($paramFile),
|
||||
'rb'
|
||||
);
|
||||
}
|
||||
{{/isFile}}
|
||||
{{^isFile}}
|
||||
$formParams['{{baseName}}'] = ObjectSerializer::toFormValue(${{paramName}});
|
||||
@@ -571,10 +578,13 @@ use {{invokerPackage}}\ObjectSerializer;
|
||||
if ($multipart) {
|
||||
$multipartContents = [];
|
||||
foreach ($formParams as $formParamName => $formParamValue) {
|
||||
$multipartContents[] = [
|
||||
'name' => $formParamName,
|
||||
'contents' => $formParamValue
|
||||
];
|
||||
$formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue];
|
||||
foreach ($formParamValueItems as $formParamValueItem) {
|
||||
$multipartContents[] = [
|
||||
'name' => $formParamName,
|
||||
'contents' => $formParamValueItem
|
||||
];
|
||||
}
|
||||
}
|
||||
// for HTTP post (form)
|
||||
$httpBody = new MultipartStream($multipartContents);
|
||||
|
||||
@@ -221,7 +221,8 @@ function {{{vendorExtensions.x-powershell-method-name}}} {
|
||||
-QueryParameters $LocalVarQueryParameters `
|
||||
-FormParameters $LocalVarFormParameters `
|
||||
-CookieParameters $LocalVarCookieParameters `
|
||||
-ReturnType "{{#returnType}}{{{.}}}{{/returnType}}"
|
||||
-ReturnType "{{#returnType}}{{{.}}}{{/returnType}}" `
|
||||
-IsBodyNullable {{#bodyParam}}{{#isNullable}}$true{{/isNullable}}{{^isNullable}}$false{{/isNullable}}{{/bodyParam}}{{^bodyParam}}$false{{/bodyParam}}
|
||||
|
||||
{{#vendorExtensions.x-ps-return-type-one-of}}
|
||||
# process oneOf response
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user