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

This commit is contained in:
William Cheng 2019-06-03 00:06:43 +08:00
commit 8d3a1a5add
1959 changed files with 24161 additions and 4878 deletions

1
.github/FUNDING.yml vendored Normal file
View File

@ -0,0 +1 @@
open_collective: openapi_generator

4
.gitignore vendored
View File

@ -88,6 +88,9 @@ samples/client/petstore/java/jersey2/build/
samples/client/petstore/java/okhttp-gson/.gradle/
samples/client/petstore/java/okhttp-gson/build/
samples/client/petstore/java/feign/build/
samples/client/petstore/java/feign10x/build/
samples/client/petstore/java/feign/project/
samples/client/petstore/java/feign10x/project/
samples/client/petstore/java/retrofit/build/
samples/client/petstore/java/retrofit2/build/
samples/client/petstore/java/retrofit2/hello.txt
@ -218,6 +221,7 @@ samples/server/petstore/erlang-server/rebar.lock
samples/client/petstore/dart/petstore/packages
samples/client/petstore/dart/flutter_petstore/test/packages
samples/client/petstore/dart/petstore/test/packages
**/.dart_tool
# JS
samples/client/petstore/javascript/package-lock.json

View File

@ -7,6 +7,9 @@ jdk:
before_cache:
- rm -f $HOME/.gradle/caches/modules-2/modules-2.lock
- rm -fr $HOME/.gradle/caches/*/plugin-resolution/
# Avoid caching our built dependencies between runs.
- rm -fr $HOME/.m2/repository/org/openapitools/
cache:
directories:
- $HOME/.m2
@ -130,24 +133,32 @@ script:
- mvn --quiet --batch-mode --show-version verify -Psamples
after_success:
# push to maven repo
- if [ $SONATYPE_USERNAME ] && [ -z $TRAVIS_TAG ] && [ "$TRAVIS_PULL_REQUEST" == "false" ]; then
if [ "$TRAVIS_BRANCH" = "master" ]; then
- if [ $SONATYPE_USERNAME ] && [ "$TRAVIS_PULL_REQUEST" == "false" ]; then
if [ "$TRAVIS_BRANCH" = "master" ] && [ -z $TRAVIS_TAG ]; then
echo "Publishing from branch $TRAVIS_BRANCH";
mvn clean deploy -DskipTests=true -B -U -P release --settings CI/settings.xml;
echo "Finished mvn clean deploy for $TRAVIS_BRANCH";
pushd .;
cd modules/openapi-generator-gradle-plugin;
./gradlew -Psigning.keyId="$SIGNING_KEY" -Psigning.password="$SIGNING_PASSPHRASE" -Psigning.secretKeyRingFile="${TRAVIS_BUILD_DIR}/sec.gpg" -PossrhUsername="${SONATYPE_USERNAME}" -PossrhPassword="${SONATYPE_PASSWORD}" uploadArchives --no-daemon;
echo "Finished ./gradlew uploadArchives";
./gradlew -Psigning.keyId="$SIGNING_KEY" -Psigning.password="$SIGNING_PASSPHRASE" -Psigning.secretKeyRingFile="${TRAVIS_BUILD_DIR}/sec.gpg" -PossrhUsername="${SONATYPE_USERNAME}" -PossrhPassword="${SONATYPE_PASSWORD}" publishMavenJavaPublicationToNexusRepository closeAndReleaseRepository --no-daemon;
echo "Finished ./gradlew publishPluginMavenPublicationToNexusRepository closeAndReleaseRepository";
popd;
elif ([[ "$TRAVIS_BRANCH" =~ ^[0-9]+\.[0-9]+\.x$ ]]) ; then
elif [ -z $TRAVIS_TAG ] && [[ "$TRAVIS_BRANCH" =~ ^[0-9]+\.[0-9]+\.x$ ]]; then
echo "Publishing from branch $TRAVIS_BRANCH";
mvn clean deploy --settings CI/settings.xml;
echo "Finished mvn clean deploy for $TRAVIS_BRANCH";
pushd .;
cd modules/openapi-generator-gradle-plugin;
./gradlew -PossrhUsername="${SONATYPE_USERNAME}" -PossrhPassword="${SONATYPE_PASSWORD}" publishPluginMavenPublicationToNexusRepository closeAndReleaseRepository --no-daemon;
echo "Finished ./gradlew publishPluginMavenPublicationToNexusRepository closeAndReleaseRepository";
popd;
fi;
if [ -n $TRAVIS_TAG ] && [[ "$TRAVIS_TAG" =~ ^[v][0-9]+\.[0-9]+\.[0-9]+$ ]]; then
echo "Publishing the gradle plugin to Gradle Portal on tag $TRAVIS_TAG (only)";
pushd .;
cd modules/openapi-generator-gradle-plugin;
./gradlew -Psigning.keyId="$SIGNING_KEY" -Psigning.password="$SIGNING_PASSPHRASE" -Psigning.secretKeyRingFile="${TRAVIS_BUILD_DIR}/sec.gpg" publishPlugins -Dgradle.publish.key=$GRADLE_PUBLISH_KEY -Dgradle.publish.secret=$GRADLE_PUBLISH_SECRET --no-daemon;
echo "Finished ./gradlew publishPlugins (plugin portal)";
./gradlew -PossrhUsername="${SONATYPE_USERNAME}" -PossrhPassword="${SONATYPE_PASSWORD}" uploadArchives --no-daemon;
echo "Finished ./gradlew uploadArchives";
popd;
fi;
fi;

View File

@ -2,7 +2,7 @@
<div align="center">
[Master](https://github.com/OpenAPITools/openapi-generator/tree/master) (`4.0.0`): [![Build Status](https://img.shields.io/travis/OpenAPITools/openapi-generator/master.svg?label=Integration%20Test)](https://travis-ci.org/OpenAPITools/openapi-generator)
[Master](https://github.com/OpenAPITools/openapi-generator/tree/master) (`4.0.1`): [![Build Status](https://img.shields.io/travis/OpenAPITools/openapi-generator/master.svg?label=Integration%20Test)](https://travis-ci.org/OpenAPITools/openapi-generator)
[![Integration Test2](https://circleci.com/gh/OpenAPITools/openapi-generator.svg?style=shield)](https://circleci.com/gh/OpenAPITools/openapi-generator)
[![Run Status](https://api.shippable.com/projects/5af6bf74e790f4070084a115/badge?branch=master)](https://app.shippable.com/github/OpenAPITools/openapi-generator)
[![Windows Test](https://ci.appveyor.com/api/projects/status/github/openapitools/openapi-generator?branch=master&svg=true&passingText=Windows%20Test%20-%20OK&failingText=Windows%20Test%20-%20Fails)](https://ci.appveyor.com/project/WilliamCheng/openapi-generator-wh2wu)
@ -97,10 +97,10 @@ The OpenAPI Specification has undergone 3 revisions since initial creation in 20
OpenAPI Generator Version | Release Date | Notes
---------------------------- | ------------ | -----
5.0.0 (upcoming major release) [SNAPSHOT](https://oss.sonatype.org/content/repositories/snapshots/org/openapitools/openapi-generator-cli/5.0.0-SNAPSHOT/)| 13.05.2019 | Major release with breaking changes (no fallback)
5.0.0 (upcoming major release) [SNAPSHOT](https://oss.sonatype.org/content/repositories/snapshots/org/openapitools/openapi-generator-cli/5.0.0-SNAPSHOT/)| 13.05.2020 | Major release with breaking changes (no fallback)
4.1.0 (upcoming minor release) [SNAPSHOT](https://oss.sonatype.org/content/repositories/snapshots/org/openapitools/openapi-generator-cli/4.1.0-SNAPSHOT/)| 15.07.2019 | Minor release (breaking changes with fallbacks)
4.0.1 (upcoming patch release) [SNAPSHOT](https://oss.sonatype.org/content/repositories/snapshots/org/openapitools/openapi-generator-cli/4.0.1-SNAPSHOT/)| 31.05.2019 | Patch release (minor bug fixes, etc)
[4.0.0](https://github.com/OpenAPITools/openapi-generator/releases/tag/v4.0.0) (latest stable release) | 13.05.2019 | Major release with breaking changes (with or without fallback)
4.0.2 (upcoming patch release) [SNAPSHOT](https://oss.sonatype.org/content/repositories/snapshots/org/openapitools/openapi-generator-cli/4.0.1-SNAPSHOT/)| 15.06.2019 | Patch release (minor bug fixes, etc)
[4.0.1](https://github.com/OpenAPITools/openapi-generator/releases/tag/v4.0.1) (latest stable release) | 31.05.2019 | Patch release (bug fixes, minor enhancements, etc)
OpenAPI Spec compatibility: 1.0, 1.1, 1.2, 2.0, 3.0
@ -156,16 +156,16 @@ See the different versions of the [openapi-generator-cli](https://mvnrepository.
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.0.0/openapi-generator-cli-4.0.0.jar`
JAR location: `http://central.maven.org/maven2/org/openapitools/openapi-generator-cli/4.0.1/openapi-generator-cli-4.0.1.jar`
For **Mac/Linux** users:
```sh
wget http://central.maven.org/maven2/org/openapitools/openapi-generator-cli/4.0.0/openapi-generator-cli-4.0.0.jar -O openapi-generator-cli.jar
wget http://central.maven.org/maven2/org/openapitools/openapi-generator-cli/4.0.1/openapi-generator-cli-4.0.1.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.0.0/openapi-generator-cli-4.0.0.jar
Invoke-WebRequest -OutFile openapi-generator-cli.jar http://central.maven.org/maven2/org/openapitools/openapi-generator-cli/4.0.1/openapi-generator-cli-4.0.1.jar
```
After downloading the JAR, run `java -jar openapi-generator-cli.jar help` to show the usage.
@ -368,10 +368,10 @@ npm install @openapitools/openapi-generator-cli -g
openapi-generator version
```
Or install a particualar OpenAPI Generator version (e.g. v4.0.0):
Or install a particualar OpenAPI Generator version (e.g. v4.0.1):
```sh
npm install @openapitools/openapi-generator-cli@cli-4.0.0 -g
npm install @openapitools/openapi-generator-cli@cli-4.0.1 -g
```
Or install it as dev-dependency:
@ -394,7 +394,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`)
You can also download the JAR (latest release) directly from [maven.org](http://central.maven.org/maven2/org/openapitools/openapi-generator-cli/4.0.0/openapi-generator-cli-4.0.0.jar)
You can also download the JAR (latest release) directly from [maven.org](http://central.maven.org/maven2/org/openapitools/openapi-generator-cli/4.0.1/openapi-generator-cli-4.0.1.jar)
To get a list of **general** options available, please run `java -jar modules/openapi-generator-cli/target/openapi-generator-cli.jar help generate`
@ -554,6 +554,7 @@ Here are some companies/projects (alphabetical order) using OpenAPI Generator in
- [unblu inc.](https://www.unblu.com/)
- [Veamly](https://www.veamly.com/)
- [Xero](https://www.xero.com/)
- [Yelp](https://www.yelp.com/)
- [Zalando](https://www.zalando.com)
## [5 - Presentations/Videos/Tutorials/Books](#table-of-contents)
@ -583,10 +584,13 @@ Here are some companies/projects (alphabetical order) using OpenAPI Generator in
- 2019-03-25 - [Access any REST service with the SAP S/4HANA Cloud SDK](https://blogs.sap.com/2019/03/25/integrate-sap-s4hana-cloud-sdk-with-open-api/) by [Alexander Duemont](https://people.sap.com/alexander.duemont)
- 2019-03-25 - [OpenAPI generatorを試してみる](https://qiita.com/amuyikam/items/e8a45daae59c68be0fc8) by [@amuyikam](https://twitter.com/amuyikam)
- 2019-03-27 - [OpenAPI3を使ってみようGo言語でクライアントとスタブの自動生成まで](https://techblog.zozo.com/entry/openapi3/go) by [@gold_kou](https://twitter.com/gold_kou)
- 2019-04-17 - [OpenAPIによるスキーマファースト開発の実施サンプルとCloud Runについて](https://tech-blog.optim.co.jp/entry/2019/04/17/174000) by [@yukey1031](https://twitter.com/yukey1031)
- 2019-04-18 - [How to use OpenAPI3 for API developer (RubyKaigi 2019)](https://speakerdeck.com/ota42y/how-to-use-openapi3-for-api-developer) by [@ota42y](https://twitter.com/ota42y) at [RubyKaigi 2019](https://rubykaigi.org/2019)
- 2019-04-29 - [A Beginner's Guide to Code Generation for REST APIs (OpenAPI Generator)](https://gum.co/openapi_generator_ebook) by [William Cheng](https://twitter.com/wing328)
- 2019-05-01 - [Design and generate a REST API from Swagger / OpenAPI in Java, Python, C# and more](https://simply-how.com/design-and-generate-api-code-from-openapi) by [Simply How](https://simply-how.com/)
- 2019-05-17 - [Generate Spring Boot REST API using Swagger/OpenAPI](https://www.47northlabs.com/knowledge-base/generate-spring-boot-rest-api-using-swagger-openapi/) by [Antonie Zafirov](https://www.47northlabs.com/author/antonie-zafirov/)
- 2019-05-22 - [REST APIs代码生成指南(OpenAPI Generator)](https://gum.co/openapi_generator_ebook_gb) by [William Cheng](https://twitter.com/wing328), [Xin Meng](https://github.com/xmeng1)
- 2019-05/24 - [REST API 代碼生成指南 (OpenAPI Generator)](https://gum.co/openapi_generator_ebook_big5) by [William Cheng](https://twitter.com/wing328)
## [6 - About Us](#table-of-contents)
@ -668,6 +672,7 @@ Here is a list of template creators:
* TypeScript (jQuery): @bherila
* TypeScript (Node): @mhardorf
* TypeScript (Rxjs): @denyo
* TypeScript (Inversify): @gualtierim
* Server Stubs
* Ada: @stcarrez
* C# ASP.NET5: @jimschubert [:heart:](https://www.patreon.com/jimschubert)

View File

@ -30,7 +30,6 @@ install:
- cmd: SET M2_HOME=C:\maven\apache-maven-3.2.5
- cmd: java -version
- cmd: gradle -v
- cmd: gradle -b modules\openapi-generator-gradle-plugin\samples\local-spec\build.gradle buildGoSdk --info
- cmd: dir/w
- git clone https://github.com/wing328/swagger-samples
- ps: Start-Process -FilePath 'C:\maven\apache-maven-3.2.5\bin\mvn' -ArgumentList 'jetty:run' -WorkingDirectory "$env:appveyor_build_folder\swagger-samples\java\java-jersey-jaxrs-ci"
@ -50,6 +49,8 @@ build_script:
- msbuild samples\client\petstore\csharp\OpenAPIClientNetStandard\Org.OpenAPITools.sln /logger:"C:\Program Files\AppVeyor\BuildAgent\Appveyor.MSBuildLogger.dll"
# install openapi-generator locally
- mvn clean install --quiet
# run the locally installed openapi-generator-gradle-plugin
- gradle -PopenApiGeneratorVersion=4.0.2-SNAPSHOT -b modules\openapi-generator-gradle-plugin\samples\local-spec\build.gradle buildGoSdk --info
test_script:
# restore test-related files
- copy /b/v/y CI\samples.ci\client\petstore\csharp\OpenAPIClient\src\Org.OpenAPITools.Test\Org.OpenAPITools.Test.csproj samples\client\petstore\csharp\OpenAPIClient\src\Org.OpenAPITools.Test\Org.OpenAPITools.Test.csproj

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/MSF4J -i modules/openapi-generator/src/test/resources/2_0/petstore-with-fake-endpoints-models-for-testing.yaml -g java-msf4j -o samples/server/petstore/java-msf4j/ -DhideGenerationTimestamp=true --additional-properties artifactId=java-msf4j-server $@"
ags="generate -t modules/openapi-generator/src/main/resources/java-msf4j-server -i modules/openapi-generator/src/test/resources/2_0/petstore-with-fake-endpoints-models-for-testing.yaml -g java-msf4j -o samples/server/petstore/java-msf4j/ -DhideGenerationTimestamp=true --additional-properties artifactId=java-msf4j-server $@"
echo "Removing files and folders under samples/server/petstore/java-msf4j/src/main"
rm -rf samples/server/petstore/java-msf4j/src/main

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/undertow -i modules/openapi-generator/src/test/resources/2_0/petstore.yaml -g java-undertow-server -o samples/server/petstore/undertow --additional-properties hideGenerationTimestamp=true $@"
ags="generate -t modules/openapi-generator/src/main/resources/java-undertow-server -i modules/openapi-generator/src/test/resources/2_0/petstore.yaml -g java-undertow-server -o samples/server/petstore/java-undertow --additional-properties hideGenerationTimestamp=true $@"
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/finch -i modules/openapi-generator/src/test/resources/3_0/petstore.yaml -g scala-finch -o samples/server/petstore/finch"
ags="generate $@ -t modules/openapi-generator/src/main/resources/scala-finch -i modules/openapi-generator/src/test/resources/3_0/petstore.yaml -g scala-finch -o samples/server/petstore/scala-finch"
java $JAVA_OPTS -jar $executable $ags

View File

@ -27,7 +27,7 @@ fi
input=modules/openapi-generator/src/test/resources/3_0/petstore-with-fake-endpoints-models-for-testing.yaml
out_folder=samples/server/openapi3/petstore/php-ze-ph
resources=modules/openapi-generator/src/main/resources/ze-ph
resources=modules/openapi-generator/src/main/resources/php-ze-ph
# if you've executed sbt assembly previously it will use that instead.
export JAVA_OPTS="${JAVA_OPTS} -Xmx1024M -DloggerPath=conf/log4j.properties"

View File

@ -27,7 +27,7 @@ fi
input=modules/openapi-generator/src/test/resources/2_0/petstore-with-fake-endpoints-models-for-testing.yaml
out_folder=samples/server/petstore/php-ze-ph
resources=modules/openapi-generator/src/main/resources/ze-ph
resources=modules/openapi-generator/src/main/resources/php-ze-ph
# if you've executed sbt assembly previously it will use that instead.
export JAVA_OPTS="${JAVA_OPTS} -Xmx1024M -DloggerPath=conf/log4j.properties"

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/finch -i modules/openapi-generator/src/test/resources/2_0/petstore.yaml -g scala-finch -o samples/server/petstore/finch $@"
ags="generate -t modules/openapi-generator/src/main/resources/scala-finch -i modules/openapi-generator/src/test/resources/2_0/petstore.yaml -g scala-finch -o samples/server/petstore/scala-finch $@"
java $JAVA_OPTS -jar $executable $ags

View File

@ -48,11 +48,12 @@ declare -a scripts=(
"./bin/r-petstore.sh"
"./bin/haskell-http-client-petstore.sh"
"./bin/csharp-petstore.sh"
"./bin/csharp-netcore-petstore.sh"
"./bin/csharp-netcore-petstore-all.sh"
"./bin/elixir-petstore.sh"
"./bin/go-petstore.sh"
"./bin/go-gin-petstore-server.sh"
"./bin/groovy-petstore.sh"
"./bin/apex-petstore.sh"
#"./bin/elm-petstore-all.sh"
"./bin/meta-codegen.sh"
# OTHERS

View File

@ -33,8 +33,10 @@ fi
echo "Release preparation: replacing $FROM with $TO in different files"
# This script assumes the files defined here have a version surrounded by angle brackets within an xml node.
# For example, >4.0.0< becomes >4.0.1-SNAPSHOT<.
# Verify the sed command below against a file before adding here.
declare -a files=("modules/openapi-generator-cli/pom.xml"
"modules/openapi-generator-gradle-plugin/gradle.properties"
"modules/openapi-generator-gradle-plugin/pom.xml"
"modules/openapi-generator-core/pom.xml"
"modules/openapi-generator-maven-plugin/pom.xml"

View File

@ -34,10 +34,12 @@ fi
echo "Release preparation: replacing $FROM with $TO in different files"
declare -a files=("modules/openapi-generator-maven-plugin/README.md"
"modules/openapi-generator-maven-plugin/examples/multi-module/java-client/pom.xml"
"modules/openapi-generator-maven-plugin/examples/java-client.xml"
"modules/openapi-generator-maven-plugin/examples/non-java-invalid-spec.xml"
"modules/openapi-generator-maven-plugin/examples/non-java.xml"
"modules/openapi-generator-gradle-plugin/README.adoc"
"modules/openapi-generator-gradle-plugin/gradle.properties"
"modules/openapi-generator-gradle-plugin/samples/local-spec/gradle.properties"
"modules/openapi-generator-gradle-plugin/samples/local-spec/build.gradle"
"modules/openapi-generator-gradle-plugin/samples/local-spec/README.md"

View File

@ -5,7 +5,7 @@ If Not Exist %executable% (
)
REM set JAVA_OPTS=%JAVA_OPTS% -Xmx1024M
set ags=generate -i modules\openapi-generator\src\test/resources\2_0\petstore-with-fake-endpoints-models-for-testing.yaml -g csharp -o samples\client\petstore\csharp\SwaggerClient --additional-properties packageGuid={321C8C3F-0156-40C1-AE42-D59761FB9B6C}
set ags=generate -i modules\openapi-generator\src\test/resources\2_0\petstore-with-fake-endpoints-models-for-testing.yaml -g csharp -o samples\client\petstore\csharp\OpenAPIClient --additional-properties packageGuid={321C8C3F-0156-40C1-AE42-D59761FB9B6C}
java %JAVA_OPTS% -jar %executable% %ags%

View File

@ -5,6 +5,6 @@ If Not Exist %executable% (
)
REM set JAVA_OPTS=%JAVA_OPTS% -Xmx1024M
set ags=generate -i modules\openapi-generator\src\test\resources\2_0\petstore-with-fake-endpoints-models-for-testing.yaml -g php-ze-ph -o samples\server\petstore\ze-ph
set ags=generate -i modules\openapi-generator\src\test\resources\2_0\petstore-with-fake-endpoints-models-for-testing.yaml -g php-ze-ph -o samples\server\petstore\php-ze-ph
java %JAVA_OPTS% -jar %executable% %ags%

View File

@ -28,3 +28,4 @@ sidebar_label: csharp
|netCoreProjectFile|Use the new format (.NET Core) for .NET project files (.csproj).| |false|
|validatable|Generates self-validatable models.| |true|
|useCompareNetObjects|Use KellermanSoftware.CompareNetObjects for deep recursive object comparison. WARNING: this option incurs potential performance impact.| |false|
|caseInsensitiveResponseHeaders|Make API response's headers case-insensitive| |false|

View File

@ -19,4 +19,5 @@ sidebar_label: typescript-inversify
|npmRepository|Use this property to set an url your private npmRepo in the package.json| |null|
|withInterfaces|Setting this property to true will generate interfaces next to the default class implementations.| |false|
|usePromise|Setting this property to use promise instead of observable inside every service.| |false|
|useRxJS6|Setting this property to use rxjs 6 instead of rxjs 5.| |false|
|taggedUnions|Use discriminators to create tagged unions instead of extending interfaces.| |false|

View File

@ -7,7 +7,7 @@ It's easy to work with templates for codegen!
The generator workflow has [transforming logic](https://github.com/openapitools/openapi-generator/tree/master/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages) as well as templates for each generation of code.
Each generator will create a data structure from the OpenAPI document; OpenAPI 2.0 and OpenAPI 3.x documents are normalized into the same API model within the generator. This model is then applied to the templates. While generators do not need to perform transformations, it's often necessary in order to add more advanced support for your language or framework. You may need to refer to the generator implementation to understand some of the logic while creating or customizing templates (see [FinchServerCodegen.java](https://github.com/OpenAPITools/openapi-generator/blob/master/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/FinchServerCodegen.java) for an advanced example).
Each generator will create a data structure from the OpenAPI document; OpenAPI 2.0 and OpenAPI 3.x documents are normalized into the same API model within the generator. This model is then applied to the templates. While generators do not need to perform transformations, it's often necessary in order to add more advanced support for your language or framework. You may need to refer to the generator implementation to understand some of the logic while creating or customizing templates (see [ScalaFinchServerCodegen.java](https://github.com/OpenAPITools/openapi-generator/blob/master/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/ScalaFinchServerCodegen.java) for an advanced example).
The transform logic needs to implement [CodegenConfig.java](https://github.com/openapitools/openapi-generator/blob/master/modules/openapi-generator/src/main/java/org/openapitools/codegen/CodegenConfig.java) and is most easily done by extending [DefaultCodegen.java](https://github.com/openapitools/openapi-generator/blob/master/modules/openapi-generator/src/main/java/org/openapitools/codegen/DefaultCodegen.java). Take a look at the various implementations as a guideline while the instructions get more complete.

View File

@ -3,7 +3,11 @@
<parent>
<groupId>org.openapitools</groupId>
<artifactId>openapi-generator-project</artifactId>
<<<<<<< HEAD
<version>4.1.0-SNAPSHOT</version>
=======
<version>4.0.2-SNAPSHOT</version>
>>>>>>> origin/master
<relativePath>../..</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>

View File

@ -5,7 +5,11 @@
<parent>
<artifactId>openapi-generator-project</artifactId>
<groupId>org.openapitools</groupId>
<<<<<<< HEAD
<version>4.1.0-SNAPSHOT</version>
=======
<version>4.0.2-SNAPSHOT</version>
>>>>>>> origin/master
<relativePath>../..</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>

View File

@ -48,7 +48,7 @@ buildscript {
mavenCentral()
}
dependencies {
classpath "org.openapitools:openapi-generator-gradle-plugin:4.0.0"
classpath "org.openapitools:openapi-generator-gradle-plugin:4.0.1"
}
}
@ -599,7 +599,7 @@ buildscript {
}
dependencies {
classpath 'com.android.tools.build:gradle:3.2.1'
classpath('org.openapitools:openapi-generator-gradle-plugin:4.0.0') {
classpath('org.openapitools:openapi-generator-gradle-plugin:4.0.1') {
exclude group: 'com.google.guava'
}
}

View File

@ -1,5 +1,5 @@
buildscript {
ext.kotlin_version = '1.2.60'
ext.kotlin_version = '1.2.61'
repositories {
mavenCentral()
maven {
@ -11,14 +11,13 @@ buildscript {
maven {
url "https://oss.sonatype.org/content/repositories/snapshots/"
}
maven {
url "https://plugins.gradle.org/m2/"
}
}
dependencies {
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath "gradle.plugin.org.gradle.kotlin:gradle-kotlin-dsl-plugins:1.0-rc-3"
classpath "com.gradle.publish:plugin-publish-plugin:0.10.1"
classpath "io.codearte.gradle.nexus:gradle-nexus-staging-plugin:0.20.0"
classpath "de.marcphilipp.gradle:nexus-publish-plugin:0.2.0"
}
}
@ -35,10 +34,11 @@ ext.isReleaseVersion = !version.endsWith("SNAPSHOT")
apply plugin: 'com.gradle.plugin-publish'
apply plugin: 'java-gradle-plugin'
apply plugin: 'maven'
apply plugin: 'signing'
apply plugin: 'kotlin'
apply plugin: "org.gradle.kotlin.kotlin-dsl"
apply plugin: 'io.codearte.nexus-staging'
apply plugin: "de.marcphilipp.nexus-publish"
sourceCompatibility = 1.8
targetCompatibility = 1.8
@ -87,6 +87,72 @@ test {
}
}
task javadocJar(type: Jar) {
from javadoc
classifier = 'javadoc'
}
task sourcesJar(type: Jar) {
from sourceSets.main.allSource
classifier = 'sources'
}
artifacts {
archives javadocJar, sourcesJar
}
publishing {
publications {
mavenJava(MavenPublication) {
from components.java
artifact sourcesJar
artifact javadocJar
pom {
name = 'OpenAPI-Generator Contributors'
description = project.description
url = 'https://openapi-generator.tech'
organization {
name = 'org.openapitools'
url = 'https://github.com/OpenAPITools'
}
licenses {
license {
name = "The Apache Software License, Version 2.0"
url = "http://www.apache.org/licenses/LICENSE-2.0.txt"
distribution = "repo"
}
}
developers {
developer {
id = "openapitools"
name = "OpenAPI-Generator Contributors"
email = "team@openapitools.org"
}
}
scm {
url = 'https://github.com/OpenAPITools/openapi-generator'
connection = 'scm:git:git://github.com/OpenAPITools/openapi-generator.git'
developerConnection = 'scm:git:ssh://git@github.com:OpenAPITools/openapi-generator.git'
}
issueManagement {
system = 'GitHub'
url = 'https://github.com/OpenAPITools/openapi-generator/issues'
}
}
}
}
}
nexusStaging {
username = project.properties["ossrhUsername"]
password = project.properties["ossrhPassword"]
}
nexusPublishing {
// To retrieve: ./gradlew -Psigning.keyId="$SIGNING_KEY" -Psigning.password="$SIGNING_PASSPHRASE" -Psigning.secretKeyRingFile="$SIGNING_SECRET" getStagingProfile --no-daemon
stagingProfileId = "456297f829bbbe"
}
gradlePlugin {
plugins {
openApiGenerator {
@ -109,6 +175,7 @@ pluginBundle {
displayName = 'OpenAPI Generator Gradle Plugin'
tags = ['openapi-3.0', 'openapi-2.0', 'openapi', 'swagger', 'codegen', 'sdk']
version = "$openApiGeneratorVersion"
group = "org.openapitools"
}
}
}
@ -119,79 +186,8 @@ pluginBundle {
// or stored as key=value pairs in ~/.gradle/gradle.properties
// You can also apply them in CI via environment variables. See Gradle's docs for details.
signing {
required { isReleaseVersion && gradle.taskGraph.hasTask("uploadArchives") }
sign configurations.archives
}
task javadocJar(type: Jar) {
classifier = 'javadoc'
from javadoc
}
task sourcesJar(type: Jar) {
from sourceSets.main.allSource
classifier = 'sources'
}
artifacts {
archives javadocJar, sourcesJar
}
def pomConfig = {
description project.description
name 'OpenAPI-Generator Contributors'
url 'https://openapi-generator.tech'
organization {
name 'org.openapitools'
url 'https://github.com/OpenAPITools'
}
licenses {
license {
name "The Apache Software License, Version 2.0"
url "http://www.apache.org/licenses/LICENSE-2.0.txt"
distribution "repo"
}
}
developers {
developer {
id "openapitools"
name "OpenAPI-Generator Contributors"
email "team@openapitools.org"
}
}
scm {
url 'https://github.com/OpenAPITools/openapi-generator'
connection 'scm:git:git://github.com/OpenAPITools/openapi-generator.git'
developerConnection 'scm:git:ssh://git@github.com:OpenAPITools/openapi-generator.git'
}
issueManagement {
system 'GitHub'
url 'https://github.com/OpenAPITools/openapi-generator/issues'
}
}
uploadArchives {
repositories {
// credentials here would need to be passed along with the gradle command:
// ./gradlew -P ossrhUsername=yourUser
// or stored in ~/.gradle/gradle.properties as key=value pairs
mavenDeployer {
beforeDeployment { MavenDeployment deployment -> signing.signPom(deployment) }
repository(url: "https://oss.sonatype.org/service/local/staging/deploy/maven2/") {
authentication(userName: ossrhUsername, password: ossrhPassword)
}
snapshotRepository(url: "https://oss.sonatype.org/content/repositories/snapshots/") {
authentication(userName: ossrhUsername, password: ossrhPassword)
}
pom.withXml {
def root = asNode()
root.appendNode('description', project.description)
root.children().last() + pomConfig
}
}
}
required { isReleaseVersion && (gradle.taskGraph.hasTask("publishPluginMavenPublicationToNexusRepository") ) }
sign publishing.publications.mavenJava
}
compileKotlin {
@ -205,4 +201,19 @@ compileTestKotlin {
}
}
uploadArchives.dependsOn 'check'
javadoc {
if(JavaVersion.current().isJava9Compatible()) {
options.addBooleanOption('html5', true)
}
}
tasks {
closeRepository {
onlyIf { nexusPublishing.useStaging.get() }
}
releaseRepository{
onlyIf { nexusPublishing.useStaging.get() }
}
}
publishToNexus.dependsOn 'check'

View File

@ -1,4 +1,8 @@
<<<<<<< HEAD
openApiGeneratorVersion=4.1.0-SNAPSHOT
=======
openApiGeneratorVersion=4.0.2-SNAPSHOT
>>>>>>> origin/master
# BEGIN placeholders
# these are just placeholders to allow contributors to build directly

View File

@ -3,7 +3,11 @@
<parent>
<groupId>org.openapitools</groupId>
<artifactId>openapi-generator-project</artifactId>
<<<<<<< HEAD
<version>4.1.0-SNAPSHOT</version>
=======
<version>4.0.2-SNAPSHOT</version>
>>>>>>> origin/master
<relativePath>../..</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
@ -72,7 +76,7 @@
<!-- calls "clean assemble install" -->
<task>clean</task>
<task>assemble</task>
<task>install</task>
<task>publishToMavenLocal</task>
</tasks>
</configuration>
</execution>

View File

@ -17,5 +17,5 @@ gradle generateGoWithInvalidSpec
The samples can be tested against other versions of the plugin using the `openApiGeneratorVersion` property. For example:
```bash
gradle -PopenApiGeneratorVersion=4.0.0 openApiValidate
gradle -PopenApiGeneratorVersion=4.0.1 openApiValidate
```

View File

@ -1 +1 @@
openApiGeneratorVersion=4.0.0
openApiGeneratorVersion=4.0.1

View File

@ -1,2 +1,3 @@
rootProject.name = 'openapi-generator-gradle-plugin'
enableFeaturePreview('STABLE_PUBLISHING')

View File

@ -11,7 +11,7 @@ Add to your `build->plugins` section (default phase is `generate-sources` phase)
<plugin>
<groupId>org.openapitools</groupId>
<artifactId>openapi-generator-maven-plugin</artifactId>
<version>4.0.0</version>
<version>4.0.1</version>
<executions>
<execution>
<goals>
@ -39,50 +39,56 @@ mvn clean compile
:bulb: These **general** configurations should be in the same level
- `inputSpec` - OpenAPI Spec file path
- `language` - target generation language (deprecated, replaced by `generatorName` as values here don't represent only 'language' any longer)
- `generatorName` - target generator name
- `output` - target output path (default is `${project.build.directory}/generated-sources/openapi`. Can also be set globally through the `openapi.generator.maven.plugin.output` property)
- `templateDirectory` - directory with mustache templates
- `addCompileSourceRoot` - add the output directory to the project as a source root (`true` by default)
- `modelPackage` - the package to use for generated model objects/classes
- `apiPackage` - the package to use for generated api objects/classes
- `invokerPackage` - the package to use for the generated invoker objects
- `modelNamePrefix` and `modelNameSuffix` - Sets the pre- or suffix for model classes and enums
- `withXml` - enable XML annotations inside the generated models and API (only works with Java `language` and libraries that provide support for JSON and XML)
- `configOptions` - a map of language-specific parameters. To show a full list of generator-specified parameters (options), please use `configHelp` (explained below)
- `configHelp` - dumps the configuration help for the specified library (generates no sources)
- `ignoreFileOverride` - specifies the full path to a `.openapi-generator-ignore` used for pattern based overrides of generated outputs
- `removeOperationIdPrefix` - remove operationId prefix (e.g. user_getName => getName)
- `logToStderr` - write all log messages (not just errors) to STDOUT
- `enablePostProcessFile` - enable file post-processing hook
- `skipValidateSpec` - Whether or not to skip validating the input spec prior to generation. By default, invalid specifications will result in an error.
- `strictSpec` - Whether or not to treat an input document strictly against the spec. 'MUST' and 'SHALL' wording in OpenAPI spec is strictly adhered to. e.g. when false, no fixes will be applied to documents which pass validation but don't follow the spec.
- `generateAliasAsModel` - generate alias (array, map) as model
- `generateApis` - generate the apis (`true` by default)
- `generateApiTests` - generate the api tests (`true` by default. Only available if `generateApis` is `true`)
- `generateApiDocumentation` - generate the api documentation (`true` by default. Only available if `generateApis` is `true`)
- `generateModels` - generate the models (`true` by default)
- `modelsToGenerate` - A comma separated list of models to generate. All models is the default.
- `generateModelTests` - generate the model tests (`true` by default. Only available if `generateModels` is `true`)
- `generateModelDocumentation` - generate the model documentation (`true` by default. Only available if `generateModels` is `true`)
- `generateSupportingFiles` - generate the supporting files (`true` by default)
- `supportingFilesToGenerate` - A comma separated list of supporting files to generate. All files is the default.
- `skip` - skip code generation (`false` by default. Can also be set globally through the `codegen.skip` property)
- `verbose` - verbose mode (`false` by default)
- `groupId`, `artifactId` and `artifactVersion` - sets project information in generated pom.xml/build.gradle or other build script. Language-specific conversions occur in non-jvm generators
- `gitUserId` and `gitRepoId` - sets git information of the project
- `auth` - adds authorization headers when fetching the OpenAPI definitions remotely. Pass in a URL-encoded string of `name:header` with a comma separating multiple values
- `configurationFile` - Path to separate json configuration file. File content should be in a json format {"optionKey":"optionValue", "optionKey1":"optionValue1"...} Supported options can be different for each language. Run `config-help -g {generator name}` command for language specific config options
- `skipOverwrite` - Specifies if the existing files should be overwritten during the generation. (`false` by default)
- `library` - library template (sub-template)
- `instantiationTypes` - sets instantiation type mappings in the format of type=instantiatedType,type=instantiatedType. For example (in Java): `array=ArrayList,map=HashMap`. In other words array types will get instantiated as ArrayList in generated code. You can also have multiple occurrences of this option
- `importMappings` - specifies mappings between a given class and the import that should be used for that class in the format of type=import,type=import. You can also have multiple occurrences of this option
- `typeMappings` - sets mappings between OpenAPI spec types and generated code types in the format of OpenAPIType=generatedType,OpenAPIType=generatedType. For example: `array=List,map=Map,string=String`. You can also have multiple occurrences of this option
- `languageSpecificPrimitives` - specifies additional language specific primitive types in the format of type1,type2,type3,type3. For example: `String,boolean,Boolean,Double`. You can also have multiple occurrences of this option
- `additionalProperties` - sets additional properties that can be referenced by the mustache templates in the format of name=value,name=value. You can also have multiple occurrences of this option
- `reservedWordsMappings` - specifies how a reserved name should be escaped to. Otherwise, the default `_<name>` is used. For example `id=identifier`. You can also have multiple occurrences of this option
- `skipIfSpecIsUnchanged` - Skip the execution if the source file is older than the output folder (`false` by default. Can also be set globally through the `codegen.skipIfSpecIsUnchanged` property)
| Option | Property | Description |
|--------|----------|-------------|
| `inputSpec` | `openapi.generator.maven.plugin.inputSpec` | OpenAPI Spec file path
| `language` | `openapi.generator.maven.plugin.language` | target generation language (deprecated, replaced by `generatorName` as values here don't represent only 'language' any longer)
| `generatorName` | `openapi.generator.maven.plugin.generatorName` | target generator name
| `output` | `openapi.generator.maven.plugin.output` | target output path (default is `${project.build.directory}/generated-sources/openapi`. Can also be set globally through the `openapi.generator.maven.plugin.output` property)
| `templateDirectory` | `openapi.generator.maven.plugin.templateDirectory` | directory with mustache templates
| `addCompileSourceRoot` | `openapi.generator.maven.plugin.addCompileSourceRoot` | add the output directory to the project as a source root (`true` by default)
| `modelPackage` | `openapi.generator.maven.plugin.modelPackage` | the package to use for generated model objects/classes
| `apiPackage` | `openapi.generator.maven.plugin.apiPackage` | the package to use for generated api objects/classes
| `invokerPackage` | `openapi.generator.maven.plugin.invokerPackage` | the package to use for the generated invoker objects
| `modelNamePrefix` | `openapi.generator.maven.plugin.modelNamePrefix` | Sets the prefix for model classes and enums
| `modelNameSuffix` | `openapi.generator.maven.plugin.modelNameSuffix` | Sets the suffix for model classes and enums
| `withXml` | `openapi.generator.maven.plugin.withXml` | enable XML annotations inside the generated models and API (only works with Java `language` and libraries that provide support for JSON and XML)
| `configOptions` | N/A | a map of language-specific parameters. To show a full list of generator-specified parameters (options), please use `configHelp` (explained below)
| `configHelp` | `codegen.configHelp` | dumps the configuration help for the specified library (generates no sources)
| `ignoreFileOverride` | `openapi.generator.maven.plugin.ignoreFileOverride` | specifies the full path to a `.openapi-generator-ignore` used for pattern based overrides of generated outputs
| `removeOperationIdPrefix` | `openapi.generator.maven.plugin.removeOperationIdPrefix` | remove operationId prefix (e.g. user_getName => getName)
| `logToStderr` | `openapi.generator.maven.plugin.logToStderr` | write all log messages (not just errors) to STDOUT
| `enablePostProcessFile` | `openapi.generator.maven.plugin.` | enable file post-processing hook
| `skipValidateSpec` | `openapi.generator.maven.plugin.skipValidateSpec` | Whether or not to skip validating the input spec prior to generation. By default, invalid specifications will result in an error.
| `strictSpec` | `openapi.generator.maven.plugin.strictSpec` | Whether or not to treat an input document strictly against the spec. 'MUST' and 'SHALL' wording in OpenAPI spec is strictly adhered to. e.g. when false, no fixes will be applied to documents which pass validation but don't follow the spec.
| `generateAliasAsModel` | `openapi.generator.maven.plugin.generateAliasAsModel` | generate alias (array, map) as model
| `generateApis` | `openapi.generator.maven.plugin.generateApis` | generate the apis (`true` by default)
| `generateApiTests` | `openapi.generator.maven.plugin.generateApiTests` | generate the api tests (`true` by default. Only available if `generateApis` is `true`)
| `generateApiDocumentation` | `openapi.generator.maven.plugin.generateApiDocumentation` | generate the api documentation (`true` by default. Only available if `generateApis` is `true`)
| `generateModels` | `openapi.generator.maven.plugin.generateModels` | generate the models (`true` by default)
| `modelsToGenerate` | `openapi.generator.maven.plugin.modelsToGenerate` | A comma separated list of models to generate. All models is the default.
| `generateModelTests` | `openapi.generator.maven.plugin.generateModelTests` | generate the model tests (`true` by default. Only available if `generateModels` is `true`)
| `generateModelDocumentation` | `openapi.generator.maven.plugin.generateModelDocumentation` | generate the model documentation (`true` by default. Only available if `generateModels` is `true`)
| `generateSupportingFiles` | `openapi.generator.maven.plugin.generateSupportingFiles` | generate the supporting files (`true` by default)
| `supportingFilesToGenerate` | `openapi.generator.maven.plugin.supportingFilesToGenerate` | A comma separated list of supporting files to generate. All files is the default.
| `skip` | `codegen.skip` | skip code generation (`false` by default. Can also be set globally through the `codegen.skip` property)
| `verbose` | `openapi.generator.maven.plugin.verbose` | verbose mode (`false` by default)
| `groupId` | `openapi.generator.maven.plugin.groupId` | sets project information in generated pom.xml/build.gradle or other build script. Language-specific conversions occur in non-jvm generators
| `artifactId` | `openapi.generator.maven.plugin.artifactId` | sets project information in generated pom.xml/build.gradle or other build script. Language-specific conversions occur in non-jvm generators
| `artifactVersion` | `openapi.generator.maven.plugin.artifactVersion` | sets project information in generated pom.xml/build.gradle or other build script. Language-specific conversions occur in non-jvm generators
| `gitUserId` and `gitRepoId` | `openapi.generator.maven.plugin.gitUserId` | sets git information of the project
| `auth` | `openapi.generator.maven.plugin.auth` | adds authorization headers when fetching the OpenAPI definitions remotely. Pass in a URL-encoded string of `name:header` with a comma separating multiple values
| `configurationFile` | `openapi.generator.maven.plugin.configurationFile` | Path to separate json configuration file. File content should be in a json format {"optionKey":"optionValue", "optionKey1":"optionValue1"...} Supported options can be different for each language. Run `config-help -g {generator name}` command for language specific config options
| `skipOverwrite` | `openapi.generator.maven.plugin.skipOverwrite` | Specifies if the existing files should be overwritten during the generation. (`false` by default)
| `library` | `openapi.generator.maven.plugin.library` | library template (sub-template)
| `instantiationTypes` | `openapi.generator.maven.plugin.instantiationTypes` | sets instantiation type mappings in the format of type=instantiatedType,type=instantiatedType. For example (in Java): `array=ArrayList,map=HashMap`. In other words array types will get instantiated as ArrayList in generated code. You can also have multiple occurrences of this option
| `importMappings` | `openapi.generator.maven.plugin.importMappings` | specifies mappings between a given class and the import that should be used for that class in the format of type=import,type=import. You can also have multiple occurrences of this option
| `typeMappings` | `openapi.generator.maven.plugin.typeMappings` | sets mappings between OpenAPI spec types and generated code types in the format of OpenAPIType=generatedType,OpenAPIType=generatedType. For example: `array=List,map=Map,string=String`. You can also have multiple occurrences of this option
| `languageSpecificPrimitives` | `openapi.generator.maven.plugin.languageSpecificPrimitives` | specifies additional language specific primitive types in the format of type1,type2,type3,type3. For example: `String,boolean,Boolean,Double`. You can also have multiple occurrences of this option
| `additionalProperties` | `openapi.generator.maven.plugin.additionalProperties` | sets additional properties that can be referenced by the mustache templates in the format of name=value,name=value. You can also have multiple occurrences of this option
| `reservedWordsMappings` | `openapi.generator.maven.plugin.reservedWordsMappings` | specifies how a reserved name should be escaped to. Otherwise, the default `_<name>` is used. For example `id=identifier`. You can also have multiple occurrences of this option
| `skipIfSpecIsUnchanged` | `codegen.skipIfSpecIsUnchanged` | Skip the execution if the source file is older than the output folder (`false` by default. Can also be set globally through the `codegen.skipIfSpecIsUnchanged` property)
| `engine` | `openapi.generator.maven.plugin.engine` | The name of templating engine to use, "mustache" (default) or "handlebars" (beta)
### Custom Generator

View File

@ -12,7 +12,7 @@
<plugin>
<groupId>org.openapitools</groupId>
<artifactId>openapi-generator-maven-plugin</artifactId>
<version>4.0.0</version>
<version>4.0.2-SNAPSHOT</version>
<executions>
<execution>
<goals>
@ -50,6 +50,12 @@
</plugin>
</plugins>
</build>
<pluginRepositories>
<pluginRepository>
<id>sonatype-snapshots</id>
<url>https://oss.sonatype.org/content/repositories/snapshots/</url>
</pluginRepository>
</pluginRepositories>
<dependencies>
<!-- dependencies are needed for the client being generated -->

View File

@ -18,7 +18,7 @@
<plugin>
<groupId>org.openapitools</groupId>
<artifactId>openapi-generator-maven-plugin</artifactId>
<version>4.0.0</version>
<version>4.0.2-SNAPSHOT</version>
<dependencies>
<dependency>
<groupId>${project.groupId}</groupId>
@ -63,6 +63,12 @@
</plugin>
</plugins>
</build>
<pluginRepositories>
<pluginRepository>
<id>sonatype-snapshots</id>
<url>https://oss.sonatype.org/content/repositories/snapshots/</url>
</pluginRepository>
</pluginRepositories>
<dependencies>
<!-- dependencies are needed for the client being generated -->

View File

@ -12,7 +12,7 @@
<plugin>
<groupId>org.openapitools</groupId>
<artifactId>openapi-generator-maven-plugin</artifactId>
<version>4.0.0</version>
<version>4.0.2-SNAPSHOT</version>
<executions>
<execution>
<goals>
@ -31,4 +31,10 @@
</plugin>
</plugins>
</build>
<pluginRepositories>
<pluginRepository>
<id>sonatype-snapshots</id>
<url>https://oss.sonatype.org/content/repositories/snapshots/</url>
</pluginRepository>
</pluginRepositories>
</project>

View File

@ -12,7 +12,7 @@
<plugin>
<groupId>org.openapitools</groupId>
<artifactId>openapi-generator-maven-plugin</artifactId>
<version>4.0.0</version>
<version>4.0.2-SNAPSHOT</version>
<executions>
<execution>
<goals>
@ -30,4 +30,10 @@
</plugin>
</plugins>
</build>
<pluginRepositories>
<pluginRepository>
<id>sonatype-snapshots</id>
<url>https://oss.sonatype.org/content/repositories/snapshots/</url>
</pluginRepository>
</pluginRepositories>
</project>

View File

@ -4,7 +4,11 @@
<parent>
<groupId>org.openapitools</groupId>
<artifactId>openapi-generator-project</artifactId>
<<<<<<< HEAD
<version>4.1.0-SNAPSHOT</version>
=======
<version>4.0.2-SNAPSHOT</version>
>>>>>>> origin/master
<relativePath>../..</relativePath>
</parent>
<artifactId>openapi-generator-maven-plugin</artifactId>

View File

@ -105,146 +105,152 @@ public class CodeGenMojo extends AbstractMojo {
/**
* Location of the OpenAPI spec, as URL or file.
*/
@Parameter(name = "inputSpec", required = true)
@Parameter(name = "inputSpec", property = "openapi.generator.maven.plugin.inputSpec", required = true)
private String inputSpec;
/**
* Git user ID, e.g. swagger-api.
*/
@Parameter(name = "gitUserId", required = false)
@Parameter(name = "gitUserId", property = "openapi.generator.maven.plugin.gitUserId", required = false)
private String gitUserId;
/**
* Git repo ID, e.g. openapi-generator.
*/
@Parameter(name = "gitRepoId", required = false)
@Parameter(name = "gitRepoId", property = "openapi.generator.maven.plugin.gitRepoId", required = false)
private String gitRepoId;
/**
* Folder containing the template files.
*/
@Parameter(name = "templateDirectory")
@Parameter(name = "templateDirectory", property = "openapi.generator.maven.plugin.templateDirectory")
private File templateDirectory;
/**
* The name of templating engine to use, "mustache" (default) or "handlebars" (beta)
*/
@Parameter(name = "engine", defaultValue = "mustache", property="openapi.generator.maven.plugin.engine")
private String engine;
/**
* Adds authorization headers when fetching the swagger definitions remotely. " Pass in a
* URL-encoded string of name:header with a comma separating multiple values
*/
@Parameter(name = "auth")
@Parameter(name = "auth", property = "openapi.generator.maven.plugin.auth")
private String auth;
/**
* Path to separate json configuration file.
*/
@Parameter(name = "configurationFile", required = false)
@Parameter(name = "configurationFile", property = "openapi.generator.maven.plugin.configurationFile", required = false)
private String configurationFile;
/**
* Specifies if the existing files should be overwritten during the generation.
*/
@Parameter(name = "skipOverwrite", required = false)
@Parameter(name = "skipOverwrite", property = "openapi.generator.maven.plugin.skipOverwrite", required = false)
private Boolean skipOverwrite;
/**
* The package to use for generated api objects/classes
*/
@Parameter(name = "apiPackage")
@Parameter(name = "apiPackage", property = "openapi.generator.maven.plugin.apiPackage")
private String apiPackage;
/**
* The package to use for generated model objects/classes
*/
@Parameter(name = "modelPackage")
@Parameter(name = "modelPackage", property = "openapi.generator.maven.plugin.modelPackage")
private String modelPackage;
/**
* The package to use for the generated invoker objects
*/
@Parameter(name = "invokerPackage")
@Parameter(name = "invokerPackage", property = "openapi.generator.maven.plugin.invokerPackage")
private String invokerPackage;
/**
* The default package to use for the generated objects
*/
@Parameter(name = "packageName")
@Parameter(name = "packageName", property = "openapi.generator.maven.plugin.packageName")
private String packageName;
/**
* groupId in generated pom.xml
*/
@Parameter(name = "groupId")
@Parameter(name = "groupId", property = "openapi.generator.maven.plugin.groupId")
private String groupId;
/**
* artifactId in generated pom.xml
*/
@Parameter(name = "artifactId")
@Parameter(name = "artifactId", property = "openapi.generator.maven.plugin.artifactId")
private String artifactId;
/**
* artifact version in generated pom.xml
*/
@Parameter(name = "artifactVersion")
@Parameter(name = "artifactVersion", property = "openapi.generator.maven.plugin.artifactVersion")
private String artifactVersion;
/**
* Sets the library
*/
@Parameter(name = "library", required = false)
@Parameter(name = "library", property = "openapi.generator.maven.plugin.library", required = false)
private String library;
/**
* Sets the prefix for model enums and classes
*/
@Parameter(name = "modelNamePrefix", required = false)
@Parameter(name = "modelNamePrefix", property = "openapi.generator.maven.plugin.modelNamePrefix", required = false)
private String modelNamePrefix;
/**
* Sets the suffix for model enums and classes
*/
@Parameter(name = "modelNameSuffix", required = false)
@Parameter(name = "modelNameSuffix", property = "openapi.generator.maven.plugin.modelNameSuffix", required = false)
private String modelNameSuffix;
/**
* Sets an optional ignoreFileOverride path
*/
@Parameter(name = "ignoreFileOverride", required = false)
@Parameter(name = "ignoreFileOverride", property = "openapi.generator.maven.plugin.ignoreFileOverride", required = false)
private String ignoreFileOverride;
/**
* To remove operationId prefix (e.g. user_getName => getName)
*/
@Parameter(name = "removeOperationIdPrefix", required = false)
@Parameter(name = "removeOperationIdPrefix", property = "openapi.generator.maven.plugin.removeOperationIdPrefix", required = false)
private Boolean removeOperationIdPrefix;
/**
* To write all log messages (not just errors) to STDOUT
*/
@Parameter(name = "logToStderr", required = false)
@Parameter(name = "logToStderr", property = "openapi.generator.maven.plugin.logToStderr", required = false)
private Boolean logToStderr;
/**
* To file post-processing hook
*/
@Parameter(name = "enablePostProcessFile", required = false)
@Parameter(name = "enablePostProcessFile", property = "openapi.generator.maven.plugin.enablePostProcessFile", required = false)
private Boolean enablePostProcessFile;
/**
* To skip spec validation
*/
@Parameter(name = "skipValidateSpec", required = false)
@Parameter(name = "skipValidateSpec", property = "openapi.generator.maven.plugin.skipValidateSpec", required = false)
private Boolean skipValidateSpec;
/**
* To treat a document strictly against the spec.
*/
@Parameter(name = "strictSpec", required = false)
@Parameter(name = "strictSpec", property = "openapi.generator.maven.plugin.strictSpec", required = false)
private Boolean strictSpecBehavior;
/**
* To generate alias (array, map) as model
*/
@Parameter(name = "generateAliasAsModel", required = false)
@Parameter(name = "generateAliasAsModel", property = "openapi.generator.maven.plugin.generateAliasAsModel", required = false)
private Boolean generateAliasAsModel;
/**
@ -256,97 +262,97 @@ public class CodeGenMojo extends AbstractMojo {
/**
* A map of types and the types they should be instantiated as
*/
@Parameter(name = "instantiationTypes")
@Parameter(name = "instantiationTypes", property = "openapi.generator.maven.plugin.instantiationTypes")
private List<String> instantiationTypes;
/**
* A map of classes and the import that should be used for that class
*/
@Parameter(name = "importMappings")
@Parameter(name = "importMappings", property = "openapi.generator.maven.plugin.importMappings")
private List<String> importMappings;
/**
* A map of swagger spec types and the generated code types to use for them
*/
@Parameter(name = "typeMappings")
@Parameter(name = "typeMappings", property = "openapi.generator.maven.plugin.typeMappings")
private List<String> typeMappings;
/**
* A map of additional language specific primitive types
*/
@Parameter(name = "languageSpecificPrimitives")
@Parameter(name = "languageSpecificPrimitives", property = "openapi.generator.maven.plugin.languageSpecificPrimitives")
private List<String> languageSpecificPrimitives;
/**
* A map of additional properties that can be referenced by the mustache templates
*/
@Parameter(name = "additionalProperties")
@Parameter(name = "additionalProperties", property = "openapi.generator.maven.plugin.additionalProperties")
private List<String> additionalProperties;
/**
* A map of reserved names and how they should be escaped
*/
@Parameter(name = "reservedWordsMappings")
@Parameter(name = "reservedWordsMappings", property = "openapi.generator.maven.plugin.reservedWordMappings")
private List<String> reservedWordsMappings;
/**
* Generate the apis
*/
@Parameter(name = "generateApis", required = false)
@Parameter(name = "generateApis", property = "openapi.generator.maven.plugin.generateApis", required = false)
private Boolean generateApis = true;
/**
* Generate the models
*/
@Parameter(name = "generateModels", required = false)
@Parameter(name = "generateModels", property = "openapi.generator.maven.plugin.generateModels", required = false)
private Boolean generateModels = true;
/**
* A comma separated list of models to generate. All models is the default.
*/
@Parameter(name = "modelsToGenerate", required = false)
@Parameter(name = "modelsToGenerate", property = "openapi.generator.maven.plugin.modelsToGenerate", required = false)
private String modelsToGenerate = "";
/**
* Generate the supporting files
*/
@Parameter(name = "generateSupportingFiles", required = false)
@Parameter(name = "generateSupportingFiles", property = "openapi.generator.maven.plugin.generateSupportingFiles", required = false)
private Boolean generateSupportingFiles = true;
/**
* A comma separated list of models to generate. All models is the default.
*/
@Parameter(name = "supportingFilesToGenerate", required = false)
@Parameter(name = "supportingFilesToGenerate", property = "openapi.generator.maven.plugin.supportingFilesToGenerate", required = false)
private String supportingFilesToGenerate = "";
/**
* Generate the model tests
*/
@Parameter(name = "generateModelTests", required = false)
@Parameter(name = "generateModelTests", property = "openapi.generator.maven.plugin.generateModelTests", required = false)
private Boolean generateModelTests = true;
/**
* Generate the model documentation
*/
@Parameter(name = "generateModelDocumentation", required = false)
@Parameter(name = "generateModelDocumentation", property = "openapi.generator.maven.plugin.generateModelDocumentation", required = false)
private Boolean generateModelDocumentation = true;
/**
* Generate the api tests
*/
@Parameter(name = "generateApiTests", required = false)
@Parameter(name = "generateApiTests", property = "openapi.generator.maven.plugin.generateApiTests", required = false)
private Boolean generateApiTests = true;
/**
* Generate the api documentation
*/
@Parameter(name = "generateApiDocumentation", required = false)
@Parameter(name = "generateApiDocumentation", property = "openapi.generator.maven.plugin.generateApiDocumentation", required = false)
private Boolean generateApiDocumentation = true;
/**
* Generate the api documentation
*/
@Parameter(name = "withXml", required = false)
@Parameter(name = "withXml", property = "openapi.generator.maven.plugin.withXml", required = false)
private Boolean withXml = false;
/**
@ -374,7 +380,7 @@ public class CodeGenMojo extends AbstractMojo {
@Parameter
protected Map<String, String> originalEnvironmentVariables = new HashMap<String, String>();
@Parameter
@Parameter(property = "codegen.configHelp")
private boolean configHelp = false;
/**
@ -550,6 +556,10 @@ public class CodeGenMojo extends AbstractMojo {
configurator.setTemplateDir(templateDirectory.getAbsolutePath());
}
if (null != engine) {
configurator.setTemplatingEngineName(engine);
}
// Set generation options
if (null != generateApis && generateApis) {
GeneratorProperties.setProperty(CodegenConstants.APIS, "");

View File

@ -3,7 +3,11 @@
<parent>
<groupId>org.openapitools</groupId>
<artifactId>openapi-generator-project</artifactId>
<<<<<<< HEAD
<version>4.1.0-SNAPSHOT</version>
=======
<version>4.0.2-SNAPSHOT</version>
>>>>>>> origin/master
<relativePath>../..</relativePath>
</parent>
<artifactId>openapi-generator-online</artifactId>

View File

@ -3,7 +3,11 @@
<parent>
<groupId>org.openapitools</groupId>
<artifactId>openapi-generator-project</artifactId>
<<<<<<< HEAD
<version>4.1.0-SNAPSHOT</version>
=======
<version>4.0.2-SNAPSHOT</version>
>>>>>>> origin/master
<relativePath>../..</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
@ -313,7 +317,11 @@
<dependency>
<groupId>org.openapitools</groupId>
<artifactId>openapi-generator-core</artifactId>
<<<<<<< HEAD
<version>4.1.0-SNAPSHOT</version>
=======
<version>4.0.2-SNAPSHOT</version>
>>>>>>> origin/master
</dependency>
</dependencies>
<repositories>

View File

@ -232,6 +232,8 @@ public class CodegenConstants {
public static final String PARCELIZE_MODELS = "parcelizeModels";
public static final String PARCELIZE_MODELS_DESC = "toggle \"@Parcelize\" for generated models";
public static final String CASE_INSENSITIVE_RESPONSE_HEADERS = "caseInsensitiveResponseHeaders";
public static final String CASE_INSENSITIVE_RESPONSE_HEADERS_DESC = "Make API response's headers case-insensitive";
// Not user-configurable. System provided for use in templates.

View File

@ -33,7 +33,7 @@ public class CodegenParameter {
public String example; // example value (x-example)
public String jsonSchema;
public boolean isString, isNumeric, isInteger, isLong, isNumber, isFloat, isDouble, isByteArray, isBinary,
isBoolean, isDate, isDateTime, isUuid, isEmail, isFreeFormObject;
isBoolean, isDate, isDateTime, isUuid, isUri, isEmail, isFreeFormObject;
public boolean isListContainer, isMapContainer;
public boolean isFile;
public boolean isEnum;
@ -168,6 +168,7 @@ public class CodegenParameter {
output.isDate = this.isDate;
output.isDateTime = this.isDateTime;
output.isUuid = this.isUuid;
output.isUri = this.isUri;
output.isEmail = this.isEmail;
output.isFreeFormObject = this.isFreeFormObject;
output.isListContainer = this.isListContainer;
@ -222,6 +223,7 @@ public class CodegenParameter {
Objects.equals(isDate, that.isDate) &&
Objects.equals(isDateTime, that.isDateTime) &&
Objects.equals(isUuid, that.isUuid) &&
Objects.equals(isUri, that.isUri) &&
Objects.equals(isEmail, that.isEmail) &&
Objects.equals(isFreeFormObject, that.isFreeFormObject) &&
Objects.equals(isListContainer, that.isListContainer) &&
@ -289,6 +291,7 @@ public class CodegenParameter {
isDate,
isDateTime,
isUuid,
isUri,
isEmail,
isFreeFormObject,
isListContainer,
@ -357,6 +360,7 @@ public class CodegenParameter {
", isDate=" + isDate +
", isDateTime=" + isDateTime +
", isUuid=" + isUuid +
", isUri=" + isUri +
", isEmail=" + isEmail +
", isFreeFormObject=" + isFreeFormObject +
", isListContainer=" + isListContainer +

View File

@ -55,7 +55,7 @@ public class CodegenProperty implements Cloneable {
public boolean hasMoreNonReadOnly; // for model constructor, true if next property is not readonly
public boolean isPrimitiveType, isModel, isContainer;
public boolean isString, isNumeric, isInteger, isLong, isNumber, isFloat, isDouble, isByteArray, isBinary, isFile,
isBoolean, isDate, isDateTime, isUuid, isEmail, isFreeFormObject;
isBoolean, isDate, isDateTime, isUuid, isUri, isEmail, isFreeFormObject;
public boolean isListContainer, isMapContainer;
public boolean isEnum;
public boolean isReadOnly;
@ -472,6 +472,7 @@ public class CodegenProperty implements Cloneable {
isDate,
isDateTime,
isUuid,
isUri,
isEmail,
isFreeFormObject,
isMapContainer,
@ -552,6 +553,7 @@ public class CodegenProperty implements Cloneable {
Objects.equals(isDate, other.isDate) &&
Objects.equals(isDateTime, other.isDateTime) &&
Objects.equals(isUuid, other.isUuid) &&
Objects.equals(isUri, other.isUri) &&
Objects.equals(isEmail, other.isEmail) &&
Objects.equals(isFreeFormObject, other.isFreeFormObject) &&
Objects.equals(isBinary, other.isBinary) &&
@ -649,6 +651,7 @@ public class CodegenProperty implements Cloneable {
", isDate=" + isDate +
", isDateTime=" + isDateTime +
", isUuid=" + isUuid +
", isUri=" + isUri +
", isEmail=" + isEmail +
", isFreeFormObject=" + isFreeFormObject +
", isListContainer=" + isListContainer +

View File

@ -1015,6 +1015,7 @@ public class DefaultCodegen implements CodegenConfig {
typeMapping.put("binary", "File");
typeMapping.put("file", "File");
typeMapping.put("UUID", "UUID");
typeMapping.put("URI", "URI");
//typeMapping.put("BigDecimal", "BigDecimal"); //TODO need the mapping?
@ -1025,6 +1026,7 @@ public class DefaultCodegen implements CodegenConfig {
importMapping = new HashMap<String, String>();
importMapping.put("BigDecimal", "java.math.BigDecimal");
importMapping.put("UUID", "java.util.UUID");
importMapping.put("URI", "java.net.URI");
importMapping.put("File", "java.io.File");
importMapping.put("Date", "java.util.Date");
importMapping.put("Timestamp", "java.sql.Timestamp");
@ -1233,6 +1235,8 @@ public class DefaultCodegen implements CodegenConfig {
codegenParameter.example = "2013-10-20T19:20:30+01:00";
} else if (Boolean.TRUE.equals(codegenParameter.isUuid)) {
codegenParameter.example = "38400000-8cf0-11bd-b23e-10b96e4ef00d";
} else if (Boolean.TRUE.equals(codegenParameter.isUri)) {
codegenParameter.example = "https://openapi-generator.tech";
} else if (Boolean.TRUE.equals(codegenParameter.isString)) {
codegenParameter.example = codegenParameter.paramName + "_example";
} else if (Boolean.TRUE.equals(codegenParameter.isFreeFormObject)) {
@ -1512,6 +1516,8 @@ public class DefaultCodegen implements CodegenConfig {
return "array";
} else if (ModelUtils.isUUIDSchema(schema)) {
return "UUID";
} else if (ModelUtils.isURISchema(schema)) {
return "URI";
} else if (ModelUtils.isStringSchema(schema)) {
return "string";
} else if (ModelUtils.isFreeFormObject(schema)) {
@ -2038,6 +2044,9 @@ public class DefaultCodegen implements CodegenConfig {
// keep isString to true to make it backward compatible
property.isString = true;
property.isUuid = true;
} else if (ModelUtils.isURISchema(p)) {
property.isString = true; // for backward compatibility
property.isUri = true;
} else if (ModelUtils.isEmailSchema(p)) {
property.isString = true;
property.isEmail = true;

View File

@ -277,6 +277,8 @@ public class ExampleGenerator {
return mp;
} else if (ModelUtils.isUUIDSchema(property)) {
return "046b6c7f-0b8a-43b9-b35d-6489e6daee91";
} else if (ModelUtils.isURISchema(property)) {
return "https://openapi-generator.tech";
} else if (ModelUtils.isStringSchema(property)) {
LOGGER.debug("String property");
String defaultValue = (String) property.getDefault();

View File

@ -193,6 +193,8 @@ public class XmlExampleGenerator {
return "********";
} else if (ModelUtils.isUUIDSchema(schema)) {
return "046b6c7f-0b8a-43b9-b35d-6489e6daee91";
} else if (ModelUtils.isURISchema(schema)) {
return "https://openapi-generator.tech";
// do these last in case the specific types above are derived from these classes
} else if (ModelUtils.isStringSchema(schema)) {
return "aeiou";

View File

@ -140,6 +140,7 @@ abstract public class AbstractAdaCodegen extends DefaultCodegen implements Codeg
typeMapping.put("object", "Swagger.Object");
typeMapping.put("number", "Swagger.Number");
typeMapping.put("UUID", "Swagger.UString");
typeMapping.put("URI", "Swagger.UString");
typeMapping.put("file", "Swagger.Http_Content_Type");
typeMapping.put("binary", "Swagger.Binary");

View File

@ -76,6 +76,8 @@ public abstract class AbstractCSharpCodegen extends DefaultCodegen implements Co
// nullable type
protected Set<String> nullableType = new HashSet<String>();
protected Set<String> valueTypes = new HashSet<String>();
private static final Logger LOGGER = LoggerFactory.getLogger(AbstractCSharpCodegen.class);
public AbstractCSharpCodegen() {
@ -185,11 +187,16 @@ public abstract class AbstractCSharpCodegen extends DefaultCodegen implements Co
typeMapping.put("map", "Dictionary");
typeMapping.put("object", "Object");
typeMapping.put("UUID", "Guid?");
typeMapping.put("URI", "string");
// nullable type
nullableType = new HashSet<String>(
Arrays.asList("decimal", "bool", "int", "float", "long", "double", "DateTime", "Guid")
);
// value Types
valueTypes = new HashSet<String>(
Arrays.asList("decimal", "bool", "int", "float", "long", "double")
);
}
public void setReturnICollection(boolean returnICollection) {
@ -414,6 +421,7 @@ public abstract class AbstractCSharpCodegen extends DefaultCodegen implements Co
public Map<String, Object> postProcessAllModels(Map<String, Object> objs) {
final Map<String, Object> processed = super.postProcessAllModels(objs);
postProcessEnumRefs(processed);
updateValueTypeProperty(processed);
return processed;
}
@ -454,6 +462,19 @@ public abstract class AbstractCSharpCodegen extends DefaultCodegen implements Co
var.isPrimitiveType = true;
}
}
for (CodegenProperty var : model.vars) {
if (enumRefs.containsKey(var.dataType)) {
// Handle any enum properties referred to by $ref.
// This is different in C# than most other generators, because enums in C# are compiled to integral types,
// while enums in many other languages are true objects.
CodegenModel refModel = enumRefs.get(var.dataType);
var.allowableValues = refModel.allowableValues;
var.isEnum = true;
// We do these after updateCodegenPropertyEnum to avoid generalities that don't mesh with C#.
var.isPrimitiveType = true;
}
}
// We're looping all models here.
if (model.isEnum) {
@ -541,6 +562,23 @@ public abstract class AbstractCSharpCodegen extends DefaultCodegen implements Co
}
}
/**
* Update property if it is a C# value type
*
* @param models list of all models
*/
protected void updateValueTypeProperty(Map<String, Object> models) {
for (Map.Entry<String, Object> entry : models.entrySet()) {
String openAPIName = entry.getKey();
CodegenModel model = ModelUtils.getModelByName(openAPIName, models);
if (model != null) {
for (CodegenProperty var : model.vars) {
var.vendorExtensions.put("isValueType", isValueType(var));
}
}
}
}
@Override
public Map<String, Object> postProcessOperationsWithModels(Map<String, Object> objs, List<Object> allModels) {
super.postProcessOperationsWithModels(objs, allModels);
@ -1055,6 +1093,17 @@ public abstract class AbstractCSharpCodegen extends DefaultCodegen implements Co
"double".equals(dataType) || "decimal".equals(dataType) || "float".equals(dataType);
}
/**
* Return true if the property being passed is a C# value type
*
* @param var property
* @return true if property is a value type
*/
protected boolean isValueType(CodegenProperty var) {
return (valueTypes.contains(var.dataType) || var.isEnum ) ;
}
@Override
public void setParameterExampleValue(CodegenParameter codegenParameter) {
@ -1087,6 +1136,8 @@ public abstract class AbstractCSharpCodegen extends DefaultCodegen implements Co
codegenParameter.example = "2013-10-20T19:20:30+01:00";
} else if (Boolean.TRUE.equals(codegenParameter.isUuid)) {
codegenParameter.example = "38400000-8cf0-11bd-b23e-10b96e4ef00d";
} else if (Boolean.TRUE.equals(codegenParameter.isUri)) {
codegenParameter.example = "https://openapi-generator.tech";
} else if (Boolean.TRUE.equals(codegenParameter.isString)) {
codegenParameter.example = codegenParameter.paramName + "_example";
}

