forked from loafle/openapi-generator-original
Compare commits
58 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
3ebefccfa9 | ||
|
|
e73bf9be1d | ||
|
|
d46bff9e78 | ||
|
|
e18f361534 | ||
|
|
8d67acc3ed | ||
|
|
9ca4bac881 | ||
|
|
f2fe4fc200 | ||
|
|
096f2d0fc8 | ||
|
|
239d68df36 | ||
|
|
5fd15b8b18 | ||
|
|
640e2ca825 | ||
|
|
ddf0e3e225 | ||
|
|
dd152eefcc | ||
|
|
c7d4a965c7 | ||
|
|
458d47b4ae | ||
|
|
9cc7bd15f2 | ||
|
|
c63cf7e5f3 | ||
|
|
6a4e92887a | ||
|
|
03edb64030 | ||
|
|
ec7f2a0450 | ||
|
|
2a2eefe93d | ||
|
|
cec2818e1f | ||
|
|
91daca36ef | ||
|
|
12ba8174d1 | ||
|
|
8f13b88ed9 | ||
|
|
3be1196264 | ||
|
|
911cdd8d0c | ||
|
|
1b12b89fd8 | ||
|
|
d21b3390fe | ||
|
|
806141297b | ||
|
|
e39b420fa8 | ||
|
|
f25c6da856 | ||
|
|
b0549fe6da | ||
|
|
87727de079 | ||
|
|
8236424aff | ||
|
|
e4b39ce95e | ||
|
|
026612fed7 | ||
|
|
8f7e43b500 | ||
|
|
1443f01709 | ||
|
|
c2f786b8ad | ||
|
|
44d8b49dee | ||
|
|
f4d3df762a | ||
|
|
ceccb4f83a | ||
|
|
34ec98d17b | ||
|
|
2016bc086f | ||
|
|
28cf0b279d | ||
|
|
31d7bf9d18 | ||
|
|
d36dd47b12 | ||
|
|
5a54aa5726 | ||
|
|
60e4c923dd | ||
|
|
dc7bcbdb85 | ||
|
|
7c480446e6 | ||
|
|
45d70e1bf3 | ||
|
|
f94ff32b0c | ||
|
|
e1116814c4 | ||
|
|
5bd63074c4 | ||
|
|
d0d545bbdd | ||
|
|
c290555e5e |
6
.github/.test/samples.json
vendored
6
.github/.test/samples.json
vendored
@@ -145,12 +145,6 @@
|
||||
"Documentation: Cwiki"
|
||||
]
|
||||
},
|
||||
{
|
||||
"input": "dart-flutter-petstore.sh",
|
||||
"matches": [
|
||||
"Client: Dart"
|
||||
]
|
||||
},
|
||||
{
|
||||
"input": "dart-jaguar-petstore.sh",
|
||||
"matches": [
|
||||
|
||||
@@ -2,6 +2,11 @@ kind: pipeline
|
||||
name: default
|
||||
|
||||
steps:
|
||||
# test haskell client
|
||||
- name: haskell-client-test
|
||||
image: haskell:8.6.5
|
||||
commands:
|
||||
- (cd samples/client/petstore/haskell-http-client/ && stack --install-ghc --no-haddock-deps haddock --fast && stack test --fast)
|
||||
# test Dart 2.x petstore client
|
||||
- name: dart2x-test
|
||||
image: google/dart
|
||||
|
||||
18
README.md
18
README.md
@@ -65,11 +65,11 @@ OpenAPI Generator allows generation of API client libraries (SDK generation), se
|
||||
|
||||
| | Languages/Frameworks |
|
||||
|-|-|
|
||||
**API clients** | **ActionScript**, **Ada**, **Apex**, **Bash**, **C**, **C#** (.net 2.0, 3.5 or later), **C++** (cpp-restsdk, Qt5, Tizen), **Clojure**, **Dart (1.x, 2.x)**, **Elixir**, **Elm**, **Eiffel**, **Erlang**, **Go**, **Groovy**, **Haskell** (http-client, Servant), **Java** (Jersey1.x, Jersey2.x, OkHttp, Retrofit1.x, Retrofit2.x, Feign, RestTemplate, RESTEasy, Vertx, Google API Client Library for Java, Rest-assured, Spring 5 Web Client), **Kotlin**, **Lua**, **Node.js/JavaScript** (ES5, ES6, AngularJS with Google Closure Compiler annotations, Flow types), **Objective-C**, **OCaml**, **Perl**, **PHP**, **PowerShell**, **Python**, **R**, **Ruby**, **Rust** (rust, rust-server), **Scala** (akka, http4s, scalaz, swagger-async-httpclient), **Swift** (2.x, 3.x, 4.x), **Typescript** (AngularJS, Angular (2.x - 8.x), Aurelia, Axios, Fetch, Inversify, jQuery, Node, Rxjs)
|
||||
**API clients** | **ActionScript**, **Ada**, **Apex**, **Bash**, **C**, **C#** (.net 2.0, 3.5 or later, .NET Standard 1.3 - 2.0, .NET Core 2.0), **C++** (cpp-restsdk, Qt5, Tizen), **Clojure**, **Dart (1.x, 2.x)**, **Elixir**, **Elm**, **Eiffel**, **Erlang**, **Go**, **Groovy**, **Haskell** (http-client, Servant), **Java** (Jersey1.x, Jersey2.x, OkHttp, Retrofit1.x, Retrofit2.x, Feign, RestTemplate, RESTEasy, Vertx, Google API Client Library for Java, Rest-assured, Spring 5 Web Client), **Kotlin**, **Lua**, **Node.js/JavaScript** (ES5, ES6, AngularJS with Google Closure Compiler annotations, Flow types), **Objective-C**, **OCaml**, **Perl**, **PHP**, **PowerShell**, **Python**, **R**, **Ruby**, **Rust** (rust, rust-server), **Scala** (akka, http4s, scalaz, swagger-async-httpclient), **Swift** (2.x, 3.x, 4.x), **Typescript** (AngularJS, Angular (2.x - 8.x), Aurelia, Axios, Fetch, Inversify, jQuery, Node, Rxjs)
|
||||
**Server stubs** | **Ada**, **C#** (ASP.NET Core, NancyFx), **C++** (Pistache, Restbed, Qt5 QHTTPEngine), **Erlang**, **F#** (Giraffe), **Go** (net/http, Gin), **Haskell** (Servant), **Java** (MSF4J, Spring, Undertow, JAX-RS: CDI, CXF, Inflector, Jersey, RestEasy, Play Framework, [PKMST](https://github.com/ProKarma-Inc/pkmst-getting-started-examples)), **Kotlin** (Spring Boot, Ktor), **PHP** (Laravel, Lumen, Slim, Silex, [Symfony](https://symfony.com/), [Zend Expressive](https://github.com/zendframework/zend-expressive)), **Python** (Flask), **NodeJS**, **Ruby** (Sinatra, Rails5), **Rust** (rust-server), **Scala** ([Finch](https://github.com/finagle/finch), [Lagom](https://github.com/lagom/lagom), [Play](https://www.playframework.com/), Scalatra)
|
||||
**API documentation generators** | **HTML**, **Confluence Wiki**
|
||||
**Configuration files** | [**Apache2**](https://httpd.apache.org/)
|
||||
**Others** | **GraphQL**, **JMeter**, **MySQL Schema**
|
||||
**Others** | **GraphQL**, **JMeter**, **MySQL Schema**, **Protocol Buffer**
|
||||
|
||||
## Table of contents
|
||||
|
||||
@@ -108,8 +108,8 @@ OpenAPI Generator Version | Release Date | Notes
|
||||
---------------------------- | ------------ | -----
|
||||
5.0.0 (upcoming major release) [SNAPSHOT](https://oss.sonatype.org/content/repositories/snapshots/org/openapitools/openapi-generator-cli/5.0.0-SNAPSHOT/)| 13.05.2020 | Major release with breaking changes (no fallback)
|
||||
4.2.0 (upcoming minor release) [SNAPSHOT](https://oss.sonatype.org/content/repositories/snapshots/org/openapitools/openapi-generator-cli/4.2.0-SNAPSHOT/)| 09.10.2019 | Minor release (breaking changes with fallbacks)
|
||||
4.1.1 (upcoming minor release) [SNAPSHOT](https://oss.sonatype.org/content/repositories/snapshots/org/openapitools/openapi-generator-cli/4.1.1/)| 23.08.2019 | Patch release (bug fixes, enhancements)
|
||||
[4.1.1](https://github.com/OpenAPITools/openapi-generator/releases/tag/v4.1.1) (latest stable release) | 09.08.2019 | Minor release (breaking changes with fallbacks)
|
||||
4.1.3 (upcoming minor release) [SNAPSHOT](https://oss.sonatype.org/content/repositories/snapshots/org/openapitools/openapi-generator-cli/4.1.3-SNAPSHOT/)| 30.09.2019 | Patch release (bug fixes, enhancements)
|
||||
[4.1.2](https://github.com/OpenAPITools/openapi-generator/releases/tag/v4.1.2) (latest stable release) | 11.09.2019 | Minor release (breaking changes with fallbacks)
|
||||
|
||||
OpenAPI Spec compatibility: 1.0, 1.1, 1.2, 2.0, 3.0
|
||||
|
||||
@@ -560,6 +560,7 @@ Here are some companies/projects (alphabetical order) using OpenAPI Generator in
|
||||
- [Commencis](https://www.commencis.com/)
|
||||
- [Cupix](https://www.cupix.com/)
|
||||
- [DB Systel](https://www.dbsystel.de)
|
||||
- [Element AI](https://www.elementai.com/)
|
||||
- [FormAPI](https://formapi.io/)
|
||||
- [Fuse](https://www.fuse.no/)
|
||||
- [GenFlow](https://github.com/RepreZen/GenFlow)
|
||||
@@ -570,6 +571,7 @@ Here are some companies/projects (alphabetical order) using OpenAPI Generator in
|
||||
- [Metaswitch](https://www.metaswitch.com/)
|
||||
- [Myworkout](https://myworkout.com)
|
||||
- [Paxos](https://www.paxos.com)
|
||||
- [Pricefx](https://www.pricefx.com/)
|
||||
- [Prometheus/Alertmanager](https://github.com/prometheus/alertmanager)
|
||||
- [Raiffeisen Schweiz Genossenschaft](https://www.raiffeisen.ch)
|
||||
- [RepreZen API Studio](https://www.reprezen.com/swagger-openapi-code-generation-api-first-microservices-enterprise-development)
|
||||
@@ -628,7 +630,12 @@ Here are some companies/projects (alphabetical order) using OpenAPI Generator in
|
||||
- 2019-07-14 - [OpenAPI GeneratorでPythonのクライアントライブラリを作成した](https://qiita.com/yuji38kwmt/items/dfb929316a1335a161c0) by [yuji38kwmt](https://qiita.com/yuji38kwmt)
|
||||
- 2019-07-19 - [Developer Experience (DX) for Open-Source Projects: How to Engage Developers and Build a Growing Developer Community](https://speakerdeck.com/wing328/developer-experience-dx-for-open-source-projects-english-japanese) by [William Cheng](https://twitter.com/wing328), [中野暁人](https://github.com/ackintosh) at [Open Source Summit Japan 2019](https://events.linuxfoundation.org/events/open-source-summit-japan-2019/)
|
||||
- 2019-08-14 - [Our OpenAPI journey with Standardizing SDKs](https://bitmovin.com/our-openapi-journey-with-standardizing-sdks/) by [Sebastian Burgstaller](https://bitmovin.com/author/sburgstaller/) at [Bitmovin](https://www.bitmovin.com)
|
||||
- 2019-08-15 - [APIのコードを自動生成させたいだけならgRPCでなくてもよくない?](https://www.m3tech.blog/entry/2019/08/15/110000) by [M3, Inc.](https://corporate.m3.com/)
|
||||
- 2019-08-22 - [マイクロサービスにおけるWeb APIスキーマの管理─ GraphQL、gRPC、OpenAPIの特徴と使いどころ](https://employment.en-japan.com/engineerhub/entry/2019/08/22/103000) by [@ota42y](https://twitter.com/ota42y)
|
||||
- 2019-08-24 - [SwaggerドキュメントからOpenAPI Generatorを使ってモックサーバー作成](https://qiita.com/masayoshi0222/items/4845e4c715d04587c104) by [坂本正義](https://qiita.com/masayoshi0222)
|
||||
- 2019-08-29 - [OpenAPI初探](https://cloud.tencent.com/developer/article/1495986) by [peakxie](https://cloud.tencent.com/developer/user/1113152) at [腾讯云社区](https://cloud.tencent.com/developer)
|
||||
- 2019-08-29 - [全面进化:Kubernetes CRD 1.16 GA前瞻](https://www.servicemesher.com/blog/kubernetes-1.16-crd-ga-preview/) by [Min Kim](https://github.com/yue9944882) at [ServiceMesher Blog](https://www.servicemesher.com/blog/)
|
||||
- 2019-09-01 - [Creating a PHP-Slim server using OpenAPI (Youtube video)](https://www.youtube.com/watch?v=5cJtbIrsYkg) by [Daniel Persson](https://www.youtube.com/channel/UCnG-TN23lswO6QbvWhMtxpA)
|
||||
|
||||
## [6 - About Us](#table-of-contents)
|
||||
|
||||
@@ -761,6 +768,7 @@ Here is a list of template creators:
|
||||
* Avro: @sgadouar
|
||||
* GraphQL: @wing328 [:heart:](https://www.patreon.com/wing328)
|
||||
* MySQL: @ybelenko
|
||||
* Protocol Buffer: @wing328
|
||||
|
||||
:heart: = Link to support the contributor directly
|
||||
|
||||
@@ -804,7 +812,7 @@ If you want to join the committee, please kindly apply by sending an email to te
|
||||
| C++ | @ravinikam (2017/07) @stkrwork (2017/07) @etherealjoy (2018/02) @martindelille (2018/03) @muttleyxd (2019/08) |
|
||||
| C# | @mandrean (2017/08), @jimschubert (2017/09) [:heart:](https://www.patreon.com/jimschubert) |
|
||||
| Clojure | |
|
||||
| Dart | @ircecho (2017/07) @swipesight (2018/09) @jaumard (2018/09) |
|
||||
| Dart | @ircecho (2017/07) @swipesight (2018/09) @jaumard (2018/09) @nickmeinhold (2019/09) |
|
||||
| Eiffel | @jvelilla (2017/09) |
|
||||
| Elixir | @mrmstn (2018/12) |
|
||||
| Elm | @eriktim (2018/09) |
|
||||
|
||||
@@ -1,50 +0,0 @@
|
||||
#!/bin/sh
|
||||
|
||||
SCRIPT="$0"
|
||||
|
||||
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"
|
||||
|
||||
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} -Xmx1024M -DloggerPath=conf/log4j.properties"
|
||||
|
||||
## Generate non-browserClient
|
||||
#ags="generate -t modules/openapi-generator/src/main/resources/dart -i modules/openapi-generator/src/test/resources/2_0/petstore.yaml -g dart -o samples/client/petstore/dart/swagger --additional-properties hideGenerationTimestamp=true,browserClient=false $@"
|
||||
#
|
||||
## then options to generate the library for vm would be:
|
||||
##ags="generate -i modules/openapi-generator/src/test/resources/2_0/petstore.yaml -g dart -o samples/client/petstore/dart/swagger_vm --additional-properties browserClient=false,pubName=swagger_vm $@"
|
||||
#java $JAVA_OPTS -jar $executable $ags
|
||||
#
|
||||
## Generate browserClient
|
||||
#ags="generate -t modules/openapi-generator/src/main/resources/dart -i modules/openapi-generator/src/test/resources/2_0/petstore.yaml -g dart -o samples/client/petstore/dart/swagger-browser-client --additional-properties hideGenerationTimestamp=true,browserClient=true $@"
|
||||
#java $JAVA_OPTS -jar $executable $ags
|
||||
|
||||
# Generate non-browserClient and put it to the flutter sample app
|
||||
ags="generate -t modules/openapi-generator/src/main/resources/dart -i modules/openapi-generator/src/test/resources/2_0/petstore.yaml -g dart -o samples/client/petstore/dart/flutter_petstore/swagger --additional-properties hideGenerationTimestamp=true,browserClient=false $@"
|
||||
java $JAVA_OPTS -jar $executable $ags
|
||||
|
||||
# There is a proposal to allow importing different libraries depending on the environment:
|
||||
# https://github.com/munificent/dep-interface-libraries
|
||||
# When this is implemented there will only be one library.
|
||||
|
||||
# The current petstore test will then work for both: the browser library and the vm library.
|
||||
|
||||
@@ -28,23 +28,6 @@ fi
|
||||
# if you've executed sbt assembly previously it will use that instead.
|
||||
export JAVA_OPTS="${JAVA_OPTS} -Xmx1024M -DloggerPath=conf/log4j.properties"
|
||||
|
||||
# Generate non-browserClient
|
||||
ags="generate -t modules/openapi-generator/src/main/resources/dart -i modules/openapi-generator/src/test/resources/2_0/petstore.yaml -g dart -o samples/client/petstore/dart2/openapi --additional-properties hideGenerationTimestamp=true,browserClient=false $@"
|
||||
|
||||
# then options to generate the library for vm would be:
|
||||
#ags="generate -i modules/openapi-generator/src/test/resources/2_0/petstore.yaml -g dart -o samples/client/petstore/dart2/openapi_vm --additional-properties browserClient=false,pubName=openapi_vm $@"
|
||||
# Generate client
|
||||
ags="generate -t modules/openapi-generator/src/main/resources/dart2 -i modules/openapi-generator/src/test/resources/2_0/petstore.yaml -g dart -o samples/client/petstore/dart2/openapi --additional-properties hideGenerationTimestamp=true $@"
|
||||
java $JAVA_OPTS -jar $executable $ags
|
||||
|
||||
# Generate browserClient
|
||||
ags="generate -t modules/openapi-generator/src/main/resources/dart -i modules/openapi-generator/src/test/resources/2_0/petstore.yaml -g dart -o samples/client/petstore/dart2/openapi-browser-client --additional-properties hideGenerationTimestamp=true,browserClient=true $@"
|
||||
java $JAVA_OPTS -jar $executable $ags
|
||||
|
||||
# Generate non-browserClient and put it to the flutter sample app
|
||||
ags="generate -t modules/openapi-generator/src/main/resources/dart -i modules/openapi-generator/src/test/resources/2_0/petstore.yaml -g dart -o samples/client/petstore/dart2/flutter_petstore/openapi --additional-properties hideGenerationTimestamp=true,browserClient=false $@"
|
||||
java $JAVA_OPTS -jar $executable $ags
|
||||
|
||||
# There is a proposal to allow importing different libraries depending on the environment:
|
||||
# https://github.com/munificent/dep-interface-libraries
|
||||
# When this is implemented there will only be one library.
|
||||
|
||||
# The current petstore test will then work for both: the browser library and the vm library.
|
||||
|
||||
@@ -26,7 +26,7 @@ then
|
||||
fi
|
||||
|
||||
export JAVA_OPTS="${JAVA_OPTS} -Xmx1024M -DloggerPath=conf/log4j.properties"
|
||||
ags="$@ generate -i modules/openapi-generator/src/test/resources/3_0/petstore-with-fake-endpoints-models-for-testing.yaml -t modules/openapi-generator/src/main/resources/kotlin-client -g kotlin --artifact-id kotlin-petstore-client --additional-properties dateLibrary=java8 -o samples/openapi3/client/petstore/kotlin $@"
|
||||
ags="generate -i modules/openapi-generator/src/test/resources/3_0/petstore-with-fake-endpoints-models-for-testing.yaml -t modules/openapi-generator/src/main/resources/kotlin-client -g kotlin --artifact-id kotlin-petstore-client --additional-properties dateLibrary=java8 -o samples/openapi3/client/petstore/kotlin $@"
|
||||
|
||||
echo "Cleaning previously generated files if any from samples/openapi3/client/petstore/kotlin"
|
||||
rm -rf samples/openapi3/client/petstore/kotlin
|
||||
|
||||
10
bin/openapi3/windows/nodejs-express-server-petstore.bat
Executable file
10
bin/openapi3/windows/nodejs-express-server-petstore.bat
Executable file
@@ -0,0 +1,10 @@
|
||||
set executable=.\modules\openapi-generator-cli\target\openapi-generator-cli.jar
|
||||
|
||||
If Not Exist %executable% (
|
||||
mvn clean package
|
||||
)
|
||||
|
||||
REM set JAVA_OPTS=%JAVA_OPTS% -Xmx1024M -DloggerPath=conf/log4j.properties
|
||||
set ags=generate -i modules\openapi-generator\src\test\resources\3_0\petstore.yaml -g nodejs-express-server -o samples\openapi3\server\petstore\nodejs-express-server
|
||||
|
||||
java %JAVA_OPTS% -jar %executable% %ags%
|
||||
32
bin/protobuf-schema-petstore.sh
Executable file
32
bin/protobuf-schema-petstore.sh
Executable file
@@ -0,0 +1,32 @@
|
||||
#!/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"
|
||||
|
||||
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} -Xmx1024M -DloggerPath=conf/log4j.properties $@"
|
||||
ags="generate -t modules/openapi-generator/src/main/resources/protobuf-schema -i modules/openapi-generator/src/test/resources/2_0/petstore.yaml -g protobuf-schema -o samples/config/petstore/protobuf-schema --additional-properties packageName=petstore $@"
|
||||
|
||||
java $JAVA_OPTS -jar $executable $ags
|
||||
@@ -6,3 +6,4 @@
|
||||
./bin/typescript-fetch-petstore.sh
|
||||
./bin/typescript-fetch-petstore-multiple-parameters.sh
|
||||
./bin/typescript-fetch-petstore-prefix-parameter-interfaces.sh
|
||||
./bin/typescript-fetch-petstore-typescript-three-plus.sh
|
||||
|
||||
7
bin/typescript-fetch-petstore-typescript-three-plus.json
Normal file
7
bin/typescript-fetch-petstore-typescript-three-plus.json
Normal file
@@ -0,0 +1,7 @@
|
||||
{
|
||||
"npmName": "@openapitools/typescript-fetch-petstore",
|
||||
"npmVersion": "1.0.0",
|
||||
"npmRepository" : "https://skimdb.npmjs.com/registry",
|
||||
"snapshot" : false,
|
||||
"typescriptThreePlus": true
|
||||
}
|
||||
32
bin/typescript-fetch-petstore-typescript-three-plus.sh
Executable file
32
bin/typescript-fetch-petstore-typescript-three-plus.sh
Executable file
@@ -0,0 +1,32 @@
|
||||
#!/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"
|
||||
|
||||
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} -Xmx1024M -DloggerPath=conf/log4j.properties"
|
||||
ags="generate -i modules/openapi-generator/src/test/resources/2_0/petstore.yaml -g typescript-fetch -c bin/typescript-fetch-petstore-typescript-three-plus.json -o samples/client/petstore/typescript-fetch/builds/typescript-three-plus $@"
|
||||
|
||||
java $JAVA_OPTS -jar $executable $ags
|
||||
@@ -59,9 +59,9 @@ declare -a scripts=(
|
||||
"./bin/apex-petstore.sh"
|
||||
"./bin/perl-petstore-all.sh"
|
||||
"./bin/dart-jaguar-petstore.sh"
|
||||
"./bin/dart-flutter-petstore.sh"
|
||||
"./bin/dart-petstore.sh"
|
||||
"./bin/dart2-petstore.sh"
|
||||
"./bin/java-play-framework-petstore-server-all.sh"
|
||||
#"./bin/elm-petstore-all.sh"
|
||||
"./bin/meta-codegen.sh"
|
||||
# OTHERS
|
||||
|
||||
10
bin/windows/protobuf-schema-petstore.bat
Executable file
10
bin/windows/protobuf-schema-petstore.bat
Executable file
@@ -0,0 +1,10 @@
|
||||
set executable=.\modules\openapi-generator-cli\target\openapi-generator-cli.jar
|
||||
|
||||
If Not Exist %executable% (
|
||||
mvn clean package
|
||||
)
|
||||
|
||||
REM set JAVA_OPTS=%JAVA_OPTS% -Xmx1024M
|
||||
set ags=generate -t modules\openapi-generator\src\main\resources\protobuf-schema -i modules\openapi-generator\src\test\resources\2_0\petstore.yaml -g protobuf-schema -o samples\config\petstore\protobuf-schema
|
||||
|
||||
java %JAVA_OPTS% -jar %executable% %ags%
|
||||
@@ -6,3 +6,4 @@ call bin\windows\typescript-fetch-petstore-with-npm-version.bat
|
||||
call bin\windows\typescript-fetch-petstore-interfaces.bat
|
||||
call bin\windows\typescript-fetch-petstore-multiple-parameters.bat
|
||||
call bin\windows\typescript-fetch-petstore-prefix-parameter-interfaces.bat
|
||||
call bin\windows\typescript-fetch-petstore-typescript-three-plus.bat
|
||||
@@ -0,0 +1,12 @@
|
||||
@ECHO OFF
|
||||
|
||||
set executable=.\modules\openapi-generator-cli\target\openapi-generator-cli.jar
|
||||
|
||||
If Not Exist %executable% (
|
||||
mvn clean package
|
||||
)
|
||||
|
||||
REM set JAVA_OPTS=%JAVA_OPTS% -Xmx1024M
|
||||
set ags=generate -i modules\openapi-generator\src\test\resources\2_0\petstore.yaml -g typescript-fetch -c bin/typescript-fetch-petstore-typescript-three-plus.json -o samples\client\petstore\typescript-fetch\builds\typescript-three-plus
|
||||
|
||||
java %JAVA_OPTS% -jar %executable% %ags%
|
||||
@@ -132,6 +132,7 @@ The following generators are available:
|
||||
## CONFIG generators
|
||||
* [apache2](generators/apache2)
|
||||
* [graphql-schema](generators/graphql-schema)
|
||||
* [protobuf-schema (beta)](generators/protobuf-schema)
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -17,6 +17,6 @@ sidebar_label: dart-jaguar
|
||||
|pubDescription|Description in generated pubspec| |null|
|
||||
|useEnumExtension|Allow the 'x-enum-values' extension for enums| |null|
|
||||
|sourceFolder|Source folder for generated code| |null|
|
||||
|supportDart2|Support Dart 2.x| |true|
|
||||
|supportDart2|Support Dart 2.x (Dart 1.x support has been deprecated)| |true|
|
||||
|nullableFields|Is the null fields should be in the JSON payload| |null|
|
||||
|serialization|Choose serialization format JSON or PROTO is supported| |null|
|
||||
|
||||
@@ -17,4 +17,4 @@ sidebar_label: dart
|
||||
|pubDescription|Description in generated pubspec| |null|
|
||||
|useEnumExtension|Allow the 'x-enum-values' extension for enums| |null|
|
||||
|sourceFolder|Source folder for generated code| |null|
|
||||
|supportDart2|Support Dart 2.x| |true|
|
||||
|supportDart2|Support Dart 2.x (Dart 1.x support has been deprecated)| |true|
|
||||
|
||||
9
docs/generators/grpc-schema.md
Normal file
9
docs/generators/grpc-schema.md
Normal file
@@ -0,0 +1,9 @@
|
||||
|
||||
---
|
||||
id: generator-opts-config-grpc-schema
|
||||
title: Config Options for grpc-schema
|
||||
sidebar_label: grpc-schema
|
||||
---
|
||||
|
||||
| Option | Description | Values | Default |
|
||||
| ------ | ----------- | ------ | ------- |
|
||||
@@ -55,4 +55,5 @@ sidebar_label: java
|
||||
|feignVersion|Version of OpenFeign: '10.x', '9.x' (default)| |false|
|
||||
|useReflectionEqualsHashCode|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.| |false|
|
||||
|caseInsensitiveResponseHeaders|Make API response's headers case-insensitive. Available on okhttp-gson, jersey2 libraries| |false|
|
||||
|library|library template (sub-template) to use|<dl><dt>**jersey1**</dt><dd>HTTP client: Jersey client 1.19.x. JSON processing: Jackson 2.8.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.8.x</dd><dt>**feign**</dt><dd>HTTP client: OpenFeign 9.x or 10.x. JSON processing: Jackson 2.8.x. To enable OpenFeign 10.x, set the 'feignVersion' option to '10.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>**retrofit**</dt><dd>HTTP client: OkHttp 2.x. JSON processing: Gson 2.x (Retrofit 1.9.0). IMPORTANT NOTE: retrofit1.x is no longer actively maintained so please upgrade to 'retrofit2' instead.</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]=true'. (RxJava 1.x or 2.x)</dd><dt>**resttemplate**</dt><dd>HTTP client: Spring RestTemplate 4.x. JSON processing: Jackson 2.8.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.8.x</dd><dt>**vertx**</dt><dd>HTTP client: VertX client 3.x. JSON processing: Jackson 2.8.x</dd><dt>**google-api-client**</dt><dd>HTTP client: Google API client 1.x. JSON processing: Jackson 2.8.x</dd><dt>**rest-assured**</dt><dd>HTTP client: rest-assured : 4.x. JSON processing: Gson 2.x. Only for Java8</dd><dt>**native**</dt><dd>HTTP client: Java native HttpClient. JSON processing: Jackson 2.9.x. Only for Java11+</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 9.x or 10.x. JSON processing: Jackson 2.9.x. To enable OpenFeign 10.x, set the 'feignVersion' option to '10.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>**retrofit**</dt><dd>HTTP client: OkHttp 2.x. JSON processing: Gson 2.x (Retrofit 1.9.0). IMPORTANT NOTE: retrofit1.x is no longer actively maintained so please upgrade to 'retrofit2' instead.</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]=true'. (RxJava 1.x or 2.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.9.x. Only for Java8</dd><dt>**native**</dt><dd>HTTP client: Java native HttpClient. JSON processing: Jackson 2.9.x. Only for Java11+</dd><dl>|okhttp-gson|
|
||||
|serializationLibrary|Serialization library, default depends from the library|<dl><dt>**jackson**</dt><dd>Use Jackson as serialization library</dd><dt>**gson**</dt><dd>Use Gson as serialization library</dd><dl>|null|
|
||||
|
||||
@@ -14,6 +14,7 @@ sidebar_label: kotlin-server
|
||||
|artifactId|Generated artifact id (name of jar).| |kotlin-server|
|
||||
|artifactVersion|Generated artifact's package version.| |1.0.0|
|
||||
|enumPropertyNaming|Naming convention for enum properties: 'camelCase', 'PascalCase', 'snake_case', 'UPPERCASE', and 'original'| |camelCase|
|
||||
|serializationLibrary|What serialization library to use: 'moshi' (default), or 'gson'| |moshi|
|
||||
|parcelizeModels|toggle "@Parcelize" for generated models| |null|
|
||||
|library|library template (sub-template)|<dl><dt>**ktor**</dt><dd>ktor framework</dd><dl>|ktor|
|
||||
|featureAutoHead|Automatically provide responses to HEAD requests for existing routes that have the GET verb defined.| |true|
|
||||
|
||||
@@ -14,6 +14,7 @@ sidebar_label: kotlin-spring
|
||||
|artifactId|Generated artifact id (name of jar).| |openapi-spring|
|
||||
|artifactVersion|Generated artifact's package version.| |1.0.0|
|
||||
|enumPropertyNaming|Naming convention for enum properties: 'camelCase', 'PascalCase', 'snake_case', 'UPPERCASE', and 'original'| |camelCase|
|
||||
|serializationLibrary|What serialization library to use: 'moshi' (default), or 'gson'| |moshi|
|
||||
|parcelizeModels|toggle "@Parcelize" for generated models| |null|
|
||||
|title|server title name or client service name| |OpenAPI Kotlin Spring|
|
||||
|basePackage|base package (invokerPackage) for generated code| |org.openapitools|
|
||||
|
||||
@@ -14,6 +14,7 @@ sidebar_label: kotlin
|
||||
|artifactId|Generated artifact id (name of jar).| |kotlin-client|
|
||||
|artifactVersion|Generated artifact's package version.| |1.0.0|
|
||||
|enumPropertyNaming|Naming convention for enum properties: 'camelCase', 'PascalCase', 'snake_case', 'UPPERCASE', and 'original'| |camelCase|
|
||||
|serializationLibrary|What serialization library to use: 'moshi' (default), or 'gson'| |moshi|
|
||||
|parcelizeModels|toggle "@Parcelize" for generated models| |null|
|
||||
|dateLibrary|Option. Date library to use|<dl><dt>**string**</dt><dd>String</dd><dt>**java8**</dt><dd>Java 8 native JSR310</dd><dt>**threetenbp**</dt><dd>Threetenbp</dd><dl>|java8|
|
||||
|collectionType|Option. Collection type to use|<dl><dt>**array**</dt><dd>kotlin.Array</dd><dt>**list**</dt><dd>kotlin.collections.List</dd><dl>|array|
|
||||
|
||||
9
docs/generators/protobuf-schema.md
Normal file
9
docs/generators/protobuf-schema.md
Normal file
@@ -0,0 +1,9 @@
|
||||
|
||||
---
|
||||
id: generator-opts-config-protobuf-schema
|
||||
title: Config Options for protobuf-schema
|
||||
sidebar_label: protobuf-schema
|
||||
---
|
||||
|
||||
| Option | Description | Values | Default |
|
||||
| ------ | ----------- | ------ | ------- |
|
||||
@@ -20,3 +20,4 @@ sidebar_label: typescript-fetch
|
||||
|withInterfaces|Setting this property to true will generate interfaces next to the default class implementations.| |false|
|
||||
|useSingleRequestParameter|Setting this property to true will generate functions with a single argument containing all API endpoint parameters instead of one argument per parameter.| |true|
|
||||
|prefixParameterInterfaces|Setting this property to true will generate parameter interface declarations prefixed with API class name to avoid name conflicts.| |false|
|
||||
|typescriptThreePlus|Setting this property to true will generate TypeScript 3.6+ compatible code.| |false|
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
<groupId>org.openapitools</groupId>
|
||||
<artifactId>openapi-generator-project</artifactId>
|
||||
<!-- RELEASE_VERSION -->
|
||||
<version>4.1.1</version>
|
||||
<version>4.1.2</version>
|
||||
<!-- /RELEASE_VERSION -->
|
||||
<relativePath>../..</relativePath>
|
||||
</parent>
|
||||
|
||||
@@ -178,6 +178,10 @@ public class Generate implements Runnable {
|
||||
@Option(name = {"--library"}, title = "library", description = CodegenConstants.LIBRARY_DESC)
|
||||
private String library;
|
||||
|
||||
@Option(name = {"--git-host"}, title = "git host",
|
||||
description = CodegenConstants.GIT_HOST_DESC)
|
||||
private String gitHost;
|
||||
|
||||
@Option(name = {"--git-user-id"}, title = "git user id",
|
||||
description = CodegenConstants.GIT_USER_ID_DESC)
|
||||
private String gitUserId;
|
||||
@@ -343,6 +347,10 @@ public class Generate implements Runnable {
|
||||
configurator.setLibrary(library);
|
||||
}
|
||||
|
||||
if (isNotEmpty(gitHost)) {
|
||||
configurator.setGitHost(gitHost);
|
||||
}
|
||||
|
||||
if (isNotEmpty(gitUserId)) {
|
||||
configurator.setGitUserId(gitUserId);
|
||||
}
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
<artifactId>openapi-generator-project</artifactId>
|
||||
<groupId>org.openapitools</groupId>
|
||||
<!-- RELEASE_VERSION -->
|
||||
<version>4.1.1</version>
|
||||
<version>4.1.2</version>
|
||||
<!-- /RELEASE_VERSION -->
|
||||
<relativePath>../..</relativePath>
|
||||
</parent>
|
||||
|
||||
@@ -30,6 +30,7 @@ import java.util.*;
|
||||
public final class GeneratorSettings implements Serializable {
|
||||
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(GeneratorSettings.class);
|
||||
private static String DEFAULT_GIT_HOST = "github.com";
|
||||
private static String DEFAULT_GIT_USER_ID = "GIT_USER_ID";
|
||||
private static String DEFAULT_GIT_REPO_ID = "GIT_REPO_ID";
|
||||
private static String DEFAULT_RELEASE_NOTE = "Minor update";
|
||||
@@ -54,6 +55,7 @@ public final class GeneratorSettings implements Serializable {
|
||||
private ImmutableMap<String, String> reservedWordMappings;
|
||||
private ImmutableMap<String, String> serverVariables;
|
||||
|
||||
private String gitHost;
|
||||
private String gitUserId;
|
||||
private String gitRepoId;
|
||||
private String releaseNote;
|
||||
@@ -256,6 +258,17 @@ public final class GeneratorSettings implements Serializable {
|
||||
return serverVariables;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets git host. e.g. <strong>gitlab.com</strong>.
|
||||
* <p>
|
||||
* Generally used by git_push.sh in generated sources which support it.
|
||||
* This value may also be used by templates in maven style references, READMEs, or other documentation.
|
||||
*
|
||||
* @return the git host
|
||||
*/
|
||||
public String getGitHost() {
|
||||
return gitHost;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets git user id. e.g. <strong>openapitools</strong>.
|
||||
@@ -324,6 +337,7 @@ public final class GeneratorSettings implements Serializable {
|
||||
languageSpecificPrimitives = ImmutableSet.copyOf(builder.languageSpecificPrimitives);
|
||||
reservedWordMappings = ImmutableMap.copyOf(builder.reservedWordMappings);
|
||||
serverVariables = ImmutableMap.copyOf(builder.serverVariables);
|
||||
gitHost = builder.gitHost;
|
||||
gitUserId = builder.gitUserId;
|
||||
gitRepoId = builder.gitRepoId;
|
||||
releaseNote = builder.releaseNote;
|
||||
@@ -358,6 +372,9 @@ public final class GeneratorSettings implements Serializable {
|
||||
if (isNotEmpty(modelNameSuffix)) {
|
||||
additional.put("modelNameSuffix", modelNameSuffix);
|
||||
}
|
||||
if (isNotEmpty(gitHost)) {
|
||||
additional.put("gitHost", gitHost);
|
||||
}
|
||||
if (isNotEmpty(gitUserId)) {
|
||||
additional.put("gitUserId", gitUserId);
|
||||
}
|
||||
@@ -390,6 +407,7 @@ public final class GeneratorSettings implements Serializable {
|
||||
}
|
||||
|
||||
private void setDefaults() {
|
||||
gitHost = DEFAULT_GIT_HOST;
|
||||
gitUserId = DEFAULT_GIT_USER_ID;
|
||||
gitRepoId = DEFAULT_GIT_REPO_ID;
|
||||
releaseNote = DEFAULT_RELEASE_NOTE;
|
||||
@@ -442,6 +460,7 @@ public final class GeneratorSettings implements Serializable {
|
||||
if (copy.getServerVariables() != null) {
|
||||
builder.serverVariables.putAll(copy.getServerVariables());
|
||||
}
|
||||
builder.gitHost = copy.getGitHost();
|
||||
builder.gitUserId = copy.getGitUserId();
|
||||
builder.gitRepoId = copy.getGitRepoId();
|
||||
builder.releaseNote = copy.getReleaseNote();
|
||||
@@ -473,6 +492,7 @@ public final class GeneratorSettings implements Serializable {
|
||||
private Set<String> languageSpecificPrimitives;
|
||||
private Map<String, String> reservedWordMappings;
|
||||
private Map<String, String> serverVariables;
|
||||
private String gitHost;
|
||||
private String gitUserId;
|
||||
private String gitRepoId;
|
||||
private String releaseNote;
|
||||
@@ -490,6 +510,7 @@ public final class GeneratorSettings implements Serializable {
|
||||
reservedWordMappings = new HashMap<>();
|
||||
serverVariables = new HashMap<>();
|
||||
|
||||
gitHost = DEFAULT_GIT_HOST;
|
||||
gitUserId = DEFAULT_GIT_USER_ID;
|
||||
gitRepoId = DEFAULT_GIT_REPO_ID;
|
||||
releaseNote = DEFAULT_RELEASE_NOTE;
|
||||
@@ -783,6 +804,17 @@ public final class GeneratorSettings implements Serializable {
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the {@code gitHost} and returns a reference to this Builder so that the methods can be chained together.
|
||||
*
|
||||
* @param gitHost the {@code gitHost} to set
|
||||
* @return a reference to this Builder
|
||||
*/
|
||||
public Builder withGitHost(String gitHost) {
|
||||
this.gitHost = gitHost;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the {@code gitUserId} and returns a reference to this Builder so that the methods can be chained together.
|
||||
*
|
||||
@@ -860,6 +892,7 @@ public final class GeneratorSettings implements Serializable {
|
||||
", importMappings=" + importMappings +
|
||||
", languageSpecificPrimitives=" + languageSpecificPrimitives +
|
||||
", reservedWordMappings=" + reservedWordMappings +
|
||||
", gitHost='" + gitHost + '\'' +
|
||||
", gitUserId='" + gitUserId + '\'' +
|
||||
", gitRepoId='" + gitRepoId + '\'' +
|
||||
", releaseNote='" + releaseNote + '\'' +
|
||||
@@ -889,6 +922,7 @@ public final class GeneratorSettings implements Serializable {
|
||||
Objects.equals(getImportMappings(), that.getImportMappings()) &&
|
||||
Objects.equals(getLanguageSpecificPrimitives(), that.getLanguageSpecificPrimitives()) &&
|
||||
Objects.equals(getReservedWordMappings(), that.getReservedWordMappings()) &&
|
||||
Objects.equals(getGitHost(), that.getGitHost()) &&
|
||||
Objects.equals(getGitUserId(), that.getGitUserId()) &&
|
||||
Objects.equals(getGitRepoId(), that.getGitRepoId()) &&
|
||||
Objects.equals(getReleaseNote(), that.getReleaseNote()) &&
|
||||
@@ -915,6 +949,7 @@ public final class GeneratorSettings implements Serializable {
|
||||
getImportMappings(),
|
||||
getLanguageSpecificPrimitives(),
|
||||
getReservedWordMappings(),
|
||||
getGitHost(),
|
||||
getGitUserId(),
|
||||
getGitRepoId(),
|
||||
getReleaseNote(),
|
||||
|
||||
@@ -202,6 +202,11 @@ apply plugin: 'org.openapi.generator'
|
||||
|None
|
||||
|Reference the library template (sub-template) of a generator.
|
||||
|
||||
|gitHost
|
||||
|String
|
||||
|github.com
|
||||
|Git user ID, e.g. gitlab.com.
|
||||
|
||||
|gitUserId
|
||||
|String
|
||||
|None
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
# RELEASE_VERSION
|
||||
openApiGeneratorVersion=4.1.1
|
||||
openApiGeneratorVersion=4.1.2
|
||||
# /RELEASE_VERSION
|
||||
|
||||
# BEGIN placeholders
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
<groupId>org.openapitools</groupId>
|
||||
<artifactId>openapi-generator-project</artifactId>
|
||||
<!-- RELEASE_VERSION -->
|
||||
<version>4.1.1</version>
|
||||
<version>4.1.2</version>
|
||||
<!-- /RELEASE_VERSION -->
|
||||
<relativePath>../..</relativePath>
|
||||
</parent>
|
||||
|
||||
@@ -116,6 +116,7 @@ class OpenApiGeneratorPlugin : Plugin<Project> {
|
||||
id.set(generate.id)
|
||||
version.set(generate.version)
|
||||
library.set(generate.library)
|
||||
gitHost.set(generate.gitHost)
|
||||
gitUserId.set(generate.gitUserId)
|
||||
gitRepoId.set(generate.gitRepoId)
|
||||
releaseNote.set(generate.releaseNote)
|
||||
|
||||
@@ -160,6 +160,11 @@ open class OpenApiGeneratorGenerateExtension(project: Project) {
|
||||
*/
|
||||
val library = project.objects.property<String?>()
|
||||
|
||||
/**
|
||||
* Git host, e.g. gitlab.com.
|
||||
*/
|
||||
val gitHost = project.objects.property<String?>()
|
||||
|
||||
/**
|
||||
* Git user ID, e.g. openapitools.
|
||||
*/
|
||||
|
||||
@@ -204,6 +204,12 @@ open class GenerateTask : DefaultTask() {
|
||||
@get:Internal
|
||||
val library = project.objects.property<String?>()
|
||||
|
||||
/**
|
||||
* Git host, e.g. gitlab.com.
|
||||
*/
|
||||
@get:Internal
|
||||
val gitHost = project.objects.property<String?>()
|
||||
|
||||
/**
|
||||
* Git user ID, e.g. openapitools.
|
||||
*/
|
||||
@@ -510,6 +516,10 @@ open class GenerateTask : DefaultTask() {
|
||||
configurator.setLibrary(value)
|
||||
}
|
||||
|
||||
gitHost.ifNotEmpty { value ->
|
||||
configurator.setGitHost(value)
|
||||
}
|
||||
|
||||
gitUserId.ifNotEmpty { value ->
|
||||
configurator.setGitUserId(value)
|
||||
}
|
||||
|
||||
@@ -91,6 +91,7 @@ mvn clean compile
|
||||
| `reservedWordsMappings` | `openapi.generator.maven.plugin.reservedWordsMappings` | specifies how a reserved name should be escaped to. Otherwise, the default `_<name>` is used. For example `id=identifier`. You can also have multiple occurrences of this option
|
||||
| `skipIfSpecIsUnchanged` | `codegen.skipIfSpecIsUnchanged` | Skip the execution if the source file is older than the output folder (`false` by default. Can also be set globally through the `codegen.skipIfSpecIsUnchanged` property)
|
||||
| `engine` | `openapi.generator.maven.plugin.engine` | The name of templating engine to use, "mustache" (default) or "handlebars" (beta)
|
||||
| `httpUserAgent` | `openapi.generator.maven.plugin.httpUserAgent` | Sets custom User-Agent header value
|
||||
|
||||
|
||||
### Custom Generator
|
||||
|
||||
@@ -13,10 +13,11 @@
|
||||
<groupId>org.openapitools</groupId>
|
||||
<artifactId>openapi-generator-maven-plugin</artifactId>
|
||||
<!-- RELEASE_VERSION -->
|
||||
<version>4.1.1</version>
|
||||
<version>4.1.2-SNAPSHOT</version>
|
||||
<!-- /RELEASE_VERSION -->
|
||||
<executions>
|
||||
<execution>
|
||||
<id>default</id>
|
||||
<goals>
|
||||
<goal>generate</goal>
|
||||
</goals>
|
||||
@@ -39,6 +40,36 @@
|
||||
<library>jersey2</library>
|
||||
</configuration>
|
||||
</execution>
|
||||
<execution>
|
||||
<id>remote</id>
|
||||
<phase>generate-sources</phase>
|
||||
<goals>
|
||||
<goal>generate</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<!-- specify the swagger yaml -->
|
||||
<inputSpec>https://raw.githubusercontent.com/OpenAPITools/openapi-generator/master/modules/openapi-generator/src/test/resources/2_0/petstore.yaml</inputSpec>
|
||||
|
||||
<!-- target to generate java client code -->
|
||||
<generatorName>java</generatorName>
|
||||
|
||||
<!-- hint: if you want to generate java server code, e.g. based on Spring Boot,
|
||||
you can use the following target: <generatorName>spring</generatorName> -->
|
||||
|
||||
<!-- pass any necessary config options -->
|
||||
<configOptions>
|
||||
<dateLibrary>joda</dateLibrary>
|
||||
</configOptions>
|
||||
|
||||
<!-- override the default library to jersey2 -->
|
||||
<library>jersey2</library>
|
||||
|
||||
<output>${project.build.directory}/generated-sources/remote-openapi</output>
|
||||
<apiPackage>remote.org.openapitools.client.api</apiPackage>
|
||||
<modelPackage>remote.org.openapitools.client.model</modelPackage>
|
||||
<invokerPackage>remote.org.openapitools.client</invokerPackage>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<plugin>
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
<groupId>org.openapitools</groupId>
|
||||
<artifactId>openapi-generator-maven-plugin</artifactId>
|
||||
<!-- RELEASE_VERSION -->
|
||||
<version>4.1.1</version>
|
||||
<version>4.1.2-SNAPSHOT</version>
|
||||
<!-- /RELEASE_VERSION -->
|
||||
<dependencies>
|
||||
<dependency>
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
<groupId>org.openapitools</groupId>
|
||||
<artifactId>openapi-generator-project</artifactId>
|
||||
<!-- RELEASE_VERSION -->
|
||||
<version>4.1.1</version>
|
||||
<version>4.1.2</version>
|
||||
<!-- /RELEASE_VERSION -->
|
||||
<relativePath>../..</relativePath>
|
||||
</parent>
|
||||
@@ -66,7 +66,7 @@
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-plugin-plugin</artifactId>
|
||||
<version>3.5.2</version>
|
||||
<version>3.6.0</version>
|
||||
<configuration>
|
||||
<skipErrorNoDescriptorsFound>true</skipErrorNoDescriptorsFound>
|
||||
</configuration>
|
||||
|
||||
@@ -20,7 +20,18 @@ package org.openapitools.codegen.plugin;
|
||||
import static org.apache.commons.lang3.StringUtils.isNotEmpty;
|
||||
import static org.openapitools.codegen.config.CodegenConfiguratorUtils.*;
|
||||
|
||||
import io.swagger.v3.parser.core.models.AuthorizationValue;
|
||||
import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.net.MalformedURLException;
|
||||
import java.net.URI;
|
||||
import java.net.URISyntaxException;
|
||||
import java.net.URL;
|
||||
import java.net.URLConnection;
|
||||
import java.nio.channels.Channels;
|
||||
import java.nio.channels.FileChannel;
|
||||
import java.nio.channels.ReadableByteChannel;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
@@ -42,6 +53,7 @@ import org.openapitools.codegen.ClientOptInput;
|
||||
import org.openapitools.codegen.CodegenConfig;
|
||||
import org.openapitools.codegen.CodegenConstants;
|
||||
import org.openapitools.codegen.DefaultGenerator;
|
||||
import org.openapitools.codegen.auth.AuthParser;
|
||||
import org.openapitools.codegen.config.CodegenConfigurator;
|
||||
import org.openapitools.codegen.config.GlobalSettings;
|
||||
import org.sonatype.plexus.build.incremental.BuildContext;
|
||||
@@ -97,6 +109,12 @@ public class CodeGenMojo extends AbstractMojo {
|
||||
@Parameter(name = "inputSpec", property = "openapi.generator.maven.plugin.inputSpec", required = true)
|
||||
private String inputSpec;
|
||||
|
||||
/**
|
||||
* Git host, e.g. gitlab.com.
|
||||
*/
|
||||
@Parameter(name = "gitHost", property = "openapi.generator.maven.plugin.gitHost", required = false)
|
||||
private String gitHost;
|
||||
|
||||
/**
|
||||
* Git user ID, e.g. swagger-api.
|
||||
*/
|
||||
@@ -206,6 +224,12 @@ public class CodeGenMojo extends AbstractMojo {
|
||||
@Parameter(name = "ignoreFileOverride", property = "openapi.generator.maven.plugin.ignoreFileOverride", required = false)
|
||||
private String ignoreFileOverride;
|
||||
|
||||
/**
|
||||
* Sets custom User-Agent header value
|
||||
*/
|
||||
@Parameter(name = "httpUserAgent", property = "openapi.generator.maven.plugin.httpUserAgent", required = false)
|
||||
private String httpUserAgent;
|
||||
|
||||
/**
|
||||
* To remove operationId prefix (e.g. user_getName => getName)
|
||||
*/
|
||||
@@ -417,7 +441,7 @@ public class CodeGenMojo extends AbstractMojo {
|
||||
if (inputSpecFile.exists()) {
|
||||
File storedInputSpecHashFile = getHashFile(inputSpecFile);
|
||||
if(storedInputSpecHashFile.exists()) {
|
||||
String inputSpecHash = Files.asByteSource(inputSpecFile).hash(Hashing.sha256()).toString();
|
||||
String inputSpecHash = calculateInputSpecHash(inputSpecFile);
|
||||
String storedInputSpecHash = Files.asCharSource(storedInputSpecHashFile, Charsets.UTF_8).read();
|
||||
if (inputSpecHash.equals(storedInputSpecHash)) {
|
||||
getLog().info(
|
||||
@@ -450,6 +474,10 @@ public class CodeGenMojo extends AbstractMojo {
|
||||
configurator.setInputSpec(inputSpec);
|
||||
}
|
||||
|
||||
if (isNotEmpty(gitHost)) {
|
||||
configurator.setGitHost(gitHost);
|
||||
}
|
||||
|
||||
if (isNotEmpty(gitUserId)) {
|
||||
configurator.setGitUserId(gitUserId);
|
||||
}
|
||||
@@ -462,6 +490,10 @@ public class CodeGenMojo extends AbstractMojo {
|
||||
configurator.setIgnoreFileOverride(ignoreFileOverride);
|
||||
}
|
||||
|
||||
if (isNotEmpty(httpUserAgent)) {
|
||||
configurator.setHttpUserAgent(httpUserAgent);
|
||||
}
|
||||
|
||||
if (skipValidateSpec != null) {
|
||||
configurator.setValidateSpec(!skipValidateSpec);
|
||||
}
|
||||
@@ -700,12 +732,7 @@ public class CodeGenMojo extends AbstractMojo {
|
||||
|
||||
// Store a checksum of the input spec
|
||||
File storedInputSpecHashFile = getHashFile(inputSpecFile);
|
||||
ByteSource inputSpecByteSource =
|
||||
inputSpecFile.exists()
|
||||
? Files.asByteSource(inputSpecFile)
|
||||
: CharSource.wrap(ClasspathHelper.loadFileFromClasspath(inputSpecFile.toString().replaceAll("\\\\","/")))
|
||||
.asByteSource(Charsets.UTF_8);
|
||||
String inputSpecHash =inputSpecByteSource.hash(Hashing.sha256()).toString();
|
||||
String inputSpecHash = calculateInputSpecHash(inputSpecFile);
|
||||
|
||||
if (storedInputSpecHashFile.getParent() != null && !new File(storedInputSpecHashFile.getParent()).exists()) {
|
||||
File parent = new File(storedInputSpecHashFile.getParent());
|
||||
@@ -726,8 +753,75 @@ public class CodeGenMojo extends AbstractMojo {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Calculate openapi specification file hash. If specification is hosted on remote resource it is downloaded first
|
||||
*
|
||||
* @param inputSpecFile - Openapi specification input file to calculate it's hash.
|
||||
* Does not taken into account if input spec is hosted on remote resource
|
||||
* @return openapi specification file hash
|
||||
* @throws IOException
|
||||
*/
|
||||
private String calculateInputSpecHash(File inputSpecFile) throws IOException {
|
||||
|
||||
URL inputSpecRemoteUrl = inputSpecRemoteUrl();
|
||||
|
||||
File inputSpecTempFile = inputSpecFile;
|
||||
|
||||
if (inputSpecRemoteUrl != null) {
|
||||
inputSpecTempFile = File.createTempFile("openapi-spec", ".tmp");
|
||||
|
||||
URLConnection conn = inputSpecRemoteUrl.openConnection();
|
||||
if (isNotEmpty(auth)) {
|
||||
List<AuthorizationValue> authList = AuthParser.parse(auth);
|
||||
for (AuthorizationValue auth : authList) {
|
||||
conn.setRequestProperty(auth.getKeyName(), auth.getValue());
|
||||
}
|
||||
}
|
||||
ReadableByteChannel readableByteChannel = Channels.newChannel(conn.getInputStream());
|
||||
|
||||
FileOutputStream fileOutputStream = new FileOutputStream(inputSpecTempFile);
|
||||
FileChannel fileChannel = fileOutputStream.getChannel();
|
||||
|
||||
fileChannel.transferFrom(readableByteChannel, 0, Long.MAX_VALUE);
|
||||
}
|
||||
|
||||
ByteSource inputSpecByteSource =
|
||||
inputSpecTempFile.exists()
|
||||
? Files.asByteSource(inputSpecTempFile)
|
||||
: CharSource.wrap(ClasspathHelper.loadFileFromClasspath(inputSpecTempFile.toString().replaceAll("\\\\","/")))
|
||||
.asByteSource(Charsets.UTF_8);
|
||||
|
||||
return inputSpecByteSource.hash(Hashing.sha256()).toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* Try to parse inputSpec setting string into URL
|
||||
* @return A valid URL or null if inputSpec is not a valid URL
|
||||
*/
|
||||
private URL inputSpecRemoteUrl(){
|
||||
try {
|
||||
return new URI(inputSpec).toURL();
|
||||
} catch (URISyntaxException | MalformedURLException | IllegalArgumentException e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get specification hash file
|
||||
* @param inputSpecFile - Openapi specification input file to calculate it's hash.
|
||||
* Does not taken into account if input spec is hosted on remote resource
|
||||
* @return a file with previously calculated hash
|
||||
*/
|
||||
private File getHashFile(File inputSpecFile) {
|
||||
return new File(output.getPath() + File.separator + ".openapi-generator" + File.separator + inputSpecFile.getName() + ".sha256");
|
||||
String name = inputSpecFile.getName();
|
||||
|
||||
URL url = inputSpecRemoteUrl();
|
||||
if (url != null) {
|
||||
String[] segments = url.getPath().split("/");
|
||||
name = Files.getNameWithoutExtension(segments[segments.length - 1]);
|
||||
}
|
||||
|
||||
return new File(output.getPath() + File.separator + ".openapi-generator" + File.separator + name + ".sha256");
|
||||
}
|
||||
|
||||
private String getCompileSourceRoot() {
|
||||
@@ -737,8 +831,7 @@ public class CodeGenMojo extends AbstractMojo {
|
||||
final String sourceFolder =
|
||||
sourceFolderObject == null ? "src/main/java" : sourceFolderObject.toString();
|
||||
|
||||
String sourceJavaFolder = output.toString() + "/" + sourceFolder;
|
||||
return sourceJavaFolder;
|
||||
return output.toString() + "/" + sourceFolder;
|
||||
}
|
||||
|
||||
private void addCompileSourceRootIfConfigured() {
|
||||
@@ -783,4 +876,4 @@ public class CodeGenMojo extends AbstractMojo {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -4,7 +4,7 @@
|
||||
<groupId>org.openapitools</groupId>
|
||||
<artifactId>openapi-generator-project</artifactId>
|
||||
<!-- RELEASE_VERSION -->
|
||||
<version>4.1.1</version>
|
||||
<version>4.1.2</version>
|
||||
<!-- /RELEASE_VERSION -->
|
||||
<relativePath>../..</relativePath>
|
||||
</parent>
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
<groupId>org.openapitools</groupId>
|
||||
<artifactId>openapi-generator-project</artifactId>
|
||||
<!-- RELEASE_VERSION -->
|
||||
<version>4.1.1</version>
|
||||
<version>4.1.2</version>
|
||||
<!-- /RELEASE_VERSION -->
|
||||
<relativePath>../..</relativePath>
|
||||
</parent>
|
||||
|
||||
@@ -222,6 +222,10 @@ public interface CodegenConfig {
|
||||
*/
|
||||
String getLibrary();
|
||||
|
||||
void setGitHost(String gitHost);
|
||||
|
||||
String getGitHost();
|
||||
|
||||
void setGitUserId(String gitUserId);
|
||||
|
||||
String getGitUserId();
|
||||
|
||||
@@ -202,12 +202,19 @@ public class CodegenConstants {
|
||||
public static final String ENUM_PROPERTY_NAMING = "enumPropertyNaming";
|
||||
public static final String ENUM_PROPERTY_NAMING_DESC = "Naming convention for enum properties: 'camelCase', 'PascalCase', 'snake_case', 'UPPERCASE', and 'original'";
|
||||
|
||||
// Allow different language generators to offer an option of serialization library. Each language specific
|
||||
// Codegen constants should define a description and provide proper input validation for the value of serializationLibrary
|
||||
public static final String SERIALIZATION_LIBRARY = "serializationLibrary";
|
||||
|
||||
public static final String MODEL_NAME_PREFIX = "modelNamePrefix";
|
||||
public static final String MODEL_NAME_PREFIX_DESC = "Prefix that will be prepended to all model names.";
|
||||
|
||||
public static final String MODEL_NAME_SUFFIX = "modelNameSuffix";
|
||||
public static final String MODEL_NAME_SUFFIX_DESC = "Suffix that will be appended to all model names.";
|
||||
|
||||
public static final String GIT_HOST = "gitHost";
|
||||
public static final String GIT_HOST_DESC = "Git host, e.g. gitlab.com.";
|
||||
|
||||
public static final String GIT_USER_ID = "gitUserId";
|
||||
public static final String GIT_USER_ID_DESC = "Git user ID, e.g. openapitools.";
|
||||
|
||||
|
||||
@@ -111,7 +111,7 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
protected Boolean sortParamsByRequiredFlag = true;
|
||||
protected Boolean ensureUniqueParams = true;
|
||||
protected Boolean allowUnicodeIdentifiers = false;
|
||||
protected String gitUserId, gitRepoId, releaseNote;
|
||||
protected String gitHost, gitUserId, gitRepoId, releaseNote;
|
||||
protected String httpUserAgent;
|
||||
protected Boolean hideGenerationTimestamp = true;
|
||||
// How to encode special characters like $
|
||||
@@ -1247,7 +1247,7 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
return instantiationTypes.get("map") + "<String, " + inner + ">";
|
||||
} else if (ModelUtils.isArraySchema(schema)) {
|
||||
ArraySchema arraySchema = (ArraySchema) schema;
|
||||
String inner = getSchemaType(arraySchema.getItems());
|
||||
String inner = getSchemaType(getSchemaItems(arraySchema));
|
||||
return instantiationTypes.get("array") + "<" + inner + ">";
|
||||
} else {
|
||||
return null;
|
||||
@@ -1462,6 +1462,15 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
|
||||
}
|
||||
|
||||
protected Schema<?> getSchemaItems(ArraySchema schema) {
|
||||
if (schema.getItems() != null) {
|
||||
return schema.getItems();
|
||||
} else {
|
||||
LOGGER.error("Undefined array inner type for `{}`. Default to String.", schema.getName());
|
||||
return new StringSchema().description("TODO default missing array inner type to string");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the name of the allOf schema
|
||||
*
|
||||
@@ -2180,11 +2189,10 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
property.isFreeFormObject = true;
|
||||
} else if (ModelUtils.isArraySchema(p)) {
|
||||
// default to string if inner item is undefined
|
||||
Schema innerSchema = ModelUtils.unaliasSchema(this.openAPI, ((ArraySchema) p).getItems());
|
||||
if (innerSchema == null) {
|
||||
LOGGER.error("Undefined array inner type for `{}`. Default to String.", p.getName());
|
||||
innerSchema = new StringSchema().description("//TODO automatically added by openapi-generator due to undefined type");
|
||||
((ArraySchema) p).setItems(innerSchema);
|
||||
ArraySchema arraySchema = (ArraySchema) p;
|
||||
Schema innerSchema = ModelUtils.unaliasSchema(this.openAPI, getSchemaItems(arraySchema));
|
||||
if (arraySchema.getItems() == null) {
|
||||
arraySchema.setItems(innerSchema);
|
||||
}
|
||||
} else if (ModelUtils.isMapSchema(p)) {
|
||||
Schema innerSchema = ModelUtils.unaliasSchema(this.openAPI, ModelUtils.getAdditionalProperties(p));
|
||||
@@ -2262,11 +2270,10 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
if (itemName == null) {
|
||||
itemName = property.name;
|
||||
}
|
||||
Schema innerSchema = ModelUtils.unaliasSchema(this.openAPI, ((ArraySchema) p).getItems());
|
||||
if (innerSchema == null) {
|
||||
LOGGER.error("Undefined array inner type for `{}`. Default to String.", p.getName());
|
||||
innerSchema = new StringSchema().description("//TODO automatically added by openapi-generator due to undefined type");
|
||||
((ArraySchema) p).setItems(innerSchema);
|
||||
ArraySchema arraySchema = (ArraySchema) p;
|
||||
Schema innerSchema = ModelUtils.unaliasSchema(this.openAPI, getSchemaItems(arraySchema));
|
||||
if (arraySchema.getItems() == null) {
|
||||
arraySchema.setItems(innerSchema);
|
||||
}
|
||||
CodegenProperty cp = fromProperty(itemName, innerSchema);
|
||||
updatePropertyForArray(property, cp);
|
||||
@@ -2584,7 +2591,7 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
|
||||
if (ModelUtils.isArraySchema(responseSchema)) {
|
||||
ArraySchema as = (ArraySchema) responseSchema;
|
||||
CodegenProperty innerProperty = fromProperty("response", as.getItems());
|
||||
CodegenProperty innerProperty = fromProperty("response", getSchemaItems(as));
|
||||
op.returnBaseType = innerProperty.baseType;
|
||||
} else if (ModelUtils.isMapSchema(responseSchema)) {
|
||||
CodegenProperty innerProperty = fromProperty("response", ModelUtils.getAdditionalProperties(responseSchema));
|
||||
@@ -2854,7 +2861,7 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
|
||||
if (ModelUtils.isArraySchema(responseSchema)) {
|
||||
ArraySchema as = (ArraySchema) responseSchema;
|
||||
CodegenProperty innerProperty = fromProperty("response", as.getItems());
|
||||
CodegenProperty innerProperty = fromProperty("response", getSchemaItems(as));
|
||||
CodegenProperty innerCp = innerProperty;
|
||||
while (innerCp != null) {
|
||||
r.baseType = innerCp.baseType;
|
||||
@@ -3062,10 +3069,8 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
String collectionFormat = null;
|
||||
if (ModelUtils.isArraySchema(parameterSchema)) { // for array parameter
|
||||
final ArraySchema arraySchema = (ArraySchema) parameterSchema;
|
||||
Schema inner = arraySchema.getItems();
|
||||
if (inner == null) {
|
||||
LOGGER.warn("warning! No inner type supplied for array parameter \"" + parameter.getName() + "\", using String");
|
||||
inner = new StringSchema().description("//TODO automatically added by openapi-generator due to missing iner type definition in the spec");
|
||||
Schema inner = getSchemaItems(arraySchema);
|
||||
if (arraySchema.getItems() == null) {
|
||||
arraySchema.setItems(inner);
|
||||
}
|
||||
|
||||
@@ -3901,6 +3906,24 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
return library;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Git host.
|
||||
*
|
||||
* @param gitHost Git host
|
||||
*/
|
||||
public void setGitHost(String gitHost) {
|
||||
this.gitHost = gitHost;
|
||||
}
|
||||
|
||||
/**
|
||||
* Git host.
|
||||
*
|
||||
* @return Git host
|
||||
*/
|
||||
public String getGitHost() {
|
||||
return gitHost;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Git user ID.
|
||||
*
|
||||
@@ -4598,10 +4621,8 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
// array of schema
|
||||
if (ModelUtils.isArraySchema(s)) {
|
||||
final ArraySchema arraySchema = (ArraySchema) s;
|
||||
Schema inner = arraySchema.getItems();
|
||||
if (inner == null) {
|
||||
LOGGER.error("No inner type supplied for array parameter `{}`. Default to type:string", s.getName());
|
||||
inner = new StringSchema().description("//TODO automatically added by openapi-generator due to missing inner type definition in the spec");
|
||||
Schema inner = getSchemaItems(arraySchema);
|
||||
if (arraySchema.getItems() == null) {
|
||||
arraySchema.setItems(inner);
|
||||
}
|
||||
|
||||
@@ -4798,10 +4819,8 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
setParameterNullable(codegenParameter, codegenProperty);
|
||||
} else if (ModelUtils.isArraySchema(schema)) {
|
||||
final ArraySchema arraySchema = (ArraySchema) schema;
|
||||
Schema inner = arraySchema.getItems();
|
||||
if (inner == null) {
|
||||
LOGGER.error("No inner type supplied for array parameter `{}`. Default to type:string", schema.getName());
|
||||
inner = new StringSchema().description("//TODO automatically added by openapi-generator due to undefined type");
|
||||
Schema inner = getSchemaItems(arraySchema);
|
||||
if (arraySchema.getItems() == null) {
|
||||
arraySchema.setItems(inner);
|
||||
}
|
||||
CodegenProperty codegenProperty = fromProperty("property", arraySchema);
|
||||
@@ -5020,11 +5039,7 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
protected void generateJSONSpecFile(Map<String, Object> objs) {
|
||||
OpenAPI openAPI = (OpenAPI) objs.get("openAPI");
|
||||
if (openAPI != null) {
|
||||
try {
|
||||
objs.put("openapi-json", Json.pretty().writeValueAsString(openAPI).replace("\r\n", "\n"));
|
||||
} catch (JsonProcessingException e) {
|
||||
LOGGER.error(e.getMessage(), e);
|
||||
}
|
||||
objs.put("openapi-json", SerializerUtils.toJsonString(openAPI));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -37,6 +37,7 @@ import org.openapitools.codegen.api.TemplatingEngineAdapter;
|
||||
import org.openapitools.codegen.ignore.CodegenIgnoreProcessor;
|
||||
import org.openapitools.codegen.meta.GeneratorMetadata;
|
||||
import org.openapitools.codegen.meta.Stability;
|
||||
import org.openapitools.codegen.serializer.SerializerUtils;
|
||||
import org.openapitools.codegen.templating.MustacheEngineAdapter;
|
||||
import org.openapitools.codegen.utils.ImplementationVersion;
|
||||
import org.openapitools.codegen.utils.ModelUtils;
|
||||
@@ -183,12 +184,12 @@ public class DefaultGenerator extends AbstractGenerator implements Generator {
|
||||
}
|
||||
|
||||
if (GlobalSettings.getProperty("debugOpenAPI") != null) {
|
||||
Json.prettyPrint(openAPI);
|
||||
SerializerUtils.toJsonString(openAPI);
|
||||
} else if (GlobalSettings.getProperty("debugSwagger") != null) {
|
||||
// This exists for backward compatibility
|
||||
// We fall to this block only if debugOpenAPI is null. No need to dump this twice.
|
||||
LOGGER.info("Please use system property 'debugOpenAPI' instead of 'debugSwagger'.");
|
||||
Json.prettyPrint(openAPI);
|
||||
SerializerUtils.toJsonString(openAPI);
|
||||
}
|
||||
|
||||
config.processOpts();
|
||||
|
||||
@@ -222,6 +222,11 @@ public class CodegenConfigurator {
|
||||
return this;
|
||||
}
|
||||
|
||||
public CodegenConfigurator setGitHost(String gitHost) {
|
||||
generatorSettingsBuilder.withGitHost(gitHost);
|
||||
return this;
|
||||
}
|
||||
|
||||
public CodegenConfigurator setGitUserId(String gitUserId) {
|
||||
generatorSettingsBuilder.withGitUserId(gitUserId);
|
||||
return this;
|
||||
|
||||
@@ -374,6 +374,7 @@ public abstract class AbstractGoCodegen extends DefaultCodegen implements Codege
|
||||
boolean addedOptionalImport = false;
|
||||
boolean addedTimeImport = false;
|
||||
boolean addedOSImport = false;
|
||||
boolean addedReflectImport = false;
|
||||
for (CodegenOperation operation : operations) {
|
||||
for (CodegenParameter param : operation.allParams) {
|
||||
// import "os" if the operation uses files
|
||||
@@ -391,8 +392,9 @@ public abstract class AbstractGoCodegen extends DefaultCodegen implements Codege
|
||||
}
|
||||
|
||||
// import "reflect" package if the parameter is collectionFormat=multi
|
||||
if (param.isCollectionFormatMulti) {
|
||||
if (!addedReflectImport && param.isCollectionFormatMulti) {
|
||||
imports.add(createMapping("import", "reflect"));
|
||||
addedReflectImport = true;
|
||||
}
|
||||
|
||||
// import "optionals" package if the parameter is optional
|
||||
|
||||
@@ -686,14 +686,8 @@ public abstract class AbstractJavaCodegen extends DefaultCodegen implements Code
|
||||
@Override
|
||||
public String getTypeDeclaration(Schema p) {
|
||||
if (ModelUtils.isArraySchema(p)) {
|
||||
ArraySchema ap = (ArraySchema) p;
|
||||
Schema inner = ap.getItems();
|
||||
if (inner == null) {
|
||||
LOGGER.error("`{}` (array property) does not have a proper inner type defined. Default to type:string", ap.getName());
|
||||
inner = new StringSchema().description("TODO default missing array inner type to string");
|
||||
ap.setItems(inner);
|
||||
}
|
||||
return getSchemaType(p) + "<" + getTypeDeclaration(inner) + ">";
|
||||
Schema<?> items = getSchemaItems((ArraySchema) p);
|
||||
return getSchemaType(p) + "<" + getTypeDeclaration(items) + ">";
|
||||
} else if (ModelUtils.isMapSchema(p)) {
|
||||
Schema inner = ModelUtils.getAdditionalProperties(p);
|
||||
if (inner == null) {
|
||||
@@ -718,7 +712,6 @@ public abstract class AbstractJavaCodegen extends DefaultCodegen implements Code
|
||||
public String toDefaultValue(Schema p) {
|
||||
p = ModelUtils.getReferencedSchema(this.openAPI, p);
|
||||
if (ModelUtils.isArraySchema(p)) {
|
||||
final ArraySchema ap = (ArraySchema) p;
|
||||
final String pattern;
|
||||
if (fullJavaUtil) {
|
||||
pattern = "new java.util.ArrayList<%s>()";
|
||||
@@ -726,13 +719,9 @@ public abstract class AbstractJavaCodegen extends DefaultCodegen implements Code
|
||||
pattern = "new ArrayList<%s>()";
|
||||
}
|
||||
|
||||
if (ap.getItems() == null) {
|
||||
LOGGER.error("`{}` (array property) does not have a proper inner type defined. Default to type:string", ap.getName());
|
||||
Schema inner = new StringSchema().description("TODO default missing array inner type to string");
|
||||
ap.setItems(inner);
|
||||
}
|
||||
Schema<?> items = getSchemaItems((ArraySchema) p);
|
||||
|
||||
String typeDeclaration = getTypeDeclaration(ap.getItems());
|
||||
String typeDeclaration = getTypeDeclaration(items);
|
||||
Object java8obj = additionalProperties.get("java8");
|
||||
if (java8obj != null) {
|
||||
Boolean java8 = Boolean.valueOf(java8obj.toString());
|
||||
|
||||
@@ -35,6 +35,10 @@ import java.util.*;
|
||||
import static org.openapitools.codegen.utils.StringUtils.*;
|
||||
|
||||
public abstract class AbstractKotlinCodegen extends DefaultCodegen implements CodegenConfig {
|
||||
|
||||
public static final String SERIALIZATION_LIBRARY_DESC = "What serialization library to use: 'moshi' (default), or 'gson'";
|
||||
public enum SERIALIZATION_LIBRARY_TYPE {moshi, gson}
|
||||
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(AbstractKotlinCodegen.class);
|
||||
|
||||
protected String artifactId;
|
||||
@@ -51,6 +55,7 @@ public abstract class AbstractKotlinCodegen extends DefaultCodegen implements Co
|
||||
protected boolean parcelizeModels = false;
|
||||
|
||||
protected CodegenConstants.ENUM_PROPERTY_NAMING_TYPE enumPropertyNaming = CodegenConstants.ENUM_PROPERTY_NAMING_TYPE.camelCase;
|
||||
protected SERIALIZATION_LIBRARY_TYPE serializationLibrary = SERIALIZATION_LIBRARY_TYPE.moshi;
|
||||
|
||||
public AbstractKotlinCodegen() {
|
||||
super();
|
||||
@@ -205,6 +210,10 @@ public abstract class AbstractKotlinCodegen extends DefaultCodegen implements Co
|
||||
|
||||
CliOption enumPropertyNamingOpt = new CliOption(CodegenConstants.ENUM_PROPERTY_NAMING, CodegenConstants.ENUM_PROPERTY_NAMING_DESC);
|
||||
cliOptions.add(enumPropertyNamingOpt.defaultValue(enumPropertyNaming.name()));
|
||||
|
||||
CliOption serializationLibraryOpt = new CliOption(CodegenConstants.SERIALIZATION_LIBRARY, SERIALIZATION_LIBRARY_DESC);
|
||||
cliOptions.add(serializationLibraryOpt.defaultValue(serializationLibrary.name()));
|
||||
|
||||
cliOptions.add(new CliOption(CodegenConstants.PARCELIZE_MODELS, CodegenConstants.PARCELIZE_MODELS_DESC));
|
||||
}
|
||||
|
||||
@@ -244,6 +253,10 @@ public abstract class AbstractKotlinCodegen extends DefaultCodegen implements Co
|
||||
return this.enumPropertyNaming;
|
||||
}
|
||||
|
||||
public SERIALIZATION_LIBRARY_TYPE getSerializationLibrary() {
|
||||
return this.serializationLibrary;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the naming convention for Kotlin enum properties
|
||||
*
|
||||
@@ -261,6 +274,24 @@ public abstract class AbstractKotlinCodegen extends DefaultCodegen implements Co
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the serialization engine for Kotlin
|
||||
*
|
||||
* @param enumSerializationLibrary The string representation of the serialization library as defined by
|
||||
* {@link org.openapitools.codegen.languages.AbstractKotlinCodegen.SERIALIZATION_LIBRARY_TYPE}
|
||||
*/
|
||||
public void setSerializationLibrary(final String enumSerializationLibrary) {
|
||||
try {
|
||||
this.serializationLibrary = SERIALIZATION_LIBRARY_TYPE.valueOf(enumSerializationLibrary);
|
||||
} catch (IllegalArgumentException ex) {
|
||||
StringBuilder sb = new StringBuilder(enumSerializationLibrary + " is an invalid enum property naming option. Please choose from:");
|
||||
for (SERIALIZATION_LIBRARY_TYPE t : SERIALIZATION_LIBRARY_TYPE.values()) {
|
||||
sb.append("\n ").append(t.name());
|
||||
}
|
||||
throw new RuntimeException(sb.toString());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* returns the swagger type for the property
|
||||
*
|
||||
@@ -330,6 +361,14 @@ public abstract class AbstractKotlinCodegen extends DefaultCodegen implements Co
|
||||
setEnumPropertyNaming((String) additionalProperties.get(CodegenConstants.ENUM_PROPERTY_NAMING));
|
||||
}
|
||||
|
||||
if (additionalProperties.containsKey(CodegenConstants.SERIALIZATION_LIBRARY)) {
|
||||
setSerializationLibrary((String) additionalProperties.get(CodegenConstants.SERIALIZATION_LIBRARY));
|
||||
additionalProperties.put(this.serializationLibrary.name(), true);
|
||||
}
|
||||
else {
|
||||
additionalProperties.put(this.serializationLibrary.name(), true);
|
||||
}
|
||||
|
||||
if (additionalProperties.containsKey(CodegenConstants.SOURCE_FOLDER)) {
|
||||
this.setSourceFolder((String) additionalProperties.get(CodegenConstants.SOURCE_FOLDER));
|
||||
} else {
|
||||
|
||||
@@ -62,7 +62,7 @@ public class DartClientCodegen extends DefaultCodegen implements CodegenConfig {
|
||||
outputFolder = "generated-code/dart";
|
||||
modelTemplateFiles.put("model.mustache", ".dart");
|
||||
apiTemplateFiles.put("api.mustache", ".dart");
|
||||
embeddedTemplateDir = templateDir = "dart";
|
||||
embeddedTemplateDir = templateDir = "dart2";
|
||||
apiPackage = "lib.api";
|
||||
modelPackage = "lib.model";
|
||||
modelDocTemplateFiles.put("object_doc.mustache", ".md");
|
||||
@@ -124,7 +124,7 @@ public class DartClientCodegen extends DefaultCodegen implements CodegenConfig {
|
||||
cliOptions.add(new CliOption(PUB_DESCRIPTION, "Description in generated pubspec"));
|
||||
cliOptions.add(new CliOption(USE_ENUM_EXTENSION, "Allow the 'x-enum-values' extension for enums"));
|
||||
cliOptions.add(new CliOption(CodegenConstants.SOURCE_FOLDER, "Source folder for generated code"));
|
||||
cliOptions.add(CliOption.newBoolean(SUPPORT_DART2, "Support Dart 2.x").defaultValue(Boolean.TRUE.toString()));
|
||||
cliOptions.add(CliOption.newBoolean(SUPPORT_DART2, "Support Dart 2.x (Dart 1.x support has been deprecated)").defaultValue(Boolean.TRUE.toString()));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -139,7 +139,7 @@ public class DartClientCodegen extends DefaultCodegen implements CodegenConfig {
|
||||
|
||||
@Override
|
||||
public String getHelp() {
|
||||
return "Generates a Dart (1.x or 2.x) client library.";
|
||||
return "Generates a Dart (1.x (deprecated) or 2.x) client library.";
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -202,7 +202,10 @@ public class DartClientCodegen extends DefaultCodegen implements CodegenConfig {
|
||||
} else {
|
||||
// dart 2.x
|
||||
LOGGER.info("Dart version: 2.x");
|
||||
embeddedTemplateDir = templateDir = "dart2";
|
||||
// check to not overwrite a custom templateDir
|
||||
if (templateDir == null) {
|
||||
embeddedTemplateDir = templateDir = "dart2";
|
||||
}
|
||||
}
|
||||
|
||||
final String libFolder = sourceFolder + File.separator + "lib";
|
||||
|
||||
@@ -78,6 +78,9 @@ public class JavaClientCodegen extends AbstractJavaCodegen
|
||||
public static final String RETROFIT_2 = "retrofit2";
|
||||
public static final String VERTX = "vertx";
|
||||
|
||||
public static final String SERIALIZATION_LIBRARY_GSON = "gson";
|
||||
public static final String SERIALIZATION_LIBRARY_JACKSON = "jackson";
|
||||
|
||||
protected String gradleWrapperPackage = "gradle.wrapper";
|
||||
protected boolean useRxJava = false;
|
||||
protected boolean useRxJava2 = false;
|
||||
@@ -95,6 +98,7 @@ public class JavaClientCodegen extends AbstractJavaCodegen
|
||||
protected boolean useReflectionEqualsHashCode = false;
|
||||
protected boolean caseInsensitiveResponseHeaders = false;
|
||||
protected String authFolder;
|
||||
protected String serializationLibrary = null;
|
||||
|
||||
public JavaClientCodegen() {
|
||||
super();
|
||||
@@ -128,19 +132,18 @@ public class JavaClientCodegen extends AbstractJavaCodegen
|
||||
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"));
|
||||
|
||||
|
||||
supportedLibraries.put(JERSEY1, "HTTP client: Jersey client 1.19.x. JSON processing: Jackson 2.8.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.8.x");
|
||||
supportedLibraries.put(FEIGN, "HTTP client: OpenFeign 9.x or 10.x. JSON processing: Jackson 2.8.x. To enable OpenFeign 10.x, set the 'feignVersion' option to '10.x'");
|
||||
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 9.x or 10.x. JSON processing: Jackson 2.9.x. To enable OpenFeign 10.x, set the 'feignVersion' option to '10.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_1, "HTTP client: OkHttp 2.x. JSON processing: Gson 2.x (Retrofit 1.9.0). IMPORTANT NOTE: retrofit1.x is no longer actively maintained so please upgrade to 'retrofit2' instead.");
|
||||
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]=true'. (RxJava 1.x or 2.x)");
|
||||
supportedLibraries.put(RESTTEMPLATE, "HTTP client: Spring RestTemplate 4.x. JSON processing: Jackson 2.8.x");
|
||||
supportedLibraries.put(RESTTEMPLATE, "HTTP client: Spring RestTemplate 4.x. JSON processing: Jackson 2.9.x");
|
||||
supportedLibraries.put(WEBCLIENT, "HTTP client: Spring WebClient 5.x. JSON processing: Jackson 2.9.x");
|
||||
supportedLibraries.put(RESTEASY, "HTTP client: Resteasy client 3.x. JSON processing: Jackson 2.8.x");
|
||||
supportedLibraries.put(VERTX, "HTTP client: VertX client 3.x. JSON processing: Jackson 2.8.x");
|
||||
supportedLibraries.put(GOOGLE_API_CLIENT, "HTTP client: Google API client 1.x. JSON processing: Jackson 2.8.x");
|
||||
supportedLibraries.put(REST_ASSURED, "HTTP client: rest-assured : 4.x. JSON processing: Gson 2.x. Only for Java8");
|
||||
supportedLibraries.put(RESTEASY, "HTTP client: Resteasy client 3.x. JSON processing: Jackson 2.9.x");
|
||||
supportedLibraries.put(VERTX, "HTTP client: VertX client 3.x. JSON processing: Jackson 2.9.x");
|
||||
supportedLibraries.put(GOOGLE_API_CLIENT, "HTTP client: Google API client 1.x. JSON processing: Jackson 2.9.x");
|
||||
supportedLibraries.put(REST_ASSURED, "HTTP client: rest-assured : 4.x. JSON processing: Gson 2.x or Jackson 2.9.x. Only for Java8");
|
||||
supportedLibraries.put(NATIVE, "HTTP client: Java native HttpClient. JSON processing: Jackson 2.9.x. Only for Java11+");
|
||||
|
||||
CliOption libraryOption = new CliOption(CodegenConstants.LIBRARY, "library template (sub-template) to use");
|
||||
@@ -150,6 +153,12 @@ public class JavaClientCodegen extends AbstractJavaCodegen
|
||||
cliOptions.add(libraryOption);
|
||||
setLibrary(OKHTTP_GSON);
|
||||
|
||||
CliOption serializationLibrary = new CliOption(CodegenConstants.SERIALIZATION_LIBRARY, "Serialization library, default depends from the library");
|
||||
Map<String, String> serializationOptions = new HashMap<>();
|
||||
serializationOptions.put(SERIALIZATION_LIBRARY_GSON, "Use Gson as serialization library");
|
||||
serializationOptions.put(SERIALIZATION_LIBRARY_JACKSON, "Use Jackson as serialization library");
|
||||
serializationLibrary.setEnum(serializationOptions);
|
||||
cliOptions.add(serializationLibrary);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -284,6 +293,10 @@ public class JavaClientCodegen extends AbstractJavaCodegen
|
||||
"BeanValidationException.java"));
|
||||
}
|
||||
|
||||
if (additionalProperties.containsKey(CodegenConstants.SERIALIZATION_LIBRARY)) {
|
||||
setSerializationLibrary(additionalProperties.get(CodegenConstants.SERIALIZATION_LIBRARY).toString());
|
||||
}
|
||||
|
||||
//TODO: add doc to retrofit1 and feign
|
||||
if (FEIGN.equals(getLibrary()) || RETROFIT_1.equals(getLibrary())) {
|
||||
modelDocTemplateFiles.remove("model_doc.mustache");
|
||||
@@ -301,7 +314,7 @@ public class JavaClientCodegen extends AbstractJavaCodegen
|
||||
}
|
||||
|
||||
if (FEIGN.equals(getLibrary())) {
|
||||
additionalProperties.put("jackson", "true");
|
||||
forceSerializationLibrary(SERIALIZATION_LIBRARY_JACKSON);
|
||||
supportingFiles.add(new SupportingFile("ParamExpander.mustache", invokerFolder, "ParamExpander.java"));
|
||||
supportingFiles.add(new SupportingFile("EncodingUtils.mustache", invokerFolder, "EncodingUtils.java"));
|
||||
} else if (OKHTTP_GSON.equals(getLibrary()) || StringUtils.isEmpty(getLibrary())) {
|
||||
@@ -316,53 +329,60 @@ public class JavaClientCodegen extends AbstractJavaCodegen
|
||||
// NOTE: below moved to postProcessOpoerationsWithModels
|
||||
//supportingFiles.add(new SupportingFile("auth/OAuthOkHttpClient.mustache", authFolder, "OAuthOkHttpClient.java"));
|
||||
//supportingFiles.add(new SupportingFile("auth/RetryingOAuth.mustache", authFolder, "RetryingOAuth.java"));
|
||||
additionalProperties.put("gson", "true");
|
||||
forceSerializationLibrary(SERIALIZATION_LIBRARY_GSON);
|
||||
} else if (usesAnyRetrofitLibrary()) {
|
||||
supportingFiles.add(new SupportingFile("auth/OAuthOkHttpClient.mustache", authFolder, "OAuthOkHttpClient.java"));
|
||||
supportingFiles.add(new SupportingFile("CollectionFormats.mustache", invokerFolder, "CollectionFormats.java"));
|
||||
additionalProperties.put("gson", "true");
|
||||
forceSerializationLibrary(SERIALIZATION_LIBRARY_GSON);
|
||||
if ("retrofit2".equals(getLibrary()) && !usePlayWS) {
|
||||
supportingFiles.add(new SupportingFile("JSON.mustache", invokerFolder, "JSON.java"));
|
||||
}
|
||||
} else if (JERSEY2.equals(getLibrary())) {
|
||||
supportingFiles.add(new SupportingFile("JSON.mustache", invokerFolder, "JSON.java"));
|
||||
supportingFiles.add(new SupportingFile("ApiResponse.mustache", invokerFolder, "ApiResponse.java"));
|
||||
additionalProperties.put("jackson", "true");
|
||||
forceSerializationLibrary(SERIALIZATION_LIBRARY_JACKSON);
|
||||
} else if (NATIVE.equals(getLibrary())) {
|
||||
setJava8Mode(true);
|
||||
additionalProperties.put("java8", "true");
|
||||
additionalProperties.put("jackson", "true");
|
||||
forceSerializationLibrary(SERIALIZATION_LIBRARY_JACKSON);
|
||||
} else if (RESTEASY.equals(getLibrary())) {
|
||||
supportingFiles.add(new SupportingFile("JSON.mustache", invokerFolder, "JSON.java"));
|
||||
additionalProperties.put("jackson", "true");
|
||||
forceSerializationLibrary(SERIALIZATION_LIBRARY_JACKSON);
|
||||
} else if (JERSEY1.equals(getLibrary())) {
|
||||
additionalProperties.put("jackson", "true");
|
||||
forceSerializationLibrary(SERIALIZATION_LIBRARY_JACKSON);
|
||||
} else if (RESTTEMPLATE.equals(getLibrary())) {
|
||||
additionalProperties.put("jackson", "true");
|
||||
forceSerializationLibrary(SERIALIZATION_LIBRARY_JACKSON);
|
||||
supportingFiles.add(new SupportingFile("auth/Authentication.mustache", authFolder, "Authentication.java"));
|
||||
} else if (WEBCLIENT.equals(getLibrary())) {
|
||||
setJava8Mode(true);
|
||||
additionalProperties.put("java8", "true");
|
||||
additionalProperties.put("jackson", "true");
|
||||
forceSerializationLibrary(SERIALIZATION_LIBRARY_JACKSON);
|
||||
} else if (VERTX.equals(getLibrary())) {
|
||||
typeMapping.put("file", "AsyncFile");
|
||||
importMapping.put("AsyncFile", "io.vertx.core.file.AsyncFile");
|
||||
setJava8Mode(true);
|
||||
additionalProperties.put("java8", "true");
|
||||
additionalProperties.put("jackson", "true");
|
||||
forceSerializationLibrary(SERIALIZATION_LIBRARY_JACKSON);
|
||||
apiTemplateFiles.put("apiImpl.mustache", "Impl.java");
|
||||
apiTemplateFiles.put("rxApiImpl.mustache", ".java");
|
||||
supportingFiles.remove(new SupportingFile("manifest.mustache", projectFolder, "AndroidManifest.xml"));
|
||||
} else if (GOOGLE_API_CLIENT.equals(getLibrary())) {
|
||||
additionalProperties.put("jackson", "true");
|
||||
forceSerializationLibrary(SERIALIZATION_LIBRARY_JACKSON);
|
||||
|
||||
} else if (REST_ASSURED.equals(getLibrary())) {
|
||||
additionalProperties.put("gson", "true");
|
||||
if(getSerializationLibrary() == null) {
|
||||
LOGGER.info("No serializationLibrary configured, using '"+SERIALIZATION_LIBRARY_GSON+"' as fallback");
|
||||
setSerializationLibrary(SERIALIZATION_LIBRARY_GSON);
|
||||
}
|
||||
if(SERIALIZATION_LIBRARY_JACKSON.equals(getSerializationLibrary())) {
|
||||
supportingFiles.add(new SupportingFile("JacksonObjectMapper.mustache", invokerFolder, "JacksonObjectMapper.java"));
|
||||
} else if (SERIALIZATION_LIBRARY_GSON.equals(getSerializationLibrary())) {
|
||||
supportingFiles.add(new SupportingFile("JSON.mustache", invokerFolder, "JSON.java"));
|
||||
supportingFiles.add(new SupportingFile("GsonObjectMapper.mustache", invokerFolder, "GsonObjectMapper.java"));
|
||||
}
|
||||
additionalProperties.put("convert", new CaseFormatLambda(LOWER_CAMEL, UPPER_UNDERSCORE));
|
||||
apiTemplateFiles.put("api.mustache", ".java");
|
||||
supportingFiles.add(new SupportingFile("ResponseSpecBuilders.mustache", invokerFolder, "ResponseSpecBuilders.java"));
|
||||
supportingFiles.add(new SupportingFile("JSON.mustache", invokerFolder, "JSON.java"));
|
||||
supportingFiles.add(new SupportingFile("GsonObjectMapper.mustache", invokerFolder, "GsonObjectMapper.java"));
|
||||
} else {
|
||||
LOGGER.error("Unknown library option (-l/--library): " + getLibrary());
|
||||
}
|
||||
@@ -415,16 +435,30 @@ public class JavaClientCodegen extends AbstractJavaCodegen
|
||||
supportingFiles.add(new SupportingFile("auth/Authentication.mustache", authFolder, "Authentication.java"));
|
||||
supportingFiles.add(new SupportingFile("Pair.mustache", invokerFolder, "Pair.java"));
|
||||
|
||||
additionalProperties.put("jackson", "true");
|
||||
additionalProperties.remove("gson");
|
||||
forceSerializationLibrary(SERIALIZATION_LIBRARY_JACKSON);
|
||||
}
|
||||
|
||||
if (additionalProperties.containsKey("jackson") && !NATIVE.equals(getLibrary())) {
|
||||
supportingFiles.add(new SupportingFile("RFC3339DateFormat.mustache", invokerFolder, "RFC3339DateFormat.java"));
|
||||
if ("threetenbp".equals(dateLibrary) && !usePlayWS) {
|
||||
supportingFiles.add(new SupportingFile("CustomInstantDeserializer.mustache", invokerFolder, "CustomInstantDeserializer.java"));
|
||||
}
|
||||
if(getSerializationLibrary() == null) {
|
||||
LOGGER.info("No serializationLibrary configured, using '"+SERIALIZATION_LIBRARY_GSON+"' as fallback");
|
||||
setSerializationLibrary(SERIALIZATION_LIBRARY_GSON);
|
||||
}
|
||||
if(SERIALIZATION_LIBRARY_JACKSON.equals(getSerializationLibrary())) {
|
||||
additionalProperties.put(SERIALIZATION_LIBRARY_JACKSON, "true");
|
||||
additionalProperties.remove(SERIALIZATION_LIBRARY_GSON);
|
||||
if (!NATIVE.equals(getLibrary())) {
|
||||
supportingFiles.add(new SupportingFile("RFC3339DateFormat.mustache", invokerFolder, "RFC3339DateFormat.java"));
|
||||
if ("threetenbp".equals(dateLibrary) && !usePlayWS) {
|
||||
supportingFiles.add(new SupportingFile("CustomInstantDeserializer.mustache", invokerFolder, "CustomInstantDeserializer.java"));
|
||||
}
|
||||
}
|
||||
} else if (SERIALIZATION_LIBRARY_GSON.equals(getSerializationLibrary())) {
|
||||
additionalProperties.put(SERIALIZATION_LIBRARY_GSON, "true");
|
||||
additionalProperties.remove(SERIALIZATION_LIBRARY_JACKSON);
|
||||
} else {
|
||||
additionalProperties.remove(SERIALIZATION_LIBRARY_JACKSON);
|
||||
additionalProperties.remove(SERIALIZATION_LIBRARY_GSON);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private boolean usesAnyRetrofitLibrary() {
|
||||
@@ -581,12 +615,12 @@ public class JavaClientCodegen extends AbstractJavaCodegen
|
||||
if (!BooleanUtils.toBoolean(model.isEnum)) {
|
||||
//final String lib = getLibrary();
|
||||
//Needed imports for Jackson based libraries
|
||||
if (additionalProperties.containsKey("jackson")) {
|
||||
if (additionalProperties.containsKey(SERIALIZATION_LIBRARY_JACKSON)) {
|
||||
model.imports.add("JsonProperty");
|
||||
model.imports.add("JsonValue");
|
||||
model.imports.add("JsonInclude");
|
||||
}
|
||||
if (additionalProperties.containsKey("gson")) {
|
||||
if (additionalProperties.containsKey(SERIALIZATION_LIBRARY_GSON)) {
|
||||
model.imports.add("SerializedName");
|
||||
model.imports.add("TypeAdapter");
|
||||
model.imports.add("JsonAdapter");
|
||||
@@ -596,7 +630,7 @@ public class JavaClientCodegen extends AbstractJavaCodegen
|
||||
}
|
||||
} else { // enum class
|
||||
//Needed imports for Jackson's JsonCreator
|
||||
if (additionalProperties.containsKey("jackson")) {
|
||||
if (additionalProperties.containsKey(SERIALIZATION_LIBRARY_JACKSON)) {
|
||||
model.imports.add("JsonValue");
|
||||
model.imports.add("JsonCreator");
|
||||
}
|
||||
@@ -607,7 +641,7 @@ public class JavaClientCodegen extends AbstractJavaCodegen
|
||||
public Map<String, Object> postProcessModelsEnum(Map<String, Object> objs) {
|
||||
objs = super.postProcessModelsEnum(objs);
|
||||
//Needed import for Gson based libraries
|
||||
if (additionalProperties.containsKey("gson")) {
|
||||
if (additionalProperties.containsKey(SERIALIZATION_LIBRARY_GSON)) {
|
||||
List<Map<String, String>> imports = (List<Map<String, String>>) objs.get("imports");
|
||||
List<Object> models = (List<Object>) objs.get("models");
|
||||
for (Object _mo : models) {
|
||||
@@ -628,7 +662,7 @@ public class JavaClientCodegen extends AbstractJavaCodegen
|
||||
@Override
|
||||
public Map<String, Object> postProcessModels(Map<String, Object> objs) {
|
||||
objs = super.postProcessModels(objs);
|
||||
if (additionalProperties.containsKey("jackson") && !JERSEY1.equals(getLibrary())) {
|
||||
if (additionalProperties.containsKey(SERIALIZATION_LIBRARY_JACKSON) && !JERSEY1.equals(getLibrary())) {
|
||||
List<Map<String, String>> imports = (List<Map<String, String>>) objs.get("imports");
|
||||
List<Object> models = (List<Object>) objs.get("models");
|
||||
for (Object _mo : models) {
|
||||
@@ -712,6 +746,31 @@ public class JavaClientCodegen extends AbstractJavaCodegen
|
||||
this.caseInsensitiveResponseHeaders = caseInsensitiveResponseHeaders;
|
||||
}
|
||||
|
||||
/**
|
||||
* Serialization library.
|
||||
* @return 'gson' or 'jackson'
|
||||
*/
|
||||
public String getSerializationLibrary() {
|
||||
return serializationLibrary;
|
||||
}
|
||||
|
||||
public void setSerializationLibrary(String serializationLibrary) {
|
||||
if(SERIALIZATION_LIBRARY_JACKSON.equalsIgnoreCase(serializationLibrary)) {
|
||||
this.serializationLibrary = SERIALIZATION_LIBRARY_JACKSON;
|
||||
} else if(SERIALIZATION_LIBRARY_GSON.equalsIgnoreCase(serializationLibrary)) {
|
||||
this.serializationLibrary = SERIALIZATION_LIBRARY_GSON;
|
||||
} else {
|
||||
throw new IllegalArgumentException("Unexpected serializationLibrary value: " + serializationLibrary);
|
||||
}
|
||||
}
|
||||
|
||||
public void forceSerializationLibrary(String serializationLibrary) {
|
||||
if((this.serializationLibrary != null) && !this.serializationLibrary.equalsIgnoreCase(serializationLibrary)) {
|
||||
LOGGER.warn("The configured serializationLibrary '" + this.serializationLibrary + "', is not supported by the library: '" + getLibrary() + "', switching back to: " + serializationLibrary);
|
||||
}
|
||||
setSerializationLibrary(serializationLibrary);
|
||||
}
|
||||
|
||||
final private static Pattern JSON_MIME_PATTERN = Pattern.compile("(?i)application\\/json(;.*)?");
|
||||
final private static Pattern JSON_VENDOR_MIME_PATTERN = Pattern.compile("(?i)application\\/vnd.(.*)+json(;.*)?");
|
||||
|
||||
|
||||
@@ -239,6 +239,9 @@ public class JavaJAXRSSpecServerCodegen extends AbstractJavaJAXRSServerCodegen {
|
||||
public String toApiName(final String name) {
|
||||
String computed = name;
|
||||
if (computed.length() == 0) {
|
||||
if (primaryResourceName == null) {
|
||||
return "DefaultApi";
|
||||
}
|
||||
return primaryResourceName + "Api";
|
||||
}
|
||||
computed = sanitizeName(computed);
|
||||
|
||||
@@ -163,11 +163,11 @@ public class NodeJSExpressServerCodegen extends DefaultCodegen implements Codege
|
||||
if (templateName.equals("service.mustache")) {
|
||||
String stringToMatch = File.separator + "controllers" + File.separator;
|
||||
String replacement = File.separator + implFolder + File.separator;
|
||||
result = result.replaceAll(Pattern.quote(stringToMatch), replacement);
|
||||
|
||||
result = result.replace(stringToMatch, replacement);
|
||||
|
||||
stringToMatch = "Controller.js";
|
||||
replacement = "Service.js";
|
||||
result = result.replaceAll(Pattern.quote(stringToMatch), replacement);
|
||||
result = result.replace(stringToMatch, replacement);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -17,13 +17,13 @@
|
||||
|
||||
package org.openapitools.codegen.languages;
|
||||
|
||||
import io.swagger.v3.core.util.Json;
|
||||
import io.swagger.v3.oas.models.OpenAPI;
|
||||
import org.apache.commons.io.FileUtils;
|
||||
import org.openapitools.codegen.CodegenConfig;
|
||||
import org.openapitools.codegen.CodegenType;
|
||||
import org.openapitools.codegen.DefaultCodegen;
|
||||
import org.openapitools.codegen.SupportingFile;
|
||||
import org.openapitools.codegen.serializer.SerializerUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
@@ -58,11 +58,11 @@ public class OpenAPIGenerator extends DefaultCodegen implements CodegenConfig {
|
||||
|
||||
@Override
|
||||
public void processOpenAPI(OpenAPI openAPI) {
|
||||
String swaggerString = Json.pretty(openAPI);
|
||||
String jsonOpenAPI = SerializerUtils.toJsonString(openAPI);
|
||||
|
||||
try {
|
||||
String outputFile = outputFolder + File.separator + "openapi.json";
|
||||
FileUtils.writeStringToFile(new File(outputFile), swaggerString);
|
||||
FileUtils.writeStringToFile(new File(outputFile), jsonOpenAPI);
|
||||
LOGGER.info("wrote file to " + outputFile);
|
||||
} catch (Exception e) {
|
||||
LOGGER.error(e.getMessage(), e);
|
||||
|
||||
@@ -0,0 +1,458 @@
|
||||
/*
|
||||
* Copyright 2019 OpenAPI-Generator Contributors (https://openapi-generator.tech)
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.openapitools.codegen.languages;
|
||||
|
||||
import io.swagger.v3.oas.models.media.ArraySchema;
|
||||
import io.swagger.v3.oas.models.media.Schema;
|
||||
|
||||
import org.openapitools.codegen.CliOption;
|
||||
import org.openapitools.codegen.CodegenConfig;
|
||||
import org.openapitools.codegen.CodegenConstants;
|
||||
import org.openapitools.codegen.CodegenType;
|
||||
import org.openapitools.codegen.*;
|
||||
import org.openapitools.codegen.meta.GeneratorMetadata;
|
||||
import org.openapitools.codegen.meta.Stability;
|
||||
import org.openapitools.codegen.utils.ProcessUtils;
|
||||
import org.openapitools.codegen.utils.ModelUtils;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.*;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import static org.openapitools.codegen.utils.StringUtils.camelize;
|
||||
import static org.openapitools.codegen.utils.StringUtils.underscore;
|
||||
|
||||
public class ProtobufSchemaCodegen extends DefaultCodegen implements CodegenConfig {
|
||||
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(ProtobufSchemaCodegen.class);
|
||||
|
||||
protected String packageName = "openapitools";
|
||||
|
||||
@Override
|
||||
public CodegenType getTag() {
|
||||
return CodegenType.CONFIG;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return "protobuf-schema";
|
||||
}
|
||||
|
||||
public String getHelp() {
|
||||
return "Generates gRPC and protocol buffer schema files (beta)";
|
||||
}
|
||||
|
||||
public ProtobufSchemaCodegen() {
|
||||
super();
|
||||
|
||||
generatorMetadata = GeneratorMetadata.newBuilder(generatorMetadata)
|
||||
.stability(Stability.BETA)
|
||||
.build();
|
||||
|
||||
outputFolder = "generated-code/protobuf-schema";
|
||||
modelTemplateFiles.put("model.mustache", ".proto");
|
||||
apiTemplateFiles.put("api.mustache", ".proto");
|
||||
embeddedTemplateDir = templateDir = "protobuf-schema";
|
||||
hideGenerationTimestamp = Boolean.TRUE;
|
||||
modelPackage = "messages";
|
||||
apiPackage = "services";
|
||||
|
||||
/*setReservedWordsLowerCase(
|
||||
Arrays.asList(
|
||||
// data type
|
||||
"nil", "string", "boolean", "number", "userdata", "thread",
|
||||
"table",
|
||||
|
||||
// reserved words: http://www.lua.org/manual/5.1/manual.html#2.1
|
||||
"and", "break", "do", "else", "elseif",
|
||||
"end", "false", "for", "function", "if",
|
||||
"in", "local", "nil", "not", "or",
|
||||
"repeat", "return", "then", "true", "until", "while"
|
||||
)
|
||||
);*/
|
||||
|
||||
defaultIncludes = new HashSet<String>(
|
||||
Arrays.asList(
|
||||
"map",
|
||||
"array")
|
||||
);
|
||||
|
||||
languageSpecificPrimitives = new HashSet<String>(
|
||||
Arrays.asList(
|
||||
"map",
|
||||
"array",
|
||||
"bool",
|
||||
"bytes",
|
||||
"string",
|
||||
"int32",
|
||||
"int64",
|
||||
"uint32",
|
||||
"uint64",
|
||||
"sint32",
|
||||
"sint64",
|
||||
"fixed32",
|
||||
"fixed64",
|
||||
"sfixed32",
|
||||
"sfixed64",
|
||||
"float",
|
||||
"double")
|
||||
);
|
||||
|
||||
instantiationTypes.clear();
|
||||
instantiationTypes.put("array", "repeat");
|
||||
//instantiationTypes.put("map", "map");
|
||||
|
||||
// ref: https://developers.google.com/protocol-buffers/docs/proto
|
||||
typeMapping.clear();
|
||||
typeMapping.put("array", "array");
|
||||
typeMapping.put("map", "map");
|
||||
typeMapping.put("integer", "int32");
|
||||
typeMapping.put("long", "int64");
|
||||
typeMapping.put("number", "float");
|
||||
typeMapping.put("float", "float");
|
||||
typeMapping.put("double", "double");
|
||||
typeMapping.put("boolean", "bool");
|
||||
typeMapping.put("string", "string");
|
||||
typeMapping.put("UUID", "string");
|
||||
typeMapping.put("URI", "string");
|
||||
typeMapping.put("date", "string");
|
||||
typeMapping.put("DateTime", "string");
|
||||
typeMapping.put("password", "string");
|
||||
// TODO fix file mapping
|
||||
typeMapping.put("file", "string");
|
||||
typeMapping.put("binary", "string");
|
||||
typeMapping.put("ByteArray", "bytes");
|
||||
typeMapping.put("object", "TODO_OBJECT_MAPPING");
|
||||
|
||||
importMapping.clear();
|
||||
/*
|
||||
importMapping = new HashMap<String, String>();
|
||||
importMapping.put("time.Time", "time");
|
||||
importMapping.put("*os.File", "os");
|
||||
importMapping.put("os", "io/ioutil");
|
||||
*/
|
||||
|
||||
modelDocTemplateFiles.put("model_doc.mustache", ".md");
|
||||
apiDocTemplateFiles.put("api_doc.mustache", ".md");
|
||||
|
||||
cliOptions.clear();
|
||||
/*cliOptions.add(new CliOption(CodegenConstants.PACKAGE_NAME, "GraphQL package name (convention: lowercase).")
|
||||
.defaultValue("openapi2graphql"));
|
||||
cliOptions.add(new CliOption(CodegenConstants.PACKAGE_VERSION, "GraphQL package version.")
|
||||
.defaultValue("1.0.0"));
|
||||
cliOptions.add(new CliOption(CodegenConstants.HIDE_GENERATION_TIMESTAMP, CodegenConstants.HIDE_GENERATION_TIMESTAMP_DESC)
|
||||
.defaultValue(Boolean.TRUE.toString()));*/
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void processOpts() {
|
||||
super.processOpts();
|
||||
|
||||
//apiTestTemplateFiles.put("api_test.mustache", ".proto");
|
||||
//modelTestTemplateFiles.put("model_test.mustache", ".proto");
|
||||
|
||||
apiDocTemplateFiles.clear(); // TODO: add api doc template
|
||||
modelDocTemplateFiles.clear(); // TODO: add model doc template
|
||||
|
||||
modelPackage = "models";
|
||||
apiPackage = "services";
|
||||
|
||||
if (additionalProperties.containsKey(CodegenConstants.PACKAGE_NAME)) {
|
||||
setPackageName((String) additionalProperties.get(CodegenConstants.PACKAGE_NAME));
|
||||
}
|
||||
|
||||
supportingFiles.add(new SupportingFile("README.mustache", "", "README.md"));
|
||||
//supportingFiles.add(new SupportingFile("root.mustache", "", packageName + ".proto"));
|
||||
//supportingFiles.add(new SupportingFile("git_push.sh.mustache", "", "git_push.sh"));
|
||||
//supportingFiles.add(new SupportingFile("gitignore.mustache", "", ".gitignore"))
|
||||
//supportingFiles.add(new SupportingFile(".travis.yml", "", ".travis.yml"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toOperationId(String operationId) {
|
||||
// throw exception if method name is empty (should not occur as an auto-generated method name will be used)
|
||||
if (StringUtils.isEmpty(operationId)) {
|
||||
throw new RuntimeException("Empty method name (operationId) not allowed");
|
||||
}
|
||||
|
||||
// method name cannot use reserved keyword, e.g. return
|
||||
if (isReservedWord(operationId)) {
|
||||
LOGGER.warn(operationId + " (reserved word) cannot be used as method name. Renamed to " + camelize(sanitizeName("call_" + operationId)));
|
||||
operationId = "call_" + operationId;
|
||||
}
|
||||
|
||||
return camelize(sanitizeName(operationId));
|
||||
}
|
||||
|
||||
@Override
|
||||
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");
|
||||
|
||||
for (CodegenProperty var : cm.vars) {
|
||||
// add x-protobuf-type: repeated if it's an array
|
||||
if (Boolean.TRUE.equals(var.isListContainer)) {
|
||||
var.vendorExtensions.put("x-protobuf-type", "repeated");
|
||||
}
|
||||
|
||||
// add x-protobuf-data-type
|
||||
// ref: https://developers.google.com/protocol-buffers/docs/proto3
|
||||
if (!var.vendorExtensions.containsKey("x-protobuf-data-type")) {
|
||||
if (var.isListContainer) {
|
||||
var.vendorExtensions.put("x-protobuf-data-type", var.items.dataType);
|
||||
} else {
|
||||
var.vendorExtensions.put("x-protobuf-data-type", var.dataType);
|
||||
}
|
||||
}
|
||||
|
||||
if (var.isEnum && var.allowableValues.containsKey("enumVars")) {
|
||||
List<Map<String, Object>> enumVars = (List<Map<String, Object>>) var.allowableValues.get("enumVars");
|
||||
int enumIndex = 0;
|
||||
for (Map<String, Object> enumVar : enumVars) {
|
||||
enumVar.put("protobuf-enum-index", enumIndex);
|
||||
enumIndex++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return objs;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String escapeUnsafeCharacters(String input) {
|
||||
return input;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String escapeQuotationMark(String input) {
|
||||
return input;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the default value of the property
|
||||
*
|
||||
* @param p OpenAPI property object
|
||||
* @return string presentation of the default value of the property
|
||||
*/
|
||||
@Override
|
||||
public String toDefaultValue(Schema p) {
|
||||
if (ModelUtils.isBooleanSchema(p)) {
|
||||
if (p.getDefault() != null) {
|
||||
if (Boolean.valueOf(p.getDefault().toString()) == false)
|
||||
return "false";
|
||||
else
|
||||
return "true";
|
||||
}
|
||||
} else if (ModelUtils.isDateSchema(p)) {
|
||||
// TODO
|
||||
} else if (ModelUtils.isDateTimeSchema(p)) {
|
||||
// TODO
|
||||
} else if (ModelUtils.isNumberSchema(p)) {
|
||||
if (p.getDefault() != null) {
|
||||
return p.getDefault().toString();
|
||||
}
|
||||
} else if (ModelUtils.isIntegerSchema(p)) {
|
||||
if (p.getDefault() != null) {
|
||||
return p.getDefault().toString();
|
||||
}
|
||||
} else if (ModelUtils.isStringSchema(p)) {
|
||||
if (p.getDefault() != null) {
|
||||
if (Pattern.compile("\r\n|\r|\n").matcher((String) p.getDefault()).find())
|
||||
return "'''" + p.getDefault() + "'''";
|
||||
else
|
||||
return "'" + p.getDefault() + "'";
|
||||
}
|
||||
} else if (ModelUtils.isArraySchema(p)) {
|
||||
if (p.getDefault() != null) {
|
||||
return p.getDefault().toString();
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String apiFileFolder() {
|
||||
return outputFolder + File.separatorChar + apiPackage;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String modelFileFolder() {
|
||||
return outputFolder + File.separatorChar + modelPackage;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toApiFilename(String name) {
|
||||
// replace - with _ e.g. created-at => created_at
|
||||
name = name.replaceAll("-", "_");
|
||||
|
||||
// e.g. PhoneNumber => phone_number
|
||||
return underscore(name) + "_service";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toApiName(String name) {
|
||||
if (name.length() == 0) {
|
||||
return "DefaultService";
|
||||
}
|
||||
// e.g. phone_number => PhoneNumber
|
||||
return camelize(name) + "Service";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toApiVarName(String name) {
|
||||
if (name.length() == 0) {
|
||||
return "default_service";
|
||||
}
|
||||
return underscore(name) + "_service";
|
||||
}
|
||||
|
||||
public void setPackageName(String packageName) {
|
||||
this.packageName = packageName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toModelFilename(String name) {
|
||||
// underscore the model file name
|
||||
// PhoneNumber => phone_number
|
||||
return underscore(toModelName(name));
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toModelName(String name) {
|
||||
name = sanitizeName(name); // FIXME: a parameter should not be assigned. Also declare the methods parameters as 'final'.
|
||||
// remove dollar sign
|
||||
name = name.replaceAll("$", "");
|
||||
|
||||
// model name cannot use reserved keyword, e.g. return
|
||||
if (isReservedWord(name)) {
|
||||
LOGGER.warn(name + " (reserved word) cannot be used as model name. Renamed to " + camelize("model_" + name));
|
||||
name = "model_" + name; // e.g. return => ModelReturn (after camelize)
|
||||
}
|
||||
|
||||
// model name starts with number
|
||||
if (name.matches("^\\d.*")) {
|
||||
LOGGER.warn(name + " (model name starts with number) cannot be used as model name. Renamed to " + camelize("model_" + name));
|
||||
name = "model_" + name; // e.g. 200Response => Model200Response (after camelize)
|
||||
}
|
||||
|
||||
if (!StringUtils.isEmpty(modelNamePrefix)) {
|
||||
name = modelNamePrefix + "_" + name;
|
||||
}
|
||||
|
||||
if (!StringUtils.isEmpty(modelNameSuffix)) {
|
||||
name = name + "_" + modelNameSuffix;
|
||||
}
|
||||
|
||||
// camelize the model name
|
||||
// phone_number => PhoneNumber
|
||||
return camelize(name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSchemaType(Schema p) {
|
||||
String schemaType = super.getSchemaType(p);
|
||||
String type = null;
|
||||
if (typeMapping.containsKey(schemaType)) {
|
||||
type = typeMapping.get(schemaType);
|
||||
if (languageSpecificPrimitives.contains(type)) {
|
||||
return type;
|
||||
}
|
||||
} else {
|
||||
type = toModelName(schemaType);
|
||||
}
|
||||
return type;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Object> postProcessOperationsWithModels(Map<String, Object> objs, List<Object> allModels) {
|
||||
Map<String, Object> operations = (Map<String, Object>) objs.get("operations");
|
||||
List<CodegenOperation> operationList = (List<CodegenOperation>) operations.get("operation");
|
||||
for (CodegenOperation op : operationList) {
|
||||
int index = 1;
|
||||
for (CodegenParameter p : op.allParams) {
|
||||
// add x-protobuf-type: repeated if it's an array
|
||||
if (Boolean.TRUE.equals(p.isListContainer)) {
|
||||
p.vendorExtensions.put("x-protobuf-type", "repeated");
|
||||
} else if (Boolean.TRUE.equals(p.isMapContainer)) {
|
||||
LOGGER.warn("Map parameter (name: {}, operation ID: {}) not yet supported", p.paramName, op.operationId);
|
||||
}
|
||||
|
||||
// add x-protobuf-data-type
|
||||
// ref: https://developers.google.com/protocol-buffers/docs/proto3
|
||||
if (!p.vendorExtensions.containsKey("x-protobuf-data-type")) {
|
||||
if (Boolean.TRUE.equals(p.isListContainer)) {
|
||||
p.vendorExtensions.put("x-protobuf-data-type", p.items.dataType);
|
||||
} else {
|
||||
p.vendorExtensions.put("x-protobuf-data-type", p.dataType);
|
||||
}
|
||||
}
|
||||
|
||||
p.vendorExtensions.put("x-index", index);
|
||||
index++;
|
||||
}
|
||||
|
||||
if (StringUtils.isEmpty(op.returnType)) {
|
||||
op.vendorExtensions.put("x-grpc-response", "google.protobuf.Empty");
|
||||
} else {
|
||||
if (Boolean.FALSE.equals(op.returnTypeIsPrimitive) && StringUtils.isEmpty(op.returnContainer)) {
|
||||
op.vendorExtensions.put("x-grpc-response", op.returnType);
|
||||
} else {
|
||||
if ("map".equals(op.returnContainer)) {
|
||||
LOGGER.warn("Map response (operation ID: {}) not yet supported", op.operationId);
|
||||
op.vendorExtensions.put("x-grpc-response-type", op.returnBaseType);
|
||||
} else if ("array".equals(op.returnContainer)) {
|
||||
op.vendorExtensions.put("x-grpc-response-type", "repeated " + op.returnBaseType);
|
||||
} else { // primitive type
|
||||
op.vendorExtensions.put("x-grpc-response-type", op.returnBaseType);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return objs;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toModelImport(String name) {
|
||||
return underscore(name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTypeDeclaration(Schema p) {
|
||||
if (ModelUtils.isArraySchema(p)) {
|
||||
ArraySchema ap = (ArraySchema) p;
|
||||
Schema inner = ap.getItems();
|
||||
return getSchemaType(p) + "[" + getTypeDeclaration(inner) + "]";
|
||||
} else if (ModelUtils.isMapSchema(p)) {
|
||||
Schema inner = ModelUtils.getAdditionalProperties(p);
|
||||
return getSchemaType(p) + "[str, " + getTypeDeclaration(inner) + "]";
|
||||
}
|
||||
return super.getTypeDeclaration(p);
|
||||
}
|
||||
}
|
||||
@@ -67,6 +67,8 @@ public class TypeScriptAngularClientCodegen extends AbstractTypeScriptClientCode
|
||||
super();
|
||||
this.outputFolder = "generated-code/typescript-angular";
|
||||
|
||||
supportsMultipleInheritance = true;
|
||||
|
||||
embeddedTemplateDir = templateDir = "typescript-angular";
|
||||
modelTemplateFiles.put("model.mustache", ".ts");
|
||||
apiTemplateFiles.put("api.service.mustache", ".ts");
|
||||
|
||||
@@ -34,12 +34,14 @@ public class TypeScriptFetchClientCodegen extends AbstractTypeScriptClientCodege
|
||||
public static final String WITH_INTERFACES = "withInterfaces";
|
||||
public static final String USE_SINGLE_REQUEST_PARAMETER = "useSingleRequestParameter";
|
||||
public static final String PREFIX_PARAMETER_INTERFACES = "prefixParameterInterfaces";
|
||||
public static final String TYPESCRIPT_THREE_PLUS = "typescriptThreePlus";
|
||||
|
||||
protected String npmRepository = null;
|
||||
private boolean useSingleRequestParameter = true;
|
||||
private boolean prefixParameterInterfaces = false;
|
||||
protected boolean addedApiIndex = false;
|
||||
protected boolean addedModelIndex = false;
|
||||
protected boolean typescriptThreePlus = false;
|
||||
|
||||
|
||||
public TypeScriptFetchClientCodegen() {
|
||||
@@ -62,6 +64,7 @@ public class TypeScriptFetchClientCodegen extends AbstractTypeScriptClientCodege
|
||||
this.cliOptions.add(new CliOption(WITH_INTERFACES, "Setting this property to true will generate interfaces next to the default class implementations.", SchemaTypeUtil.BOOLEAN_TYPE).defaultValue(Boolean.FALSE.toString()));
|
||||
this.cliOptions.add(new CliOption(USE_SINGLE_REQUEST_PARAMETER, "Setting this property to true will generate functions with a single argument containing all API endpoint parameters instead of one argument per parameter.", SchemaTypeUtil.BOOLEAN_TYPE).defaultValue(Boolean.TRUE.toString()));
|
||||
this.cliOptions.add(new CliOption(PREFIX_PARAMETER_INTERFACES, "Setting this property to true will generate parameter interface declarations prefixed with API class name to avoid name conflicts.", SchemaTypeUtil.BOOLEAN_TYPE).defaultValue(Boolean.FALSE.toString()));
|
||||
this.cliOptions.add(new CliOption(TYPESCRIPT_THREE_PLUS, "Setting this property to true will generate TypeScript 3.6+ compatible code.", SchemaTypeUtil.BOOLEAN_TYPE).defaultValue(Boolean.FALSE.toString()));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -82,6 +85,14 @@ public class TypeScriptFetchClientCodegen extends AbstractTypeScriptClientCodege
|
||||
this.npmRepository = npmRepository;
|
||||
}
|
||||
|
||||
public Boolean getTypescriptThreePlus() {
|
||||
return typescriptThreePlus;
|
||||
}
|
||||
|
||||
public void setTypescriptThreePlus(Boolean typescriptThreePlus) {
|
||||
this.typescriptThreePlus = typescriptThreePlus;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void processOpts() {
|
||||
super.processOpts();
|
||||
@@ -105,6 +116,10 @@ public class TypeScriptFetchClientCodegen extends AbstractTypeScriptClientCodege
|
||||
if (additionalProperties.containsKey(NPM_NAME)) {
|
||||
addNpmPackageGeneration();
|
||||
}
|
||||
|
||||
if (additionalProperties.containsKey(TYPESCRIPT_THREE_PLUS)) {
|
||||
this.setTypescriptThreePlus(convertPropertyToBoolean(TYPESCRIPT_THREE_PLUS));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -4,6 +4,7 @@ import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
import com.fasterxml.jackson.databind.MapperFeature;
|
||||
import com.fasterxml.jackson.databind.module.SimpleModule;
|
||||
import io.swagger.v3.core.util.Yaml;
|
||||
import io.swagger.v3.core.util.Json;
|
||||
import io.swagger.v3.oas.models.OpenAPI;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
@@ -15,9 +16,7 @@ public class SerializerUtils {
|
||||
if(openAPI == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
SimpleModule module = new SimpleModule("OpenAPIModule");
|
||||
module.addSerializer(OpenAPI.class, new OpenAPISerializer());
|
||||
SimpleModule module = createModule();
|
||||
try {
|
||||
return Yaml.mapper()
|
||||
.registerModule(module)
|
||||
@@ -29,4 +28,30 @@ public class SerializerUtils {
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static String toJsonString(OpenAPI openAPI) {
|
||||
if (openAPI == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
SimpleModule module = createModule();
|
||||
try {
|
||||
return Json.mapper()
|
||||
.copy()
|
||||
.registerModule(module)
|
||||
.configure(MapperFeature.SORT_PROPERTIES_ALPHABETICALLY, true)
|
||||
.writerWithDefaultPrettyPrinter()
|
||||
.writeValueAsString(openAPI)
|
||||
.replace("\r\n", "\n");
|
||||
} catch (JsonProcessingException e) {
|
||||
LOGGER.warn("Can not create json content", e);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private static SimpleModule createModule() {
|
||||
SimpleModule module = new SimpleModule("OpenAPIModule");
|
||||
module.addSerializer(OpenAPI.class, new OpenAPISerializer());
|
||||
return module;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -359,14 +359,7 @@ public class ModelUtils {
|
||||
}
|
||||
|
||||
public static boolean isArraySchema(Schema schema) {
|
||||
if (schema instanceof ArraySchema) {
|
||||
return true;
|
||||
}
|
||||
// assume it's an array if maxItems, minItems is set
|
||||
if (schema != null && (schema.getMaxItems() != null || schema.getMinItems() != null)) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
return (schema instanceof ArraySchema);
|
||||
}
|
||||
|
||||
public static boolean isStringSchema(Schema schema) {
|
||||
@@ -896,6 +889,8 @@ public class ModelUtils {
|
||||
public static String getParentName(ComposedSchema composedSchema, Map<String, Schema> allSchemas) {
|
||||
List<Schema> interfaces = getInterfaces(composedSchema);
|
||||
|
||||
List<String> refedParentNames = new ArrayList<>();
|
||||
|
||||
if (interfaces != null && !interfaces.isEmpty()) {
|
||||
for (Schema schema : interfaces) {
|
||||
// get the actual schema
|
||||
@@ -911,6 +906,7 @@ public class ModelUtils {
|
||||
} else {
|
||||
LOGGER.debug("Not a parent since discriminator.propertyName is not set {}", s.get$ref());
|
||||
// not a parent since discriminator.propertyName is not set
|
||||
refedParentNames.add(parentName);
|
||||
}
|
||||
} else {
|
||||
// not a ref, doing nothing
|
||||
@@ -918,6 +914,13 @@ public class ModelUtils {
|
||||
}
|
||||
}
|
||||
|
||||
// parent name only makes sense when there is a single obvious parent
|
||||
if (refedParentNames.size() == 1) {
|
||||
LOGGER.warn("[deprecated] inheritance without use of 'discriminator.propertyName' is deprecated " +
|
||||
"and will be removed in a future release. Generating model for {}", composedSchema.getName());
|
||||
return refedParentNames.get(0);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@@ -138,6 +138,7 @@ ext {
|
||||
swagger_annotations_version = "1.5.22"
|
||||
jackson_version = "{{^threetenbp}}2.9.9{{/threetenbp}}{{#threetenbp}}2.6.4{{/threetenbp}}"
|
||||
jackson_databind_version = "{{^threetenbp}}2.9.9{{/threetenbp}}{{#threetenbp}}2.6.4{{/threetenbp}}"
|
||||
jackson-databind-nullable-version = "0.2.0"
|
||||
jersey_version = "1.19.4"
|
||||
jodatime_version = "2.9.9"
|
||||
junit_version = "4.12"
|
||||
@@ -152,6 +153,7 @@ dependencies {
|
||||
compile "com.fasterxml.jackson.core:jackson-annotations:$jackson_version"
|
||||
compile "com.fasterxml.jackson.core:jackson-databind:$jackson_databind_version"
|
||||
compile "com.fasterxml.jackson.jaxrs:jackson-jaxrs-json-provider:$jackson_version"
|
||||
compile "org.openapitools:jackson-databind-nullable:$jackson-databind-nullable-version"
|
||||
{{#joda}}
|
||||
compile "com.fasterxml.jackson.datatype:jackson-datatype-joda:$jackson_version"
|
||||
{{/joda}}
|
||||
|
||||
@@ -1,11 +1,17 @@
|
||||
#!/bin/sh
|
||||
# ref: https://help.github.com/articles/adding-an-existing-project-to-github-using-the-command-line/
|
||||
#
|
||||
# Usage example: /bin/sh ./git_push.sh wing328 openapi-pestore-perl "minor update"
|
||||
# Usage example: /bin/sh ./git_push.sh wing328 openapi-pestore-perl "minor update" "gitlab.com"
|
||||
|
||||
git_user_id=$1
|
||||
git_repo_id=$2
|
||||
release_note=$3
|
||||
git_host=$4
|
||||
|
||||
if [ "$git_host" = "" ]; then
|
||||
git_host="{{{gitHost}}}"
|
||||
echo "[INFO] No command line input provided. Set \$git_host to $git_host"
|
||||
fi
|
||||
|
||||
if [ "$git_user_id" = "" ]; then
|
||||
git_user_id="{{{gitUserId}}}"
|
||||
@@ -28,7 +34,7 @@ git init
|
||||
# Adds the files in the local repository and stages them for commit.
|
||||
git add .
|
||||
|
||||
# Commits the tracked changes and prepares them to be pushed to a remote repository.
|
||||
# Commits the tracked changes and prepares them to be pushed to a remote repository.
|
||||
git commit -m "$release_note"
|
||||
|
||||
# Sets the new remote
|
||||
@@ -37,9 +43,9 @@ if [ "$git_remote" = "" ]; then # git remote not defined
|
||||
|
||||
if [ "$GIT_TOKEN" = "" ]; then
|
||||
echo "[INFO] \$GIT_TOKEN (environment variable) is not set. Using the git credential in your environment."
|
||||
git remote add origin https://github.com/${git_user_id}/${git_repo_id}.git
|
||||
git remote add origin https://${git_host}/${git_user_id}/${git_repo_id}.git
|
||||
else
|
||||
git remote add origin https://${git_user_id}:${GIT_TOKEN}@github.com/${git_user_id}/${git_repo_id}.git
|
||||
git remote add origin https://${git_user_id}:${GIT_TOKEN}@${git_host}/${git_user_id}/${git_repo_id}.git
|
||||
fi
|
||||
|
||||
fi
|
||||
@@ -47,6 +53,6 @@ fi
|
||||
git pull origin master
|
||||
|
||||
# Pushes (Forces) the changes in the local repository up to the remote repository
|
||||
echo "Git pushing to https://github.com/${git_user_id}/${git_repo_id}.git"
|
||||
echo "Git pushing to https://${git_host}/${git_user_id}/${git_repo_id}.git"
|
||||
git push origin master 2>&1 | grep -v 'To https'
|
||||
|
||||
|
||||
@@ -122,6 +122,7 @@ ext {
|
||||
swagger_annotations_version = "1.5.22"
|
||||
jackson_version = "2.9.9"
|
||||
jackson_databind_version = "2.9.9"
|
||||
jackson-databind-nullable-version = "0.2.0"
|
||||
{{#threetenbp}}
|
||||
threepane_version = "2.6.4"
|
||||
{{/threetenbp}}
|
||||
@@ -141,6 +142,7 @@ dependencies {
|
||||
compile "com.fasterxml.jackson.core:jackson-core:$jackson_version"
|
||||
compile "com.fasterxml.jackson.core:jackson-annotations:$jackson_version"
|
||||
compile "com.fasterxml.jackson.core:jackson-databind:$jackson_databind_version"
|
||||
compile "org.openapitools:jackson-databind-nullable:$jackson-databind-nullable-version"
|
||||
{{#joda}}
|
||||
compile "com.fasterxml.jackson.datatype:jackson-datatype-joda:$jackson_version"
|
||||
{{/joda}}
|
||||
|
||||
@@ -122,6 +122,7 @@ ext {
|
||||
swagger_annotations_version = "1.5.22"
|
||||
jackson_version = "2.9.9"
|
||||
jackson_databind_version = "2.9.9"
|
||||
jackson-databind-nullable-version = "0.2.0"
|
||||
google_api_client_version = "1.23.0"
|
||||
jersey_common_version = "2.25.1"
|
||||
jodatime_version = "2.9.9"
|
||||
@@ -140,6 +141,7 @@ dependencies {
|
||||
compile "com.fasterxml.jackson.core:jackson-annotations:$jackson_version"
|
||||
compile "com.fasterxml.jackson.core:jackson-databind:$jackson_databind_version"
|
||||
compile "com.fasterxml.jackson.jaxrs:jackson-jaxrs-json-provider:$jackson_version"
|
||||
compile "org.openapitools:jackson-databind-nullable:$jackson-databind-nullable-version"
|
||||
{{#java8}}
|
||||
compile "com.fasterxml.jackson.datatype:jackson-datatype-jsr310:$jackson_version"
|
||||
{{/java8}}
|
||||
|
||||
@@ -121,6 +121,7 @@ ext {
|
||||
swagger_annotations_version = "1.5.22"
|
||||
jackson_version = "2.9.9"
|
||||
jackson_databind_version = "2.9.9"
|
||||
jackson-databind-nullable-version = "0.2.0"
|
||||
{{#supportJava6}}
|
||||
jersey_version = "2.6"
|
||||
commons_io_version=2.5
|
||||
@@ -144,6 +145,7 @@ dependencies {
|
||||
compile "com.fasterxml.jackson.core:jackson-core:$jackson_version"
|
||||
compile "com.fasterxml.jackson.core:jackson-annotations:$jackson_version"
|
||||
compile "com.fasterxml.jackson.core:jackson-databind:$jackson_databind_version"
|
||||
compile "org.openapitools:jackson-databind-nullable:$jackson-databind-nullable-version"
|
||||
{{#joda}}
|
||||
compile "com.fasterxml.jackson.datatype:jackson-datatype-joda:$jackson_version"
|
||||
{{/joda}}
|
||||
|
||||
@@ -13,7 +13,8 @@ import java.util.function.Supplier;
|
||||
|
||||
import static io.restassured.config.ObjectMapperConfig.objectMapperConfig;
|
||||
import static io.restassured.config.RestAssuredConfig.config;
|
||||
import static {{invokerPackage}}.GsonObjectMapper.gson;
|
||||
import static {{invokerPackage}}.{{#gson}}GsonObjectMapper.gson{{/gson}}{{#jackson}}JacksonObjectMapper.jackson{{/jackson}};
|
||||
|
||||
{{/fullJavaUtil}}
|
||||
|
||||
public class ApiClient {
|
||||
@@ -42,7 +43,7 @@ public class ApiClient {
|
||||
public static class Config {
|
||||
private Supplier<RequestSpecBuilder> reqSpecSupplier = () -> new RequestSpecBuilder()
|
||||
{{#basePath}}.setBaseUri(BASE_URI){{/basePath}}
|
||||
.setConfig(config().objectMapperConfig(objectMapperConfig().defaultObjectMapper(gson())));
|
||||
.setConfig(config().objectMapperConfig(objectMapperConfig().defaultObjectMapper({{#gson}}gson(){{/gson}}{{#jackson}}jackson(){{/jackson}})));
|
||||
|
||||
/**
|
||||
* Use common specification for all operations
|
||||
|
||||
@@ -0,0 +1,64 @@
|
||||
{{>licenseInfo}}
|
||||
|
||||
package {{invokerPackage}};
|
||||
|
||||
{{#threetenbp}}
|
||||
import org.threeten.bp.*;
|
||||
{{/threetenbp}}
|
||||
import com.fasterxml.jackson.annotation.*;
|
||||
import com.fasterxml.jackson.databind.*;
|
||||
import org.openapitools.jackson.nullable.JsonNullableModule;
|
||||
{{#java8}}
|
||||
import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule;
|
||||
{{/java8}}
|
||||
{{#joda}}
|
||||
import com.fasterxml.jackson.datatype.joda.JodaModule;
|
||||
{{/joda}}
|
||||
{{#threetenbp}}
|
||||
import com.fasterxml.jackson.datatype.threetenbp.ThreeTenModule;
|
||||
{{/threetenbp}}
|
||||
|
||||
import io.restassured.internal.mapping.Jackson2Mapper;
|
||||
import io.restassured.path.json.mapper.factory.Jackson2ObjectMapperFactory;
|
||||
|
||||
|
||||
public class JacksonObjectMapper extends Jackson2Mapper {
|
||||
|
||||
private JacksonObjectMapper() {
|
||||
super(createFactory());
|
||||
}
|
||||
|
||||
private static Jackson2ObjectMapperFactory createFactory() {
|
||||
return (cls, charset) -> {
|
||||
ObjectMapper mapper = new ObjectMapper();
|
||||
mapper = new ObjectMapper();
|
||||
mapper.setSerializationInclusion(JsonInclude.Include.NON_NULL);
|
||||
mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
|
||||
mapper.configure(DeserializationFeature.FAIL_ON_INVALID_SUBTYPE, false);
|
||||
mapper.disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS);
|
||||
mapper.enable(SerializationFeature.WRITE_ENUMS_USING_TO_STRING);
|
||||
mapper.enable(DeserializationFeature.READ_ENUMS_USING_TO_STRING);
|
||||
mapper.setDateFormat(new RFC3339DateFormat());
|
||||
{{#java8}}
|
||||
mapper.registerModule(new JavaTimeModule());
|
||||
{{/java8}}
|
||||
{{#joda}}
|
||||
mapper.registerModule(new JodaModule());
|
||||
{{/joda}}
|
||||
{{#threetenbp}}
|
||||
ThreeTenModule module = new ThreeTenModule();
|
||||
module.addDeserializer(Instant.class, CustomInstantDeserializer.INSTANT);
|
||||
module.addDeserializer(OffsetDateTime.class, CustomInstantDeserializer.OFFSET_DATE_TIME);
|
||||
module.addDeserializer(ZonedDateTime.class, CustomInstantDeserializer.ZONED_DATE_TIME);
|
||||
mapper.registerModule(module);
|
||||
{{/threetenbp}}
|
||||
JsonNullableModule jnm = new JsonNullableModule();
|
||||
mapper.registerModule(jnm);
|
||||
return mapper;
|
||||
};
|
||||
}
|
||||
|
||||
public static JacksonObjectMapper jackson() {
|
||||
return new JacksonObjectMapper();
|
||||
}
|
||||
}
|
||||
@@ -2,7 +2,9 @@
|
||||
|
||||
package {{package}};
|
||||
|
||||
{{#gson}}
|
||||
import com.google.gson.reflect.TypeToken;
|
||||
{{/gson}}
|
||||
{{#imports}}import {{import}};
|
||||
{{/imports}}
|
||||
|
||||
@@ -15,6 +17,9 @@ import java.util.Map;
|
||||
import io.restassured.RestAssured;
|
||||
import io.restassured.builder.RequestSpecBuilder;
|
||||
import io.restassured.builder.ResponseSpecBuilder;
|
||||
{{#jackson}}
|
||||
import io.restassured.common.mapper.TypeRef;
|
||||
{{/jackson}}
|
||||
import io.restassured.http.Method;
|
||||
import io.restassured.response.Response;
|
||||
import io.swagger.annotations.*;
|
||||
@@ -24,8 +29,9 @@ import java.util.function.Consumer;
|
||||
import java.util.function.Function;
|
||||
import java.util.function.Supplier;
|
||||
{{/fullJavaUtil}}
|
||||
{{#gson}}
|
||||
import {{invokerPackage}}.JSON;
|
||||
|
||||
{{/gson}}
|
||||
import static io.restassured.http.Method.*;
|
||||
|
||||
@Api(value = "{{{baseName}}}")
|
||||
@@ -139,8 +145,9 @@ public class {{classname}} {
|
||||
* @return {{returnType}}
|
||||
*/
|
||||
public {{{returnType}}} executeAs(Function<Response, Response> handler) {
|
||||
Type type = new TypeToken<{{{returnType}}}>(){}.getType();
|
||||
return execute(handler).as(type);
|
||||
{{#gson}}Type type = new TypeToken<{{{returnType}}}>(){}.getType();
|
||||
{{/gson}}{{#jackson}}TypeRef<{{{returnType}}}> type = new TypeRef<{{{returnType}}}>(){};
|
||||
{{/jackson}}return execute(handler).as(type);
|
||||
}
|
||||
{{/returnType}}
|
||||
{{#bodyParams}}
|
||||
|
||||
@@ -20,7 +20,7 @@ import java.util.Map;
|
||||
{{/fullJavaUtil}}
|
||||
import static io.restassured.config.ObjectMapperConfig.objectMapperConfig;
|
||||
import static io.restassured.config.RestAssuredConfig.config;
|
||||
import static {{invokerPackage}}.GsonObjectMapper.gson;
|
||||
import static {{invokerPackage}}.{{#gson}}GsonObjectMapper.gson{{/gson}}{{#jackson}}JacksonObjectMapper.jackson{{/jackson}};
|
||||
|
||||
/**
|
||||
* API tests for {{classname}}
|
||||
@@ -33,7 +33,8 @@ public class {{classname}}Test {
|
||||
@Before
|
||||
public void createApi() {
|
||||
api = ApiClient.api(ApiClient.Config.apiConfig().reqSpecSupplier(
|
||||
() -> new RequestSpecBuilder().setConfig(config().objectMapperConfig(objectMapperConfig().defaultObjectMapper(gson())))
|
||||
() -> new RequestSpecBuilder()
|
||||
.setConfig(config().objectMapperConfig(objectMapperConfig().defaultObjectMapper({{#gson}}gson(){{/gson}}{{#jackson}}jackson(){{/jackson}})))
|
||||
.addFilter(new ErrorLoggingFilter())
|
||||
.setBaseUri("{{{basePath}}}"))).{{classVarName}}();
|
||||
}
|
||||
|
||||
@@ -98,8 +98,15 @@ ext {
|
||||
swagger_annotations_version = "1.5.21"
|
||||
rest_assured_version = "4.0.0"
|
||||
junit_version = "4.12"
|
||||
{{#jackson}}
|
||||
jackson_version = "{{^threetenbp}}2.9.9{{/threetenbp}}{{#threetenbp}}2.6.4{{/threetenbp}}"
|
||||
jackson_databind_version = "{{^threetenbp}}2.9.9{{/threetenbp}}{{#threetenbp}}2.6.4{{/threetenbp}}"
|
||||
jackson-databind-nullable-version = 0.2.0
|
||||
{{/jackson}}
|
||||
{{#gson}}
|
||||
gson_version = "2.8.5"
|
||||
gson_fire_version = "1.8.3"
|
||||
{{/gson}}
|
||||
{{#joda}}
|
||||
jodatime_version = "2.9.9"
|
||||
{{/joda}}
|
||||
@@ -113,10 +120,19 @@ dependencies {
|
||||
compile "io.swagger:swagger-annotations:$swagger_annotations_version"
|
||||
compile "com.google.code.findbugs:jsr305:3.0.2"
|
||||
compile "io.rest-assured:scala-support:$rest_assured_version"
|
||||
{{#jackson}}
|
||||
compile "com.fasterxml.jackson.core:jackson-core:$jackson_version"
|
||||
compile "com.fasterxml.jackson.core:jackson-annotations:$jackson_version"
|
||||
compile "com.fasterxml.jackson.core:jackson-databind:$jackson_databind_version"
|
||||
compile "com.fasterxml.jackson.jaxrs:jackson-jaxrs-json-provider:$jackson_version"
|
||||
compile "org.openapitools:jackson-databind-nullable:$jackson-databind-nullable-version"
|
||||
{{/jackson}}
|
||||
{{#gson}}
|
||||
compile "io.gsonfire:gson-fire:$gson_fire_version"
|
||||
compile 'com.google.code.gson:gson:$gson_version'
|
||||
{{/gson}}
|
||||
{{#joda}}
|
||||
compile "joda-time:joda-time:$jodatime_version"
|
||||
compile 'com.google.code.gson:gson:$gson_version'
|
||||
{{/joda}}
|
||||
{{#threetenbp}}
|
||||
compile "org.threeten:threetenbp:$threetenbp_version"
|
||||
|
||||
@@ -11,8 +11,15 @@ lazy val root = (project in file(".")).
|
||||
libraryDependencies ++= Seq(
|
||||
"io.swagger" % "swagger-annotations" % "1.5.21",
|
||||
"io.rest-assured" % "scala-support" % "4.0.0",
|
||||
{{#jackson}}
|
||||
"com.fasterxml.jackson.core" % "jackson-core" % "2.9.9" % "compile",
|
||||
"com.fasterxml.jackson.core" % "jackson-annotations" % "2.9.9" % "compile",
|
||||
"com.fasterxml.jackson.core" % "jackson-databind" % "2.9.9" % "compile",
|
||||
{{/jackson}}
|
||||
{{#gson}}
|
||||
"com.google.code.gson" % "gson" % "2.8.5",
|
||||
"io.gsonfire" % "gson-fire" % "1.8.3" % "compile",
|
||||
{{/gson}}
|
||||
{{#joda}}
|
||||
"joda-time" % "joda-time" % "2.9.9" % "compile",
|
||||
{{/joda}}
|
||||
|
||||
@@ -217,11 +217,13 @@
|
||||
<artifactId>rest-assured</artifactId>
|
||||
<version>${rest-assured.version}</version>
|
||||
</dependency>
|
||||
{{#gson}}
|
||||
<dependency>
|
||||
<groupId>com.google.code.gson</groupId>
|
||||
<artifactId>gson</artifactId>
|
||||
<version>${gson-version}</version>
|
||||
</dependency>
|
||||
{{/gson}}
|
||||
{{#joda}}
|
||||
<dependency>
|
||||
<groupId>joda-time</groupId>
|
||||
@@ -236,16 +238,69 @@
|
||||
<version>${threetenbp-version}</version>
|
||||
</dependency>
|
||||
{{/threetenbp}}
|
||||
{{#gson}}
|
||||
<dependency>
|
||||
<groupId>io.gsonfire</groupId>
|
||||
<artifactId>gson-fire</artifactId>
|
||||
<version>${gson-fire-version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.squareup.okio</groupId>
|
||||
<artifactId>okio</artifactId>
|
||||
<version>${okio-version}</version>
|
||||
</dependency>
|
||||
{{/gson}}
|
||||
{{#jackson}}
|
||||
<!-- JSON processing: jackson -->
|
||||
<dependency>
|
||||
<groupId>com.fasterxml.jackson.core</groupId>
|
||||
<artifactId>jackson-core</artifactId>
|
||||
<version>${jackson-version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.fasterxml.jackson.core</groupId>
|
||||
<artifactId>jackson-annotations</artifactId>
|
||||
<version>${jackson-version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.fasterxml.jackson.core</groupId>
|
||||
<artifactId>jackson-databind</artifactId>
|
||||
<version>${jackson-databind-version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.openapitools</groupId>
|
||||
<artifactId>jackson-databind-nullable</artifactId>
|
||||
<version>${jackson-databind-nullable-version}</version>
|
||||
</dependency>
|
||||
{{#withXml}}
|
||||
<dependency>
|
||||
<groupId>com.fasterxml.jackson.dataformat</groupId>
|
||||
<artifactId>jackson-dataformat-xml</artifactId>
|
||||
<version>${jackson-version}</version>
|
||||
</dependency>
|
||||
{{/withXml}}
|
||||
{{#joda}}
|
||||
<dependency>
|
||||
<groupId>com.fasterxml.jackson.datatype</groupId>
|
||||
<artifactId>jackson-datatype-joda</artifactId>
|
||||
<version>${jackson-version}</version>
|
||||
</dependency>
|
||||
{{/joda}}
|
||||
{{#java8}}
|
||||
<dependency>
|
||||
<groupId>com.fasterxml.jackson.datatype</groupId>
|
||||
<artifactId>jackson-datatype-jsr310</artifactId>
|
||||
<version>${jackson-version}</version>
|
||||
</dependency>
|
||||
{{/java8}}
|
||||
{{#threetenbp}}
|
||||
<dependency>
|
||||
<groupId>com.github.joschi.jackson</groupId>
|
||||
<artifactId>jackson-datatype-threetenbp</artifactId>
|
||||
<version>${jackson-threetenbp-version}</version>
|
||||
</dependency>
|
||||
{{/threetenbp}}
|
||||
{{/jackson}}
|
||||
<dependency>
|
||||
<groupId>com.squareup.okio</groupId>
|
||||
<artifactId>okio</artifactId>
|
||||
<version>${okio-version}</version>
|
||||
</dependency>
|
||||
<!-- test dependencies -->
|
||||
<dependency>
|
||||
<groupId>junit</groupId>
|
||||
@@ -267,6 +322,14 @@
|
||||
{{#threetenbp}}
|
||||
<threetenbp-version>1.3.8</threetenbp-version>
|
||||
{{/threetenbp}}
|
||||
{{#jackson}}
|
||||
<jackson-version>2.9.9</jackson-version>
|
||||
<jackson-databind-version>2.9.9</jackson-databind-version>
|
||||
<jackson-databind-nullable-version>0.2.0</jackson-databind-nullable-version>
|
||||
{{#threetenbp}}
|
||||
<jackson-threetenbp-version>2.6.4</jackson-threetenbp-version>
|
||||
{{/threetenbp}}
|
||||
{{/jackson}}
|
||||
<okio-version>1.13.0</okio-version>
|
||||
<junit-version>4.12</junit-version>
|
||||
</properties>
|
||||
|
||||
@@ -121,6 +121,7 @@ ext {
|
||||
swagger_annotations_version = "1.5.22"
|
||||
jackson_version = "2.9.9"
|
||||
jackson_databind_version = "2.9.9"
|
||||
jackson-databind-nullable-version = "0.2.0"
|
||||
threetenbp_version = "2.6.4"
|
||||
resteasy_version = "3.1.3.Final"
|
||||
{{^java8}}
|
||||
@@ -143,6 +144,7 @@ dependencies {
|
||||
compile "com.fasterxml.jackson.core:jackson-annotations:$jackson_version"
|
||||
compile "com.fasterxml.jackson.core:jackson-databind:$jackson_databind_version"
|
||||
compile "com.github.joschi.jackson:jackson-datatype-threetenbp:$threetenbp_version"
|
||||
compile "org.openapitools:jackson-databind-nullable:$jackson-databind-nullable-version"
|
||||
{{#java8}}
|
||||
compile "com.fasterxml.jackson.datatype:jackson-datatype-jsr310:$jackson_version"
|
||||
{{/java8}}
|
||||
|
||||
@@ -122,6 +122,7 @@ ext {
|
||||
swagger_annotations_version = "1.5.22"
|
||||
jackson_version = "2.9.9"
|
||||
jackson_databind_version = "2.9.9"
|
||||
jackson-databind-nullable-version = "0.2.0"
|
||||
spring_web_version = "4.3.9.RELEASE"
|
||||
jodatime_version = "2.9.9"
|
||||
junit_version = "4.12"
|
||||
@@ -138,6 +139,7 @@ dependencies {
|
||||
compile "com.fasterxml.jackson.core:jackson-annotations:$jackson_version"
|
||||
compile "com.fasterxml.jackson.core:jackson-databind:$jackson_databind_version"
|
||||
compile "com.fasterxml.jackson.jaxrs:jackson-jaxrs-json-provider:$jackson_version"
|
||||
compile "org.openapitools:jackson-databind-nullable:$jackson-databind-nullable-version"
|
||||
{{#java8}}
|
||||
compile "com.fasterxml.jackson.datatype:jackson-datatype-jsr310:$jackson_version"
|
||||
{{/java8}}
|
||||
|
||||
@@ -133,6 +133,7 @@ ext {
|
||||
{{#play26}}
|
||||
jackson_version = "2.9.9"
|
||||
jackson_databind_version = "2.9.9"
|
||||
jackson-databind-nullable-version = "0.2.0"
|
||||
play_version = "2.6.7"
|
||||
{{/play26}}
|
||||
{{/usePlayWS}}
|
||||
@@ -189,6 +190,7 @@ dependencies {
|
||||
compile "com.fasterxml.jackson.core:jackson-core:$jackson_version"
|
||||
compile "com.fasterxml.jackson.core:jackson-annotations:$jackson_version"
|
||||
compile "com.fasterxml.jackson.core:jackson-databind:$jackson_databind_version"
|
||||
compile "org.openapitools:jackson-databind-nullable:$jackson-databind-nullable-version"
|
||||
compile "com.fasterxml.jackson.datatype:jackson-datatype-{{^java8}}joda{{/java8}}{{#java8}}jsr310{{/java8}}:$jackson_version"
|
||||
{{/usePlayWS}}
|
||||
|
||||
|
||||
@@ -20,6 +20,7 @@ import {{import}};
|
||||
import java.io.Serializable;
|
||||
{{/serializableModel}}
|
||||
{{#jackson}}
|
||||
import com.fasterxml.jackson.annotation.JsonPropertyOrder;
|
||||
{{#withXml}}
|
||||
import com.fasterxml.jackson.dataformat.xml.annotation.*;
|
||||
{{/withXml}}
|
||||
|
||||
@@ -56,7 +56,7 @@
|
||||
|
||||
@Override
|
||||
public {{#datatypeWithEnum}}{{{.}}}{{/datatypeWithEnum}}{{^datatypeWithEnum}}{{classname}}{{/datatypeWithEnum}} read(final JsonReader jsonReader) throws IOException {
|
||||
{{^isNumber}}{{{dataType}}}{{/isNumber}}{{#isNumber}}String{{/isNumber}} value = jsonReader.{{#isNumber}}nextString(){{/isNumber}}{{#isInteger}}nextInt(){{/isInteger}}{{^isNumber}}{{^isInteger}}next{{{dataType}}}(){{/isInteger}}{{/isNumber}};
|
||||
{{^isNumber}}{{{dataType}}}{{/isNumber}}{{#isNumber}}String{{/isNumber}} value = {{#isFloat}}(float){{/isFloat}} jsonReader.{{#isNumber}}nextString(){{/isNumber}}{{#isInteger}}nextInt(){{/isInteger}}{{^isNumber}}{{^isInteger}}{{#isFloat}}nextDouble{{/isFloat}}{{^isFloat}}next{{{dataType}}}{{/isFloat}}(){{/isInteger}}{{/isNumber}};
|
||||
return {{#datatypeWithEnum}}{{{.}}}{{/datatypeWithEnum}}{{^datatypeWithEnum}}{{classname}}{{/datatypeWithEnum}}.fromValue({{#isNumber}}new BigDecimal({{/isNumber}}value{{#isNumber}}){{/isNumber}});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,6 +2,13 @@
|
||||
* {{#description}}{{.}}{{/description}}{{^description}}{{classname}}{{/description}}
|
||||
*/{{#description}}
|
||||
@ApiModel(description = "{{{description}}}"){{/description}}
|
||||
{{#jackson}}
|
||||
@JsonPropertyOrder({
|
||||
{{#vars}}
|
||||
{{classname}}.JSON_PROPERTY_{{nameInSnakeCase}}{{^-last}},{{/-last}}
|
||||
{{/vars}}
|
||||
})
|
||||
{{/jackson}}
|
||||
{{>generatedAnnotation}}{{#discriminator}}{{>typeInfoAnnotation}}{{/discriminator}}{{>xmlAnnotation}}
|
||||
public class {{classname}} {{#parent}}extends {{{parent}}} {{/parent}}{{#parcelableModel}}implements Parcelable {{#serializableModel}}, Serializable {{/serializableModel}}{{/parcelableModel}}{{^parcelableModel}}{{#serializableModel}}implements Serializable {{/serializableModel}}{{/parcelableModel}}{
|
||||
{{#serializableModel}}
|
||||
|
||||
@@ -10,6 +10,9 @@ import org.apache.commons.lang3.ObjectUtils;
|
||||
{{/supportJava6}}
|
||||
{{#imports}}import {{import}};
|
||||
{{/imports}}
|
||||
{{#jackson}}
|
||||
import com.fasterxml.jackson.annotation.JsonPropertyOrder;
|
||||
{{/jackson}}
|
||||
{{#serializableModel}}
|
||||
import java.io.Serializable;
|
||||
{{/serializableModel}}
|
||||
|
||||
@@ -2,6 +2,13 @@
|
||||
* {{#description}}{{.}}{{/description}}{{^description}}{{classname}}{{/description}}
|
||||
*/{{#description}}
|
||||
@ApiModel(description = "{{{description}}}"){{/description}}
|
||||
{{#jackson}}
|
||||
@JsonPropertyOrder({
|
||||
{{#vars}}
|
||||
{{classname}}.JSON_PROPERTY_{{nameInSnakeCase}}{{^-last}},{{/-last}}
|
||||
{{/vars}}
|
||||
})
|
||||
{{/jackson}}
|
||||
{{>generatedAnnotation}}{{#discriminator}}{{>typeInfoAnnotation}}{{/discriminator}}
|
||||
public class {{classname}} {{#parent}}extends {{{parent}}}{{/parent}} {{#serializableModel}}implements Serializable{{/serializableModel}} {
|
||||
{{#vars}}
|
||||
|
||||
@@ -1,11 +1,17 @@
|
||||
#!/bin/sh
|
||||
# ref: https://help.github.com/articles/adding-an-existing-project-to-github-using-the-command-line/
|
||||
#
|
||||
# Usage example: /bin/sh ./git_push.sh wing328 openapi-pestore-perl "minor update"
|
||||
# Usage example: /bin/sh ./git_push.sh wing328 openapi-pestore-perl "minor update" "gitlab.com"
|
||||
|
||||
git_user_id=$1
|
||||
git_repo_id=$2
|
||||
release_note=$3
|
||||
git_host=$4
|
||||
|
||||
if [ "$git_host" = "" ]; then
|
||||
git_host="{{{gitHost}}}"
|
||||
echo "[INFO] No command line input provided. Set \$git_host to $git_host"
|
||||
fi
|
||||
|
||||
if [ "$git_user_id" = "" ]; then
|
||||
git_user_id="{{{gitUserId}}}"
|
||||
@@ -28,7 +34,7 @@ git init
|
||||
# Adds the files in the local repository and stages them for commit.
|
||||
git add .
|
||||
|
||||
# Commits the tracked changes and prepares them to be pushed to a remote repository.
|
||||
# Commits the tracked changes and prepares them to be pushed to a remote repository.
|
||||
git commit -m "$release_note"
|
||||
|
||||
# Sets the new remote
|
||||
@@ -36,10 +42,10 @@ git_remote=`git remote`
|
||||
if [ "$git_remote" = "" ]; then # git remote not defined
|
||||
|
||||
if [ "$GIT_TOKEN" = "" ]; then
|
||||
echo "[INFO] \$GIT_TOKEN (environment variable) is not set. Using the Git credential in your environment."
|
||||
git remote add origin https://github.com/${git_user_id}/${git_repo_id}.git
|
||||
echo "[INFO] \$GIT_TOKEN (environment variable) is not set. Using the git credential in your environment."
|
||||
git remote add origin https://${git_host}/${git_user_id}/${git_repo_id}.git
|
||||
else
|
||||
git remote add origin https://${git_user_id}:${GIT_TOKEN}@github.com/${git_user_id}/${git_repo_id}.git
|
||||
git remote add origin https://${git_user_id}:${GIT_TOKEN}@${git_host}/${git_user_id}/${git_repo_id}.git
|
||||
fi
|
||||
|
||||
fi
|
||||
@@ -47,6 +53,6 @@ fi
|
||||
git pull origin master
|
||||
|
||||
# Pushes (Forces) the changes in the local repository up to the remote repository
|
||||
echo "Git pushing to https://github.com/${git_user_id}/${git_repo_id}.git"
|
||||
echo "Git pushing to https://${git_host}/${git_user_id}/${git_repo_id}.git"
|
||||
git push origin master 2>&1 | grep -v 'To https'
|
||||
|
||||
|
||||
@@ -1,11 +1,17 @@
|
||||
#!/bin/sh
|
||||
# ref: https://help.github.com/articles/adding-an-existing-project-to-github-using-the-command-line/
|
||||
#
|
||||
# Usage example: /bin/sh ./git_push.sh wing328 openapi-pestore-perl "minor update"
|
||||
# Usage example: /bin/sh ./git_push.sh wing328 openapi-pestore-perl "minor update" "gitlab.com"
|
||||
|
||||
git_user_id=$1
|
||||
git_repo_id=$2
|
||||
release_note=$3
|
||||
git_host=$4
|
||||
|
||||
if [ "$git_host" = "" ]; then
|
||||
git_host="{{{gitHost}}}"
|
||||
echo "[INFO] No command line input provided. Set \$git_host to $git_host"
|
||||
fi
|
||||
|
||||
if [ "$git_user_id" = "" ]; then
|
||||
git_user_id="{{{gitUserId}}}"
|
||||
@@ -28,7 +34,7 @@ git init
|
||||
# Adds the files in the local repository and stages them for commit.
|
||||
git add .
|
||||
|
||||
# Commits the tracked changes and prepares them to be pushed to a remote repository.
|
||||
# Commits the tracked changes and prepares them to be pushed to a remote repository.
|
||||
git commit -m "$release_note"
|
||||
|
||||
# Sets the new remote
|
||||
@@ -36,10 +42,10 @@ git_remote=`git remote`
|
||||
if [ "$git_remote" = "" ]; then # git remote not defined
|
||||
|
||||
if [ "$GIT_TOKEN" = "" ]; then
|
||||
echo "[INFO] \$GIT_TOKEN (environment variable) is not set. Using the Git credential in your environment."
|
||||
git remote add origin https://github.com/${git_user_id}/${git_repo_id}.git
|
||||
echo "[INFO] \$GIT_TOKEN (environment variable) is not set. Using the git credential in your environment."
|
||||
git remote add origin https://${git_host}/${git_user_id}/${git_repo_id}.git
|
||||
else
|
||||
git remote add origin https://${git_user_id}:${GIT_TOKEN}@github.com/${git_user_id}/${git_repo_id}.git
|
||||
git remote add origin https://${git_user_id}:${GIT_TOKEN}@${git_host}/${git_user_id}/${git_repo_id}.git
|
||||
fi
|
||||
|
||||
fi
|
||||
@@ -47,6 +53,6 @@ fi
|
||||
git pull origin master
|
||||
|
||||
# Pushes (Forces) the changes in the local repository up to the remote repository
|
||||
echo "Git pushing to https://github.com/${git_user_id}/${git_repo_id}.git"
|
||||
echo "Git pushing to https://${git_host}/${git_user_id}/${git_repo_id}.git"
|
||||
git push origin master 2>&1 | grep -v 'To https'
|
||||
|
||||
|
||||
@@ -76,6 +76,7 @@ org.openapitools.codegen.languages.PhpSilexServerCodegen
|
||||
org.openapitools.codegen.languages.PhpSymfonyServerCodegen
|
||||
org.openapitools.codegen.languages.PhpZendExpressivePathHandlerServerCodegen
|
||||
org.openapitools.codegen.languages.PowerShellClientCodegen
|
||||
org.openapitools.codegen.languages.ProtobufSchemaCodegen
|
||||
org.openapitools.codegen.languages.PythonClientCodegen
|
||||
org.openapitools.codegen.languages.PythonClientExperimentalCodegen
|
||||
org.openapitools.codegen.languages.PythonFlaskConnexionServerCodegen
|
||||
|
||||
@@ -1,11 +1,17 @@
|
||||
#!/bin/sh
|
||||
# ref: https://help.github.com/articles/adding-an-existing-project-to-github-using-the-command-line/
|
||||
#
|
||||
# Usage example: /bin/sh ./git_push.sh wing328 openapi-pestore-perl "minor update"
|
||||
# Usage example: /bin/sh ./git_push.sh wing328 openapi-pestore-perl "minor update" "gitlab.com"
|
||||
|
||||
git_user_id=$1
|
||||
git_repo_id=$2
|
||||
release_note=$3
|
||||
git_host=$4
|
||||
|
||||
if [ "$git_host" = "" ]; then
|
||||
git_host="{{{gitHost}}}"
|
||||
echo "[INFO] No command line input provided. Set \$git_host to $git_host"
|
||||
fi
|
||||
|
||||
if [ "$git_user_id" = "" ]; then
|
||||
git_user_id="{{{gitUserId}}}"
|
||||
@@ -37,9 +43,9 @@ if [ "$git_remote" = "" ]; then # git remote not defined
|
||||
|
||||
if [ "$GIT_TOKEN" = "" ]; then
|
||||
echo "[INFO] \$GIT_TOKEN (environment variable) is not set. Using the git credential in your environment."
|
||||
git remote add origin https://github.com/${git_user_id}/${git_repo_id}.git
|
||||
git remote add origin https://${git_host}/${git_user_id}/${git_repo_id}.git
|
||||
else
|
||||
git remote add origin https://${git_user_id}:${GIT_TOKEN}@github.com/${git_user_id}/${git_repo_id}.git
|
||||
git remote add origin https://${git_user_id}:${GIT_TOKEN}@${git_host}/${git_user_id}/${git_repo_id}.git
|
||||
fi
|
||||
|
||||
fi
|
||||
@@ -47,6 +53,6 @@ fi
|
||||
git pull origin master
|
||||
|
||||
# Pushes (Forces) the changes in the local repository up to the remote repository
|
||||
echo "Git pushing to https://github.com/${git_user_id}/${git_repo_id}.git"
|
||||
echo "Git pushing to https://${git_host}/${git_user_id}/${git_repo_id}.git"
|
||||
git push origin master 2>&1 | grep -v 'To https'
|
||||
|
||||
|
||||
@@ -1,11 +1,17 @@
|
||||
#!/bin/sh
|
||||
# ref: https://help.github.com/articles/adding-an-existing-project-to-github-using-the-command-line/
|
||||
#
|
||||
# Usage example: /bin/sh ./git_push.sh wing328 openapi-pestore-perl "minor update"
|
||||
# Usage example: /bin/sh ./git_push.sh wing328 openapi-pestore-perl "minor update" "gitlab.com"
|
||||
|
||||
git_user_id=$1
|
||||
git_repo_id=$2
|
||||
release_note=$3
|
||||
git_host=$4
|
||||
|
||||
if [ "$git_host" = "" ]; then
|
||||
git_host="{{{gitHost}}}"
|
||||
echo "[INFO] No command line input provided. Set \$git_host to $git_host"
|
||||
fi
|
||||
|
||||
if [ "$git_user_id" = "" ]; then
|
||||
git_user_id="{{{gitUserId}}}"
|
||||
@@ -37,9 +43,9 @@ if [ "$git_remote" = "" ]; then # git remote not defined
|
||||
|
||||
if [ "$GIT_TOKEN" = "" ]; then
|
||||
echo "[INFO] \$GIT_TOKEN (environment variable) is not set. Using the git credential in your environment."
|
||||
git remote add origin https://github.com/${git_user_id}/${git_repo_id}.git
|
||||
git remote add origin https://${git_host}/${git_user_id}/${git_repo_id}.git
|
||||
else
|
||||
git remote add origin https://${git_user_id}:${GIT_TOKEN}@github.com/${git_user_id}/${git_repo_id}.git
|
||||
git remote add origin https://${git_user_id}:${GIT_TOKEN}@${git_host}/${git_user_id}/${git_repo_id}.git
|
||||
fi
|
||||
|
||||
fi
|
||||
@@ -47,5 +53,6 @@ fi
|
||||
git pull origin master
|
||||
|
||||
# Pushes (Forces) the changes in the local repository up to the remote repository
|
||||
echo "Git pushing to https://github.com/${git_user_id}/${git_repo_id}.git"
|
||||
echo "Git pushing to https://${git_host}/${git_user_id}/${git_repo_id}.git"
|
||||
git push origin master 2>&1 | grep -v 'To https'
|
||||
|
||||
|
||||
@@ -45,10 +45,10 @@ For more information, see <https://developer.salesforce.com/docs/atlas.en-us.daa
|
||||
1. Clone the repo from GitHub
|
||||
|
||||
```bash
|
||||
git clone git@github.com:{{gitUserId}}/{{gitRepoId}}.git
|
||||
git clone git@{{gitHost}}:{{gitUserId}}/{{gitRepoId}}.git
|
||||
```
|
||||
|
||||
Or, [download](https://github.com/{{gitUserId}}/{{gitRepoId}}/archive/master.zip) the repo as a ZIP and extract it to `{{gitRepoId}}`
|
||||
Or, [download](https://{{gitHost}}/{{gitUserId}}/{{gitRepoId}}/archive/master.zip) the repo as a ZIP and extract it to `{{gitRepoId}}`
|
||||
{{/gitUserId}}{{/gitRepoId}}
|
||||
|
||||
2. Set the `SF_USERNAME` and `SF_PASSWORD` environment variables to your Salesforce username and password. Alternatively, they may be set in `build.properties`. Environment variables will override the values in `build.properties` if set. `SF_SESSIONID` may also be set instead of `SF_USERNAME` and `SF_PASSWORD` (more info in `build.properties`)
|
||||
|
||||
@@ -1,11 +1,17 @@
|
||||
#!/bin/sh
|
||||
# ref: https://help.github.com/articles/adding-an-existing-project-to-github-using-the-command-line/
|
||||
#
|
||||
# Usage example: /bin/sh ./git_push.sh wing328 OAS-petstore-perl "minor update"
|
||||
# Usage example: /bin/sh ./git_push.sh wing328 openapi-pestore-perl "minor update" "gitlab.com"
|
||||
|
||||
git_user_id=$1
|
||||
git_repo_id=$2
|
||||
release_note=$3
|
||||
git_host=$4
|
||||
|
||||
if [ "$git_host" = "" ]; then
|
||||
git_host="{{{gitHost}}}"
|
||||
echo "[INFO] No command line input provided. Set \$git_host to $git_host"
|
||||
fi
|
||||
|
||||
if [ "$git_user_id" = "" ]; then
|
||||
git_user_id="{{{gitUserId}}}"
|
||||
@@ -28,7 +34,7 @@ git init
|
||||
# Adds the files in the local repository and stages them for commit.
|
||||
git add .
|
||||
|
||||
# Commits the tracked changes and prepares them to be pushed to a remote repository.
|
||||
# Commits the tracked changes and prepares them to be pushed to a remote repository.
|
||||
git commit -m "$release_note"
|
||||
|
||||
# Sets the new remote
|
||||
@@ -36,10 +42,10 @@ git_remote=`git remote`
|
||||
if [ "$git_remote" = "" ]; then # git remote not defined
|
||||
|
||||
if [ "$GIT_TOKEN" = "" ]; then
|
||||
echo "[INFO] \$GIT_TOKEN (environment variable) is not set. Using the git crediential in your environment."
|
||||
git remote add origin https://github.com/${git_user_id}/${git_repo_id}.git
|
||||
echo "[INFO] \$GIT_TOKEN (environment variable) is not set. Using the git credential in your environment."
|
||||
git remote add origin https://${git_host}/${git_user_id}/${git_repo_id}.git
|
||||
else
|
||||
git remote add origin https://${git_user_id}:${GIT_TOKEN}@github.com/${git_user_id}/${git_repo_id}.git
|
||||
git remote add origin https://${git_user_id}:${GIT_TOKEN}@${git_host}/${git_user_id}/${git_repo_id}.git
|
||||
fi
|
||||
|
||||
fi
|
||||
@@ -47,6 +53,6 @@ fi
|
||||
git pull origin master
|
||||
|
||||
# Pushes (Forces) the changes in the local repository up to the remote repository
|
||||
echo "Git pushing to https://github.com/${git_user_id}/${git_repo_id}.git"
|
||||
echo "Git pushing to https://${git_host}/${git_user_id}/${git_repo_id}.git"
|
||||
git push origin master 2>&1 | grep -v 'To https'
|
||||
|
||||
|
||||
@@ -1,11 +1,17 @@
|
||||
#!/bin/sh
|
||||
# ref: https://help.github.com/articles/adding-an-existing-project-to-github-using-the-command-line/
|
||||
#
|
||||
# Usage example: /bin/sh ./git_push.sh wing328 openapi-pestore-perl "minor update"
|
||||
# Usage example: /bin/sh ./git_push.sh wing328 openapi-pestore-perl "minor update" "gitlab.com"
|
||||
|
||||
git_user_id=$1
|
||||
git_repo_id=$2
|
||||
release_note=$3
|
||||
git_host=$4
|
||||
|
||||
if [ "$git_host" = "" ]; then
|
||||
git_host="{{{gitHost}}}"
|
||||
echo "[INFO] No command line input provided. Set \$git_host to $git_host"
|
||||
fi
|
||||
|
||||
if [ "$git_user_id" = "" ]; then
|
||||
git_user_id="{{{gitUserId}}}"
|
||||
@@ -28,7 +34,7 @@ git init
|
||||
# Adds the files in the local repository and stages them for commit.
|
||||
git add .
|
||||
|
||||
# Commits the tracked changes and prepares them to be pushed to a remote repository.
|
||||
# Commits the tracked changes and prepares them to be pushed to a remote repository.
|
||||
git commit -m "$release_note"
|
||||
|
||||
# Sets the new remote
|
||||
@@ -37,9 +43,9 @@ if [ "$git_remote" = "" ]; then # git remote not defined
|
||||
|
||||
if [ "$GIT_TOKEN" = "" ]; then
|
||||
echo "[INFO] \$GIT_TOKEN (environment variable) is not set. Using the git credential in your environment."
|
||||
git remote add origin https://github.com/${git_user_id}/${git_repo_id}.git
|
||||
git remote add origin https://${git_host}/${git_user_id}/${git_repo_id}.git
|
||||
else
|
||||
git remote add origin https://${git_user_id}:${GIT_TOKEN}@github.com/${git_user_id}/${git_repo_id}.git
|
||||
git remote add origin https://${git_user_id}:${GIT_TOKEN}@${git_host}/${git_user_id}/${git_repo_id}.git
|
||||
fi
|
||||
|
||||
fi
|
||||
@@ -47,6 +53,6 @@ fi
|
||||
git pull origin master
|
||||
|
||||
# Pushes (Forces) the changes in the local repository up to the remote repository
|
||||
echo "Git pushing to https://github.com/${git_user_id}/${git_repo_id}.git"
|
||||
echo "Git pushing to https://${git_host}/${git_user_id}/${git_repo_id}.git"
|
||||
git push origin master 2>&1 | grep -v 'To https'
|
||||
|
||||
|
||||
@@ -35,12 +35,10 @@ public:
|
||||
/// <summary>
|
||||
/// {{description}}
|
||||
/// </summary>
|
||||
{{#isContainer}}{{{dataType}}}& {{getter}}();
|
||||
{{/isContainer}}{{^isContainer}}{{{dataType}}} {{getter}}() const;
|
||||
void {{setter}}({{{dataType}}} const{{^isPrimitiveType}}&{{/isPrimitiveType}} value);
|
||||
{{/isContainer}}{{^required}}bool {{nameInCamelCase}}IsSet() const;
|
||||
void unset{{name}}();
|
||||
{{/required}}
|
||||
{{{dataType}}}{{#isContainer}}&{{/isContainer}} {{getter}}(){{^isContainer}} const{{/isContainer}};
|
||||
void {{setter}}({{{dataType}}} const{{^isPrimitiveType}}&{{/isPrimitiveType}} value);{{^required}}
|
||||
bool {{nameInCamelCase}}IsSet() const;
|
||||
void unset{{name}}();{{/required}}
|
||||
{{/vars}}
|
||||
|
||||
friend void to_json(nlohmann::json& j, const {{classname}}& o);
|
||||
|
||||
@@ -29,7 +29,7 @@ void to_json(nlohmann::json& j, const {{classname}}& o)
|
||||
{
|
||||
j = nlohmann::json();
|
||||
{{#vars}}
|
||||
{{#required}}j["{{baseName}}"] = o.m_{{name}};{{/required}}{{^required}}if(o.{{nameInCamelCase}}IsSet())
|
||||
{{#required}}j["{{baseName}}"] = o.m_{{name}};{{/required}}{{^required}}if(o.{{nameInCamelCase}}IsSet(){{#isContainer}} || !o.m_{{name}}.empty(){{/isContainer}})
|
||||
j["{{baseName}}"] = o.m_{{name}};{{/required}}
|
||||
{{/vars}}
|
||||
}
|
||||
@@ -45,20 +45,15 @@ void from_json(const nlohmann::json& j, {{classname}}& o)
|
||||
{{/vars}}
|
||||
}
|
||||
|
||||
{{#vars}}{{#isContainer}}{{{dataType}}}& {{classname}}::{{getter}}()
|
||||
{
|
||||
return m_{{name}};
|
||||
}
|
||||
{{/isContainer}}{{^isContainer}}{{{dataType}}} {{classname}}::{{getter}}() const
|
||||
{{#vars}}{{{dataType}}}{{#isContainer}}&{{/isContainer}} {{classname}}::{{getter}}(){{^isContainer}} const{{/isContainer}}
|
||||
{
|
||||
return m_{{name}};
|
||||
}
|
||||
void {{classname}}::{{setter}}({{{dataType}}} const{{^isPrimitiveType}}&{{/isPrimitiveType}} value)
|
||||
{
|
||||
m_{{name}} = value;
|
||||
{{^required}}m_{{name}}IsSet = true;{{/required}}
|
||||
m_{{name}} = value;{{^required}}
|
||||
m_{{name}}IsSet = true;{{/required}}
|
||||
}
|
||||
{{/isContainer}}
|
||||
{{^required}}bool {{classname}}::{{nameInCamelCase}}IsSet() const
|
||||
{
|
||||
return m_{{name}}IsSet;
|
||||
|
||||
@@ -1,11 +1,17 @@
|
||||
#!/bin/sh
|
||||
# ref: https://help.github.com/articles/adding-an-existing-project-to-github-using-the-command-line/
|
||||
#
|
||||
# Usage example: /bin/sh ./git_push.sh wing328 openapi-petstore-cpprest "minor update"
|
||||
# Usage example: /bin/sh ./git_push.sh wing328 openapi-pestore-perl "minor update" "gitlab.com"
|
||||
|
||||
git_user_id=$1
|
||||
git_repo_id=$2
|
||||
release_note=$3
|
||||
git_host=$4
|
||||
|
||||
if [ "$git_host" = "" ]; then
|
||||
git_host="{{{gitHost}}}"
|
||||
echo "[INFO] No command line input provided. Set \$git_host to $git_host"
|
||||
fi
|
||||
|
||||
if [ "$git_user_id" = "" ]; then
|
||||
git_user_id="{{{gitUserId}}}"
|
||||
@@ -37,9 +43,9 @@ if [ "$git_remote" = "" ]; then # git remote not defined
|
||||
|
||||
if [ "$GIT_TOKEN" = "" ]; then
|
||||
echo "[INFO] \$GIT_TOKEN (environment variable) is not set. Using the git credential in your environment."
|
||||
git remote add origin https://github.com/${git_user_id}/${git_repo_id}.git
|
||||
git remote add origin https://${git_host}/${git_user_id}/${git_repo_id}.git
|
||||
else
|
||||
git remote add origin https://${git_user_id}:${GIT_TOKEN}@github.com/${git_user_id}/${git_repo_id}.git
|
||||
git remote add origin https://${git_user_id}:${GIT_TOKEN}@${git_host}/${git_user_id}/${git_repo_id}.git
|
||||
fi
|
||||
|
||||
fi
|
||||
@@ -47,5 +53,6 @@ fi
|
||||
git pull origin master
|
||||
|
||||
# Pushes (Forces) the changes in the local repository up to the remote repository
|
||||
echo "Git pushing to https://github.com/${git_user_id}/${git_repo_id}.git"
|
||||
echo "Git pushing to https://${git_host}/${git_user_id}/${git_repo_id}.git"
|
||||
git push origin master 2>&1 | grep -v 'To https'
|
||||
|
||||
|
||||
@@ -1,11 +1,17 @@
|
||||
#!/bin/sh
|
||||
# ref: https://help.github.com/articles/adding-an-existing-project-to-github-using-the-command-line/
|
||||
#
|
||||
# Usage example: /bin/sh ./git_push.sh wing328 openapi-petstore-cpprest "minor update"
|
||||
# Usage example: /bin/sh ./git_push.sh wing328 openapi-pestore-perl "minor update" "gitlab.com"
|
||||
|
||||
git_user_id=$1
|
||||
git_repo_id=$2
|
||||
release_note=$3
|
||||
git_host=$4
|
||||
|
||||
if [ "$git_host" = "" ]; then
|
||||
git_host="{{{gitHost}}}"
|
||||
echo "[INFO] No command line input provided. Set \$git_host to $git_host"
|
||||
fi
|
||||
|
||||
if [ "$git_user_id" = "" ]; then
|
||||
git_user_id="{{{gitUserId}}}"
|
||||
@@ -37,9 +43,9 @@ if [ "$git_remote" = "" ]; then # git remote not defined
|
||||
|
||||
if [ "$GIT_TOKEN" = "" ]; then
|
||||
echo "[INFO] \$GIT_TOKEN (environment variable) is not set. Using the git credential in your environment."
|
||||
git remote add origin https://github.com/${git_user_id}/${git_repo_id}.git
|
||||
git remote add origin https://${git_host}/${git_user_id}/${git_repo_id}.git
|
||||
else
|
||||
git remote add origin https://${git_user_id}:${GIT_TOKEN}@github.com/${git_user_id}/${git_repo_id}.git
|
||||
git remote add origin https://${git_user_id}:${GIT_TOKEN}@${git_host}/${git_user_id}/${git_repo_id}.git
|
||||
fi
|
||||
|
||||
fi
|
||||
@@ -47,5 +53,6 @@ fi
|
||||
git pull origin master
|
||||
|
||||
# Pushes (Forces) the changes in the local repository up to the remote repository
|
||||
echo "Git pushing to https://github.com/${git_user_id}/${git_repo_id}.git"
|
||||
echo "Git pushing to https://${git_host}/${git_user_id}/${git_repo_id}.git"
|
||||
git push origin master 2>&1 | grep -v 'To https'
|
||||
|
||||
|
||||
@@ -317,7 +317,7 @@ namespace {{packageName}}.Client
|
||||
request.RequestFormat = DataFormat.Json;
|
||||
}
|
||||
|
||||
request.AddBody(options.Data);
|
||||
request.AddJsonBody(options.Data);
|
||||
}
|
||||
|
||||
if (options.FileParameters != null)
|
||||
@@ -327,9 +327,9 @@ namespace {{packageName}}.Client
|
||||
var bytes = ClientUtils.ReadAsBytes(fileParam.Value);
|
||||
var fileStream = fileParam.Value as FileStream;
|
||||
if (fileStream != null)
|
||||
FileParameter.Create(fileParam.Key, bytes, System.IO.Path.GetFileName(fileStream.Name));
|
||||
request.Files.Add(FileParameter.Create(fileParam.Key, bytes, System.IO.Path.GetFileName(fileStream.Name)));
|
||||
else
|
||||
FileParameter.Create(fileParam.Key, bytes, "no_file_name_provided");
|
||||
request.Files.Add(FileParameter.Create(fileParam.Key, bytes, "no_file_name_provided"));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -400,7 +400,7 @@ namespace {{packageName}}.Client
|
||||
{
|
||||
ApiKey = apiKey,
|
||||
ApiKeyPrefix = apiKeyPrefix,
|
||||
DefaultHeader = defaultHeaders,
|
||||
DefaultHeaders = defaultHeaders,
|
||||
BasePath = second.BasePath ?? first.BasePath,
|
||||
Timeout = second.Timeout,
|
||||
UserAgent = second.UserAgent ?? first.UserAgent,
|
||||
|
||||
@@ -1,11 +1,17 @@
|
||||
#!/bin/sh
|
||||
# ref: https://help.github.com/articles/adding-an-existing-project-to-github-using-the-command-line/
|
||||
#
|
||||
# Usage example: /bin/sh ./git_push.sh wing328 openapi-petstore-perl "minor update"
|
||||
# Usage example: /bin/sh ./git_push.sh wing328 openapi-pestore-perl "minor update" "gitlab.com"
|
||||
|
||||
git_user_id=$1
|
||||
git_repo_id=$2
|
||||
release_note=$3
|
||||
git_host=$4
|
||||
|
||||
if [ "$git_host" = "" ]; then
|
||||
git_host="{{{gitHost}}}"
|
||||
echo "[INFO] No command line input provided. Set \$git_host to $git_host"
|
||||
fi
|
||||
|
||||
if [ "$git_user_id" = "" ]; then
|
||||
git_user_id="{{{gitUserId}}}"
|
||||
@@ -37,9 +43,9 @@ if [ "$git_remote" = "" ]; then # git remote not defined
|
||||
|
||||
if [ "$GIT_TOKEN" = "" ]; then
|
||||
echo "[INFO] \$GIT_TOKEN (environment variable) is not set. Using the git credential in your environment."
|
||||
git remote add origin https://github.com/${git_user_id}/${git_repo_id}.git
|
||||
git remote add origin https://${git_host}/${git_user_id}/${git_repo_id}.git
|
||||
else
|
||||
git remote add origin https://${git_user_id}:${GIT_TOKEN}@github.com/${git_user_id}/${git_repo_id}.git
|
||||
git remote add origin https://${git_user_id}:${GIT_TOKEN}@${git_host}/${git_user_id}/${git_repo_id}.git
|
||||
fi
|
||||
|
||||
fi
|
||||
@@ -47,6 +53,6 @@ fi
|
||||
git pull origin master
|
||||
|
||||
# Pushes (Forces) the changes in the local repository up to the remote repository
|
||||
echo "Git pushing to https://github.com/${git_user_id}/${git_repo_id}.git"
|
||||
echo "Git pushing to https://${git_host}/${git_user_id}/${git_repo_id}.git"
|
||||
git push origin master 2>&1 | grep -v 'To https'
|
||||
|
||||
|
||||
@@ -1,11 +1,17 @@
|
||||
#!/bin/sh
|
||||
# ref: https://help.github.com/articles/adding-an-existing-project-to-github-using-the-command-line/
|
||||
#
|
||||
# Usage example: /bin/sh ./git_push.sh wing328 openapi-petstore-perl "minor update"
|
||||
# Usage example: /bin/sh ./git_push.sh wing328 openapi-pestore-perl "minor update" "gitlab.com"
|
||||
|
||||
git_user_id=$1
|
||||
git_repo_id=$2
|
||||
release_note=$3
|
||||
git_host=$4
|
||||
|
||||
if [ "$git_host" = "" ]; then
|
||||
git_host="{{{gitHost}}}"
|
||||
echo "[INFO] No command line input provided. Set \$git_host to $git_host"
|
||||
fi
|
||||
|
||||
if [ "$git_user_id" = "" ]; then
|
||||
git_user_id="{{{gitUserId}}}"
|
||||
@@ -37,9 +43,9 @@ if [ "$git_remote" = "" ]; then # git remote not defined
|
||||
|
||||
if [ "$GIT_TOKEN" = "" ]; then
|
||||
echo "[INFO] \$GIT_TOKEN (environment variable) is not set. Using the git credential in your environment."
|
||||
git remote add origin https://github.com/${git_user_id}/${git_repo_id}.git
|
||||
git remote add origin https://${git_host}/${git_user_id}/${git_repo_id}.git
|
||||
else
|
||||
git remote add origin https://${git_user_id}:${GIT_TOKEN}@github.com/${git_user_id}/${git_repo_id}.git
|
||||
git remote add origin https://${git_user_id}:${GIT_TOKEN}@${git_host}/${git_user_id}/${git_repo_id}.git
|
||||
fi
|
||||
|
||||
fi
|
||||
@@ -47,6 +53,6 @@ fi
|
||||
git pull origin master
|
||||
|
||||
# Pushes (Forces) the changes in the local repository up to the remote repository
|
||||
echo "Git pushing to https://github.com/${git_user_id}/${git_repo_id}.git"
|
||||
echo "Git pushing to https://${git_host}/${git_user_id}/${git_repo_id}.git"
|
||||
git push origin master 2>&1 | grep -v 'To https'
|
||||
|
||||
|
||||
@@ -39,7 +39,7 @@ version: {{pubVersion}}
|
||||
description: {{pubDescription}}
|
||||
dependencies:
|
||||
{{pubName}}:
|
||||
git: https://github.com/{{gitUserId}}/{{gitRepoId}}.git
|
||||
git: https://{{gitHost}}/{{gitUserId}}/{{gitRepoId}}.git
|
||||
version: 'any'
|
||||
```
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
library {{pubName}}.api;
|
||||
|
||||
import 'package:http/io_client.dart';
|
||||
import 'package:http/http.dart' as http;
|
||||
import 'package:jaguar_serializer/jaguar_serializer.dart';
|
||||
{{#protoFormat}}
|
||||
import 'package:jaguar_serializer_protobuf/proto_repo.dart';
|
||||
@@ -19,7 +19,7 @@ import 'package:jaguar_mimetype/jaguar_mimetype.dart';
|
||||
|
||||
{{#jsonFormat}}
|
||||
final _jsonJaguarRepo = JsonRepo()
|
||||
{{#models}}{{#model}}..add({{classname}}Serializer())
|
||||
{{#models}}{{#model}}{{^isEnum}}..add({{classname}}Serializer()){{/isEnum}}
|
||||
{{/model}}{{/models}};
|
||||
final Map<String, CodecRepo> defaultConverters = {
|
||||
MimeTypes.json: _jsonJaguarRepo,
|
||||
@@ -52,7 +52,7 @@ class {{clientName}} {
|
||||
* Add custom global interceptors, put overrideInterceptors to true to set your interceptors only (auth interceptors will not be added)
|
||||
*/
|
||||
{{clientName}}({List<Interceptor> interceptors, bool overrideInterceptors = false, String baseUrl, this.timeout = const Duration(minutes: 2)}) {
|
||||
_baseRoute = Route(baseUrl ?? basePath).withClient(globalClient ?? IOClient());
|
||||
_baseRoute = Route(baseUrl ?? basePath).withClient(globalClient ?? http.Client());
|
||||
if(interceptors == null) {
|
||||
this.interceptors = _defaultInterceptors;
|
||||
}
|
||||
@@ -97,4 +97,4 @@ class {{clientName}} {
|
||||
}
|
||||
|
||||
{{/apis}}{{/apiInfo}}
|
||||
}
|
||||
}
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user