mirror of
https://github.com/OpenAPITools/openapi-generator.git
synced 2025-12-29 13:37:06 +00:00
Compare commits
49 Commits
v4.1.0
...
java_fix_e
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a049e4c271 | ||
|
|
eee7a40629 | ||
|
|
a5ab60bec8 | ||
|
|
e086ad1b6e | ||
|
|
1a6d3671d9 | ||
|
|
589e5c6312 | ||
|
|
024f46814c | ||
|
|
1ce09788a9 | ||
|
|
44fda895d2 | ||
|
|
aa4ead2a6d | ||
|
|
7e8c7db798 | ||
|
|
b83fe0c611 | ||
|
|
5182955cca | ||
|
|
cd9eea2fe5 | ||
|
|
ef88bd175f | ||
|
|
99fcfbc802 | ||
|
|
a4811c7850 | ||
|
|
2ada4d90b4 | ||
|
|
dac370b7f7 | ||
|
|
6f7d2792c7 | ||
|
|
2d7785ac63 | ||
|
|
eb6ca9199b | ||
|
|
c3535cf9ca | ||
|
|
286cdfdfa2 | ||
|
|
55786119e7 | ||
|
|
94d4e0cfac | ||
|
|
99d85a39a3 | ||
|
|
b936d72dfa | ||
|
|
93aedcf3d5 | ||
|
|
d04e16a255 | ||
|
|
fae0528cd5 | ||
|
|
ba65f675e2 | ||
|
|
5e27f11ef1 | ||
|
|
850c493c63 | ||
|
|
f5327b601e | ||
|
|
123efc5d65 | ||
|
|
36ccd87a80 | ||
|
|
20db89e277 | ||
|
|
a5349cfde5 | ||
|
|
4a92cd8dca | ||
|
|
c8a65a9942 | ||
|
|
4b6499c636 | ||
|
|
290550ef91 | ||
|
|
06533b977c | ||
|
|
07381e7275 | ||
|
|
22d022b2d5 | ||
|
|
42d6420400 | ||
|
|
ac85c8f901 | ||
|
|
5956569e7a |
@@ -53,6 +53,7 @@ public class ArrayOfArrayOfNumberOnlyTest {
|
|||||||
List<BigDecimal> arrayArrayNumber = new ArrayList<BigDecimal>();
|
List<BigDecimal> arrayArrayNumber = new ArrayList<BigDecimal>();
|
||||||
arrayArrayNumber.add(b1);
|
arrayArrayNumber.add(b1);
|
||||||
arrayArrayNumber.add(b2);
|
arrayArrayNumber.add(b2);
|
||||||
|
model.setArrayArrayNumber(new ArrayList<List<BigDecimal>>());
|
||||||
model.getArrayArrayNumber().add(arrayArrayNumber);
|
model.getArrayArrayNumber().add(arrayArrayNumber);
|
||||||
|
|
||||||
// create another instance for comparison
|
// create another instance for comparison
|
||||||
@@ -62,6 +63,7 @@ public class ArrayOfArrayOfNumberOnlyTest {
|
|||||||
List<BigDecimal> arrayArrayNumber2 = new ArrayList<BigDecimal>();
|
List<BigDecimal> arrayArrayNumber2 = new ArrayList<BigDecimal>();
|
||||||
arrayArrayNumber2.add(b1);
|
arrayArrayNumber2.add(b1);
|
||||||
arrayArrayNumber2.add(b2);
|
arrayArrayNumber2.add(b2);
|
||||||
|
model2.setArrayArrayNumber(new ArrayList<List<BigDecimal>>());
|
||||||
model2.getArrayArrayNumber().add(arrayArrayNumber2);
|
model2.getArrayArrayNumber().add(arrayArrayNumber2);
|
||||||
|
|
||||||
Assert.assertTrue(model2.equals(model));
|
Assert.assertTrue(model2.equals(model));
|
||||||
|
|||||||
23
README.md
23
README.md
@@ -8,6 +8,12 @@
|
|||||||
[](https://ci.appveyor.com/project/WilliamCheng/openapi-generator-wh2wu)
|
[](https://ci.appveyor.com/project/WilliamCheng/openapi-generator-wh2wu)
|
||||||
[](https://cloud.drone.io/OpenAPITools/openapi-generator)
|
[](https://cloud.drone.io/OpenAPITools/openapi-generator)
|
||||||
|
|
||||||
|
[`4.2.x`](https://github.com/OpenAPITools/openapi-generator/tree/4.2.x) branch: [](https://travis-ci.org/OpenAPITools/openapi-generator)
|
||||||
|
[](https://circleci.com/gh/OpenAPITools/openapi-generator)
|
||||||
|
[](https://app.shippable.com/github/OpenAPITools/openapi-generator)
|
||||||
|
[](https://ci.appveyor.com/project/WilliamCheng/openapi-generator-wh2wu)
|
||||||
|
[](https://cloud.drone.io/OpenAPITools/openapi-generator)
|
||||||
|
|
||||||
[`5.0.x`](https://github.com/OpenAPITools/openapi-generator/tree/5.0.x) branch: [](https://travis-ci.org/OpenAPITools/openapi-generator)
|
[`5.0.x`](https://github.com/OpenAPITools/openapi-generator/tree/5.0.x) branch: [](https://travis-ci.org/OpenAPITools/openapi-generator)
|
||||||
[](https://circleci.com/gh/OpenAPITools/openapi-generator)
|
[](https://circleci.com/gh/OpenAPITools/openapi-generator)
|
||||||
[](https://app.shippable.com/github/OpenAPITools/openapi-generator)
|
[](https://app.shippable.com/github/OpenAPITools/openapi-generator)
|
||||||
@@ -59,7 +65,7 @@ OpenAPI Generator allows generation of API client libraries (SDK generation), se
|
|||||||
|
|
||||||
| | Languages/Frameworks |
|
| | 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 - 7.x), Aurelia, Axios, Fetch, Inversify, jQuery, Node, Rxjs)
|
**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)
|
||||||
**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, 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)
|
**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, 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**
|
**API documentation generators** | **HTML**, **Confluence Wiki**
|
||||||
**Configuration files** | [**Apache2**](https://httpd.apache.org/)
|
**Configuration files** | [**Apache2**](https://httpd.apache.org/)
|
||||||
@@ -101,8 +107,9 @@ The OpenAPI Specification has undergone 3 revisions since initial creation in 20
|
|||||||
OpenAPI Generator Version | Release Date | Notes
|
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)
|
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.1.0 (upcoming minor release) [SNAPSHOT](https://oss.sonatype.org/content/repositories/snapshots/org/openapitools/openapi-generator-cli/4.1.0-SNAPSHOT/)| 31.07.2019 | Minor release (breaking changes with fallbacks)
|
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.0](https://github.com/OpenAPITools/openapi-generator/releases/tag/v4.1.0) (latest stable release) | 09.07.2019 | Patch release (bug fixes, minor enhancements, etc)
|
4.1.1 (upcoming minor release) [SNAPSHOT](https://oss.sonatype.org/content/repositories/snapshots/org/openapitools/openapi-generator-cli/4.1.1-SNAPSHOT/)| 23.08.2019 | Patch release (bug fixes, enhancements)
|
||||||
|
[4.1.0](https://github.com/OpenAPITools/openapi-generator/releases/tag/v4.1.0) (latest stable release) | 09.08.2019 | Minor release (breaking changes with fallbacks)
|
||||||
|
|
||||||
OpenAPI Spec compatibility: 1.0, 1.1, 1.2, 2.0, 3.0
|
OpenAPI Spec compatibility: 1.0, 1.1, 1.2, 2.0, 3.0
|
||||||
|
|
||||||
@@ -448,7 +455,6 @@ NAME
|
|||||||
SYNOPSIS
|
SYNOPSIS
|
||||||
openapi-generator-cli generate
|
openapi-generator-cli generate
|
||||||
[(-a <authorization> | --auth <authorization>)]
|
[(-a <authorization> | --auth <authorization>)]
|
||||||
[--additional-properties <additional properties>...]
|
|
||||||
[--api-package <api package>] [--artifact-id <artifact id>]
|
[--api-package <api package>] [--artifact-id <artifact id>]
|
||||||
[--artifact-version <artifact version>]
|
[--artifact-version <artifact version>]
|
||||||
[(-c <configuration file> | --config <configuration file>)]
|
[(-c <configuration file> | --config <configuration file>)]
|
||||||
@@ -469,12 +475,13 @@ SYNOPSIS
|
|||||||
[--model-name-prefix <model name prefix>]
|
[--model-name-prefix <model name prefix>]
|
||||||
[--model-name-suffix <model name suffix>]
|
[--model-name-suffix <model name suffix>]
|
||||||
[--model-package <model package>]
|
[--model-package <model package>]
|
||||||
[(-o <output directory> | --output <output directory>)]
|
[(-o <output directory> | --output <output directory>)]
|
||||||
|
[(-p <additional properties> | --additional-properties <additional properties>)...]
|
||||||
[--package-name <package name>] [--release-note <release note>]
|
[--package-name <package name>] [--release-note <release note>]
|
||||||
[--remove-operation-id-prefix]
|
[--remove-operation-id-prefix]
|
||||||
[--reserved-words-mappings <reserved word mappings>...]
|
[--reserved-words-mappings <reserved word mappings>...]
|
||||||
[(-s | --skip-overwrite)] [--skip-validate-spec]
|
[(-s | --skip-overwrite)] [--server-variables <server variables>...]
|
||||||
[--strict-spec <true/false strict behavior>]
|
[--skip-validate-spec] [--strict-spec <true/false strict behavior>]
|
||||||
[(-t <template directory> | --template-dir <template directory>)]
|
[(-t <template directory> | --template-dir <template directory>)]
|
||||||
[--type-mappings <type mappings>...] [(-v | --verbose)]
|
[--type-mappings <type mappings>...] [(-v | --verbose)]
|
||||||
|
|
||||||
@@ -790,7 +797,7 @@ If you want to join the committee, please kindly apply by sending an email to te
|
|||||||
| Apex | |
|
| Apex | |
|
||||||
| Bash | @frol (2017/07) @bkryza (2017/08) @kenjones-cisco (2017/09) |
|
| Bash | @frol (2017/07) @bkryza (2017/08) @kenjones-cisco (2017/09) |
|
||||||
| C | @zhemant (2018/11) |
|
| C | @zhemant (2018/11) |
|
||||||
| C++ | @ravinikam (2017/07) @stkrwork (2017/07) @etherealjoy (2018/02) @martindelille (2018/03) |
|
| 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) |
|
| C# | @mandrean (2017/08), @jimschubert (2017/09) [:heart:](https://www.patreon.com/jimschubert) |
|
||||||
| Clojure | |
|
| Clojure | |
|
||||||
| Dart | @ircecho (2017/07) @swipesight (2018/09) @jaumard (2018/09) |
|
| Dart | @ircecho (2017/07) @swipesight (2018/09) @jaumard (2018/09) |
|
||||||
|
|||||||
@@ -38,4 +38,8 @@ for spec_path in modules/openapi-generator/src/test/resources/*/rust-server/* ;
|
|||||||
$@"
|
$@"
|
||||||
|
|
||||||
java $JAVA_OPTS -jar $executable $args
|
java $JAVA_OPTS -jar $executable $args
|
||||||
|
|
||||||
|
if [ $? -ne 0 ]; then
|
||||||
|
exit $?
|
||||||
|
fi
|
||||||
done
|
done
|
||||||
|
|||||||
@@ -13,3 +13,4 @@
|
|||||||
./bin/typescript-angular-v7-petstore-not-provided-in-root-with-npm.sh
|
./bin/typescript-angular-v7-petstore-not-provided-in-root-with-npm.sh
|
||||||
./bin/typescript-angular-v7-petstore-provided-in-root.sh
|
./bin/typescript-angular-v7-petstore-provided-in-root.sh
|
||||||
./bin/typescript-angular-v7-petstore-provided-in-root-with-npm.sh
|
./bin/typescript-angular-v7-petstore-provided-in-root-with-npm.sh
|
||||||
|
./bin/typescript-angular-v8-petstore-provided-in-root-with-npm.sh
|
||||||
|
|||||||
@@ -0,0 +1,7 @@
|
|||||||
|
{
|
||||||
|
"npmName": "@openapitools/typescript-angular-petstore",
|
||||||
|
"npmVersion": "1.0.0",
|
||||||
|
"npmRepository" : "https://skimdb.npmjs.com/registry",
|
||||||
|
"snapshot" : false,
|
||||||
|
"ngVersion": "8.0.0"
|
||||||
|
}
|
||||||
32
bin/typescript-angular-v8-petstore-provided-in-root-with-npm.sh
Executable file
32
bin/typescript-angular-v8-petstore-provided-in-root-with-npm.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-angular -c bin/typescript-angular-v8-petstore-provided-in-root-with-npm.json -o samples/client/petstore/typescript-angular-v8-provided-in-root/builds/with-npm --additional-properties ngVersion=8.0.0 $@"
|
||||||
|
|
||||||
|
java $JAVA_OPTS -jar $executable $ags
|
||||||
@@ -12,6 +12,7 @@ sleep 5
|
|||||||
# LIST OF SCRIPTS:
|
# LIST OF SCRIPTS:
|
||||||
declare -a scripts=(
|
declare -a scripts=(
|
||||||
# SAMPLES
|
# SAMPLES
|
||||||
|
"./bin/ruby-client-petstore.sh"
|
||||||
"./bin/openapi3/ruby-client-petstore.sh"
|
"./bin/openapi3/ruby-client-petstore.sh"
|
||||||
"./bin/openapi3/ruby-client-faraday-petstore.sh"
|
"./bin/openapi3/ruby-client-faraday-petstore.sh"
|
||||||
"./bin/java-petstore-all.sh"
|
"./bin/java-petstore-all.sh"
|
||||||
@@ -57,11 +58,11 @@ declare -a scripts=(
|
|||||||
"./bin/groovy-petstore.sh"
|
"./bin/groovy-petstore.sh"
|
||||||
"./bin/apex-petstore.sh"
|
"./bin/apex-petstore.sh"
|
||||||
"./bin/perl-petstore-all.sh"
|
"./bin/perl-petstore-all.sh"
|
||||||
|
"./bin/dart-jaguar-petstore.sh"
|
||||||
#"./bin/elm-petstore-all.sh"
|
#"./bin/elm-petstore-all.sh"
|
||||||
"./bin/meta-codegen.sh"
|
"./bin/meta-codegen.sh"
|
||||||
# OTHERS
|
# OTHERS
|
||||||
"./bin/utils/export_docs_generators.sh"
|
"./bin/utils/export_docs_generators.sh"
|
||||||
"./bin/utils/export_generators_docusaurus_index.sh"
|
|
||||||
"./bin/utils/copy-to-website.sh"
|
"./bin/utils/copy-to-website.sh"
|
||||||
"./bin/utils/export_generators_readme.sh")
|
"./bin/utils/export_generators_readme.sh")
|
||||||
|
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ echo "# START SCRIPT: ${SCRIPT}"
|
|||||||
|
|
||||||
executable="./modules/openapi-generator-cli/target/openapi-generator-cli.jar"
|
executable="./modules/openapi-generator-cli/target/openapi-generator-cli.jar"
|
||||||
|
|
||||||
for GENERATOR in $(java -jar ${executable} list --short | sed -e 's/,/\'$'\n''/g')
|
for GENERATOR in $(java -jar ${executable} list --short --include all | sed -e 's/,/\'$'\n''/g')
|
||||||
do
|
do
|
||||||
./bin/utils/export_generator.sh ${GENERATOR}
|
./bin/utils/export_generator.sh ${GENERATOR}
|
||||||
done
|
done
|
||||||
|
|||||||
@@ -1,20 +0,0 @@
|
|||||||
#!/bin/sh
|
|
||||||
|
|
||||||
SCRIPT="$0"
|
|
||||||
echo "# START SCRIPT: $SCRIPT"
|
|
||||||
|
|
||||||
executable="./modules/openapi-generator-cli/target/openapi-generator-cli.jar"
|
|
||||||
|
|
||||||
\rm -rf docs/generators.md
|
|
||||||
|
|
||||||
cat > docs/generators.md << EOF
|
|
||||||
---
|
|
||||||
id: generators
|
|
||||||
title: Generators List
|
|
||||||
---
|
|
||||||
|
|
||||||
EOF
|
|
||||||
|
|
||||||
java -jar $executable list --docsite >> docs/generators.md
|
|
||||||
|
|
||||||
echo "Wrote $(pwd)/docs/generators.md"
|
|
||||||
@@ -15,6 +15,6 @@ title: Generators List
|
|||||||
|
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
java -jar $executable list | sed -e 's/\([A-Z]*\) generators:/* \1 generators:/g' -e 's/- \([a-z0-9\-]*\)/- [\1]\(generators\/\1.md\)/g' >> docs/generators.md
|
java -jar $executable list --docsite --include all >> docs/generators.md
|
||||||
|
|
||||||
echo "Wrote $(pwd)/docs/generators.md"
|
echo "Wrote $(pwd)/docs/generators.md"
|
||||||
|
|||||||
@@ -42,7 +42,7 @@ artifactid=openapi-generator-cli
|
|||||||
ver=${OPENAPI_GENERATOR_VERSION:-$(latest.tag $ghrepo)}
|
ver=${OPENAPI_GENERATOR_VERSION:-$(latest.tag $ghrepo)}
|
||||||
|
|
||||||
jar=${artifactid}-${ver}.jar
|
jar=${artifactid}-${ver}.jar
|
||||||
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
DIR=${OPENAPI_GENERATOR_DOWLOAD_CACHE_DIR:-"$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"}
|
||||||
|
|
||||||
if [ ! -f ${DIR}/${jar} ]; then
|
if [ ! -f ${DIR}/${jar} ]; then
|
||||||
repo="central::default::https://repo1.maven.org/maven2/"
|
repo="central::default::https://repo1.maven.org/maven2/"
|
||||||
|
|||||||
@@ -11,4 +11,4 @@ call .\bin\windows\typescript-angular-v7-provided-in-root.bat
|
|||||||
call .\bin\windows\typescript-angular-v7-provided-in-root-with-npm.bat
|
call .\bin\windows\typescript-angular-v7-provided-in-root-with-npm.bat
|
||||||
call .\bin\windows\typescript-angular-v7-not-provided-in-root.bat
|
call .\bin\windows\typescript-angular-v7-not-provided-in-root.bat
|
||||||
call .\bin\windows\typescript-angular-v7-not-provided-in-root-with-npm.bat
|
call .\bin\windows\typescript-angular-v7-not-provided-in-root-with-npm.bat
|
||||||
|
call .\bin\windows\typescript-angular-v8-provided-in-root-with-npm.bat
|
||||||
|
|||||||
@@ -0,0 +1,9 @@
|
|||||||
|
set executable=.\modules\openapi-generator-cli\target\openapi-generator-cli.jar
|
||||||
|
|
||||||
|
If Not Exist %executable% (
|
||||||
|
mvn clean package
|
||||||
|
)
|
||||||
|
|
||||||
|
set ags=generate -i modules\openapi-generator\src\test\resources\2_0\petstore.yaml -g typescript-angular -c bin/typescript-angular-v8-petstore-provided-in-root-with-npm.json -o samples\client\petstore\typescript-angular-v8-provided-in-root\builds\with-npm --additional-properties ngVersion=8.0.0
|
||||||
|
|
||||||
|
java %JAVA_OPTS% -jar %executable% %ags%
|
||||||
@@ -5,132 +5,132 @@ title: Generators List
|
|||||||
|
|
||||||
The following generators are available:
|
The following generators are available:
|
||||||
|
|
||||||
* CLIENT generators:
|
## CLIENT generators
|
||||||
- [ada](generators/ada.md)
|
* [ada](generators/ada)
|
||||||
- [android](generators/android.md)
|
* [android](generators/android)
|
||||||
- [apex](generators/apex.md)
|
* [apex](generators/apex)
|
||||||
- [bash](generators/bash.md)
|
* [bash](generators/bash)
|
||||||
- [c](generators/c.md)
|
* [c](generators/c)
|
||||||
- [clojure](generators/clojure.md)
|
* [clojure](generators/clojure)
|
||||||
- [cpp-qt5-client](generators/cpp-qt5-client.md)
|
* [cpp-qt5-client](generators/cpp-qt5-client)
|
||||||
- [cpp-restsdk](generators/cpp-restsdk.md)
|
* [cpp-restsdk](generators/cpp-restsdk)
|
||||||
- [cpp-tizen](generators/cpp-tizen.md)
|
* [cpp-tizen](generators/cpp-tizen)
|
||||||
- [csharp](generators/csharp.md)
|
* [csharp](generators/csharp)
|
||||||
- [csharp-dotnet2](generators/csharp-dotnet2.md) (deprecated)
|
* [csharp-dotnet2 (deprecated)](generators/csharp-dotnet2)
|
||||||
- [csharp-netcore](generators/csharp-netcore.md)
|
* [csharp-netcore](generators/csharp-netcore)
|
||||||
- [dart](generators/dart.md)
|
* [dart](generators/dart)
|
||||||
- [dart-jaguar](generators/dart-jaguar.md)
|
* [dart-jaguar](generators/dart-jaguar)
|
||||||
- [eiffel](generators/eiffel.md)
|
* [eiffel](generators/eiffel)
|
||||||
- [elixir](generators/elixir.md)
|
* [elixir](generators/elixir)
|
||||||
- [elm](generators/elm.md)
|
* [elm](generators/elm)
|
||||||
- [erlang-client](generators/erlang-client.md)
|
* [erlang-client](generators/erlang-client)
|
||||||
- [erlang-proper](generators/erlang-proper.md)
|
* [erlang-proper](generators/erlang-proper)
|
||||||
- [flash](generators/flash.md)
|
* [flash](generators/flash)
|
||||||
- [go](generators/go.md)
|
* [go](generators/go)
|
||||||
- [go-experimental](generators/go-experimental.md)
|
* [go-experimental (experimental)](generators/go-experimental)
|
||||||
- [groovy](generators/groovy.md)
|
* [groovy](generators/groovy)
|
||||||
- [haskell-http-client](generators/haskell-http-client.md)
|
* [haskell-http-client](generators/haskell-http-client)
|
||||||
- [java](generators/java.md)
|
* [java](generators/java)
|
||||||
- [javascript](generators/javascript.md)
|
* [javascript](generators/javascript)
|
||||||
- [javascript-closure-angular](generators/javascript-closure-angular.md)
|
* [javascript-closure-angular](generators/javascript-closure-angular)
|
||||||
- [javascript-flowtyped](generators/javascript-flowtyped.md)
|
* [javascript-flowtyped](generators/javascript-flowtyped)
|
||||||
- [jaxrs-cxf-client](generators/jaxrs-cxf-client.md)
|
* [jaxrs-cxf-client](generators/jaxrs-cxf-client)
|
||||||
- [jmeter](generators/jmeter.md)
|
* [jmeter](generators/jmeter)
|
||||||
- [kotlin](generators/kotlin.md)
|
* [kotlin](generators/kotlin)
|
||||||
- [lua](generators/lua.md)
|
* [lua](generators/lua)
|
||||||
- [objc](generators/objc.md)
|
* [objc](generators/objc)
|
||||||
- [ocaml](generators/ocaml.md)
|
* [ocaml](generators/ocaml)
|
||||||
- [perl](generators/perl.md)
|
* [perl](generators/perl)
|
||||||
- [php](generators/php.md)
|
* [php](generators/php)
|
||||||
- [powershell](generators/powershell.md)
|
* [powershell](generators/powershell)
|
||||||
- [python](generators/python.md)
|
* [python](generators/python)
|
||||||
- [python-experimental](generators/python-experimental.md)
|
* [python-experimental (experimental)](generators/python-experimental)
|
||||||
- [r](generators/r.md)
|
* [r](generators/r)
|
||||||
- [ruby](generators/ruby.md)
|
* [ruby](generators/ruby)
|
||||||
- [rust](generators/rust.md)
|
* [rust](generators/rust)
|
||||||
- [scala-akka](generators/scala-akka.md)
|
* [scala-akka](generators/scala-akka)
|
||||||
- [scala-gatling](generators/scala-gatling.md)
|
* [scala-gatling](generators/scala-gatling)
|
||||||
- [scala-httpclient-deprecated](generators/scala-httpclient-deprecated.md) (deprecated)
|
* [scala-httpclient-deprecated (deprecated)](generators/scala-httpclient-deprecated)
|
||||||
- [scalaz](generators/scalaz.md)
|
* [scalaz](generators/scalaz)
|
||||||
- [swift2-deprecated](generators/swift2-deprecated.md) (deprecated)
|
* [swift2-deprecated (deprecated)](generators/swift2-deprecated)
|
||||||
- [swift3-deprecated](generators/swift3-deprecated.md) (deprecated)
|
* [swift3-deprecated (deprecated)](generators/swift3-deprecated)
|
||||||
- [swift4](generators/swift4.md)
|
* [swift4](generators/swift4)
|
||||||
- [typescript-angular](generators/typescript-angular.md)
|
* [typescript-angular](generators/typescript-angular)
|
||||||
- [typescript-angularjs](generators/typescript-angularjs.md)
|
* [typescript-angularjs](generators/typescript-angularjs)
|
||||||
- [typescript-aurelia](generators/typescript-aurelia.md)
|
* [typescript-aurelia](generators/typescript-aurelia)
|
||||||
- [typescript-axios](generators/typescript-axios.md)
|
* [typescript-axios](generators/typescript-axios)
|
||||||
- [typescript-fetch](generators/typescript-fetch.md)
|
* [typescript-fetch](generators/typescript-fetch)
|
||||||
- [typescript-inversify](generators/typescript-inversify.md)
|
* [typescript-inversify](generators/typescript-inversify)
|
||||||
- [typescript-jquery](generators/typescript-jquery.md)
|
* [typescript-jquery](generators/typescript-jquery)
|
||||||
- [typescript-node](generators/typescript-node.md)
|
* [typescript-node](generators/typescript-node)
|
||||||
- [typescript-rxjs](generators/typescript-rxjs.md)
|
* [typescript-rxjs](generators/typescript-rxjs)
|
||||||
|
|
||||||
|
|
||||||
* SERVER generators:
|
## SERVER generators
|
||||||
- [ada-server](generators/ada-server.md)
|
* [ada-server](generators/ada-server)
|
||||||
- [aspnetcore](generators/aspnetcore.md)
|
* [aspnetcore](generators/aspnetcore)
|
||||||
- [cpp-pistache-server](generators/cpp-pistache-server.md)
|
* [cpp-pistache-server](generators/cpp-pistache-server)
|
||||||
- [cpp-qt5-qhttpengine-server](generators/cpp-qt5-qhttpengine-server.md)
|
* [cpp-qt5-qhttpengine-server](generators/cpp-qt5-qhttpengine-server)
|
||||||
- [cpp-restbed-server](generators/cpp-restbed-server.md)
|
* [cpp-restbed-server](generators/cpp-restbed-server)
|
||||||
- [csharp-nancyfx](generators/csharp-nancyfx.md)
|
* [csharp-nancyfx](generators/csharp-nancyfx)
|
||||||
- [erlang-server](generators/erlang-server.md)
|
* [erlang-server](generators/erlang-server)
|
||||||
- [fsharp-giraffe-server](generators/fsharp-giraffe-server.md)
|
* [fsharp-giraffe-server](generators/fsharp-giraffe-server)
|
||||||
- [go-gin-server](generators/go-gin-server.md)
|
* [go-gin-server](generators/go-gin-server)
|
||||||
- [go-server](generators/go-server.md)
|
* [go-server](generators/go-server)
|
||||||
- [graphql-nodejs-express-server](generators/graphql-nodejs-express-server.md)
|
* [graphql-nodejs-express-server](generators/graphql-nodejs-express-server)
|
||||||
- [haskell](generators/haskell.md)
|
* [haskell](generators/haskell)
|
||||||
- [java-inflector](generators/java-inflector.md)
|
* [java-inflector](generators/java-inflector)
|
||||||
- [java-msf4j](generators/java-msf4j.md)
|
* [java-msf4j](generators/java-msf4j)
|
||||||
- [java-pkmst](generators/java-pkmst.md)
|
* [java-pkmst](generators/java-pkmst)
|
||||||
- [java-play-framework](generators/java-play-framework.md)
|
* [java-play-framework](generators/java-play-framework)
|
||||||
- [java-undertow-server](generators/java-undertow-server.md)
|
* [java-undertow-server](generators/java-undertow-server)
|
||||||
- [java-vertx](generators/java-vertx.md)
|
* [java-vertx](generators/java-vertx)
|
||||||
- [jaxrs-cxf](generators/jaxrs-cxf.md)
|
* [jaxrs-cxf](generators/jaxrs-cxf)
|
||||||
- [jaxrs-cxf-cdi](generators/jaxrs-cxf-cdi.md)
|
* [jaxrs-cxf-cdi](generators/jaxrs-cxf-cdi)
|
||||||
- [jaxrs-cxf-extended](generators/jaxrs-cxf-extended.md)
|
* [jaxrs-cxf-extended](generators/jaxrs-cxf-extended)
|
||||||
- [jaxrs-jersey](generators/jaxrs-jersey.md)
|
* [jaxrs-jersey](generators/jaxrs-jersey)
|
||||||
- [jaxrs-resteasy](generators/jaxrs-resteasy.md)
|
* [jaxrs-resteasy](generators/jaxrs-resteasy)
|
||||||
- [jaxrs-resteasy-eap](generators/jaxrs-resteasy-eap.md)
|
* [jaxrs-resteasy-eap](generators/jaxrs-resteasy-eap)
|
||||||
- [jaxrs-spec](generators/jaxrs-spec.md)
|
* [jaxrs-spec](generators/jaxrs-spec)
|
||||||
- [kotlin-server](generators/kotlin-server.md)
|
* [kotlin-server](generators/kotlin-server)
|
||||||
- [kotlin-spring](generators/kotlin-spring.md)
|
* [kotlin-spring](generators/kotlin-spring)
|
||||||
- [nodejs-express-server](generators/nodejs-express-server.md) (beta)
|
* [nodejs-express-server (beta)](generators/nodejs-express-server)
|
||||||
- [nodejs-server-deprecated](generators/nodejs-server-deprecated.md) (deprecated)
|
* [nodejs-server-deprecated (deprecated)](generators/nodejs-server-deprecated)
|
||||||
- [php-laravel](generators/php-laravel.md)
|
* [php-laravel](generators/php-laravel)
|
||||||
- [php-lumen](generators/php-lumen.md)
|
* [php-lumen](generators/php-lumen)
|
||||||
- [php-silex](generators/php-silex.md)
|
* [php-silex](generators/php-silex)
|
||||||
- [php-slim](generators/php-slim.md)
|
* [php-slim](generators/php-slim)
|
||||||
- [php-symfony](generators/php-symfony.md)
|
* [php-symfony](generators/php-symfony)
|
||||||
- [php-ze-ph](generators/php-ze-ph.md)
|
* [php-ze-ph](generators/php-ze-ph)
|
||||||
- [python-aiohttp](generators/python-aiohttp.md)
|
* [python-aiohttp](generators/python-aiohttp)
|
||||||
- [python-blueplanet](generators/python-blueplanet.md)
|
* [python-blueplanet](generators/python-blueplanet)
|
||||||
- [python-flask](generators/python-flask.md)
|
* [python-flask](generators/python-flask)
|
||||||
- [ruby-on-rails](generators/ruby-on-rails.md)
|
* [ruby-on-rails](generators/ruby-on-rails)
|
||||||
- [ruby-sinatra](generators/ruby-sinatra.md)
|
* [ruby-sinatra](generators/ruby-sinatra)
|
||||||
- [rust-server](generators/rust-server.md)
|
* [rust-server](generators/rust-server)
|
||||||
- [scala-finch](generators/scala-finch.md)
|
* [scala-finch](generators/scala-finch)
|
||||||
- [scala-lagom-server](generators/scala-lagom-server.md)
|
* [scala-lagom-server](generators/scala-lagom-server)
|
||||||
- [scala-play-server](generators/scala-play-server.md)
|
* [scala-play-server](generators/scala-play-server)
|
||||||
- [scalatra](generators/scalatra.md)
|
* [scalatra](generators/scalatra)
|
||||||
- [spring](generators/spring.md)
|
* [spring](generators/spring)
|
||||||
|
|
||||||
|
|
||||||
* DOCUMENTATION generators:
|
## DOCUMENTATION generators
|
||||||
- [cwiki](generators/cwiki.md)
|
* [cwiki](generators/cwiki)
|
||||||
- [dynamic-html](generators/dynamic-html.md)
|
* [dynamic-html](generators/dynamic-html)
|
||||||
- [html](generators/html.md)
|
* [html](generators/html)
|
||||||
- [html2](generators/html2.md)
|
* [html2](generators/html2)
|
||||||
- [openapi](generators/openapi.md)
|
* [openapi](generators/openapi)
|
||||||
- [openapi-yaml](generators/openapi-yaml.md)
|
* [openapi-yaml](generators/openapi-yaml)
|
||||||
|
|
||||||
|
|
||||||
* SCHEMA generators:
|
## SCHEMA generators
|
||||||
- [mysql-schema](generators/mysql-schema.md)
|
* [mysql-schema](generators/mysql-schema)
|
||||||
|
|
||||||
|
|
||||||
* CONFIG generators:
|
## CONFIG generators
|
||||||
- [apache2](generators/apache2.md)
|
* [apache2](generators/apache2)
|
||||||
- [graphql-schema](generators/graphql-schema.md)
|
* [graphql-schema](generators/graphql-schema)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -11,12 +11,12 @@ sidebar_label: dart-jaguar
|
|||||||
|ensureUniqueParams|Whether to ensure parameter names are unique in an operation (rename parameters that are not).| |true|
|
|ensureUniqueParams|Whether to ensure parameter names are unique in an operation (rename parameters that are not).| |true|
|
||||||
|allowUnicodeIdentifiers|boolean, toggles whether unicode identifiers are allowed in names or not, default is false| |false|
|
|allowUnicodeIdentifiers|boolean, toggles whether unicode identifiers are allowed in names or not, default is false| |false|
|
||||||
|prependFormOrBodyParameters|Add form or body parameters to the beginning of the parameter list.| |false|
|
|prependFormOrBodyParameters|Add form or body parameters to the beginning of the parameter list.| |false|
|
||||||
|browserClient|Is the client browser based| |null|
|
|browserClient|Is the client browser based (for Dart 1.x only)| |null|
|
||||||
|pubName|Name in generated pubspec| |null|
|
|pubName|Name in generated pubspec| |null|
|
||||||
|pubVersion|Version in generated pubspec| |null|
|
|pubVersion|Version in generated pubspec| |null|
|
||||||
|pubDescription|Description in generated pubspec| |null|
|
|pubDescription|Description in generated pubspec| |null|
|
||||||
|useEnumExtension|Allow the 'x-enum-values' extension for enums| |null|
|
|useEnumExtension|Allow the 'x-enum-values' extension for enums| |null|
|
||||||
|sourceFolder|source folder for generated code| |null|
|
|sourceFolder|Source folder for generated code| |null|
|
||||||
|supportDart2|support dart2| |true|
|
|supportDart2|Support Dart 2.x| |true|
|
||||||
|nullableFields|Is the null fields should be in the JSON payload| |null|
|
|nullableFields|Is the null fields should be in the JSON payload| |null|
|
||||||
|serialization|Choose serialization format JSON or PROTO is supported| |null|
|
|serialization|Choose serialization format JSON or PROTO is supported| |null|
|
||||||
|
|||||||
@@ -11,10 +11,10 @@ sidebar_label: dart
|
|||||||
|ensureUniqueParams|Whether to ensure parameter names are unique in an operation (rename parameters that are not).| |true|
|
|ensureUniqueParams|Whether to ensure parameter names are unique in an operation (rename parameters that are not).| |true|
|
||||||
|allowUnicodeIdentifiers|boolean, toggles whether unicode identifiers are allowed in names or not, default is false| |false|
|
|allowUnicodeIdentifiers|boolean, toggles whether unicode identifiers are allowed in names or not, default is false| |false|
|
||||||
|prependFormOrBodyParameters|Add form or body parameters to the beginning of the parameter list.| |false|
|
|prependFormOrBodyParameters|Add form or body parameters to the beginning of the parameter list.| |false|
|
||||||
|browserClient|Is the client browser based| |null|
|
|browserClient|Is the client browser based (for Dart 1.x only)| |null|
|
||||||
|pubName|Name in generated pubspec| |null|
|
|pubName|Name in generated pubspec| |null|
|
||||||
|pubVersion|Version in generated pubspec| |null|
|
|pubVersion|Version in generated pubspec| |null|
|
||||||
|pubDescription|Description in generated pubspec| |null|
|
|pubDescription|Description in generated pubspec| |null|
|
||||||
|useEnumExtension|Allow the 'x-enum-values' extension for enums| |null|
|
|useEnumExtension|Allow the 'x-enum-values' extension for enums| |null|
|
||||||
|sourceFolder|source folder for generated code| |null|
|
|sourceFolder|Source folder for generated code| |null|
|
||||||
|supportDart2|support dart2| |true|
|
|supportDart2|Support Dart 2.x| |true|
|
||||||
|
|||||||
@@ -38,9 +38,15 @@ NAME
|
|||||||
openapi-generator-cli list - Lists the available generators
|
openapi-generator-cli list - Lists the available generators
|
||||||
|
|
||||||
SYNOPSIS
|
SYNOPSIS
|
||||||
openapi-generator-cli list [(-s | --short)]
|
openapi-generator-cli list [(-i <include> | --include <include>)]
|
||||||
|
[(-s | --short)]
|
||||||
|
|
||||||
OPTIONS
|
OPTIONS
|
||||||
|
-i <include>, --include <include>
|
||||||
|
comma-separated list of stability indexes to include (value:
|
||||||
|
all,beta,stable,experimental,deprecated). Excludes deprecated by
|
||||||
|
default.
|
||||||
|
|
||||||
-s, --short
|
-s, --short
|
||||||
shortened output (suitable for scripting)
|
shortened output (suitable for scripting)
|
||||||
|
|
||||||
@@ -210,13 +216,14 @@ This command takes one or more parameters representing the args list you would o
|
|||||||
|
|
||||||
```bash
|
```bash
|
||||||
openapi-generator completion config-help
|
openapi-generator completion config-help
|
||||||
--named-header
|
|
||||||
-o
|
-o
|
||||||
--output
|
--output
|
||||||
|
--named-header
|
||||||
-g
|
-g
|
||||||
--generator-name
|
--generator-name
|
||||||
-l
|
-f
|
||||||
--lang
|
--format
|
||||||
|
--markdown-header
|
||||||
```
|
```
|
||||||
|
|
||||||
An example bash completion script can be found in the repo at [scripts/openapi-generator-cli-completion.bash](https://github.com/OpenAPITools/openapi-generator/blob/master/scripts/openapi-generator-cli-completion.bash).
|
An example bash completion script can be found in the repo at [scripts/openapi-generator-cli-completion.bash](https://github.com/OpenAPITools/openapi-generator/blob/master/scripts/openapi-generator-cli-completion.bash).
|
||||||
@@ -235,7 +242,6 @@ NAME
|
|||||||
SYNOPSIS
|
SYNOPSIS
|
||||||
openapi-generator-cli generate
|
openapi-generator-cli generate
|
||||||
[(-a <authorization> | --auth <authorization>)]
|
[(-a <authorization> | --auth <authorization>)]
|
||||||
[--additional-properties <additional properties>...]
|
|
||||||
[--api-package <api package>] [--artifact-id <artifact id>]
|
[--api-package <api package>] [--artifact-id <artifact id>]
|
||||||
[--artifact-version <artifact version>]
|
[--artifact-version <artifact version>]
|
||||||
[(-c <configuration file> | --config <configuration file>)]
|
[(-c <configuration file> | --config <configuration file>)]
|
||||||
@@ -256,15 +262,15 @@ SYNOPSIS
|
|||||||
[--model-name-prefix <model name prefix>]
|
[--model-name-prefix <model name prefix>]
|
||||||
[--model-name-suffix <model name suffix>]
|
[--model-name-suffix <model name suffix>]
|
||||||
[--model-package <model package>]
|
[--model-package <model package>]
|
||||||
[(-o <output directory> | --output <output directory>)]
|
[(-o <output directory> | --output <output directory>)]
|
||||||
|
[(-p <additional properties> | --additional-properties <additional properties>)...]
|
||||||
[--package-name <package name>] [--release-note <release note>]
|
[--package-name <package name>] [--release-note <release note>]
|
||||||
[--remove-operation-id-prefix]
|
[--remove-operation-id-prefix]
|
||||||
[--reserved-words-mappings <reserved word mappings>...]
|
[--reserved-words-mappings <reserved word mappings>...]
|
||||||
[(-s | --skip-overwrite)] [--skip-validate-spec]
|
[(-s | --skip-overwrite)] [--server-variables <server variables>...]
|
||||||
[--strict-spec <true/false strict behavior>]
|
[--skip-validate-spec] [--strict-spec <true/false strict behavior>]
|
||||||
[(-t <template directory> | --template-dir <template directory>)]
|
[(-t <template directory> | --template-dir <template directory>)]
|
||||||
[--type-mappings <type mappings>...] [(-v | --verbose)]
|
[--type-mappings <type mappings>...] [(-v | --verbose)]
|
||||||
|
|
||||||
```
|
```
|
||||||
|
|
||||||
<details>
|
<details>
|
||||||
@@ -277,19 +283,16 @@ OPTIONS
|
|||||||
remotely. Pass in a URL-encoded string of name:header with a comma
|
remotely. Pass in a URL-encoded string of name:header with a comma
|
||||||
separating multiple values
|
separating multiple values
|
||||||
|
|
||||||
--additional-properties <additional properties>
|
|
||||||
sets additional properties that can be referenced by the mustache
|
|
||||||
templates in the format of name=value,name=value. You can also have
|
|
||||||
multiple occurrences of this option.
|
|
||||||
|
|
||||||
--api-package <api package>
|
--api-package <api package>
|
||||||
package for generated api classes
|
package for generated api classes
|
||||||
|
|
||||||
--artifact-id <artifact id>
|
--artifact-id <artifact id>
|
||||||
artifactId in generated pom.xml
|
artifactId in generated pom.xml. This also becomes part of the
|
||||||
|
generated library's filename
|
||||||
|
|
||||||
--artifact-version <artifact version>
|
--artifact-version <artifact version>
|
||||||
artifact version in generated pom.xml
|
artifact version in generated pom.xml. This also becomes part of the
|
||||||
|
generated library's filename
|
||||||
|
|
||||||
-c <configuration file>, --config <configuration file>
|
-c <configuration file>, --config <configuration file>
|
||||||
Path to configuration file configuration file. It can be json or
|
Path to configuration file configuration file. It can be json or
|
||||||
@@ -382,6 +385,12 @@ OPTIONS
|
|||||||
-o <output directory>, --output <output directory>
|
-o <output directory>, --output <output directory>
|
||||||
where to write the generated files (current dir by default)
|
where to write the generated files (current dir by default)
|
||||||
|
|
||||||
|
-p <additional properties>, --additional-properties <additional
|
||||||
|
properties>
|
||||||
|
sets additional properties that can be referenced by the mustache
|
||||||
|
templates in the format of name=value,name=value. You can also have
|
||||||
|
multiple occurrences of this option.
|
||||||
|
|
||||||
--package-name <package name>
|
--package-name <package name>
|
||||||
package for generated classes (where supported)
|
package for generated classes (where supported)
|
||||||
|
|
||||||
@@ -400,6 +409,10 @@ OPTIONS
|
|||||||
specifies if the existing files should be overwritten during the
|
specifies if the existing files should be overwritten during the
|
||||||
generation.
|
generation.
|
||||||
|
|
||||||
|
--server-variables <server variables>
|
||||||
|
sets server variables for spec documents which support variable
|
||||||
|
templating of servers.
|
||||||
|
|
||||||
--skip-validate-spec
|
--skip-validate-spec
|
||||||
Skips the default behavior of validating an input specification.
|
Skips the default behavior of validating an input specification.
|
||||||
|
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
<groupId>org.openapitools</groupId>
|
<groupId>org.openapitools</groupId>
|
||||||
<artifactId>openapi-generator-project</artifactId>
|
<artifactId>openapi-generator-project</artifactId>
|
||||||
<!-- RELEASE_VERSION -->
|
<!-- RELEASE_VERSION -->
|
||||||
<version>4.1.0</version>
|
<version>4.1.1-SNAPSHOT</version>
|
||||||
<!-- /RELEASE_VERSION -->
|
<!-- /RELEASE_VERSION -->
|
||||||
<relativePath>../..</relativePath>
|
<relativePath>../..</relativePath>
|
||||||
</parent>
|
</parent>
|
||||||
|
|||||||
@@ -18,13 +18,7 @@
|
|||||||
package org.openapitools.codegen.cmd;
|
package org.openapitools.codegen.cmd;
|
||||||
|
|
||||||
import static org.apache.commons.lang3.StringUtils.isNotEmpty;
|
import static org.apache.commons.lang3.StringUtils.isNotEmpty;
|
||||||
import static org.openapitools.codegen.config.CodegenConfiguratorUtils.applyAdditionalPropertiesKvpList;
|
import static org.openapitools.codegen.config.CodegenConfiguratorUtils.*;
|
||||||
import static org.openapitools.codegen.config.CodegenConfiguratorUtils.applyImportMappingsKvpList;
|
|
||||||
import static org.openapitools.codegen.config.CodegenConfiguratorUtils.applyInstantiationTypesKvpList;
|
|
||||||
import static org.openapitools.codegen.config.CodegenConfiguratorUtils.applyLanguageSpecificPrimitivesCsvList;
|
|
||||||
import static org.openapitools.codegen.config.CodegenConfiguratorUtils.applyReservedWordsMappingsKvpList;
|
|
||||||
import static org.openapitools.codegen.config.CodegenConfiguratorUtils.applySystemPropertiesKvpList;
|
|
||||||
import static org.openapitools.codegen.config.CodegenConfiguratorUtils.applyTypeMappingsKvpList;
|
|
||||||
|
|
||||||
import ch.qos.logback.classic.LoggerContext;
|
import ch.qos.logback.classic.LoggerContext;
|
||||||
import ch.qos.logback.core.spi.FilterAttachable;
|
import ch.qos.logback.core.spi.FilterAttachable;
|
||||||
@@ -160,6 +154,12 @@ public class Generate implements Runnable {
|
|||||||
+ " You can also have multiple occurrences of this option.")
|
+ " You can also have multiple occurrences of this option.")
|
||||||
private List<String> importMappings = new ArrayList<>();
|
private List<String> importMappings = new ArrayList<>();
|
||||||
|
|
||||||
|
@Option(
|
||||||
|
name = {"--server-variables"},
|
||||||
|
title = "server variables",
|
||||||
|
description = "sets server variables overrides for spec documents which support variable templating of servers.")
|
||||||
|
private List<String> serverVariableOverrides = new ArrayList<>();
|
||||||
|
|
||||||
@Option(name = {"--invoker-package"}, title = "invoker package",
|
@Option(name = {"--invoker-package"}, title = "invoker package",
|
||||||
description = CodegenConstants.INVOKER_PACKAGE_DESC)
|
description = CodegenConstants.INVOKER_PACKAGE_DESC)
|
||||||
private String invokerPackage;
|
private String invokerPackage;
|
||||||
@@ -393,6 +393,7 @@ public class Generate implements Runnable {
|
|||||||
applyAdditionalPropertiesKvpList(additionalProperties, configurator);
|
applyAdditionalPropertiesKvpList(additionalProperties, configurator);
|
||||||
applyLanguageSpecificPrimitivesCsvList(languageSpecificPrimitives, configurator);
|
applyLanguageSpecificPrimitivesCsvList(languageSpecificPrimitives, configurator);
|
||||||
applyReservedWordsMappingsKvpList(reservedWordsMappings, configurator);
|
applyReservedWordsMappingsKvpList(reservedWordsMappings, configurator);
|
||||||
|
applyServerVariablesKvpList(serverVariableOverrides, configurator);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
final ClientOptInput clientOptInput = configurator.toClientOptInput();
|
final ClientOptInput clientOptInput = configurator.toClientOptInput();
|
||||||
|
|||||||
@@ -5,15 +5,14 @@ import com.google.common.base.Objects;
|
|||||||
import io.airlift.airline.Command;
|
import io.airlift.airline.Command;
|
||||||
import io.airlift.airline.Option;
|
import io.airlift.airline.Option;
|
||||||
|
|
||||||
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.openapitools.codegen.CodegenConfig;
|
import org.openapitools.codegen.CodegenConfig;
|
||||||
import org.openapitools.codegen.CodegenConfigLoader;
|
import org.openapitools.codegen.CodegenConfigLoader;
|
||||||
import org.openapitools.codegen.CodegenType;
|
import org.openapitools.codegen.CodegenType;
|
||||||
import org.openapitools.codegen.meta.GeneratorMetadata;
|
import org.openapitools.codegen.meta.GeneratorMetadata;
|
||||||
import org.openapitools.codegen.meta.Stability;
|
import org.openapitools.codegen.meta.Stability;
|
||||||
|
|
||||||
import java.util.Comparator;
|
import java.util.*;
|
||||||
import java.util.List;
|
|
||||||
import java.util.Locale;
|
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
// NOTE: List can later have subcommands such as list languages, list types, list frameworks, etc.
|
// NOTE: List can later have subcommands such as list languages, list types, list frameworks, etc.
|
||||||
@@ -26,9 +25,31 @@ public class ListGenerators implements Runnable {
|
|||||||
@Option(name = {"-d", "--docsite" }, description = "format for docusaurus site output", hidden = true)
|
@Option(name = {"-d", "--docsite" }, description = "format for docusaurus site output", hidden = true)
|
||||||
private Boolean docusaurus = false;
|
private Boolean docusaurus = false;
|
||||||
|
|
||||||
|
@Option(name = {"-i", "--include" },
|
||||||
|
description = "comma-separated list of stability indexes to include (value: all,beta,stable,experimental,deprecated). Excludes deprecated by default.",
|
||||||
|
allowedValues = { "all", "beta", "stable", "experimental", "deprecated" })
|
||||||
|
private String include = "stable,beta,experimental";
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
List<CodegenConfig> generators = CodegenConfigLoader.getAll();
|
List<CodegenConfig> generators = new ArrayList<>();
|
||||||
|
List<Stability> stabilities = Arrays.asList(Stability.values());
|
||||||
|
|
||||||
|
if (!StringUtils.isEmpty(include)) {
|
||||||
|
List<String> includes = Arrays.asList(include.split(","));
|
||||||
|
if (includes.size() != 0 && !includes.contains("all")) {
|
||||||
|
stabilities = includes.stream()
|
||||||
|
.map(Stability::forDescription)
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for (CodegenConfig codegenConfig : CodegenConfigLoader.getAll()) {
|
||||||
|
GeneratorMetadata meta = codegenConfig.getGeneratorMetadata();
|
||||||
|
if (meta != null && stabilities.contains(meta.getStability())) {
|
||||||
|
generators.add(codegenConfig);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
StringBuilder sb = new StringBuilder();
|
StringBuilder sb = new StringBuilder();
|
||||||
|
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
<artifactId>openapi-generator-project</artifactId>
|
<artifactId>openapi-generator-project</artifactId>
|
||||||
<groupId>org.openapitools</groupId>
|
<groupId>org.openapitools</groupId>
|
||||||
<!-- RELEASE_VERSION -->
|
<!-- RELEASE_VERSION -->
|
||||||
<version>4.1.0</version>
|
<version>4.1.1-SNAPSHOT</version>
|
||||||
<!-- /RELEASE_VERSION -->
|
<!-- /RELEASE_VERSION -->
|
||||||
<relativePath>../..</relativePath>
|
<relativePath>../..</relativePath>
|
||||||
</parent>
|
</parent>
|
||||||
|
|||||||
@@ -52,6 +52,7 @@ public final class GeneratorSettings implements Serializable {
|
|||||||
private ImmutableMap<String, String> importMappings;
|
private ImmutableMap<String, String> importMappings;
|
||||||
private ImmutableSet<String> languageSpecificPrimitives;
|
private ImmutableSet<String> languageSpecificPrimitives;
|
||||||
private ImmutableMap<String, String> reservedWordMappings;
|
private ImmutableMap<String, String> reservedWordMappings;
|
||||||
|
private ImmutableMap<String, String> serverVariables;
|
||||||
|
|
||||||
private String gitUserId;
|
private String gitUserId;
|
||||||
private String gitRepoId;
|
private String gitRepoId;
|
||||||
@@ -245,6 +246,17 @@ public final class GeneratorSettings implements Serializable {
|
|||||||
return reservedWordMappings;
|
return reservedWordMappings;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets server variable. Values defined here will be attempted to be replaced within a templated server object.
|
||||||
|
*
|
||||||
|
* @return the server variables
|
||||||
|
*/
|
||||||
|
public Map<String, String> getServerVariables() {
|
||||||
|
return serverVariables;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets git user id. e.g. <strong>openapitools</strong>.
|
* Gets git user id. e.g. <strong>openapitools</strong>.
|
||||||
* <p>
|
* <p>
|
||||||
@@ -311,6 +323,7 @@ public final class GeneratorSettings implements Serializable {
|
|||||||
importMappings = ImmutableMap.copyOf(builder.importMappings);
|
importMappings = ImmutableMap.copyOf(builder.importMappings);
|
||||||
languageSpecificPrimitives = ImmutableSet.copyOf(builder.languageSpecificPrimitives);
|
languageSpecificPrimitives = ImmutableSet.copyOf(builder.languageSpecificPrimitives);
|
||||||
reservedWordMappings = ImmutableMap.copyOf(builder.reservedWordMappings);
|
reservedWordMappings = ImmutableMap.copyOf(builder.reservedWordMappings);
|
||||||
|
serverVariables = ImmutableMap.copyOf(builder.serverVariables);
|
||||||
gitUserId = builder.gitUserId;
|
gitUserId = builder.gitUserId;
|
||||||
gitRepoId = builder.gitRepoId;
|
gitRepoId = builder.gitRepoId;
|
||||||
releaseNote = builder.releaseNote;
|
releaseNote = builder.releaseNote;
|
||||||
@@ -373,6 +386,7 @@ public final class GeneratorSettings implements Serializable {
|
|||||||
importMappings = ImmutableMap.of();
|
importMappings = ImmutableMap.of();
|
||||||
languageSpecificPrimitives = ImmutableSet.of();
|
languageSpecificPrimitives = ImmutableSet.of();
|
||||||
reservedWordMappings = ImmutableMap.of();
|
reservedWordMappings = ImmutableMap.of();
|
||||||
|
serverVariables = ImmutableMap.of();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setDefaults() {
|
private void setDefaults() {
|
||||||
@@ -394,12 +408,6 @@ public final class GeneratorSettings implements Serializable {
|
|||||||
return new Builder();
|
return new Builder();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* New builder builder.
|
|
||||||
*
|
|
||||||
* @param copy the copy
|
|
||||||
* @return the builder
|
|
||||||
*/
|
|
||||||
public static Builder newBuilder(GeneratorSettings copy) {
|
public static Builder newBuilder(GeneratorSettings copy) {
|
||||||
Builder builder = new Builder();
|
Builder builder = new Builder();
|
||||||
builder.generatorName = copy.getGeneratorName();
|
builder.generatorName = copy.getGeneratorName();
|
||||||
@@ -419,6 +427,7 @@ public final class GeneratorSettings implements Serializable {
|
|||||||
builder.importMappings = new HashMap<>(copy.getImportMappings());
|
builder.importMappings = new HashMap<>(copy.getImportMappings());
|
||||||
builder.languageSpecificPrimitives = new HashSet<>(copy.getLanguageSpecificPrimitives());
|
builder.languageSpecificPrimitives = new HashSet<>(copy.getLanguageSpecificPrimitives());
|
||||||
builder.reservedWordMappings = new HashMap<>(copy.getReservedWordMappings());
|
builder.reservedWordMappings = new HashMap<>(copy.getReservedWordMappings());
|
||||||
|
builder.serverVariables = new HashMap<>(copy.getServerVariables());
|
||||||
builder.gitUserId = copy.getGitUserId();
|
builder.gitUserId = copy.getGitUserId();
|
||||||
builder.gitRepoId = copy.getGitRepoId();
|
builder.gitRepoId = copy.getGitRepoId();
|
||||||
builder.releaseNote = copy.getReleaseNote();
|
builder.releaseNote = copy.getReleaseNote();
|
||||||
@@ -449,6 +458,7 @@ public final class GeneratorSettings implements Serializable {
|
|||||||
private Map<String, String> importMappings;
|
private Map<String, String> importMappings;
|
||||||
private Set<String> languageSpecificPrimitives;
|
private Set<String> languageSpecificPrimitives;
|
||||||
private Map<String, String> reservedWordMappings;
|
private Map<String, String> reservedWordMappings;
|
||||||
|
private Map<String, String> serverVariables;
|
||||||
private String gitUserId;
|
private String gitUserId;
|
||||||
private String gitRepoId;
|
private String gitRepoId;
|
||||||
private String releaseNote;
|
private String releaseNote;
|
||||||
@@ -464,6 +474,7 @@ public final class GeneratorSettings implements Serializable {
|
|||||||
importMappings = new HashMap<>();
|
importMappings = new HashMap<>();
|
||||||
languageSpecificPrimitives = new HashSet<>();
|
languageSpecificPrimitives = new HashSet<>();
|
||||||
reservedWordMappings = new HashMap<>();
|
reservedWordMappings = new HashMap<>();
|
||||||
|
serverVariables = new HashMap<>();
|
||||||
|
|
||||||
gitUserId = DEFAULT_GIT_USER_ID;
|
gitUserId = DEFAULT_GIT_USER_ID;
|
||||||
gitRepoId = DEFAULT_GIT_REPO_ID;
|
gitRepoId = DEFAULT_GIT_REPO_ID;
|
||||||
@@ -617,6 +628,17 @@ public final class GeneratorSettings implements Serializable {
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the {@code serverVariables} and returns a reference to this Builder so that the methods can be chained together.
|
||||||
|
*
|
||||||
|
* @param serverVariables the {@code serverVariables} to set
|
||||||
|
* @return a reference to this Builder
|
||||||
|
*/
|
||||||
|
public Builder withServerVariables(Map<String, String> serverVariables) {
|
||||||
|
this.serverVariables = serverVariables;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the {@code typeMappings} and returns a reference to this Builder so that the methods can be chained together.
|
* Sets the {@code typeMappings} and returns a reference to this Builder so that the methods can be chained together.
|
||||||
*
|
*
|
||||||
@@ -731,6 +753,22 @@ public final class GeneratorSettings implements Serializable {
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets a single {@code serverVariables} and returns a reference to this Builder so that the methods can be chained together.
|
||||||
|
*
|
||||||
|
* @param key A key for some server variable
|
||||||
|
* @param value The value of some server variable to be replaced in a templated server object.
|
||||||
|
* @return a reference to this Builder
|
||||||
|
*/
|
||||||
|
public Builder withServerVariable(String key, String value) {
|
||||||
|
if (this.serverVariables == null) {
|
||||||
|
this.serverVariables = new HashMap<>();
|
||||||
|
}
|
||||||
|
this.serverVariables.put(key, value);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the {@code gitUserId} and returns a reference to this Builder so that the methods can be chained together.
|
* Sets the {@code gitUserId} and returns a reference to this Builder so that the methods can be chained together.
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -50,4 +50,14 @@ public enum Stability {
|
|||||||
* @return The descriptive value of this enum.
|
* @return The descriptive value of this enum.
|
||||||
*/
|
*/
|
||||||
public String value() { return description; }
|
public String value() { return description; }
|
||||||
|
|
||||||
|
public static Stability forDescription(String description) {
|
||||||
|
for (Stability value: values()) {
|
||||||
|
if (value.description.equals(description)) {
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
throw new IllegalArgumentException("description not found in the available values.");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -374,6 +374,18 @@ openApiGenerate {
|
|||||||
|
|
||||||
|===
|
|===
|
||||||
|
|
||||||
|
=== openApiGenerators
|
||||||
|
|
||||||
|
.Options
|
||||||
|
|===
|
||||||
|
|Key |Data Type |Default |Description
|
||||||
|
|
||||||
|
|include
|
||||||
|
|String[]
|
||||||
|
|None
|
||||||
|
|A list of stability indexes to include (values: all,beta,stable,experimental,deprecated). Excludes deprecated by default.
|
||||||
|
|
||||||
|
|===
|
||||||
|
|
||||||
== Examples
|
== Examples
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
buildscript {
|
buildscript {
|
||||||
ext.kotlin_version = '1.2.61'
|
ext.kotlin_version = '1.2.61'
|
||||||
repositories {
|
repositories {
|
||||||
|
mavenLocal()
|
||||||
mavenCentral()
|
mavenCentral()
|
||||||
maven {
|
maven {
|
||||||
url "https://plugins.gradle.org/m2/"
|
url "https://plugins.gradle.org/m2/"
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
# RELEASE_VERSION
|
# RELEASE_VERSION
|
||||||
openApiGeneratorVersion=4.1.0
|
openApiGeneratorVersion=4.1.1-SNAPSHOT
|
||||||
# /RELEASE_VERSION
|
# /RELEASE_VERSION
|
||||||
|
|
||||||
# BEGIN placeholders
|
# BEGIN placeholders
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
<groupId>org.openapitools</groupId>
|
<groupId>org.openapitools</groupId>
|
||||||
<artifactId>openapi-generator-project</artifactId>
|
<artifactId>openapi-generator-project</artifactId>
|
||||||
<!-- RELEASE_VERSION -->
|
<!-- RELEASE_VERSION -->
|
||||||
<version>4.1.0</version>
|
<version>4.1.1-SNAPSHOT</version>
|
||||||
<!-- /RELEASE_VERSION -->
|
<!-- /RELEASE_VERSION -->
|
||||||
<relativePath>../..</relativePath>
|
<relativePath>../..</relativePath>
|
||||||
</parent>
|
</parent>
|
||||||
|
|||||||
@@ -19,6 +19,7 @@ package org.openapitools.generator.gradle.plugin
|
|||||||
import org.gradle.api.Plugin
|
import org.gradle.api.Plugin
|
||||||
import org.gradle.api.Project
|
import org.gradle.api.Project
|
||||||
import org.openapitools.generator.gradle.plugin.extensions.OpenApiGeneratorGenerateExtension
|
import org.openapitools.generator.gradle.plugin.extensions.OpenApiGeneratorGenerateExtension
|
||||||
|
import org.openapitools.generator.gradle.plugin.extensions.OpenApiGeneratorGeneratorsExtension
|
||||||
import org.openapitools.generator.gradle.plugin.extensions.OpenApiGeneratorMetaExtension
|
import org.openapitools.generator.gradle.plugin.extensions.OpenApiGeneratorMetaExtension
|
||||||
import org.openapitools.generator.gradle.plugin.extensions.OpenApiGeneratorValidateExtension
|
import org.openapitools.generator.gradle.plugin.extensions.OpenApiGeneratorValidateExtension
|
||||||
import org.openapitools.generator.gradle.plugin.tasks.GenerateTask
|
import org.openapitools.generator.gradle.plugin.tasks.GenerateTask
|
||||||
@@ -53,12 +54,20 @@ class OpenApiGeneratorPlugin : Plugin<Project> {
|
|||||||
project
|
project
|
||||||
)
|
)
|
||||||
|
|
||||||
|
val generators = extensions.create(
|
||||||
|
"openApiGenerators",
|
||||||
|
OpenApiGeneratorGeneratorsExtension::class.java,
|
||||||
|
project
|
||||||
|
)
|
||||||
|
|
||||||
generate.outputDir.set("$buildDir/generate-resources/main")
|
generate.outputDir.set("$buildDir/generate-resources/main")
|
||||||
|
|
||||||
tasks.apply {
|
tasks.apply {
|
||||||
create("openApiGenerators", GeneratorsTask::class.java) {
|
create("openApiGenerators", GeneratorsTask::class.java) {
|
||||||
group = pluginGroup
|
group = pluginGroup
|
||||||
description = "Lists generators available via Open API Generators."
|
description = "Lists generators available via Open API Generators."
|
||||||
|
|
||||||
|
include.set(generators.include)
|
||||||
}
|
}
|
||||||
|
|
||||||
create("openApiMeta", MetaTask::class.java) {
|
create("openApiMeta", MetaTask::class.java) {
|
||||||
@@ -99,6 +108,7 @@ class OpenApiGeneratorPlugin : Plugin<Project> {
|
|||||||
instantiationTypes.set(generate.instantiationTypes)
|
instantiationTypes.set(generate.instantiationTypes)
|
||||||
typeMappings.set(generate.typeMappings)
|
typeMappings.set(generate.typeMappings)
|
||||||
additionalProperties.set(generate.additionalProperties)
|
additionalProperties.set(generate.additionalProperties)
|
||||||
|
serverVariables.set(generate.serverVariables)
|
||||||
languageSpecificPrimitives.set(generate.languageSpecificPrimitives)
|
languageSpecificPrimitives.set(generate.languageSpecificPrimitives)
|
||||||
importMappings.set(generate.importMappings)
|
importMappings.set(generate.importMappings)
|
||||||
invokerPackage.set(generate.invokerPackage)
|
invokerPackage.set(generate.invokerPackage)
|
||||||
|
|||||||
@@ -120,6 +120,11 @@ open class OpenApiGeneratorGenerateExtension(project: Project) {
|
|||||||
*/
|
*/
|
||||||
val additionalProperties = project.objects.property<Map<String, String>>()
|
val additionalProperties = project.objects.property<Map<String, String>>()
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets server variable for server URL template substitution, in the format of name=value,name=value.
|
||||||
|
*/
|
||||||
|
val serverVariables = project.objects.property<Map<String, String>>()
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Specifies additional language specific primitive types in the format of type1,type2,type3,type3. For example: String,boolean,Boolean,Double.
|
* Specifies additional language specific primitive types in the format of type1,type2,type3,type3. For example: String,boolean,Boolean,Double.
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -0,0 +1,43 @@
|
|||||||
|
/*
|
||||||
|
* 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.generator.gradle.plugin.extensions
|
||||||
|
|
||||||
|
import org.gradle.api.Project
|
||||||
|
import org.gradle.api.tasks.Internal
|
||||||
|
import org.gradle.kotlin.dsl.listProperty
|
||||||
|
import org.openapitools.codegen.meta.Stability
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gradle project level extension object definition for the generators task
|
||||||
|
*
|
||||||
|
* @author Jim Schubert
|
||||||
|
*/
|
||||||
|
open class OpenApiGeneratorGeneratorsExtension(project: Project) {
|
||||||
|
/**
|
||||||
|
* A list of stability indexes to include (value: all,beta,stable,experimental,deprecated). Excludes deprecated by default.
|
||||||
|
*/
|
||||||
|
val include = project.objects.listProperty<String>()
|
||||||
|
|
||||||
|
init {
|
||||||
|
applyDefaults()
|
||||||
|
}
|
||||||
|
|
||||||
|
@Suppress("MemberVisibilityCanBePrivate")
|
||||||
|
fun applyDefaults(){
|
||||||
|
include.set(Stability.values().map { s -> s.value() }.filterNot { it == Stability.DEPRECATED.value() })
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -155,6 +155,13 @@ open class GenerateTask : DefaultTask() {
|
|||||||
@get:Internal
|
@get:Internal
|
||||||
val additionalProperties = project.objects.property<Map<String, String>>()
|
val additionalProperties = project.objects.property<Map<String, String>>()
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets server variable for server URL template substitution, in the format of name=value,name=value.
|
||||||
|
* You can also have multiple occurrences of this option.
|
||||||
|
*/
|
||||||
|
@get:Internal
|
||||||
|
val serverVariables = project.objects.property<Map<String, String>>()
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Specifies additional language specific primitive types in the format of type1,type2,type3,type3. For example: String,boolean,Boolean,Double.
|
* Specifies additional language specific primitive types in the format of type1,type2,type3,type3. For example: String,boolean,Boolean,Double.
|
||||||
*/
|
*/
|
||||||
@@ -573,6 +580,12 @@ open class GenerateTask : DefaultTask() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (serverVariables.isPresent) {
|
||||||
|
serverVariables.get().forEach { entry ->
|
||||||
|
configurator.addServerVariable(entry.key, entry.value)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (languageSpecificPrimitives.isPresent) {
|
if (languageSpecificPrimitives.isPresent) {
|
||||||
languageSpecificPrimitives.get().forEach {
|
languageSpecificPrimitives.get().forEach {
|
||||||
configurator.addLanguageSpecificPrimitive(it)
|
configurator.addLanguageSpecificPrimitive(it)
|
||||||
|
|||||||
@@ -17,9 +17,11 @@
|
|||||||
package org.openapitools.generator.gradle.plugin.tasks
|
package org.openapitools.generator.gradle.plugin.tasks
|
||||||
|
|
||||||
import org.gradle.api.DefaultTask
|
import org.gradle.api.DefaultTask
|
||||||
|
import org.gradle.api.tasks.Internal
|
||||||
import org.gradle.api.tasks.TaskAction
|
import org.gradle.api.tasks.TaskAction
|
||||||
import org.gradle.internal.logging.text.StyledTextOutput
|
import org.gradle.internal.logging.text.StyledTextOutput
|
||||||
import org.gradle.internal.logging.text.StyledTextOutputFactory
|
import org.gradle.internal.logging.text.StyledTextOutputFactory
|
||||||
|
import org.gradle.kotlin.dsl.listProperty
|
||||||
import org.openapitools.codegen.CodegenConfigLoader
|
import org.openapitools.codegen.CodegenConfigLoader
|
||||||
import org.openapitools.codegen.CodegenType
|
import org.openapitools.codegen.CodegenType
|
||||||
import org.openapitools.codegen.meta.GeneratorMetadata
|
import org.openapitools.codegen.meta.GeneratorMetadata
|
||||||
@@ -35,6 +37,12 @@ import org.openapitools.codegen.meta.Stability
|
|||||||
* @author Jim Schubert
|
* @author Jim Schubert
|
||||||
*/
|
*/
|
||||||
open class GeneratorsTask : DefaultTask() {
|
open class GeneratorsTask : DefaultTask() {
|
||||||
|
/**
|
||||||
|
* A list of stability indexes to include (value: all,beta,stable,experimental,deprecated). Excludes deprecated by default.
|
||||||
|
*/
|
||||||
|
@get:Internal
|
||||||
|
val include = project.objects.listProperty<String>()
|
||||||
|
|
||||||
@Suppress("unused")
|
@Suppress("unused")
|
||||||
@TaskAction
|
@TaskAction
|
||||||
fun doWork() {
|
fun doWork() {
|
||||||
@@ -45,6 +53,15 @@ open class GeneratorsTask : DefaultTask() {
|
|||||||
StringBuilder().apply {
|
StringBuilder().apply {
|
||||||
val types = CodegenType.values()
|
val types = CodegenType.values()
|
||||||
|
|
||||||
|
val stabilities = if (include.isPresent) {
|
||||||
|
when {
|
||||||
|
include.get().contains("all") -> Stability.values().toList()
|
||||||
|
else -> include.get().map { Stability.forDescription(it) }
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
Stability.values().filterNot { it == Stability.DEPRECATED }
|
||||||
|
}
|
||||||
|
|
||||||
append("The following generators are available:")
|
append("The following generators are available:")
|
||||||
|
|
||||||
append(System.lineSeparator())
|
append(System.lineSeparator())
|
||||||
@@ -56,21 +73,23 @@ open class GeneratorsTask : DefaultTask() {
|
|||||||
|
|
||||||
generators.filter { it.tag == type }
|
generators.filter { it.tag == type }
|
||||||
.sortedBy { it.name }
|
.sortedBy { it.name }
|
||||||
.forEach({ generator ->
|
.forEach { generator ->
|
||||||
|
|
||||||
val meta: GeneratorMetadata? = generator.generatorMetadata
|
val meta: GeneratorMetadata? = generator.generatorMetadata
|
||||||
|
val include = stabilities.contains(meta?.stability)
|
||||||
|
if (include) {
|
||||||
|
append(" - ")
|
||||||
|
append(generator.name)
|
||||||
|
|
||||||
append(" - ")
|
meta?.stability?.let {
|
||||||
append(generator.name)
|
if (it != Stability.STABLE) {
|
||||||
|
append(" (${it.value()})")
|
||||||
meta?.stability?.let {
|
}
|
||||||
if (it != Stability.STABLE) {
|
|
||||||
append(" (${it.value()})")
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
append(System.lineSeparator())
|
append(System.lineSeparator())
|
||||||
})
|
}
|
||||||
|
}
|
||||||
|
|
||||||
append(System.lineSeparator())
|
append(System.lineSeparator())
|
||||||
append(System.lineSeparator())
|
append(System.lineSeparator())
|
||||||
|
|||||||
@@ -13,7 +13,7 @@
|
|||||||
<groupId>org.openapitools</groupId>
|
<groupId>org.openapitools</groupId>
|
||||||
<artifactId>openapi-generator-maven-plugin</artifactId>
|
<artifactId>openapi-generator-maven-plugin</artifactId>
|
||||||
<!-- RELEASE_VERSION -->
|
<!-- RELEASE_VERSION -->
|
||||||
<version>4.1.0</version>
|
<version>4.1.1-SNAPSHOT</version>
|
||||||
<!-- /RELEASE_VERSION -->
|
<!-- /RELEASE_VERSION -->
|
||||||
<executions>
|
<executions>
|
||||||
<execution>
|
<execution>
|
||||||
@@ -120,7 +120,12 @@
|
|||||||
<groupId>com.fasterxml.jackson.jaxrs</groupId>
|
<groupId>com.fasterxml.jackson.jaxrs</groupId>
|
||||||
<artifactId>jackson-jaxrs-json-provider</artifactId>
|
<artifactId>jackson-jaxrs-json-provider</artifactId>
|
||||||
<version>${jackson-version}</version>
|
<version>${jackson-version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.openapitools</groupId>
|
||||||
|
<artifactId>jackson-databind-nullable</artifactId>
|
||||||
|
<version>${jackson-databind-nullable-version}</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
<!-- Joda time: if you use it -->
|
<!-- Joda time: if you use it -->
|
||||||
<dependency>
|
<dependency>
|
||||||
@@ -146,6 +151,7 @@
|
|||||||
<swagger-annotations-version>1.5.8</swagger-annotations-version>
|
<swagger-annotations-version>1.5.8</swagger-annotations-version>
|
||||||
<jersey-version>2.27</jersey-version>
|
<jersey-version>2.27</jersey-version>
|
||||||
<jackson-version>2.8.9</jackson-version>
|
<jackson-version>2.8.9</jackson-version>
|
||||||
|
<jackson-databind-nullable-version>0.2.0</jackson-databind-nullable-version>
|
||||||
<jodatime-version>2.7</jodatime-version>
|
<jodatime-version>2.7</jodatime-version>
|
||||||
<maven-plugin-version>1.0.0</maven-plugin-version>
|
<maven-plugin-version>1.0.0</maven-plugin-version>
|
||||||
<junit-version>4.8.1</junit-version>
|
<junit-version>4.8.1</junit-version>
|
||||||
|
|||||||
@@ -19,7 +19,7 @@
|
|||||||
<groupId>org.openapitools</groupId>
|
<groupId>org.openapitools</groupId>
|
||||||
<artifactId>openapi-generator-maven-plugin</artifactId>
|
<artifactId>openapi-generator-maven-plugin</artifactId>
|
||||||
<!-- RELEASE_VERSION -->
|
<!-- RELEASE_VERSION -->
|
||||||
<version>4.1.0</version>
|
<version>4.1.1-SNAPSHOT</version>
|
||||||
<!-- /RELEASE_VERSION -->
|
<!-- /RELEASE_VERSION -->
|
||||||
<dependencies>
|
<dependencies>
|
||||||
<dependency>
|
<dependency>
|
||||||
@@ -133,7 +133,12 @@
|
|||||||
<groupId>com.fasterxml.jackson.jaxrs</groupId>
|
<groupId>com.fasterxml.jackson.jaxrs</groupId>
|
||||||
<artifactId>jackson-jaxrs-json-provider</artifactId>
|
<artifactId>jackson-jaxrs-json-provider</artifactId>
|
||||||
<version>${jackson-version}</version>
|
<version>${jackson-version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.openapitools</groupId>
|
||||||
|
<artifactId>jackson-databind-nullable</artifactId>
|
||||||
|
<version>${jackson-databind-nullable-version}</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
<!-- Joda time: if you use it -->
|
<!-- Joda time: if you use it -->
|
||||||
<dependency>
|
<dependency>
|
||||||
|
|||||||
@@ -16,6 +16,7 @@
|
|||||||
<swagger-annotations-version>1.5.8</swagger-annotations-version>
|
<swagger-annotations-version>1.5.8</swagger-annotations-version>
|
||||||
<jersey-version>2.27</jersey-version>
|
<jersey-version>2.27</jersey-version>
|
||||||
<jackson-version>2.8.9</jackson-version>
|
<jackson-version>2.8.9</jackson-version>
|
||||||
|
<jackson-databind-nullable-version>0.2.0</jackson-databind-nullable-version>
|
||||||
<jodatime-version>2.7</jodatime-version>
|
<jodatime-version>2.7</jodatime-version>
|
||||||
<maven-plugin-version>1.0.0</maven-plugin-version>
|
<maven-plugin-version>1.0.0</maven-plugin-version>
|
||||||
<junit-version>4.8.1</junit-version>
|
<junit-version>4.8.1</junit-version>
|
||||||
|
|||||||
@@ -5,7 +5,7 @@
|
|||||||
<groupId>org.openapitools</groupId>
|
<groupId>org.openapitools</groupId>
|
||||||
<artifactId>openapi-generator-project</artifactId>
|
<artifactId>openapi-generator-project</artifactId>
|
||||||
<!-- RELEASE_VERSION -->
|
<!-- RELEASE_VERSION -->
|
||||||
<version>4.1.0</version>
|
<version>4.1.1-SNAPSHOT</version>
|
||||||
<!-- /RELEASE_VERSION -->
|
<!-- /RELEASE_VERSION -->
|
||||||
<relativePath>../..</relativePath>
|
<relativePath>../..</relativePath>
|
||||||
</parent>
|
</parent>
|
||||||
|
|||||||
@@ -17,19 +17,8 @@
|
|||||||
|
|
||||||
package org.openapitools.codegen.plugin;
|
package org.openapitools.codegen.plugin;
|
||||||
|
|
||||||
import static org.openapitools.codegen.config.CodegenConfiguratorUtils.applyAdditionalPropertiesKvp;
|
|
||||||
import static org.openapitools.codegen.config.CodegenConfiguratorUtils.applyImportMappingsKvp;
|
|
||||||
import static org.openapitools.codegen.config.CodegenConfiguratorUtils.applyInstantiationTypesKvp;
|
|
||||||
import static org.openapitools.codegen.config.CodegenConfiguratorUtils.applyLanguageSpecificPrimitivesCsv;
|
|
||||||
import static org.openapitools.codegen.config.CodegenConfiguratorUtils.applyTypeMappingsKvp;
|
|
||||||
import static org.openapitools.codegen.config.CodegenConfiguratorUtils.applyReservedWordsMappingsKvp;
|
|
||||||
import static org.openapitools.codegen.config.CodegenConfiguratorUtils.applyAdditionalPropertiesKvpList;
|
|
||||||
import static org.openapitools.codegen.config.CodegenConfiguratorUtils.applyImportMappingsKvpList;
|
|
||||||
import static org.openapitools.codegen.config.CodegenConfiguratorUtils.applyInstantiationTypesKvpList;
|
|
||||||
import static org.openapitools.codegen.config.CodegenConfiguratorUtils.applyLanguageSpecificPrimitivesCsvList;
|
|
||||||
import static org.openapitools.codegen.config.CodegenConfiguratorUtils.applyTypeMappingsKvpList;
|
|
||||||
import static org.openapitools.codegen.config.CodegenConfiguratorUtils.applyReservedWordsMappingsKvpList;
|
|
||||||
import static org.apache.commons.lang3.StringUtils.isNotEmpty;
|
import static org.apache.commons.lang3.StringUtils.isNotEmpty;
|
||||||
|
import static org.openapitools.codegen.config.CodegenConfiguratorUtils.*;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
@@ -289,6 +278,12 @@ public class CodeGenMojo extends AbstractMojo {
|
|||||||
@Parameter(name = "additionalProperties", property = "openapi.generator.maven.plugin.additionalProperties")
|
@Parameter(name = "additionalProperties", property = "openapi.generator.maven.plugin.additionalProperties")
|
||||||
private List<String> additionalProperties;
|
private List<String> additionalProperties;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A map of server variable overrides for specs that support server URL templating
|
||||||
|
*/
|
||||||
|
@Parameter(name = "serverVariableOverrides", property = "openapi.generator.maven.plugin.serverVariableOverrides")
|
||||||
|
private List<String> serverVariableOverrides;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A map of reserved names and how they should be escaped
|
* A map of reserved names and how they should be escaped
|
||||||
*/
|
*/
|
||||||
@@ -615,6 +610,10 @@ public class CodeGenMojo extends AbstractMojo {
|
|||||||
configurator);
|
configurator);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (serverVariableOverrides == null && configOptions.containsKey("server-variables")) {
|
||||||
|
applyServerVariablesKvp(configOptions.get("server-variables").toString(), configurator);
|
||||||
|
}
|
||||||
|
|
||||||
// Retained for backwards-compataibility with configOptions -> reserved-words-mappings
|
// Retained for backwards-compataibility with configOptions -> reserved-words-mappings
|
||||||
if (reservedWordsMappings == null && configOptions.containsKey("reserved-words-mappings")) {
|
if (reservedWordsMappings == null && configOptions.containsKey("reserved-words-mappings")) {
|
||||||
applyReservedWordsMappingsKvp(configOptions.get("reserved-words-mappings")
|
applyReservedWordsMappingsKvp(configOptions.get("reserved-words-mappings")
|
||||||
@@ -648,6 +647,10 @@ public class CodeGenMojo extends AbstractMojo {
|
|||||||
applyAdditionalPropertiesKvpList(additionalProperties, configurator);
|
applyAdditionalPropertiesKvpList(additionalProperties, configurator);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (serverVariableOverrides != null && (configOptions == null || !configOptions.containsKey("server-variables"))) {
|
||||||
|
applyServerVariablesKvpList(serverVariableOverrides, configurator);
|
||||||
|
}
|
||||||
|
|
||||||
// Apply Reserved Words Mappings
|
// Apply Reserved Words Mappings
|
||||||
if (reservedWordsMappings != null && (configOptions == null || !configOptions.containsKey("reserved-words-mappings"))) {
|
if (reservedWordsMappings != null && (configOptions == null || !configOptions.containsKey("reserved-words-mappings"))) {
|
||||||
applyReservedWordsMappingsKvpList(reservedWordsMappings, configurator);
|
applyReservedWordsMappingsKvpList(reservedWordsMappings, configurator);
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
<groupId>org.openapitools</groupId>
|
<groupId>org.openapitools</groupId>
|
||||||
<artifactId>openapi-generator-project</artifactId>
|
<artifactId>openapi-generator-project</artifactId>
|
||||||
<!-- RELEASE_VERSION -->
|
<!-- RELEASE_VERSION -->
|
||||||
<version>4.1.0</version>
|
<version>4.1.1-SNAPSHOT</version>
|
||||||
<!-- /RELEASE_VERSION -->
|
<!-- /RELEASE_VERSION -->
|
||||||
<relativePath>../..</relativePath>
|
<relativePath>../..</relativePath>
|
||||||
</parent>
|
</parent>
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
<groupId>org.openapitools</groupId>
|
<groupId>org.openapitools</groupId>
|
||||||
<artifactId>openapi-generator-project</artifactId>
|
<artifactId>openapi-generator-project</artifactId>
|
||||||
<!-- RELEASE_VERSION -->
|
<!-- RELEASE_VERSION -->
|
||||||
<version>4.1.0</version>
|
<version>4.1.1-SNAPSHOT</version>
|
||||||
<!-- /RELEASE_VERSION -->
|
<!-- /RELEASE_VERSION -->
|
||||||
<relativePath>../..</relativePath>
|
<relativePath>../..</relativePath>
|
||||||
</parent>
|
</parent>
|
||||||
|
|||||||
@@ -43,6 +43,8 @@ public interface CodegenConfig {
|
|||||||
|
|
||||||
Map<String, Object> additionalProperties();
|
Map<String, Object> additionalProperties();
|
||||||
|
|
||||||
|
Map<String, String> serverVariableOverrides();
|
||||||
|
|
||||||
Map<String, Object> vendorExtensions();
|
Map<String, Object> vendorExtensions();
|
||||||
|
|
||||||
String testPackage();
|
String testPackage();
|
||||||
|
|||||||
@@ -7,4 +7,5 @@ public class CodegenServerVariable {
|
|||||||
public String defaultValue;
|
public String defaultValue;
|
||||||
public String description;
|
public String description;
|
||||||
public List<String> enumValues;
|
public List<String> enumValues;
|
||||||
|
public String value;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -97,6 +97,7 @@ public class DefaultCodegen implements CodegenConfig {
|
|||||||
protected String embeddedTemplateDir;
|
protected String embeddedTemplateDir;
|
||||||
protected String commonTemplateDir = "_common";
|
protected String commonTemplateDir = "_common";
|
||||||
protected Map<String, Object> additionalProperties = new HashMap<String, Object>();
|
protected Map<String, Object> additionalProperties = new HashMap<String, Object>();
|
||||||
|
protected Map<String, String> serverVariables = new HashMap<String, String>();
|
||||||
protected Map<String, Object> vendorExtensions = new HashMap<String, Object>();
|
protected Map<String, Object> vendorExtensions = new HashMap<String, Object>();
|
||||||
protected List<SupportingFile> supportingFiles = new ArrayList<SupportingFile>();
|
protected List<SupportingFile> supportingFiles = new ArrayList<SupportingFile>();
|
||||||
protected List<CliOption> cliOptions = new ArrayList<CliOption>();
|
protected List<CliOption> cliOptions = new ArrayList<CliOption>();
|
||||||
@@ -240,13 +241,10 @@ public class DefaultCodegen implements CodegenConfig {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (additionalProperties.containsKey("lambda")) {
|
if (additionalProperties.containsKey("lambda")) {
|
||||||
LOGGER.warn("A property named 'lambda' already exists. Mustache lambdas renamed from 'lambda' to '_lambda'. " +
|
LOGGER.error("A property called 'lambda' already exists in additionalProperties");
|
||||||
"You'll likely need to use a custom template, " +
|
throw new RuntimeException("A property called 'lambda' already exists in additionalProperties");
|
||||||
"see https://github.com/OpenAPITools/openapi-generator/blob/master/docs/templating.md. ");
|
|
||||||
additionalProperties.put("_lambda", lambdas);
|
|
||||||
} else {
|
|
||||||
additionalProperties.put("lambda", lambdas);
|
|
||||||
}
|
}
|
||||||
|
additionalProperties.put("lambda", lambdas);
|
||||||
}
|
}
|
||||||
|
|
||||||
// override with any special post-processing for all models
|
// override with any special post-processing for all models
|
||||||
@@ -506,12 +504,12 @@ public class DefaultCodegen implements CodegenConfig {
|
|||||||
public void postProcessParameter(CodegenParameter parameter) {
|
public void postProcessParameter(CodegenParameter parameter) {
|
||||||
}
|
}
|
||||||
|
|
||||||
//override with any special handling of the entire swagger spec
|
//override with any special handling of the entire OpenAPI spec document
|
||||||
@SuppressWarnings("unused")
|
@SuppressWarnings("unused")
|
||||||
public void preprocessOpenAPI(OpenAPI openAPI) {
|
public void preprocessOpenAPI(OpenAPI openAPI) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// override with any special handling of the entire swagger spec
|
// override with any special handling of the entire OpenAPI spec document
|
||||||
@SuppressWarnings("unused")
|
@SuppressWarnings("unused")
|
||||||
public void processOpenAPI(OpenAPI openAPI) {
|
public void processOpenAPI(OpenAPI openAPI) {
|
||||||
}
|
}
|
||||||
@@ -725,6 +723,10 @@ public class DefaultCodegen implements CodegenConfig {
|
|||||||
return additionalProperties;
|
return additionalProperties;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Map<String, String> serverVariableOverrides() {
|
||||||
|
return serverVariables;
|
||||||
|
}
|
||||||
|
|
||||||
public Map<String, Object> vendorExtensions() {
|
public Map<String, Object> vendorExtensions() {
|
||||||
return vendorExtensions;
|
return vendorExtensions;
|
||||||
}
|
}
|
||||||
@@ -1825,6 +1827,7 @@ public class DefaultCodegen implements CodegenConfig {
|
|||||||
} else {
|
} else {
|
||||||
// composition
|
// composition
|
||||||
addProperties(properties, required, refSchema);
|
addProperties(properties, required, refSchema);
|
||||||
|
addProperties(allProperties, allRequired, refSchema);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -4881,41 +4884,54 @@ public class DefaultCodegen implements CodegenConfig {
|
|||||||
imports.add(codegenParameter.baseType);
|
imports.add(codegenParameter.baseType);
|
||||||
} else {
|
} else {
|
||||||
CodegenProperty codegenProperty = fromProperty("property", schema);
|
CodegenProperty codegenProperty = fromProperty("property", schema);
|
||||||
if (ModelUtils.getAdditionalProperties(schema) != null) {// http body is map
|
|
||||||
LOGGER.error("Map should be supported. Please report to openapi-generator github repo about the issue.");
|
|
||||||
} else if (codegenProperty != null) {
|
|
||||||
String codegenModelName, codegenModelDescription;
|
|
||||||
|
|
||||||
if (codegenModel != null) {
|
|
||||||
codegenModelName = codegenModel.classname;
|
|
||||||
codegenModelDescription = codegenModel.description;
|
|
||||||
} else {
|
|
||||||
LOGGER.warn("The following schema has undefined (null) baseType. " +
|
|
||||||
"It could be due to form parameter defined in OpenAPI v2 spec with incorrect consumes. " +
|
|
||||||
"A correct 'consumes' for form parameters should be " +
|
|
||||||
"'application/x-www-form-urlencoded' or 'multipart/form-data'");
|
|
||||||
LOGGER.warn("schema: " + schema);
|
|
||||||
LOGGER.warn("codegenModel is null. Default to UNKNOWN_BASE_TYPE");
|
|
||||||
codegenModelName = "UNKNOWN_BASE_TYPE";
|
|
||||||
codegenModelDescription = "UNKNOWN_DESCRIPTION";
|
|
||||||
}
|
|
||||||
|
|
||||||
if (StringUtils.isEmpty(bodyParameterName)) {
|
|
||||||
codegenParameter.baseName = codegenModelName;
|
|
||||||
} else {
|
|
||||||
codegenParameter.baseName = bodyParameterName;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
if (codegenProperty != null && codegenProperty.getComplexType() != null && codegenProperty.getComplexType().contains(" | ")) {
|
||||||
|
List<String> parts = Arrays.asList(codegenProperty.getComplexType().split(" \\| "));
|
||||||
|
imports.addAll(parts);
|
||||||
|
String codegenModelName = codegenProperty.getComplexType();
|
||||||
|
codegenParameter.baseName = codegenModelName;
|
||||||
codegenParameter.paramName = toParamName(codegenParameter.baseName);
|
codegenParameter.paramName = toParamName(codegenParameter.baseName);
|
||||||
codegenParameter.baseType = codegenModelName;
|
codegenParameter.baseType = codegenParameter.baseName;
|
||||||
codegenParameter.dataType = getTypeDeclaration(codegenModelName);
|
codegenParameter.dataType = getTypeDeclaration(codegenModelName);
|
||||||
codegenParameter.description = codegenModelDescription;
|
codegenParameter.description = codegenProperty.getDescription();
|
||||||
imports.add(codegenParameter.baseType);
|
} else {
|
||||||
|
if (ModelUtils.getAdditionalProperties(schema) != null) {// http body is map
|
||||||
|
LOGGER.error("Map should be supported. Please report to openapi-generator github repo about the issue.");
|
||||||
|
} else if (codegenProperty != null) {
|
||||||
|
String codegenModelName, codegenModelDescription;
|
||||||
|
|
||||||
if (codegenProperty.complexType != null) {
|
if (codegenModel != null) {
|
||||||
imports.add(codegenProperty.complexType);
|
codegenModelName = codegenModel.classname;
|
||||||
|
codegenModelDescription = codegenModel.description;
|
||||||
|
} else {
|
||||||
|
LOGGER.warn("The following schema has undefined (null) baseType. " +
|
||||||
|
"It could be due to form parameter defined in OpenAPI v2 spec with incorrect consumes. " +
|
||||||
|
"A correct 'consumes' for form parameters should be " +
|
||||||
|
"'application/x-www-form-urlencoded' or 'multipart/form-data'");
|
||||||
|
LOGGER.warn("schema: " + schema);
|
||||||
|
LOGGER.warn("codegenModel is null. Default to UNKNOWN_BASE_TYPE");
|
||||||
|
codegenModelName = "UNKNOWN_BASE_TYPE";
|
||||||
|
codegenModelDescription = "UNKNOWN_DESCRIPTION";
|
||||||
|
}
|
||||||
|
|
||||||
|
if (StringUtils.isEmpty(bodyParameterName)) {
|
||||||
|
codegenParameter.baseName = codegenModelName;
|
||||||
|
} else {
|
||||||
|
codegenParameter.baseName = bodyParameterName;
|
||||||
|
}
|
||||||
|
|
||||||
|
codegenParameter.paramName = toParamName(codegenParameter.baseName);
|
||||||
|
codegenParameter.baseType = codegenModelName;
|
||||||
|
codegenParameter.dataType = getTypeDeclaration(codegenModelName);
|
||||||
|
codegenParameter.description = codegenModelDescription;
|
||||||
|
imports.add(codegenParameter.baseType);
|
||||||
|
|
||||||
|
if (codegenProperty.complexType != null) {
|
||||||
|
imports.add(codegenProperty.complexType);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
setParameterBooleanFlagWithCodegenProperty(codegenParameter, codegenProperty);
|
setParameterBooleanFlagWithCodegenProperty(codegenParameter, codegenProperty);
|
||||||
// set nullable
|
// set nullable
|
||||||
setParameterNullable(codegenParameter, codegenProperty);
|
setParameterNullable(codegenParameter, codegenProperty);
|
||||||
@@ -5056,14 +5072,34 @@ public class DefaultCodegen implements CodegenConfig {
|
|||||||
if (variables == null) {
|
if (variables == null) {
|
||||||
return Collections.emptyList();
|
return Collections.emptyList();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Map<String, String> variableOverrides = serverVariableOverrides();
|
||||||
|
|
||||||
List<CodegenServerVariable> codegenServerVariables = new LinkedList<>();
|
List<CodegenServerVariable> codegenServerVariables = new LinkedList<>();
|
||||||
for (Entry<String, ServerVariable> variableEntry : variables.entrySet()) {
|
for (Entry<String, ServerVariable> variableEntry : variables.entrySet()) {
|
||||||
CodegenServerVariable codegenServerVariable = new CodegenServerVariable();
|
CodegenServerVariable codegenServerVariable = new CodegenServerVariable();
|
||||||
ServerVariable variable = variableEntry.getValue();
|
ServerVariable variable = variableEntry.getValue();
|
||||||
|
List<String> enums = variable.getEnum();
|
||||||
|
|
||||||
codegenServerVariable.defaultValue = variable.getDefault();
|
codegenServerVariable.defaultValue = variable.getDefault();
|
||||||
codegenServerVariable.description = escapeText(variable.getDescription());
|
codegenServerVariable.description = escapeText(variable.getDescription());
|
||||||
codegenServerVariable.enumValues = variable.getEnum();
|
codegenServerVariable.enumValues = enums;
|
||||||
codegenServerVariable.name = variableEntry.getKey();
|
codegenServerVariable.name = variableEntry.getKey();
|
||||||
|
|
||||||
|
// Sets the override value for a server variable pattern.
|
||||||
|
// NOTE: OpenAPI Specification doesn't prevent multiple server URLs with variables. If multiple objects have the same
|
||||||
|
// variables pattern, user overrides will apply to _all_ of these patterns. We may want to consider indexed overrides.
|
||||||
|
if (variableOverrides != null && !variableOverrides.isEmpty()) {
|
||||||
|
String value = variableOverrides.getOrDefault(variableEntry.getKey(), variable.getDefault());
|
||||||
|
codegenServerVariable.value = value;
|
||||||
|
|
||||||
|
if (enums != null && !enums.isEmpty() && !enums.contains(value)) {
|
||||||
|
LOGGER.warn("Variable override of '{}' is not listed in the enum of allowed values ({}).", value, StringUtils.join(enums, ","));
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
codegenServerVariable.value = variable.getDefault();
|
||||||
|
}
|
||||||
|
|
||||||
codegenServerVariables.add(codegenServerVariable);
|
codegenServerVariables.add(codegenServerVariable);
|
||||||
}
|
}
|
||||||
return codegenServerVariables;
|
return codegenServerVariables;
|
||||||
|
|||||||
@@ -207,10 +207,12 @@ public class DefaultGenerator extends AbstractGenerator implements Generator {
|
|||||||
config.vendorExtensions().putAll(openAPI.getExtensions());
|
config.vendorExtensions().putAll(openAPI.getExtensions());
|
||||||
}
|
}
|
||||||
|
|
||||||
URL url = URLPathUtils.getServerURL(openAPI);
|
// TODO: Allow user to define _which_ servers object in the array to target.
|
||||||
|
// Configures contextPath/basePath according to api document's servers
|
||||||
|
URL url = URLPathUtils.getServerURL(openAPI, config.serverVariableOverrides());
|
||||||
contextPath = config.escapeText(url.getPath()).replaceAll("/$", ""); // for backward compatibility
|
contextPath = config.escapeText(url.getPath()).replaceAll("/$", ""); // for backward compatibility
|
||||||
basePathWithoutHost = contextPath;
|
basePathWithoutHost = contextPath;
|
||||||
basePath = config.escapeText(URLPathUtils.getHost(openAPI)).replaceAll("/$", "");
|
basePath = config.escapeText(URLPathUtils.getHost(openAPI, config.serverVariableOverrides())).replaceAll("/$", "");
|
||||||
}
|
}
|
||||||
|
|
||||||
private void configureOpenAPIInfo() {
|
private void configureOpenAPIInfo() {
|
||||||
@@ -548,7 +550,7 @@ public class DefaultGenerator extends AbstractGenerator implements Generator {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
Map<String, Object> operation = processOperations(config, tag, ops, allModels);
|
Map<String, Object> operation = processOperations(config, tag, ops, allModels);
|
||||||
URL url = URLPathUtils.getServerURL(openAPI);
|
URL url = URLPathUtils.getServerURL(openAPI, config.serverVariableOverrides());
|
||||||
operation.put("basePath", basePath);
|
operation.put("basePath", basePath);
|
||||||
operation.put("basePathWithoutHost", config.encodePath(url.getPath()).replaceAll("/$", ""));
|
operation.put("basePathWithoutHost", config.encodePath(url.getPath()).replaceAll("/$", ""));
|
||||||
operation.put("contextPath", contextPath);
|
operation.put("contextPath", contextPath);
|
||||||
@@ -819,7 +821,7 @@ public class DefaultGenerator extends AbstractGenerator implements Generator {
|
|||||||
Map<String, Object> apis = new HashMap<String, Object>();
|
Map<String, Object> apis = new HashMap<String, Object>();
|
||||||
apis.put("apis", allOperations);
|
apis.put("apis", allOperations);
|
||||||
|
|
||||||
URL url = URLPathUtils.getServerURL(openAPI);
|
URL url = URLPathUtils.getServerURL(openAPI, config.serverVariableOverrides());
|
||||||
|
|
||||||
bundle.put("openAPI", openAPI);
|
bundle.put("openAPI", openAPI);
|
||||||
bundle.put("basePath", basePath);
|
bundle.put("basePath", basePath);
|
||||||
@@ -972,6 +974,7 @@ public class DefaultGenerator extends AbstractGenerator implements Generator {
|
|||||||
processOperation(resourcePath, "delete", path.getDelete(), ops, path);
|
processOperation(resourcePath, "delete", path.getDelete(), ops, path);
|
||||||
processOperation(resourcePath, "patch", path.getPatch(), ops, path);
|
processOperation(resourcePath, "patch", path.getPatch(), ops, path);
|
||||||
processOperation(resourcePath, "options", path.getOptions(), ops, path);
|
processOperation(resourcePath, "options", path.getOptions(), ops, path);
|
||||||
|
processOperation(resourcePath, "trace", path.getTrace(), ops, path);
|
||||||
}
|
}
|
||||||
return ops;
|
return ops;
|
||||||
}
|
}
|
||||||
@@ -1191,7 +1194,7 @@ public class DefaultGenerator extends AbstractGenerator implements Generator {
|
|||||||
for (String key : definitions.keySet()) {
|
for (String key : definitions.keySet()) {
|
||||||
Schema schema = definitions.get(key);
|
Schema schema = definitions.get(key);
|
||||||
if (schema == null)
|
if (schema == null)
|
||||||
throw new RuntimeException("schema cannot be null in processMoels");
|
throw new RuntimeException("schema cannot be null in processModels");
|
||||||
CodegenModel cm = config.fromModel(key, schema);
|
CodegenModel cm = config.fromModel(key, schema);
|
||||||
Map<String, Object> mo = new HashMap<String, Object>();
|
Map<String, Object> mo = new HashMap<String, Object>();
|
||||||
mo.put("model", cm);
|
mo.put("model", cm);
|
||||||
|
|||||||
@@ -19,6 +19,7 @@ package org.openapitools.codegen;
|
|||||||
|
|
||||||
import io.swagger.v3.core.util.Json;
|
import io.swagger.v3.core.util.Json;
|
||||||
import io.swagger.v3.oas.models.*;
|
import io.swagger.v3.oas.models.*;
|
||||||
|
import io.swagger.v3.oas.models.callbacks.Callback;
|
||||||
import io.swagger.v3.oas.models.media.*;
|
import io.swagger.v3.oas.models.media.*;
|
||||||
import io.swagger.v3.oas.models.parameters.Parameter;
|
import io.swagger.v3.oas.models.parameters.Parameter;
|
||||||
import io.swagger.v3.oas.models.parameters.RequestBody;
|
import io.swagger.v3.oas.models.parameters.RequestBody;
|
||||||
@@ -29,6 +30,7 @@ import org.slf4j.Logger;
|
|||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
public class InlineModelResolver {
|
public class InlineModelResolver {
|
||||||
private OpenAPI openapi;
|
private OpenAPI openapi;
|
||||||
@@ -64,7 +66,20 @@ public class InlineModelResolver {
|
|||||||
|
|
||||||
for (String pathname : paths.keySet()) {
|
for (String pathname : paths.keySet()) {
|
||||||
PathItem path = paths.get(pathname);
|
PathItem path = paths.get(pathname);
|
||||||
|
List<Operation> operations = new ArrayList<>(path.readOperations());
|
||||||
|
|
||||||
|
// Include callback operation as well
|
||||||
for (Operation operation : path.readOperations()) {
|
for (Operation operation : path.readOperations()) {
|
||||||
|
Map<String, Callback> callbacks = operation.getCallbacks();
|
||||||
|
if (callbacks != null) {
|
||||||
|
operations.addAll(callbacks.values().stream()
|
||||||
|
.flatMap(callback -> callback.values().stream())
|
||||||
|
.flatMap(pathItem -> pathItem.readOperations().stream())
|
||||||
|
.collect(Collectors.toList()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for (Operation operation : operations) {
|
||||||
flattenRequestBody(openAPI, pathname, operation);
|
flattenRequestBody(openAPI, pathname, operation);
|
||||||
flattenParameters(openAPI, pathname, operation);
|
flattenParameters(openAPI, pathname, operation);
|
||||||
flattenResponses(openAPI, pathname, operation);
|
flattenResponses(openAPI, pathname, operation);
|
||||||
|
|||||||
@@ -67,6 +67,7 @@ public class CodegenConfigurator {
|
|||||||
private Map<String, String> importMappings = new HashMap<>();
|
private Map<String, String> importMappings = new HashMap<>();
|
||||||
private Set<String> languageSpecificPrimitives = new HashSet<>();
|
private Set<String> languageSpecificPrimitives = new HashSet<>();
|
||||||
private Map<String, String> reservedWordMappings = new HashMap<>();
|
private Map<String, String> reservedWordMappings = new HashMap<>();
|
||||||
|
private Map<String, String> serverVariables = new HashMap<>();
|
||||||
private String auth;
|
private String auth;
|
||||||
|
|
||||||
public CodegenConfigurator() {
|
public CodegenConfigurator() {
|
||||||
@@ -98,6 +99,12 @@ public class CodegenConfigurator {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public CodegenConfigurator addServerVariable(String key, String value) {
|
||||||
|
this.serverVariables.put(key, value);
|
||||||
|
generatorSettingsBuilder.withServerVariable(key, value);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
public CodegenConfigurator addAdditionalProperty(String key, Object value) {
|
public CodegenConfigurator addAdditionalProperty(String key, Object value) {
|
||||||
this.additionalProperties.put(key, value);
|
this.additionalProperties.put(key, value);
|
||||||
generatorSettingsBuilder.withAdditionalProperty(key, value);
|
generatorSettingsBuilder.withAdditionalProperty(key, value);
|
||||||
@@ -146,6 +153,18 @@ public class CodegenConfigurator {
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public CodegenConfigurator setServerVariables(Map<String, String> serverVariables) {
|
||||||
|
this.serverVariables = serverVariables;
|
||||||
|
generatorSettingsBuilder.withServerVariables(serverVariables);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public CodegenConfigurator setReservedWordsMappings(Map<String, String> reservedWordMappings) {
|
||||||
|
this.reservedWordMappings = reservedWordMappings;
|
||||||
|
generatorSettingsBuilder.withReservedWordMappings(reservedWordMappings);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
public CodegenConfigurator setApiPackage(String apiPackage) {
|
public CodegenConfigurator setApiPackage(String apiPackage) {
|
||||||
generatorSettingsBuilder.withApiPackage(apiPackage);
|
generatorSettingsBuilder.withApiPackage(apiPackage);
|
||||||
return this;
|
return this;
|
||||||
@@ -247,6 +266,7 @@ public class CodegenConfigurator {
|
|||||||
|
|
||||||
public CodegenConfigurator setLanguageSpecificPrimitives(
|
public CodegenConfigurator setLanguageSpecificPrimitives(
|
||||||
Set<String> languageSpecificPrimitives) {
|
Set<String> languageSpecificPrimitives) {
|
||||||
|
this.languageSpecificPrimitives = languageSpecificPrimitives;
|
||||||
generatorSettingsBuilder.withLanguageSpecificPrimitives(languageSpecificPrimitives);
|
generatorSettingsBuilder.withLanguageSpecificPrimitives(languageSpecificPrimitives);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
@@ -296,12 +316,6 @@ public class CodegenConfigurator {
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public CodegenConfigurator setReservedWordsMappings(Map<String, String> reservedWordMappings) {
|
|
||||||
this.reservedWordMappings = reservedWordMappings;
|
|
||||||
generatorSettingsBuilder.withReservedWordMappings(reservedWordMappings);
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public CodegenConfigurator setSkipOverwrite(boolean skipOverwrite) {
|
public CodegenConfigurator setSkipOverwrite(boolean skipOverwrite) {
|
||||||
workflowSettingsBuilder.withSkipOverwrite(skipOverwrite);
|
workflowSettingsBuilder.withSkipOverwrite(skipOverwrite);
|
||||||
return this;
|
return this;
|
||||||
@@ -459,6 +473,13 @@ public class CodegenConfigurator {
|
|||||||
config.reservedWordsMappings().putAll(generatorSettings.getReservedWordMappings());
|
config.reservedWordsMappings().putAll(generatorSettings.getReservedWordMappings());
|
||||||
config.additionalProperties().putAll(generatorSettings.getAdditionalProperties());
|
config.additionalProperties().putAll(generatorSettings.getAdditionalProperties());
|
||||||
|
|
||||||
|
Map<String, String> serverVariables = generatorSettings.getServerVariables();
|
||||||
|
if (!serverVariables.isEmpty()) {
|
||||||
|
// This is currently experimental due to vagueness in the specification
|
||||||
|
LOGGER.warn("user-defined server variable support is experimental.");
|
||||||
|
config.serverVariableOverrides().putAll(serverVariables);
|
||||||
|
}
|
||||||
|
|
||||||
// any other additional properties?
|
// any other additional properties?
|
||||||
String templateDir = workflowSettings.getTemplateDir();
|
String templateDir = workflowSettings.getTemplateDir();
|
||||||
if (templateDir != null) {
|
if (templateDir != null) {
|
||||||
|
|||||||
@@ -107,6 +107,19 @@ public final class CodegenConfiguratorUtils {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void applyServerVariablesKvpList(List<String> values, CodegenConfigurator configurator) {
|
||||||
|
for(String value : values) {
|
||||||
|
applyServerVariablesKvp(value, configurator);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void applyServerVariablesKvp(String values, CodegenConfigurator configurator) {
|
||||||
|
final Map<String, String> map = createMapFromKeyValuePairs(values);
|
||||||
|
for (Map.Entry<String, String> entry : map.entrySet()) {
|
||||||
|
configurator.addServerVariable(entry.getKey(), entry.getValue());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public static void applyLanguageSpecificPrimitivesCsvList(List<String> languageSpecificPrimitives, CodegenConfigurator configurator) {
|
public static void applyLanguageSpecificPrimitivesCsvList(List<String> languageSpecificPrimitives, CodegenConfigurator configurator) {
|
||||||
for(String propString : languageSpecificPrimitives) {
|
for(String propString : languageSpecificPrimitives) {
|
||||||
applyLanguageSpecificPrimitivesCsv(propString, configurator);
|
applyLanguageSpecificPrimitivesCsv(propString, configurator);
|
||||||
|
|||||||
@@ -296,7 +296,7 @@ abstract public class AbstractCppCodegen extends DefaultCodegen implements Codeg
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void preprocessOpenAPI(OpenAPI openAPI) {
|
public void preprocessOpenAPI(OpenAPI openAPI) {
|
||||||
URL url = URLPathUtils.getServerURL(openAPI);
|
URL url = URLPathUtils.getServerURL(openAPI, serverVariableOverrides());
|
||||||
String port = URLPathUtils.getPort(url, "");
|
String port = URLPathUtils.getPort(url, "");
|
||||||
String host = url.getHost();
|
String host = url.getHost();
|
||||||
if(!port.isEmpty()) {
|
if(!port.isEmpty()) {
|
||||||
|
|||||||
@@ -389,6 +389,11 @@ public abstract class AbstractGoCodegen extends DefaultCodegen implements Codege
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// import "reflect" package if the parameter is collectionFormat=multi
|
||||||
|
if (param.isCollectionFormatMulti) {
|
||||||
|
imports.add(createMapping("import", "reflect"));
|
||||||
|
}
|
||||||
|
|
||||||
// import "optionals" package if the parameter is optional
|
// import "optionals" package if the parameter is optional
|
||||||
if (!param.required) {
|
if (!param.required) {
|
||||||
if (!addedOptionalImport) {
|
if (!addedOptionalImport) {
|
||||||
|
|||||||
@@ -17,6 +17,7 @@
|
|||||||
|
|
||||||
package org.openapitools.codegen.languages;
|
package org.openapitools.codegen.languages;
|
||||||
|
|
||||||
|
import com.google.common.base.CaseFormat;
|
||||||
import com.google.common.base.Strings;
|
import com.google.common.base.Strings;
|
||||||
import io.swagger.v3.oas.models.OpenAPI;
|
import io.swagger.v3.oas.models.OpenAPI;
|
||||||
import io.swagger.v3.oas.models.Operation;
|
import io.swagger.v3.oas.models.Operation;
|
||||||
@@ -417,6 +418,8 @@ public abstract class AbstractJavaCodegen extends DefaultCodegen implements Code
|
|||||||
importMapping.put("JsonTypeInfo", "com.fasterxml.jackson.annotation.JsonTypeInfo");
|
importMapping.put("JsonTypeInfo", "com.fasterxml.jackson.annotation.JsonTypeInfo");
|
||||||
importMapping.put("JsonCreator", "com.fasterxml.jackson.annotation.JsonCreator");
|
importMapping.put("JsonCreator", "com.fasterxml.jackson.annotation.JsonCreator");
|
||||||
importMapping.put("JsonValue", "com.fasterxml.jackson.annotation.JsonValue");
|
importMapping.put("JsonValue", "com.fasterxml.jackson.annotation.JsonValue");
|
||||||
|
importMapping.put("JsonIgnore", "com.fasterxml.jackson.annotation.JsonIgnore");
|
||||||
|
importMapping.put("JsonInclude", "com.fasterxml.jackson.annotation.JsonInclude");
|
||||||
importMapping.put("SerializedName", "com.google.gson.annotations.SerializedName");
|
importMapping.put("SerializedName", "com.google.gson.annotations.SerializedName");
|
||||||
importMapping.put("TypeAdapter", "com.google.gson.TypeAdapter");
|
importMapping.put("TypeAdapter", "com.google.gson.TypeAdapter");
|
||||||
importMapping.put("JsonAdapter", "com.google.gson.annotations.JsonAdapter");
|
importMapping.put("JsonAdapter", "com.google.gson.annotations.JsonAdapter");
|
||||||
@@ -800,7 +803,13 @@ public abstract class AbstractJavaCodegen extends DefaultCodegen implements Code
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
|
} else if (ModelUtils.isObjectSchema(p)) {
|
||||||
|
if (p.getDefault() != null) {
|
||||||
|
return super.toDefaultValue(p);
|
||||||
|
}
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
return super.toDefaultValue(p);
|
return super.toDefaultValue(p);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -976,6 +985,9 @@ public abstract class AbstractJavaCodegen extends DefaultCodegen implements Code
|
|||||||
model.imports.add("ApiModelProperty");
|
model.imports.add("ApiModelProperty");
|
||||||
model.imports.add("ApiModel");
|
model.imports.add("ApiModel");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// store java constant property name in vendor extension, remove dollar sign from the constant name
|
||||||
|
property.vendorExtensions.put("x-java-const-name", CaseFormat.UPPER_CAMEL.to(CaseFormat.UPPER_UNDERSCORE, property.nameInCamelCase.replaceAll("\\$", "")));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -110,7 +110,7 @@ public abstract class AbstractJavaJAXRSServerCodegen extends AbstractJavaCodegen
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
if (!this.additionalProperties.containsKey(SERVER_PORT)) {
|
if (!this.additionalProperties.containsKey(SERVER_PORT)) {
|
||||||
URL url = URLPathUtils.getServerURL(openAPI);
|
URL url = URLPathUtils.getServerURL(openAPI, serverVariableOverrides());
|
||||||
// 8080 is the default value for a JEE Server:
|
// 8080 is the default value for a JEE Server:
|
||||||
this.additionalProperties.put(SERVER_PORT, URLPathUtils.getPort(url, serverPort));
|
this.additionalProperties.put(SERVER_PORT, URLPathUtils.getPort(url, serverPort));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -612,6 +612,7 @@ public abstract class AbstractKotlinCodegen extends DefaultCodegen implements Co
|
|||||||
StringBuilder instantiationType = new StringBuilder(arrayType);
|
StringBuilder instantiationType = new StringBuilder(arrayType);
|
||||||
Schema items = arr.getItems();
|
Schema items = arr.getItems();
|
||||||
String nestedType = getTypeDeclaration(items);
|
String nestedType = getTypeDeclaration(items);
|
||||||
|
additionalProperties.put("nestedType", nestedType);
|
||||||
// TODO: We may want to differentiate here between generics and primitive arrays.
|
// TODO: We may want to differentiate here between generics and primitive arrays.
|
||||||
instantiationType.append("<").append(nestedType).append(">");
|
instantiationType.append("<").append(nestedType).append(">");
|
||||||
return instantiationType.toString();
|
return instantiationType.toString();
|
||||||
|
|||||||
@@ -268,7 +268,7 @@ public class AspNetCoreServerCodegen extends AbstractCSharpCodegen {
|
|||||||
@Override
|
@Override
|
||||||
public void preprocessOpenAPI(OpenAPI openAPI) {
|
public void preprocessOpenAPI(OpenAPI openAPI) {
|
||||||
super.preprocessOpenAPI(openAPI);
|
super.preprocessOpenAPI(openAPI);
|
||||||
URL url = URLPathUtils.getServerURL(openAPI);
|
URL url = URLPathUtils.getServerURL(openAPI, serverVariableOverrides());
|
||||||
additionalProperties.put("serverHost", url.getHost());
|
additionalProperties.put("serverHost", url.getHost());
|
||||||
additionalProperties.put("serverPort", URLPathUtils.getPort(url, 8080));
|
additionalProperties.put("serverPort", URLPathUtils.getPort(url, 8080));
|
||||||
}
|
}
|
||||||
@@ -327,6 +327,7 @@ public class AspNetCoreServerCodegen extends AbstractCSharpCodegen {
|
|||||||
supportingFiles.add(new SupportingFile("Solution.mustache", "", packageName + ".sln"));
|
supportingFiles.add(new SupportingFile("Solution.mustache", "", packageName + ".sln"));
|
||||||
supportingFiles.add(new SupportingFile("gitignore", packageFolder, ".gitignore"));
|
supportingFiles.add(new SupportingFile("gitignore", packageFolder, ".gitignore"));
|
||||||
supportingFiles.add(new SupportingFile("validateModel.mustache", packageFolder + File.separator + "Attributes", "ValidateModelStateAttribute.cs"));
|
supportingFiles.add(new SupportingFile("validateModel.mustache", packageFolder + File.separator + "Attributes", "ValidateModelStateAttribute.cs"));
|
||||||
|
supportingFiles.add(new SupportingFile("typeConverter.mustache", packageFolder + File.separator + "Converters", "CustomEnumConverter.cs"));
|
||||||
supportingFiles.add(new SupportingFile("Project.csproj.mustache", packageFolder, packageName + ".csproj"));
|
supportingFiles.add(new SupportingFile("Project.csproj.mustache", packageFolder, packageName + ".csproj"));
|
||||||
if (!isLibrary) {
|
if (!isLibrary) {
|
||||||
supportingFiles.add(new SupportingFile("Dockerfile.mustache", packageFolder, "Dockerfile"));
|
supportingFiles.add(new SupportingFile("Dockerfile.mustache", packageFolder, "Dockerfile"));
|
||||||
|
|||||||
@@ -359,7 +359,7 @@ public class CSharpNancyFXServerCodegen extends AbstractCSharpCodegen {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void preprocessOpenAPI(final OpenAPI openAPI) {
|
public void preprocessOpenAPI(final OpenAPI openAPI) {
|
||||||
URL url = URLPathUtils.getServerURL(openAPI);
|
URL url = URLPathUtils.getServerURL(openAPI, serverVariableOverrides());
|
||||||
String path = URLPathUtils.getPath(url, "/");
|
String path = URLPathUtils.getPath(url, "/");
|
||||||
final String packageContextOption = (String) additionalProperties.get(PACKAGE_CONTEXT);
|
final String packageContextOption = (String) additionalProperties.get(PACKAGE_CONTEXT);
|
||||||
additionalProperties.put("packageContext", packageContextOption == null ? sanitizeName(path) : packageContextOption);
|
additionalProperties.put("packageContext", packageContextOption == null ? sanitizeName(path) : packageContextOption);
|
||||||
|
|||||||
@@ -118,13 +118,13 @@ public class DartClientCodegen extends DefaultCodegen implements CodegenConfig {
|
|||||||
typeMapping.put("URI", "String");
|
typeMapping.put("URI", "String");
|
||||||
typeMapping.put("ByteArray", "String");
|
typeMapping.put("ByteArray", "String");
|
||||||
|
|
||||||
cliOptions.add(new CliOption(BROWSER_CLIENT, "Is the client browser based"));
|
cliOptions.add(new CliOption(BROWSER_CLIENT, "Is the client browser based (for Dart 1.x only)"));
|
||||||
cliOptions.add(new CliOption(PUB_NAME, "Name in generated pubspec"));
|
cliOptions.add(new CliOption(PUB_NAME, "Name in generated pubspec"));
|
||||||
cliOptions.add(new CliOption(PUB_VERSION, "Version in generated pubspec"));
|
cliOptions.add(new CliOption(PUB_VERSION, "Version in generated pubspec"));
|
||||||
cliOptions.add(new CliOption(PUB_DESCRIPTION, "Description in generated pubspec"));
|
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(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(new CliOption(CodegenConstants.SOURCE_FOLDER, "Source folder for generated code"));
|
||||||
cliOptions.add(CliOption.newBoolean(SUPPORT_DART2, "support dart2").defaultValue(Boolean.TRUE.toString()));
|
cliOptions.add(CliOption.newBoolean(SUPPORT_DART2, "Support Dart 2.x").defaultValue(Boolean.TRUE.toString()));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -23,20 +23,14 @@ import org.openapitools.codegen.CodegenConstants;
|
|||||||
import org.openapitools.codegen.CodegenOperation;
|
import org.openapitools.codegen.CodegenOperation;
|
||||||
import org.openapitools.codegen.CodegenType;
|
import org.openapitools.codegen.CodegenType;
|
||||||
import org.openapitools.codegen.SupportingFile;
|
import org.openapitools.codegen.SupportingFile;
|
||||||
import org.openapitools.codegen.CodegenModel;
|
|
||||||
import org.openapitools.codegen.CodegenProperty;
|
|
||||||
import org.openapitools.codegen.utils.URLPathUtils;
|
import org.openapitools.codegen.utils.URLPathUtils;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
|
|
||||||
import static java.util.UUID.randomUUID;
|
import static java.util.UUID.randomUUID;
|
||||||
|
|
||||||
@@ -165,7 +159,7 @@ public class FsharpGiraffeServerCodegen extends AbstractFSharpCodegen {
|
|||||||
@Override
|
@Override
|
||||||
public void preprocessOpenAPI(OpenAPI openAPI) {
|
public void preprocessOpenAPI(OpenAPI openAPI) {
|
||||||
super.preprocessOpenAPI(openAPI);
|
super.preprocessOpenAPI(openAPI);
|
||||||
URL url = URLPathUtils.getServerURL(openAPI);
|
URL url = URLPathUtils.getServerURL(openAPI, serverVariableOverrides());
|
||||||
additionalProperties.put("serverHost", url.getHost());
|
additionalProperties.put("serverHost", url.getHost());
|
||||||
additionalProperties.put("serverPort", URLPathUtils.getPort(url, 8080));
|
additionalProperties.put("serverPort", URLPathUtils.getPort(url, 8080));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,6 +19,8 @@ package org.openapitools.codegen.languages;
|
|||||||
import org.openapitools.codegen.CodegenModel;
|
import org.openapitools.codegen.CodegenModel;
|
||||||
import org.openapitools.codegen.CodegenProperty;
|
import org.openapitools.codegen.CodegenProperty;
|
||||||
import org.openapitools.codegen.SupportingFile;
|
import org.openapitools.codegen.SupportingFile;
|
||||||
|
import org.openapitools.codegen.meta.GeneratorMetadata;
|
||||||
|
import org.openapitools.codegen.meta.Stability;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
@@ -33,6 +35,10 @@ public class GoClientExperimentalCodegen extends GoClientCodegen {
|
|||||||
super();
|
super();
|
||||||
outputFolder = "generated-code/go-experimental";
|
outputFolder = "generated-code/go-experimental";
|
||||||
embeddedTemplateDir = templateDir = "go-experimental";
|
embeddedTemplateDir = templateDir = "go-experimental";
|
||||||
|
|
||||||
|
generatorMetadata = GeneratorMetadata.newBuilder(generatorMetadata)
|
||||||
|
.stability(Stability.EXPERIMENTAL)
|
||||||
|
.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -1065,13 +1065,14 @@ public class HaskellHttpClientCodegen extends DefaultCodegen implements CodegenC
|
|||||||
case "tsv":
|
case "tsv":
|
||||||
return "TabSeparated";
|
return "TabSeparated";
|
||||||
case "ssv":
|
case "ssv":
|
||||||
|
case "space":
|
||||||
return "SpaceSeparated";
|
return "SpaceSeparated";
|
||||||
case "pipes":
|
case "pipes":
|
||||||
return "PipeSeparated";
|
return "PipeSeparated";
|
||||||
case "multi":
|
case "multi":
|
||||||
return "MultiParamArray";
|
return "MultiParamArray";
|
||||||
default:
|
default:
|
||||||
throw new UnsupportedOperationException();
|
throw new UnsupportedOperationException(collectionFormat + " (collection format) not supported");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -549,6 +549,7 @@ public class HaskellServantCodegen extends DefaultCodegen implements CodegenConf
|
|||||||
return "(QueryList 'CommaSeparated (" + type + "))";
|
return "(QueryList 'CommaSeparated (" + type + "))";
|
||||||
case "tsv":
|
case "tsv":
|
||||||
return "(QueryList 'TabSeparated (" + type + "))";
|
return "(QueryList 'TabSeparated (" + type + "))";
|
||||||
|
case "space":
|
||||||
case "ssv":
|
case "ssv":
|
||||||
return "(QueryList 'SpaceSeparated (" + type + "))";
|
return "(QueryList 'SpaceSeparated (" + type + "))";
|
||||||
case "pipes":
|
case "pipes":
|
||||||
@@ -556,7 +557,7 @@ public class HaskellServantCodegen extends DefaultCodegen implements CodegenConf
|
|||||||
case "multi":
|
case "multi":
|
||||||
return "(QueryList 'MultiParamArray (" + type + "))";
|
return "(QueryList 'MultiParamArray (" + type + "))";
|
||||||
default:
|
default:
|
||||||
throw new UnsupportedOperationException();
|
throw new UnsupportedOperationException(collectionFormat + " (collection format) not supported");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -24,6 +24,7 @@ import org.openapitools.codegen.languages.features.BeanValidationFeatures;
|
|||||||
import org.openapitools.codegen.languages.features.GzipFeatures;
|
import org.openapitools.codegen.languages.features.GzipFeatures;
|
||||||
import org.openapitools.codegen.languages.features.PerformBeanValidationFeatures;
|
import org.openapitools.codegen.languages.features.PerformBeanValidationFeatures;
|
||||||
import org.openapitools.codegen.templating.mustache.CaseFormatLambda;
|
import org.openapitools.codegen.templating.mustache.CaseFormatLambda;
|
||||||
|
import org.openapitools.codegen.utils.ModelUtils;
|
||||||
import org.openapitools.codegen.utils.ProcessUtils;
|
import org.openapitools.codegen.utils.ProcessUtils;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
@@ -583,6 +584,7 @@ public class JavaClientCodegen extends AbstractJavaCodegen
|
|||||||
if (additionalProperties.containsKey("jackson")) {
|
if (additionalProperties.containsKey("jackson")) {
|
||||||
model.imports.add("JsonProperty");
|
model.imports.add("JsonProperty");
|
||||||
model.imports.add("JsonValue");
|
model.imports.add("JsonValue");
|
||||||
|
model.imports.add("JsonInclude");
|
||||||
}
|
}
|
||||||
if (additionalProperties.containsKey("gson")) {
|
if (additionalProperties.containsKey("gson")) {
|
||||||
model.imports.add("SerializedName");
|
model.imports.add("SerializedName");
|
||||||
@@ -623,6 +625,39 @@ public class JavaClientCodegen extends AbstractJavaCodegen
|
|||||||
return objs;
|
return objs;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Map<String, Object> postProcessModels(Map<String, Object> objs) {
|
||||||
|
objs = super.postProcessModels(objs);
|
||||||
|
if (additionalProperties.containsKey("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) {
|
||||||
|
Map<String, Object> mo = (Map<String, Object>) _mo;
|
||||||
|
CodegenModel cm = (CodegenModel) mo.get("model");
|
||||||
|
boolean addImports = false;
|
||||||
|
for (CodegenProperty var : cm.vars) {
|
||||||
|
boolean isOptionalNullable = Boolean.FALSE.equals(var.required) && Boolean.TRUE.equals(var.isNullable);
|
||||||
|
// only add JsonNullable and related imports to optional and nullable values
|
||||||
|
addImports |= isOptionalNullable;
|
||||||
|
var.getVendorExtensions().put("isJacksonOptionalNullable", isOptionalNullable);
|
||||||
|
}
|
||||||
|
if (addImports) {
|
||||||
|
cm.imports.add("JsonNullable");
|
||||||
|
Map<String, String> itemJsonNullable = new HashMap<String, String>();
|
||||||
|
itemJsonNullable.put("import", "org.openapitools.jackson.nullable.JsonNullable");
|
||||||
|
imports.add(itemJsonNullable);
|
||||||
|
|
||||||
|
cm.imports.add("NoSuchElementException");
|
||||||
|
Map<String, String> itemExc = new HashMap<String, String>();
|
||||||
|
itemExc.put("import", "java.util.NoSuchElementException");
|
||||||
|
imports.add(itemExc);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return objs;
|
||||||
|
}
|
||||||
|
|
||||||
public void setUseRxJava(boolean useRxJava) {
|
public void setUseRxJava(boolean useRxJava) {
|
||||||
this.useRxJava = useRxJava;
|
this.useRxJava = useRxJava;
|
||||||
doNotUseRx = false;
|
doNotUseRx = false;
|
||||||
|
|||||||
@@ -538,7 +538,7 @@ public class JavaPKMSTServerCodegen extends AbstractJavaCodegen {
|
|||||||
additionalProperties.put(TITLE, this.title);
|
additionalProperties.put(TITLE, this.title);
|
||||||
}
|
}
|
||||||
|
|
||||||
URL url = URLPathUtils.getServerURL(openAPI);
|
URL url = URLPathUtils.getServerURL(openAPI, serverVariableOverrides());
|
||||||
this.additionalProperties.put("serverPort", URLPathUtils.getPort(url, 8080));
|
this.additionalProperties.put("serverPort", URLPathUtils.getPort(url, 8080));
|
||||||
|
|
||||||
if (openAPI.getPaths() != null) {
|
if (openAPI.getPaths() != null) {
|
||||||
|
|||||||
@@ -221,7 +221,7 @@ public class JavaVertXServerCodegen extends AbstractJavaCodegen {
|
|||||||
super.preprocessOpenAPI(openAPI);
|
super.preprocessOpenAPI(openAPI);
|
||||||
|
|
||||||
// add server port from the swagger file, 8080 by default
|
// add server port from the swagger file, 8080 by default
|
||||||
URL url = URLPathUtils.getServerURL(openAPI);
|
URL url = URLPathUtils.getServerURL(openAPI, serverVariableOverrides());
|
||||||
this.additionalProperties.put("serverPort", URLPathUtils.getPort(url, 8080));
|
this.additionalProperties.put("serverPort", URLPathUtils.getPort(url, 8080));
|
||||||
|
|
||||||
// retrieve api version from swagger file, 1.0.0-SNAPSHOT by default
|
// retrieve api version from swagger file, 1.0.0-SNAPSHOT by default
|
||||||
|
|||||||
@@ -149,6 +149,7 @@ public class KotlinClientCodegen extends AbstractKotlinCodegen {
|
|||||||
if (CollectionType.LIST.value.equals(collectionType)) {
|
if (CollectionType.LIST.value.equals(collectionType)) {
|
||||||
typeMapping.put("array", "kotlin.collections.List");
|
typeMapping.put("array", "kotlin.collections.List");
|
||||||
typeMapping.put("list", "kotlin.collections.List");
|
typeMapping.put("list", "kotlin.collections.List");
|
||||||
|
additionalProperties.put("isList", true);
|
||||||
}
|
}
|
||||||
|
|
||||||
supportingFiles.add(new SupportingFile("README.mustache", "", "README.md"));
|
supportingFiles.add(new SupportingFile("README.mustache", "", "README.md"));
|
||||||
|
|||||||
@@ -407,7 +407,7 @@ public class KotlinSpringServerCodegen extends AbstractKotlinCodegen
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!additionalProperties.containsKey(SERVER_PORT)) {
|
if (!additionalProperties.containsKey(SERVER_PORT)) {
|
||||||
URL url = URLPathUtils.getServerURL(openAPI);
|
URL url = URLPathUtils.getServerURL(openAPI, serverVariableOverrides());
|
||||||
this.additionalProperties.put(SERVER_PORT, URLPathUtils.getPort(url, 8080));
|
this.additionalProperties.put(SERVER_PORT, URLPathUtils.getPort(url, 8080));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -300,7 +300,7 @@ public class NodeJSExpressServerCodegen extends DefaultCodegen implements Codege
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void preprocessOpenAPI(OpenAPI openAPI) {
|
public void preprocessOpenAPI(OpenAPI openAPI) {
|
||||||
URL url = URLPathUtils.getServerURL(openAPI);
|
URL url = URLPathUtils.getServerURL(openAPI, serverVariableOverrides());
|
||||||
String host = URLPathUtils.getProtocolAndHost(url);
|
String host = URLPathUtils.getProtocolAndHost(url);
|
||||||
String port = URLPathUtils.getPort(url, defaultServerPort) ;
|
String port = URLPathUtils.getPort(url, defaultServerPort) ;
|
||||||
String basePath = url.getPath();
|
String basePath = url.getPath();
|
||||||
|
|||||||
@@ -358,7 +358,7 @@ public class NodeJSServerCodegen extends DefaultCodegen implements CodegenConfig
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void preprocessOpenAPI(OpenAPI openAPI) {
|
public void preprocessOpenAPI(OpenAPI openAPI) {
|
||||||
URL url = URLPathUtils.getServerURL(openAPI);
|
URL url = URLPathUtils.getServerURL(openAPI, serverVariableOverrides());
|
||||||
String host = URLPathUtils.getProtocolAndHost(url);
|
String host = URLPathUtils.getProtocolAndHost(url);
|
||||||
String port = URLPathUtils.getPort(url, defaultServerPort) ;
|
String port = URLPathUtils.getPort(url, defaultServerPort) ;
|
||||||
String basePath = url.getPath();
|
String basePath = url.getPath();
|
||||||
|
|||||||
@@ -18,6 +18,9 @@ package org.openapitools.codegen.languages;
|
|||||||
|
|
||||||
import java.text.DateFormat;
|
import java.text.DateFormat;
|
||||||
import java.text.SimpleDateFormat;
|
import java.text.SimpleDateFormat;
|
||||||
|
|
||||||
|
import org.openapitools.codegen.meta.GeneratorMetadata;
|
||||||
|
import org.openapitools.codegen.meta.Stability;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
@@ -39,6 +42,10 @@ public class PythonClientExperimentalCodegen extends PythonClientCodegen {
|
|||||||
apiTemplateFiles.put("python-experimental/api.mustache", ".py");
|
apiTemplateFiles.put("python-experimental/api.mustache", ".py");
|
||||||
modelDocTemplateFiles.put("python-experimental/model_doc.mustache", ".md");
|
modelDocTemplateFiles.put("python-experimental/model_doc.mustache", ".md");
|
||||||
modelTemplateFiles.put("python-experimental/model.mustache", ".py");
|
modelTemplateFiles.put("python-experimental/model.mustache", ".py");
|
||||||
|
|
||||||
|
generatorMetadata = GeneratorMetadata.newBuilder(generatorMetadata)
|
||||||
|
.stability(Stability.EXPERIMENTAL)
|
||||||
|
.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -24,9 +24,7 @@ import io.swagger.v3.oas.models.info.Info;
|
|||||||
import io.swagger.v3.oas.models.media.ArraySchema;
|
import io.swagger.v3.oas.models.media.ArraySchema;
|
||||||
import io.swagger.v3.oas.models.media.FileSchema;
|
import io.swagger.v3.oas.models.media.FileSchema;
|
||||||
import io.swagger.v3.oas.models.media.Schema;
|
import io.swagger.v3.oas.models.media.Schema;
|
||||||
import io.swagger.v3.oas.models.media.StringSchema;
|
|
||||||
import io.swagger.v3.oas.models.media.XML;
|
import io.swagger.v3.oas.models.media.XML;
|
||||||
import io.swagger.v3.oas.models.parameters.Parameter;
|
|
||||||
import io.swagger.v3.oas.models.parameters.RequestBody;
|
import io.swagger.v3.oas.models.parameters.RequestBody;
|
||||||
import io.swagger.v3.oas.models.servers.Server;
|
import io.swagger.v3.oas.models.servers.Server;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
@@ -291,7 +289,7 @@ public class RustServerCodegen extends DefaultCodegen implements CodegenConfig {
|
|||||||
}
|
}
|
||||||
info.setVersion(StringUtils.join(versionComponents, "."));
|
info.setVersion(StringUtils.join(versionComponents, "."));
|
||||||
|
|
||||||
URL url = URLPathUtils.getServerURL(openAPI);
|
URL url = URLPathUtils.getServerURL(openAPI, serverVariableOverrides());
|
||||||
additionalProperties.put("serverHost", url.getHost());
|
additionalProperties.put("serverHost", url.getHost());
|
||||||
additionalProperties.put("serverPort", URLPathUtils.getPort(url, 80));
|
additionalProperties.put("serverPort", URLPathUtils.getPort(url, 80));
|
||||||
}
|
}
|
||||||
@@ -617,10 +615,6 @@ public class RustServerCodegen extends DefaultCodegen implements CodegenConfig {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for (CodegenParameter param : op.headerParams) {
|
for (CodegenParameter param : op.headerParams) {
|
||||||
// If a header uses UUIDs, we need to import the UUID package.
|
|
||||||
if (param.dataType.equals(uuidType)) {
|
|
||||||
additionalProperties.put("apiUsesUuid", true);
|
|
||||||
}
|
|
||||||
processParam(param, op);
|
processParam(param, op);
|
||||||
|
|
||||||
// Give header params a name in camel case. CodegenParameters don't have a nameInCamelCase property.
|
// Give header params a name in camel case. CodegenParameters don't have a nameInCamelCase property.
|
||||||
@@ -756,10 +750,21 @@ public class RustServerCodegen extends DefaultCodegen implements CodegenConfig {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (op.authMethods != null) {
|
if (op.authMethods != null) {
|
||||||
|
boolean headerAuthMethods = false;
|
||||||
|
|
||||||
for (CodegenSecurity s : op.authMethods) {
|
for (CodegenSecurity s : op.authMethods) {
|
||||||
if (s.isApiKey && s.isKeyInHeader) {
|
if (s.isApiKey && s.isKeyInHeader) {
|
||||||
s.vendorExtensions.put("x-apiKeyName", toModelName(s.keyParamName));
|
s.vendorExtensions.put("x-apiKeyName", toModelName(s.keyParamName));
|
||||||
|
headerAuthMethods = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (s.isBasicBasic || s.isBasicBearer || s.isOAuth) {
|
||||||
|
headerAuthMethods = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (headerAuthMethods) {
|
||||||
|
op.vendorExtensions.put("hasHeaderAuthMethods", "true");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -927,7 +932,15 @@ public class RustServerCodegen extends DefaultCodegen implements CodegenConfig {
|
|||||||
String modelName = entry.getKey();
|
String modelName = entry.getKey();
|
||||||
CodegenModel model = entry.getValue();
|
CodegenModel model = entry.getValue();
|
||||||
|
|
||||||
|
if (uuidType.equals(model.dataType)) {
|
||||||
|
additionalProperties.put("apiUsesUuid", true);
|
||||||
|
}
|
||||||
|
|
||||||
for (CodegenProperty prop : model.vars) {
|
for (CodegenProperty prop : model.vars) {
|
||||||
|
if (prop.dataType.equals(uuidType)) {
|
||||||
|
additionalProperties.put("apiUsesUuid", true);
|
||||||
|
}
|
||||||
|
|
||||||
String xmlName = modelXmlNames.get(prop.dataType);
|
String xmlName = modelXmlNames.get(prop.dataType);
|
||||||
if (xmlName != null) {
|
if (xmlName != null) {
|
||||||
prop.vendorExtensions.put("itemXmlName", xmlName);
|
prop.vendorExtensions.put("itemXmlName", xmlName);
|
||||||
@@ -1134,6 +1147,11 @@ public class RustServerCodegen extends DefaultCodegen implements CodegenConfig {
|
|||||||
private void processParam(CodegenParameter param, CodegenOperation op) {
|
private void processParam(CodegenParameter param, CodegenOperation op) {
|
||||||
String example = null;
|
String example = null;
|
||||||
|
|
||||||
|
// If a parameter uses UUIDs, we need to import the UUID package.
|
||||||
|
if (param.dataType.equals(uuidType)) {
|
||||||
|
additionalProperties.put("apiUsesUuid", true);
|
||||||
|
}
|
||||||
|
|
||||||
if (param.isString) {
|
if (param.isString) {
|
||||||
param.vendorExtensions.put("formatString", "\\\"{}\\\"");
|
param.vendorExtensions.put("formatString", "\\\"{}\\\"");
|
||||||
example = "\"" + ((param.example != null) ? param.example : "") + "\".to_string()";
|
example = "\"" + ((param.example != null) ? param.example : "") + "\".to_string()";
|
||||||
|
|||||||
@@ -515,8 +515,8 @@ public class SpringCodegen extends AbstractJavaCodegen
|
|||||||
additionalProperties.put(TITLE, this.title);
|
additionalProperties.put(TITLE, this.title);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!additionalProperties.containsKey(SERVER_PORT)) {
|
if(!additionalProperties.containsKey(SERVER_PORT)) {
|
||||||
URL url = URLPathUtils.getServerURL(openAPI);
|
URL url = URLPathUtils.getServerURL(openAPI, serverVariableOverrides());
|
||||||
this.additionalProperties.put(SERVER_PORT, URLPathUtils.getPort(url, 8080));
|
this.additionalProperties.put(SERVER_PORT, URLPathUtils.getPort(url, 8080));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -209,8 +209,9 @@ public class TypeScriptAngularClientCodegen extends AbstractTypeScriptClientCode
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Set the typescript version compatible to the Angular version
|
// Set the typescript version compatible to the Angular version
|
||||||
if (ngVersion.atLeast("7.0.0")) {
|
if (ngVersion.atLeast("8.0.0")) {
|
||||||
// Angular v7 requires typescript ">=3.1.1 <3.2.0"
|
additionalProperties.put("tsVersion", ">=3.4.0 <3.6.0");
|
||||||
|
} else if (ngVersion.atLeast("7.0.0")) {
|
||||||
additionalProperties.put("tsVersion", ">=3.1.1 <3.2.0");
|
additionalProperties.put("tsVersion", ">=3.1.1 <3.2.0");
|
||||||
} else if (ngVersion.atLeast("6.0.0")) {
|
} else if (ngVersion.atLeast("6.0.0")) {
|
||||||
additionalProperties.put("tsVersion", ">=2.7.2 and <2.10.0");
|
additionalProperties.put("tsVersion", ">=2.7.2 and <2.10.0");
|
||||||
@@ -222,7 +223,9 @@ public class TypeScriptAngularClientCodegen extends AbstractTypeScriptClientCode
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Set the rxJS version compatible to the Angular version
|
// Set the rxJS version compatible to the Angular version
|
||||||
if (ngVersion.atLeast("7.0.0")) {
|
if (ngVersion.atLeast("8.0.0")) {
|
||||||
|
additionalProperties.put("rxjsVersion", "6.5.0");
|
||||||
|
} else if (ngVersion.atLeast("7.0.0")) {
|
||||||
additionalProperties.put("rxjsVersion", "6.3.0");
|
additionalProperties.put("rxjsVersion", "6.3.0");
|
||||||
} else if (ngVersion.atLeast("6.0.0")) {
|
} else if (ngVersion.atLeast("6.0.0")) {
|
||||||
additionalProperties.put("rxjsVersion", "6.1.0");
|
additionalProperties.put("rxjsVersion", "6.1.0");
|
||||||
@@ -250,7 +253,10 @@ public class TypeScriptAngularClientCodegen extends AbstractTypeScriptClientCode
|
|||||||
additionalProperties.put("useOldNgPackagr", !ngVersion.atLeast("5.0.0"));
|
additionalProperties.put("useOldNgPackagr", !ngVersion.atLeast("5.0.0"));
|
||||||
|
|
||||||
// Specific ng-packagr configuration
|
// Specific ng-packagr configuration
|
||||||
if (ngVersion.atLeast("7.0.0")) {
|
if (ngVersion.atLeast("8.0.0")) {
|
||||||
|
additionalProperties.put("ngPackagrVersion", "5.4.0");
|
||||||
|
additionalProperties.put("tsickleVersion", "0.35.0");
|
||||||
|
} else if (ngVersion.atLeast("7.0.0")) {
|
||||||
// compatible versions with typescript version
|
// compatible versions with typescript version
|
||||||
additionalProperties.put("ngPackagrVersion", "5.1.0");
|
additionalProperties.put("ngPackagrVersion", "5.1.0");
|
||||||
additionalProperties.put("tsickleVersion", "0.34.0");
|
additionalProperties.put("tsickleVersion", "0.34.0");
|
||||||
@@ -268,7 +274,9 @@ public class TypeScriptAngularClientCodegen extends AbstractTypeScriptClientCode
|
|||||||
}
|
}
|
||||||
|
|
||||||
// set zone.js version
|
// set zone.js version
|
||||||
if (ngVersion.atLeast("5.0.0")) {
|
if (ngVersion.atLeast("8.0.0")) {
|
||||||
|
additionalProperties.put("zonejsVersion", "0.9.1");
|
||||||
|
} else if (ngVersion.atLeast("5.0.0")) {
|
||||||
// compatible versions to Angular 5+
|
// compatible versions to Angular 5+
|
||||||
additionalProperties.put("zonejsVersion", "0.8.26");
|
additionalProperties.put("zonejsVersion", "0.8.26");
|
||||||
} else {
|
} else {
|
||||||
@@ -659,3 +667,4 @@ public class TypeScriptAngularClientCodegen extends AbstractTypeScriptClientCode
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -17,6 +17,7 @@
|
|||||||
|
|
||||||
package org.openapitools.codegen.utils;
|
package org.openapitools.codegen.utils;
|
||||||
|
|
||||||
|
import com.google.common.collect.ImmutableMap;
|
||||||
import io.swagger.v3.oas.models.OpenAPI;
|
import io.swagger.v3.oas.models.OpenAPI;
|
||||||
import io.swagger.v3.oas.models.servers.Server;
|
import io.swagger.v3.oas.models.servers.Server;
|
||||||
import io.swagger.v3.oas.models.servers.ServerVariable;
|
import io.swagger.v3.oas.models.servers.ServerVariable;
|
||||||
@@ -28,9 +29,7 @@ import org.slf4j.LoggerFactory;
|
|||||||
|
|
||||||
import java.net.MalformedURLException;
|
import java.net.MalformedURLException;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
import java.util.HashSet;
|
import java.util.*;
|
||||||
import java.util.List;
|
|
||||||
import java.util.Set;
|
|
||||||
import java.util.regex.Matcher;
|
import java.util.regex.Matcher;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
@@ -40,24 +39,28 @@ public class URLPathUtils {
|
|||||||
public static final String LOCAL_HOST = "http://localhost";
|
public static final String LOCAL_HOST = "http://localhost";
|
||||||
public static final Pattern VARIABLE_PATTERN = Pattern.compile("\\{([^\\}]+)\\}");
|
public static final Pattern VARIABLE_PATTERN = Pattern.compile("\\{([^\\}]+)\\}");
|
||||||
|
|
||||||
public static URL getServerURL(OpenAPI openAPI) {
|
// TODO: This should probably be moved into generator/workflow type rather than a static like this.
|
||||||
|
public static URL getServerURL(OpenAPI openAPI, Map<String, String> userDefinedVariables) {
|
||||||
final List<Server> servers = openAPI.getServers();
|
final List<Server> servers = openAPI.getServers();
|
||||||
if (servers == null || servers.isEmpty()) {
|
if (servers == null || servers.isEmpty()) {
|
||||||
LOGGER.warn("Server information seems not defined in the spec. Default to {}.", LOCAL_HOST);
|
LOGGER.warn("Server information seems not defined in the spec. Default to {}.", LOCAL_HOST);
|
||||||
return getDefaultUrl();
|
return getDefaultUrl();
|
||||||
}
|
}
|
||||||
// TODO need a way to obtain all server URLs
|
// TODO need a way to obtain all server URLs
|
||||||
return getServerURL(servers.get(0));
|
return getServerURL(servers.get(0), userDefinedVariables);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static URL getServerURL(final Server server) {
|
public static URL getServerURL(final Server server, final Map<String, String> userDefinedVariables) {
|
||||||
String url = server.getUrl();
|
String url = server.getUrl();
|
||||||
ServerVariables variables = server.getVariables();
|
ServerVariables variables = server.getVariables();
|
||||||
if (variables == null) {
|
if (variables == null) {
|
||||||
variables = new ServerVariables();
|
variables = new ServerVariables();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Map<String, String> userVariables = userDefinedVariables == null ? new HashMap<>() : ImmutableMap.copyOf(userDefinedVariables);
|
||||||
|
|
||||||
if (StringUtils.isNotBlank(url)) {
|
if (StringUtils.isNotBlank(url)) {
|
||||||
url = extractUrl(server, url, variables);
|
url = extractUrl(server, url, variables, userVariables);
|
||||||
url = sanitizeUrl(url);
|
url = sanitizeUrl(url);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
@@ -69,26 +72,37 @@ public class URLPathUtils {
|
|||||||
return getDefaultUrl();
|
return getDefaultUrl();
|
||||||
}
|
}
|
||||||
|
|
||||||
private static String extractUrl(Server server, String url, ServerVariables variables) {
|
private static String extractUrl(Server server, String url, ServerVariables variables, Map<String, String> userVariables) {
|
||||||
Set<String> replacedVariables = new HashSet<>();
|
Set<String> replacedVariables = new HashSet<>();
|
||||||
Matcher matcher = VARIABLE_PATTERN.matcher(url);
|
Matcher matcher = VARIABLE_PATTERN.matcher(url);
|
||||||
while (matcher.find()) {
|
while (matcher.find()) {
|
||||||
if (!replacedVariables.contains(matcher.group())) {
|
if (!replacedVariables.contains(matcher.group())) {
|
||||||
ServerVariable variable = variables.get(matcher.group(1));
|
String variableName = matcher.group(1);
|
||||||
|
ServerVariable variable = variables.get(variableName);
|
||||||
String replacement;
|
String replacement;
|
||||||
if (variable != null) {
|
if (variable != null) {
|
||||||
if (variable.getDefault() != null) {
|
String defaultValue = variable.getDefault();
|
||||||
replacement = variable.getDefault();
|
List<String> enumValues = variable.getEnum() == null ? new ArrayList<>() : variable.getEnum();
|
||||||
} else if (variable.getEnum() != null && !variable.getEnum().isEmpty()) {
|
if (defaultValue == null && !enumValues.isEmpty()) {
|
||||||
replacement = variable.getEnum().get(0);
|
defaultValue = enumValues.get(0);
|
||||||
} else {
|
} else if (defaultValue == null) {
|
||||||
LOGGER.warn("No value found for variable '{}' in server definition '{}', default to empty string.", matcher.group(1), server.getUrl());
|
defaultValue = "";
|
||||||
replacement = "";
|
}
|
||||||
|
|
||||||
|
replacement = userVariables.getOrDefault(variableName, defaultValue);
|
||||||
|
|
||||||
|
if (!enumValues.isEmpty() && !enumValues.contains(replacement)) {
|
||||||
|
LOGGER.warn("Variable override of '{}' is not listed in the enum of allowed values ({}).", replacement, StringUtils.join(enumValues, ","));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
LOGGER.warn("No variable '{}' found in server definition '{}', default to empty string.", matcher.group(1), server.getUrl());
|
replacement = userVariables.getOrDefault(variableName, "");
|
||||||
replacement = "";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (StringUtils.isEmpty(replacement)) {
|
||||||
|
replacement = "";
|
||||||
|
LOGGER.warn("No value found for variable '{}' in server definition '{}' and no user override specified, default to empty string.", variableName, server.getUrl());
|
||||||
|
}
|
||||||
|
|
||||||
url = url.replace(matcher.group(), replacement);
|
url = url.replace(matcher.group(), replacement);
|
||||||
replacedVariables.add(matcher.group());
|
replacedVariables.add(matcher.group());
|
||||||
matcher = VARIABLE_PATTERN.matcher(url);
|
matcher = VARIABLE_PATTERN.matcher(url);
|
||||||
@@ -98,7 +112,7 @@ public class URLPathUtils {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static String getScheme(OpenAPI openAPI, CodegenConfig config) {
|
public static String getScheme(OpenAPI openAPI, CodegenConfig config) {
|
||||||
URL url = getServerURL(openAPI);
|
URL url = getServerURL(openAPI, config.serverVariableOverrides());
|
||||||
return getScheme(url, config);
|
return getScheme(url, config);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -176,11 +190,12 @@ public class URLPathUtils {
|
|||||||
* Return the first complete URL from the OpenAPI specification
|
* Return the first complete URL from the OpenAPI specification
|
||||||
*
|
*
|
||||||
* @param openAPI current OpenAPI specification
|
* @param openAPI current OpenAPI specification
|
||||||
|
* @param userDefinedVariables User overrides for server variable templating
|
||||||
* @return host
|
* @return host
|
||||||
*/
|
*/
|
||||||
public static String getHost(OpenAPI openAPI) {
|
public static String getHost(OpenAPI openAPI, final Map<String, String> userDefinedVariables) {
|
||||||
if (openAPI.getServers() != null && openAPI.getServers().size() > 0) {
|
if (openAPI.getServers() != null && openAPI.getServers().size() > 0) {
|
||||||
return sanitizeUrl(getServerURL(openAPI.getServers().get(0)).toString());
|
return sanitizeUrl(getServerURL(openAPI.getServers().get(0), userDefinedVariables).toString());
|
||||||
}
|
}
|
||||||
return LOCAL_HOST;
|
return LOCAL_HOST;
|
||||||
}
|
}
|
||||||
|
|||||||
19
modules/openapi-generator/src/main/resources/Java/jackson_annotations.mustache
vendored
Normal file
19
modules/openapi-generator/src/main/resources/Java/jackson_annotations.mustache
vendored
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
{{!
|
||||||
|
If this is map and items are nullable, make sure that nulls are included.
|
||||||
|
To determine what JsonInclude.Include method to use, consider the following:
|
||||||
|
* If the field is required, always include it, even if it is null.
|
||||||
|
* Else use custom behaviour, IOW use whatever is defined on the object mapper
|
||||||
|
}}
|
||||||
|
@JsonProperty(JSON_PROPERTY_{{vendorExtensions.x-java-const-name}})
|
||||||
|
@JsonInclude({{#isMapContainer}}{{#items.isNullable}}content = JsonInclude.Include.ALWAYS, {{/items.isNullable}}{{/isMapContainer}}value = JsonInclude.Include.{{#required}}ALWAYS{{/required}}{{^required}}USE_DEFAULTS{{/required}})
|
||||||
|
{{#withXml}}
|
||||||
|
{{^isContainer}}
|
||||||
|
@JacksonXmlProperty({{#isXmlAttribute}}isAttribute = true, {{/isXmlAttribute}}{{#xmlNamespace}}namespace="{{xmlNamespace}}", {{/xmlNamespace}}localName = "{{#xmlName}}{{xmlName}}{{/xmlName}}{{^xmlName}}{{baseName}}{{/xmlName}}")
|
||||||
|
{{/isContainer}}
|
||||||
|
{{#isContainer}}
|
||||||
|
{{#isXmlWrapped}}
|
||||||
|
// items.xmlName={{items.xmlName}}
|
||||||
|
@JacksonXmlElementWrapper(useWrapping = {{isXmlWrapped}}, {{#xmlNamespace}}namespace="{{xmlNamespace}}", {{/xmlNamespace}}localName = "{{#items.xmlName}}{{items.xmlName}}{{/items.xmlName}}{{^items.xmlName}}{{items.baseName}}{{/items.xmlName}}")
|
||||||
|
{{/isXmlWrapped}}
|
||||||
|
{{/isContainer}}
|
||||||
|
{{/withXml}}
|
||||||
@@ -12,6 +12,7 @@ import org.threeten.bp.*;
|
|||||||
import com.fasterxml.jackson.databind.DeserializationFeature;
|
import com.fasterxml.jackson.databind.DeserializationFeature;
|
||||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
import com.fasterxml.jackson.databind.SerializationFeature;
|
import com.fasterxml.jackson.databind.SerializationFeature;
|
||||||
|
import org.openapitools.jackson.nullable.JsonNullableModule;
|
||||||
{{#joda}}
|
{{#joda}}
|
||||||
import com.fasterxml.jackson.datatype.joda.JodaModule;
|
import com.fasterxml.jackson.datatype.joda.JodaModule;
|
||||||
{{/joda}}
|
{{/joda}}
|
||||||
@@ -177,6 +178,8 @@ public class ApiClient {
|
|||||||
module.addDeserializer(ZonedDateTime.class, CustomInstantDeserializer.ZONED_DATE_TIME);
|
module.addDeserializer(ZonedDateTime.class, CustomInstantDeserializer.ZONED_DATE_TIME);
|
||||||
objectMapper.registerModule(module);
|
objectMapper.registerModule(module);
|
||||||
{{/threetenbp}}
|
{{/threetenbp}}
|
||||||
|
JsonNullableModule jnm = new JsonNullableModule();
|
||||||
|
objectMapper.registerModule(jnm);
|
||||||
return objectMapper;
|
return objectMapper;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -244,6 +244,11 @@
|
|||||||
<artifactId>jackson-databind</artifactId>
|
<artifactId>jackson-databind</artifactId>
|
||||||
<version>${jackson-databind-version}</version>
|
<version>${jackson-databind-version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.openapitools</groupId>
|
||||||
|
<artifactId>jackson-databind-nullable</artifactId>
|
||||||
|
<version>${jackson-databind-nullable-version}</version>
|
||||||
|
</dependency>
|
||||||
{{#withXml}}
|
{{#withXml}}
|
||||||
|
|
||||||
<!-- XML Support -->
|
<!-- XML Support -->
|
||||||
@@ -310,6 +315,7 @@
|
|||||||
<feign-version>{{#useFeign10}}10.2.3{{/useFeign10}}{{^useFeign10}}9.7.0{{/useFeign10}}</feign-version>
|
<feign-version>{{#useFeign10}}10.2.3{{/useFeign10}}{{^useFeign10}}9.7.0{{/useFeign10}}</feign-version>
|
||||||
<feign-form-version>2.1.0</feign-form-version>
|
<feign-form-version>2.1.0</feign-form-version>
|
||||||
<jackson-version>2.9.9</jackson-version>
|
<jackson-version>2.9.9</jackson-version>
|
||||||
|
<jackson-databind-nullable-version>0.2.0</jackson-databind-nullable-version>
|
||||||
<jackson-databind-version>2.9.9</jackson-databind-version>
|
<jackson-databind-version>2.9.9</jackson-databind-version>
|
||||||
{{#threetenbp}}
|
{{#threetenbp}}
|
||||||
<jackson-threetenbp-version>2.6.4</jackson-threetenbp-version>
|
<jackson-threetenbp-version>2.6.4</jackson-threetenbp-version>
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import {{apiPackage}}.*;
|
|||||||
import com.fasterxml.jackson.databind.DeserializationFeature;
|
import com.fasterxml.jackson.databind.DeserializationFeature;
|
||||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
import com.fasterxml.jackson.databind.SerializationFeature;
|
import com.fasterxml.jackson.databind.SerializationFeature;
|
||||||
|
import org.openapitools.jackson.nullable.JsonNullableModule;
|
||||||
{{#joda}}
|
{{#joda}}
|
||||||
import com.fasterxml.jackson.datatype.joda.JodaModule;
|
import com.fasterxml.jackson.datatype.joda.JodaModule;
|
||||||
{{/joda}}
|
{{/joda}}
|
||||||
@@ -53,6 +54,8 @@ public class ApiClient {
|
|||||||
module.addDeserializer(ZonedDateTime.class, CustomInstantDeserializer.ZONED_DATE_TIME);
|
module.addDeserializer(ZonedDateTime.class, CustomInstantDeserializer.ZONED_DATE_TIME);
|
||||||
objectMapper.registerModule(module);
|
objectMapper.registerModule(module);
|
||||||
{{/threetenbp}}
|
{{/threetenbp}}
|
||||||
|
JsonNullableModule jnm = new JsonNullableModule();
|
||||||
|
objectMapper.registerModule(jnm);
|
||||||
return objectMapper;
|
return objectMapper;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -104,8 +104,8 @@ public class {{classname}} {
|
|||||||
}
|
}
|
||||||
}{{/queryParams}}{{/hasQueryParams}}
|
}{{/queryParams}}{{/hasQueryParams}}
|
||||||
|
|
||||||
String url = uriBuilder{{#hasPathParams}}.buildFromMap(uriVariables).toString();{{/hasPathParams}}{{^hasPathParams}}.build().toString();{{/hasPathParams}}
|
String localVarUrl = uriBuilder{{#hasPathParams}}.buildFromMap(uriVariables).toString();{{/hasPathParams}}{{^hasPathParams}}.build().toString();{{/hasPathParams}}
|
||||||
GenericUrl genericUrl = new GenericUrl(url);
|
GenericUrl genericUrl = new GenericUrl(localVarUrl);
|
||||||
|
|
||||||
HttpContent content = {{#isBodyAllowed}}apiClient.new JacksonJsonHttpContent({{#bodyParam}}{{paramName}}{{/bodyParam}}{{^bodyParam}}null{{/bodyParam}}){{/isBodyAllowed}}{{^isBodyAllowed}}null{{/isBodyAllowed}};
|
HttpContent content = {{#isBodyAllowed}}apiClient.new JacksonJsonHttpContent({{#bodyParam}}{{paramName}}{{/bodyParam}}{{^bodyParam}}null{{/bodyParam}}){{/isBodyAllowed}}{{^isBodyAllowed}}null{{/isBodyAllowed}};
|
||||||
return apiClient.getHttpRequestFactory().buildRequest(HttpMethods.{{httpMethod}}, genericUrl, content).execute();
|
return apiClient.getHttpRequestFactory().buildRequest(HttpMethods.{{httpMethod}}, genericUrl, content).execute();
|
||||||
@@ -135,8 +135,8 @@ public class {{classname}} {
|
|||||||
}
|
}
|
||||||
}{{/queryParams}}{{/hasQueryParams}}
|
}{{/queryParams}}{{/hasQueryParams}}
|
||||||
|
|
||||||
String url = uriBuilder{{#hasPathParams}}.buildFromMap(uriVariables).toString();{{/hasPathParams}}{{^hasPathParams}}.build().toString();{{/hasPathParams}}
|
String localVarUrl = uriBuilder{{#hasPathParams}}.buildFromMap(uriVariables).toString();{{/hasPathParams}}{{^hasPathParams}}.build().toString();{{/hasPathParams}}
|
||||||
GenericUrl genericUrl = new GenericUrl(url);
|
GenericUrl genericUrl = new GenericUrl(localVarUrl);
|
||||||
|
|
||||||
HttpContent content = {{#bodyParam}}{{paramName}} == null ?
|
HttpContent content = {{#bodyParam}}{{paramName}} == null ?
|
||||||
apiClient.new JacksonJsonHttpContent(null) :
|
apiClient.new JacksonJsonHttpContent(null) :
|
||||||
@@ -176,8 +176,8 @@ public class {{classname}} {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
String url = uriBuilder{{#hasPathParams}}.buildFromMap(uriVariables).toString();{{/hasPathParams}}{{^hasPathParams}}.build().toString();{{/hasPathParams}}
|
String localVarUrl = uriBuilder{{#hasPathParams}}.buildFromMap(uriVariables).toString();{{/hasPathParams}}{{^hasPathParams}}.build().toString();{{/hasPathParams}}
|
||||||
GenericUrl genericUrl = new GenericUrl(url);
|
GenericUrl genericUrl = new GenericUrl(localVarUrl);
|
||||||
|
|
||||||
HttpContent content = {{#isBodyAllowed}}apiClient.new JacksonJsonHttpContent({{#bodyParam}}{{paramName}}{{/bodyParam}}{{^bodyParam}}null{{/bodyParam}}){{/isBodyAllowed}}{{^isBodyAllowed}}null{{/isBodyAllowed}};
|
HttpContent content = {{#isBodyAllowed}}apiClient.new JacksonJsonHttpContent({{#bodyParam}}{{paramName}}{{/bodyParam}}{{^bodyParam}}null{{/bodyParam}}){{/isBodyAllowed}}{{^isBodyAllowed}}null{{/isBodyAllowed}};
|
||||||
return apiClient.getHttpRequestFactory().buildRequest(HttpMethods.{{httpMethod}}, genericUrl, content).execute();
|
return apiClient.getHttpRequestFactory().buildRequest(HttpMethods.{{httpMethod}}, genericUrl, content).execute();
|
||||||
|
|||||||
@@ -253,6 +253,11 @@
|
|||||||
<artifactId>jackson-databind</artifactId>
|
<artifactId>jackson-databind</artifactId>
|
||||||
<version>${jackson-version}</version>
|
<version>${jackson-version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.openapitools</groupId>
|
||||||
|
<artifactId>jackson-databind-nullable</artifactId>
|
||||||
|
<version>${jackson-databind-nullable-version}</version>
|
||||||
|
</dependency>
|
||||||
{{#withXml}}
|
{{#withXml}}
|
||||||
<!-- XML processing: Jackson -->
|
<!-- XML processing: Jackson -->
|
||||||
<dependency>
|
<dependency>
|
||||||
@@ -303,6 +308,7 @@
|
|||||||
<jersey-common-version>2.25.1</jersey-common-version>
|
<jersey-common-version>2.25.1</jersey-common-version>
|
||||||
<jackson-version>2.9.9</jackson-version>
|
<jackson-version>2.9.9</jackson-version>
|
||||||
<jackson-databind-version>2.9.9</jackson-databind-version>
|
<jackson-databind-version>2.9.9</jackson-databind-version>
|
||||||
|
<jackson-databind-nullable-version>0.2.0</jackson-databind-nullable-version>
|
||||||
{{#joda}}
|
{{#joda}}
|
||||||
<jodatime-version>2.9.9</jodatime-version>
|
<jodatime-version>2.9.9</jodatime-version>
|
||||||
{{/joda}}
|
{{/joda}}
|
||||||
|
|||||||
@@ -721,6 +721,8 @@ public class ApiClient {
|
|||||||
response = invocationBuilder.method("PATCH", entity);
|
response = invocationBuilder.method("PATCH", entity);
|
||||||
} else if ("HEAD".equals(method)) {
|
} else if ("HEAD".equals(method)) {
|
||||||
response = invocationBuilder.head();
|
response = invocationBuilder.head();
|
||||||
|
} else if ("TRACE".equals(method)) {
|
||||||
|
response = invocationBuilder.trace();
|
||||||
} else {
|
} else {
|
||||||
throw new ApiException(500, "unknown method type " + method);
|
throw new ApiException(500, "unknown method type " + method);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import org.threeten.bp.*;
|
|||||||
{{/threetenbp}}
|
{{/threetenbp}}
|
||||||
import com.fasterxml.jackson.annotation.*;
|
import com.fasterxml.jackson.annotation.*;
|
||||||
import com.fasterxml.jackson.databind.*;
|
import com.fasterxml.jackson.databind.*;
|
||||||
|
import org.openapitools.jackson.nullable.JsonNullableModule;
|
||||||
{{#java8}}
|
{{#java8}}
|
||||||
import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule;
|
import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule;
|
||||||
{{/java8}}
|
{{/java8}}
|
||||||
@@ -45,6 +46,8 @@ public class JSON implements ContextResolver<ObjectMapper> {
|
|||||||
module.addDeserializer(ZonedDateTime.class, CustomInstantDeserializer.ZONED_DATE_TIME);
|
module.addDeserializer(ZonedDateTime.class, CustomInstantDeserializer.ZONED_DATE_TIME);
|
||||||
mapper.registerModule(module);
|
mapper.registerModule(module);
|
||||||
{{/threetenbp}}
|
{{/threetenbp}}
|
||||||
|
JsonNullableModule jnm = new JsonNullableModule();
|
||||||
|
mapper.registerModule(jnm);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -276,6 +276,11 @@
|
|||||||
<artifactId>jackson-databind</artifactId>
|
<artifactId>jackson-databind</artifactId>
|
||||||
<version>${jackson-databind-version}</version>
|
<version>${jackson-databind-version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.openapitools</groupId>
|
||||||
|
<artifactId>jackson-databind-nullable</artifactId>
|
||||||
|
<version>${jackson-databind-nullable-version}</version>
|
||||||
|
</dependency>
|
||||||
{{#withXml}}
|
{{#withXml}}
|
||||||
|
|
||||||
<!-- XML processing: JAXB -->
|
<!-- XML processing: JAXB -->
|
||||||
@@ -357,6 +362,7 @@
|
|||||||
{{/supportJava6}}
|
{{/supportJava6}}
|
||||||
<jackson-version>2.9.9</jackson-version>
|
<jackson-version>2.9.9</jackson-version>
|
||||||
<jackson-databind-version>2.9.9</jackson-databind-version>
|
<jackson-databind-version>2.9.9</jackson-databind-version>
|
||||||
|
<jackson-databind-nullable-version>0.2.0</jackson-databind-nullable-version>
|
||||||
{{#threetenbp}}
|
{{#threetenbp}}
|
||||||
<threetenbp-version>2.6.4</threetenbp-version>
|
<threetenbp-version>2.6.4</threetenbp-version>
|
||||||
{{/threetenbp}}
|
{{/threetenbp}}
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ import com.fasterxml.jackson.databind.DeserializationFeature;
|
|||||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
import com.fasterxml.jackson.databind.SerializationFeature;
|
import com.fasterxml.jackson.databind.SerializationFeature;
|
||||||
import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule;
|
import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule;
|
||||||
|
import org.openapitools.jackson.nullable.JsonNullableModule;
|
||||||
|
|
||||||
import java.net.URI;
|
import java.net.URI;
|
||||||
import java.net.URLEncoder;
|
import java.net.URLEncoder;
|
||||||
@@ -151,6 +152,8 @@ public class ApiClient {
|
|||||||
mapper.enable(SerializationFeature.WRITE_ENUMS_USING_TO_STRING);
|
mapper.enable(SerializationFeature.WRITE_ENUMS_USING_TO_STRING);
|
||||||
mapper.enable(DeserializationFeature.READ_ENUMS_USING_TO_STRING);
|
mapper.enable(DeserializationFeature.READ_ENUMS_USING_TO_STRING);
|
||||||
mapper.registerModule(new JavaTimeModule());
|
mapper.registerModule(new JavaTimeModule());
|
||||||
|
JsonNullableModule jnm = new JsonNullableModule();
|
||||||
|
mapper.registerModule(jnm);
|
||||||
URI baseURI = URI.create("{{{basePath}}}");
|
URI baseURI = URI.create("{{{basePath}}}");
|
||||||
scheme = baseURI.getScheme();
|
scheme = baseURI.getScheme();
|
||||||
host = baseURI.getHost();
|
host = baseURI.getHost();
|
||||||
|
|||||||
@@ -0,0 +1 @@
|
|||||||
|
{{^hideGenerationTimestamp}}@javax.annotation.processing.Generated(value = "{{generatorClass}}", date = "{{generatedDate}}"){{/hideGenerationTimestamp}}
|
||||||
@@ -188,6 +188,11 @@
|
|||||||
<artifactId>jackson-datatype-jsr310</artifactId>
|
<artifactId>jackson-datatype-jsr310</artifactId>
|
||||||
<version>${jackson-version}</version>
|
<version>${jackson-version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.openapitools</groupId>
|
||||||
|
<artifactId>jackson-databind-nullable</artifactId>
|
||||||
|
<version>${jackson-databind-nullable-version}</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
<!-- @Nullable annotation -->
|
<!-- @Nullable annotation -->
|
||||||
<dependency>
|
<dependency>
|
||||||
@@ -210,6 +215,7 @@
|
|||||||
<maven.compiler.source>11</maven.compiler.source>
|
<maven.compiler.source>11</maven.compiler.source>
|
||||||
<maven.compiler.target>11</maven.compiler.target>
|
<maven.compiler.target>11</maven.compiler.target>
|
||||||
<jackson-version>2.9.9</jackson-version>
|
<jackson-version>2.9.9</jackson-version>
|
||||||
|
<jackson-databind-nullable-version>0.2.0</jackson-databind-nullable-version>
|
||||||
<junit-version>4.12</junit-version>
|
<junit-version>4.12</junit-version>
|
||||||
</properties>
|
</properties>
|
||||||
</project>
|
</project>
|
||||||
|
|||||||
@@ -666,6 +666,8 @@ public class ApiClient {
|
|||||||
response = invocationBuilder.header("X-HTTP-Method-Override", "PATCH").post(entity);
|
response = invocationBuilder.header("X-HTTP-Method-Override", "PATCH").post(entity);
|
||||||
} else if ("HEAD".equals(method)) {
|
} else if ("HEAD".equals(method)) {
|
||||||
response = invocationBuilder.head();
|
response = invocationBuilder.head();
|
||||||
|
} else if ("TRACE".equals(method)) {
|
||||||
|
response = invocationBuilder.trace();
|
||||||
} else {
|
} else {
|
||||||
throw new ApiException(500, "unknown method type " + method);
|
throw new ApiException(500, "unknown method type " + method);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ package {{invokerPackage}};
|
|||||||
|
|
||||||
import com.fasterxml.jackson.annotation.*;
|
import com.fasterxml.jackson.annotation.*;
|
||||||
import com.fasterxml.jackson.databind.*;
|
import com.fasterxml.jackson.databind.*;
|
||||||
|
import org.openapitools.jackson.nullable.JsonNullableModule;
|
||||||
{{#java8}}
|
{{#java8}}
|
||||||
import com.fasterxml.jackson.datatype.jsr310.*;
|
import com.fasterxml.jackson.datatype.jsr310.*;
|
||||||
{{/java8}}
|
{{/java8}}
|
||||||
@@ -26,6 +27,8 @@ public class JSON implements ContextResolver<ObjectMapper> {
|
|||||||
mapper.enable(SerializationFeature.WRITE_ENUMS_USING_TO_STRING);
|
mapper.enable(SerializationFeature.WRITE_ENUMS_USING_TO_STRING);
|
||||||
mapper.enable(DeserializationFeature.READ_ENUMS_USING_TO_STRING);
|
mapper.enable(DeserializationFeature.READ_ENUMS_USING_TO_STRING);
|
||||||
mapper.setDateFormat(new RFC3339DateFormat());
|
mapper.setDateFormat(new RFC3339DateFormat());
|
||||||
|
JsonNullableModule jnm = new JsonNullableModule();
|
||||||
|
mapper.registerModule(jnm);
|
||||||
{{#java8}}
|
{{#java8}}
|
||||||
mapper.registerModule(new JavaTimeModule());
|
mapper.registerModule(new JavaTimeModule());
|
||||||
{{/java8}}
|
{{/java8}}
|
||||||
|
|||||||
@@ -212,6 +212,11 @@
|
|||||||
<artifactId>jackson-databind</artifactId>
|
<artifactId>jackson-databind</artifactId>
|
||||||
<version>${jackson-databind-version}</version>
|
<version>${jackson-databind-version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.openapitools</groupId>
|
||||||
|
<artifactId>jackson-databind-nullable</artifactId>
|
||||||
|
<version>${jackson-databind-nullable-version}</version>
|
||||||
|
</dependency>
|
||||||
{{#withXml}}
|
{{#withXml}}
|
||||||
|
|
||||||
<!-- XML processing: Jackson -->
|
<!-- XML processing: Jackson -->
|
||||||
@@ -291,6 +296,7 @@
|
|||||||
<resteasy-version>3.1.3.Final</resteasy-version>
|
<resteasy-version>3.1.3.Final</resteasy-version>
|
||||||
<jackson-version>2.9.9</jackson-version>
|
<jackson-version>2.9.9</jackson-version>
|
||||||
<jackson-databind-version>2.9.9</jackson-databind-version>
|
<jackson-databind-version>2.9.9</jackson-databind-version>
|
||||||
|
<jackson-databind-nullable-version>0.2.0</jackson-databind-nullable-version>
|
||||||
<threetenbp-version>2.6.4</threetenbp-version>
|
<threetenbp-version>2.6.4</threetenbp-version>
|
||||||
{{^java8}}
|
{{^java8}}
|
||||||
<jodatime-version>2.9.9</jodatime-version>
|
<jodatime-version>2.9.9</jodatime-version>
|
||||||
|
|||||||
@@ -39,6 +39,7 @@ import com.fasterxml.jackson.datatype.threetenbp.ThreeTenModule;
|
|||||||
import org.springframework.http.converter.HttpMessageConverter;
|
import org.springframework.http.converter.HttpMessageConverter;
|
||||||
import org.springframework.http.converter.json.AbstractJackson2HttpMessageConverter;
|
import org.springframework.http.converter.json.AbstractJackson2HttpMessageConverter;
|
||||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
|
import org.openapitools.jackson.nullable.JsonNullableModule;
|
||||||
{{/threetenbp}}
|
{{/threetenbp}}
|
||||||
|
|
||||||
import java.io.BufferedReader;
|
import java.io.BufferedReader;
|
||||||
@@ -661,6 +662,7 @@ public class ApiClient {
|
|||||||
messageConverters.add(new MappingJackson2HttpMessageConverter());
|
messageConverters.add(new MappingJackson2HttpMessageConverter());
|
||||||
XmlMapper xmlMapper = new XmlMapper();
|
XmlMapper xmlMapper = new XmlMapper();
|
||||||
xmlMapper.configure(ToXmlGenerator.Feature.WRITE_XML_DECLARATION, true);
|
xmlMapper.configure(ToXmlGenerator.Feature.WRITE_XML_DECLARATION, true);
|
||||||
|
xmlMapper.registerModule(new JsonNullableModule());
|
||||||
messageConverters.add(new MappingJackson2XmlHttpMessageConverter(xmlMapper));
|
messageConverters.add(new MappingJackson2XmlHttpMessageConverter(xmlMapper));
|
||||||
|
|
||||||
RestTemplate restTemplate = new RestTemplate(messageConverters);
|
RestTemplate restTemplate = new RestTemplate(messageConverters);
|
||||||
@@ -674,6 +676,7 @@ public class ApiClient {
|
|||||||
module.addDeserializer(OffsetDateTime.class, CustomInstantDeserializer.OFFSET_DATE_TIME);
|
module.addDeserializer(OffsetDateTime.class, CustomInstantDeserializer.OFFSET_DATE_TIME);
|
||||||
module.addDeserializer(ZonedDateTime.class, CustomInstantDeserializer.ZONED_DATE_TIME);
|
module.addDeserializer(ZonedDateTime.class, CustomInstantDeserializer.ZONED_DATE_TIME);
|
||||||
mapper.registerModule(module);
|
mapper.registerModule(module);
|
||||||
|
mapper.registerModule(new JsonNullableModule());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
{{/threetenbp}}
|
{{/threetenbp}}
|
||||||
|
|||||||
@@ -255,6 +255,11 @@
|
|||||||
<artifactId>jackson-jaxrs-json-provider</artifactId>
|
<artifactId>jackson-jaxrs-json-provider</artifactId>
|
||||||
<version>${jackson-version}</version>
|
<version>${jackson-version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.openapitools</groupId>
|
||||||
|
<artifactId>jackson-databind-nullable</artifactId>
|
||||||
|
<version>${jackson-databind-nullable-version}</version>
|
||||||
|
</dependency>
|
||||||
{{#withXml}}
|
{{#withXml}}
|
||||||
|
|
||||||
<!-- XML processing: Jackson -->
|
<!-- XML processing: Jackson -->
|
||||||
@@ -306,6 +311,7 @@
|
|||||||
<spring-web-version>4.3.9.RELEASE</spring-web-version>
|
<spring-web-version>4.3.9.RELEASE</spring-web-version>
|
||||||
<jackson-version>2.9.9</jackson-version>
|
<jackson-version>2.9.9</jackson-version>
|
||||||
<jackson-databind-version>2.9.9</jackson-databind-version>
|
<jackson-databind-version>2.9.9</jackson-databind-version>
|
||||||
|
<jackson-databind-nullable-version>0.2.0</jackson-databind-nullable-version>
|
||||||
{{#joda}}
|
{{#joda}}
|
||||||
<jodatime-version>2.9.9</jodatime-version>
|
<jodatime-version>2.9.9</jodatime-version>
|
||||||
{{/joda}}
|
{{/joda}}
|
||||||
|
|||||||
@@ -35,6 +35,10 @@ public class CollectionFormats {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static class SPACEParams extends SSVParams {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
public static class SSVParams extends CSVParams {
|
public static class SSVParams extends CSVParams {
|
||||||
|
|
||||||
public SSVParams() {
|
public SSVParams() {
|
||||||
|
|||||||
@@ -35,6 +35,10 @@ public class CollectionFormats {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static class SPACEParams extends SSVParams {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
public static class SSVParams extends CSVParams {
|
public static class SSVParams extends CSVParams {
|
||||||
|
|
||||||
public SSVParams() {
|
public SSVParams() {
|
||||||
|
|||||||
@@ -8,6 +8,8 @@ import java.util.*;
|
|||||||
import retrofit2.Retrofit;
|
import retrofit2.Retrofit;
|
||||||
import retrofit2.converter.scalars.ScalarsConverterFactory;
|
import retrofit2.converter.scalars.ScalarsConverterFactory;
|
||||||
import retrofit2.converter.jackson.JacksonConverterFactory;
|
import retrofit2.converter.jackson.JacksonConverterFactory;
|
||||||
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
|
import org.openapitools.jackson.nullable.JsonNullableModule;
|
||||||
|
|
||||||
import play.libs.Json;
|
import play.libs.Json;
|
||||||
import play.libs.ws.WSClient;
|
import play.libs.ws.WSClient;
|
||||||
@@ -68,10 +70,14 @@ public class ApiClient {
|
|||||||
auth.applyToParams(extraQueryParams, extraHeaders);
|
auth.applyToParams(extraQueryParams, extraHeaders);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ObjectMapper mapper = Json.mapper();
|
||||||
|
JsonNullableModule jnm = new JsonNullableModule();
|
||||||
|
mapper.registerModule(jnm);
|
||||||
|
|
||||||
return new Retrofit.Builder()
|
return new Retrofit.Builder()
|
||||||
.baseUrl(basePath)
|
.baseUrl(basePath)
|
||||||
.addConverterFactory(ScalarsConverterFactory.create())
|
.addConverterFactory(ScalarsConverterFactory.create())
|
||||||
.addConverterFactory(JacksonConverterFactory.create(Json.mapper()))
|
.addConverterFactory(JacksonConverterFactory.create(mapper))
|
||||||
.callFactory(new Play24CallFactory(wsClient, extraHeaders, extraQueryParams))
|
.callFactory(new Play24CallFactory(wsClient, extraHeaders, extraQueryParams))
|
||||||
.addCallAdapterFactory(new Play24CallAdapterFactory())
|
.addCallAdapterFactory(new Play24CallAdapterFactory())
|
||||||
.build()
|
.build()
|
||||||
|
|||||||
@@ -8,6 +8,8 @@ import java.util.*;
|
|||||||
import retrofit2.Retrofit;
|
import retrofit2.Retrofit;
|
||||||
import retrofit2.converter.scalars.ScalarsConverterFactory;
|
import retrofit2.converter.scalars.ScalarsConverterFactory;
|
||||||
import retrofit2.converter.jackson.JacksonConverterFactory;
|
import retrofit2.converter.jackson.JacksonConverterFactory;
|
||||||
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
|
import org.openapitools.jackson.nullable.JsonNullableModule;
|
||||||
|
|
||||||
import play.libs.Json;
|
import play.libs.Json;
|
||||||
import play.libs.ws.WSClient;
|
import play.libs.ws.WSClient;
|
||||||
@@ -67,10 +69,14 @@ public class ApiClient {
|
|||||||
auth.applyToParams(extraQueryParams, extraHeaders);
|
auth.applyToParams(extraQueryParams, extraHeaders);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ObjectMapper mapper = Json.mapper();
|
||||||
|
JsonNullableModule jnm = new JsonNullableModule();
|
||||||
|
mapper.registerModule(jnm);
|
||||||
|
|
||||||
return new Retrofit.Builder()
|
return new Retrofit.Builder()
|
||||||
.baseUrl(basePath)
|
.baseUrl(basePath)
|
||||||
.addConverterFactory(ScalarsConverterFactory.create())
|
.addConverterFactory(ScalarsConverterFactory.create())
|
||||||
.addConverterFactory(JacksonConverterFactory.create(Json.mapper()))
|
.addConverterFactory(JacksonConverterFactory.create(mapper))
|
||||||
.callFactory(new Play25CallFactory(wsClient, extraHeaders, extraQueryParams))
|
.callFactory(new Play25CallFactory(wsClient, extraHeaders, extraQueryParams))
|
||||||
.addCallAdapterFactory(new Play25CallAdapterFactory())
|
.addCallAdapterFactory(new Play25CallAdapterFactory())
|
||||||
.build()
|
.build()
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ import retrofit2.Converter;
|
|||||||
import retrofit2.Retrofit;
|
import retrofit2.Retrofit;
|
||||||
import retrofit2.converter.scalars.ScalarsConverterFactory;
|
import retrofit2.converter.scalars.ScalarsConverterFactory;
|
||||||
import retrofit2.converter.jackson.JacksonConverterFactory;
|
import retrofit2.converter.jackson.JacksonConverterFactory;
|
||||||
|
import org.openapitools.jackson.nullable.JsonNullableModule;
|
||||||
|
|
||||||
import play.libs.Json;
|
import play.libs.Json;
|
||||||
import play.libs.ws.WSClient;
|
import play.libs.ws.WSClient;
|
||||||
@@ -89,6 +90,8 @@ public class ApiClient {
|
|||||||
}
|
}
|
||||||
if (defaultMapper == null) {
|
if (defaultMapper == null) {
|
||||||
defaultMapper = Json.mapper();
|
defaultMapper = Json.mapper();
|
||||||
|
JsonNullableModule jnm = new JsonNullableModule();
|
||||||
|
defaultMapper.registerModule(jnm);
|
||||||
}
|
}
|
||||||
|
|
||||||
return new Retrofit.Builder()
|
return new Retrofit.Builder()
|
||||||
|
|||||||
@@ -314,6 +314,11 @@
|
|||||||
<artifactId>play-java-ws_2.11</artifactId>
|
<artifactId>play-java-ws_2.11</artifactId>
|
||||||
<version>${play-version}</version>
|
<version>${play-version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.openapitools</groupId>
|
||||||
|
<artifactId>jackson-databind-nullable</artifactId>
|
||||||
|
<version>${jackson-databind-nullable-version}</version>
|
||||||
|
</dependency>
|
||||||
{{/play24}}
|
{{/play24}}
|
||||||
{{#play25}}
|
{{#play25}}
|
||||||
<dependency>
|
<dependency>
|
||||||
@@ -321,6 +326,11 @@
|
|||||||
<artifactId>play-java-ws_2.11</artifactId>
|
<artifactId>play-java-ws_2.11</artifactId>
|
||||||
<version>${play-version}</version>
|
<version>${play-version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.openapitools</groupId>
|
||||||
|
<artifactId>jackson-databind-nullable</artifactId>
|
||||||
|
<version>${jackson-databind-nullable-version}</version>
|
||||||
|
</dependency>
|
||||||
{{/play25}}
|
{{/play25}}
|
||||||
{{#play26}}
|
{{#play26}}
|
||||||
<dependency>
|
<dependency>
|
||||||
@@ -333,6 +343,11 @@
|
|||||||
<artifactId>validation-api</artifactId>
|
<artifactId>validation-api</artifactId>
|
||||||
<version>1.1.0.Final</version>
|
<version>1.1.0.Final</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.openapitools</groupId>
|
||||||
|
<artifactId>jackson-databind-nullable</artifactId>
|
||||||
|
<version>${jackson-databind-nullable-version}</version>
|
||||||
|
</dependency>
|
||||||
{{/play26}}
|
{{/play26}}
|
||||||
{{/usePlayWS}}
|
{{/usePlayWS}}
|
||||||
{{#parcelableModel}}
|
{{#parcelableModel}}
|
||||||
@@ -373,6 +388,7 @@
|
|||||||
<jackson-version>2.9.9</jackson-version>
|
<jackson-version>2.9.9</jackson-version>
|
||||||
<play-version>2.6.7</play-version>
|
<play-version>2.6.7</play-version>
|
||||||
{{/play26}}
|
{{/play26}}
|
||||||
|
<jackson-databind-nullable-version>0.2.0</jackson-databind-nullable-version>
|
||||||
{{/usePlayWS}}
|
{{/usePlayWS}}
|
||||||
<retrofit-version>2.5.0</retrofit-version>
|
<retrofit-version>2.5.0</retrofit-version>
|
||||||
{{#useRxJava}}
|
{{#useRxJava}}
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ import com.fasterxml.jackson.databind.DeserializationFeature;
|
|||||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
import com.fasterxml.jackson.databind.SerializationFeature;
|
import com.fasterxml.jackson.databind.SerializationFeature;
|
||||||
import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule;
|
import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule;
|
||||||
|
import org.openapitools.jackson.nullable.JsonNullableModule;
|
||||||
import io.vertx.core.*;
|
import io.vertx.core.*;
|
||||||
import io.vertx.core.buffer.Buffer;
|
import io.vertx.core.buffer.Buffer;
|
||||||
import io.vertx.core.file.AsyncFile;
|
import io.vertx.core.file.AsyncFile;
|
||||||
@@ -77,6 +78,8 @@ public class ApiClient {
|
|||||||
this.objectMapper.enable(DeserializationFeature.READ_ENUMS_USING_TO_STRING);
|
this.objectMapper.enable(DeserializationFeature.READ_ENUMS_USING_TO_STRING);
|
||||||
this.objectMapper.registerModule(new JavaTimeModule());
|
this.objectMapper.registerModule(new JavaTimeModule());
|
||||||
this.objectMapper.setDateFormat(dateFormat);
|
this.objectMapper.setDateFormat(dateFormat);
|
||||||
|
JsonNullableModule jnm = new JsonNullableModule();
|
||||||
|
this.objectMapper.registerModule(jnm);
|
||||||
|
|
||||||
// Setup authentications (key: authentication name, value: authentication).
|
// Setup authentications (key: authentication name, value: authentication).
|
||||||
this.authentications = new HashMap<>();{{#authMethods}}{{#isBasic}}{{#isBasicBasic}}
|
this.authentications = new HashMap<>();{{#authMethods}}{{#isBasic}}{{#isBasicBasic}}
|
||||||
|
|||||||
@@ -243,6 +243,11 @@
|
|||||||
<artifactId>jackson-databind</artifactId>
|
<artifactId>jackson-databind</artifactId>
|
||||||
<version>${jackson-databind}</version>
|
<version>${jackson-databind}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.openapitools</groupId>
|
||||||
|
<artifactId>jackson-databind-nullable</artifactId>
|
||||||
|
<version>${jackson-databind-nullable-version}</version>
|
||||||
|
</dependency>
|
||||||
{{#joda}}
|
{{#joda}}
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.fasterxml.jackson.datatype</groupId>
|
<groupId>com.fasterxml.jackson.datatype</groupId>
|
||||||
@@ -286,6 +291,7 @@
|
|||||||
<swagger-annotations-version>1.5.22</swagger-annotations-version>
|
<swagger-annotations-version>1.5.22</swagger-annotations-version>
|
||||||
<jackson-version>{{^threetenbp}}2.9.9{{/threetenbp}}{{#threetenbp}}2.6.4{{/threetenbp}}</jackson-version>
|
<jackson-version>{{^threetenbp}}2.9.9{{/threetenbp}}{{#threetenbp}}2.6.4{{/threetenbp}}</jackson-version>
|
||||||
<jackson-databind>{{^threetenbp}}2.9.9{{/threetenbp}}{{#threetenbp}}2.6.4{{/threetenbp}}</jackson-databind>
|
<jackson-databind>{{^threetenbp}}2.9.9{{/threetenbp}}{{#threetenbp}}2.6.4{{/threetenbp}}</jackson-databind>
|
||||||
|
<jackson-databind-nullable-version>0.2.0</jackson-databind-nullable-version>
|
||||||
<junit-version>4.12</junit-version>
|
<junit-version>4.12</junit-version>
|
||||||
</properties>
|
</properties>
|
||||||
</project>
|
</project>
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ package {{invokerPackage}};
|
|||||||
import com.fasterxml.jackson.databind.DeserializationFeature;
|
import com.fasterxml.jackson.databind.DeserializationFeature;
|
||||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule;
|
import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule;
|
||||||
|
import org.openapitools.jackson.nullable.JsonNullableModule;
|
||||||
import org.apache.commons.logging.Log;
|
import org.apache.commons.logging.Log;
|
||||||
import org.apache.commons.logging.LogFactory;
|
import org.apache.commons.logging.LogFactory;
|
||||||
import org.springframework.core.ParameterizedTypeReference;
|
import org.springframework.core.ParameterizedTypeReference;
|
||||||
@@ -96,6 +97,8 @@ public class ApiClient {
|
|||||||
mapper.setDateFormat(dateFormat);
|
mapper.setDateFormat(dateFormat);
|
||||||
mapper.registerModule(new JavaTimeModule());
|
mapper.registerModule(new JavaTimeModule());
|
||||||
mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
|
mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
|
||||||
|
JsonNullableModule jnm = new JsonNullableModule();
|
||||||
|
mapper.registerModule(jnm);
|
||||||
|
|
||||||
this.webClient = buildWebClient(mapper);
|
this.webClient = buildWebClient(mapper);
|
||||||
this.init();
|
this.init();
|
||||||
|
|||||||
@@ -105,6 +105,11 @@
|
|||||||
<artifactId>jackson-databind</artifactId>
|
<artifactId>jackson-databind</artifactId>
|
||||||
<version>${jackson-databind-version}</version>
|
<version>${jackson-databind-version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.openapitools</groupId>
|
||||||
|
<artifactId>jackson-databind-nullable</artifactId>
|
||||||
|
<version>${jackson-databind-nullable-version}</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
{{#java8}}
|
{{#java8}}
|
||||||
<dependency>
|
<dependency>
|
||||||
@@ -140,6 +145,7 @@
|
|||||||
<spring-web-version>5.0.7.RELEASE</spring-web-version>
|
<spring-web-version>5.0.7.RELEASE</spring-web-version>
|
||||||
<jackson-version>2.9.9</jackson-version>
|
<jackson-version>2.9.9</jackson-version>
|
||||||
<jackson-databind-version>2.9.9</jackson-databind-version>
|
<jackson-databind-version>2.9.9</jackson-databind-version>
|
||||||
|
<jackson-databind-nullable-version>0.2.0</jackson-databind-nullable-version>
|
||||||
<junit-version>4.12</junit-version>
|
<junit-version>4.12</junit-version>
|
||||||
<reactor-version>3.1.8.RELEASE</reactor-version>
|
<reactor-version>3.1.8.RELEASE</reactor-version>
|
||||||
<reactor-netty-version>0.7.8.RELEASE</reactor-netty-version>
|
<reactor-netty-version>0.7.8.RELEASE</reactor-netty-version>
|
||||||
|
|||||||
@@ -19,21 +19,6 @@ public class {{classname}} {{#parent}}extends {{{parent}}} {{/parent}}{{#parcela
|
|||||||
{{/mostInnerItems}}
|
{{/mostInnerItems}}
|
||||||
{{/isContainer}}
|
{{/isContainer}}
|
||||||
{{/isEnum}}
|
{{/isEnum}}
|
||||||
{{#jackson}}
|
|
||||||
public static final String JSON_PROPERTY_{{nameInSnakeCase}} = "{{baseName}}";
|
|
||||||
@JsonProperty(JSON_PROPERTY_{{nameInSnakeCase}})
|
|
||||||
{{#withXml}}
|
|
||||||
{{^isContainer}}
|
|
||||||
@JacksonXmlProperty({{#isXmlAttribute}}isAttribute = true, {{/isXmlAttribute}}{{#xmlNamespace}}namespace="{{xmlNamespace}}", {{/xmlNamespace}}localName = "{{#xmlName}}{{xmlName}}{{/xmlName}}{{^xmlName}}{{baseName}}{{/xmlName}}")
|
|
||||||
{{/isContainer}}
|
|
||||||
{{#isContainer}}
|
|
||||||
{{#isXmlWrapped}}
|
|
||||||
// items.xmlName={{items.xmlName}}
|
|
||||||
@JacksonXmlElementWrapper(useWrapping = {{isXmlWrapped}}, {{#xmlNamespace}}namespace="{{xmlNamespace}}", {{/xmlNamespace}}localName = "{{#items.xmlName}}{{items.xmlName}}{{/items.xmlName}}{{^items.xmlName}}{{items.baseName}}{{/items.xmlName}}")
|
|
||||||
{{/isXmlWrapped}}
|
|
||||||
{{/isContainer}}
|
|
||||||
{{/withXml}}
|
|
||||||
{{/jackson}}
|
|
||||||
{{#withXml}}
|
{{#withXml}}
|
||||||
{{#isXmlAttribute}}
|
{{#isXmlAttribute}}
|
||||||
@XmlAttribute(name = "{{#xmlName}}{{xmlName}}{{/xmlName}}{{^xmlName}}{{baseName}}{{/xmlName}}")
|
@XmlAttribute(name = "{{#xmlName}}{{xmlName}}{{/xmlName}}{{^xmlName}}{{baseName}}{{/xmlName}}")
|
||||||
@@ -56,10 +41,28 @@ public class {{classname}} {{#parent}}extends {{{parent}}} {{/parent}}{{#parcela
|
|||||||
{{/isXmlAttribute}}
|
{{/isXmlAttribute}}
|
||||||
{{/withXml}}
|
{{/withXml}}
|
||||||
{{#gson}}
|
{{#gson}}
|
||||||
public static final String SERIALIZED_NAME_{{nameInSnakeCase}} = "{{baseName}}";
|
public static final String SERIALIZED_NAME_{{vendorExtensions.x-java-const-name}} = "{{baseName}}";
|
||||||
@SerializedName(SERIALIZED_NAME_{{nameInSnakeCase}})
|
@SerializedName(SERIALIZED_NAME_{{vendorExtensions.x-java-const-name}})
|
||||||
{{/gson}}
|
{{/gson}}
|
||||||
|
{{#jackson}}
|
||||||
|
public static final String JSON_PROPERTY_{{vendorExtensions.x-java-const-name}} = "{{baseName}}";
|
||||||
|
{{/jackson}}
|
||||||
|
{{#vendorExtensions.isJacksonOptionalNullable}}
|
||||||
|
{{#isContainer}}
|
||||||
|
private JsonNullable<{{{datatypeWithEnum}}}> {{name}} = JsonNullable.<{{{datatypeWithEnum}}}>undefined();
|
||||||
|
{{/isContainer}}
|
||||||
|
{{^isContainer}}
|
||||||
|
private JsonNullable<{{{datatypeWithEnum}}}> {{name}} = JsonNullable.<{{{datatypeWithEnum}}}>{{#defaultValue}}of({{{.}}}){{/defaultValue}}{{^defaultValue}}undefined(){{/defaultValue}};
|
||||||
|
{{/isContainer}}
|
||||||
|
{{/vendorExtensions.isJacksonOptionalNullable}}
|
||||||
|
{{^vendorExtensions.isJacksonOptionalNullable}}
|
||||||
|
{{#isContainer}}
|
||||||
|
private {{{datatypeWithEnum}}} {{name}}{{#required}}{{#defaultValue}} = {{{.}}}{{/defaultValue}}{{/required}}{{^required}} = null{{/required}};
|
||||||
|
{{/isContainer}}
|
||||||
|
{{^isContainer}}
|
||||||
private {{{datatypeWithEnum}}} {{name}}{{#defaultValue}} = {{{.}}}{{/defaultValue}};
|
private {{{datatypeWithEnum}}} {{name}}{{#defaultValue}} = {{{.}}}{{/defaultValue}};
|
||||||
|
{{/isContainer}}
|
||||||
|
{{/vendorExtensions.isJacksonOptionalNullable}}
|
||||||
|
|
||||||
{{/vars}}
|
{{/vars}}
|
||||||
{{#parcelableModel}}
|
{{#parcelableModel}}
|
||||||
@@ -84,14 +87,28 @@ public class {{classname}} {{#parent}}extends {{{parent}}} {{/parent}}{{#parcela
|
|||||||
{{/gson}}
|
{{/gson}}
|
||||||
{{/parcelableModel}}
|
{{/parcelableModel}}
|
||||||
{{#vars}}
|
{{#vars}}
|
||||||
|
|
||||||
{{^isReadOnly}}
|
{{^isReadOnly}}
|
||||||
public {{classname}} {{name}}({{{datatypeWithEnum}}} {{name}}) {
|
public {{classname}} {{name}}({{{datatypeWithEnum}}} {{name}}) {
|
||||||
this.{{name}} = {{name}};
|
{{#vendorExtensions.isJacksonOptionalNullable}}this.{{name}} = JsonNullable.<{{{datatypeWithEnum}}}>of({{name}});{{/vendorExtensions.isJacksonOptionalNullable}}
|
||||||
|
{{^vendorExtensions.isJacksonOptionalNullable}}this.{{name}} = {{name}};{{/vendorExtensions.isJacksonOptionalNullable}}
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
{{#isListContainer}}
|
{{#isListContainer}}
|
||||||
|
|
||||||
public {{classname}} add{{nameInCamelCase}}Item({{{items.datatypeWithEnum}}} {{name}}Item) {
|
public {{classname}} add{{nameInCamelCase}}Item({{{items.datatypeWithEnum}}} {{name}}Item) {
|
||||||
|
{{#vendorExtensions.isJacksonOptionalNullable}}
|
||||||
|
if (this.{{name}} == null || !this.{{name}}.isPresent()) {
|
||||||
|
this.{{name}} = JsonNullable.<{{{datatypeWithEnum}}}>of({{{defaultValue}}});
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
this.{{name}}.get().add({{name}}Item);
|
||||||
|
} catch (java.util.NoSuchElementException e) {
|
||||||
|
// this can never happen, as we make sure above that the value is present
|
||||||
|
}
|
||||||
|
return this;
|
||||||
|
{{/vendorExtensions.isJacksonOptionalNullable}}
|
||||||
|
{{^vendorExtensions.isJacksonOptionalNullable}}
|
||||||
{{^required}}
|
{{^required}}
|
||||||
if (this.{{name}} == null) {
|
if (this.{{name}} == null) {
|
||||||
this.{{name}} = {{{defaultValue}}};
|
this.{{name}} = {{{defaultValue}}};
|
||||||
@@ -99,11 +116,24 @@ public class {{classname}} {{#parent}}extends {{{parent}}} {{/parent}}{{#parcela
|
|||||||
{{/required}}
|
{{/required}}
|
||||||
this.{{name}}.add({{name}}Item);
|
this.{{name}}.add({{name}}Item);
|
||||||
return this;
|
return this;
|
||||||
|
{{/vendorExtensions.isJacksonOptionalNullable}}
|
||||||
}
|
}
|
||||||
{{/isListContainer}}
|
{{/isListContainer}}
|
||||||
{{#isMapContainer}}
|
{{#isMapContainer}}
|
||||||
|
|
||||||
public {{classname}} put{{nameInCamelCase}}Item(String key, {{{items.datatypeWithEnum}}} {{name}}Item) {
|
public {{classname}} put{{nameInCamelCase}}Item(String key, {{{items.datatypeWithEnum}}} {{name}}Item) {
|
||||||
|
{{#vendorExtensions.isJacksonOptionalNullable}}
|
||||||
|
if (this.{{name}} == null || !this.{{name}}.isPresent()) {
|
||||||
|
this.{{name}} = JsonNullable.<{{{datatypeWithEnum}}}>of({{{defaultValue}}});
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
this.{{name}}.get().put(key, {{name}}Item);
|
||||||
|
} catch (java.util.NoSuchElementException e) {
|
||||||
|
// this can never happen, as we make sure above that the value is present
|
||||||
|
}
|
||||||
|
return this;
|
||||||
|
{{/vendorExtensions.isJacksonOptionalNullable}}
|
||||||
|
{{^vendorExtensions.isJacksonOptionalNullable}}
|
||||||
{{^required}}
|
{{^required}}
|
||||||
if (this.{{name}} == null) {
|
if (this.{{name}} == null) {
|
||||||
this.{{name}} = {{{defaultValue}}};
|
this.{{name}} = {{{defaultValue}}};
|
||||||
@@ -111,6 +141,7 @@ public class {{classname}} {{#parent}}extends {{{parent}}} {{/parent}}{{#parcela
|
|||||||
{{/required}}
|
{{/required}}
|
||||||
this.{{name}}.put(key, {{name}}Item);
|
this.{{name}}.put(key, {{name}}Item);
|
||||||
return this;
|
return this;
|
||||||
|
{{/vendorExtensions.isJacksonOptionalNullable}}
|
||||||
}
|
}
|
||||||
{{/isMapContainer}}
|
{{/isMapContainer}}
|
||||||
|
|
||||||
@@ -142,13 +173,43 @@ public class {{classname}} {{#parent}}extends {{{parent}}} {{/parent}}{{#parcela
|
|||||||
{{#vendorExtensions.extraAnnotation}}
|
{{#vendorExtensions.extraAnnotation}}
|
||||||
{{{vendorExtensions.extraAnnotation}}}
|
{{{vendorExtensions.extraAnnotation}}}
|
||||||
{{/vendorExtensions.extraAnnotation}}
|
{{/vendorExtensions.extraAnnotation}}
|
||||||
|
{{^vendorExtensions.isJacksonOptionalNullable}}{{#jackson}}{{> jackson_annotations}}{{/jackson}}{{/vendorExtensions.isJacksonOptionalNullable}}
|
||||||
public {{{datatypeWithEnum}}} {{getter}}() {
|
public {{{datatypeWithEnum}}} {{getter}}() {
|
||||||
|
{{#vendorExtensions.isJacksonOptionalNullable}}
|
||||||
|
{{#isReadOnly}}{{! A readonly attribute doesn't have setter => jackson will set null directly if explicitly returned by API, so make sure we have an empty JsonNullable}}
|
||||||
|
if ({{name}} == null) {
|
||||||
|
{{name}} = JsonNullable.<{{{datatypeWithEnum}}}>{{#defaultValue}}of({{{.}}}){{/defaultValue}}{{^defaultValue}}undefined(){{/defaultValue}};
|
||||||
|
}
|
||||||
|
{{/isReadOnly}}
|
||||||
|
return {{name}}.orElse(null);
|
||||||
|
{{/vendorExtensions.isJacksonOptionalNullable}}
|
||||||
|
{{^vendorExtensions.isJacksonOptionalNullable}}
|
||||||
|
return {{name}};
|
||||||
|
{{/vendorExtensions.isJacksonOptionalNullable}}
|
||||||
|
}
|
||||||
|
|
||||||
|
{{#vendorExtensions.isJacksonOptionalNullable}}
|
||||||
|
{{> jackson_annotations}}
|
||||||
|
public JsonNullable<{{{datatypeWithEnum}}}> {{getter}}_JsonNullable() {
|
||||||
return {{name}};
|
return {{name}};
|
||||||
}
|
}
|
||||||
|
{{/vendorExtensions.isJacksonOptionalNullable}}
|
||||||
|
|
||||||
{{^isReadOnly}}
|
{{^isReadOnly}}
|
||||||
|
{{#vendorExtensions.isJacksonOptionalNullable}}
|
||||||
|
@JsonProperty(JSON_PROPERTY_{{vendorExtensions.x-java-const-name}})
|
||||||
|
public void {{setter}}_JsonNullable(JsonNullable<{{{datatypeWithEnum}}}> {{name}}) {
|
||||||
|
this.{{name}} = {{name}};
|
||||||
|
}
|
||||||
|
{{/vendorExtensions.isJacksonOptionalNullable}}
|
||||||
|
|
||||||
public void {{setter}}({{{datatypeWithEnum}}} {{name}}) {
|
public void {{setter}}({{{datatypeWithEnum}}} {{name}}) {
|
||||||
|
{{#vendorExtensions.isJacksonOptionalNullable}}
|
||||||
|
this.{{name}} = JsonNullable.<{{{datatypeWithEnum}}}>of({{name}});
|
||||||
|
{{/vendorExtensions.isJacksonOptionalNullable}}
|
||||||
|
{{^vendorExtensions.isJacksonOptionalNullable}}
|
||||||
this.{{name}} = {{name}};
|
this.{{name}} = {{name}};
|
||||||
|
{{/vendorExtensions.isJacksonOptionalNullable}}
|
||||||
}
|
}
|
||||||
{{/isReadOnly}}
|
{{/isReadOnly}}
|
||||||
|
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ public class {{classname}} {{#parent}}extends {{{parent}}}{{/parent}} {{#seriali
|
|||||||
@SerializedName(SERIALIZED_NAME_{{nameInSnakeCase}})
|
@SerializedName(SERIALIZED_NAME_{{nameInSnakeCase}})
|
||||||
{{/gson}}
|
{{/gson}}
|
||||||
{{#isContainer}}
|
{{#isContainer}}
|
||||||
private {{{datatypeWithEnum}}} {{name}}{{#required}} = {{{defaultValue}}}{{/required}}{{^required}} = null{{/required}};
|
private {{{datatypeWithEnum}}} {{name}}{{#required}}{{#defaultValue}} = {{{.}}}{{/defaultValue}}{{/required}}{{^required}} = null{{/required}};
|
||||||
{{/isContainer}}
|
{{/isContainer}}
|
||||||
{{^isContainer}}
|
{{^isContainer}}
|
||||||
private {{{datatypeWithEnum}}} {{name}}{{#defaultValue}} = {{{.}}}{{/defaultValue}};
|
private {{{datatypeWithEnum}}} {{name}}{{#defaultValue}} = {{{.}}}{{/defaultValue}};
|
||||||
|
|||||||
@@ -11,7 +11,7 @@
|
|||||||
"fs": false
|
"fs": false
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"superagent": "3.7.0"
|
"superagent": "5.1.0"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"expect.js": "^0.3.1",
|
"expect.js": "^0.3.1",
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user