View File

@ -19,6 +19,8 @@ package org.openapitools.codegen.languages;
import com.google.common.collect.ImmutableMap;
import com.samskivert.mustache.Mustache;
import io.swagger.v3.oas.models.OpenAPI;
import io.swagger.v3.oas.models.media.Schema;
import org.apache.commons.io.FilenameUtils;
import org.apache.commons.lang3.StringUtils;
@ -26,10 +28,12 @@ import org.openapitools.codegen.CodegenConfig;
import org.openapitools.codegen.CodegenProperty;
import org.openapitools.codegen.DefaultCodegen;
import org.openapitools.codegen.templating.mustache.IndentedLambda;
import org.openapitools.codegen.utils.URLPathUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.File;
import java.net.URL;
import java.util.Arrays;
import java.util.Map;
@ -300,4 +304,17 @@ abstract public class AbstractCppCodegen extends DefaultCodegen implements Codeg
}
}
}
@Override
public void preprocessOpenAPI(OpenAPI openAPI) {
URL url = URLPathUtils.getServerURL(openAPI);
String port = URLPathUtils.getPort(url, "");
String host = url.getHost();
if(!port.isEmpty()) {
this.additionalProperties.put("serverPort", port);
}
if(!host.isEmpty()) {
this.additionalProperties.put("serverHost", host);
}
}
}

