Merge remote-tracking branch 'origin/master' into 4.2.x

This commit is contained in:
William Cheng 2019-10-04 15:02:58 +08:00
commit d4500b307f
1246 changed files with 29609 additions and 16734 deletions

1
.gitignore vendored
View File

@ -174,6 +174,7 @@ samples/client/petstore/python-tornado/.venv/
samples/client/petstore/typescript-angular2/npm/npm-debug.log
samples/client/petstore/typescript-node/npm/npm-debug.log
samples/client/petstore/typescript-angular/tsd-debug.log
samples/client/petstore/typescript-fetch/tests/**/dist/
# aspnetcore
samples/server/petstore/aspnetcore/.vs/

View File

@ -13,7 +13,7 @@ steps:
commands:
- (cd samples/client/petstore/dart-jaguar/openapi && pub get && pub run build_runner build --delete-conflicting-outputs)
- (cd samples/client/petstore/dart-jaguar/flutter_petstore/openapi && pub get && pub run build_runner build --delete-conflicting-outputs)
- (cd samples/client/petstore/dart2/openapi && pub get && pub run test)
- (cd samples/client/petstore/dart2/petstore && pub get && pub run test)
# test Java 11 HTTP client
- name: java11-test
image: openjdk:11.0

View File

@ -165,16 +165,16 @@ See the different versions of the [openapi-generator-cli](https://mvnrepository.
<!-- RELEASE_VERSION -->
If you're looking for the latest stable version, you can grab it directly from Maven.org (Java 8 runtime at a minimum):
JAR location: `http://central.maven.org/maven2/org/openapitools/openapi-generator-cli/4.1.2/openapi-generator-cli-4.1.2.jar`
JAR location: `http://central.maven.org/maven2/org/openapitools/openapi-generator-cli/4.1.3/openapi-generator-cli-4.1.3.jar`
For **Mac/Linux** users:
```sh
wget http://central.maven.org/maven2/org/openapitools/openapi-generator-cli/4.1.2/openapi-generator-cli-4.1.2.jar -O openapi-generator-cli.jar
wget http://central.maven.org/maven2/org/openapitools/openapi-generator-cli/4.1.3/openapi-generator-cli-4.1.3.jar -O openapi-generator-cli.jar
```
For **Windows** users, you will need to install [wget](http://gnuwin32.sourceforge.net/packages/wget.htm) or you can use Invoke-WebRequest in PowerShell (3.0+), e.g.
```
Invoke-WebRequest -OutFile openapi-generator-cli.jar http://central.maven.org/maven2/org/openapitools/openapi-generator-cli/4.1.2/openapi-generator-cli-4.1.2.jar
Invoke-WebRequest -OutFile openapi-generator-cli.jar http://central.maven.org/maven2/org/openapitools/openapi-generator-cli/4.1.3/openapi-generator-cli-4.1.3.jar
```
After downloading the JAR, run `java -jar openapi-generator-cli.jar help` to show the usage.
@ -389,10 +389,10 @@ openapi-generator version
```
<!-- RELEASE_VERSION -->
Or install a particular OpenAPI Generator version (e.g. v4.1.2):
Or install a particular OpenAPI Generator version (e.g. v4.1.3):
```sh
npm install @openapitools/openapi-generator-cli@cli-4.1.2 -g
npm install @openapitools/openapi-generator-cli@cli-4.1.3 -g
```
Or install it as dev-dependency:
@ -416,7 +416,7 @@ java -jar modules/openapi-generator-cli/target/openapi-generator-cli.jar generat
(if you're on Windows, replace the last command with `java -jar modules\openapi-generator-cli\target\openapi-generator-cli.jar generate -i https://raw.githubusercontent.com/openapitools/openapi-generator/master/modules/openapi-generator/src/test/resources/2_0/petstore.yaml -g php -o c:\temp\php_api_client`)
<!-- RELEASE_VERSION -->
You can also download the JAR (latest release) directly from [maven.org](http://central.maven.org/maven2/org/openapitools/openapi-generator-cli/4.1.2/openapi-generator-cli-4.1.2.jar)
You can also download the JAR (latest release) directly from [maven.org](http://central.maven.org/maven2/org/openapitools/openapi-generator-cli/4.1.3/openapi-generator-cli-4.1.3.jar)
<!-- /RELEASE_VERSION -->
To get a list of **general** options available, please run `java -jar modules/openapi-generator-cli/target/openapi-generator-cli.jar help generate`
@ -455,6 +455,7 @@ NAME
SYNOPSIS
openapi-generator-cli generate
[(-a <authorization> | --auth <authorization>)]
[--api-name-suffix <api name suffix>]
[--api-package <api package>] [--artifact-id <artifact id>]
[--artifact-version <artifact version>]
[(-c <configuration file> | --config <configuration file>)]
@ -563,6 +564,7 @@ Here are some companies/projects (alphabetical order) using OpenAPI Generator in
- [Element AI](https://www.elementai.com/)
- [FormAPI](https://formapi.io/)
- [Fuse](https://www.fuse.no/)
- [Gantner](https://www.gantner.com)
- [GenFlow](https://github.com/RepreZen/GenFlow)
- [GMO Pepabo](https://pepabo.com/en/)
- [GoDaddy](https://godaddy.com)
@ -637,8 +639,16 @@ Here are some companies/projects (alphabetical order) using OpenAPI Generator in
- 2019-08-29 - [OpenAPI初探](https://cloud.tencent.com/developer/article/1495986) by [peakxie](https://cloud.tencent.com/developer/user/1113152) at [腾讯云社区](https://cloud.tencent.com/developer)
- 2019-08-29 - [全面进化Kubernetes CRD 1.16 GA前瞻](https://www.servicemesher.com/blog/kubernetes-1.16-crd-ga-preview/) by [Min Kim](https://github.com/yue9944882) at [ServiceMesher Blog](https://www.servicemesher.com/blog/)
- 2019-09-01 - [Creating a PHP-Slim server using OpenAPI (Youtube video)](https://www.youtube.com/watch?v=5cJtbIrsYkg) by [Daniel Persson](https://www.youtube.com/channel/UCnG-TN23lswO6QbvWhMtxpA)
- 2019-09-06 - [Vert.x and OpenAPI](https://wissel.net/blog/2019/09/vertx-and-openapi.html) by [Stephan H Wissel](https://twitter.com/notessensei) at [wissel.net blog](https://wissel.net)
- 2019-09-09 - [Cloud-native development - Creating RESTful microservices](https://cloud.ibm.com/docs/cloud-native?topic=cloud-native-rest-api) in [IBM Cloud Docs](https://cloud.ibm.com/docs)
- 2019-09-14 - [Generating and Configuring a Mastercard API Client](https://developer.mastercard.com/platform/documentation/generating-and-configuring-a-mastercard-api-client/) at [Mastercard Developers Platform](https://developer.mastercard.com/platform/documentation/)
- 2019-09-15 - [OpenAPI(Swagger)導入下調べ](https://qiita.com/ShoichiKuraoka/items/f1f7a3c2376f7cd9c56a) by [Shoichi Kuraoka](https://qiita.com/ShoichiKuraoka)
- 2019-09-17 - [Tutorial: Documenting http4k APIs with OpenApi3](https://www.http4k.org/tutorials/documenting_apis_with_openapi/) by [http4k](https://www.http4k.org/)
- 2019-09-22 - [OpenAPI 3を完全に理解できる本](https://booth.pm/ja/items/1571902) by [@ota42y](https://twitter.com/ota42y)
- 2019-09-22 - [RESTful APIs: Tutorial of OpenAPI Specification](https://medium.com/@amirm.lavasani/restful-apis-tutorial-of-openapi-specification-eeada0e3901d) by [Amir Lavasani](https://medium.com/@amirm.lavasani)
- 2019-09-22 - [Redefining SDKs as software diversity kits](https://devrel.net/dev-rel/redefining-sdks-as-software-diversity-kits) by [Sid Maestre (Xero)](https://twitter.com/sidneyallen) at [DevRelCon San Francisco 2019](https://sf2019.devrel.net/)
- 2019-09-23 - [swaggerからOpenApi GeneratorでSpringのコードを自動生成](https://qiita.com/littleFeet/items/492df2ad68a0799a5e5e) by [@littleFeet](https://qiita.com/littleFeet) at [Qiita](https://qiita.com/)
## [6 - About Us](#table-of-contents)
@ -817,7 +827,7 @@ If you want to join the committee, please kindly apply by sending an email to te
| Bash | @frol (2017/07) @bkryza (2017/08) @kenjones-cisco (2017/09) |
| C | @zhemant (2018/11) |
| 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) @frankyjuang (2019/09) |
| Clojure | |
| Dart | @ircecho (2017/07) @swipesight (2018/09) @jaumard (2018/09) @nickmeinhold (2019/09) |
| Eiffel | @jvelilla (2017/09) |

View File

@ -27,6 +27,6 @@ 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 -g cpp-pistache-server -t modules/openapi-generator/src/main/resources/cpp-pistache-server -i modules/openapi-generator/src/test/resources/2_0/petstore.yaml --additional-properties addExternalLibs=true -o samples/server/petstore/cpp-pistache $@"
ags="generate -g cpp-pistache-server -t modules/openapi-generator/src/main/resources/cpp-pistache-server -i modules/openapi-generator/src/test/resources/2_0/petstore.yaml --additional-properties addExternalLibs=true --additional-properties useStructModel=false -o samples/server/petstore/cpp-pistache $@"
java $JAVA_OPTS -jar $executable $ags

View File

@ -29,5 +29,5 @@ fi
export JAVA_OPTS="${JAVA_OPTS} -Xmx1024M -DloggerPath=conf/log4j.properties"
# Generate client
ags="generate -t modules/openapi-generator/src/main/resources/dart2 -i modules/openapi-generator/src/test/resources/2_0/petstore.yaml -g dart -o samples/client/petstore/dart2/openapi --additional-properties hideGenerationTimestamp=true $@"
ags="generate -t modules/openapi-generator/src/main/resources/dart2 -i modules/openapi-generator/src/test/resources/2_0/petstore.yaml -g dart -o samples/client/petstore/dart2/petstore_client_lib --additional-properties hideGenerationTimestamp=true $@"
java $JAVA_OPTS -jar $executable $ags

View File

@ -1,7 +1,6 @@
#!/bin/sh
SCRIPT="$0"
echo "# START SCRIPT: $SCRIPT"
while [ -h "$SCRIPT" ] ; do
ls=$(ls -ld "$SCRIPT")
@ -22,11 +21,11 @@ executable="./modules/openapi-generator-cli/target/openapi-generator-cli.jar"
if [ ! -f "$executable" ]
then
mvn -B clean package
mvn clean package
fi
# if you've executed sbt assembly previously it will use that instead.
export JAVA_OPTS="${JAVA_OPTS} -Xmx1024M -DloggerPath=conf/log4j.properties"
ags="generate -t modules/openapi-generator/src/main/resources/rust -i modules/openapi-generator/src/test/resources/2_0/petstore.yaml -g rust -o samples/client/petstore/rust-reqwest --additional-properties packageName=petstore_client --library=reqwest $@"
export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties"
ags="$@ generate -i modules/openapi-generator/src/test/resources/2_0/petstore.yaml -g fsharp-functions -o samples/server/petstore/fsharp-functions"
java ${JAVA_OPTS} -jar ${executable} ${ags}

View File

@ -27,6 +27,6 @@ fi
# if you've executed sbt assembly previously it will use that instead.
export JAVA_OPTS="${JAVA_OPTS} -Xmx1024M -DloggerPath=conf/log4j.properties"
ags="generate -t modules/openapi-generator/src/main/resources/kotlin-client -i modules/openapi-generator/src/test/resources/2_0/petstore.yaml -g kotlin --artifact-id kotlin-petstore-client --additional-properties dateLibrary=java8 -o samples/client/petstore/kotlin $@"
ags="generate -t modules/openapi-generator/src/main/resources/kotlin-client -i modules/openapi-generator/src/test/resources/2_0/petstore.yaml -g kotlin --artifact-id kotlin-petstore-client --additional-properties dateLibrary=java8,serializableModel=true -o samples/client/petstore/kotlin $@"
java ${JAVA_OPTS} -jar ${executable} ${ags}

View File

@ -27,7 +27,7 @@ fi
# if you've executed sbt assembly previously it will use that instead.
export JAVA_OPTS="${JAVA_OPTS} -Xmx1024M -DloggerPath=conf/log4j.properties"
ags="generate -t modules/openapi-generator/src/main/resources/kotlin-client -i modules/openapi-generator/src/test/resources/2_0/petstore.yaml -g kotlin --artifact-id kotlin-petstore-string --additional-properties dateLibrary=string -o samples/client/petstore/kotlin-string $@"
ags="generate -t modules/openapi-generator/src/main/resources/kotlin-client -i modules/openapi-generator/src/test/resources/2_0/petstore.yaml -g kotlin --artifact-id kotlin-petstore-string --additional-properties dateLibrary=string,serializableModel=true -o samples/client/petstore/kotlin-string $@"
java ${JAVA_OPTS} -jar ${executable} ${ags}

View File

@ -27,7 +27,7 @@ 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 -t modules/openapi-generator/src/main/resources/kotlin-server -g kotlin-server --library=ktor -o samples/server/petstore/kotlin-server/ktor --additional-properties hideGenerationTimestamp=true $@"
ags="generate -i modules/openapi-generator/src/test/resources/2_0/petstore.yaml -t modules/openapi-generator/src/main/resources/kotlin-server -g kotlin-server --library=ktor -o samples/server/petstore/kotlin-server/ktor --additional-properties hideGenerationTimestamp=true,serializableModel=true $@"
java ${JAVA_OPTS} -jar ${executable} ${ags}

View File

@ -26,7 +26,7 @@ then
fi
export JAVA_OPTS="${JAVA_OPTS} -Xmx1024M -DloggerPath=conf/log4j.properties"
ags="$@ generate -i modules/openapi-generator/src/test/resources/2_0/petstore.yaml -t modules/openapi-generator/src/main/resources/kotlin-spring -g kotlin-spring -o samples/server/petstore/kotlin-springboot --additional-properties=library=spring-boot,beanValidations=true,swaggerAnnotations=true,serviceImplementation=true"
ags="$@ generate -i modules/openapi-generator/src/test/resources/2_0/petstore.yaml -t modules/openapi-generator/src/main/resources/kotlin-spring -g kotlin-spring -o samples/server/petstore/kotlin-springboot --additional-properties=library=spring-boot,beanValidations=true,swaggerAnnotations=true,serviceImplementation=true,serializableModel=true"
echo "Cleaning previously generated files if any from samples/server/petstore/kotlin-springboot"
rm -rf samples/server/petstore/kotlin-springboot

View File

@ -26,7 +26,7 @@ then
fi
export JAVA_OPTS="${JAVA_OPTS} -Xmx1024M -DloggerPath=conf/log4j.properties"
ags="generate -i modules/openapi-generator/src/test/resources/3_0/petstore-with-fake-endpoints-models-for-testing.yaml -t modules/openapi-generator/src/main/resources/kotlin-client -g kotlin --artifact-id kotlin-petstore-client --additional-properties dateLibrary=java8 -o samples/openapi3/client/petstore/kotlin $@"
ags="generate -i modules/openapi-generator/src/test/resources/3_0/petstore-with-fake-endpoints-models-for-testing.yaml -t modules/openapi-generator/src/main/resources/kotlin-client -g kotlin --artifact-id kotlin-petstore-client --additional-properties dateLibrary=java8,serializableModel=true -o samples/openapi3/client/petstore/kotlin $@"
echo "Cleaning previously generated files if any from samples/openapi3/client/petstore/kotlin"
rm -rf samples/openapi3/client/petstore/kotlin

View File

@ -26,7 +26,7 @@ then
fi
export JAVA_OPTS="${JAVA_OPTS} -Xmx1024M -DloggerPath=conf/log4j.properties"
ags="$@ generate -i modules/openapi-generator/src/test/resources/3_0/petstore.yaml -t modules/openapi-generator/src/main/resources/kotlin-spring -g kotlin-spring -o samples/openapi3/server/petstore/kotlin-springboot --additional-properties=library=spring-boot,beanValidations=true,swaggerAnnotations=true,serviceImplementation=true"
ags="$@ generate -i modules/openapi-generator/src/test/resources/3_0/petstore.yaml -t modules/openapi-generator/src/main/resources/kotlin-spring -g kotlin-spring -o samples/openapi3/server/petstore/kotlin-springboot --additional-properties=library=spring-boot,beanValidations=true,swaggerAnnotations=true,serviceImplementation=true,serializableModel=true"
echo "Cleaning previously generated files if any from samples/server/openapi3/petstore/kotlin-springboot"
rm -rf samples/server/openapi3/petstore/kotlin-springboot

View File

@ -27,6 +27,6 @@ fi
# if you've executed sbt assembly previously it will use that instead.
export JAVA_OPTS="${JAVA_OPTS} -Xmx1024M -DloggerPath=conf/log4j.properties"
ags="generate -t modules/openapi-generator/src/main/resources/python -i modules/openapi-generator/src/test/resources/2_0/python-client-experimental/petstore-with-fake-endpoints-models-for-testing.yaml -g python-experimental -o samples/client/petstore/python-experimental -DpackageName=petstore_api $@"
ags="generate -t modules/openapi-generator/src/main/resources/python -i modules/openapi-generator/src/test/resources/2_0/python-client-experimental/petstore-with-fake-endpoints-models-for-testing.yaml -g python-experimental -o samples/client/petstore/python-experimental --additional-properties packageName=petstore_api $@"
java $JAVA_OPTS -jar $executable $ags

View File

@ -27,6 +27,21 @@ fi
# if you've executed sbt assembly previously it will use that instead.
export JAVA_OPTS="${JAVA_OPTS} -Xmx1024M -DloggerPath=conf/log4j.properties"
ags="generate -t modules/openapi-generator/src/main/resources/rust -i modules/openapi-generator/src/test/resources/2_0/petstore.yaml -g rust -o samples/client/petstore/rust --additional-properties packageName=petstore_client --library=hyper $@"
java ${JAVA_OPTS} -jar ${executable} ${ags}
for spec_path in \
modules/openapi-generator/src/test/resources/2_0/petstore.yaml \
modules/openapi-generator/src/test/resources/3_0/rust/rust-test.yaml \
modules/openapi-generator/src/test/resources/2_0/fileResponseTest.json\
; do
spec=$(basename "$spec_path" | sed 's/.yaml//' | sed 's/.json//' )
for library in hyper reqwest; do
args="generate --template-dir modules/openapi-generator/src/main/resources/rust
--input-spec $spec_path
--generator-name rust
--output samples/client/petstore/rust/$library/$spec
--additional-properties packageName=${spec}-${library}
--library=$library $@"
java ${JAVA_OPTS} -jar ${executable} ${args} || exit 1
done
done

View File

@ -54,6 +54,8 @@ declare -a scripts=(
"./bin/csharp-petstore.sh"
"./bin/csharp-netcore-petstore-all.sh"
"./bin/elixir-petstore.sh"
"./bin/openapi3/go-petstore.sh"
"./bin/go-experimental-petstore.sh"
"./bin/go-petstore.sh"
"./bin/go-petstore-withxml.sh"
"./bin/go-gin-petstore-server.sh"

View File

@ -0,0 +1,10 @@
set executable=.\modules\openapi-generator-cli\target\openapi-generator-cli.jar
If Not Exist %executable% (
mvn clean package
)
REM set JAVA_OPTS=%JAVA_OPTS% -Xmx1024M -DloggerPath=conf/log4j.properties
set ags=generate --artifact-id "fsharp-functions-petstore-server" -i modules\openapi-generator\src\test\resources\2_0\petstore.yaml -g fsharp-functions -o samples\server\petstore\fsharp-functions
java %JAVA_OPTS% -jar %executable% %ags%

View File

@ -5,7 +5,7 @@ title: FAQ: General
## Do you have a chat room?
[![Gitter](https://img.shields.io/gitter/room/:user/:repo.svg?style=for-the-badge)](https://gitter.im/OpenAPITools/openapi-generator)
[![Jion the Slack chat room](https://img.shields.io/badge/Slack-Join%20the%20chat%20room-orange)](https://join.slack.com/t/openapi-generator/shared_invite/enQtNzAyNDMyOTU0OTE1LTY5ZDBiNDI5NzI5ZjQ1Y2E5OWVjMjZkYzY1ZGM2MWQ4YWFjMzcyNDY5MGI4NjQxNDBiMTlmZTc5NjY2ZTQ5MGM)
## What is the governance structure of the OpenAPI Generator project?

View File

@ -75,7 +75,8 @@ The following generators are available:
* [cpp-restbed-server](generators/cpp-restbed-server)
* [csharp-nancyfx](generators/csharp-nancyfx)
* [erlang-server](generators/erlang-server)
* [fsharp-giraffe-server](generators/fsharp-giraffe-server)
* [fsharp-functions (beta)](generators/fsharp-functions)
* [fsharp-giraffe-server (beta)](generators/fsharp-giraffe-server)
* [go-gin-server](generators/go-gin-server)
* [go-server](generators/go-server)
* [graphql-nodejs-express-server](generators/graphql-nodejs-express-server)

View File

@ -9,3 +9,4 @@ sidebar_label: cpp-pistache-server
| ------ | ----------- | ------ | ------- |
|addExternalLibs|Add the Possibility to fetch and compile external Libraries needed by this Framework.| |true|
|helpersPackage|Specify the package name to be used for the helpers (e.g. org.openapitools.server.helpers).| |org.openapitools.server.helpers|
|useStructModel|Use struct-based model template instead of get/set-based model template| |false|

View File

@ -0,0 +1,22 @@
---
id: generator-opts-server-fsharp-functions
title: Config Options for fsharp-functions
sidebar_label: fsharp-functions
---
| Option | Description | Values | Default |
| ------ | ----------- | ------ | ------- |
|sortParamsByRequiredFlag|Sort method arguments to place required parameters before optional parameters.| |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|
|prependFormOrBodyParameters|Add form or body parameters to the beginning of the parameter list.| |false|
|licenseUrl|The URL of the license| |http://localhost|
|licenseName|The name of the license| |NoLicense|
|packageCopyright|Specifies an AssemblyCopyright for the .NET Framework global assembly attributes stored in the AssemblyInfo file.| |No Copyright|
|packageAuthors|Specifies Authors property in the .NET Core project file.| |OpenAPI|
|packageTitle|Specifies an AssemblyTitle for the .NET Framework global assembly attributes stored in the AssemblyInfo file.| |OpenAPI Library|
|packageName|F# module name (convention: Title.Case).| |OpenAPI|
|packageVersion|F# package version.| |1.0.0|
|packageGuid|The GUID that will be associated with the C# project| |null|
|sourceFolder|source folder for generated code| |OpenAPI/src|

View File

@ -28,6 +28,7 @@ sidebar_label: haskell-http-client
|strictFields|Add strictness annotations to all model fields| |true|
|useKatip|Sets the default value for the UseKatip cabal flag. If true, the katip package provides logging instead of monad-logger| |true|
|dateTimeFormat|format string used to parse/render a datetime| |null|
|dateTimeParseFormat|overrides the format string used to parse a datetime| |null|
|dateFormat|format string used to parse/render a date| |%Y-%m-%d|
|customTestInstanceModule|test module used to provide typeclass instances for types not known by the generator| |null|
|hideGenerationTimestamp|Hides the generation timestamp when files are generated.| |true|

View File

@ -46,7 +46,7 @@ sidebar_label: jaxrs-cxf-cdi
|title|a title describing the application| |OpenAPI Server|
|useBeanValidation|Use BeanValidation API annotations| |true|
|serverPort|The port on which the server should be started| |8080|
|library|library template (sub-template)|<dl><dt>**&lt;default&gt;**</dt><dd>JAXRS</dd><dl>|&lt;default&gt;|
|library|library template (sub-template)|<dl><dt>**&lt;default&gt;**</dt><dd>JAXRS spec only, to be deployed in an app server (TomEE, JBoss, WLS, ...)</dd><dt>**quarkus**</dt><dd>Server using Quarkus</dd><dt>**thorntail**</dt><dd>Server using Thorntail</dd><dt>**openliberty**</dt><dd>Server using Open Liberty</dd><dt>**helidon**</dt><dd>Server using Helidon</dd><dl>|&lt;default&gt;|
|generatePom|Whether to generate pom.xml if the file does not already exist.| |true|
|interfaceOnly|Whether to generate only API interface stubs without the server files.| |false|
|returnResponse|Whether generate API interface should return javax.ws.rs.core.Response instead of a deserialized entity. Only useful if interfaceOnly is true.| |false|

View File

@ -46,7 +46,7 @@ sidebar_label: jaxrs-spec
|title|a title describing the application| |OpenAPI Server|
|useBeanValidation|Use BeanValidation API annotations| |true|
|serverPort|The port on which the server should be started| |8080|
|library|library template (sub-template)|<dl><dt>**&lt;default&gt;**</dt><dd>JAXRS</dd><dl>|&lt;default&gt;|
|library|library template (sub-template)|<dl><dt>**&lt;default&gt;**</dt><dd>JAXRS spec only, to be deployed in an app server (TomEE, JBoss, WLS, ...)</dd><dt>**quarkus**</dt><dd>Server using Quarkus</dd><dt>**thorntail**</dt><dd>Server using Thorntail</dd><dt>**openliberty**</dt><dd>Server using Open Liberty</dd><dt>**helidon**</dt><dd>Server using Helidon</dd><dl>|&lt;default&gt;|
|generatePom|Whether to generate pom.xml if the file does not already exist.| |true|
|interfaceOnly|Whether to generate only API interface stubs without the server files.| |false|
|returnResponse|Whether generate API interface should return javax.ws.rs.core.Response instead of a deserialized entity. Only useful if interfaceOnly is true.| |false|

View File

@ -16,6 +16,7 @@ sidebar_label: kotlin-server
|enumPropertyNaming|Naming convention for enum properties: 'camelCase', 'PascalCase', 'snake_case', 'UPPERCASE', and 'original'| |camelCase|
|serializationLibrary|What serialization library to use: 'moshi' (default), or 'gson'| |moshi|
|parcelizeModels|toggle &quot;@Parcelize&quot; for generated models| |null|
|serializableModel|boolean - toggle &quot;implements Serializable&quot; for generated models| |null|
|library|library template (sub-template)|<dl><dt>**ktor**</dt><dd>ktor framework</dd><dl>|ktor|
|featureAutoHead|Automatically provide responses to HEAD requests for existing routes that have the GET verb defined.| |true|
|featureConditionalHeaders|Avoid sending content if client already has same content, by checking ETag or LastModified properties.| |false|

View File

@ -16,6 +16,7 @@ sidebar_label: kotlin-spring
|enumPropertyNaming|Naming convention for enum properties: 'camelCase', 'PascalCase', 'snake_case', 'UPPERCASE', and 'original'| |camelCase|
|serializationLibrary|What serialization library to use: 'moshi' (default), or 'gson'| |moshi|
|parcelizeModels|toggle &quot;@Parcelize&quot; for generated models| |null|
|serializableModel|boolean - toggle &quot;implements Serializable&quot; for generated models| |null|
|title|server title name or client service name| |OpenAPI Kotlin Spring|
|basePackage|base package (invokerPackage) for generated code| |org.openapitools|
|serverPort|configuration the port in which the sever is to run on| |8080|

View File

@ -16,3 +16,4 @@ sidebar_label: kotlin-vertx
|enumPropertyNaming|Naming convention for enum properties: 'camelCase', 'PascalCase', 'snake_case', 'UPPERCASE', and 'original'| |camelCase|
|serializationLibrary|What serialization library to use: 'moshi' (default), or 'gson'| |moshi|
|parcelizeModels|toggle &quot;@Parcelize&quot; for generated models| |null|
|serializableModel|boolean - toggle &quot;implements Serializable&quot; for generated models| |null|

View File

@ -16,6 +16,7 @@ sidebar_label: kotlin
|enumPropertyNaming|Naming convention for enum properties: 'camelCase', 'PascalCase', 'snake_case', 'UPPERCASE', and 'original'| |camelCase|
|serializationLibrary|What serialization library to use: 'moshi' (default), or 'gson'| |moshi|
|parcelizeModels|toggle &quot;@Parcelize&quot; for generated models| |null|
|serializableModel|boolean - toggle &quot;implements Serializable&quot; for generated models| |null|
|dateLibrary|Option. Date library to use|<dl><dt>**string**</dt><dd>String</dd><dt>**java8**</dt><dd>Java 8 native JSR310 (jvm only)</dd><dt>**threetenbp**</dt><dd>Threetenbp (jvm only)</dd><dl>|java8|
|collectionType|Option. Collection type to use|<dl><dt>**array**</dt><dd>kotlin.Array</dd><dt>**list**</dt><dd>kotlin.collections.List</dd><dl>|array|
|library|Library template (sub-template) to use|<dl><dt>**jvm**</dt><dd>Platform: Java Virtual Machine. HTTP client: OkHttp 2.7.5. JSON processing: Gson 2.8.1.</dd><dt>**multiplatform**</dt><dd>Platform: Kotlin multiplatform. HTTP client: Ktor 1.2.4. JSON processing: Kotlinx Serialization: 0.12.0.</dd><dl>|jvm|

View File

@ -54,10 +54,7 @@
<property name="tokens" value="LITERAL_TRY, LITERAL_FINALLY, LITERAL_IF, LITERAL_ELSE, LITERAL_SWITCH"/>
</module>
<module name="NeedBraces"/>
<module name="LeftCurly">
<property name="maxLineLength" value="100"/>
</module>
<module name="RightCurly"/>
<module name="LeftCurly"/>
<module name="RightCurly">
<property name="option" value="alone"/>
<property name="tokens" value="CLASS_DEF, METHOD_DEF, CTOR_DEF, LITERAL_FOR, LITERAL_WHILE, LITERAL_DO, STATIC_INIT, INSTANCE_INIT"/>

View File

@ -65,7 +65,7 @@ public class Generate implements Runnable {
private String templateDir;
@Option(name = {"-e", "--engine"}, title = "templating engine",
description = "templating engine: \"mustache\" (default) or \"handlebars\" (beta)")
description = "templating engine: \"mustache\" (default) or \"handlebars\" (beta)")
private String templatingEngine;
@Option(
@ -109,6 +109,10 @@ public class Generate implements Runnable {
description = CodegenConstants.MODEL_PACKAGE_DESC)
private String modelPackage;
@Option(name = {"--api-name-suffix"}, title = "api name suffix",
description = CodegenConstants.API_NAME_SUFFIX_DESC)
private String apiNameSuffix;
@Option(name = {"--model-name-prefix"}, title = "model name prefix",
description = CodegenConstants.MODEL_NAME_PREFIX_DESC)
private String modelNamePrefix;
@ -319,6 +323,10 @@ public class Generate implements Runnable {
configurator.setModelPackage(modelPackage);
}
if (isNotEmpty(apiNameSuffix)) {
configurator.setApiNameSuffix(apiNameSuffix);
}
if (isNotEmpty(modelNamePrefix)) {
configurator.setModelNamePrefix(modelNamePrefix);
}

View File

@ -40,6 +40,7 @@ public final class GeneratorSettings implements Serializable {
private String modelPackage;
private String invokerPackage;
private String packageName;
private String apiNameSuffix;
private String modelNamePrefix;
private String modelNameSuffix;
private String groupId;
@ -106,6 +107,21 @@ public final class GeneratorSettings implements Serializable {
return packageName;
}
/**
* Gets a api name suffix for generated models. This name will be appended to a api name.
* <p>
* This option is often used to circumvent compilation issues where models match keywords.
* <p>
* Example:
* <p>
* Suffix <code>Gen</code> applied to <code>Object</code> results in a generated class named <code>ObjectGen</code>.
*
* @return the model name suffix
*/
public String getApiNameSuffix() {
return apiNameSuffix;
}
/**
* Gets a model name prefix for generated models. This name will be prefixed to a model name.
* <p>
@ -325,6 +341,7 @@ public final class GeneratorSettings implements Serializable {
modelPackage = builder.modelPackage;
invokerPackage = builder.invokerPackage;
packageName = builder.packageName;
apiNameSuffix = builder.apiNameSuffix;
modelNamePrefix = builder.modelNamePrefix;
modelNameSuffix = builder.modelNameSuffix;
groupId = builder.groupId;
@ -366,6 +383,9 @@ public final class GeneratorSettings implements Serializable {
if (isNotEmpty(artifactVersion)) {
additional.put("artifactVersion", artifactVersion);
}
if (isNotEmpty(apiNameSuffix)) {
additional.put("apiNameSuffix", apiNameSuffix);
}
if (isNotEmpty(modelNamePrefix)) {
additional.put("modelNamePrefix", modelNamePrefix);
}
@ -433,6 +453,7 @@ public final class GeneratorSettings implements Serializable {
builder.modelPackage = copy.getModelPackage();
builder.invokerPackage = copy.getInvokerPackage();
builder.packageName = copy.getPackageName();
builder.apiNameSuffix = copy.getApiNameSuffix();
builder.modelNamePrefix = copy.getModelNamePrefix();
builder.modelNameSuffix = copy.getModelNameSuffix();
builder.groupId = copy.getGroupId();
@ -479,6 +500,7 @@ public final class GeneratorSettings implements Serializable {
private String modelPackage;
private String invokerPackage;
private String packageName;
private String apiNameSuffix;
private String modelNamePrefix;
private String modelNameSuffix;
private String groupId;
@ -571,6 +593,17 @@ public final class GeneratorSettings implements Serializable {
return this;
}
/**
* Sets the {@code apiNameSuffix} and returns a reference to this Builder so that the methods can be chained together.
*
* @param apiNameSuffix the {@code apiNameSuffix} to set
* @return a reference to this Builder
*/
public Builder withApiNameSuffix(String apiNameSuffix) {
this.apiNameSuffix = apiNameSuffix;
return this;
}
/**
* Sets the {@code modelNamePrefix} and returns a reference to this Builder so that the methods can be chained together.
*
@ -880,6 +913,7 @@ public final class GeneratorSettings implements Serializable {
", modelPackage='" + modelPackage + '\'' +
", invokerPackage='" + invokerPackage + '\'' +
", packageName='" + packageName + '\'' +
", apiNameSuffix='" + apiNameSuffix + '\'' +
", modelNamePrefix='" + modelNamePrefix + '\'' +
", modelNameSuffix='" + modelNameSuffix + '\'' +
", groupId='" + groupId + '\'' +
@ -910,6 +944,7 @@ public final class GeneratorSettings implements Serializable {
Objects.equals(getModelPackage(), that.getModelPackage()) &&
Objects.equals(getInvokerPackage(), that.getInvokerPackage()) &&
Objects.equals(getPackageName(), that.getPackageName()) &&
Objects.equals(getApiNameSuffix(), that.getApiNameSuffix()) &&
Objects.equals(getModelNamePrefix(), that.getModelNamePrefix()) &&
Objects.equals(getModelNameSuffix(), that.getModelNameSuffix()) &&
Objects.equals(getGroupId(), that.getGroupId()) &&
@ -937,6 +972,7 @@ public final class GeneratorSettings implements Serializable {
getModelPackage(),
getInvokerPackage(),
getPackageName(),
getApiNameSuffix(),
getModelNamePrefix(),
getModelNameSuffix(),
getGroupId(),

View File

@ -20,6 +20,20 @@
<gradleVersion>4.10.2</gradleVersion>
</properties>
<pluginRepositories>
<pluginRepository>
<id>Gradle Releases</id>
<name>Gradle Releases repository</name>
<url>https://repo.gradle.org/gradle/libs-releases-local/</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>false</enabled>
</snapshots>
</pluginRepository>
</pluginRepositories>
<dependencies>
<dependency>
<groupId>org.openapitools</groupId>

View File

@ -75,11 +75,11 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.6.1</version>
<version>3.8.1</version>
<configuration>
<source>1.7</source>
<target>1.7</target>
<proc>none</proc>
<source>1.7</source>
<target>1.7</target>
<proc>none</proc>
</configuration>
</plugin>
</plugins>

View File

@ -57,11 +57,11 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.6.1</version>
<version>3.8.1</version>
<configuration>
<source>1.7</source>
<target>1.7</target>
<proc>none</proc>
<source>1.7</source>
<target>1.7</target>
<proc>none</proc>
</configuration>
</plugin>
</plugins>

View File

@ -300,7 +300,7 @@
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
<version>3.0.0</version>
<version>3.1.0</version>
<scope>test</scope>
</dependency>
<dependency>

View File

@ -206,6 +206,9 @@ public class CodegenConstants {
// Codegen constants should define a description and provide proper input validation for the value of serializationLibrary
public static final String SERIALIZATION_LIBRARY = "serializationLibrary";
public static final String API_NAME_SUFFIX = "apiNameSuffix";
public static final String API_NAME_SUFFIX_DESC = "Suffix that will be appended to all API names ('tags'). Default: Api. e.g. Pet => PetApi. Note: Only ruby, python, jaxrs generators suppport this feature at the moment.";
public static final String MODEL_NAME_PREFIX = "modelNamePrefix";
public static final String MODEL_NAME_PREFIX_DESC = "Prefix that will be prepended to all model names.";

View File

@ -85,6 +85,7 @@ public class DefaultCodegen implements CodegenConfig {
protected Map<String, String> importMapping = new HashMap<String, String>();
protected String modelPackage = "", apiPackage = "", fileSuffix;
protected String modelNamePrefix = "", modelNameSuffix = "";
protected String apiNameSuffix = "Api";
protected String testPackage = "";
protected Map<String, String> apiTemplateFiles = new HashMap<String, String>();
protected Map<String, String> modelTemplateFiles = new HashMap<String, String>();
@ -180,6 +181,10 @@ public class DefaultCodegen implements CodegenConfig {
.get(CodegenConstants.ALLOW_UNICODE_IDENTIFIERS).toString()));
}
if (additionalProperties.containsKey(CodegenConstants.API_NAME_SUFFIX)) {
this.setApiNameSuffix((String) additionalProperties.get(CodegenConstants.API_NAME_SUFFIX));
}
if (additionalProperties.containsKey(CodegenConstants.MODEL_NAME_PREFIX)) {
this.setModelNamePrefix((String) additionalProperties.get(CodegenConstants.MODEL_NAME_PREFIX));
}
@ -779,6 +784,14 @@ public class DefaultCodegen implements CodegenConfig {
this.modelNameSuffix = modelNameSuffix;
}
public String getApiNameSuffix() {
return apiNameSuffix;
}
public void setApiNameSuffix(String apiNameSuffix) {
this.apiNameSuffix = apiNameSuffix;
}
public void setApiPackage(String apiPackage) {
this.apiPackage = apiPackage;
}
@ -1068,8 +1081,7 @@ public class DefaultCodegen implements CodegenConfig {
typeMapping.put("file", "File");
typeMapping.put("UUID", "UUID");
typeMapping.put("URI", "URI");
//typeMapping.put("BigDecimal", "BigDecimal"); //TODO need the mapping?
typeMapping.put("BigDecimal", "BigDecimal");
instantiationTypes = new HashMap<String, String>();
@ -1693,17 +1705,17 @@ public class DefaultCodegen implements CodegenConfig {
}
/**
* Output the API (class) name (capitalized) ending with "Api"
* Output the API (class) name (capitalized) ending with the specified or default suffix
* Return DefaultApi if name is empty
*
* @param name the name of the Api
* @return capitalized Api name ending with "Api"
* @return capitalized Api name
*/
public String toApiName(String name) {
if (name.length() == 0) {
return "DefaultApi";
}
return camelize(name) + "Api";
return camelize(name + "_" + apiNameSuffix);
}
/**
@ -2493,6 +2505,76 @@ public class DefaultCodegen implements CodegenConfig {
return responses.get(code);
}
/**
* Set op's returnBaseType, returnType, examples etc.
*
* @param operation endpoint Operation
* @param schemas a map of the schemas in the openapi spec
* @param op endpoint CodegenOperation
* @param methodResponse the default ApiResponse for the endpoint
*/
protected void handleMethodResponse(Operation operation,
Map<String, Schema> schemas,
CodegenOperation op,
ApiResponse methodResponse) {
Schema responseSchema = ModelUtils.unaliasSchema(this.openAPI, ModelUtils.getSchemaFromResponse(methodResponse));
if (responseSchema != null) {
CodegenProperty cm = fromProperty("response", responseSchema);
if (ModelUtils.isArraySchema(responseSchema)) {
ArraySchema as = (ArraySchema) responseSchema;
CodegenProperty innerProperty = fromProperty("response", getSchemaItems(as));
op.returnBaseType = innerProperty.baseType;
} else if (ModelUtils.isMapSchema(responseSchema)) {
CodegenProperty innerProperty = fromProperty("response", ModelUtils.getAdditionalProperties(responseSchema));
op.returnBaseType = innerProperty.baseType;
} else {
if (cm.complexType != null) {
op.returnBaseType = cm.complexType;
} else {
op.returnBaseType = cm.baseType;
}
}
// generate examples
String exampleStatusCode = "200";
for (String key : operation.getResponses().keySet()) {
if (operation.getResponses().get(key) == methodResponse && !key.equals("default")) {
exampleStatusCode = key;
}
}
op.examples = new ExampleGenerator(schemas, this.openAPI).generateFromResponseSchema(exampleStatusCode, responseSchema, getProducesInfo(this.openAPI, operation));
op.defaultResponse = toDefaultValue(responseSchema);
op.returnType = cm.dataType;
op.hasReference = schemas.containsKey(op.returnBaseType);
// lookup discriminator
Schema schema = schemas.get(op.returnBaseType);
if (schema != null) {
CodegenModel cmod = fromModel(op.returnBaseType, schema);
op.discriminator = cmod.discriminator;
}
if (cm.isContainer) {
op.returnContainer = cm.containerType;
if ("map".equals(cm.containerType)) {
op.isMapContainer = true;
} else if ("list".equalsIgnoreCase(cm.containerType)) {
op.isListContainer = true;
} else if ("array".equalsIgnoreCase(cm.containerType)) {
op.isListContainer = true;
}
} else {
op.returnSimpleType = true;
}
if (languageSpecificPrimitives().contains(op.returnBaseType) || op.returnBaseType == null) {
op.returnTypeIsPrimitive = true;
}
}
addHeaders(methodResponse, op.responseHeaders);
}
/**
* Convert OAS Operation object to Codegen Operation object
*
@ -2585,62 +2667,7 @@ public class DefaultCodegen implements CodegenConfig {
op.responses.get(op.responses.size() - 1).hasMore = false;
if (methodResponse != null) {
Schema responseSchema = ModelUtils.unaliasSchema(this.openAPI, ModelUtils.getSchemaFromResponse(methodResponse));
if (responseSchema != null) {
CodegenProperty cm = fromProperty("response", responseSchema);
if (ModelUtils.isArraySchema(responseSchema)) {
ArraySchema as = (ArraySchema) responseSchema;
CodegenProperty innerProperty = fromProperty("response", getSchemaItems(as));
op.returnBaseType = innerProperty.baseType;
} else if (ModelUtils.isMapSchema(responseSchema)) {
CodegenProperty innerProperty = fromProperty("response", ModelUtils.getAdditionalProperties(responseSchema));
op.returnBaseType = innerProperty.baseType;
} else {
if (cm.complexType != null) {
op.returnBaseType = cm.complexType;
} else {
op.returnBaseType = cm.baseType;
}
}
// generate examples
String exampleStatusCode = "200";
for (String key : operation.getResponses().keySet()) {
if (operation.getResponses().get(key) == methodResponse && !key.equals("default")) {
exampleStatusCode = key;
}
}
op.examples = new ExampleGenerator(schemas, this.openAPI).generateFromResponseSchema(exampleStatusCode, responseSchema, getProducesInfo(this.openAPI, operation));
op.defaultResponse = toDefaultValue(responseSchema);
op.returnType = cm.dataType;
op.hasReference = schemas.containsKey(op.returnBaseType);
// lookup discriminator
Schema schema = schemas.get(op.returnBaseType);
if (schema != null) {
CodegenModel cmod = fromModel(op.returnBaseType, schema);
op.discriminator = cmod.discriminator;
}
if (cm.isContainer) {
op.returnContainer = cm.containerType;
if ("map".equals(cm.containerType)) {
op.isMapContainer = true;
} else if ("list".equalsIgnoreCase(cm.containerType)) {
op.isListContainer = true;
} else if ("array".equalsIgnoreCase(cm.containerType)) {
op.isListContainer = true;
}
} else {
op.returnSimpleType = true;
}
if (languageSpecificPrimitives().contains(op.returnBaseType) || op.returnBaseType == null) {
op.returnTypeIsPrimitive = true;
}
}
addHeaders(methodResponse, op.responseHeaders);
handleMethodResponse(operation, schemas, op, methodResponse);
}
}
@ -3511,7 +3538,7 @@ public class DefaultCodegen implements CodegenConfig {
* @param response API response
* @param properties list of codegen property
*/
private void addHeaders(ApiResponse response, List<CodegenProperty> properties) {
protected void addHeaders(ApiResponse response, List<CodegenProperty> properties) {
if (response.getHeaders() != null) {
for (Map.Entry<String, Header> headerEntry : response.getHeaders().entrySet()) {
String description = headerEntry.getValue().getDescription();
@ -4316,7 +4343,7 @@ public class DefaultCodegen implements CodegenConfig {
}
}
private void updateEnumVarsWithExtensions(List<Map<String, Object>> enumVars, Map<String, Object> vendorExtensions) {
protected void updateEnumVarsWithExtensions(List<Map<String, Object>> enumVars, Map<String, Object> vendorExtensions) {
if (vendorExtensions != null) {
updateEnumVarsWithExtensions(enumVars, vendorExtensions, "x-enum-varnames", "name");
updateEnumVarsWithExtensions(enumVars, vendorExtensions, "x-enum-descriptions", "enumDescription");

View File

@ -35,6 +35,7 @@ import org.apache.commons.lang3.StringUtils;
import org.openapitools.codegen.config.GlobalSettings;
import org.openapitools.codegen.api.TemplatingEngineAdapter;
import org.openapitools.codegen.ignore.CodegenIgnoreProcessor;
import org.openapitools.codegen.languages.PythonClientExperimentalCodegen;
import org.openapitools.codegen.meta.GeneratorMetadata;
import org.openapitools.codegen.meta.Stability;
import org.openapitools.codegen.serializer.SerializerUtils;
@ -490,10 +491,11 @@ public class DefaultGenerator extends AbstractGenerator implements Generator {
// TODO revise below as we've already performed unaliasing so that the isAlias check may be removed
Map<String, Object> modelTemplate = (Map<String, Object>) ((List<Object>) models.get("models")).get(0);
// Special handling of aliases only applies to Java
if (modelTemplate != null && modelTemplate.containsKey("model")) {
CodegenModel m = (CodegenModel) modelTemplate.get("model");
if (m.isAlias) {
if (m.isAlias && !(config instanceof PythonClientExperimentalCodegen)) {
// alias to number, string, enum, etc, which should not be generated as model
// for PythonClientExperimentalCodegen, all aliases are generated as models
continue; // Don't create user-defined classes for aliases
}
}
@ -943,7 +945,6 @@ public class DefaultGenerator extends AbstractGenerator implements Generator {
* Returns the path of a template, allowing access to the template where consuming literal contents aren't desirable or possible.
*
* @param name the template name (e.g. model.mustache)
*
* @return The {@link Path} to the template
*/
@Override
@ -1063,21 +1064,21 @@ public class DefaultGenerator extends AbstractGenerator implements Generator {
if (authMethods != null && !authMethods.isEmpty()) {
codegenOperation.authMethods = config.fromSecurity(authMethods);
List<Map<String, Object>> scopes = new ArrayList<Map<String, Object>>();
if (codegenOperation.authMethods != null){
for (CodegenSecurity security : codegenOperation.authMethods){
if (codegenOperation.authMethods != null) {
for (CodegenSecurity security : codegenOperation.authMethods) {
if (security != null && security.isBasicBearer != null && security.isBasicBearer &&
securities != null){
for (SecurityRequirement req : securities){
securities != null) {
for (SecurityRequirement req : securities) {
if (req == null) continue;
for (String key : req.keySet()){
if (security.name != null && key.equals(security.name)){
for (String key : req.keySet()) {
if (security.name != null && key.equals(security.name)) {
int count = 0;
for (String sc : req.get(key)){
for (String sc : req.get(key)) {
Map<String, Object> scope = new HashMap<String, Object>();
scope.put("scope", sc);
scope.put("description", "");
count++;
if (req.get(key) != null && count < req.get(key).size()){
if (req.get(key) != null && count < req.get(key).size()) {
scope.put("hasMore", "true");
} else {
scope.put("hasMore", null);

View File

@ -287,6 +287,11 @@ public class CodegenConfigurator {
return this;
}
public CodegenConfigurator setApiNameSuffix(String suffix) {
generatorSettingsBuilder.withApiNameSuffix(suffix);
return this;
}
public CodegenConfigurator setModelNamePrefix(String prefix) {
generatorSettingsBuilder.withModelNamePrefix(prefix);
return this;

View File

@ -181,6 +181,7 @@ public abstract class AbstractCSharpCodegen extends DefaultCodegen implements Co
typeMapping.put("long", "long?");
typeMapping.put("double", "double?");
typeMapping.put("number", "decimal?");
typeMapping.put("BigDecimal", "decimal?");
typeMapping.put("DateTime", "DateTime?");
typeMapping.put("date", "DateTime?");
typeMapping.put("file", "System.IO.Stream");

View File

@ -35,6 +35,7 @@ import org.slf4j.LoggerFactory;
import java.io.File;
import java.net.URL;
import java.util.Arrays;
import java.util.Map;
abstract public class AbstractCppCodegen extends DefaultCodegen implements CodegenConfig {
private static final Logger LOGGER = LoggerFactory.getLogger(AbstractCppCodegen.class);
@ -150,7 +151,7 @@ abstract public class AbstractCppCodegen extends DefaultCodegen implements Codeg
@Override
public String toApiName(String type) {
return sanitizeName(modelNamePrefix + Character.toUpperCase(type.charAt(0)) + type.substring(1) + "Api");
return sanitizeName(modelNamePrefix + super.toApiName(type));
}
@Override
@ -306,4 +307,9 @@ abstract public class AbstractCppCodegen extends DefaultCodegen implements Codeg
this.additionalProperties.put("serverHost", host);
}
}
@Override
public Map<String, Object> postProcessModels(Map<String, Object> objs) {
return postProcessModelsEnum(objs);
}
}

View File

@ -30,10 +30,13 @@ import org.openapitools.codegen.utils.ModelUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.lang.Exception;
import java.io.File;
import java.util.*;
import static org.openapitools.codegen.utils.StringUtils.camelize;
import static org.openapitools.codegen.utils.StringUtils.underscore;
public abstract class AbstractFSharpCodegen extends DefaultCodegen implements CodegenConfig {
@ -246,11 +249,6 @@ public abstract class AbstractFSharpCodegen extends DefaultCodegen implements Co
additionalProperties.put(CodegenConstants.PACKAGE_NAME, packageName);
}
if (additionalProperties.containsKey(CodegenConstants.INVOKER_PACKAGE)) {
LOGGER.warn(String.format(Locale.ROOT, "%s is not used by F# generators. Please use %s",
CodegenConstants.INVOKER_PACKAGE, CodegenConstants.PACKAGE_NAME));
}
// {{packageTitle}}
if (additionalProperties.containsKey(CodegenConstants.PACKAGE_TITLE)) {
setPackageTitle((String) additionalProperties.get(CodegenConstants.PACKAGE_TITLE));
@ -300,32 +298,8 @@ public abstract class AbstractFSharpCodegen extends DefaultCodegen implements Co
additionalProperties.put(CodegenConstants.USE_DATETIME_OFFSET, useDateTimeOffsetFlag);
}
if (additionalProperties.containsKey(CodegenConstants.USE_COLLECTION)) {
setUseCollection(convertPropertyToBooleanAndWriteBack(CodegenConstants.USE_COLLECTION));
} else {
additionalProperties.put(CodegenConstants.USE_COLLECTION, useCollection);
}
if (additionalProperties.containsKey(CodegenConstants.RETURN_ICOLLECTION)) {
setReturnICollection(convertPropertyToBooleanAndWriteBack(CodegenConstants.RETURN_ICOLLECTION));
} else {
additionalProperties.put(CodegenConstants.RETURN_ICOLLECTION, returnICollection);
}
if (additionalProperties.containsKey(CodegenConstants.NETCORE_PROJECT_FILE)) {
setNetCoreProjectFileFlag(convertPropertyToBooleanAndWriteBack(CodegenConstants.NETCORE_PROJECT_FILE));
} else {
additionalProperties.put(CodegenConstants.NETCORE_PROJECT_FILE, netCoreProjectFileFlag);
}
if (additionalProperties.containsKey(CodegenConstants.INTERFACE_PREFIX)) {
String useInterfacePrefix = additionalProperties.get(CodegenConstants.INTERFACE_PREFIX).toString();
if ("false".equals(useInterfacePrefix.toLowerCase(Locale.ROOT))) {
setInterfacePrefix("");
} else if (!"true".equals(useInterfacePrefix.toLowerCase(Locale.ROOT))) {
// NOTE: if user passes "true" explicitly, we use the default I- prefix. The other supported case here is a custom prefix.
setInterfacePrefix(sanitizeName(useInterfacePrefix));
}
if (additionalProperties.containsKey(CodegenConstants.MODEL_PROPERTY_NAMING)) {
setModelPropertyNaming((String) additionalProperties.get(CodegenConstants.MODEL_PROPERTY_NAMING));
}
// This either updates additionalProperties with the above fixes, or sets the default if the option was not specified.
@ -374,62 +348,46 @@ public abstract class AbstractFSharpCodegen extends DefaultCodegen implements Co
/*
* F# does not allow forward declarations, so files must be imported in the correct order.
* Output of CodeGen models must therefore bein dependency order (rather than alphabetical order, which seems to be the default).
* We achieve this by creating a comparator to check whether the first model contains any properties of the comparison model's type
* This could probably be made more efficient if absolutely needed.
*/
@SuppressWarnings({"unchecked"})
public Map<String, Object> postProcessDependencyOrders(final Map<String, Object> objs) {
Comparator<String> comparator = new Comparator<String>() {
@Override
public int compare(String key1, String key2) {
// Get the corresponding models
CodegenModel model1 = ModelUtils.getModelByName(key1, objs);
CodegenModel model2 = ModelUtils.getModelByName(key2, objs);
List<String> complexVars1 = new ArrayList<String>();
List<String> complexVars2 = new ArrayList<String>();
Map<String, Set<String>> dependencies = new HashMap<String, Set<String>>();
for (CodegenProperty prop : model1.vars) {
if (prop.complexType != null)
complexVars1.add(prop.complexType);
}
for (CodegenProperty prop : model2.vars) {
if (prop.complexType != null)
complexVars2.add(prop.complexType);
}
// if first has complex vars and second has none, first is greater
if (complexVars1.size() > 0 && complexVars2.size() == 0)
return 1;
// if second has complex vars and first has none, first is lesser
if (complexVars1.size() == 0 && complexVars2.size() > 0)
return -1;
// if first has complex var that matches the second's key, first is greater
if (complexVars1.contains(key2))
return 1;
// if second has complex var that matches the first's key, first is lesser
if (complexVars2.contains(key1))
return -1;
// if none of the above, don't care
return 0;
List<String> classNames = new ArrayList<String>();
for (String k : objs.keySet()) {
CodegenModel model = ModelUtils.getModelByName(k, objs);
if (model == null || model.classname == null) {
throw new RuntimeException("Null model encountered");
}
dependencies.put(model.classname, model.imports);
classNames.add(model.classname);
}
Object[] sortedKeys = classNames.toArray();
for (int i1 = 0; i1 < sortedKeys.length; i1++) {
String k1 = sortedKeys[i1].toString();
for (int i2 = i1 + 1; i2 < sortedKeys.length; i2++) {
String k2 = sortedKeys[i2].toString();
if (dependencies.get(k2).contains(k1)) {
sortedKeys[i2] = k1;
sortedKeys[i1] = k2;
i1 = -1;
break;
}
}
};
PriorityQueue<String> queue = new PriorityQueue<String>(objs.size(), comparator);
for (Object k : objs.keySet()) {
queue.add(k.toString());
}
Map<String, Object> sorted = new LinkedHashMap<String, Object>();
while (queue.size() > 0) {
String key = queue.poll();
sorted.put(key, objs.get(key));
for (int i = sortedKeys.length - 1; i >= 0; i--) {
Object k = sortedKeys[i];
sorted.put(k.toString(), objs.get(k));
}
return sorted;
}
@ -684,6 +642,39 @@ public abstract class AbstractFSharpCodegen extends DefaultCodegen implements Co
return camelize(sanitizeName(operationId));
}
public String getModelPropertyNaming() {
return this.modelPropertyNaming;
}
public void setModelPropertyNaming(String naming) {
if ("original".equals(naming) || "camelCase".equals(naming) ||
"PascalCase".equals(naming) || "snake_case".equals(naming)) {
this.modelPropertyNaming = naming;
} else {
throw new IllegalArgumentException("Invalid model property naming '" +
naming + "'. Must be 'original', 'camelCase', " +
"'PascalCase' or 'snake_case'");
}
}
public String getNameUsingModelPropertyNaming(String name) {
switch (CodegenConstants.MODEL_PROPERTY_NAMING_TYPE.valueOf(getModelPropertyNaming())) {
case original:
return name;
case camelCase:
return camelize(name, true);
case PascalCase:
return camelize(name);
case snake_case:
return underscore(name);
default:
throw new IllegalArgumentException("Invalid model property naming '" +
name + "'. Must be 'original', 'camelCase', " +
"'PascalCase' or 'snake_case'");
}
}
@Override
public String toVarName(String name) {
// sanitize name
@ -694,9 +685,8 @@ public abstract class AbstractFSharpCodegen extends DefaultCodegen implements Co
return name;
}
// camelize the variable name
// pet_id => PetId
name = camelize(name);
name = getNameUsingModelPropertyNaming(name);
// for reserved word or word starting with number, append _
if (isReservedWord(name) || name.matches("^\\d.*")) {
name = escapeReservedWord(name);

View File

@ -96,6 +96,7 @@ public abstract class AbstractGoCodegen extends DefaultCodegen implements Codege
typeMapping.put("number", "float32");
typeMapping.put("float", "float32");
typeMapping.put("double", "float64");
typeMapping.put("BigDecimal", "float64");
typeMapping.put("boolean", "bool");
typeMapping.put("string", "string");
typeMapping.put("UUID", "string");
@ -376,6 +377,11 @@ public abstract class AbstractGoCodegen extends DefaultCodegen implements Codege
boolean addedOSImport = false;
boolean addedReflectImport = false;
for (CodegenOperation operation : operations) {
// import "os" if the operation uses files
if (!addedOSImport && "*os.File".equals(operation.returnType)) {
imports.add(createMapping("import", "os"));
addedOSImport = true;
}
for (CodegenParameter param : operation.allParams) {
// import "os" if the operation uses files
if (!addedOSImport && "*os.File".equals(param.dataType)) {
@ -489,7 +495,8 @@ public abstract class AbstractGoCodegen extends DefaultCodegen implements Codege
if (v instanceof CodegenModel) {
CodegenModel model = (CodegenModel) v;
for (CodegenProperty param : model.vars) {
if (!addedTimeImport && "time.Time".equals(param.baseType)) {
if (!addedTimeImport
&& "time.Time".equals(param.dataType) || ("[]time.Time".equals(param.dataType))) {
imports.add(createMapping("import", "time"));
addedTimeImport = true;
}

View File

@ -43,6 +43,8 @@ import static org.openapitools.codegen.utils.StringUtils.*;
public abstract class AbstractJavaCodegen extends DefaultCodegen implements CodegenConfig {
private static final Logger LOGGER = LoggerFactory.getLogger(AbstractJavaCodegen.class);
private static final String ARTIFACT_VERSION_DEFAULT_VALUE = "1.0.0";
public static final String FULL_JAVA_UTIL = "fullJavaUtil";
public static final String DEFAULT_LIBRARY = "<default>";
public static final String DATE_LIBRARY = "dateLibrary";
@ -60,7 +62,7 @@ public abstract class AbstractJavaCodegen extends DefaultCodegen implements Code
protected String invokerPackage = "org.openapitools";
protected String groupId = "org.openapitools";
protected String artifactId = "openapi-java";
protected String artifactVersion = "1.0.0";
protected String artifactVersion = null;
protected String artifactUrl = "https://github.com/openapitools/openapi-generator";
protected String artifactDescription = "OpenAPI Java";
protected String developerName = "OpenAPI-Generator Contributors";
@ -144,7 +146,7 @@ public abstract class AbstractJavaCodegen extends DefaultCodegen implements Code
cliOptions.add(new CliOption(CodegenConstants.INVOKER_PACKAGE, CodegenConstants.INVOKER_PACKAGE_DESC).defaultValue(this.getInvokerPackage()));
cliOptions.add(new CliOption(CodegenConstants.GROUP_ID, CodegenConstants.GROUP_ID_DESC).defaultValue(this.getGroupId()));
cliOptions.add(new CliOption(CodegenConstants.ARTIFACT_ID, CodegenConstants.ARTIFACT_ID_DESC).defaultValue(this.getArtifactId()));
cliOptions.add(new CliOption(CodegenConstants.ARTIFACT_VERSION, CodegenConstants.ARTIFACT_VERSION_DESC).defaultValue(this.getArtifactVersion()));
cliOptions.add(new CliOption(CodegenConstants.ARTIFACT_VERSION, CodegenConstants.ARTIFACT_VERSION_DESC).defaultValue(ARTIFACT_VERSION_DEFAULT_VALUE));
cliOptions.add(new CliOption(CodegenConstants.ARTIFACT_URL, CodegenConstants.ARTIFACT_URL_DESC).defaultValue(this.getArtifactUrl()));
cliOptions.add(new CliOption(CodegenConstants.ARTIFACT_DESCRIPTION, CodegenConstants.ARTIFACT_DESCRIPTION_DESC).defaultValue(this.getArtifactDescription()));
cliOptions.add(new CliOption(CodegenConstants.SCM_CONNECTION, CodegenConstants.SCM_CONNECTION_DESC).defaultValue(this.getScmConnection()));
@ -1038,12 +1040,18 @@ public abstract class AbstractJavaCodegen extends DefaultCodegen implements Code
}
}
// If no artifactVersion is provided in additional properties, version from API specification is used.
// If none of them is provided then fallbacks to default version
if (additionalProperties.containsKey(CodegenConstants.ARTIFACT_VERSION)) {
this.setArtifactVersion((String) additionalProperties.get(CodegenConstants.ARTIFACT_VERSION));
} else if (openAPI.getInfo() != null && openAPI.getInfo().getVersion() != null) {
this.setArtifactVersion(openAPI.getInfo().getVersion());
if(artifactVersion == null) {
// If no artifactVersion is provided in additional properties, version from API specification is used.
// If none of them is provided then fallbacks to default version
if (additionalProperties.containsKey(CodegenConstants.ARTIFACT_VERSION)) {
this.setArtifactVersion((String) additionalProperties.get(CodegenConstants.ARTIFACT_VERSION));
} else if (openAPI.getInfo() != null && openAPI.getInfo().getVersion() != null) {
this.setArtifactVersion(openAPI.getInfo().getVersion());
} else {
this.setArtifactVersion(ARTIFACT_VERSION_DEFAULT_VALUE);
}
} else {
additionalProperties.put(CodegenConstants.ARTIFACT_VERSION, artifactVersion);
}
if (additionalProperties.containsKey(CodegenConstants.SNAPSHOT_VERSION)) {
@ -1433,7 +1441,10 @@ public abstract class AbstractJavaCodegen extends DefaultCodegen implements Code
* @return SNAPSHOT version
*/
private String buildSnapshotVersion(String version) {
return version + "-" + "SNAPSHOT";
if(version.endsWith("-SNAPSHOT")) {
return version;
}
return version + "-SNAPSHOT";
}
public void setSupportJava6(boolean value) {

View File

@ -244,11 +244,10 @@ public abstract class AbstractJavaJAXRSServerCodegen extends AbstractJavaCodegen
@Override
public String toApiName(final String name) {
String computed = name;
if (computed.length() == 0) {
return "DefaultApi";
if (computed.length() > 0) {
computed = sanitizeName(computed);
}
computed = sanitizeName(computed);
return camelize(computed) + "Api";
return super.toApiName(computed);
}
@Override

View File

@ -54,6 +54,8 @@ public abstract class AbstractKotlinCodegen extends DefaultCodegen implements Co
protected String modelDocPath = "docs/";
protected boolean parcelizeModels = false;
protected boolean serializableModel = false;
protected CodegenConstants.ENUM_PROPERTY_NAMING_TYPE enumPropertyNaming = CodegenConstants.ENUM_PROPERTY_NAMING_TYPE.camelCase;
protected SERIALIZATION_LIBRARY_TYPE serializationLibrary = SERIALIZATION_LIBRARY_TYPE.moshi;
@ -215,6 +217,7 @@ public abstract class AbstractKotlinCodegen extends DefaultCodegen implements Co
cliOptions.add(serializationLibraryOpt.defaultValue(serializationLibrary.name()));
cliOptions.add(new CliOption(CodegenConstants.PARCELIZE_MODELS, CodegenConstants.PARCELIZE_MODELS_DESC));
cliOptions.add(new CliOption(CodegenConstants.SERIALIZABLE_MODEL, CodegenConstants.SERIALIZABLE_MODEL_DESC));
}
@Override
@ -411,16 +414,14 @@ public abstract class AbstractKotlinCodegen extends DefaultCodegen implements Co
LOGGER.warn(CodegenConstants.INVOKER_PACKAGE + " with " + this.getName() + " generator is ignored. Use " + CodegenConstants.PACKAGE_NAME + ".");
}
if (additionalProperties.containsKey(CodegenConstants.SERIALIZABLE_MODEL)) {
this.setSerializableModel(Boolean.valueOf((String) additionalProperties.get(CodegenConstants.SERIALIZABLE_MODEL)));
} else {
additionalProperties.put(CodegenConstants.SERIALIZABLE_MODEL, serializableModel);
}
if (additionalProperties.containsKey(CodegenConstants.PARCELIZE_MODELS)) {
this.setParcelizeModels(Boolean.valueOf((String) additionalProperties.get(CodegenConstants.PARCELIZE_MODELS)));
LOGGER.info(CodegenConstants.PARCELIZE_MODELS + " depends on the android framework and " +
"experimental parcelize feature. Make sure your build applies the android plugin:\n" +
"apply plugin: 'com.android.library' OR apply plugin: 'com.android.application'.\n" +
"and enables the experimental features:\n" +
"androidExtensions {\n" +
" experimental = true\n" +
"}"
);
} else {
additionalProperties.put(CodegenConstants.PARCELIZE_MODELS, parcelizeModels);
}
@ -468,6 +469,13 @@ public abstract class AbstractKotlinCodegen extends DefaultCodegen implements Co
this.parcelizeModels = parcelizeModels;
}
public boolean isSerializableModel() {
return serializableModel;
}
public void setSerializableModel(boolean serializableModel) {
this.serializableModel = serializableModel;
}
/**
* Return the sanitized variable name for enum
*

View File

@ -95,6 +95,7 @@ public class CSharpClientCodegen extends AbstractCSharpCodegen {
typeMapping.put("long", "long");
typeMapping.put("double", "double");
typeMapping.put("number", "decimal");
typeMapping.put("BigDecimal", "decimal");
typeMapping.put("DateTime", "DateTime");
typeMapping.put("date", "DateTime");
typeMapping.put("UUID", "Guid");

View File

@ -94,6 +94,7 @@ public class CSharpNetCoreClientCodegen extends AbstractCSharpCodegen {
typeMapping.put("long", "long");
typeMapping.put("double", "double");
typeMapping.put("number", "decimal");
typeMapping.put("BigDecimal", "decimal");
typeMapping.put("DateTime", "DateTime");
typeMapping.put("date", "DateTime");
typeMapping.put("file", "System.IO.Stream");

View File

@ -27,6 +27,8 @@ import org.apache.commons.lang3.StringUtils;
import org.openapitools.codegen.*;
import org.openapitools.codegen.utils.ModelUtils;
import org.openapitools.codegen.utils.URLPathUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.File;
import java.util.*;
@ -35,10 +37,15 @@ import java.net.URL;
import static org.openapitools.codegen.utils.StringUtils.*;
public class CppPistacheServerCodegen extends AbstractCppCodegen {
private static final Logger LOGGER = LoggerFactory.getLogger(CppPistacheServerCodegen.class);
protected String implFolder = "impl";
protected boolean isAddExternalLibs = true;
protected boolean isUseStructModel = false;
public static final String OPTIONAL_EXTERNAL_LIB = "addExternalLibs";
public static final String OPTIONAL_EXTERNAL_LIB_DESC = "Add the Possibility to fetch and compile external Libraries needed by this Framework.";
public static final String OPTION_USE_STRUCT_MODEL = "useStructModel";
public static final String OPTION_USE_STRUCT_MODEL_DESC = "Use struct-based model template instead of get/set-based model template";
public static final String HELPERS_PACKAGE_NAME = "helpersPackage";
public static final String HELPERS_PACKAGE_NAME_DESC = "Specify the package name to be used for the helpers (e.g. org.openapitools.server.helpers).";
protected final String PREFIX = "";
@ -68,9 +75,6 @@ public class CppPistacheServerCodegen extends AbstractCppCodegen {
apiPackage = "org.openapitools.server.api";
modelPackage = "org.openapitools.server.model";
modelTemplateFiles.put("model-header.mustache", ".h");
modelTemplateFiles.put("model-source.mustache", ".cpp");
apiTemplateFiles.put("api-header.mustache", ".h");
apiTemplateFiles.put("api-source.mustache", ".cpp");
apiTemplateFiles.put("api-impl-header.mustache", ".h");
@ -81,6 +85,7 @@ public class CppPistacheServerCodegen extends AbstractCppCodegen {
cliOptions.clear();
addSwitch(OPTIONAL_EXTERNAL_LIB, OPTIONAL_EXTERNAL_LIB_DESC, this.isAddExternalLibs);
addOption(HELPERS_PACKAGE_NAME, HELPERS_PACKAGE_NAME_DESC, this.helpersPackage);
addSwitch(OPTION_USE_STRUCT_MODEL, OPTION_USE_STRUCT_MODEL_DESC, this.isUseStructModel);
reservedWords = new HashSet<>();
@ -144,6 +149,23 @@ public class CppPistacheServerCodegen extends AbstractCppCodegen {
} else {
additionalProperties.put(OPTIONAL_EXTERNAL_LIB, isAddExternalLibs);
}
setupModelTemplate();
}
private void setupModelTemplate() {
if (additionalProperties.containsKey(OPTION_USE_STRUCT_MODEL))
isUseStructModel = convertPropertyToBooleanAndWriteBack(OPTION_USE_STRUCT_MODEL);
if (isUseStructModel) {
LOGGER.info("Using struct-based model template");
modelTemplateFiles.put("model-struct-header.mustache", ".h");
modelTemplateFiles.put("model-struct-source.mustache", ".cpp");
} else {
LOGGER.info("Using get/set-based model template");
modelTemplateFiles.put("model-header.mustache", ".h");
modelTemplateFiles.put("model-source.mustache", ".cpp");
}
}
@Override

View File

@ -332,11 +332,6 @@ public class CppQt5AbstractCodegen extends AbstractCppCodegen implements Codegen
return objs;
}
@Override
public Map<String, Object> postProcessModels(Map<String, Object> objs) {
return postProcessModelsEnum(objs);
}
@Override
public String toEnumValue(String value, String datatype) {
return escapeText(value);

View File

@ -0,0 +1,151 @@
/*
* Copyright 2018 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. x
*/
package org.openapitools.codegen.languages;
import org.openapitools.codegen.*;
import org.openapitools.codegen.meta.GeneratorMetadata;
import org.openapitools.codegen.meta.Stability;
import io.swagger.models.properties.ArrayProperty;
import io.swagger.models.properties.MapProperty;
import io.swagger.models.properties.Property;
import io.swagger.models.parameters.Parameter;
import java.io.File;
import java.util.*;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class FsharpFunctionsServerCodegen extends AbstractFSharpCodegen {
public static final String PROJECT_NAME = "projectName";
static Logger LOGGER = LoggerFactory.getLogger(FsharpFunctionsServerCodegen.class);
public CodegenType getTag() {
return CodegenType.SERVER;
}
public String getName() {
return "fsharp-functions";
}
public String getHelp() {
return "Generates a fsharp-functions server (beta).";
}
public FsharpFunctionsServerCodegen() {
super();
generatorMetadata = GeneratorMetadata.newBuilder(generatorMetadata)
.stability(Stability.BETA)
.build();
// CLI options
addOption(CodegenConstants.LICENSE_URL,
CodegenConstants.LICENSE_URL_DESC,
licenseUrl);
addOption(CodegenConstants.LICENSE_NAME,
CodegenConstants.LICENSE_NAME_DESC,
licenseName);
addOption(CodegenConstants.PACKAGE_COPYRIGHT,
CodegenConstants.PACKAGE_COPYRIGHT_DESC,
packageCopyright);
addOption(CodegenConstants.PACKAGE_AUTHORS,
CodegenConstants.PACKAGE_AUTHORS_DESC,
packageAuthors);
addOption(CodegenConstants.PACKAGE_TITLE,
CodegenConstants.PACKAGE_TITLE_DESC,
packageTitle);
addOption(CodegenConstants.PACKAGE_NAME,
"F# module name (convention: Title.Case).",
packageName);
addOption(CodegenConstants.PACKAGE_VERSION,
"F# package version.",
packageVersion);
addOption(CodegenConstants.OPTIONAL_PROJECT_GUID,
CodegenConstants.OPTIONAL_PROJECT_GUID_DESC,
null);
addOption(CodegenConstants.SOURCE_FOLDER,
CodegenConstants.SOURCE_FOLDER_DESC,
sourceFolder);
}
@Override
public void processOpts() {
super.processOpts();
modelPackage = "Model";
embeddedTemplateDir = templateDir = "fsharp-functions-server";
apiTemplateFiles.put("Handler.mustache", "Handler.fs");
apiTemplateFiles.put("HandlerParams.mustache", "HandlerParams.fs");
apiTemplateFiles.put("ServiceInterface.mustache", "ServiceInterface.fs");
apiTemplateFiles.put("ServiceImpl.mustache", "Service.fs");
modelTemplateFiles.put("Model.mustache", ".fs");
String implFolder = sourceFolder + File.separator + "impl";
supportingFiles.add(new SupportingFile("gitignore.mustache", "", ".gitignore"));
supportingFiles.add(new SupportingFile("build.sh.mustache", projectFolder, "build.sh"));
supportingFiles.add(new SupportingFile("build.bat.mustache", projectFolder, "build.bat"));
supportingFiles.add(new SupportingFile("host.json", "", "host.json"));
supportingFiles.add(new SupportingFile("local.settings.json", "", "local.settings.json"));
supportingFiles.add(new SupportingFile("Project.fsproj.mustache", projectFolder, packageName + ".fsproj"));
}
@Override
public String modelFileFolder() {
return super.modelFileFolder().replace("Model", "model");
}
@Override
public String apiFileFolder() {
return super.apiFileFolder() + File.separator + "api";
}
private String implFileFolder() {
return outputFolder + File.separator + sourceFolder + File.separator + "impl";
}
@Override()
public String toModelImport(String name) {
return packageName + "." + modelPackage() + "." + name;
}
@Override
public String apiFilename(String templateName, String tag) {
String result = super.apiFilename(templateName, tag);
if (templateName.endsWith("Impl.mustache")) {
int ix = result.lastIndexOf(File.separatorChar);
result = result.substring(0, ix) + result.substring(ix, result.length() - 2) + "fs";
result = result.replace(apiFileFolder(), implFileFolder());
}
return result;
}
}

View File

@ -22,6 +22,8 @@ import io.swagger.v3.oas.models.OpenAPI;
import org.openapitools.codegen.CodegenConstants;
import org.openapitools.codegen.CodegenOperation;
import org.openapitools.codegen.CodegenType;
import org.openapitools.codegen.meta.GeneratorMetadata;
import org.openapitools.codegen.meta.Stability;
import org.openapitools.codegen.SupportingFile;
import org.openapitools.codegen.utils.URLPathUtils;
import org.slf4j.Logger;
@ -59,6 +61,10 @@ public class FsharpGiraffeServerCodegen extends AbstractFSharpCodegen {
public FsharpGiraffeServerCodegen() {
super();
generatorMetadata = GeneratorMetadata.newBuilder(generatorMetadata)
.stability(Stability.BETA)
.build();
modelPackage = "Model";
apiTemplateFiles.put("Handler.mustache", "Handler.fs");
@ -187,7 +193,6 @@ public class FsharpGiraffeServerCodegen extends AbstractFSharpCodegen {
LOGGER.warn("Library flag not currently supported.");
String authFolder = sourceFolder + File.separator + "auth";
String serviceFolder = sourceFolder + File.separator + "services";
String implFolder = sourceFolder + File.separator + "impl";
String helperFolder = sourceFolder + File.separator + "helpers";

View File

@ -63,6 +63,7 @@ public class HaskellHttpClientCodegen extends DefaultCodegen implements CodegenC
public static final String PROP_CABAL_VERSION = "cabalVersion";
public static final String PROP_CONFIG_TYPE = "configType";
public static final String PROP_DATETIME_FORMAT = "dateTimeFormat";
public static final String PROP_DATETIME_PARSE_FORMAT = "dateTimeParseFormat";
public static final String PROP_CUSTOM_TEST_INSTANCE_MODULE = "customTestInstanceModule";
public static final String PROP_DATE_FORMAT = "dateFormat";
public static final String PROP_GENERATE_ENUMS = "generateEnums";
@ -222,6 +223,7 @@ public class HaskellHttpClientCodegen extends DefaultCodegen implements CodegenC
typeMapping.put("float", "Float");
typeMapping.put("double", "Double");
typeMapping.put("number", "Double");
typeMapping.put("BigDecimal", "Double");
typeMapping.put("integer", "Int");
typeMapping.put("file", "FilePath");
// lib
@ -270,6 +272,7 @@ public class HaskellHttpClientCodegen extends DefaultCodegen implements CodegenC
cliOptions.add(CliOption.newBoolean(PROP_USE_KATIP, "Sets the default value for the UseKatip cabal flag. If true, the katip package provides logging instead of monad-logger").defaultValue((Boolean.TRUE.toString())));
cliOptions.add(CliOption.newString(PROP_DATETIME_FORMAT, "format string used to parse/render a datetime"));
cliOptions.add(CliOption.newString(PROP_DATETIME_PARSE_FORMAT, "overrides the format string used to parse a datetime"));
cliOptions.add(CliOption.newString(PROP_DATE_FORMAT, "format string used to parse/render a date").defaultValue(defaultDateFormat));
cliOptions.add(CliOption.newString(PROP_CUSTOM_TEST_INSTANCE_MODULE, "test module used to provide typeclass instances for types not known by the generator"));
@ -320,9 +323,9 @@ public class HaskellHttpClientCodegen extends DefaultCodegen implements CodegenC
}
}
public void setDateTimeFormat(String value) {
setStringProp(PROP_DATETIME_FORMAT, value);
}
public void setDateTimeFormat(String value) { setStringProp(PROP_DATETIME_FORMAT, value); }
public void setDateTimeParseFormat(String value) { setStringProp(PROP_DATETIME_PARSE_FORMAT, value); }
public void setDateFormat(String value) { setStringProp(PROP_DATE_FORMAT, value); }
@ -437,6 +440,12 @@ public class HaskellHttpClientCodegen extends DefaultCodegen implements CodegenC
setDateTimeFormat(null); // default should be null
}
if (additionalProperties.containsKey(PROP_DATETIME_PARSE_FORMAT)) {
setDateTimeParseFormat(additionalProperties.get(PROP_DATETIME_PARSE_FORMAT).toString());
} else {
setDateTimeParseFormat(null); // default should be null
}
if (additionalProperties.containsKey(PROP_DATE_FORMAT)) {
setDateFormat(additionalProperties.get(PROP_DATE_FORMAT).toString());
} else {

View File

@ -171,6 +171,7 @@ public class HaskellServantCodegen extends DefaultCodegen implements CodegenConf
typeMapping.put("file", "FilePath");
typeMapping.put("binary", "FilePath");
typeMapping.put("number", "Double");
typeMapping.put("BigDecimal", "Double");
typeMapping.put("any", "Value");
typeMapping.put("UUID", "UUID");
typeMapping.put("URI", "Text");

View File

@ -17,19 +17,23 @@
package org.openapitools.codegen.languages;
import static org.openapitools.codegen.utils.StringUtils.camelize;
import io.swagger.v3.oas.models.Operation;
import io.swagger.v3.oas.models.media.Schema;
import org.apache.commons.lang3.StringUtils;
import org.openapitools.codegen.*;
import org.openapitools.codegen.CliOption;
import org.openapitools.codegen.CodegenConstants;
import org.openapitools.codegen.CodegenModel;
import org.openapitools.codegen.CodegenOperation;
import org.openapitools.codegen.SupportingFile;
import java.io.File;
import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import static org.openapitools.codegen.utils.StringUtils.camelize;
public class JavaJAXRSSpecServerCodegen extends AbstractJavaJAXRSServerCodegen {
public static final String INTERFACE_ONLY = "interfaceOnly";
@ -39,6 +43,11 @@ public class JavaJAXRSSpecServerCodegen extends AbstractJavaJAXRSServerCodegen {
public static final String JACKSON = "jackson";
public static final String OPEN_API_SPEC_FILE_LOCATION = "openApiSpecFileLocation";
public static final String QUARKUS_LIBRARY = "quarkus";
public static final String THORNTAIL_LIBRARY = "thorntail";
public static final String OPEN_LIBERTY_LIBRARY = "openliberty";
public static final String HELIDON_LIBRARY = "helidon";
private boolean interfaceOnly = false;
private boolean returnResponse = false;
private boolean generatePom = true;
@ -84,8 +93,11 @@ public class JavaJAXRSSpecServerCodegen extends AbstractJavaJAXRSServerCodegen {
removeOption(CodegenConstants.LIBRARY);
CliOption library = new CliOption(CodegenConstants.LIBRARY, CodegenConstants.LIBRARY_DESC).defaultValue(DEFAULT_LIBRARY);
Map<String, String> supportedLibraries = new LinkedHashMap<>();
supportedLibraries.put(DEFAULT_LIBRARY, "JAXRS");
supportedLibraries.put(DEFAULT_LIBRARY, "JAXRS spec only, to be deployed in an app server (TomEE, JBoss, WLS, ...)");
supportedLibraries.put(QUARKUS_LIBRARY, "Server using Quarkus");
supportedLibraries.put(THORNTAIL_LIBRARY, "Server using Thorntail");
supportedLibraries.put(OPEN_LIBERTY_LIBRARY, "Server using Open Liberty");
supportedLibraries.put(HELIDON_LIBRARY, "Server using Helidon");
library.setEnum(supportedLibraries);
cliOptions.add(library);
@ -113,12 +125,20 @@ public class JavaJAXRSSpecServerCodegen extends AbstractJavaJAXRSServerCodegen {
additionalProperties.remove(RETURN_RESPONSE);
}
}
if (additionalProperties.containsKey(USE_SWAGGER_ANNOTATIONS)) {
useSwaggerAnnotations = Boolean.valueOf(additionalProperties.get(USE_SWAGGER_ANNOTATIONS).toString());
if(QUARKUS_LIBRARY.equals(library) || THORNTAIL_LIBRARY.equals(library) || HELIDON_LIBRARY.equals(library) || OPEN_LIBERTY_LIBRARY.equals(library)) {
useSwaggerAnnotations = false;
} else {
if (additionalProperties.containsKey(USE_SWAGGER_ANNOTATIONS)) {
useSwaggerAnnotations = Boolean.valueOf(additionalProperties.get(USE_SWAGGER_ANNOTATIONS).toString());
}
}
writePropertyBack(USE_SWAGGER_ANNOTATIONS, useSwaggerAnnotations);
if (additionalProperties.containsKey(OPEN_API_SPEC_FILE_LOCATION)) {
openApiSpecFileLocation = additionalProperties.get(OPEN_API_SPEC_FILE_LOCATION).toString();
} else if(QUARKUS_LIBRARY.equals(library) || THORNTAIL_LIBRARY.equals(library) || HELIDON_LIBRARY.equals(library)) {
openApiSpecFileLocation = "src/main/resources/META-INF/openapi.yaml";
} else if(OPEN_LIBERTY_LIBRARY.equals(library)) {
openApiSpecFileLocation = "src/main/webapp/META-INF/openapi.yaml";
}
additionalProperties.put(OPEN_API_SPEC_FILE_LOCATION, openApiSpecFileLocation);
@ -154,6 +174,26 @@ public class JavaJAXRSSpecServerCodegen extends AbstractJavaJAXRSServerCodegen {
}
supportingFiles.add(new SupportingFile("openapi.mustache", fileFolder, fileName));
}
if(QUARKUS_LIBRARY.equals(library)) {
writeOptional(outputFolder, new SupportingFile("application.properties.mustache", "src/main/resources", "application.properties"));
writeOptional(outputFolder, new SupportingFile("Dockerfile.jvm.mustache", "src/main/docker", "Dockerfile.jvm"));
writeOptional(outputFolder, new SupportingFile("Dockerfile.native.mustache", "src/main/docker", "Dockerfile.native"));
writeOptional(outputFolder, new SupportingFile("dockerignore.mustache", "", ".dockerignore"));
} else if(OPEN_LIBERTY_LIBRARY.equals(library)) {
writeOptional(outputFolder, new SupportingFile("server.xml.mustache", "src/main/liberty/config", "server.xml"));
writeOptional(outputFolder, new SupportingFile("beans.xml.mustache", "src/main/webapp/META-INF", "beans.xml"));
writeOptional(outputFolder, new SupportingFile("MANIFEST.MF.mustache", "src/main/webapp/META-INF", "MANIFEST.MF"));
writeOptional(outputFolder, new SupportingFile("microprofile-config.properties.mustache", "src/main/webapp/META-INF", "microprofile-config.properties"));
writeOptional(outputFolder, new SupportingFile("ibm-web-ext.xml.mustache", "src/main/webapp/WEB-INF", "ibm-web-ext.xml"));
} else if(HELIDON_LIBRARY.equals(library)) {
writeOptional(outputFolder, new SupportingFile("logging.properties.mustache", "src/main/resources", "logging.properties"));
writeOptional(outputFolder, new SupportingFile("microprofile-config.properties.mustache", "src/main/resources/META-INF", "microprofile-config.properties"));
writeOptional(outputFolder, new SupportingFile("beans.xml.mustache", "src/main/webapp/META-INF", "beans.xml"));
}
}
@Override

View File

@ -144,6 +144,7 @@ public class JavascriptClientCodegen extends DefaultCodegen implements CodegenCo
typeMapping.put("int", "Number");
typeMapping.put("float", "Number");
typeMapping.put("number", "Number");
typeMapping.put("BigDecimal", "Number");
typeMapping.put("DateTime", "Date");
typeMapping.put("date", "Date");
typeMapping.put("long", "Number");

View File

@ -19,25 +19,17 @@ package org.openapitools.codegen.languages;
import org.openapitools.codegen.CliOption;
import org.openapitools.codegen.CodegenConstants;
import org.openapitools.codegen.CodegenModel;
import org.openapitools.codegen.CodegenOperation;
import org.openapitools.codegen.CodegenProperty;
import org.openapitools.codegen.CodegenType;
import org.openapitools.codegen.SupportingFile;
import java.io.File;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.regex.Pattern;
public class KotlinClientCodegen extends AbstractKotlinCodegen {
protected static final String VENDOR_EXTENSION_ESCAPED_NAME = "x-escapedName";
protected static final String JVM = "jvm";
protected static final String MULTIPLATFORM = "multiplatform";
@ -47,14 +39,6 @@ public class KotlinClientCodegen extends AbstractKotlinCodegen {
protected String dateLibrary = DateLibrary.JAVA8.value;
protected String collectionType = CollectionType.ARRAY.value;
// https://kotlinlang.org/docs/reference/grammar.html#Identifier
protected static final Pattern IDENTIFIER_PATTERN =
Pattern.compile("[\\p{Ll}\\p{Lm}\\p{Lo}\\p{Lt}\\p{Lu}\\p{Nl}_][\\p{Ll}\\p{Lm}\\p{Lo}\\p{Lt}\\p{Lu}\\p{Nl}\\p{Nd}_]*");
// https://kotlinlang.org/docs/reference/grammar.html#Identifier
protected static final String IDENTIFIER_REPLACEMENTS =
"[.;:/\\[\\]<>]";
public enum DateLibrary {
STRING("string"),
THREETENBP("threetenbp"),
@ -212,7 +196,6 @@ public class KotlinClientCodegen extends AbstractKotlinCodegen {
supportingFiles.add(new SupportingFile("infrastructure/HttpResponse.kt.mustache", infrastructureFolder, "HttpResponse.kt"));
// multiplatform specific testing files
final String testFolder = (sourceFolder + File.separator + packageName + File.separator + "infrastructure").replace(".", "/");
supportingFiles.add(new SupportingFile("commonTest/coroutine.mustache", "src/commonTest/kotlin/util", "Coroutine.kt"));
supportingFiles.add(new SupportingFile("iosTest/coroutine.mustache", "src/iosTest/kotlin/util", "Coroutine.kt"));
supportingFiles.add(new SupportingFile("jvmTest/coroutine.mustache", "src/jvmTest/kotlin/util", "Coroutine.kt"));
@ -253,58 +236,6 @@ public class KotlinClientCodegen extends AbstractKotlinCodegen {
}
}
@Override
public Map<String, Object> postProcessModels(Map<String, Object> objs) {
objs = super.postProcessModels(objs);
return postProcessModelsEscapeNames(objs);
}
@SuppressWarnings("unchecked")
private static Map<String, Object> postProcessModelsEscapeNames(Map<String, Object> objs) {
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");
if (cm.vars != null) {
for (CodegenProperty var : cm.vars) {
var.vendorExtensions.put(VENDOR_EXTENSION_ESCAPED_NAME, escapeIdentifier(var.name));
}
}
if (cm.requiredVars != null) {
for (CodegenProperty var : cm.requiredVars) {
var.vendorExtensions.put(VENDOR_EXTENSION_ESCAPED_NAME, escapeIdentifier(var.name));
}
}
if (cm.optionalVars != null) {
for (CodegenProperty var : cm.optionalVars) {
var.vendorExtensions.put(VENDOR_EXTENSION_ESCAPED_NAME, escapeIdentifier(var.name));
}
}
}
return objs;
}
private static String escapeIdentifier(String identifier) {
// the kotlin grammar permits a wider set of characters in their identifiers that all target
// platforms permit (namely jvm). in order to remain compatible with target platforms, we
// initially replace all illegal target characters before escaping the identifier if required.
identifier = identifier.replaceAll(IDENTIFIER_REPLACEMENTS, "_");
if (IDENTIFIER_PATTERN.matcher(identifier).matches()) return identifier;
return '`' + identifier + '`';
}
private static void removeDuplicates(List<CodegenProperty> list) {
Set<String> set = new HashSet<>();
Iterator<CodegenProperty> iterator = list.iterator();
while (iterator.hasNext()) {
CodegenProperty item = iterator.next();
if (set.contains(item.name)) iterator.remove();
else set.add(item.name);
}
}
@Override
@SuppressWarnings("unchecked")
public Map<String, Object> postProcessOperationsWithModels(Map<String, Object> objs, List<Object> allModels) {

View File

@ -531,7 +531,7 @@ public class PythonClientCodegen extends DefaultCodegen implements CodegenConfig
name = name.replaceAll("-", "_");
// e.g. PhoneNumberApi.py => phone_number_api.py
return underscore(name) + "_api";
return underscore(name+ "_" + apiNameSuffix);
}
@Override
@ -541,11 +541,7 @@ public class PythonClientCodegen extends DefaultCodegen implements CodegenConfig
@Override
public String toApiName(String name) {
if (name.length() == 0) {
return "DefaultApi";
}
// e.g. phone_number_api => PhoneNumberApi
return camelize(name) + "Api";
return super.toApiName(name);
}
@Override
@ -553,7 +549,7 @@ public class PythonClientCodegen extends DefaultCodegen implements CodegenConfig
if (name.length() == 0) {
return "default_api";
}
return underscore(name) + "_api";
return underscore(name+ "_" + apiNameSuffix);
}
@Override

View File

@ -16,31 +16,50 @@
package org.openapitools.codegen.languages;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import io.swagger.v3.oas.models.Operation;
import io.swagger.v3.oas.models.examples.Example;
import io.swagger.v3.oas.models.media.*;
import io.swagger.v3.oas.models.media.ArraySchema;
import io.swagger.v3.oas.models.media.MediaType;
import io.swagger.v3.oas.models.media.Schema;
import io.swagger.v3.oas.models.parameters.Parameter;
import io.swagger.v3.oas.models.parameters.RequestBody;
import io.swagger.v3.oas.models.responses.ApiResponse;
import org.apache.commons.io.FilenameUtils;
import org.apache.commons.lang3.StringUtils;
import org.openapitools.codegen.*;
import org.openapitools.codegen.examples.ExampleGenerator;
import org.openapitools.codegen.utils.ModelUtils;
import org.openapitools.codegen.meta.GeneratorMetadata;
import org.openapitools.codegen.meta.Stability;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import io.swagger.v3.oas.models.media.Schema;
import org.openapitools.codegen.*;
import org.openapitools.codegen.utils.ModelUtils;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.io.File;
import java.util.*;
import java.util.regex.Pattern;
import static org.openapitools.codegen.utils.StringUtils.camelize;
import static org.openapitools.codegen.utils.StringUtils.underscore;
public class PythonClientExperimentalCodegen extends PythonClientCodegen {
private static final Logger LOGGER = LoggerFactory.getLogger(PythonClientExperimentalCodegen.class);
public PythonClientExperimentalCodegen() {
super();
supportingFiles.add(new SupportingFile("python-experimental/api_client.mustache", packagePath(), "api_client.py"));
apiDocTemplateFiles.put("python-experimental/api_doc.mustache", ".md");
apiTemplateFiles.remove("api.mustache");
apiTemplateFiles.put("python-experimental/api.mustache", ".py");
apiDocTemplateFiles.remove("api_doc.mustache");
apiDocTemplateFiles.put("python-experimental/api_doc.mustache", ".md");
modelDocTemplateFiles.remove("model_doc.mustache");
modelDocTemplateFiles.put("python-experimental/model_doc.mustache", ".md");
modelTemplateFiles.remove("model.mustache");
modelTemplateFiles.put("python-experimental/model.mustache", ".py");
generatorMetadata = GeneratorMetadata.newBuilder(generatorMetadata)
@ -48,6 +67,20 @@ public class PythonClientExperimentalCodegen extends PythonClientCodegen {
.build();
}
@Override
public void processOpts() {
super.processOpts();
supportingFiles.remove(new SupportingFile("api_client.mustache", packagePath(), "api_client.py"));
supportingFiles.add(new SupportingFile("python-experimental/api_client.mustache", packagePath(), "api_client.py"));
supportingFiles.add(new SupportingFile("python-experimental/model_utils.mustache", packagePath(), "model_utils.py"));
// default this to true so the python ModelSimple models will be generated
ModelUtils.setGenerateAliasAsModel(true);
LOGGER.info(CodegenConstants.GENERATE_ALIAS_AS_MODEL + " is hard coded to true in this generator. Alias models will only be generated if they contain validations or enums");
}
/**
* Configures a friendly name for the generator. This will be used by the
* generator to select the library with the -g flag.
@ -72,6 +105,7 @@ public class PythonClientExperimentalCodegen extends PythonClientCodegen {
/**
* Return the default value of the property
*
* @param p OpenAPI property object
* @return string presentation of the default value of the property
*/
@ -158,8 +192,401 @@ public class PythonClientExperimentalCodegen extends PythonClientCodegen {
}
return defaultValue;
} else {
return defaultObject.toString();
return defaultObject.toString();
}
}
@Override
public void postProcessModelProperty(CodegenModel model, CodegenProperty property) {
// add regex information to property
postProcessPattern(property.pattern, property.vendorExtensions);
}
// override with any special post-processing for all models
@SuppressWarnings({"static-method", "unchecked"})
public Map<String, Object> postProcessAllModels(Map<String, Object> objs) {
// loop through all models and delete ones where type!=object and the model has no validations and enums
// we will remove them because they are not needed
Map<String, Schema> modelSchemasToRemove = new HashMap<String, Schema>();
for (Map.Entry<String, Object> entry : objs.entrySet()) {
Map<String, Object> inner = (Map<String, Object>) entry.getValue();
List<Map<String, Object>> models = (List<Map<String, Object>>) inner.get("models");
for (Map<String, Object> mo : models) {
CodegenModel cm = (CodegenModel) mo.get("model");
Schema modelSchema = ModelUtils.getSchema(this.openAPI, cm.name);
CodegenProperty modelProperty = fromProperty("value", modelSchema);
if (cm.isEnum || cm.isAlias) {
if (!modelProperty.isEnum && !modelProperty.hasValidation) {
// remove these models because they are aliases and do not have any enums or validations
modelSchemasToRemove.put(cm.name, modelSchema);
}
} else if (cm.isArrayModel && !modelProperty.isEnum && !modelProperty.hasValidation) {
// remove any ArrayModels which lack validation and enums
modelSchemasToRemove.put(cm.name, modelSchema);
}
}
}
// Remove modelSchemasToRemove models from objs
for (String modelName : modelSchemasToRemove.keySet()) {
objs.remove(modelName);
}
return objs;
}
/**
* Convert OAS Property object to Codegen Property object
*
* @param name name of the property
* @param p OAS property object
* @return Codegen Property object
*/
@Override
public CodegenProperty fromProperty(String name, Schema p) {
// we have a custom version of this function to always set allowableValues.enumVars on all enum variables
CodegenProperty result = super.fromProperty(name, p);
if (result.isEnum) {
updateCodegenPropertyEnum(result);
}
return result;
}
/**
* Update codegen property's enum by adding "enumVars" (with name and value)
*
* @param var list of CodegenProperty
*/
@Override
public void updateCodegenPropertyEnum(CodegenProperty var) {
// we have a custom version of this method to omit overwriting the defaultValue
Map<String, Object> allowableValues = var.allowableValues;
// handle array
if (var.mostInnerItems != null) {
allowableValues = var.mostInnerItems.allowableValues;
}
if (allowableValues == null) {
return;
}
List<Object> values = (List<Object>) allowableValues.get("values");
if (values == null) {
return;
}
String varDataType = var.mostInnerItems != null ? var.mostInnerItems.dataType : var.dataType;
Optional<Schema> referencedSchema = ModelUtils.getSchemas(openAPI).entrySet().stream()
.filter(entry -> Objects.equals(varDataType, toModelName(entry.getKey())))
.map(Map.Entry::getValue)
.findFirst();
String dataType = (referencedSchema.isPresent()) ? getTypeDeclaration(referencedSchema.get()) : varDataType;
// put "enumVars" map into `allowableValues", including `name` and `value`
List<Map<String, Object>> enumVars = new ArrayList<>();
String commonPrefix = findCommonPrefixOfVars(values);
int truncateIdx = commonPrefix.length();
for (Object value : values) {
Map<String, Object> enumVar = new HashMap<>();
String enumName;
if (truncateIdx == 0) {
enumName = value.toString();
} else {
enumName = value.toString().substring(truncateIdx);
if ("".equals(enumName)) {
enumName = value.toString();
}
}
enumVar.put("name", toEnumVarName(enumName, dataType));
enumVar.put("value", toEnumValue(value.toString(), dataType));
enumVar.put("isString", isDataTypeString(dataType));
enumVars.add(enumVar);
}
// if "x-enum-varnames" or "x-enum-descriptions" defined, update varnames
Map<String, Object> extensions = var.mostInnerItems != null ? var.mostInnerItems.getVendorExtensions() : var.getVendorExtensions();
if (referencedSchema.isPresent()) {
extensions = referencedSchema.get().getExtensions();
}
updateEnumVarsWithExtensions(enumVars, extensions);
allowableValues.put("enumVars", enumVars);
// overwriting defaultValue omitted from here
}
@Override
public CodegenParameter fromRequestBody(RequestBody body, Set<String> imports, String bodyParameterName) {
CodegenParameter result = super.fromRequestBody(body, imports, bodyParameterName);
// if we generated a model with a non-object type because it has validations or enums,
// make sure that the datatype of that body parameter refers to our model class
Content content = body.getContent();
Set<String> keySet = content.keySet();
Object[] keyArray = (Object[]) keySet.toArray();
MediaType mediaType = content.get(keyArray[0]);
Schema schema = mediaType.getSchema();
String ref = schema.get$ref();
if (ref == null) {
return result;
}
String modelName = ModelUtils.getSimpleRef(ref);
// the result lacks validation info so we need to make a CodegenProperty from the schema to check
// if we have validation and enum info exists
Schema realSchema = ModelUtils.getSchema(this.openAPI, modelName);
CodegenProperty modelProp = fromProperty("body", realSchema);
if (modelProp.isPrimitiveType && (modelProp.hasValidation || modelProp.isEnum)) {
String simpleDataType = result.dataType;
result.isPrimitiveType = false;
result.isModel = true;
result.dataType = modelName;
imports.add(modelName);
// set the example value
if (modelProp.isEnum) {
String value = modelProp._enum.get(0).toString();
result.example = modelName + "(" + toEnumValue(value, simpleDataType) + ")";
} else {
result.example = modelName + "(" + result.example + ")";
}
}
return result;
}
/**
* Convert OAS Response object to Codegen Response object
*
* @param responseCode HTTP response code
* @param response OAS Response object
* @return Codegen Response object
*/
@Override
public CodegenResponse fromResponse(String responseCode, ApiResponse response) {
// if a response points at a model whose type != object and it has validations and/or enums, then we will
// generate the model, and the response.isModel must be changed to true and response.baseType must be the name
// of the model. Point responses at models if the model is python class type ModelSimple
// When we serialize/deserialize ModelSimple models, validations and enums will be checked.
Schema responseSchema;
if (this.openAPI != null && this.openAPI.getComponents() != null) {
responseSchema = ModelUtils.unaliasSchema(this.openAPI, ModelUtils.getSchemaFromResponse(response));
} else { // no model/alias defined
responseSchema = ModelUtils.getSchemaFromResponse(response);
}
String newBaseType = null;
if (responseSchema != null) {
CodegenProperty cp = fromProperty("response", responseSchema);
if (cp.complexType != null) {
// check the referenced schema to see if it is an type=object model
Schema modelSchema = ModelUtils.getSchema(this.openAPI, cp.complexType);
if (modelSchema != null && !"object".equals(modelSchema.getType())) {
CodegenProperty modelProp = fromProperty("response", modelSchema);
if (modelProp.isEnum == true || modelProp.hasValidation == true) {
// this model has validations and/or enums so we will generate it
newBaseType = cp.complexType;
}
}
} else {
if (cp.isEnum == true || cp.hasValidation == true) {
// this model has validations and/or enums so we will generate it
Schema sc = ModelUtils.getSchemaFromResponse(response);
newBaseType = ModelUtils.getSimpleRef(sc.get$ref());
}
}
}
CodegenResponse result = super.fromResponse(responseCode, response);
if (newBaseType != null) {
result.isModel = true;
result.baseType = newBaseType;
result.dataType = newBaseType;
}
return result;
}
/**
* Set op's returnBaseType, returnType, examples etc.
*
* @param operation endpoint Operation
* @param schemas a map of the schemas in the openapi spec
* @param op endpoint CodegenOperation
* @param methodResponse the default ApiResponse for the endpoint
*/
@Override
public void handleMethodResponse(Operation operation,
Map<String, Schema> schemas,
CodegenOperation op,
ApiResponse methodResponse) {
// we have a custom version of this method to handle endpoints that return models where
// type != object the model has validations and/or enums
// we do this by invoking our custom fromResponse method to create defaultResponse
// which we then use to set op.returnType and op.returnBaseType
CodegenResponse defaultResponse = fromResponse("defaultResponse", methodResponse);
Schema responseSchema = ModelUtils.unaliasSchema(this.openAPI, ModelUtils.getSchemaFromResponse(methodResponse));
if (responseSchema != null) {
op.returnBaseType = defaultResponse.baseType;
// generate examples
String exampleStatusCode = "200";
for (String key : operation.getResponses().keySet()) {
if (operation.getResponses().get(key) == methodResponse && !key.equals("default")) {
exampleStatusCode = key;
}
}
op.examples = new ExampleGenerator(schemas, this.openAPI).generateFromResponseSchema(exampleStatusCode, responseSchema, getProducesInfo(this.openAPI, operation));
op.defaultResponse = toDefaultValue(responseSchema);
op.returnType = defaultResponse.dataType;
op.hasReference = schemas.containsKey(op.returnBaseType);
// lookup discriminator
Schema schema = schemas.get(op.returnBaseType);
if (schema != null) {
CodegenModel cmod = fromModel(op.returnBaseType, schema);
op.discriminator = cmod.discriminator;
}
if (defaultResponse.isListContainer) {
op.isListContainer = true;
} else if (defaultResponse.isMapContainer) {
op.isMapContainer = true;
} else {
op.returnSimpleType = true;
}
if (languageSpecificPrimitives().contains(op.returnBaseType) || op.returnBaseType == null) {
op.returnTypeIsPrimitive = true;
}
}
addHeaders(methodResponse, op.responseHeaders);
}
/**
* Return the sanitized variable name for enum
*
* @param value enum variable name
* @param datatype data type
* @return the sanitized variable name for enum
*/
public String toEnumVarName(String value, String datatype) {
// our enum var names are keys in a python dict, so change spaces to underscores
if (value.length() == 0) {
return "EMPTY";
}
String var = value.replaceAll("\\s+", "_").toUpperCase(Locale.ROOT);
return var;
}
/**
* Return the enum value in the language specified format
* e.g. status becomes "status"
*
* @param value enum variable name
* @param datatype data type
* @return the sanitized value for enum
*/
public String toEnumValue(String value, String datatype) {
if (datatype.equals("int") || datatype.equals("float")) {
return value;
} else {
return "\"" + escapeText(value) + "\"";
}
}
@Override
public void postProcessParameter(CodegenParameter parameter) {
postProcessPattern(parameter.pattern, parameter.vendorExtensions);
}
/**
* Convert OAS Model object to Codegen Model object
*
* @param name the name of the model
* @param schema OAS Model object
* @return Codegen Model object
*/
@Override
public CodegenModel fromModel(String name, Schema schema) {
// we have a custom version of this function so we can produce
// models for components whose type != object and which have validations and enums
// this ensures that endpoint (operation) responses with validations and enums
// will generate models, and when those endpoint responses are received in python
// the response is cast as a model, and the model will validate the response using the enums and validations
Map<String, String> propertyToModelName = new HashMap<String, String>();
Map<String, Schema> propertiesMap = schema.getProperties();
if (propertiesMap != null) {
for (Map.Entry<String, Schema> entry : propertiesMap.entrySet()) {
String schemaPropertyName = entry.getKey();
String pythonPropertyName = toVarName(schemaPropertyName);
Schema propertySchema = entry.getValue();
String ref = propertySchema.get$ref();
if (ref == null) {
continue;
}
Schema refSchema = ModelUtils.getReferencedSchema(this.openAPI, propertySchema);
String refType = refSchema.getType();
if (refType == null || refType.equals("object")) {
continue;
}
CodegenProperty modelProperty = fromProperty("_fake_name", refSchema);
if (modelProperty.isEnum == false && modelProperty.hasValidation == false) {
continue;
}
String modelName = ModelUtils.getSimpleRef(ref);
propertyToModelName.put(pythonPropertyName, modelName);
}
}
CodegenModel result = super.fromModel(name, schema);
// make non-object type models have one property so we can use it to store enums and validations
if (result.isAlias || result.isEnum) {
Schema modelSchema = ModelUtils.getSchema(this.openAPI, result.name);
CodegenProperty modelProperty = fromProperty("value", modelSchema);
if (modelProperty.isEnum == true || modelProperty.hasValidation == true) {
// these models are non-object models with enums and/or validations
// add a single property to the model so we can have a way to access validations
result.isAlias = true;
modelProperty.required = true;
List<CodegenProperty> theProperties = Arrays.asList(modelProperty);
result.setAllVars(theProperties);
result.setVars(theProperties);
result.setRequiredVars(theProperties);
// post process model properties
if (result.vars != null) {
for (CodegenProperty prop : result.vars) {
postProcessModelProperty(result, prop);
}
}
}
}
// return all models which don't need their properties connected to non-object models
if (propertyToModelName.isEmpty()) {
return result;
}
// fix all property references to non-object models, make those properties non-primitive and
// set their dataType and complexType to the model name, so documentation will refer to the correct model
ArrayList<List<CodegenProperty>> listOfLists = new ArrayList<List<CodegenProperty>>();
listOfLists.add(result.vars);
listOfLists.add(result.allVars);
listOfLists.add(result.requiredVars);
listOfLists.add(result.optionalVars);
listOfLists.add(result.readOnlyVars);
listOfLists.add(result.readWriteVars);
for (List<CodegenProperty> cpList : listOfLists) {
for (CodegenProperty cp : cpList) {
if (!propertyToModelName.containsKey(cp.name)) {
continue;
}
cp.isPrimitiveType = false;
String modelName = propertyToModelName.get(cp.name);
cp.complexType = modelName;
cp.dataType = modelName;
cp.isEnum = false;
cp.hasValidation = false;
}
}
return result;
}
}

View File

@ -387,7 +387,7 @@ public class RubyClientCodegen extends AbstractRubyCodegen {
name = name.replaceAll("-", "_"); // FIXME: a parameter should not be assigned. Also declare the methods parameters as 'final'.
// e.g. PhoneNumberApi.rb => phone_number_api.rb
return underscore(name) + "_api";
return underscore(name + "_" + apiNameSuffix);
}
@Override
@ -407,11 +407,7 @@ public class RubyClientCodegen extends AbstractRubyCodegen {
@Override
public String toApiName(String name) {
if (name.length() == 0) {
return "DefaultApi";
}
// e.g. phone_number_api => PhoneNumberApi
return camelize(name) + "Api";
return super.toApiName(name);
}
@Override

View File

@ -101,7 +101,8 @@ public class Swift4Codegen extends DefaultCodegen implements CodegenConfig {
"UUID",
"URL",
"AnyObject",
"Any")
"Any",
"Decimal")
);
defaultIncludes = new HashSet<>(
Arrays.asList(
@ -115,7 +116,8 @@ public class Swift4Codegen extends DefaultCodegen implements CodegenConfig {
"Any",
"Empty",
"AnyObject",
"Any")
"Any",
"Decimal")
);
objcReservedWords = new HashSet<>(
@ -198,6 +200,7 @@ public class Swift4Codegen extends DefaultCodegen implements CodegenConfig {
typeMapping.put("ByteArray", "Data");
typeMapping.put("UUID", "UUID");
typeMapping.put("URI", "String");
typeMapping.put("BigDecimal", "Decimal");
importMapping = new HashMap<>();

View File

@ -17,7 +17,9 @@
package org.openapitools.codegen.languages;
import io.swagger.v3.oas.models.Operation;
import io.swagger.v3.oas.models.media.Schema;
import io.swagger.v3.oas.models.responses.ApiResponse;
import org.openapitools.codegen.*;
import org.openapitools.codegen.utils.ModelUtils;
import org.slf4j.Logger;
@ -40,8 +42,12 @@ public class TypeScriptNodeClientCodegen extends AbstractTypeScriptClientCodegen
public TypeScriptNodeClientCodegen() {
super();
typeMapping.put("file", "Buffer");
typeMapping.put("file", "RequestFile");
// RequestFile is defined as: `type RequestFile = string | Buffer | ReadStream | RequestDetailedFile;`
languageSpecificPrimitives.add("Buffer");
languageSpecificPrimitives.add("ReadStream");
languageSpecificPrimitives.add("RequestDetailedFile");
languageSpecificPrimitives.add("RequestFile");
// clear import mapping (from default generator) as TS does not use it
// at the moment
@ -70,19 +76,35 @@ public class TypeScriptNodeClientCodegen extends AbstractTypeScriptClientCodegen
@Override
public boolean isDataTypeFile(final String dataType) {
return "Buffer".equals(dataType);
return dataType != null && dataType.equals("RequestFile");
}
@Override
public String getTypeDeclaration(Schema p) {
if (ModelUtils.isFileSchema(p)) {
return "Buffer";
// There are two file types:
// 1) RequestFile: the parameter for the request lib when uploading a file
// (https://github.com/request/request#multipartform-data-multipart-form-uploads)
// 2) Buffer: for downloading files.
// Use RequestFile as a default. The return type is fixed to Buffer in handleMethodResponse.
return "RequestFile";
} else if (ModelUtils.isBinarySchema(p)) {
return "Buffer";
}
return super.getTypeDeclaration(p);
}
@Override
protected void handleMethodResponse(Operation operation, Map<String, Schema> schemas, CodegenOperation op,
ApiResponse methodResponse) {
super.handleMethodResponse(operation, schemas, op, methodResponse);
// see comment in getTypeDeclaration
if (op.isResponseFile) {
op.returnType = "Buffer";
}
}
@Override
public String toApiName(String name) {
if (name.length() == 0) {
@ -239,13 +261,12 @@ public class TypeScriptNodeClientCodegen extends AbstractTypeScriptClientCodegen
if (isLanguagePrimitive(openAPIType) || isLanguageGenericType(openAPIType)) {
return openAPIType;
}
applyLocalTypeMapping(openAPIType);
return openAPIType;
return applyLocalTypeMapping(openAPIType);
}
private String applyLocalTypeMapping(String type) {
if (typeMapping.containsKey(type)) {
type = typeMapping.get(type);
return typeMapping.get(type);
}
return type;
}

View File

@ -27,7 +27,7 @@ repositories {
ext {
swagger_annotations_version = "1.5.22"
jackson_version = "2.9.9"
jackson_version = "2.9.10"
}
dependencies {

View File

@ -136,8 +136,8 @@ if(hasProperty('target') && target == 'android') {
ext {
swagger_annotations_version = "1.5.22"
jackson_version = "{{^threetenbp}}2.9.9{{/threetenbp}}{{#threetenbp}}2.6.4{{/threetenbp}}"
jackson_databind_version = "{{^threetenbp}}2.9.9{{/threetenbp}}{{#threetenbp}}2.6.4{{/threetenbp}}"
jackson_version = "{{^threetenbp}}2.9.10{{/threetenbp}}{{#threetenbp}}2.6.4{{/threetenbp}}"
jackson_databind_version = "{{^threetenbp}}2.9.10{{/threetenbp}}{{#threetenbp}}2.6.4{{/threetenbp}}"
jackson-databind-nullable-version = "0.2.0"
jersey_version = "1.19.4"
jodatime_version = "2.9.9"

View File

@ -3,8 +3,11 @@ package {{invokerPackage}};
import java.util.LinkedHashMap;
import java.util.Map;
{{#hasOAuthMethods}}
import org.apache.oltu.oauth2.client.request.OAuthClientRequest.AuthenticationRequestBuilder;
import org.apache.oltu.oauth2.client.request.OAuthClientRequest.TokenRequestBuilder;
{{/hasOAuthMethods}}
{{#threetenbp}}
import org.threeten.bp.*;
{{/threetenbp}}

View File

@ -77,7 +77,7 @@ public final class EncodingUtils {
return null;
}
try {
return URLEncoder.encode(parameter.toString(), "UTF-8");
return URLEncoder.encode(parameter.toString(), "UTF-8").replaceAll("\\+", "%20");
} catch (UnsupportedEncodingException e) {
// Should never happen, UTF-8 is always supported
throw new RuntimeException(e);

View File

@ -120,8 +120,8 @@ if(hasProperty('target') && target == 'android') {
ext {
swagger_annotations_version = "1.5.22"
jackson_version = "2.9.9"
jackson_databind_version = "2.9.9"
jackson_version = "2.9.10"
jackson_databind_version = "2.9.10"
jackson-databind-nullable-version = "0.2.0"
{{#threetenbp}}
threepane_version = "2.6.4"

View File

@ -14,9 +14,9 @@ lazy val root = (project in file(".")).
"io.github.openfeign" % "feign-jackson" % "{{#useFeign10}}10.2.3{{/useFeign10}}{{^useFeign10}}9.7.0{{/useFeign10}}" % "compile",
"io.github.openfeign" % "feign-slf4j" % "{{#useFeign10}}10.2.3{{/useFeign10}}{{^useFeign10}}9.7.0{{/useFeign10}}" % "compile",
"io.github.openfeign.form" % "feign-form" % "2.1.0" % "compile",
"com.fasterxml.jackson.core" % "jackson-core" % "2.9.9" % "compile",
"com.fasterxml.jackson.core" % "jackson-annotations" % "2.9.9" % "compile",
"com.fasterxml.jackson.core" % "jackson-databind" % "2.9.9" % "compile",
"com.fasterxml.jackson.core" % "jackson-core" % "2.9.10" % "compile",
"com.fasterxml.jackson.core" % "jackson-annotations" % "2.9.10" % "compile",
"com.fasterxml.jackson.core" % "jackson-databind" % "2.9.10" % "compile",
"com.fasterxml.jackson.datatype" % "jackson-datatype-{{^java8}}joda{{/java8}}{{#java8}}jsr310{{/java8}}" % "2.9.9" % "compile",
"com.github.joschi.jackson" % "jackson-datatype-threetenbp" % "2.6.4" % "compile",
"org.apache.oltu.oauth2" % "org.apache.oltu.oauth2.client" % "1.0.1" % "compile",

View File

@ -314,9 +314,9 @@
<swagger-annotations-version>1.5.21</swagger-annotations-version>
<feign-version>{{#useFeign10}}10.2.3{{/useFeign10}}{{^useFeign10}}9.7.0{{/useFeign10}}</feign-version>
<feign-form-version>2.1.0</feign-form-version>
<jackson-version>2.9.9</jackson-version>
<jackson-version>2.9.10</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.10</jackson-databind-version>
{{#threetenbp}}
<jackson-threetenbp-version>2.6.4</jackson-threetenbp-version>
{{/threetenbp}}

View File

@ -120,8 +120,8 @@ if(hasProperty('target') && target == 'android') {
ext {
swagger_annotations_version = "1.5.22"
jackson_version = "2.9.9"
jackson_databind_version = "2.9.9"
jackson_version = "2.9.10"
jackson_databind_version = "2.9.10"
jackson-databind-nullable-version = "0.2.0"
google_api_client_version = "1.23.0"
jersey_common_version = "2.25.1"

View File

@ -12,9 +12,9 @@ lazy val root = (project in file(".")).
"io.swagger" % "swagger-annotations" % "1.5.22",
"com.google.api-client" % "google-api-client" % "1.23.0",
"org.glassfish.jersey.core" % "jersey-common" % "2.25.1",
"com.fasterxml.jackson.core" % "jackson-core" % "2.9.9" % "compile",
"com.fasterxml.jackson.core" % "jackson-annotations" % "2.9.9" % "compile",
"com.fasterxml.jackson.core" % "jackson-databind" % "2.9.9" % "compile",
"com.fasterxml.jackson.core" % "jackson-core" % "2.9.10" % "compile",
"com.fasterxml.jackson.core" % "jackson-annotations" % "2.9.10" % "compile",
"com.fasterxml.jackson.core" % "jackson-databind" % "2.9.10" % "compile",
{{#withXml}}
"com.fasterxml.jackson.dataformat" % "jackson-dataformat-xml" % "2.9.9" % "compile",
{{/withXml}}

View File

@ -306,8 +306,8 @@
<swagger-annotations-version>1.5.22</swagger-annotations-version>
<google-api-client-version>1.30.2</google-api-client-version>
<jersey-common-version>2.25.1</jersey-common-version>
<jackson-version>2.9.9</jackson-version>
<jackson-databind-version>2.9.9</jackson-databind-version>
<jackson-version>2.9.10</jackson-version>
<jackson-databind-version>2.9.10</jackson-databind-version>
<jackson-databind-nullable-version>0.2.0</jackson-databind-nullable-version>
{{#joda}}
<jodatime-version>2.9.9</jodatime-version>

View File

@ -119,8 +119,8 @@ if(hasProperty('target') && target == 'android') {
ext {
swagger_annotations_version = "1.5.22"
jackson_version = "2.9.9"
jackson_databind_version = "2.9.9"
jackson_version = "2.9.10"
jackson_databind_version = "2.9.10"
jackson-databind-nullable-version = "0.2.0"
{{#supportJava6}}
jersey_version = "2.6"

View File

@ -13,9 +13,9 @@ lazy val root = (project in file(".")).
"org.glassfish.jersey.core" % "jersey-client" % {{#supportJava6}}"2.6"{{/supportJava6}}{{^supportJava6}}"2.25.1"{{/supportJava6}},
"org.glassfish.jersey.media" % "jersey-media-multipart" % {{#supportJava6}}"2.6"{{/supportJava6}}{{^supportJava6}}"2.25.1"{{/supportJava6}},
"org.glassfish.jersey.media" % "jersey-media-json-jackson" % {{#supportJava6}}"2.6"{{/supportJava6}}{{^supportJava6}}"2.25.1"{{/supportJava6}},
"com.fasterxml.jackson.core" % "jackson-core" % "2.9.9" % "compile",
"com.fasterxml.jackson.core" % "jackson-annotations" % "2.9.9" % "compile",
"com.fasterxml.jackson.core" % "jackson-databind" % "2.9.9" % "compile",
"com.fasterxml.jackson.core" % "jackson-core" % "2.9.10" % "compile",
"com.fasterxml.jackson.core" % "jackson-annotations" % "2.9.10" % "compile",
"com.fasterxml.jackson.core" % "jackson-databind" % "2.9.10" % "compile",
{{#joda}}
"com.fasterxml.jackson.datatype" % "jackson-datatype-joda" % "2.9.9" % "compile",
{{/joda}}

View File

@ -360,8 +360,8 @@
<commons_io_version>2.5</commons_io_version>
<commons_lang3_version>3.6</commons_lang3_version>
{{/supportJava6}}
<jackson-version>2.9.9</jackson-version>
<jackson-databind-version>2.9.9</jackson-databind-version>
<jackson-version>2.9.10</jackson-version>
<jackson-databind-version>2.9.10</jackson-databind-version>
<jackson-databind-nullable-version>0.2.0</jackson-databind-nullable-version>
{{#threetenbp}}
<threetenbp-version>2.6.4</threetenbp-version>

View File

@ -119,8 +119,8 @@ if(hasProperty('target') && target == 'android') {
ext {
swagger_annotations_version = "1.5.22"
jackson_version = "2.9.9"
jackson_databind_version = "2.9.9"
jackson_version = "2.9.10"
jackson_databind_version = "2.9.10"
jackson-databind-nullable-version = "0.2.0"
threetenbp_version = "2.6.4"
resteasy_version = "3.1.3.Final"

View File

@ -13,9 +13,9 @@ lazy val root = (project in file(".")).
"org.jboss.resteasy" % "resteasy-client" % "3.1.3.Final" % "compile",
"org.jboss.resteasy" % "resteasy-multipart-provider" % "3.1.3.Final" % "compile",
"org.jboss.resteasy" % "resteasy-jackson2-provider" % "3.1.3.Final" % "compile",
"com.fasterxml.jackson.core" % "jackson-core" % "2.9.9" % "compile",
"com.fasterxml.jackson.core" % "jackson-annotations" % "2.9.9" % "compile",
"com.fasterxml.jackson.core" % "jackson-databind" % "2.9.9" % "compile",
"com.fasterxml.jackson.core" % "jackson-core" % "2.9.10" % "compile",
"com.fasterxml.jackson.core" % "jackson-annotations" % "2.9.10" % "compile",
"com.fasterxml.jackson.core" % "jackson-databind" % "2.9.10" % "compile",
"com.github.joschi.jackson" % "jackson-datatype-threetenbp" % "2.6.4" % "compile",
{{#java8}}
"com.fasterxml.jackson.datatype" % "jackson-datatype-jsr310" % "2.9.9" % "compile",

View File

@ -294,8 +294,8 @@
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<swagger-annotations-version>1.5.22</swagger-annotations-version>
<resteasy-version>3.1.3.Final</resteasy-version>
<jackson-version>2.9.9</jackson-version>
<jackson-databind-version>2.9.9</jackson-databind-version>
<jackson-version>2.9.10</jackson-version>
<jackson-databind-version>2.9.10</jackson-databind-version>
<jackson-databind-nullable-version>0.2.0</jackson-databind-nullable-version>
<threetenbp-version>2.6.4</threetenbp-version>
{{^java8}}

View File

@ -120,8 +120,8 @@ if(hasProperty('target') && target == 'android') {
ext {
swagger_annotations_version = "1.5.22"
jackson_version = "2.9.9"
jackson_databind_version = "2.9.9"
jackson_version = "2.9.10"
jackson_databind_version = "2.9.10"
jackson-databind-nullable-version = "0.2.0"
spring_web_version = "4.3.9.RELEASE"
jodatime_version = "2.9.9"

View File

@ -7,8 +7,11 @@ import java.lang.reflect.Type;
import java.util.LinkedHashMap;
import java.util.Map;
{{#hasOAuthMethods}}
import org.apache.oltu.oauth2.client.request.OAuthClientRequest.AuthenticationRequestBuilder;
import org.apache.oltu.oauth2.client.request.OAuthClientRequest.TokenRequestBuilder;
{{/hasOAuthMethods}}
import org.joda.time.DateTime;
import org.joda.time.LocalDate;
import org.joda.time.format.DateTimeFormatter;

View File

@ -7,8 +7,10 @@ import okhttp3.Interceptor;
import okhttp3.OkHttpClient;
import okhttp3.RequestBody;
import okhttp3.ResponseBody;
{{#hasOAuthMethods}}
import org.apache.oltu.oauth2.client.request.OAuthClientRequest.AuthenticationRequestBuilder;
import org.apache.oltu.oauth2.client.request.OAuthClientRequest.TokenRequestBuilder;
{{/hasOAuthMethods}}
{{#joda}}
import org.joda.time.format.DateTimeFormatter;
{{/joda}}

View File

@ -127,12 +127,12 @@ ext {
play_version = "2.4.11"
{{/play24}}
{{#play25}}
jackson_version = "2.9.9"
jackson_version = "2.9.10"
play_version = "2.5.14"
{{/play25}}
{{#play26}}
jackson_version = "2.9.9"
jackson_databind_version = "2.9.9"
jackson_version = "2.9.10"
jackson_databind_version = "2.9.10"
jackson-databind-nullable-version = "0.2.0"
play_version = "2.6.7"
{{/play26}}

View File

@ -23,16 +23,16 @@ lazy val root = (project in file(".")).
{{/play24}}
{{#play25}}
"com.typesafe.play" % "play-java-ws_2.11" % "2.5.15" % "compile",
"com.fasterxml.jackson.core" % "jackson-core" % "2.9.9" % "compile",
"com.fasterxml.jackson.core" % "jackson-annotations" % "2.9.9" % "compile",
"com.fasterxml.jackson.core" % "jackson-databind" % "2.9.9" % "compile",
"com.fasterxml.jackson.core" % "jackson-core" % "2.9.10" % "compile",
"com.fasterxml.jackson.core" % "jackson-annotations" % "2.9.10" % "compile",
"com.fasterxml.jackson.core" % "jackson-databind" % "2.9.10" % "compile",
{{/play25}}
{{#play26}}
"com.typesafe.play" % "play-ahc-ws_2.12" % "2.6.7" % "compile",
"javax.validation" % "validation-api" % "1.1.0.Final" % "compile",
"com.fasterxml.jackson.core" % "jackson-core" % "2.9.9" % "compile",
"com.fasterxml.jackson.core" % "jackson-annotations" % "2.9.9" % "compile",
"com.fasterxml.jackson.core" % "jackson-databind" % "2.9.9" % "compile",
"com.fasterxml.jackson.core" % "jackson-core" % "2.9.10" % "compile",
"com.fasterxml.jackson.core" % "jackson-annotations" % "2.9.10" % "compile",
"com.fasterxml.jackson.core" % "jackson-databind" % "2.9.10" % "compile",
{{/play26}}
"com.squareup.retrofit2" % "converter-jackson" % "2.3.0" % "compile",
{{/usePlayWS}}

View File

@ -375,17 +375,17 @@
<gson-fire-version>1.8.3</gson-fire-version>
<swagger-annotations-version>1.5.22</swagger-annotations-version>
{{#usePlayWS}}
<jackson-databind-version>2.9.9</jackson-databind-version>
<jackson-databind-version>2.9.10</jackson-databind-version>
{{#play24}}
<jackson-version>2.6.6</jackson-version>
<play-version>2.4.11</play-version>
{{/play24}}
{{#play25}}
<jackson-version>2.9.9</jackson-version>
<jackson-version>2.9.10</jackson-version>
<play-version>2.5.15</play-version>
{{/play25}}
{{#play26}}
<jackson-version>2.9.9</jackson-version>
<jackson-version>2.9.10</jackson-version>
<play-version>2.6.7</play-version>
{{/play26}}
<jackson-databind-nullable-version>0.2.0</jackson-databind-nullable-version>

View File

@ -28,8 +28,8 @@ task execute(type:JavaExec) {
ext {
swagger_annotations_version = "1.5.21"
jackson_version = "{{^threetenbp}}2.9.9{{/threetenbp}}{{#threetenbp}}2.6.4{{/threetenbp}}"
jackson_databind_version = "{{^threetenbp}}2.9.9{{/threetenbp}}{{#threetenbp}}2.6.4{{/threetenbp}}"
jackson_version = "{{^threetenbp}}2.9.10{{/threetenbp}}{{#threetenbp}}2.6.4{{/threetenbp}}"
jackson_databind_version = "{{^threetenbp}}2.9.10{{/threetenbp}}{{#threetenbp}}2.6.4{{/threetenbp}}"
vertx_version = "3.4.2"
junit_version = "4.12"
}

View File

@ -289,8 +289,8 @@
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<vertx-version>3.4.2</vertx-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-databind>{{^threetenbp}}2.9.9{{/threetenbp}}{{#threetenbp}}2.6.4{{/threetenbp}}</jackson-databind>
<jackson-version>{{^threetenbp}}2.9.10{{/threetenbp}}{{#threetenbp}}2.6.4{{/threetenbp}}</jackson-version>
<jackson-databind>{{^threetenbp}}2.9.10{{/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>
</properties>

View File

@ -143,8 +143,8 @@
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<swagger-annotations-version>1.5.22</swagger-annotations-version>
<spring-web-version>5.0.7.RELEASE</spring-web-version>
<jackson-version>2.9.9</jackson-version>
<jackson-databind-version>2.9.9</jackson-databind-version>
<jackson-version>2.9.10</jackson-version>
<jackson-databind-version>2.9.10</jackson-databind-version>
<jackson-databind-nullable-version>0.2.0</jackson-databind-nullable-version>
<junit-version>4.12</junit-version>
<reactor-version>3.1.8.RELEASE</reactor-version>

View File

@ -0,0 +1,43 @@
# JAX-RS server with OpenAPI using Helidon
## Overview
This server was generated by the [OpenAPI Generator](https://openapi-generator.tech) project. By using an
[OpenAPI-Spec](https://openapis.org), you can easily generate a server stub.
This is an example of building a OpenAPI-enabled JAX-RS server.
This example uses the [JAX-RS](https://jax-rs-spec.java.net/) framework and
the [Eclipse-MicroProfile-OpenAPI](https://github.com/eclipse/microprofile-open-api) addition.
The pom file is configured to use [Helidon](https://helidon.io/) as application server.
{{#interfaceOnly}}
This project produces a jar that defines some interfaces.
The jar can be used in combination with an other project providing the implementation.
{{/interfaceOnly}}
{{^interfaceOnly}}
To build the server, run this maven command:
```bash
mvn package
```
To run the server, run this maven command:
```bash
mvn exec:java
```
You can then call your server endpoints under:
```
http://localhost:8080/
```
You can access the OpenAPI specification at:
```
http://localhost:8080/openapi
```
{{/interfaceOnly}}

View File

@ -0,0 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://xmlns.jcp.org/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee
http://xmlns.jcp.org/xml/ns/javaee/beans_2_0.xsd"
version="2.0"
bean-discovery-mode="annotated">
</beans>

View File

@ -0,0 +1,24 @@
# Example Logging Configuration File
# For more information see $JAVA_HOME/jre/lib/logging.properties
# Send messages to the console
handlers=java.util.logging.ConsoleHandler
# Global default logging level. Can be overriden by specific handlers and loggers
.level=INFO
# Helidon Web Server has a custom log formatter that extends SimpleFormatter.
# It replaces "!thread!" with the current thread name
java.util.logging.ConsoleHandler.level=INFO
java.util.logging.ConsoleHandler.formatter=io.helidon.webserver.WebServerLogFormatter
java.util.logging.SimpleFormatter.format=%1$tY.%1$tm.%1$td %1$tH:%1$tM:%1$tS %4$s %3$s !thread!: %5$s%6$s%n
#Component specific log levels
#io.helidon.webserver.level=INFO
#io.helidon.config.level=INFO
#io.helidon.security.level=INFO
#io.helidon.microprofile.level=INFO
#io.helidon.common.level=INFO
#io.netty.level=INFO
#org.glassfish.jersey.level=INFO
#org.jboss.weld=INFO

View File

@ -0,0 +1,6 @@
# Microprofile server properties
server.port=8080
server.host=0.0.0.0
# Microprofile OpenAPI properties
mp.openapi.scan.disable=true

View File

@ -0,0 +1,110 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>{{groupId}}</groupId>
<artifactId>{{artifactId}}</artifactId>
<version>{{artifactVersion}}</version>
<properties>
<mainClass>io.helidon.microprofile.server.Main</mainClass>
<version.lib.helidon>1.2.0</version.lib.helidon>
<version.plugin.compiler>3.8.1</version.plugin.compiler>
<version.plugin.exec>1.6.0</version.plugin.exec>
<version.plugin.jandex>1.0.6</version.plugin.jandex>
<version.plugin.jar>3.0.2</version.plugin.jar>
<version.lib.microprofile-openapi-api>1.1.2</version.lib.microprofile-openapi-api>
<version.lib.jersey>2.29</version.lib.jersey>
<version.lib.activation-api>1.2.0</version.lib.activation-api>
<version.lib.junit>5.1.0</version.lib.junit>
</properties>
<build>
<plugins>
<plugin>
<groupId>org.jboss.jandex</groupId>
<artifactId>jandex-maven-plugin</artifactId>
<version>${version.plugin.jandex}</version>
<executions>
<execution>
<id>make-index</id>
<goals>
<goal>jandex</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>${version.plugin.jar}</version>
<configuration>
<archive>
<manifest>
<addClasspath>true</addClasspath>
<mainClass>${mainClass}</mainClass>
</manifest>
</archive>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>${version.plugin.compiler}</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
<compilerArgs>
<arg>-Xlint:unchecked</arg>
</compilerArgs>
</configuration>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>${version.plugin.exec}</version>
<configuration>
<mainClass>${mainClass}</mainClass>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>io.helidon.microprofile.bundles</groupId>
<artifactId>helidon-microprofile-2.2</artifactId>
<version>${version.lib.helidon}</version>
</dependency>
<dependency>
<groupId>org.eclipse.microprofile.openapi</groupId>
<artifactId>microprofile-openapi-api</artifactId>
<version>${version.lib.microprofile-openapi-api}</version>
</dependency>
<dependency>
<groupId>org.glassfish.jersey.media</groupId>
<artifactId>jersey-media-json-binding</artifactId>
<version>${version.lib.jersey}</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>javax.activation</groupId>
<artifactId>javax.activation-api</artifactId>
<version>${version.lib.activation-api}</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
<version>${version.lib.junit}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<version>${version.lib.junit}</version>
<scope>test</scope>
</dependency>
</dependencies>
</project>

View File

@ -0,0 +1,2 @@
Manifest-Version: 1.0
Class-Path:

View File

@ -0,0 +1,43 @@
# JAX-RS server with OpenAPI using Open Liberty
## Overview
This server was generated by the [OpenAPI Generator](https://openapi-generator.tech) project. By using an
[OpenAPI-Spec](https://openapis.org), you can easily generate a server stub.
This is an example of building a OpenAPI-enabled JAX-RS server.
This example uses the [JAX-RS](https://jax-rs-spec.java.net/) framework and
the [Eclipse-MicroProfile-OpenAPI](https://github.com/eclipse/microprofile-open-api) addition.
The pom file is configured to use [Open Liberty](https://openliberty.io/) as application server.
{{#interfaceOnly}}
This project produces a jar that defines some interfaces.
The jar can be used in combination with an other project providing the implementation.
{{/interfaceOnly}}
{{^interfaceOnly}}
To start the server with maven, run this command:
```bash
mvn install liberty:start-server
```
The OpenAPI specification is available at:
```
http://localhost:9080/openapi
```
A UI for this OpenAPI Specification is available at:
```
http://localhost:9080/openapi/ui
```
When you are done stop Open Liberty with:
```
mvn liberty:stop-server
```
{{/interfaceOnly}}

View File

@ -0,0 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/beans_1_0.xsd">
</beans>

View File

@ -0,0 +1,15 @@
<?xml version="1.0" encoding="UTF-8"?>
<web-ext
xmlns="http://websphere.ibm.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://websphere.ibm.com/xml/ns/javaee http://websphere.ibm.com/xml/ns/javaee/ibm-web-ext_1_0.xsd"
version="1.0">
<reload-interval value="3"/>
<context-root uri="book-purchase" />
<enable-directory-browsing value="false"/>
<enable-file-serving value="true"/>
<enable-reloading value="true"/>
<enable-serving-servlets-by-class-name value="false" />
</web-ext>

View File

@ -0,0 +1,116 @@
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>net.wasdev.wlp.maven.parent</groupId>
<artifactId>liberty-maven-app-parent</artifactId>
<version>2.6</version>
</parent>
<groupId>{{groupId}}</groupId>
<artifactId>{{artifactId}}</artifactId>
<version>{{artifactVersion}}</version>
<packaging>war</packaging>
<dependencies>
<dependency>
<groupId>javax</groupId>
<artifactId>javaee-api</artifactId>
<version>8.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.eclipse.microprofile</groupId>
<artifactId>microprofile</artifactId>
<version>2.0.1</version>
<type>pom</type>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>javax.validation</groupId>
<artifactId>validation-api</artifactId>
<version>2.0.1.Final</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-annotations</artifactId>
<version>2.0.1</version>
</dependency>
</dependencies>
<properties>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
<failOnMissingWebXml>false</failOnMissingWebXml>
<version.maven-war-plugin>3.2.2</version.maven-war-plugin>
<!-- OpenLiberty runtime -->
<version.openliberty-runtime>19.0.0.7</version.openliberty-runtime>
<http.port>9080</http.port>
<https.port>9443</https.port>
<packaging.type>usr</packaging.type>
<app.name>${project.artifactId}</app.name>
<package.file>${project.build.directory}/${app.name}.zip</package.file>
</properties>
<build>
<finalName>{{artifactId}}</finalName>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<version>1.9.1</version>
<executions>
<execution>
<id>add-source</id>
<phase>generate-sources</phase>
<goals>
<goal>add-source</goal>
</goals>
<configuration>
<sources>
<source>src/gen/java</source>
</sources>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>${version.maven-war-plugin}</version>
<configuration>
<failOnMissingWebXml>false</failOnMissingWebXml>
<packagingExcludes>pom.xml</packagingExcludes>
</configuration>
</plugin>
<!-- Enable liberty-maven plugin -->
<plugin>
<groupId>net.wasdev.wlp.maven.plugins</groupId>
<artifactId>liberty-maven-plugin</artifactId>
<configuration>
<assemblyArtifact>
<groupId>io.openliberty</groupId>
<artifactId>openliberty-runtime</artifactId>
<version>${version.openliberty-runtime}</version>
<type>zip</type>
</assemblyArtifact>
<serverName>OpenAPIGeneratorServer</serverName>
<stripVersion>true</stripVersion>
<configFile>src/main/liberty/config/server.xml</configFile>
<looseApplication>true</looseApplication>
<packageFile>${package.file}</packageFile>
<include>${packaging.type}</include>
<bootstrapProperties>
<default.http.port>${http.port}</default.http.port>
<default.https.port>${https.port}</default.https.port>
<app.context.root>${app.name}</app.context.root>
</bootstrapProperties>
</configuration>
</plugin>
</plugins>
</build>
</project>

View File

@ -0,0 +1,19 @@
<server description="OpenAPI Generator Server">
<featureManager>
<feature>cdi-2.0</feature>
<feature>jaxrs-2.1</feature>
<feature>mpOpenAPI-1.1</feature>
</featureManager>
<applicationManager autoExpand="true" />
<quickStartSecurity userName="admin" userPassword="adminpwd"/>
<keyStore id="defaultKeyStore" password="mpKeystore"/>
<logging traceSpecification="com.ibm.ws.microprofile.health.*=all"/>
<!-- To access this server from a remote client add a host attribute to the following element, e.g. host="*" -->
<httpEndpoint host="*" httpPort="9080" httpsPort="9443" id="defaultHttpEndpoint"/>
<webApplication id="{{artifactId}}" location="{{artifactId}}.war" name="{{artifactId}}" contextRoot="/"/>
</server>

View File

@ -0,0 +1,22 @@
####
# This Dockerfile is used in order to build a container that runs the Quarkus application in JVM mode
#
# Before building the docker image run:
#
# mvn package
#
# Then, build the image with:
#
# docker build -f src/main/docker/Dockerfile.jvm -t quarkus/getting-started-jvm .
#
# Then run the container using:
#
# docker run -i --rm -p 8080:8080 quarkus/getting-started-jvm
#
###
FROM fabric8/java-alpine-openjdk8-jre
ENV JAVA_OPTIONS="-Dquarkus.http.host=0.0.0.0 -Djava.util.logging.manager=org.jboss.logmanager.LogManager"
ENV AB_ENABLED=jmx_exporter
COPY target/lib/* /deployments/lib/
COPY target/*-runner.jar /deployments/app.jar
ENTRYPOINT [ "/deployments/run-java.sh" ]

View File

@ -0,0 +1,22 @@
####
# This Dockerfile is used in order to build a container that runs the Quarkus application in native (no JVM) mode
#
# Before building the docker image run:
#
# mvn package -Pnative -Dnative-image.docker-build=true
#
# Then, build the image with:
#
# docker build -f src/main/docker/Dockerfile.native -t quarkus/getting-started .
#
# Then run the container using:
#
# docker run -i --rm -p 8080:8080 quarkus/getting-started
#
###
FROM registry.access.redhat.com/ubi8/ubi-minimal
WORKDIR /work/
COPY target/*-runner /work/application
RUN chmod 775 /work
EXPOSE 8080
CMD ["./application", "-Dquarkus.http.host=0.0.0.0"]

Some files were not shown because too many files have changed in this diff Show More