View File

@ -71,6 +71,7 @@ public abstract class AbstractEiffelCodegen extends DefaultCodegen implements Co
typeMapping.put("boolean", "BOOLEAN");
typeMapping.put("string", "STRING_32");
typeMapping.put("UUID", "UUID"); //
typeMapping.put("URI", "STRING"); //
typeMapping.put("date", "DATE");
typeMapping.put("DateTime", "DATE_TIME");
typeMapping.put("date-time", "DATE_TIME");

View File

@ -171,6 +171,7 @@ public abstract class AbstractFSharpCodegen extends DefaultCodegen implements Co
typeMapping.put("map", "IDictionary");
typeMapping.put("object", "obj");
typeMapping.put("UUID", "Guid");
typeMapping.put("URI", "string");
// nullable type
nullableType = new HashSet<String>(

View File

@ -98,6 +98,7 @@ public abstract class AbstractGoCodegen extends DefaultCodegen implements Codege
typeMapping.put("boolean", "bool");
typeMapping.put("string", "string");
typeMapping.put("UUID", "string");
typeMapping.put("URI", "string");
typeMapping.put("date", "string");
typeMapping.put("DateTime", "time.Time");
typeMapping.put("password", "string");

View File

@ -82,6 +82,7 @@ public abstract class AbstractGraphQLCodegen extends DefaultCodegen implements C
typeMapping.put("boolean", "Boolean");
typeMapping.put("string", "String");
typeMapping.put("UUID", "ID");
typeMapping.put("URI", "String");
typeMapping.put("date", "String");
typeMapping.put("DateTime", "String");
typeMapping.put("password", "String");
@ -463,4 +464,4 @@ public abstract class AbstractGraphQLCodegen extends DefaultCodegen implements C
return camelize(name) + "Input";
}
}
}

View File

@ -44,6 +44,7 @@ public abstract class AbstractKotlinCodegen extends DefaultCodegen implements Co
protected String apiSuffix = "Api";
protected String sourceFolder = "src/main/kotlin";
protected String testFolder = "src/test/kotlin";
protected String apiDocPath = "docs/";
protected String modelDocPath = "docs/";
@ -166,14 +167,14 @@ public abstract class AbstractKotlinCodegen extends DefaultCodegen implements Co
typeMapping.put("ByteArray", "kotlin.ByteArray");
typeMapping.put("number", "java.math.BigDecimal");
typeMapping.put("date-time", "java.time.LocalDateTime");
typeMapping.put("date", "java.time.LocalDateTime");
typeMapping.put("date", "java.time.LocalDate");
typeMapping.put("file", "java.io.File");
typeMapping.put("array", "kotlin.Array");
typeMapping.put("list", "kotlin.collections.List");
typeMapping.put("map", "kotlin.collections.Map");
typeMapping.put("object", "kotlin.Any");
typeMapping.put("binary", "kotlin.Array<kotlin.Byte>");
typeMapping.put("Date", "java.time.LocalDateTime");
typeMapping.put("Date", "java.time.LocalDate");
typeMapping.put("DateTime", "java.time.LocalDateTime");
instantiationTypes.put("array", "kotlin.arrayOf");
@ -183,6 +184,7 @@ public abstract class AbstractKotlinCodegen extends DefaultCodegen implements Co
importMapping = new HashMap<String, String>();
importMapping.put("BigDecimal", "java.math.BigDecimal");
importMapping.put("UUID", "java.util.UUID");
importMapping.put("URI", "java.net.URI");
importMapping.put("File", "java.io.File");
importMapping.put("Date", "java.util.Date");
importMapping.put("Timestamp", "java.sql.Timestamp");
@ -208,12 +210,17 @@ public abstract class AbstractKotlinCodegen extends DefaultCodegen implements Co
@Override
public String apiDocFileFolder() {
return (outputFolder + "/" + apiDocPath).replace('/', File.separatorChar);
return (outputFolder + File.separator + apiDocPath).replace('/', File.separatorChar);
}
@Override
public String apiFileFolder() {
return outputFolder + File.separator + sourceFolder + File.separator + apiPackage().replace('.', File.separatorChar);
return (outputFolder + File.separator + sourceFolder + File.separator + apiPackage().replace('.', File.separatorChar)).replace('/', File.separatorChar);
}
@Override
public String apiTestFileFolder() {
return (outputFolder + File.separator + testFolder + File.separator + apiPackage().replace('.', File.separatorChar)).replace('/', File.separatorChar) ;
}
@Override
@ -410,6 +417,10 @@ public abstract class AbstractKotlinCodegen extends DefaultCodegen implements Co
this.sourceFolder = sourceFolder;
}
public void setTestFolder(String testFolder) {
this.testFolder = testFolder;
}
public Boolean getParcelizeModels() {
return parcelizeModels;
}

View File

@ -125,6 +125,7 @@ public abstract class AbstractPhpCodegen extends DefaultCodegen implements Codeg
typeMapping.put("binary", "string");
typeMapping.put("ByteArray", "string");
typeMapping.put("UUID", "string");
typeMapping.put("URI", "string");
cliOptions.add(new CliOption(CodegenConstants.MODEL_PACKAGE, CodegenConstants.MODEL_PACKAGE_DESC));
cliOptions.add(new CliOption(CodegenConstants.API_PACKAGE, CodegenConstants.API_PACKAGE_DESC));

View File

@ -81,6 +81,7 @@ abstract public class AbstractRubyCodegen extends DefaultCodegen implements Code
typeMapping.put("binary", "String");
typeMapping.put("ByteArray", "String");
typeMapping.put("UUID", "String");
typeMapping.put("URI", "String");
}
@Override

View File

@ -123,6 +123,7 @@ public abstract class AbstractTypeScriptClientCodegen extends DefaultCodegen imp
typeMapping.put("File", "any");
typeMapping.put("ByteArray", "string");
typeMapping.put("UUID", "string");
typeMapping.put("URI", "string");
typeMapping.put("Error", "Error");
cliOptions.add(new CliOption(CodegenConstants.MODEL_PROPERTY_NAMING, CodegenConstants.MODEL_PROPERTY_NAMING_DESC).defaultValue(this.modelPropertyNaming));

View File

@ -21,6 +21,7 @@ import io.swagger.v3.oas.models.OpenAPI;
import io.swagger.v3.oas.models.info.Info;
import io.swagger.v3.oas.models.media.ArraySchema;
import io.swagger.v3.oas.models.media.Schema;
import org.apache.commons.lang3.StringUtils;
import org.openapitools.codegen.CliOption;
import org.openapitools.codegen.CodegenProperty;
import org.openapitools.codegen.SupportingFile;
@ -46,7 +47,7 @@ public class ApexClientCodegen extends AbstractApexCodegen {
private String classPrefix = "OAS";
private String apiVersion = "42.0";
private String buildMethod = "sfdx";
private String namedCredential = classPrefix;
private String namedCredential;
private String srcPath = "force-app/main/default/";
private String sfdxConfigPath = "config/";
private HashMap<String, Object> primitiveDefaults = new HashMap<String, Object>();
@ -93,6 +94,7 @@ public class ApexClientCodegen extends AbstractApexCodegen {
typeMapping.put("number", "Double");
typeMapping.put("short", "Integer");
typeMapping.put("UUID", "String");
typeMapping.put("URI", "String");
// https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_reserved_words.htm
setReservedWordsLowerCase(
@ -161,8 +163,10 @@ public class ApexClientCodegen extends AbstractApexCodegen {
@Override
public void preprocessOpenAPI(OpenAPI openAPI) {
Info info = openAPI.getInfo();
String calloutLabel = info.getTitle();
String calloutLabel = openAPI.getInfo().getTitle();
if (StringUtils.isNotBlank(namedCredential)) {
calloutLabel = namedCredential;
}
additionalProperties.put("calloutLabel", calloutLabel);
String sanitized = sanitizeName(calloutLabel);
additionalProperties.put("calloutName", sanitized);

View File

@ -100,6 +100,7 @@ public class AspNetCoreServerCodegen extends AbstractCSharpCodegen {
typeMapping.put("DateTime", "DateTime");
typeMapping.put("date", "DateTime");
typeMapping.put("UUID", "Guid");
typeMapping.put("URI", "string");
setSupportNullable(Boolean.TRUE);

View File

@ -199,6 +199,7 @@ public class BashClientCodegen extends DefaultCodegen implements CodegenConfig {
typeMapping.put("file", "binary");
typeMapping.put("binary", "binary");
typeMapping.put("UUID", "string");
typeMapping.put("URI", "string");
/**
* Additional Properties. These values can be passed to the templates and

View File

@ -152,6 +152,7 @@ public class CLibcurlClientCodegen extends DefaultCodegen implements CodegenConf
typeMapping.put("binary", "binary_t*");
typeMapping.put("ByteArray", "char");
typeMapping.put("UUID", "char");
typeMapping.put("URI", "char");
typeMapping.put("array", "list");
typeMapping.put("map", "list_t*");
typeMapping.put("date-time", "char");

View File

@ -73,6 +73,9 @@ public class CSharpClientCodegen extends AbstractCSharpCodegen {
// use KellermanSoftware.CompareNetObjects for deep recursive object comparision
protected boolean useCompareNetObjects = Boolean.FALSE;
// To make API response's headers dictionary case insensitive
protected boolean caseInsensitiveResponseHeaders = Boolean.FALSE;
public CSharpClientCodegen() {
super();
supportsInheritance = true;
@ -95,6 +98,7 @@ public class CSharpClientCodegen extends AbstractCSharpCodegen {
typeMapping.put("DateTime", "DateTime");
typeMapping.put("date", "DateTime");
typeMapping.put("UUID", "Guid");
typeMapping.put("URI", "string");
setSupportNullable(Boolean.TRUE);
@ -198,6 +202,10 @@ public class CSharpClientCodegen extends AbstractCSharpCodegen {
CodegenConstants.USE_COMPARE_NET_OBJECTS_DESC,
this.useCompareNetObjects);
addSwitch(CodegenConstants.CASE_INSENSITIVE_RESPONSE_HEADERS,
CodegenConstants.CASE_INSENSITIVE_RESPONSE_HEADERS_DESC,
this.caseInsensitiveResponseHeaders);
regexModifiers = new HashMap<Character, String>();
regexModifiers.put('i', "IgnoreCase");
regexModifiers.put('m', "Multiline");
@ -801,6 +809,10 @@ public class CSharpClientCodegen extends AbstractCSharpCodegen {
this.useCompareNetObjects = useCompareNetObjects;
}
public void setCaseInsensitiveResponseHeaders(final Boolean caseInsensitiveResponseHeaders) {
this.caseInsensitiveResponseHeaders = caseInsensitiveResponseHeaders;
}
public boolean isNonPublicApi() {
return nonPublicApi;
}

View File

@ -100,6 +100,7 @@ public class CSharpNetCoreClientCodegen extends AbstractCSharpCodegen {
typeMapping.put("map", "Dictionary");
typeMapping.put("object", "Object");
typeMapping.put("UUID", "Guid");
typeMapping.put("URI", "string");
setSupportNullable(Boolean.TRUE);
hideGenerationTimestamp = Boolean.TRUE;

View File

@ -93,6 +93,7 @@ public class ClojureClientCodegen extends DefaultCodegen implements CodegenConfi
typeMapping.put("date", "inst?");
typeMapping.put("DateTime", "inst?");
typeMapping.put("UUID", "uuid?");
typeMapping.put("URI", "string?");
// But some type mappings are not really worth/meaningful to check for:
typeMapping.put("object", "any?"); // Like, everything is an object.

View File

@ -107,6 +107,7 @@ public class CppPistacheServerCodegen extends AbstractCppCodegen {
typeMapping.put("binary", "std::string");
typeMapping.put("number", "double");
typeMapping.put("UUID", "std::string");
typeMapping.put("URI", "std::string");
typeMapping.put("ByteArray", "std::string");
super.importMapping = new HashMap<String, String>();
@ -404,14 +405,7 @@ public class CppPistacheServerCodegen extends AbstractCppCodegen {
public String getTypeDeclaration(String str) {
return toModelName(str);
}
@Override
public void preprocessOpenAPI(OpenAPI openAPI) {
URL url = URLPathUtils.getServerURL(openAPI);
String port = URLPathUtils.getPort(url, "8080");
this.additionalProperties.put("serverPort", port);
}
/**
* Specify whether external libraries will be added during the generation
* @param value the value to be set

View File

@ -78,6 +78,7 @@ public class CppQt5AbstractCodegen extends AbstractCppCodegen implements Codegen
typeMapping.put("integer", "qint32");
typeMapping.put("long", "qint64");
typeMapping.put("boolean", "bool");
typeMapping.put("number", "double");
typeMapping.put("array", "QList");
typeMapping.put("map", "QMap");
typeMapping.put("object", PREFIX + "Object");
@ -88,6 +89,7 @@ public class CppQt5AbstractCodegen extends AbstractCppCodegen implements Codegen
// come out of the box and will need to be sorted out (at least imply
// modifications on multiple templates)
typeMapping.put("UUID", "QString");
typeMapping.put("URI", "QString");
typeMapping.put("file", "QIODevice");
typeMapping.put("binary", "QIODevice");
importMapping = new HashMap<String, String>();

View File

@ -194,13 +194,6 @@ public class CppQt5QHttpEngineServerCodegen extends CppQt5AbstractCodegen implem
return result;
}
@Override
public void preprocessOpenAPI(OpenAPI openAPI) {
URL url = URLPathUtils.getServerURL(openAPI);
String port = URLPathUtils.getPort(url, "8080");
this.additionalProperties.put("serverPort", port);
}
@Override
public String toApiFilename(String name) {
return modelNamePrefix + sanitizeName(camelize(name)) + "ApiHandler";

View File

@ -146,6 +146,7 @@ public class CppRestSdkClientCodegen extends AbstractCppCodegen {
typeMapping.put("binary", "utility::string_t");
typeMapping.put("number", "double");
typeMapping.put("UUID", "utility::string_t");
typeMapping.put("URI", "utility::string_t");
typeMapping.put("ByteArray", "utility::string_t");
super.importMapping = new HashMap<String, String>();

View File

@ -89,6 +89,7 @@ public class CppRestbedServerCodegen extends AbstractCppCodegen {
typeMapping.put("binary", "restbed::Bytes");
typeMapping.put("number", "double");
typeMapping.put("UUID", "std::string");
typeMapping.put("URI", "std::string");
typeMapping.put("ByteArray", "std::string");
super.importMapping = new HashMap<String, String>();

View File

@ -102,6 +102,7 @@ public class CppTizenClientCodegen extends AbstractCppCodegen implements Codegen
typeMapping.put("DateTime", "std::string");
typeMapping.put("Date", "std::string");
typeMapping.put("UUID", "std::string");
typeMapping.put("URI", "std::string");
importMapping = new HashMap<String, String>();

View File

@ -49,6 +49,8 @@ public class DartClientCodegen extends DefaultCodegen implements CodegenConfig {
protected String sourceFolder = "";
protected String apiDocPath = "docs" + File.separator;
protected String modelDocPath = "docs" + File.separator;
protected String apiTestPath = "test" + File.separator;
protected String modelTestPath = "test" + File.separator;
public DartClientCodegen() {
super();
@ -66,6 +68,9 @@ public class DartClientCodegen extends DefaultCodegen implements CodegenConfig {
modelDocTemplateFiles.put("object_doc.mustache", ".md");
apiDocTemplateFiles.put("api_doc.mustache", ".md");
modelTestTemplateFiles.put("model_test.mustache", ".dart");
apiTestTemplateFiles.put("api_test.mustache", ".dart");
setReservedWordsLowerCase(
Arrays.asList(
"abstract", "as", "assert", "async", "async*", "await",
@ -110,6 +115,7 @@ public class DartClientCodegen extends DefaultCodegen implements CodegenConfig {
typeMapping.put("File", "MultipartFile");
typeMapping.put("binary", "MultipartFile");
typeMapping.put("UUID", "String");
typeMapping.put("URI", "String");
typeMapping.put("ByteArray", "String");
cliOptions.add(new CliOption(BROWSER_CLIENT, "Is the client browser based"));
@ -214,6 +220,7 @@ public class DartClientCodegen extends DefaultCodegen implements CodegenConfig {
supportingFiles.add(new SupportingFile("git_push.sh.mustache", "", "git_push.sh"));
supportingFiles.add(new SupportingFile("gitignore.mustache", "", ".gitignore"));
supportingFiles.add(new SupportingFile("README.mustache", "", "README.md"));
supportingFiles.add(new SupportingFile("travis.mustache", "", ".travis.yml"));
}
@Override
@ -231,6 +238,16 @@ public class DartClientCodegen extends DefaultCodegen implements CodegenConfig {
return outputFolder + File.separator + sourceFolder + File.separator + modelPackage().replace('.', File.separatorChar);
}
@Override
public String apiTestFileFolder() {
return outputFolder + File.separator + apiTestPath.replace('/', File.separatorChar);
}
@Override
public String modelTestFileFolder() {
return outputFolder + File.separator + modelTestPath.replace('/', File.separatorChar);
}
@Override
public String apiDocFileFolder() {
return outputFolder + File.separator + apiDocPath.replace('/', File.separatorChar);
@ -295,6 +312,16 @@ public class DartClientCodegen extends DefaultCodegen implements CodegenConfig {
return underscore(toApiName(name));
}
@Override
public String toApiTestFilename(String name) {
return toApiFilename(name) + "_test";
}
@Override
public String toModelTestFilename(String name) {
return toModelFilename(name) + "_test";
}
@Override
public String toDefaultValue(Schema schema) {
if (ModelUtils.isMapSchema(schema)) {

View File

@ -43,6 +43,7 @@ public class DartJaguarClientCodegen extends DartClientCodegen {
static {
modelToIgnore.add("datetime");
modelToIgnore.add("map");
modelToIgnore.add("object");
modelToIgnore.add("list");
modelToIgnore.add("file");
modelToIgnore.add("uint8list");
@ -86,6 +87,7 @@ public class DartJaguarClientCodegen extends DartClientCodegen {
protoTypeMapping.put("file", "bytes");
protoTypeMapping.put("binary", "bytes");
protoTypeMapping.put("UUID", "string");
protoTypeMapping.put("URI", "string");
protoTypeMapping.put("ByteArray", "bytes");
}
@ -177,6 +179,7 @@ public class DartJaguarClientCodegen extends DartClientCodegen {
supportingFiles.add(new SupportingFile("git_push.sh.mustache", "", "git_push.sh"));
supportingFiles.add(new SupportingFile("gitignore.mustache", "", ".gitignore"));
supportingFiles.add(new SupportingFile("README.mustache", "", "README.md"));
supportingFiles.add(new SupportingFile("travis.mustache", "", ".travis.yml"));
final String authFolder = sourceFolder + File.separator + "lib" + File.separator + "auth";
supportingFiles.add(new SupportingFile("auth/api_key_auth.mustache", authFolder, "api_key_auth.dart"));

View File

@ -175,6 +175,7 @@ public class ElixirClientCodegen extends DefaultCodegen implements CodegenConfig
typeMapping.put("binary", "String");
typeMapping.put("ByteArray", "String");
typeMapping.put("UUID", "String");
typeMapping.put("URI", "String");
cliOptions.add(new CliOption(CodegenConstants.INVOKER_PACKAGE, "The main namespace to use for all classes. e.g. Yay.Pets"));
cliOptions.add(new CliOption("licenseHeader", "The license header to prepend to the top of all source files."));

View File

@ -138,6 +138,7 @@ public class ElmClientCodegen extends DefaultCodegen implements CodegenConfig {
typeMapping.put("file", "String");
typeMapping.put("binary", "String");
typeMapping.put("UUID", "Uuid");
typeMapping.put("URI", "String");
importMapping.clear();
@ -567,44 +568,56 @@ public class ElmClientCodegen extends DefaultCodegen implements CodegenConfig {
return "(Just " + value + ")";
}
private Optional<String> paramToStringMapper(final String paramName, final CodegenProperty property) {
if (property.isEnum) {
return Optional.of(toVarName(paramName) + "ToString");
} else if (property.isString || property.isBinary || property.isByteArray) {
return Optional.empty();
} else if (property.isBoolean) {
return Optional.of("(\\val -> if val then \"true\" else \"false\")");
} else if (property.isDateTime) {
return Optional.of("DateTime.toString");
} else if (property.isDate) {
return Optional.of("DateOnly.toString");
} else if (property.isUuid) {
return Optional.of("Uuid.toString");
} else if (ElmVersion.ELM_018.equals(elmVersion)) {
return Optional.of("toString");
} else if (property.isInteger || property.isLong) {
return Optional.of("String.fromInt");
} else if (property.isFloat || property.isDouble) {
return Optional.of("String.fromFloat");
}
throw new RuntimeException("Parameter '" + paramName + "' cannot be converted to a string. Please report the issue.");
}
private CodegenProperty paramToProperty(final CodegenParameter parameter) {
final CodegenProperty property = new CodegenProperty();
property.isEnum = parameter.isEnum;
property.isString = parameter.isString;
property.isBinary = parameter.isBinary;
property.isByteArray = parameter.isByteArray;
property.isBoolean = parameter.isBoolean;
property.isDateTime = parameter.isDateTime;
property.isDate = parameter.isDate;
property.isUuid = parameter.isUuid;
property.isInteger = parameter.isInteger;
property.isLong = parameter.isLong;
property.isFloat = parameter.isFloat;
property.isDouble = parameter.isDouble;
return property;
}
private String paramToString(final String prefix, final CodegenParameter param, final boolean useMaybe, final String maybeMapResult) {
final String paramName = (ElmVersion.ELM_018.equals(elmVersion) ? "" : prefix + ".") + param.paramName;
if (!useMaybe) {
param.required = true;
}
String mapFn = null;
if (param.isString || param.isBinary || param.isByteArray) {
mapFn = "";
} else if (param.isBoolean) {
mapFn = "(\\val -> if val then \"true\" else \"false\")";
} else if (param.isDateTime) {
mapFn = "DateTime.toString";
} else if (param.isDate) {
mapFn = "DateOnly.toString";
} else if (param.isUuid) {
mapFn = "Uuid.toString";
} else if (ElmVersion.ELM_018.equals(elmVersion)) {
mapFn = "toString";
} else if (param.isInteger || param.isLong) {
mapFn = "String.fromInt";
} else if (param.isFloat || param.isDouble) {
mapFn = "String.fromFloat";
} else if (param.isListContainer) {
// TODO duplicate ALL types from parameter to property...
if (param.items.isString || param.items.isUuid || param.items.isBinary || param.items.isByteArray) {
mapFn = "String.join \",\"";
}
}
if (mapFn == null) {
throw new RuntimeException("Parameter '" + param.paramName + "' cannot be converted to a string. Please report the issue.");
}
final String mapFn = param.isListContainer
? "(String.join \",\"" + paramToStringMapper(param.paramName, param.items).map(mapper -> " << List.map " + mapper).orElse("") + ")"
: paramToStringMapper(param.paramName, paramToProperty(param)).orElse("");
if (param.isListContainer) {
if (!param.required) {
mapFn = "(" + mapFn + ")";
}
}
String mapResult = "";
if (maybeMapResult != null) {
if ("".equals(mapFn)) {

View File

@ -95,6 +95,7 @@ public class ErlangClientCodegen extends DefaultCodegen implements CodegenConfig
typeMapping.put("bytearray", "binary()");
typeMapping.put("byte", "binary()");
typeMapping.put("uuid", "binary()");
typeMapping.put("uri", "binary()");
typeMapping.put("password", "binary()");
cliOptions.clear();

View File

@ -98,6 +98,7 @@ public class ErlangProperCodegen extends DefaultCodegen implements CodegenConfig
typeMapping.put("bytearray", "binary()");
typeMapping.put("byte", "binary()");
typeMapping.put("uuid", "binary()");
typeMapping.put("uri", "binary()");
typeMapping.put("password", "binary()");
cliOptions.clear();

View File

@ -102,6 +102,7 @@ public class ErlangServerCodegen extends DefaultCodegen implements CodegenConfig
typeMapping.put("bytearray", "binary");
typeMapping.put("byte", "binary");
typeMapping.put("uuid", "binary");
typeMapping.put("uri", "binary");
typeMapping.put("password", "binary");
cliOptions.clear();

View File

@ -74,6 +74,7 @@ public class FlashClientCodegen extends DefaultCodegen implements CodegenConfig
typeMapping.put("object", "Object");
typeMapping.put("file", "File");
typeMapping.put("UUID", "String");
typeMapping.put("URI", "String");
typeMapping.put("binary", "File");
importMapping = new HashMap<String, String>();

View File

@ -227,6 +227,7 @@ public class HaskellHttpClientCodegen extends DefaultCodegen implements CodegenC
// lib
typeMapping.put("string", "Text");
typeMapping.put("UUID", "Text");
typeMapping.put("URI", "Text");
typeMapping.put("any", "A.Value");
typeMapping.put("set", "Set.Set");
// newtype

View File

@ -173,6 +173,7 @@ public class HaskellServantCodegen extends DefaultCodegen implements CodegenConf
typeMapping.put("number", "Double");
typeMapping.put("any", "Value");
typeMapping.put("UUID", "UUID");
typeMapping.put("URI", "Text");
typeMapping.put("ByteArray", "Text");
typeMapping.put("object", "Value");

View File

@ -44,7 +44,7 @@ public class JavaMSF4JServerCodegen extends AbstractJavaJAXRSServerCodegen {
apiTestTemplateFiles.clear();
modelDocTemplateFiles.remove("model_doc.mustache");
apiDocTemplateFiles.remove("api_doc.mustache");
embeddedTemplateDir = templateDir = "MSF4J";
embeddedTemplateDir = templateDir = "java-msf4j-server";
CliOption library = new CliOption(CodegenConstants.LIBRARY, CodegenConstants.LIBRARY_DESC);
supportedLibraries.put(LIBRARY_JERSEY1, "Jersey core 1.x");
supportedLibraries.put(LIBRARY_JERSEY2, "Jersey core 2.x");

View File

@ -40,7 +40,7 @@ public class JavaUndertowServerCodegen extends AbstractJavaCodegen {
public JavaUndertowServerCodegen() {
super();
embeddedTemplateDir = templateDir = "undertow";
embeddedTemplateDir = templateDir = "java-undertow-server";
invokerPackage = "org.openapitools.handler";
artifactId = "openapi-undertow-server";
dateLibrary = "legacy"; //TODO: add joda support

View File

@ -156,6 +156,7 @@ public class JavascriptClientCodegen extends DefaultCodegen implements CodegenCo
typeMapping.put("binary", "File");
typeMapping.put("file", "File");
typeMapping.put("UUID", "String");
typeMapping.put("URI", "String");
importMapping.clear();

View File

@ -95,6 +95,7 @@ public class JavascriptFlowtypedClientCodegen extends AbstractTypeScriptClientCo
typeMapping.put("binary", "string");
typeMapping.put("ByteArray", "string");
typeMapping.put("UUID", "string");
typeMapping.put("URI", "string");
defaultIncludes = new HashSet<String>(languageSpecificPrimitives);
outputFolder = "generated-code/javascript-flowtyped";

View File

@ -131,6 +131,7 @@ public class KotlinClientCodegen extends AbstractKotlinCodegen {
typeMapping.put("DateTime", "LocalDateTime");
importMapping.put("LocalDate", "org.threeten.bp.LocalDate");
importMapping.put("LocalDateTime", "org.threeten.bp.LocalDateTime");
defaultIncludes.add("org.threeten.bp.LocalDate");
defaultIncludes.add("org.threeten.bp.LocalDateTime");
} else if (DateLibrary.STRING.value.equals(dateLibrary)) {
typeMapping.put("date-time", "kotlin.String");
@ -166,5 +167,8 @@ public class KotlinClientCodegen extends AbstractKotlinCodegen {
supportingFiles.add(new SupportingFile("infrastructure/Serializer.kt.mustache", infrastructureFolder, "Serializer.kt"));
supportingFiles.add(new SupportingFile("infrastructure/Errors.kt.mustache", infrastructureFolder, "Errors.kt"));
supportingFiles.add(new SupportingFile("infrastructure/ByteArrayAdapter.kt.mustache", infrastructureFolder, "ByteArrayAdapter.kt"));
supportingFiles.add(new SupportingFile("infrastructure/LocalDateAdapter.kt.mustache", infrastructureFolder, "LocalDateAdapter.kt"));
supportingFiles.add(new SupportingFile("infrastructure/LocalDateTimeAdapter.kt.mustache", infrastructureFolder, "LocalDateTimeAdapter.kt"));
supportingFiles.add(new SupportingFile("infrastructure/UUIDAdapter.kt.mustache", infrastructureFolder, "UUIDAdapter.kt"));
}
}

View File

@ -76,10 +76,11 @@ public class KotlinSpringServerCodegen extends AbstractKotlinCodegen
public KotlinSpringServerCodegen() {
super();
apiTestTemplateFiles.put("api_test.mustache", ".kt");
reservedWords.addAll(VARIABLE_RESERVED_WORDS);
outputFolder = "generated-code/kotlin-spring";
apiTestTemplateFiles.clear(); // TODO: add test template
embeddedTemplateDir = templateDir = "kotlin-spring";
artifactId = "openapi-spring";

View File

@ -108,6 +108,7 @@ public class LuaClientCodegen extends DefaultCodegen implements CodegenConfig {
typeMapping.put("boolean", "boolean");
typeMapping.put("string", "string");
typeMapping.put("UUID", "string");
typeMapping.put("URI", "string");
typeMapping.put("date", "string");
typeMapping.put("DateTime", "string");
typeMapping.put("password", "string");

View File

@ -117,6 +117,7 @@ public class MysqlSchemaCodegen extends DefaultCodegen implements CodegenConfig
"binary",
"file",
"UUID",
"URI",
"BigDecimal",
"mixed",
"number",
@ -148,6 +149,7 @@ public class MysqlSchemaCodegen extends DefaultCodegen implements CodegenConfig
typeMapping.put("binary", "MEDIUMBLOB");
typeMapping.put("file", "MEDIUMBLOB");
typeMapping.put("UUID", "TEXT");
typeMapping.put("URI", "TEXT");
typeMapping.put("BigDecimal", "DECIMAL");
embeddedTemplateDir = templateDir = "mysql-schema";

View File

@ -134,6 +134,7 @@ public class ObjcClientCodegen extends DefaultCodegen implements CodegenConfig {
typeMapping.put("bytearray", "NSData");
typeMapping.put("byte", "NSData");
typeMapping.put("uuid", "NSString");
typeMapping.put("uri", "NSString");
typeMapping.put("password", "NSString");
// ref: http://www.tutorialspoint.com/objective_c/objective_c_basic_syntax.htm

View File

@ -111,6 +111,7 @@ public class PerlClientCodegen extends DefaultCodegen implements CodegenConfig {
typeMapping.put("file", "string");
typeMapping.put("ByteArray", "string");
typeMapping.put("UUID", "string");
typeMapping.put("URI", "string");
cliOptions.clear();
cliOptions.add(new CliOption(MODULE_NAME, "Perl module name (convention: CamelCase or Long::Module).").defaultValue("OpenAPIClient"));

View File

@ -173,6 +173,7 @@ public class PhpSymfonyServerCodegen extends AbstractPhpCodegen implements Codeg
typeMapping.put("binary", "string");
typeMapping.put("ByteArray", "string");
typeMapping.put("UUID", "string");
typeMapping.put("URI", "string");
cliOptions.add(new CliOption(COMPOSER_VENDOR_NAME, "The vendor name used in the composer package name." +
" The template uses {{composerVendorName}}/{{composerProjectName}} for the composer package name. e.g. yaypets"));

View File

@ -60,7 +60,7 @@ public class PhpZendExpressivePathHandlerServerCodegen extends AbstractPhpCodege
//no point to use double - http://php.net/manual/en/language.types.float.php , especially because of PHP 7+ float type declaration
typeMapping.put("double", "float");
embeddedTemplateDir = templateDir = "ze-ph";
embeddedTemplateDir = templateDir = "php-ze-ph";
invokerPackage = "App";
srcBasePath = "src" + File.separator + "App";
apiDirName = "Handler";

View File

@ -93,6 +93,7 @@ public class PythonAbstractConnexionServerCodegen extends DefaultCodegen impleme
typeMapping.put("object", "object");
typeMapping.put("file", "file");
typeMapping.put("UUID", "str");
typeMapping.put("URI", "str");
typeMapping.put("byte", "bytearray");
typeMapping.put("ByteArray", "bytearray");
@ -201,6 +202,7 @@ public class PythonAbstractConnexionServerCodegen extends DefaultCodegen impleme
}
supportingFiles.add(new SupportingFile("__main__.mustache", packagePath(), "__main__.py"));
supportingFiles.add(new SupportingFile("util.mustache", packagePath(), "util.py"));
supportingFiles.add(new SupportingFile("typing_utils.mustache", packagePath(), "typing_utils.py"));
supportingFiles.add(new SupportingFile("__init__.mustache", packagePath() + File.separatorChar + packageToPath(controllerPackage), "__init__.py"));
supportingFiles.add(new SupportingFile("security_controller_.mustache", packagePath() + File.separatorChar + packageToPath(controllerPackage), "security_controller_.py"));
supportingFiles.add(new SupportingFile("__init__model.mustache", packagePath() + File.separatorChar + packageToPath(modelPackage), "__init__.py"));

View File

@ -118,6 +118,7 @@ public class PythonBluePlanetServerCodegen extends PythonAbstractConnexionServer
supportingFiles.add(new SupportingFile("app/{{packageName}}/__main__.mustache", APP_PACKAGE_PATH, "__main__.py"));
supportingFiles.add(new SupportingFile("app/{{packageName}}/encoder.mustache", APP_PACKAGE_PATH, "encoder.py"));
supportingFiles.add(new SupportingFile("app/{{packageName}}/util.mustache", APP_PACKAGE_PATH, "util.py"));
supportingFiles.add(new SupportingFile("app/{{packageName}}/typing_utils.mustache", APP_PACKAGE_PATH, "typing_utils.py"));
supportingFiles.add(new SupportingFile("app/{{packageName}}/controllers/__init__.mustache", CONTROLLER_PATH, "__init__.py"));
@ -192,6 +193,7 @@ public class PythonBluePlanetServerCodegen extends PythonAbstractConnexionServer
supportingFiles.add(new SupportingFile("app/{{packageName}}/__main__.mustache", APP_PACKAGE_PATH, "__main__.py"));
supportingFiles.add(new SupportingFile("app/{{packageName}}/encoder.mustache", APP_PACKAGE_PATH, "encoder.py"));
supportingFiles.add(new SupportingFile("app/{{packageName}}/util.mustache", APP_PACKAGE_PATH, "util.py"));
supportingFiles.add(new SupportingFile("app/{{packageName}}/typing_utils.mustache", APP_PACKAGE_PATH, "typing_utils.py"));
supportingFiles.add(new SupportingFile("app/{{packageName}}/controllers/__init__.mustache", CONTROLLER_PATH, "__init__.py"));

View File

@ -41,8 +41,8 @@ public class PythonClientCodegen extends DefaultCodegen implements CodegenConfig
public static final String PACKAGE_URL = "packageUrl";
public static final String DEFAULT_LIBRARY = "urllib3";
protected String packageName; // e.g. petstore_api
protected String packageVersion;
protected String packageName = "openapi_client";
protected String packageVersion = "1.0.0";
protected String projectName; // for setup.py, e.g. petstore-api
protected String packageUrl;
protected String apiDocPath = "docs/";
@ -113,6 +113,7 @@ public class PythonClientCodegen extends DefaultCodegen implements CodegenConfig
typeMapping.put("ByteArray", "str");
// map uuid to string for the time being
typeMapping.put("UUID", "str");
typeMapping.put("URI", "str");
// from https://docs.python.org/3/reference/lexical_analysis.html#keywords
setReservedWordsLowerCase(
@ -176,8 +177,6 @@ public class PythonClientCodegen extends DefaultCodegen implements CodegenConfig
if (additionalProperties.containsKey(CodegenConstants.PACKAGE_NAME)) {
setPackageName((String) additionalProperties.get(CodegenConstants.PACKAGE_NAME));
} else {
setPackageName("openapi_client");
}
if (additionalProperties.containsKey(CodegenConstants.PROJECT_NAME)) {
@ -190,9 +189,7 @@ public class PythonClientCodegen extends DefaultCodegen implements CodegenConfig
if (additionalProperties.containsKey(CodegenConstants.PACKAGE_VERSION)) {
setPackageVersion((String) additionalProperties.get(CodegenConstants.PACKAGE_VERSION));
} else {
setPackageVersion("1.0.0");
}
}
Boolean generateSourceCodeOnly = false;
if (additionalProperties.containsKey(CodegenConstants.SOURCECODEONLY_GENERATION)) {
@ -240,10 +237,22 @@ public class PythonClientCodegen extends DefaultCodegen implements CodegenConfig
supportingFiles.add(new SupportingFile("__init__package.mustache", packagePath(), "__init__.py"));
supportingFiles.add(new SupportingFile("__init__model.mustache", packagePath() + File.separatorChar + modelPackage, "__init__.py"));
supportingFiles.add(new SupportingFile("__init__api.mustache", packagePath() + File.separatorChar + apiPackage, "__init__.py"));
// If the package name consists of dots(openapi.client), then we need to create the directory structure like openapi/client with __init__ files.
String[] packageNameSplits = packageName.split("\\.");
String currentPackagePath = "";
for (int i = 0; i < packageNameSplits.length-1; i++) {
if (i > 0) {
currentPackagePath = currentPackagePath + File.separatorChar;
}
currentPackagePath = currentPackagePath + packageNameSplits[i];
supportingFiles.add(new SupportingFile("__init__.mustache", currentPackagePath, "__init__.py"));
}
supportingFiles.add(new SupportingFile("exceptions.mustache", packagePath(), "exceptions.py"));
if (Boolean.FALSE.equals(excludeTests)) {
supportingFiles.add(new SupportingFile("__init__test.mustache", testFolder, "__init__.py"));
supportingFiles.add(new SupportingFile("__init__.mustache", testFolder, "__init__.py"));
}
supportingFiles.add(new SupportingFile("api_client.mustache", packagePath(), "api_client.py"));

View File

@ -96,6 +96,7 @@ public class RClientCodegen extends DefaultCodegen implements CodegenConfig {
typeMapping.put("boolean", "character");
typeMapping.put("string", "character");
typeMapping.put("UUID", "character");
typeMapping.put("URI", "character");
typeMapping.put("date", "character");
typeMapping.put("DateTime", "character");
typeMapping.put("password", "character");
@ -683,4 +684,4 @@ public class RClientCodegen extends DefaultCodegen implements CodegenConfig {
example += ")";
return example;
}
}
}

View File

@ -116,6 +116,7 @@ public class RustClientCodegen extends DefaultCodegen implements CodegenConfig {
typeMapping.put("boolean", "bool");
typeMapping.put("string", "String");
typeMapping.put("UUID", "String");
typeMapping.put("URI", "String");
typeMapping.put("date", "string");
typeMapping.put("DateTime", "String");
typeMapping.put("password", "String");

View File

@ -154,6 +154,7 @@ public class RustServerCodegen extends DefaultCodegen implements CodegenConfig {
typeMapping.put("double", "f64");
typeMapping.put("string", "String");
typeMapping.put("UUID", uuidType);
typeMapping.put("URI", "String");
typeMapping.put("byte", "u8");
typeMapping.put("ByteArray", bytesType);
typeMapping.put("binary", bytesType);

View File

@ -25,7 +25,7 @@ import org.openapitools.codegen.utils.ModelUtils;
import java.io.File;
import java.util.*;
public class FinchServerCodegen extends DefaultCodegen implements CodegenConfig {
public class ScalaFinchServerCodegen extends DefaultCodegen implements CodegenConfig {
protected String invokerPackage = "org.openapitools.client";
protected String groupId = "org.openapitools";
protected String artifactId = "finch-server";
@ -33,12 +33,12 @@ public class FinchServerCodegen extends DefaultCodegen implements CodegenConfig
protected String sourceFolder = "src/main/scala";
protected String packageName = "org.openapitools";
public FinchServerCodegen() {
public ScalaFinchServerCodegen() {
super();
outputFolder = "generated-code/finch";
modelTemplateFiles.put("model.mustache", ".scala");
apiTemplateFiles.put("api.mustache", ".scala");
embeddedTemplateDir = templateDir = "finch";
embeddedTemplateDir = templateDir = "scala-finch";
apiPackage = packageName + ".apis";
modelPackage = packageName + ".models";
@ -154,6 +154,7 @@ public class FinchServerCodegen extends DefaultCodegen implements CodegenConfig
importMapping = new HashMap<String, String>();
importMapping.put("BigDecimal", "java.math.BigDecimal");
importMapping.put("UUID", "java.util.UUID");
importMapping.put("URI", "java.net.URI");
importMapping.put("File", "java.io.File");
importMapping.put("Date", "java.util.Date");
importMapping.put("Timestamp", "java.sql.Timestamp");

View File

@ -101,6 +101,7 @@ public class ScalatraServerCodegen extends AbstractScalaCodegen implements Codeg
importMapping = new HashMap<String, String>();
importMapping.put("BigDecimal", "java.math.BigDecimal");
importMapping.put("UUID", "java.util.UUID");
importMapping.put("URI", "java.net.URI");
importMapping.put("File", "java.io.File");
importMapping.put("Date", "java.util.Date");
importMapping.put("Timestamp", "java.sql.Timestamp");

View File

@ -151,6 +151,7 @@ public class Swift3Codegen extends DefaultCodegen implements CodegenConfig {
typeMapping.put("binary", "Data");
typeMapping.put("ByteArray", "Data");
typeMapping.put("UUID", "UUID");
typeMapping.put("URI", "String");
importMapping = new HashMap<>();

View File

@ -197,6 +197,7 @@ public class Swift4Codegen extends DefaultCodegen implements CodegenConfig {
typeMapping.put("binary", "URL");
typeMapping.put("ByteArray", "Data");
typeMapping.put("UUID", "UUID");
typeMapping.put("URI", "String");
importMapping = new HashMap<>();

View File

@ -169,6 +169,7 @@ public class SwiftClientCodegen extends DefaultCodegen implements CodegenConfig
typeMapping.put("binary", "NSURL");
typeMapping.put("ByteArray", "NSData");
typeMapping.put("UUID", "NSUUID");
typeMapping.put("URI", "String");
importMapping = new HashMap<String, String>();

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