mirror of
https://github.com/OpenAPITools/openapi-generator.git
synced 2025-12-08 16:46:13 +00:00
Merge remote-tracking branch 'origin/4.2.x' into 5.0.x
This commit is contained in:
@@ -94,6 +94,8 @@ before_install:
|
||||
# - Rely on `kerl` for [pre-compiled versions available](https://docs.travis-ci.com/user/languages/erlang#Choosing-OTP-releases-to-test-against). Rely on installation path chosen by [`travis-erlang-builder`](https://github.com/travis-ci/travis-erlang-builder/blob/e6d016b1a91ca7ecac5a5a46395bde917ea13d36/bin/compile#L18).
|
||||
# - . ~/otp/18.2.1/activate && erl -version
|
||||
#- curl -f -L -o ./rebar3 https://s3.amazonaws.com/rebar3/rebar3 && chmod +x ./rebar3 && ./rebar3 version && export PATH="${TRAVIS_BUILD_DIR}:$PATH"
|
||||
# install valgrind for C++ memory test
|
||||
- sudo apt-get install valgrind
|
||||
# install Qt 5.10
|
||||
- sudo add-apt-repository --yes ppa:beineri/opt-qt-5.10.1-trusty
|
||||
- sudo apt-get update -qq
|
||||
|
||||
@@ -2,12 +2,27 @@ kind: pipeline
|
||||
name: default
|
||||
|
||||
steps:
|
||||
# test Dart 2.x petstore client
|
||||
- name: dart2x-test
|
||||
image: google/dart
|
||||
commands:
|
||||
- (cd samples/client/petstore/dart-jaguar/openapi && pub get && pub run build_runner build --delete-conflicting-outputs)
|
||||
- (cd samples/client/petstore/dart-jaguar/flutter_petstore/openapi && pub get && pub run build_runner build --delete-conflicting-outputs)
|
||||
- (cd samples/client/petstore/dart2/openapi && pub get && pub run test)
|
||||
# test Java 11 HTTP client
|
||||
- name: java11-test
|
||||
image: hirokimatsumoto/alpine-openjdk-11
|
||||
image: openjdk:11.0
|
||||
commands:
|
||||
- ./mvnw clean install
|
||||
- ./mvnw --quiet verify -Psamples.droneio
|
||||
# test all generators with fake petstore spec (2.0, 3.0)
|
||||
- /bin/bash bin/utils/test-fake-petstore-for-all.sh
|
||||
# generate test scripts
|
||||
- /bin/bash bin/tests/run-all-test
|
||||
# generate all petstore samples (client, servers, doc)
|
||||
- /bin/bash bin/run-all-petstore
|
||||
# generate all petstore samples (openapi3)
|
||||
- /bin/bash bin/openapi3/run-all-petstore
|
||||
# test ocaml petstore client
|
||||
- name: ocaml-test
|
||||
image: ocaml/opam2:4.07
|
||||
|
||||
@@ -14,14 +14,6 @@ if [ "$NODE_INDEX" = "1" ]; then
|
||||
mvn --quiet verify -Psamples.circleci
|
||||
mvn --quiet javadoc:javadoc -Psamples.circleci
|
||||
|
||||
# generate all petstore samples (client, servers, doc)
|
||||
./bin/run-all-petstore
|
||||
# generate all petstore samples (openapi3)
|
||||
./bin/openapi3/run-all-petstore
|
||||
# generate test scripts
|
||||
./bin/tests/run-all-test
|
||||
# test all generators with fake petstore spec (2.0, 3.0)
|
||||
./bin/utils/test-fake-petstore-for-all.sh
|
||||
elif [ "$NODE_INDEX" = "2" ]; then
|
||||
# run ensure-up-to-date sample script on SNAPSHOT version only
|
||||
project_version=`mvn org.apache.maven.plugins:maven-help-plugin:3.1.0:evaluate -Dexpression=project.version -q -DforceStdout`
|
||||
@@ -29,12 +21,6 @@ elif [ "$NODE_INDEX" = "2" ]; then
|
||||
echo "Running node $NODE_INDEX to test ensure-up-to-date"
|
||||
java -version
|
||||
|
||||
# install elm-format for formatting elm code
|
||||
npm install -g elm-format
|
||||
|
||||
# symlink elm-format
|
||||
sudo ln -s /opt/circleci/.nvm/versions/node/v12.1.0/bin/elm-format /usr/local/bin/elm-format
|
||||
|
||||
./bin/utils/ensure-up-to-date
|
||||
fi
|
||||
#elif [ "$NODE_INDEX" = "3" ]; then
|
||||
|
||||
@@ -53,6 +53,7 @@ public class ArrayOfArrayOfNumberOnlyTest {
|
||||
List<BigDecimal> arrayArrayNumber = new ArrayList<BigDecimal>();
|
||||
arrayArrayNumber.add(b1);
|
||||
arrayArrayNumber.add(b2);
|
||||
model.setArrayArrayNumber(new ArrayList<List<BigDecimal>>());
|
||||
model.getArrayArrayNumber().add(arrayArrayNumber);
|
||||
|
||||
// create another instance for comparison
|
||||
@@ -62,6 +63,7 @@ public class ArrayOfArrayOfNumberOnlyTest {
|
||||
List<BigDecimal> arrayArrayNumber2 = new ArrayList<BigDecimal>();
|
||||
arrayArrayNumber2.add(b1);
|
||||
arrayArrayNumber2.add(b2);
|
||||
model2.setArrayArrayNumber(new ArrayList<List<BigDecimal>>());
|
||||
model2.getArrayArrayNumber().add(arrayArrayNumber2);
|
||||
|
||||
Assert.assertTrue(model2.equals(model));
|
||||
|
||||
@@ -0,0 +1,73 @@
|
||||
<project>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>org.openapitools</groupId>
|
||||
<artifactId>TypeScriptFetchBuildPrefixParameterInterfacesPestoreClientTests</artifactId>
|
||||
<packaging>pom</packaging>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
<name>TS Fetch Petstore Client (with namespacing for parameter interfaces)</name>
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<artifactId>maven-dependency-plugin</artifactId>
|
||||
<executions>
|
||||
<execution>
|
||||
<phase>package</phase>
|
||||
<goals>
|
||||
<goal>copy-dependencies</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<outputDirectory>${project.build.directory}</outputDirectory>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.codehaus.mojo</groupId>
|
||||
<artifactId>exec-maven-plugin</artifactId>
|
||||
<version>1.2.1</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>npm-install</id>
|
||||
<phase>integration-test</phase>
|
||||
<goals>
|
||||
<goal>exec</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<executable>npm</executable>
|
||||
<arguments>
|
||||
<argument>install</argument>
|
||||
</arguments>
|
||||
</configuration>
|
||||
</execution>
|
||||
<execution>
|
||||
<id>npm-build</id>
|
||||
<phase>integration-test</phase>
|
||||
<goals>
|
||||
<goal>exec</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<executable>npm</executable>
|
||||
<arguments>
|
||||
<argument>run</argument>
|
||||
<argument>build</argument>
|
||||
</arguments>
|
||||
</configuration>
|
||||
</execution>
|
||||
<execution>
|
||||
<id>npm-test</id>
|
||||
<phase>integration-test</phase>
|
||||
<goals>
|
||||
<goal>exec</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<executable>npm</executable>
|
||||
<arguments>
|
||||
<argument>test</argument>
|
||||
</arguments>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</project>
|
||||
41
README.md
41
README.md
@@ -2,12 +2,18 @@
|
||||
|
||||
<div align="center">
|
||||
|
||||
[Master](https://github.com/OpenAPITools/openapi-generator/tree/master) (`4.1.0`): [](https://travis-ci.org/OpenAPITools/openapi-generator)
|
||||
[Master](https://github.com/OpenAPITools/openapi-generator/tree/master) (`4.1.1`): [](https://travis-ci.org/OpenAPITools/openapi-generator)
|
||||
[](https://circleci.com/gh/OpenAPITools/openapi-generator)
|
||||
[](https://app.shippable.com/github/OpenAPITools/openapi-generator)
|
||||
[](https://ci.appveyor.com/project/WilliamCheng/openapi-generator-wh2wu)
|
||||
[](https://cloud.drone.io/OpenAPITools/openapi-generator)
|
||||
|
||||
[`4.2.x`](https://github.com/OpenAPITools/openapi-generator/tree/4.2.x) branch: [](https://travis-ci.org/OpenAPITools/openapi-generator)
|
||||
[](https://circleci.com/gh/OpenAPITools/openapi-generator)
|
||||
[](https://app.shippable.com/github/OpenAPITools/openapi-generator)
|
||||
[](https://ci.appveyor.com/project/WilliamCheng/openapi-generator-wh2wu)
|
||||
[](https://cloud.drone.io/OpenAPITools/openapi-generator)
|
||||
|
||||
[`5.0.x`](https://github.com/OpenAPITools/openapi-generator/tree/5.0.x) branch: [](https://travis-ci.org/OpenAPITools/openapi-generator)
|
||||
[](https://circleci.com/gh/OpenAPITools/openapi-generator)
|
||||
[](https://app.shippable.com/github/OpenAPITools/openapi-generator)
|
||||
@@ -59,8 +65,8 @@ OpenAPI Generator allows generation of API client libraries (SDK generation), se
|
||||
|
||||
| | Languages/Frameworks |
|
||||
|-|-|
|
||||
**API clients** | **ActionScript**, **Ada**, **Apex**, **Bash**, **C**, **C#** (.net 2.0, 3.5 or later), **C++** (cpp-restsdk, Qt5, Tizen), **Clojure**, **Dart (1.x, 2.x)**, **Elixir**, **Elm**, **Eiffel**, **Erlang**, **Go**, **Groovy**, **Haskell** (http-client, Servant), **Java** (Jersey1.x, Jersey2.x, OkHttp, Retrofit1.x, Retrofit2.x, Feign, RestTemplate, RESTEasy, Vertx, Google API Client Library for Java, Rest-assured, Spring 5 Web Client), **Kotlin**, **Lua**, **Node.js/JavaScript** (ES5, ES6, AngularJS with Google Closure Compiler annotations, Flow types), **Objective-C**, **OCaml**, **Perl**, **PHP**, **PowerShell**, **Python**, **R**, **Ruby**, **Rust** (rust, rust-server), **Scala** (akka, http4s, scalaz, swagger-async-httpclient), **Swift** (2.x, 3.x, 4.x), **Typescript** (AngularJS, Angular (2.x - 7.x), Aurelia, Axios, Fetch, Inversify, jQuery, Node, Rxjs)
|
||||
**Server stubs** | **Ada**, **C#** (ASP.NET Core, NancyFx), **C++** (Pistache, Restbed, Qt5 QHTTPEngine), **Erlang**, **F#** (Giraffe), **Go** (net/http, Gin), **Haskell** (Servant), **Java** (MSF4J, Spring, Undertow, JAX-RS: CDI, CXF, Inflector, RestEasy, Play Framework, [PKMST](https://github.com/ProKarma-Inc/pkmst-getting-started-examples)), **Kotlin** (Spring Boot, Ktor), **PHP** (Laravel, Lumen, Slim, Silex, [Symfony](https://symfony.com/), [Zend Expressive](https://github.com/zendframework/zend-expressive)), **Python** (Flask), **NodeJS**, **Ruby** (Sinatra, Rails5), **Rust** (rust-server), **Scala** ([Finch](https://github.com/finagle/finch), [Lagom](https://github.com/lagom/lagom), [Play](https://www.playframework.com/), Scalatra)
|
||||
**API clients** | **ActionScript**, **Ada**, **Apex**, **Bash**, **C**, **C#** (.net 2.0, 3.5 or later), **C++** (cpp-restsdk, Qt5, Tizen), **Clojure**, **Dart (1.x, 2.x)**, **Elixir**, **Elm**, **Eiffel**, **Erlang**, **Go**, **Groovy**, **Haskell** (http-client, Servant), **Java** (Jersey1.x, Jersey2.x, OkHttp, Retrofit1.x, Retrofit2.x, Feign, RestTemplate, RESTEasy, Vertx, Google API Client Library for Java, Rest-assured, Spring 5 Web Client), **Kotlin**, **Lua**, **Node.js/JavaScript** (ES5, ES6, AngularJS with Google Closure Compiler annotations, Flow types), **Objective-C**, **OCaml**, **Perl**, **PHP**, **PowerShell**, **Python**, **R**, **Ruby**, **Rust** (rust, rust-server), **Scala** (akka, http4s, scalaz, swagger-async-httpclient), **Swift** (2.x, 3.x, 4.x), **Typescript** (AngularJS, Angular (2.x - 8.x), Aurelia, Axios, Fetch, Inversify, jQuery, Node, Rxjs)
|
||||
**Server stubs** | **Ada**, **C#** (ASP.NET Core, NancyFx), **C++** (Pistache, Restbed, Qt5 QHTTPEngine), **Erlang**, **F#** (Giraffe), **Go** (net/http, Gin), **Haskell** (Servant), **Java** (MSF4J, Spring, Undertow, JAX-RS: CDI, CXF, Inflector, Jersey, RestEasy, Play Framework, [PKMST](https://github.com/ProKarma-Inc/pkmst-getting-started-examples)), **Kotlin** (Spring Boot, Ktor), **PHP** (Laravel, Lumen, Slim, Silex, [Symfony](https://symfony.com/), [Zend Expressive](https://github.com/zendframework/zend-expressive)), **Python** (Flask), **NodeJS**, **Ruby** (Sinatra, Rails5), **Rust** (rust-server), **Scala** ([Finch](https://github.com/finagle/finch), [Lagom](https://github.com/lagom/lagom), [Play](https://www.playframework.com/), Scalatra)
|
||||
**API documentation generators** | **HTML**, **Confluence Wiki**
|
||||
**Configuration files** | [**Apache2**](https://httpd.apache.org/)
|
||||
**Others** | **GraphQL**, **JMeter**, **MySQL Schema**
|
||||
@@ -102,8 +108,8 @@ OpenAPI Generator Version | Release Date | Notes
|
||||
---------------------------- | ------------ | -----
|
||||
5.0.0 (upcoming major release) [SNAPSHOT](https://oss.sonatype.org/content/repositories/snapshots/org/openapitools/openapi-generator-cli/5.0.0-SNAPSHOT/)| 13.05.2020 | Major release with breaking changes (no fallback)
|
||||
4.2.0 (upcoming minor release) [SNAPSHOT](https://oss.sonatype.org/content/repositories/snapshots/org/openapitools/openapi-generator-cli/4.2.0-SNAPSHOT/)| 09.10.2019 | Minor release (breaking changes with fallbacks)
|
||||
4.1.1 (upcoming minor release) [SNAPSHOT](https://oss.sonatype.org/content/repositories/snapshots/org/openapitools/openapi-generator-cli/4.1.1-SNAPSHOT/)| 23.08.2019 | Patch release (bug fixes, enhancements)
|
||||
[4.1.0](https://github.com/OpenAPITools/openapi-generator/releases/tag/v4.1.0) (latest stable release) | 09.08.2019 | Minor release (breaking changes with fallbacks)
|
||||
4.1.2 (upcoming minor release) [SNAPSHOT](https://oss.sonatype.org/content/repositories/snapshots/org/openapitools/openapi-generator-cli/4.1.2-SNAPSHOT/)| 13.09.2019 | Patch release (bug fixes, enhancements)
|
||||
[4.1.1](https://github.com/OpenAPITools/openapi-generator/releases/tag/v4.1.1) (latest stable release) | 26.08.2019 | Minor release (breaking changes with fallbacks)
|
||||
|
||||
OpenAPI Spec compatibility: 1.0, 1.1, 1.2, 2.0, 3.0
|
||||
|
||||
@@ -159,16 +165,16 @@ See the different versions of the [openapi-generator-cli](https://mvnrepository.
|
||||
<!-- RELEASE_VERSION -->
|
||||
If you're looking for the latest stable version, you can grab it directly from Maven.org (Java 8 runtime at a minimum):
|
||||
|
||||
JAR location: `http://central.maven.org/maven2/org/openapitools/openapi-generator-cli/4.1.0/openapi-generator-cli-4.1.0.jar`
|
||||
JAR location: `http://central.maven.org/maven2/org/openapitools/openapi-generator-cli/4.1.1/openapi-generator-cli-4.1.1.jar`
|
||||
|
||||
For **Mac/Linux** users:
|
||||
```sh
|
||||
wget http://central.maven.org/maven2/org/openapitools/openapi-generator-cli/4.1.0/openapi-generator-cli-4.1.0.jar -O openapi-generator-cli.jar
|
||||
wget http://central.maven.org/maven2/org/openapitools/openapi-generator-cli/4.1.1/openapi-generator-cli-4.1.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.1.0/openapi-generator-cli-4.1.0.jar
|
||||
Invoke-WebRequest -OutFile openapi-generator-cli.jar http://central.maven.org/maven2/org/openapitools/openapi-generator-cli/4.1.1/openapi-generator-cli-4.1.1.jar
|
||||
```
|
||||
|
||||
After downloading the JAR, run `java -jar openapi-generator-cli.jar help` to show the usage.
|
||||
@@ -383,10 +389,10 @@ openapi-generator version
|
||||
```
|
||||
|
||||
<!-- RELEASE_VERSION -->
|
||||
Or install a particular OpenAPI Generator version (e.g. v4.1.0):
|
||||
Or install a particular OpenAPI Generator version (e.g. v4.1.1):
|
||||
|
||||
```sh
|
||||
npm install @openapitools/openapi-generator-cli@cli-4.1.0 -g
|
||||
npm install @openapitools/openapi-generator-cli@cli-4.1.1 -g
|
||||
```
|
||||
|
||||
Or install it as dev-dependency:
|
||||
@@ -410,7 +416,7 @@ java -jar modules/openapi-generator-cli/target/openapi-generator-cli.jar generat
|
||||
(if you're on Windows, replace the last command with `java -jar modules\openapi-generator-cli\target\openapi-generator-cli.jar generate -i https://raw.githubusercontent.com/openapitools/openapi-generator/master/modules/openapi-generator/src/test/resources/2_0/petstore.yaml -g php -o c:\temp\php_api_client`)
|
||||
|
||||
<!-- RELEASE_VERSION -->
|
||||
You can also download the JAR (latest release) directly from [maven.org](http://central.maven.org/maven2/org/openapitools/openapi-generator-cli/4.1.0/openapi-generator-cli-4.1.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.1.1/openapi-generator-cli-4.1.1.jar)
|
||||
<!-- /RELEASE_VERSION -->
|
||||
|
||||
To get a list of **general** options available, please run `java -jar modules/openapi-generator-cli/target/openapi-generator-cli.jar help generate`
|
||||
@@ -449,7 +455,6 @@ NAME
|
||||
SYNOPSIS
|
||||
openapi-generator-cli generate
|
||||
[(-a <authorization> | --auth <authorization>)]
|
||||
[--additional-properties <additional properties>...]
|
||||
[--api-package <api package>] [--artifact-id <artifact id>]
|
||||
[--artifact-version <artifact version>]
|
||||
[(-c <configuration file> | --config <configuration file>)]
|
||||
@@ -471,11 +476,12 @@ SYNOPSIS
|
||||
[--model-name-suffix <model name suffix>]
|
||||
[--model-package <model package>]
|
||||
[(-o <output directory> | --output <output directory>)]
|
||||
[(-p <additional properties> | --additional-properties <additional properties>)...]
|
||||
[--package-name <package name>] [--release-note <release note>]
|
||||
[--remove-operation-id-prefix]
|
||||
[--reserved-words-mappings <reserved word mappings>...]
|
||||
[(-s | --skip-overwrite)] [--skip-validate-spec]
|
||||
[--strict-spec <true/false strict behavior>]
|
||||
[(-s | --skip-overwrite)] [--server-variables <server variables>...]
|
||||
[--skip-validate-spec] [--strict-spec <true/false strict behavior>]
|
||||
[(-t <template directory> | --template-dir <template directory>)]
|
||||
[--type-mappings <type mappings>...] [(-v | --verbose)]
|
||||
|
||||
@@ -563,6 +569,7 @@ Here are some companies/projects (alphabetical order) using OpenAPI Generator in
|
||||
- [Klarna](https://www.klarna.com/)
|
||||
- [Metaswitch](https://www.metaswitch.com/)
|
||||
- [Myworkout](https://myworkout.com)
|
||||
- [Paxos](https://www.paxos.com)
|
||||
- [Prometheus/Alertmanager](https://github.com/prometheus/alertmanager)
|
||||
- [Raiffeisen Schweiz Genossenschaft](https://www.raiffeisen.ch)
|
||||
- [RepreZen API Studio](https://www.reprezen.com/swagger-openapi-code-generation-api-first-microservices-enterprise-development)
|
||||
@@ -620,6 +627,9 @@ Here are some companies/projects (alphabetical order) using OpenAPI Generator in
|
||||
- 2019-07-08 - [OpenAPI Generator にコントリビュートしたら社名が載った話。(CAM) - CAM TECH BLOG](https://tech.cam-inc.co.jp/entry/2019/07/08/140000) by [CAM, Inc.](https://www.cam-inc.co.jp/)
|
||||
- 2019-07-14 - [OpenAPI GeneratorでPythonのクライアントライブラリを作成した](https://qiita.com/yuji38kwmt/items/dfb929316a1335a161c0) by [yuji38kwmt](https://qiita.com/yuji38kwmt)
|
||||
- 2019-07-19 - [Developer Experience (DX) for Open-Source Projects: How to Engage Developers and Build a Growing Developer Community](https://speakerdeck.com/wing328/developer-experience-dx-for-open-source-projects-english-japanese) by [William Cheng](https://twitter.com/wing328), [中野暁人](https://github.com/ackintosh) at [Open Source Summit Japan 2019](https://events.linuxfoundation.org/events/open-source-summit-japan-2019/)
|
||||
- 2019-08-14 - [Our OpenAPI journey with Standardizing SDKs](https://bitmovin.com/our-openapi-journey-with-standardizing-sdks/) by [Sebastian Burgstaller](https://bitmovin.com/author/sburgstaller/) at [Bitmovin](https://www.bitmovin.com)
|
||||
- 2019-08-15 - [APIのコードを自動生成させたいだけならgRPCでなくてもよくない?](https://www.m3tech.blog/entry/2019/08/15/110000) by [M3, Inc.](https://corporate.m3.com/)
|
||||
- 2019-08-24 - [SwaggerドキュメントからOpenAPI Generatorを使ってモックサーバー作成](https://qiita.com/masayoshi0222/items/4845e4c715d04587c104) by [坂本正義](https://qiita.com/masayoshi0222)
|
||||
|
||||
## [6 - About Us](#table-of-contents)
|
||||
|
||||
@@ -749,6 +759,7 @@ Here is a list of template creators:
|
||||
* Configuration
|
||||
* Apache2: @stkrwork
|
||||
* Schema
|
||||
* Avro: @sgadouar
|
||||
* GraphQL: @wing328 [:heart:](https://www.patreon.com/wing328)
|
||||
* MySQL: @ybelenko
|
||||
|
||||
@@ -791,7 +802,7 @@ If you want to join the committee, please kindly apply by sending an email to te
|
||||
| Apex | |
|
||||
| Bash | @frol (2017/07) @bkryza (2017/08) @kenjones-cisco (2017/09) |
|
||||
| C | @zhemant (2018/11) |
|
||||
| C++ | @ravinikam (2017/07) @stkrwork (2017/07) @etherealjoy (2018/02) @martindelille (2018/03) |
|
||||
| C++ | @ravinikam (2017/07) @stkrwork (2017/07) @etherealjoy (2018/02) @martindelille (2018/03) @muttleyxd (2019/08) |
|
||||
| C# | @mandrean (2017/08), @jimschubert (2017/09) [:heart:](https://www.patreon.com/jimschubert) |
|
||||
| Clojure | |
|
||||
| Dart | @ircecho (2017/07) @swipesight (2018/09) @jaumard (2018/09) |
|
||||
|
||||
@@ -22,7 +22,7 @@ executable="./modules/openapi-generator-cli/target/openapi-generator-cli.jar"
|
||||
|
||||
if [ ! -f "$executable" ]
|
||||
then
|
||||
mvn -B clean package
|
||||
./mvnw -B clean package
|
||||
fi
|
||||
|
||||
export JAVA_OPTS="${JAVA_OPTS} -Xmx1024M -DloggerPath=conf/log4j.properties"
|
||||
@@ -30,7 +30,7 @@ ags="meta -n myClientCodegen -t DOCUMENTATION -p com.my.company.codegen -o sampl
|
||||
|
||||
java $JAVA_OPTS -jar $executable $ags
|
||||
|
||||
mvn clean package -f samples/meta-codegen/pom.xml
|
||||
./mvnw clean package -f samples/meta-codegen/pom.xml
|
||||
|
||||
ags2="generate -g myClientCodegen -i modules/openapi-generator/src/test/resources/2_0/petstore.json -o samples/meta-codegen/usage $@"
|
||||
|
||||
|
||||
32
bin/openapi3/avro-petstore.sh
Executable file
32
bin/openapi3/avro-petstore.sh
Executable file
@@ -0,0 +1,32 @@
|
||||
#!/bin/sh
|
||||
|
||||
SCRIPT="$0"
|
||||
echo "# START SCRIPT: $SCRIPT"
|
||||
|
||||
while [ -h "$SCRIPT" ] ; do
|
||||
ls=`ls -ld "$SCRIPT"`
|
||||
link=`expr "$ls" : '.*-> \(.*\)$'`
|
||||
if expr "$link" : '/.*' > /dev/null; then
|
||||
SCRIPT="$link"
|
||||
else
|
||||
SCRIPT=`dirname "$SCRIPT"`/"$link"
|
||||
fi
|
||||
done
|
||||
|
||||
if [ ! -d "${APP_DIR}" ]; then
|
||||
APP_DIR=`dirname "$SCRIPT"`/..
|
||||
APP_DIR=`cd "${APP_DIR}"; pwd`
|
||||
fi
|
||||
|
||||
executable="./modules/openapi-generator-cli/target/openapi-generator-cli.jar"
|
||||
|
||||
if [ ! -f "$executable" ]
|
||||
then
|
||||
mvn clean package
|
||||
fi
|
||||
|
||||
# if you've executed sbt assembly previously it will use that instead.
|
||||
export JAVA_OPTS="${JAVA_OPTS} -Xmx1024M -DloggerPath=conf/log4j.properties"
|
||||
ags="generate -t modules/openapi-generator/src/main/resources/avro-schema -i modules/openapi-generator/src/test/resources/3_0/petstore.yaml -g avro-schema -o samples/openapi3/schema/petstore/avro-schema $@"
|
||||
|
||||
java $JAVA_OPTS -jar $executable $ags
|
||||
@@ -4,3 +4,4 @@
|
||||
./bin/openapi3/typescript-fetch-petstore-with-npm-version.sh
|
||||
./bin/openapi3/typescript-fetch-petstore-interfaces.sh
|
||||
./bin/openapi3/typescript-fetch-petstore.sh
|
||||
./bin/openapi3/typescript-fetch-petstore-prefix-parameter-interfaces.sh
|
||||
|
||||
32
bin/openapi3/typescript-fetch-petstore-prefix-parameter-interfaces.sh
Executable file
32
bin/openapi3/typescript-fetch-petstore-prefix-parameter-interfaces.sh
Executable file
@@ -0,0 +1,32 @@
|
||||
#!/bin/sh
|
||||
|
||||
SCRIPT="$0"
|
||||
echo "# START SCRIPT: $SCRIPT"
|
||||
|
||||
while [ -h "$SCRIPT" ] ; do
|
||||
ls=`ls -ld "$SCRIPT"`
|
||||
link=`expr "$ls" : '.*-> \(.*\)$'`
|
||||
if expr "$link" : '/.*' > /dev/null; then
|
||||
SCRIPT="$link"
|
||||
else
|
||||
SCRIPT=`dirname "$SCRIPT"`/"$link"
|
||||
fi
|
||||
done
|
||||
|
||||
if [ ! -d "${APP_DIR}" ]; then
|
||||
APP_DIR=`dirname "$SCRIPT"`/..
|
||||
APP_DIR=`cd "${APP_DIR}"; pwd`
|
||||
fi
|
||||
|
||||
executable="./modules/openapi-generator-cli/target/openapi-generator-cli.jar"
|
||||
|
||||
if [ ! -f "$executable" ]
|
||||
then
|
||||
mvn clean package
|
||||
fi
|
||||
|
||||
# if you've executed sbt assembly previously it will use that instead.
|
||||
export JAVA_OPTS="${JAVA_OPTS} -Xmx1024M -DloggerPath=conf/log4j.properties"
|
||||
ags="generate -i modules/openapi-generator/src/test/resources/3_0/petstore.yaml -g typescript-fetch -o samples/client/petstore/typescript-fetch/builds/prefix-parameter-interfaces --additional-properties prefixParameterInterfaces=true $@"
|
||||
|
||||
java $JAVA_OPTS -jar $executable $ags
|
||||
@@ -2,5 +2,6 @@
|
||||
"gemName": "petstore",
|
||||
"moduleName": "Petstore",
|
||||
"library": "faraday",
|
||||
"gemVersion": "1.0.0"
|
||||
"gemVersion": "1.0.0",
|
||||
"strictSpecBehavior": false
|
||||
}
|
||||
|
||||
@@ -2,5 +2,6 @@
|
||||
"gemName": "petstore",
|
||||
"library": "typhoeus",
|
||||
"moduleName": "Petstore",
|
||||
"gemVersion": "1.0.0"
|
||||
"gemVersion": "1.0.0",
|
||||
"strictSpecBehavior": false
|
||||
}
|
||||
|
||||
@@ -38,4 +38,8 @@ for spec_path in modules/openapi-generator/src/test/resources/*/rust-server/* ;
|
||||
$@"
|
||||
|
||||
java $JAVA_OPTS -jar $executable $args
|
||||
|
||||
if [ $? -ne 0 ]; then
|
||||
exit $?
|
||||
fi
|
||||
done
|
||||
|
||||
@@ -13,3 +13,4 @@
|
||||
./bin/typescript-angular-v7-petstore-not-provided-in-root-with-npm.sh
|
||||
./bin/typescript-angular-v7-petstore-provided-in-root.sh
|
||||
./bin/typescript-angular-v7-petstore-provided-in-root-with-npm.sh
|
||||
./bin/typescript-angular-v8-petstore-provided-in-root-with-npm.sh
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
{
|
||||
"npmName": "@openapitools/typescript-angular-petstore",
|
||||
"npmVersion": "1.0.0",
|
||||
"npmRepository" : "https://skimdb.npmjs.com/registry",
|
||||
"snapshot" : false,
|
||||
"ngVersion": "8.0.0"
|
||||
}
|
||||
32
bin/typescript-angular-v8-petstore-provided-in-root-with-npm.sh
Executable file
32
bin/typescript-angular-v8-petstore-provided-in-root-with-npm.sh
Executable file
@@ -0,0 +1,32 @@
|
||||
#!/bin/sh
|
||||
|
||||
SCRIPT="$0"
|
||||
echo "# START SCRIPT: $SCRIPT"
|
||||
|
||||
while [ -h "$SCRIPT" ] ; do
|
||||
ls=`ls -ld "$SCRIPT"`
|
||||
link=`expr "$ls" : '.*-> \(.*\)$'`
|
||||
if expr "$link" : '/.*' > /dev/null; then
|
||||
SCRIPT="$link"
|
||||
else
|
||||
SCRIPT=`dirname "$SCRIPT"`/"$link"
|
||||
fi
|
||||
done
|
||||
|
||||
if [ ! -d "${APP_DIR}" ]; then
|
||||
APP_DIR=`dirname "$SCRIPT"`/..
|
||||
APP_DIR=`cd "${APP_DIR}"; pwd`
|
||||
fi
|
||||
|
||||
executable="./modules/openapi-generator-cli/target/openapi-generator-cli.jar"
|
||||
|
||||
if [ ! -f "$executable" ]
|
||||
then
|
||||
mvn -B clean package
|
||||
fi
|
||||
|
||||
# if you've executed sbt assembly previously it will use that instead.
|
||||
export JAVA_OPTS="${JAVA_OPTS} -Xmx1024M -DloggerPath=conf/log4j.properties"
|
||||
ags="generate -i modules/openapi-generator/src/test/resources/2_0/petstore.yaml -g typescript-angular -c bin/typescript-angular-v8-petstore-provided-in-root-with-npm.json -o samples/client/petstore/typescript-angular-v8-provided-in-root/builds/with-npm --additional-properties ngVersion=8.0.0 $@"
|
||||
|
||||
java $JAVA_OPTS -jar $executable $ags
|
||||
@@ -5,3 +5,4 @@
|
||||
./bin/typescript-fetch-petstore-interfaces.sh
|
||||
./bin/typescript-fetch-petstore.sh
|
||||
./bin/typescript-fetch-petstore-multiple-parameters.sh
|
||||
./bin/typescript-fetch-petstore-prefix-parameter-interfaces.sh
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
{
|
||||
"npmName": "@openapitools/typescript-fetch-petstore",
|
||||
"npmVersion": "1.0.0",
|
||||
"npmRepository" : "https://skimdb.npmjs.com/registry",
|
||||
"snapshot" : false,
|
||||
"prefixParameterInterfaces": true
|
||||
}
|
||||
34
bin/typescript-fetch-petstore-prefix-parameter-interfaces.sh
Executable file
34
bin/typescript-fetch-petstore-prefix-parameter-interfaces.sh
Executable file
@@ -0,0 +1,34 @@
|
||||
#!/bin/sh
|
||||
|
||||
SCRIPT="$0"
|
||||
echo "# START SCRIPT: $SCRIPT"
|
||||
|
||||
while [ -h "$SCRIPT" ] ; do
|
||||
ls=`ls -ld "$SCRIPT"`
|
||||
link=`expr "$ls" : '.*-> \(.*\)$'`
|
||||
if expr "$link" : '/.*' > /dev/null; then
|
||||
SCRIPT="$link"
|
||||
else
|
||||
SCRIPT=`dirname "$SCRIPT"`/"$link"
|
||||
fi
|
||||
done
|
||||
|
||||
if [ ! -d "${APP_DIR}" ]; then
|
||||
APP_DIR=`dirname "$SCRIPT"`/..
|
||||
APP_DIR=`cd "${APP_DIR}"; pwd`
|
||||
fi
|
||||
|
||||
executable="./modules/openapi-generator-cli/target/openapi-generator-cli.jar"
|
||||
|
||||
if [ ! -f "$executable" ]
|
||||
then
|
||||
mvn -B clean package
|
||||
fi
|
||||
|
||||
# if you've executed sbt assembly previously it will use that instead.
|
||||
export JAVA_OPTS="${JAVA_OPTS} -Xmx1024M -DloggerPath=conf/log4j.properties"
|
||||
ags="generate -i modules/openapi-generator/src/test/resources/2_0/petstore.yaml -g typescript-fetch -c bin/typescript-fetch-petstore-prefix-parameter-interfaces.json -o samples/client/petstore/typescript-fetch/builds/prefix-parameter-interfaces $@"
|
||||
|
||||
java $JAVA_OPTS -jar $executable $ags
|
||||
|
||||
cp CI/samples.ci/client/petstore/typescript-fetch/builds/prefix-parameter-interfaces/pom.xml samples/client/petstore/typescript-fetch/builds/prefix-parameter-interfaces/pom.xml
|
||||
@@ -12,6 +12,7 @@ sleep 5
|
||||
# LIST OF SCRIPTS:
|
||||
declare -a scripts=(
|
||||
# SAMPLES
|
||||
"./bin/ruby-client-petstore.sh"
|
||||
"./bin/openapi3/ruby-client-petstore.sh"
|
||||
"./bin/openapi3/ruby-client-faraday-petstore.sh"
|
||||
"./bin/java-petstore-all.sh"
|
||||
@@ -57,11 +58,15 @@ declare -a scripts=(
|
||||
"./bin/groovy-petstore.sh"
|
||||
"./bin/apex-petstore.sh"
|
||||
"./bin/perl-petstore-all.sh"
|
||||
"./bin/dart-jaguar-petstore.sh"
|
||||
"./bin/dart-flutter-petstore.sh"
|
||||
"./bin/dart-petstore.sh"
|
||||
"./bin/dart2-petstore.sh"
|
||||
"./bin/java-play-framework-petstore-server-all.sh"
|
||||
#"./bin/elm-petstore-all.sh"
|
||||
"./bin/meta-codegen.sh"
|
||||
# OTHERS
|
||||
"./bin/utils/export_docs_generators.sh"
|
||||
"./bin/utils/export_generators_docusaurus_index.sh"
|
||||
"./bin/utils/copy-to-website.sh"
|
||||
"./bin/utils/export_generators_readme.sh")
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@ echo "# START SCRIPT: ${SCRIPT}"
|
||||
|
||||
executable="./modules/openapi-generator-cli/target/openapi-generator-cli.jar"
|
||||
|
||||
for GENERATOR in $(java -jar ${executable} list --short | sed -e 's/,/\'$'\n''/g')
|
||||
for GENERATOR in $(java -jar ${executable} list --short --include all | sed -e 's/,/\'$'\n''/g')
|
||||
do
|
||||
./bin/utils/export_generator.sh ${GENERATOR}
|
||||
done
|
||||
|
||||
@@ -1,20 +0,0 @@
|
||||
#!/bin/sh
|
||||
|
||||
SCRIPT="$0"
|
||||
echo "# START SCRIPT: $SCRIPT"
|
||||
|
||||
executable="./modules/openapi-generator-cli/target/openapi-generator-cli.jar"
|
||||
|
||||
\rm -rf docs/generators.md
|
||||
|
||||
cat > docs/generators.md << EOF
|
||||
---
|
||||
id: generators
|
||||
title: Generators List
|
||||
---
|
||||
|
||||
EOF
|
||||
|
||||
java -jar $executable list --docsite >> docs/generators.md
|
||||
|
||||
echo "Wrote $(pwd)/docs/generators.md"
|
||||
@@ -15,6 +15,6 @@ title: Generators List
|
||||
|
||||
EOF
|
||||
|
||||
java -jar $executable list | sed -e 's/\([A-Z]*\) generators:/* \1 generators:/g' -e 's/- \([a-z0-9\-]*\)/- [\1]\(generators\/\1.md\)/g' >> docs/generators.md
|
||||
java -jar $executable list --docsite --include all >> docs/generators.md
|
||||
|
||||
echo "Wrote $(pwd)/docs/generators.md"
|
||||
|
||||
@@ -42,7 +42,7 @@ artifactid=openapi-generator-cli
|
||||
ver=${OPENAPI_GENERATOR_VERSION:-$(latest.tag $ghrepo)}
|
||||
|
||||
jar=${artifactid}-${ver}.jar
|
||||
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
||||
DIR=${OPENAPI_GENERATOR_DOWLOAD_CACHE_DIR:-"$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"}
|
||||
|
||||
if [ ! -f ${DIR}/${jar} ]; then
|
||||
repo="central::default::https://repo1.maven.org/maven2/"
|
||||
|
||||
@@ -11,4 +11,4 @@ call .\bin\windows\typescript-angular-v7-provided-in-root.bat
|
||||
call .\bin\windows\typescript-angular-v7-provided-in-root-with-npm.bat
|
||||
call .\bin\windows\typescript-angular-v7-not-provided-in-root.bat
|
||||
call .\bin\windows\typescript-angular-v7-not-provided-in-root-with-npm.bat
|
||||
|
||||
call .\bin\windows\typescript-angular-v8-provided-in-root-with-npm.bat
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
set executable=.\modules\openapi-generator-cli\target\openapi-generator-cli.jar
|
||||
|
||||
If Not Exist %executable% (
|
||||
mvn clean package
|
||||
)
|
||||
|
||||
set ags=generate -i modules\openapi-generator\src\test\resources\2_0\petstore.yaml -g typescript-angular -c bin/typescript-angular-v8-petstore-provided-in-root-with-npm.json -o samples\client\petstore\typescript-angular-v8-provided-in-root\builds\with-npm --additional-properties ngVersion=8.0.0
|
||||
|
||||
java %JAVA_OPTS% -jar %executable% %ags%
|
||||
@@ -5,3 +5,4 @@ call bin\windows\typescript-fetch-petstore-target-es6.bat
|
||||
call bin\windows\typescript-fetch-petstore-with-npm-version.bat
|
||||
call bin\windows\typescript-fetch-petstore-interfaces.bat
|
||||
call bin\windows\typescript-fetch-petstore-multiple-parameters.bat
|
||||
call bin\windows\typescript-fetch-petstore-prefix-parameter-interfaces.bat
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
@ECHO OFF
|
||||
|
||||
set executable=.\modules\openapi-generator-cli\target\openapi-generator-cli.jar
|
||||
|
||||
If Not Exist %executable% (
|
||||
mvn clean package
|
||||
)
|
||||
|
||||
REM set JAVA_OPTS=%JAVA_OPTS% -Xmx1024M
|
||||
set ags=generate -i modules\openapi-generator\src\test\resources\2_0\petstore.yaml -g typescript-fetch -o samples\client\petstore\typescript-fetch\builds\prefix-parameter-interfaces --additional-properties prefixParameterInterfaces=true
|
||||
|
||||
java %JAVA_OPTS% -jar %executable% %ags%
|
||||
@@ -5,132 +5,133 @@ title: Generators List
|
||||
|
||||
The following generators are available:
|
||||
|
||||
* CLIENT generators:
|
||||
- [ada](generators/ada.md)
|
||||
- [android](generators/android.md)
|
||||
- [apex](generators/apex.md)
|
||||
- [bash](generators/bash.md)
|
||||
- [c](generators/c.md)
|
||||
- [clojure](generators/clojure.md)
|
||||
- [cpp-qt5-client](generators/cpp-qt5-client.md)
|
||||
- [cpp-restsdk](generators/cpp-restsdk.md)
|
||||
- [cpp-tizen](generators/cpp-tizen.md)
|
||||
- [csharp](generators/csharp.md)
|
||||
- [csharp-dotnet2](generators/csharp-dotnet2.md) (deprecated)
|
||||
- [csharp-netcore](generators/csharp-netcore.md)
|
||||
- [dart](generators/dart.md)
|
||||
- [dart-jaguar](generators/dart-jaguar.md)
|
||||
- [eiffel](generators/eiffel.md)
|
||||
- [elixir](generators/elixir.md)
|
||||
- [elm](generators/elm.md)
|
||||
- [erlang-client](generators/erlang-client.md)
|
||||
- [erlang-proper](generators/erlang-proper.md)
|
||||
- [flash](generators/flash.md)
|
||||
- [go](generators/go.md)
|
||||
- [go-experimental](generators/go-experimental.md)
|
||||
- [groovy](generators/groovy.md)
|
||||
- [haskell-http-client](generators/haskell-http-client.md)
|
||||
- [java](generators/java.md)
|
||||
- [javascript](generators/javascript.md)
|
||||
- [javascript-closure-angular](generators/javascript-closure-angular.md)
|
||||
- [javascript-flowtyped](generators/javascript-flowtyped.md)
|
||||
- [jaxrs-cxf-client](generators/jaxrs-cxf-client.md)
|
||||
- [jmeter](generators/jmeter.md)
|
||||
- [kotlin](generators/kotlin.md)
|
||||
- [lua](generators/lua.md)
|
||||
- [objc](generators/objc.md)
|
||||
- [ocaml](generators/ocaml.md)
|
||||
- [perl](generators/perl.md)
|
||||
- [php](generators/php.md)
|
||||
- [powershell](generators/powershell.md)
|
||||
- [python](generators/python.md)
|
||||
- [python-experimental](generators/python-experimental.md)
|
||||
- [r](generators/r.md)
|
||||
- [ruby](generators/ruby.md)
|
||||
- [rust](generators/rust.md)
|
||||
- [scala-akka](generators/scala-akka.md)
|
||||
- [scala-gatling](generators/scala-gatling.md)
|
||||
- [scala-httpclient-deprecated](generators/scala-httpclient-deprecated.md) (deprecated)
|
||||
- [scalaz](generators/scalaz.md)
|
||||
- [swift2-deprecated](generators/swift2-deprecated.md) (deprecated)
|
||||
- [swift3-deprecated](generators/swift3-deprecated.md) (deprecated)
|
||||
- [swift4](generators/swift4.md)
|
||||
- [typescript-angular](generators/typescript-angular.md)
|
||||
- [typescript-angularjs](generators/typescript-angularjs.md)
|
||||
- [typescript-aurelia](generators/typescript-aurelia.md)
|
||||
- [typescript-axios](generators/typescript-axios.md)
|
||||
- [typescript-fetch](generators/typescript-fetch.md)
|
||||
- [typescript-inversify](generators/typescript-inversify.md)
|
||||
- [typescript-jquery](generators/typescript-jquery.md)
|
||||
- [typescript-node](generators/typescript-node.md)
|
||||
- [typescript-rxjs](generators/typescript-rxjs.md)
|
||||
## CLIENT generators
|
||||
* [ada](generators/ada)
|
||||
* [android](generators/android)
|
||||
* [apex](generators/apex)
|
||||
* [bash](generators/bash)
|
||||
* [c](generators/c)
|
||||
* [clojure](generators/clojure)
|
||||
* [cpp-qt5-client](generators/cpp-qt5-client)
|
||||
* [cpp-restsdk](generators/cpp-restsdk)
|
||||
* [cpp-tizen](generators/cpp-tizen)
|
||||
* [csharp](generators/csharp)
|
||||
* [csharp-dotnet2 (deprecated)](generators/csharp-dotnet2)
|
||||
* [csharp-netcore](generators/csharp-netcore)
|
||||
* [dart](generators/dart)
|
||||
* [dart-jaguar](generators/dart-jaguar)
|
||||
* [eiffel](generators/eiffel)
|
||||
* [elixir](generators/elixir)
|
||||
* [elm](generators/elm)
|
||||
* [erlang-client](generators/erlang-client)
|
||||
* [erlang-proper](generators/erlang-proper)
|
||||
* [flash](generators/flash)
|
||||
* [go](generators/go)
|
||||
* [go-experimental (experimental)](generators/go-experimental)
|
||||
* [groovy](generators/groovy)
|
||||
* [haskell-http-client](generators/haskell-http-client)
|
||||
* [java](generators/java)
|
||||
* [javascript](generators/javascript)
|
||||
* [javascript-closure-angular](generators/javascript-closure-angular)
|
||||
* [javascript-flowtyped](generators/javascript-flowtyped)
|
||||
* [jaxrs-cxf-client](generators/jaxrs-cxf-client)
|
||||
* [jmeter](generators/jmeter)
|
||||
* [kotlin](generators/kotlin)
|
||||
* [lua](generators/lua)
|
||||
* [objc](generators/objc)
|
||||
* [ocaml](generators/ocaml)
|
||||
* [perl](generators/perl)
|
||||
* [php](generators/php)
|
||||
* [powershell](generators/powershell)
|
||||
* [python](generators/python)
|
||||
* [python-experimental (experimental)](generators/python-experimental)
|
||||
* [r](generators/r)
|
||||
* [ruby](generators/ruby)
|
||||
* [rust](generators/rust)
|
||||
* [scala-akka](generators/scala-akka)
|
||||
* [scala-gatling](generators/scala-gatling)
|
||||
* [scala-httpclient-deprecated (deprecated)](generators/scala-httpclient-deprecated)
|
||||
* [scalaz](generators/scalaz)
|
||||
* [swift2-deprecated (deprecated)](generators/swift2-deprecated)
|
||||
* [swift3-deprecated (deprecated)](generators/swift3-deprecated)
|
||||
* [swift4](generators/swift4)
|
||||
* [typescript-angular](generators/typescript-angular)
|
||||
* [typescript-angularjs](generators/typescript-angularjs)
|
||||
* [typescript-aurelia](generators/typescript-aurelia)
|
||||
* [typescript-axios](generators/typescript-axios)
|
||||
* [typescript-fetch](generators/typescript-fetch)
|
||||
* [typescript-inversify](generators/typescript-inversify)
|
||||
* [typescript-jquery](generators/typescript-jquery)
|
||||
* [typescript-node](generators/typescript-node)
|
||||
* [typescript-rxjs](generators/typescript-rxjs)
|
||||
|
||||
|
||||
* SERVER generators:
|
||||
- [ada-server](generators/ada-server.md)
|
||||
- [aspnetcore](generators/aspnetcore.md)
|
||||
- [cpp-pistache-server](generators/cpp-pistache-server.md)
|
||||
- [cpp-qt5-qhttpengine-server](generators/cpp-qt5-qhttpengine-server.md)
|
||||
- [cpp-restbed-server](generators/cpp-restbed-server.md)
|
||||
- [csharp-nancyfx](generators/csharp-nancyfx.md)
|
||||
- [erlang-server](generators/erlang-server.md)
|
||||
- [fsharp-giraffe-server](generators/fsharp-giraffe-server.md)
|
||||
- [go-gin-server](generators/go-gin-server.md)
|
||||
- [go-server](generators/go-server.md)
|
||||
- [graphql-nodejs-express-server](generators/graphql-nodejs-express-server.md)
|
||||
- [haskell](generators/haskell.md)
|
||||
- [java-inflector](generators/java-inflector.md)
|
||||
- [java-msf4j](generators/java-msf4j.md)
|
||||
- [java-pkmst](generators/java-pkmst.md)
|
||||
- [java-play-framework](generators/java-play-framework.md)
|
||||
- [java-undertow-server](generators/java-undertow-server.md)
|
||||
- [java-vertx](generators/java-vertx.md)
|
||||
- [jaxrs-cxf](generators/jaxrs-cxf.md)
|
||||
- [jaxrs-cxf-cdi](generators/jaxrs-cxf-cdi.md)
|
||||
- [jaxrs-cxf-extended](generators/jaxrs-cxf-extended.md)
|
||||
- [jaxrs-jersey](generators/jaxrs-jersey.md)
|
||||
- [jaxrs-resteasy](generators/jaxrs-resteasy.md)
|
||||
- [jaxrs-resteasy-eap](generators/jaxrs-resteasy-eap.md)
|
||||
- [jaxrs-spec](generators/jaxrs-spec.md)
|
||||
- [kotlin-server](generators/kotlin-server.md)
|
||||
- [kotlin-spring](generators/kotlin-spring.md)
|
||||
- [nodejs-express-server](generators/nodejs-express-server.md) (beta)
|
||||
- [nodejs-server-deprecated](generators/nodejs-server-deprecated.md) (deprecated)
|
||||
- [php-laravel](generators/php-laravel.md)
|
||||
- [php-lumen](generators/php-lumen.md)
|
||||
- [php-silex](generators/php-silex.md)
|
||||
- [php-slim](generators/php-slim.md)
|
||||
- [php-symfony](generators/php-symfony.md)
|
||||
- [php-ze-ph](generators/php-ze-ph.md)
|
||||
- [python-aiohttp](generators/python-aiohttp.md)
|
||||
- [python-blueplanet](generators/python-blueplanet.md)
|
||||
- [python-flask](generators/python-flask.md)
|
||||
- [ruby-on-rails](generators/ruby-on-rails.md)
|
||||
- [ruby-sinatra](generators/ruby-sinatra.md)
|
||||
- [rust-server](generators/rust-server.md)
|
||||
- [scala-finch](generators/scala-finch.md)
|
||||
- [scala-lagom-server](generators/scala-lagom-server.md)
|
||||
- [scala-play-server](generators/scala-play-server.md)
|
||||
- [scalatra](generators/scalatra.md)
|
||||
- [spring](generators/spring.md)
|
||||
## SERVER generators
|
||||
* [ada-server](generators/ada-server)
|
||||
* [aspnetcore](generators/aspnetcore)
|
||||
* [cpp-pistache-server](generators/cpp-pistache-server)
|
||||
* [cpp-qt5-qhttpengine-server](generators/cpp-qt5-qhttpengine-server)
|
||||
* [cpp-restbed-server](generators/cpp-restbed-server)
|
||||
* [csharp-nancyfx](generators/csharp-nancyfx)
|
||||
* [erlang-server](generators/erlang-server)
|
||||
* [fsharp-giraffe-server](generators/fsharp-giraffe-server)
|
||||
* [go-gin-server](generators/go-gin-server)
|
||||
* [go-server](generators/go-server)
|
||||
* [graphql-nodejs-express-server](generators/graphql-nodejs-express-server)
|
||||
* [haskell](generators/haskell)
|
||||
* [java-inflector](generators/java-inflector)
|
||||
* [java-msf4j](generators/java-msf4j)
|
||||
* [java-pkmst](generators/java-pkmst)
|
||||
* [java-play-framework](generators/java-play-framework)
|
||||
* [java-undertow-server](generators/java-undertow-server)
|
||||
* [java-vertx](generators/java-vertx)
|
||||
* [jaxrs-cxf](generators/jaxrs-cxf)
|
||||
* [jaxrs-cxf-cdi](generators/jaxrs-cxf-cdi)
|
||||
* [jaxrs-cxf-extended](generators/jaxrs-cxf-extended)
|
||||
* [jaxrs-jersey](generators/jaxrs-jersey)
|
||||
* [jaxrs-resteasy](generators/jaxrs-resteasy)
|
||||
* [jaxrs-resteasy-eap](generators/jaxrs-resteasy-eap)
|
||||
* [jaxrs-spec](generators/jaxrs-spec)
|
||||
* [kotlin-server](generators/kotlin-server)
|
||||
* [kotlin-spring](generators/kotlin-spring)
|
||||
* [nodejs-express-server (beta)](generators/nodejs-express-server)
|
||||
* [nodejs-server-deprecated (deprecated)](generators/nodejs-server-deprecated)
|
||||
* [php-laravel](generators/php-laravel)
|
||||
* [php-lumen](generators/php-lumen)
|
||||
* [php-silex](generators/php-silex)
|
||||
* [php-slim](generators/php-slim)
|
||||
* [php-symfony](generators/php-symfony)
|
||||
* [php-ze-ph](generators/php-ze-ph)
|
||||
* [python-aiohttp](generators/python-aiohttp)
|
||||
* [python-blueplanet](generators/python-blueplanet)
|
||||
* [python-flask](generators/python-flask)
|
||||
* [ruby-on-rails](generators/ruby-on-rails)
|
||||
* [ruby-sinatra](generators/ruby-sinatra)
|
||||
* [rust-server](generators/rust-server)
|
||||
* [scala-finch](generators/scala-finch)
|
||||
* [scala-lagom-server](generators/scala-lagom-server)
|
||||
* [scala-play-server](generators/scala-play-server)
|
||||
* [scalatra](generators/scalatra)
|
||||
* [spring](generators/spring)
|
||||
|
||||
|
||||
* DOCUMENTATION generators:
|
||||
- [cwiki](generators/cwiki.md)
|
||||
- [dynamic-html](generators/dynamic-html.md)
|
||||
- [html](generators/html.md)
|
||||
- [html2](generators/html2.md)
|
||||
- [openapi](generators/openapi.md)
|
||||
- [openapi-yaml](generators/openapi-yaml.md)
|
||||
## DOCUMENTATION generators
|
||||
* [cwiki](generators/cwiki)
|
||||
* [dynamic-html](generators/dynamic-html)
|
||||
* [html](generators/html)
|
||||
* [html2](generators/html2)
|
||||
* [openapi](generators/openapi)
|
||||
* [openapi-yaml](generators/openapi-yaml)
|
||||
|
||||
|
||||
* SCHEMA generators:
|
||||
- [mysql-schema](generators/mysql-schema.md)
|
||||
## SCHEMA generators
|
||||
* [avro-schema (beta)](generators/avro-schema)
|
||||
* [mysql-schema](generators/mysql-schema)
|
||||
|
||||
|
||||
* CONFIG generators:
|
||||
- [apache2](generators/apache2.md)
|
||||
- [graphql-schema](generators/graphql-schema.md)
|
||||
## CONFIG generators
|
||||
* [apache2](generators/apache2)
|
||||
* [graphql-schema](generators/graphql-schema)
|
||||
|
||||
|
||||
|
||||
|
||||
14
docs/generators/avro-schema.md
Normal file
14
docs/generators/avro-schema.md
Normal file
@@ -0,0 +1,14 @@
|
||||
|
||||
---
|
||||
id: generator-opts-schema-avro-schema
|
||||
title: Config Options for avro-schema
|
||||
sidebar_label: avro-schema
|
||||
---
|
||||
|
||||
| Option | Description | Values | Default |
|
||||
| ------ | ----------- | ------ | ------- |
|
||||
|sortParamsByRequiredFlag|Sort method arguments to place required parameters before optional parameters.| |true|
|
||||
|ensureUniqueParams|Whether to ensure parameter names are unique in an operation (rename parameters that are not).| |true|
|
||||
|allowUnicodeIdentifiers|boolean, toggles whether unicode identifiers are allowed in names or not, default is false| |false|
|
||||
|prependFormOrBodyParameters|Add form or body parameters to the beginning of the parameter list.| |false|
|
||||
|packageName|package for generated classes (where supported)| |null|
|
||||
@@ -12,7 +12,7 @@ sidebar_label: csharp-netcore
|
||||
|sourceFolder|source folder for generated code| |src|
|
||||
|packageGuid|The GUID that will be associated with the C# project| |null|
|
||||
|interfacePrefix|Prefix interfaces with a community standard or widely accepted prefix.| |I|
|
||||
|targetFramework|The target .NET framework version.|<dl><dt>**netstandard1.3**</dt><dd>.NET Standard 1.3 compatible</dd><dt>**netstandard1.4**</dt><dd>.NET Standard 1.4 compatible</dd><dt>**netstandard1.5**</dt><dd>.NET Standard 1.5 compatible</dd><dt>**netstandard1.6**</dt><dd>.NET Standard 1.6 compatible</dd><dt>**netstandard2.0**</dt><dd>.NET Standard 2.0 compatible</dd><dt>**netcoreapp2.0**</dt><dd>.NET Core 2.0 compatible</dd><dl>|v4.6.1|
|
||||
|targetFramework|The target .NET framework version.|<dl><dt>**netstandard1.3**</dt><dd>.NET Standard 1.3 compatible</dd><dt>**netstandard1.4**</dt><dd>.NET Standard 1.4 compatible</dd><dt>**netstandard1.5**</dt><dd>.NET Standard 1.5 compatible</dd><dt>**netstandard1.6**</dt><dd>.NET Standard 1.6 compatible</dd><dt>**netstandard2.0**</dt><dd>.NET Standard 2.0 compatible</dd><dt>**netcoreapp2.0**</dt><dd>.NET Core 2.0 compatible</dd><dl>|netstandard2.0|
|
||||
|modelPropertyNaming|Naming convention for the property: 'camelCase', 'PascalCase', 'snake_case' and 'original', which keeps the original name| |PascalCase|
|
||||
|hideGenerationTimestamp|Hides the generation timestamp when files are generated.| |true|
|
||||
|sortParamsByRequiredFlag|Sort method arguments to place required parameters before optional parameters.| |true|
|
||||
@@ -26,3 +26,4 @@ sidebar_label: csharp-netcore
|
||||
|allowUnicodeIdentifiers|boolean, toggles whether unicode identifiers are allowed in names or not, default is false| |false|
|
||||
|netCoreProjectFile|Use the new format (.NET Core) for .NET project files (.csproj).| |false|
|
||||
|validatable|Generates self-validatable models.| |true|
|
||||
|caseInsensitiveResponseHeaders|Make API response's headers case-insensitive| |false|
|
||||
|
||||
@@ -11,12 +11,12 @@ sidebar_label: dart-jaguar
|
||||
|ensureUniqueParams|Whether to ensure parameter names are unique in an operation (rename parameters that are not).| |true|
|
||||
|allowUnicodeIdentifiers|boolean, toggles whether unicode identifiers are allowed in names or not, default is false| |false|
|
||||
|prependFormOrBodyParameters|Add form or body parameters to the beginning of the parameter list.| |false|
|
||||
|browserClient|Is the client browser based| |null|
|
||||
|browserClient|Is the client browser based (for Dart 1.x only)| |null|
|
||||
|pubName|Name in generated pubspec| |null|
|
||||
|pubVersion|Version in generated pubspec| |null|
|
||||
|pubDescription|Description in generated pubspec| |null|
|
||||
|useEnumExtension|Allow the 'x-enum-values' extension for enums| |null|
|
||||
|sourceFolder|source folder for generated code| |null|
|
||||
|supportDart2|support dart2| |true|
|
||||
|sourceFolder|Source folder for generated code| |null|
|
||||
|supportDart2|Support Dart 2.x| |true|
|
||||
|nullableFields|Is the null fields should be in the JSON payload| |null|
|
||||
|serialization|Choose serialization format JSON or PROTO is supported| |null|
|
||||
|
||||
@@ -11,10 +11,10 @@ sidebar_label: dart
|
||||
|ensureUniqueParams|Whether to ensure parameter names are unique in an operation (rename parameters that are not).| |true|
|
||||
|allowUnicodeIdentifiers|boolean, toggles whether unicode identifiers are allowed in names or not, default is false| |false|
|
||||
|prependFormOrBodyParameters|Add form or body parameters to the beginning of the parameter list.| |false|
|
||||
|browserClient|Is the client browser based| |null|
|
||||
|browserClient|Is the client browser based (for Dart 1.x only)| |null|
|
||||
|pubName|Name in generated pubspec| |null|
|
||||
|pubVersion|Version in generated pubspec| |null|
|
||||
|pubDescription|Description in generated pubspec| |null|
|
||||
|useEnumExtension|Allow the 'x-enum-values' extension for enums| |null|
|
||||
|sourceFolder|source folder for generated code| |null|
|
||||
|supportDart2|support dart2| |true|
|
||||
|sourceFolder|Source folder for generated code| |null|
|
||||
|supportDart2|Support Dart 2.x| |true|
|
||||
|
||||
@@ -13,4 +13,5 @@ sidebar_label: go-experimental
|
||||
|isGoSubmodule|whether the generated Go module is a submodule| |false|
|
||||
|withGoCodegenComment|whether to include Go codegen comment to disable Go Lint and collapse by default GitHub in PRs and diffs| |false|
|
||||
|withXml|whether to include support for application/xml content type and include XML annotations in the model (works with libraries that provide support for JSON and XML)| |false|
|
||||
|enumClassPrefix|Prefix enum with class name| |false|
|
||||
|prependFormOrBodyParameters|Add form or body parameters to the beginning of the parameter list.| |false|
|
||||
|
||||
@@ -13,4 +13,5 @@ sidebar_label: go
|
||||
|isGoSubmodule|whether the generated Go module is a submodule| |false|
|
||||
|withGoCodegenComment|whether to include Go codegen comment to disable Go Lint and collapse by default GitHub in PRs and diffs| |false|
|
||||
|withXml|whether to include support for application/xml content type and include XML annotations in the model (works with libraries that provide support for JSON and XML)| |false|
|
||||
|enumClassPrefix|Prefix enum with class name| |false|
|
||||
|prependFormOrBodyParameters|Add form or body parameters to the beginning of the parameter list.| |false|
|
||||
|
||||
@@ -56,3 +56,4 @@ sidebar_label: java
|
||||
|useReflectionEqualsHashCode|Use org.apache.commons.lang3.builder for equals and hashCode in the models. WARNING: This will fail under a security manager, unless the appropriate permissions are set up correctly and also there's potential performance impact.| |false|
|
||||
|caseInsensitiveResponseHeaders|Make API response's headers case-insensitive. Available on okhttp-gson, jersey2 libraries| |false|
|
||||
|library|library template (sub-template) to use|<dl><dt>**jersey1**</dt><dd>HTTP client: Jersey client 1.19.x. JSON processing: Jackson 2.8.x. Enable Java6 support using '-DsupportJava6=true'. Enable gzip request encoding using '-DuseGzipFeature=true'. IMPORTANT NOTE: jersey 1.x is no longer actively maintained so please upgrade to 'jersey2' or other HTTP libaries instead.</dd><dt>**jersey2**</dt><dd>HTTP client: Jersey client 2.25.1. JSON processing: Jackson 2.8.x</dd><dt>**feign**</dt><dd>HTTP client: OpenFeign 9.x or 10.x. JSON processing: Jackson 2.8.x. To enable OpenFeign 10.x, set the 'feignVersion' option to '10.x'</dd><dt>**okhttp-gson**</dt><dd>[DEFAULT] HTTP client: OkHttp 3.x. JSON processing: Gson 2.8.x. Enable Parcelable models on Android using '-DparcelableModel=true'. Enable gzip request encoding using '-DuseGzipFeature=true'.</dd><dt>**retrofit**</dt><dd>HTTP client: OkHttp 2.x. JSON processing: Gson 2.x (Retrofit 1.9.0). IMPORTANT NOTE: retrofit1.x is no longer actively maintained so please upgrade to 'retrofit2' instead.</dd><dt>**retrofit2**</dt><dd>HTTP client: OkHttp 3.x. JSON processing: Gson 2.x (Retrofit 2.3.0). Enable the RxJava adapter using '-DuseRxJava[2]=true'. (RxJava 1.x or 2.x)</dd><dt>**resttemplate**</dt><dd>HTTP client: Spring RestTemplate 4.x. JSON processing: Jackson 2.8.x</dd><dt>**webclient**</dt><dd>HTTP client: Spring WebClient 5.x. JSON processing: Jackson 2.9.x</dd><dt>**resteasy**</dt><dd>HTTP client: Resteasy client 3.x. JSON processing: Jackson 2.8.x</dd><dt>**vertx**</dt><dd>HTTP client: VertX client 3.x. JSON processing: Jackson 2.8.x</dd><dt>**google-api-client**</dt><dd>HTTP client: Google API client 1.x. JSON processing: Jackson 2.8.x</dd><dt>**rest-assured**</dt><dd>HTTP client: rest-assured : 4.x. JSON processing: Gson 2.x. Only for Java8</dd><dt>**native**</dt><dd>HTTP client: Java native HttpClient. JSON processing: Jackson 2.9.x. Only for Java11+</dd><dl>|okhttp-gson|
|
||||
|serializationLibrary|Serialization library, default depends from the library|<dl><dt>**jackson**</dt><dd>Use Jackson as serialization library</dd><dt>**gson**</dt><dd>Use Gson as serialization library</dd><dl>|null|
|
||||
|
||||
@@ -20,7 +20,7 @@ sidebar_label: typescript-angular
|
||||
|withInterfaces|Setting this property to true will generate interfaces next to the default class implementations.| |false|
|
||||
|taggedUnions|Use discriminators to create tagged unions instead of extending interfaces.| |false|
|
||||
|providedInRoot|Use this property to provide Injectables in root (it is only valid in angular version greater or equal to 6.0.0).| |false|
|
||||
|ngVersion|The version of Angular.| |7.0.0|
|
||||
|ngVersion|The version of Angular.| |8.0.0|
|
||||
|serviceSuffix|The suffix of the generated service.| |Service|
|
||||
|serviceFileSuffix|The suffix of the file of the generated service (service<suffix>.ts).| |.service|
|
||||
|modelSuffix|The suffix of the generated model.| |null|
|
||||
|
||||
@@ -19,3 +19,4 @@ sidebar_label: typescript-fetch
|
||||
|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|
|
||||
|useSingleRequestParameter|Setting this property to true will generate functions with a single argument containing all API endpoint parameters instead of one argument per parameter.| |true|
|
||||
|prefixParameterInterfaces|Setting this property to true will generate parameter interface declarations prefixed with API class name to avoid name conflicts.| |false|
|
||||
|
||||
@@ -3,7 +3,7 @@ id: swagger-codegen-migration
|
||||
title: Migrating from Swagger Codegen
|
||||
---
|
||||
|
||||
OpenAPI Generator is a fork of `swagger-codegen` between version `2.3.1` and `2.4.0`.
|
||||
OpenAPI Generator is a fork of `swagger-codegen` between version `2.3.1` and `2.4.0`. For the reasons behind the fork, please refer to the [Q&A](https://github.com/OpenAPITools/openapi-generator/blob/master/docs/qna.md).
|
||||
This community-driven version called "OpenAPI Generator" provides similar functionalities and can be used as drop-in replacement.
|
||||
This guide explains the major differences in order to help you with the migration.
|
||||
|
||||
@@ -22,6 +22,7 @@ This guide explains the major differences in order to help you with the migratio
|
||||
- [New fully qualified name for the classes](#new-fully-qualified-name-for-the-classes)
|
||||
- [Body parameter name](#body-parameter-name)
|
||||
- [Default basePath](#default-basepath)
|
||||
- [Nullable](#nullable)
|
||||
|
||||
## New docker images
|
||||
|
||||
@@ -250,3 +251,7 @@ If your API client is using named parameters in the function call (e.g. Perl req
|
||||
## Default basePath
|
||||
|
||||
The default `basePath` has been changed from `https://localhost` to `http://localhost` (http without s)
|
||||
|
||||
## Nullable
|
||||
|
||||
OpenAPI spec v3 has better support for `nullable`. If you're still using OpenAPI/Swagger spec v2, please use `x-nullable: true` instead.
|
||||
|
||||
@@ -38,9 +38,15 @@ NAME
|
||||
openapi-generator-cli list - Lists the available generators
|
||||
|
||||
SYNOPSIS
|
||||
openapi-generator-cli list [(-s | --short)]
|
||||
openapi-generator-cli list [(-i <include> | --include <include>)]
|
||||
[(-s | --short)]
|
||||
|
||||
OPTIONS
|
||||
-i <include>, --include <include>
|
||||
comma-separated list of stability indexes to include (value:
|
||||
all,beta,stable,experimental,deprecated). Excludes deprecated by
|
||||
default.
|
||||
|
||||
-s, --short
|
||||
shortened output (suitable for scripting)
|
||||
|
||||
@@ -210,13 +216,14 @@ This command takes one or more parameters representing the args list you would o
|
||||
|
||||
```bash
|
||||
openapi-generator completion config-help
|
||||
--named-header
|
||||
-o
|
||||
--output
|
||||
--named-header
|
||||
-g
|
||||
--generator-name
|
||||
-l
|
||||
--lang
|
||||
-f
|
||||
--format
|
||||
--markdown-header
|
||||
```
|
||||
|
||||
An example bash completion script can be found in the repo at [scripts/openapi-generator-cli-completion.bash](https://github.com/OpenAPITools/openapi-generator/blob/master/scripts/openapi-generator-cli-completion.bash).
|
||||
@@ -235,7 +242,6 @@ NAME
|
||||
SYNOPSIS
|
||||
openapi-generator-cli generate
|
||||
[(-a <authorization> | --auth <authorization>)]
|
||||
[--additional-properties <additional properties>...]
|
||||
[--api-package <api package>] [--artifact-id <artifact id>]
|
||||
[--artifact-version <artifact version>]
|
||||
[(-c <configuration file> | --config <configuration file>)]
|
||||
@@ -257,14 +263,14 @@ SYNOPSIS
|
||||
[--model-name-suffix <model name suffix>]
|
||||
[--model-package <model package>]
|
||||
[(-o <output directory> | --output <output directory>)]
|
||||
[(-p <additional properties> | --additional-properties <additional properties>)...]
|
||||
[--package-name <package name>] [--release-note <release note>]
|
||||
[--remove-operation-id-prefix]
|
||||
[--reserved-words-mappings <reserved word mappings>...]
|
||||
[(-s | --skip-overwrite)] [--skip-validate-spec]
|
||||
[--strict-spec <true/false strict behavior>]
|
||||
[(-s | --skip-overwrite)] [--server-variables <server variables>...]
|
||||
[--skip-validate-spec] [--strict-spec <true/false strict behavior>]
|
||||
[(-t <template directory> | --template-dir <template directory>)]
|
||||
[--type-mappings <type mappings>...] [(-v | --verbose)]
|
||||
|
||||
```
|
||||
|
||||
<details>
|
||||
@@ -277,19 +283,16 @@ OPTIONS
|
||||
remotely. Pass in a URL-encoded string of name:header with a comma
|
||||
separating multiple values
|
||||
|
||||
--additional-properties <additional properties>
|
||||
sets additional properties that can be referenced by the mustache
|
||||
templates in the format of name=value,name=value. You can also have
|
||||
multiple occurrences of this option.
|
||||
|
||||
--api-package <api package>
|
||||
package for generated api classes
|
||||
|
||||
--artifact-id <artifact id>
|
||||
artifactId in generated pom.xml
|
||||
artifactId in generated pom.xml. This also becomes part of the
|
||||
generated library's filename
|
||||
|
||||
--artifact-version <artifact version>
|
||||
artifact version in generated pom.xml
|
||||
artifact version in generated pom.xml. This also becomes part of the
|
||||
generated library's filename
|
||||
|
||||
-c <configuration file>, --config <configuration file>
|
||||
Path to configuration file configuration file. It can be json or
|
||||
@@ -382,6 +385,12 @@ OPTIONS
|
||||
-o <output directory>, --output <output directory>
|
||||
where to write the generated files (current dir by default)
|
||||
|
||||
-p <additional properties>, --additional-properties <additional
|
||||
properties>
|
||||
sets additional properties that can be referenced by the mustache
|
||||
templates in the format of name=value,name=value. You can also have
|
||||
multiple occurrences of this option.
|
||||
|
||||
--package-name <package name>
|
||||
package for generated classes (where supported)
|
||||
|
||||
@@ -400,6 +409,10 @@ OPTIONS
|
||||
specifies if the existing files should be overwritten during the
|
||||
generation.
|
||||
|
||||
--server-variables <server variables>
|
||||
sets server variables for spec documents which support variable
|
||||
templating of servers.
|
||||
|
||||
--skip-validate-spec
|
||||
Skips the default behavior of validating an input specification.
|
||||
|
||||
|
||||
@@ -18,13 +18,7 @@
|
||||
package org.openapitools.codegen.cmd;
|
||||
|
||||
import static org.apache.commons.lang3.StringUtils.isNotEmpty;
|
||||
import static org.openapitools.codegen.config.CodegenConfiguratorUtils.applyAdditionalPropertiesKvpList;
|
||||
import static org.openapitools.codegen.config.CodegenConfiguratorUtils.applyImportMappingsKvpList;
|
||||
import static org.openapitools.codegen.config.CodegenConfiguratorUtils.applyInstantiationTypesKvpList;
|
||||
import static org.openapitools.codegen.config.CodegenConfiguratorUtils.applyLanguageSpecificPrimitivesCsvList;
|
||||
import static org.openapitools.codegen.config.CodegenConfiguratorUtils.applyReservedWordsMappingsKvpList;
|
||||
import static org.openapitools.codegen.config.CodegenConfiguratorUtils.applySystemPropertiesKvpList;
|
||||
import static org.openapitools.codegen.config.CodegenConfiguratorUtils.applyTypeMappingsKvpList;
|
||||
import static org.openapitools.codegen.config.CodegenConfiguratorUtils.*;
|
||||
|
||||
import ch.qos.logback.classic.LoggerContext;
|
||||
import ch.qos.logback.core.spi.FilterAttachable;
|
||||
@@ -160,6 +154,12 @@ public class Generate implements Runnable {
|
||||
+ " You can also have multiple occurrences of this option.")
|
||||
private List<String> importMappings = new ArrayList<>();
|
||||
|
||||
@Option(
|
||||
name = {"--server-variables"},
|
||||
title = "server variables",
|
||||
description = "sets server variables overrides for spec documents which support variable templating of servers.")
|
||||
private List<String> serverVariableOverrides = new ArrayList<>();
|
||||
|
||||
@Option(name = {"--invoker-package"}, title = "invoker package",
|
||||
description = CodegenConstants.INVOKER_PACKAGE_DESC)
|
||||
private String invokerPackage;
|
||||
@@ -393,6 +393,7 @@ public class Generate implements Runnable {
|
||||
applyAdditionalPropertiesKvpList(additionalProperties, configurator);
|
||||
applyLanguageSpecificPrimitivesCsvList(languageSpecificPrimitives, configurator);
|
||||
applyReservedWordsMappingsKvpList(reservedWordsMappings, configurator);
|
||||
applyServerVariablesKvpList(serverVariableOverrides, configurator);
|
||||
|
||||
try {
|
||||
final ClientOptInput clientOptInput = configurator.toClientOptInput();
|
||||
|
||||
@@ -5,15 +5,14 @@ import com.google.common.base.Objects;
|
||||
import io.airlift.airline.Command;
|
||||
import io.airlift.airline.Option;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.openapitools.codegen.CodegenConfig;
|
||||
import org.openapitools.codegen.CodegenConfigLoader;
|
||||
import org.openapitools.codegen.CodegenType;
|
||||
import org.openapitools.codegen.meta.GeneratorMetadata;
|
||||
import org.openapitools.codegen.meta.Stability;
|
||||
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
// NOTE: List can later have subcommands such as list languages, list types, list frameworks, etc.
|
||||
@@ -26,9 +25,31 @@ public class ListGenerators implements Runnable {
|
||||
@Option(name = {"-d", "--docsite" }, description = "format for docusaurus site output", hidden = true)
|
||||
private Boolean docusaurus = false;
|
||||
|
||||
@Option(name = {"-i", "--include" },
|
||||
description = "comma-separated list of stability indexes to include (value: all,beta,stable,experimental,deprecated). Excludes deprecated by default.",
|
||||
allowedValues = { "all", "beta", "stable", "experimental", "deprecated" })
|
||||
private String include = "stable,beta,experimental";
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
List<CodegenConfig> generators = CodegenConfigLoader.getAll();
|
||||
List<CodegenConfig> generators = new ArrayList<>();
|
||||
List<Stability> stabilities = Arrays.asList(Stability.values());
|
||||
|
||||
if (!StringUtils.isEmpty(include)) {
|
||||
List<String> includes = Arrays.asList(include.split(","));
|
||||
if (includes.size() != 0 && !includes.contains("all")) {
|
||||
stabilities = includes.stream()
|
||||
.map(Stability::forDescription)
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
}
|
||||
|
||||
for (CodegenConfig codegenConfig : CodegenConfigLoader.getAll()) {
|
||||
GeneratorMetadata meta = codegenConfig.getGeneratorMetadata();
|
||||
if (meta != null && stabilities.contains(meta.getStability())) {
|
||||
generators.add(codegenConfig);
|
||||
}
|
||||
}
|
||||
|
||||
StringBuilder sb = new StringBuilder();
|
||||
|
||||
|
||||
@@ -52,6 +52,7 @@ public final class GeneratorSettings implements Serializable {
|
||||
private ImmutableMap<String, String> importMappings;
|
||||
private ImmutableSet<String> languageSpecificPrimitives;
|
||||
private ImmutableMap<String, String> reservedWordMappings;
|
||||
private ImmutableMap<String, String> serverVariables;
|
||||
|
||||
private String gitUserId;
|
||||
private String gitRepoId;
|
||||
@@ -245,6 +246,17 @@ public final class GeneratorSettings implements Serializable {
|
||||
return reservedWordMappings;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Gets server variable. Values defined here will be attempted to be replaced within a templated server object.
|
||||
*
|
||||
* @return the server variables
|
||||
*/
|
||||
public Map<String, String> getServerVariables() {
|
||||
return serverVariables;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Gets git user id. e.g. <strong>openapitools</strong>.
|
||||
* <p>
|
||||
@@ -311,6 +323,7 @@ public final class GeneratorSettings implements Serializable {
|
||||
importMappings = ImmutableMap.copyOf(builder.importMappings);
|
||||
languageSpecificPrimitives = ImmutableSet.copyOf(builder.languageSpecificPrimitives);
|
||||
reservedWordMappings = ImmutableMap.copyOf(builder.reservedWordMappings);
|
||||
serverVariables = ImmutableMap.copyOf(builder.serverVariables);
|
||||
gitUserId = builder.gitUserId;
|
||||
gitRepoId = builder.gitRepoId;
|
||||
releaseNote = builder.releaseNote;
|
||||
@@ -373,6 +386,7 @@ public final class GeneratorSettings implements Serializable {
|
||||
importMappings = ImmutableMap.of();
|
||||
languageSpecificPrimitives = ImmutableSet.of();
|
||||
reservedWordMappings = ImmutableMap.of();
|
||||
serverVariables = ImmutableMap.of();
|
||||
}
|
||||
|
||||
private void setDefaults() {
|
||||
@@ -394,12 +408,6 @@ public final class GeneratorSettings implements Serializable {
|
||||
return new Builder();
|
||||
}
|
||||
|
||||
/**
|
||||
* New builder builder.
|
||||
*
|
||||
* @param copy the copy
|
||||
* @return the builder
|
||||
*/
|
||||
public static Builder newBuilder(GeneratorSettings copy) {
|
||||
Builder builder = new Builder();
|
||||
builder.generatorName = copy.getGeneratorName();
|
||||
@@ -413,12 +421,27 @@ public final class GeneratorSettings implements Serializable {
|
||||
builder.artifactId = copy.getArtifactId();
|
||||
builder.artifactVersion = copy.getArtifactVersion();
|
||||
builder.library = copy.getLibrary();
|
||||
builder.instantiationTypes = new HashMap<>(copy.getInstantiationTypes());
|
||||
builder.typeMappings = new HashMap<>(copy.getTypeMappings());
|
||||
builder.additionalProperties = new HashMap<>(copy.getAdditionalProperties());
|
||||
builder.importMappings = new HashMap<>(copy.getImportMappings());
|
||||
builder.languageSpecificPrimitives = new HashSet<>(copy.getLanguageSpecificPrimitives());
|
||||
builder.reservedWordMappings = new HashMap<>(copy.getReservedWordMappings());
|
||||
if (copy.getInstantiationTypes() != null) {
|
||||
builder.instantiationTypes.putAll(copy.getInstantiationTypes());
|
||||
}
|
||||
if (copy.getTypeMappings() != null) {
|
||||
builder.typeMappings.putAll(copy.getTypeMappings());
|
||||
}
|
||||
if (copy.getAdditionalProperties() != null) {
|
||||
builder.additionalProperties.putAll(copy.getAdditionalProperties());
|
||||
}
|
||||
if (copy.getImportMappings() != null) {
|
||||
builder.importMappings.putAll(copy.getImportMappings());
|
||||
}
|
||||
if (copy.getLanguageSpecificPrimitives() != null) {
|
||||
builder.languageSpecificPrimitives.addAll(copy.getLanguageSpecificPrimitives());
|
||||
}
|
||||
if (copy.getReservedWordMappings() != null) {
|
||||
builder.reservedWordMappings.putAll(copy.getReservedWordMappings());
|
||||
}
|
||||
if (copy.getServerVariables() != null) {
|
||||
builder.serverVariables.putAll(copy.getServerVariables());
|
||||
}
|
||||
builder.gitUserId = copy.getGitUserId();
|
||||
builder.gitRepoId = copy.getGitRepoId();
|
||||
builder.releaseNote = copy.getReleaseNote();
|
||||
@@ -449,6 +472,7 @@ public final class GeneratorSettings implements Serializable {
|
||||
private Map<String, String> importMappings;
|
||||
private Set<String> languageSpecificPrimitives;
|
||||
private Map<String, String> reservedWordMappings;
|
||||
private Map<String, String> serverVariables;
|
||||
private String gitUserId;
|
||||
private String gitRepoId;
|
||||
private String releaseNote;
|
||||
@@ -464,6 +488,7 @@ public final class GeneratorSettings implements Serializable {
|
||||
importMappings = new HashMap<>();
|
||||
languageSpecificPrimitives = new HashSet<>();
|
||||
reservedWordMappings = new HashMap<>();
|
||||
serverVariables = new HashMap<>();
|
||||
|
||||
gitUserId = DEFAULT_GIT_USER_ID;
|
||||
gitRepoId = DEFAULT_GIT_REPO_ID;
|
||||
@@ -617,6 +642,17 @@ public final class GeneratorSettings implements Serializable {
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the {@code serverVariables} and returns a reference to this Builder so that the methods can be chained together.
|
||||
*
|
||||
* @param serverVariables the {@code serverVariables} to set
|
||||
* @return a reference to this Builder
|
||||
*/
|
||||
public Builder withServerVariables(Map<String, String> serverVariables) {
|
||||
this.serverVariables = serverVariables;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the {@code typeMappings} and returns a reference to this Builder so that the methods can be chained together.
|
||||
*
|
||||
@@ -731,6 +767,22 @@ public final class GeneratorSettings implements Serializable {
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Sets a single {@code serverVariables} and returns a reference to this Builder so that the methods can be chained together.
|
||||
*
|
||||
* @param key A key for some server variable
|
||||
* @param value The value of some server variable to be replaced in a templated server object.
|
||||
* @return a reference to this Builder
|
||||
*/
|
||||
public Builder withServerVariable(String key, String value) {
|
||||
if (this.serverVariables == null) {
|
||||
this.serverVariables = new HashMap<>();
|
||||
}
|
||||
this.serverVariables.put(key, value);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the {@code gitUserId} and returns a reference to this Builder so that the methods can be chained together.
|
||||
*
|
||||
|
||||
@@ -33,38 +33,48 @@ import java.util.Objects;
|
||||
public class WorkflowSettings {
|
||||
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(WorkflowSettings.class);
|
||||
public static final String DEFAULT_OUTPUT_DIR = ".";
|
||||
public static final boolean DEFAULT_VERBOSE = false;
|
||||
public static final boolean DEFAULT_SKIP_OVERWRITE = false;
|
||||
public static final boolean DEFAULT_REMOVE_OPERATION_ID_PREFIX = false;
|
||||
public static final boolean DEFAULT_LOG_TO_STDERR = false;
|
||||
public static final boolean DEFAULT_VALIDATE_SPEC = true;
|
||||
public static final boolean DEFAULT_ENABLE_POST_PROCESS_FILE = false;
|
||||
public static final boolean DEFAULT_ENABLE_MINIMAL_UPDATE = false;
|
||||
public static final boolean DEFAULT_STRICT_SPEC_BEHAVIOR = true;
|
||||
public static final String DEFAULT_TEMPLATING_ENGINE_NAME = "mustache";
|
||||
public static final ImmutableMap<String, String> DEFAULT_SYSTEM_PROPERTIES = ImmutableMap.of();
|
||||
|
||||
private String inputSpec;
|
||||
private String outputDir;
|
||||
private boolean verbose;
|
||||
private boolean skipOverwrite;
|
||||
private boolean removeOperationIdPrefix;
|
||||
private boolean logToStderr;
|
||||
private boolean validateSpec;
|
||||
private boolean enablePostProcessFile;
|
||||
private boolean enableMinimalUpdate;
|
||||
private boolean strictSpecBehavior;
|
||||
private String outputDir = DEFAULT_OUTPUT_DIR;
|
||||
private boolean verbose = DEFAULT_VERBOSE;
|
||||
private boolean skipOverwrite = DEFAULT_SKIP_OVERWRITE;
|
||||
private boolean removeOperationIdPrefix = DEFAULT_REMOVE_OPERATION_ID_PREFIX;
|
||||
private boolean logToStderr = DEFAULT_LOG_TO_STDERR;
|
||||
private boolean validateSpec = DEFAULT_VALIDATE_SPEC;
|
||||
private boolean enablePostProcessFile = DEFAULT_ENABLE_POST_PROCESS_FILE;
|
||||
private boolean enableMinimalUpdate = DEFAULT_ENABLE_MINIMAL_UPDATE;
|
||||
private boolean strictSpecBehavior = DEFAULT_STRICT_SPEC_BEHAVIOR;
|
||||
private String templateDir;
|
||||
private String templatingEngineName;
|
||||
private String templatingEngineName = DEFAULT_TEMPLATING_ENGINE_NAME;
|
||||
private String ignoreFileOverride;
|
||||
private ImmutableMap<String, String> systemProperties;
|
||||
private ImmutableMap<String, String> systemProperties = DEFAULT_SYSTEM_PROPERTIES;
|
||||
|
||||
private WorkflowSettings(Builder builder) {
|
||||
setDefaults();
|
||||
inputSpec = builder.inputSpec;
|
||||
outputDir = builder.outputDir;
|
||||
verbose = builder.verbose;
|
||||
skipOverwrite = builder.skipOverwrite;
|
||||
removeOperationIdPrefix = builder.removeOperationIdPrefix;
|
||||
logToStderr = builder.logToStderr;
|
||||
validateSpec = builder.validateSpec;
|
||||
enablePostProcessFile = builder.enablePostProcessFile;
|
||||
enableMinimalUpdate = builder.enableMinimalUpdate;
|
||||
strictSpecBehavior = builder.strictSpecBehavior;
|
||||
templateDir = builder.templateDir;
|
||||
templatingEngineName = builder.templatingEngineName;
|
||||
ignoreFileOverride = builder.ignoreFileOverride;
|
||||
systemProperties = ImmutableMap.copyOf(builder.systemProperties);
|
||||
this.inputSpec = builder.inputSpec;
|
||||
this.outputDir = builder.outputDir;
|
||||
this.verbose = builder.verbose;
|
||||
this.skipOverwrite = builder.skipOverwrite;
|
||||
this.removeOperationIdPrefix = builder.removeOperationIdPrefix;
|
||||
this.logToStderr = builder.logToStderr;
|
||||
this.validateSpec = builder.validateSpec;
|
||||
this.enablePostProcessFile = builder.enablePostProcessFile;
|
||||
this.enableMinimalUpdate = builder.enableMinimalUpdate;
|
||||
this.strictSpecBehavior = builder.strictSpecBehavior;
|
||||
this.templateDir = builder.templateDir;
|
||||
this.templatingEngineName = builder.templatingEngineName;
|
||||
this.ignoreFileOverride = builder.ignoreFileOverride;
|
||||
this.systemProperties = ImmutableMap.copyOf(builder.systemProperties);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -72,14 +82,7 @@ public class WorkflowSettings {
|
||||
*/
|
||||
@SuppressWarnings("unused")
|
||||
public WorkflowSettings() {
|
||||
setDefaults();
|
||||
systemProperties = ImmutableMap.of();
|
||||
}
|
||||
|
||||
private void setDefaults(){
|
||||
validateSpec = true;
|
||||
strictSpecBehavior = true;
|
||||
outputDir = ".";
|
||||
}
|
||||
|
||||
public static Builder newBuilder() {
|
||||
@@ -257,24 +260,24 @@ public class WorkflowSettings {
|
||||
@SuppressWarnings("unused")
|
||||
public static final class Builder {
|
||||
private String inputSpec;
|
||||
private String outputDir;
|
||||
private boolean verbose;
|
||||
private boolean skipOverwrite;
|
||||
private boolean removeOperationIdPrefix;
|
||||
private boolean logToStderr;
|
||||
private boolean validateSpec;
|
||||
private boolean enablePostProcessFile;
|
||||
private boolean enableMinimalUpdate;
|
||||
private boolean strictSpecBehavior;
|
||||
private String outputDir = DEFAULT_OUTPUT_DIR;
|
||||
private Boolean verbose = DEFAULT_VERBOSE;
|
||||
private Boolean skipOverwrite = DEFAULT_SKIP_OVERWRITE;
|
||||
private Boolean removeOperationIdPrefix = DEFAULT_REMOVE_OPERATION_ID_PREFIX;
|
||||
private Boolean logToStderr = DEFAULT_LOG_TO_STDERR;
|
||||
private Boolean validateSpec = DEFAULT_VALIDATE_SPEC;
|
||||
private Boolean enablePostProcessFile = DEFAULT_ENABLE_POST_PROCESS_FILE;
|
||||
private Boolean enableMinimalUpdate = DEFAULT_ENABLE_MINIMAL_UPDATE;
|
||||
private Boolean strictSpecBehavior = DEFAULT_STRICT_SPEC_BEHAVIOR;
|
||||
private String templateDir;
|
||||
private String templatingEngineName;
|
||||
private String templatingEngineName = DEFAULT_TEMPLATING_ENGINE_NAME;
|
||||
private String ignoreFileOverride;
|
||||
private Map<String, String> systemProperties;
|
||||
private Map<String, String> systemProperties = new HashMap<>();;
|
||||
|
||||
private Builder() {
|
||||
systemProperties = new HashMap<>();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Sets the {@code inputSpec} and returns a reference to this Builder so that the methods can be chained together.
|
||||
*
|
||||
@@ -282,7 +285,9 @@ public class WorkflowSettings {
|
||||
* @return a reference to this Builder
|
||||
*/
|
||||
public Builder withInputSpec(String inputSpec) {
|
||||
if (inputSpec != null) {
|
||||
this.inputSpec = inputSpec;
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -293,7 +298,11 @@ public class WorkflowSettings {
|
||||
* @return a reference to this Builder
|
||||
*/
|
||||
public Builder withOutputDir(String outputDir) {
|
||||
this.outputDir = Paths.get(outputDir).toAbsolutePath().toString();;
|
||||
if (outputDir != null ) {
|
||||
this.outputDir = Paths.get(outputDir).toAbsolutePath().toString();
|
||||
} else {
|
||||
this.outputDir = DEFAULT_OUTPUT_DIR;
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -303,8 +312,8 @@ public class WorkflowSettings {
|
||||
* @param verbose the {@code verbose} to set
|
||||
* @return a reference to this Builder
|
||||
*/
|
||||
public Builder withVerbose(boolean verbose) {
|
||||
this.verbose = verbose;
|
||||
public Builder withVerbose(Boolean verbose) {
|
||||
this.verbose = verbose != null ? verbose : Boolean.valueOf(DEFAULT_VERBOSE);
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -314,8 +323,8 @@ public class WorkflowSettings {
|
||||
* @param skipOverwrite the {@code skipOverwrite} to set
|
||||
* @return a reference to this Builder
|
||||
*/
|
||||
public Builder withSkipOverwrite(boolean skipOverwrite) {
|
||||
this.skipOverwrite = skipOverwrite;
|
||||
public Builder withSkipOverwrite(Boolean skipOverwrite) {
|
||||
this.skipOverwrite = skipOverwrite != null ? skipOverwrite : Boolean.valueOf(DEFAULT_SKIP_OVERWRITE);
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -325,8 +334,8 @@ public class WorkflowSettings {
|
||||
* @param removeOperationIdPrefix the {@code removeOperationIdPrefix} to set
|
||||
* @return a reference to this Builder
|
||||
*/
|
||||
public Builder withRemoveOperationIdPrefix(boolean removeOperationIdPrefix) {
|
||||
this.removeOperationIdPrefix = removeOperationIdPrefix;
|
||||
public Builder withRemoveOperationIdPrefix(Boolean removeOperationIdPrefix) {
|
||||
this.removeOperationIdPrefix = removeOperationIdPrefix != null ? removeOperationIdPrefix : Boolean.valueOf(DEFAULT_REMOVE_OPERATION_ID_PREFIX);
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -336,8 +345,8 @@ public class WorkflowSettings {
|
||||
* @param logToStderr the {@code logToStderr} to set
|
||||
* @return a reference to this Builder
|
||||
*/
|
||||
public Builder withLogToStderr(boolean logToStderr) {
|
||||
this.logToStderr = logToStderr;
|
||||
public Builder withLogToStderr(Boolean logToStderr) {
|
||||
this.logToStderr = logToStderr != null ? logToStderr : Boolean.valueOf(DEFAULT_LOG_TO_STDERR);
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -347,8 +356,8 @@ public class WorkflowSettings {
|
||||
* @param validateSpec the {@code validateSpec} to set
|
||||
* @return a reference to this Builder
|
||||
*/
|
||||
public Builder withValidateSpec(boolean validateSpec) {
|
||||
this.validateSpec = validateSpec;
|
||||
public Builder withValidateSpec(Boolean validateSpec) {
|
||||
this.validateSpec = validateSpec != null ? validateSpec : Boolean.valueOf(DEFAULT_VALIDATE_SPEC);
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -358,8 +367,8 @@ public class WorkflowSettings {
|
||||
* @param enablePostProcessFile the {@code enablePostProcessFile} to set
|
||||
* @return a reference to this Builder
|
||||
*/
|
||||
public Builder withEnablePostProcessFile(boolean enablePostProcessFile) {
|
||||
this.enablePostProcessFile = enablePostProcessFile;
|
||||
public Builder withEnablePostProcessFile(Boolean enablePostProcessFile) {
|
||||
this.enablePostProcessFile = enablePostProcessFile != null ? enablePostProcessFile : Boolean.valueOf(DEFAULT_ENABLE_POST_PROCESS_FILE);
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -369,8 +378,8 @@ public class WorkflowSettings {
|
||||
* @param enableMinimalUpdate the {@code enableMinimalUpdate} to set
|
||||
* @return a reference to this Builder
|
||||
*/
|
||||
public Builder withEnableMinimalUpdate(boolean enableMinimalUpdate) {
|
||||
this.enableMinimalUpdate = enableMinimalUpdate;
|
||||
public Builder withEnableMinimalUpdate(Boolean enableMinimalUpdate) {
|
||||
this.enableMinimalUpdate = enableMinimalUpdate != null ? enableMinimalUpdate : Boolean.valueOf(DEFAULT_ENABLE_MINIMAL_UPDATE);
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -380,8 +389,8 @@ public class WorkflowSettings {
|
||||
* @param strictSpecBehavior the {@code strictSpecBehavior} to set
|
||||
* @return a reference to this Builder
|
||||
*/
|
||||
public Builder withStrictSpecBehavior(boolean strictSpecBehavior) {
|
||||
this.strictSpecBehavior = strictSpecBehavior;
|
||||
public Builder withStrictSpecBehavior(Boolean strictSpecBehavior) {
|
||||
this.strictSpecBehavior = strictSpecBehavior != null ? strictSpecBehavior : Boolean.valueOf(DEFAULT_STRICT_SPEC_BEHAVIOR);
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -392,9 +401,7 @@ public class WorkflowSettings {
|
||||
* @return a reference to this Builder
|
||||
*/
|
||||
public Builder withTemplateDir(String templateDir) {
|
||||
if (templateDir == null) {
|
||||
this.templateDir = null;
|
||||
} else {
|
||||
if (templateDir != null) {
|
||||
File f = new File(templateDir);
|
||||
|
||||
// check to see if the folder exists
|
||||
@@ -416,7 +423,7 @@ public class WorkflowSettings {
|
||||
* @return a reference to this Builder
|
||||
*/
|
||||
public Builder withTemplatingEngineName(String templatingEngineName) {
|
||||
this.templatingEngineName = templatingEngineName;
|
||||
this.templatingEngineName = templatingEngineName != null ? templatingEngineName : DEFAULT_TEMPLATING_ENGINE_NAME;
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -438,7 +445,9 @@ public class WorkflowSettings {
|
||||
* @return a reference to this Builder
|
||||
*/
|
||||
public Builder withSystemProperties(Map<String, String> systemProperties) {
|
||||
if (systemProperties != null) {
|
||||
this.systemProperties = systemProperties;
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
@@ -50,4 +50,14 @@ public enum Stability {
|
||||
* @return The descriptive value of this enum.
|
||||
*/
|
||||
public String value() { return description; }
|
||||
|
||||
public static Stability forDescription(String description) {
|
||||
for (Stability value: values()) {
|
||||
if (value.description.equals(description)) {
|
||||
return value;
|
||||
}
|
||||
}
|
||||
|
||||
throw new IllegalArgumentException("description not found in the available values.");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,103 @@
|
||||
/*
|
||||
* Copyright 2019 OpenAPI-Generator Contributors (https://openapi-generator.tech)
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.openapitools.codegen.config;
|
||||
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import java.nio.file.Paths;
|
||||
|
||||
import static org.testng.Assert.*;
|
||||
|
||||
public class WorkflowSettingsTest {
|
||||
@Test
|
||||
public void defaultValuesNotOverriddenByNulls(){
|
||||
WorkflowSettings settings = WorkflowSettings.newBuilder()
|
||||
.withOutputDir(null)
|
||||
.withVerbose(null)
|
||||
.withSkipOverwrite(null)
|
||||
.withRemoveOperationIdPrefix(null)
|
||||
.withLogToStderr(null)
|
||||
.withValidateSpec(null)
|
||||
.withEnablePostProcessFile(null)
|
||||
.withEnableMinimalUpdate(null)
|
||||
.withStrictSpecBehavior(null)
|
||||
.build();
|
||||
|
||||
assertEquals(settings.getOutputDir(), ".");
|
||||
assertFalse(settings.isVerbose());
|
||||
assertFalse(settings.isSkipOverwrite());
|
||||
assertFalse(settings.isRemoveOperationIdPrefix());
|
||||
assertFalse(settings.isLogToStderr());
|
||||
assertTrue(settings.isValidateSpec());
|
||||
assertFalse(settings.isEnablePostProcessFile());
|
||||
assertFalse(settings.isEnableMinimalUpdate());
|
||||
assertTrue(settings.isStrictSpecBehavior());
|
||||
}
|
||||
|
||||
private void assertOnChangesToDefaults(WorkflowSettings defaults) {
|
||||
WorkflowSettings settings = WorkflowSettings.newBuilder()
|
||||
.withOutputDir("output")
|
||||
.withVerbose(true)
|
||||
.withSkipOverwrite(true)
|
||||
.withRemoveOperationIdPrefix(true)
|
||||
.withLogToStderr(true)
|
||||
.withValidateSpec(false)
|
||||
.withEnablePostProcessFile(true)
|
||||
.withEnableMinimalUpdate(true)
|
||||
.withStrictSpecBehavior(false)
|
||||
.build();
|
||||
|
||||
assertNotEquals(defaults.getOutputDir(), settings.getOutputDir());
|
||||
assertEquals(settings.getOutputDir(), Paths.get("output").toAbsolutePath().toString());
|
||||
|
||||
assertNotEquals(defaults.isVerbose(), settings.isVerbose());
|
||||
assertTrue(settings.isVerbose());
|
||||
|
||||
assertNotEquals(defaults.isSkipOverwrite(), settings.isSkipOverwrite());
|
||||
assertTrue(settings.isSkipOverwrite());
|
||||
|
||||
assertNotEquals(defaults.isRemoveOperationIdPrefix(), settings.isRemoveOperationIdPrefix());
|
||||
assertTrue(settings.isRemoveOperationIdPrefix());
|
||||
|
||||
assertNotEquals(defaults.isLogToStderr(), settings.isLogToStderr());
|
||||
assertTrue(settings.isLogToStderr());
|
||||
|
||||
assertNotEquals(defaults.isValidateSpec(), settings.isValidateSpec());
|
||||
assertFalse(settings.isValidateSpec());
|
||||
|
||||
assertNotEquals(defaults.isEnablePostProcessFile(), settings.isEnablePostProcessFile());
|
||||
assertTrue(settings.isEnablePostProcessFile());
|
||||
|
||||
assertNotEquals(defaults.isEnableMinimalUpdate(), settings.isEnableMinimalUpdate());
|
||||
assertTrue(settings.isEnableMinimalUpdate());
|
||||
|
||||
assertNotEquals(defaults.isStrictSpecBehavior(), settings.isStrictSpecBehavior());
|
||||
assertFalse(settings.isStrictSpecBehavior());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void defaultValuesCanBeChangedClassConstructor(){
|
||||
WorkflowSettings defaults = new WorkflowSettings();
|
||||
assertOnChangesToDefaults(defaults);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void defaultValuesCanBeChangedBuilder(){
|
||||
WorkflowSettings defaults = WorkflowSettings.newBuilder().build();
|
||||
assertOnChangesToDefaults(defaults);
|
||||
}
|
||||
}
|
||||
@@ -45,7 +45,7 @@ compileJava.dependsOn tasks.openApiGenerate
|
||||
[source,group]
|
||||
----
|
||||
plugins {
|
||||
id "org.openapi.generator" version "4.1.0"
|
||||
id "org.openapi.generator" version "4.1.1"
|
||||
}
|
||||
----
|
||||
|
||||
@@ -61,7 +61,7 @@ buildscript {
|
||||
// url "https://plugins.gradle.org/m2/"
|
||||
}
|
||||
dependencies {
|
||||
classpath "org.openapitools:openapi-generator-gradle-plugin:4.1.0"
|
||||
classpath "org.openapitools:openapi-generator-gradle-plugin:4.1.1"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -374,6 +374,18 @@ openApiGenerate {
|
||||
|
||||
|===
|
||||
|
||||
=== openApiGenerators
|
||||
|
||||
.Options
|
||||
|===
|
||||
|Key |Data Type |Default |Description
|
||||
|
||||
|include
|
||||
|String[]
|
||||
|None
|
||||
|A list of stability indexes to include (values: all,beta,stable,experimental,deprecated). Excludes deprecated by default.
|
||||
|
||||
|===
|
||||
|
||||
== Examples
|
||||
|
||||
@@ -609,7 +621,7 @@ buildscript {
|
||||
}
|
||||
dependencies {
|
||||
classpath 'com.android.tools.build:gradle:3.2.1'
|
||||
classpath('org.openapitools:openapi-generator-gradle-plugin:4.1.0') {
|
||||
classpath('org.openapitools:openapi-generator-gradle-plugin:4.1.1') {
|
||||
exclude group: 'com.google.guava'
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
buildscript {
|
||||
ext.kotlin_version = '1.2.61'
|
||||
repositories {
|
||||
mavenLocal()
|
||||
mavenCentral()
|
||||
maven {
|
||||
url "https://plugins.gradle.org/m2/"
|
||||
|
||||
@@ -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.1.0 openApiValidate
|
||||
gradle -PopenApiGeneratorVersion=4.1.1 openApiValidate
|
||||
```
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
# RELEASE_VERSION
|
||||
openApiGeneratorVersion=4.1.0
|
||||
openApiGeneratorVersion=4.1.1
|
||||
# /RELEASE_VERSION
|
||||
|
||||
@@ -19,6 +19,7 @@ package org.openapitools.generator.gradle.plugin
|
||||
import org.gradle.api.Plugin
|
||||
import org.gradle.api.Project
|
||||
import org.openapitools.generator.gradle.plugin.extensions.OpenApiGeneratorGenerateExtension
|
||||
import org.openapitools.generator.gradle.plugin.extensions.OpenApiGeneratorGeneratorsExtension
|
||||
import org.openapitools.generator.gradle.plugin.extensions.OpenApiGeneratorMetaExtension
|
||||
import org.openapitools.generator.gradle.plugin.extensions.OpenApiGeneratorValidateExtension
|
||||
import org.openapitools.generator.gradle.plugin.tasks.GenerateTask
|
||||
@@ -53,12 +54,20 @@ class OpenApiGeneratorPlugin : Plugin<Project> {
|
||||
project
|
||||
)
|
||||
|
||||
val generators = extensions.create(
|
||||
"openApiGenerators",
|
||||
OpenApiGeneratorGeneratorsExtension::class.java,
|
||||
project
|
||||
)
|
||||
|
||||
generate.outputDir.set("$buildDir/generate-resources/main")
|
||||
|
||||
tasks.apply {
|
||||
create("openApiGenerators", GeneratorsTask::class.java) {
|
||||
group = pluginGroup
|
||||
description = "Lists generators available via Open API Generators."
|
||||
|
||||
include.set(generators.include)
|
||||
}
|
||||
|
||||
create("openApiMeta", MetaTask::class.java) {
|
||||
@@ -99,6 +108,7 @@ class OpenApiGeneratorPlugin : Plugin<Project> {
|
||||
instantiationTypes.set(generate.instantiationTypes)
|
||||
typeMappings.set(generate.typeMappings)
|
||||
additionalProperties.set(generate.additionalProperties)
|
||||
serverVariables.set(generate.serverVariables)
|
||||
languageSpecificPrimitives.set(generate.languageSpecificPrimitives)
|
||||
importMappings.set(generate.importMappings)
|
||||
invokerPackage.set(generate.invokerPackage)
|
||||
|
||||
@@ -120,6 +120,11 @@ open class OpenApiGeneratorGenerateExtension(project: Project) {
|
||||
*/
|
||||
val additionalProperties = project.objects.property<Map<String, String>>()
|
||||
|
||||
/**
|
||||
* Sets server variable for server URL template substitution, in the format of name=value,name=value.
|
||||
*/
|
||||
val serverVariables = project.objects.property<Map<String, String>>()
|
||||
|
||||
/**
|
||||
* Specifies additional language specific primitive types in the format of type1,type2,type3,type3. For example: String,boolean,Boolean,Double.
|
||||
*/
|
||||
|
||||
@@ -0,0 +1,43 @@
|
||||
/*
|
||||
* Copyright 2019 OpenAPI-Generator Contributors (https://openapi-generator.tech)
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.openapitools.generator.gradle.plugin.extensions
|
||||
|
||||
import org.gradle.api.Project
|
||||
import org.gradle.api.tasks.Internal
|
||||
import org.gradle.kotlin.dsl.listProperty
|
||||
import org.openapitools.codegen.meta.Stability
|
||||
|
||||
/**
|
||||
* Gradle project level extension object definition for the generators task
|
||||
*
|
||||
* @author Jim Schubert
|
||||
*/
|
||||
open class OpenApiGeneratorGeneratorsExtension(project: Project) {
|
||||
/**
|
||||
* A list of stability indexes to include (value: all,beta,stable,experimental,deprecated). Excludes deprecated by default.
|
||||
*/
|
||||
val include = project.objects.listProperty<String>()
|
||||
|
||||
init {
|
||||
applyDefaults()
|
||||
}
|
||||
|
||||
@Suppress("MemberVisibilityCanBePrivate")
|
||||
fun applyDefaults(){
|
||||
include.set(Stability.values().map { s -> s.value() }.filterNot { it == Stability.DEPRECATED.value() })
|
||||
}
|
||||
}
|
||||
@@ -155,6 +155,13 @@ open class GenerateTask : DefaultTask() {
|
||||
@get:Internal
|
||||
val additionalProperties = project.objects.property<Map<String, String>>()
|
||||
|
||||
/**
|
||||
* Sets server variable for server URL template substitution, in the format of name=value,name=value.
|
||||
* You can also have multiple occurrences of this option.
|
||||
*/
|
||||
@get:Internal
|
||||
val serverVariables = project.objects.property<Map<String, String>>()
|
||||
|
||||
/**
|
||||
* Specifies additional language specific primitive types in the format of type1,type2,type3,type3. For example: String,boolean,Boolean,Double.
|
||||
*/
|
||||
@@ -573,6 +580,12 @@ open class GenerateTask : DefaultTask() {
|
||||
}
|
||||
}
|
||||
|
||||
if (serverVariables.isPresent) {
|
||||
serverVariables.get().forEach { entry ->
|
||||
configurator.addServerVariable(entry.key, entry.value)
|
||||
}
|
||||
}
|
||||
|
||||
if (languageSpecificPrimitives.isPresent) {
|
||||
languageSpecificPrimitives.get().forEach {
|
||||
configurator.addLanguageSpecificPrimitive(it)
|
||||
|
||||
@@ -17,9 +17,11 @@
|
||||
package org.openapitools.generator.gradle.plugin.tasks
|
||||
|
||||
import org.gradle.api.DefaultTask
|
||||
import org.gradle.api.tasks.Internal
|
||||
import org.gradle.api.tasks.TaskAction
|
||||
import org.gradle.internal.logging.text.StyledTextOutput
|
||||
import org.gradle.internal.logging.text.StyledTextOutputFactory
|
||||
import org.gradle.kotlin.dsl.listProperty
|
||||
import org.openapitools.codegen.CodegenConfigLoader
|
||||
import org.openapitools.codegen.CodegenType
|
||||
import org.openapitools.codegen.meta.GeneratorMetadata
|
||||
@@ -35,6 +37,12 @@ import org.openapitools.codegen.meta.Stability
|
||||
* @author Jim Schubert
|
||||
*/
|
||||
open class GeneratorsTask : DefaultTask() {
|
||||
/**
|
||||
* A list of stability indexes to include (value: all,beta,stable,experimental,deprecated). Excludes deprecated by default.
|
||||
*/
|
||||
@get:Internal
|
||||
val include = project.objects.listProperty<String>()
|
||||
|
||||
@Suppress("unused")
|
||||
@TaskAction
|
||||
fun doWork() {
|
||||
@@ -45,6 +53,15 @@ open class GeneratorsTask : DefaultTask() {
|
||||
StringBuilder().apply {
|
||||
val types = CodegenType.values()
|
||||
|
||||
val stabilities = if (include.isPresent) {
|
||||
when {
|
||||
include.get().contains("all") -> Stability.values().toList()
|
||||
else -> include.get().map { Stability.forDescription(it) }
|
||||
}
|
||||
} else {
|
||||
Stability.values().filterNot { it == Stability.DEPRECATED }
|
||||
}
|
||||
|
||||
append("The following generators are available:")
|
||||
|
||||
append(System.lineSeparator())
|
||||
@@ -56,10 +73,11 @@ open class GeneratorsTask : DefaultTask() {
|
||||
|
||||
generators.filter { it.tag == type }
|
||||
.sortedBy { it.name }
|
||||
.forEach({ generator ->
|
||||
.forEach { generator ->
|
||||
|
||||
val meta: GeneratorMetadata? = generator.generatorMetadata
|
||||
|
||||
val include = stabilities.contains(meta?.stability)
|
||||
if (include) {
|
||||
append(" - ")
|
||||
append(generator.name)
|
||||
|
||||
@@ -70,7 +88,8 @@ open class GeneratorsTask : DefaultTask() {
|
||||
}
|
||||
|
||||
append(System.lineSeparator())
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
append(System.lineSeparator())
|
||||
append(System.lineSeparator())
|
||||
|
||||
@@ -12,7 +12,7 @@ Add to your `build->plugins` section (default phase is `generate-sources` phase)
|
||||
<groupId>org.openapitools</groupId>
|
||||
<artifactId>openapi-generator-maven-plugin</artifactId>
|
||||
<!-- RELEASE_VERSION -->
|
||||
<version>4.1.0</version>
|
||||
<version>4.1.1</version>
|
||||
<!-- /RELEASE_VERSION -->
|
||||
<executions>
|
||||
<execution>
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
<groupId>org.openapitools</groupId>
|
||||
<artifactId>openapi-generator-maven-plugin</artifactId>
|
||||
<!-- RELEASE_VERSION -->
|
||||
<version>4.1.1-SNAPSHOT</version>
|
||||
<version>4.1.2-SNAPSHOT</version>
|
||||
<!-- /RELEASE_VERSION -->
|
||||
<executions>
|
||||
<execution>
|
||||
@@ -121,6 +121,11 @@
|
||||
<artifactId>jackson-jaxrs-json-provider</artifactId>
|
||||
<version>${jackson-version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.openapitools</groupId>
|
||||
<artifactId>jackson-databind-nullable</artifactId>
|
||||
<version>${jackson-databind-nullable-version}</version>
|
||||
</dependency>
|
||||
|
||||
<!-- Joda time: if you use it -->
|
||||
<dependency>
|
||||
@@ -146,6 +151,7 @@
|
||||
<swagger-annotations-version>1.5.8</swagger-annotations-version>
|
||||
<jersey-version>2.27</jersey-version>
|
||||
<jackson-version>2.8.9</jackson-version>
|
||||
<jackson-databind-nullable-version>0.2.0</jackson-databind-nullable-version>
|
||||
<jodatime-version>2.7</jodatime-version>
|
||||
<maven-plugin-version>1.0.0</maven-plugin-version>
|
||||
<junit-version>4.8.1</junit-version>
|
||||
|
||||
@@ -134,6 +134,11 @@
|
||||
<artifactId>jackson-jaxrs-json-provider</artifactId>
|
||||
<version>${jackson-version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.openapitools</groupId>
|
||||
<artifactId>jackson-databind-nullable</artifactId>
|
||||
<version>${jackson-databind-nullable-version}</version>
|
||||
</dependency>
|
||||
|
||||
<!-- Joda time: if you use it -->
|
||||
<dependency>
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
<swagger-annotations-version>1.5.8</swagger-annotations-version>
|
||||
<jersey-version>2.27</jersey-version>
|
||||
<jackson-version>2.8.9</jackson-version>
|
||||
<jackson-databind-nullable-version>0.2.0</jackson-databind-nullable-version>
|
||||
<jodatime-version>2.7</jodatime-version>
|
||||
<maven-plugin-version>1.0.0</maven-plugin-version>
|
||||
<junit-version>4.8.1</junit-version>
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
<groupId>org.openapitools</groupId>
|
||||
<artifactId>openapi-generator-maven-plugin</artifactId>
|
||||
<!-- RELEASE_VERSION -->
|
||||
<version>4.1.0</version>
|
||||
<version>4.1.1</version>
|
||||
<!-- /RELEASE_VERSION -->
|
||||
<executions>
|
||||
<execution>
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
<groupId>org.openapitools</groupId>
|
||||
<artifactId>openapi-generator-maven-plugin</artifactId>
|
||||
<!-- RELEASE_VERSION -->
|
||||
<version>4.1.0</version>
|
||||
<version>4.1.1</version>
|
||||
<!-- /RELEASE_VERSION -->
|
||||
<executions>
|
||||
<execution>
|
||||
|
||||
@@ -17,19 +17,8 @@
|
||||
|
||||
package org.openapitools.codegen.plugin;
|
||||
|
||||
import static org.openapitools.codegen.config.CodegenConfiguratorUtils.applyAdditionalPropertiesKvp;
|
||||
import static org.openapitools.codegen.config.CodegenConfiguratorUtils.applyImportMappingsKvp;
|
||||
import static org.openapitools.codegen.config.CodegenConfiguratorUtils.applyInstantiationTypesKvp;
|
||||
import static org.openapitools.codegen.config.CodegenConfiguratorUtils.applyLanguageSpecificPrimitivesCsv;
|
||||
import static org.openapitools.codegen.config.CodegenConfiguratorUtils.applyTypeMappingsKvp;
|
||||
import static org.openapitools.codegen.config.CodegenConfiguratorUtils.applyReservedWordsMappingsKvp;
|
||||
import static org.openapitools.codegen.config.CodegenConfiguratorUtils.applyAdditionalPropertiesKvpList;
|
||||
import static org.openapitools.codegen.config.CodegenConfiguratorUtils.applyImportMappingsKvpList;
|
||||
import static org.openapitools.codegen.config.CodegenConfiguratorUtils.applyInstantiationTypesKvpList;
|
||||
import static org.openapitools.codegen.config.CodegenConfiguratorUtils.applyLanguageSpecificPrimitivesCsvList;
|
||||
import static org.openapitools.codegen.config.CodegenConfiguratorUtils.applyTypeMappingsKvpList;
|
||||
import static org.openapitools.codegen.config.CodegenConfiguratorUtils.applyReservedWordsMappingsKvpList;
|
||||
import static org.apache.commons.lang3.StringUtils.isNotEmpty;
|
||||
import static org.openapitools.codegen.config.CodegenConfiguratorUtils.*;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.HashMap;
|
||||
@@ -289,6 +278,12 @@ public class CodeGenMojo extends AbstractMojo {
|
||||
@Parameter(name = "additionalProperties", property = "openapi.generator.maven.plugin.additionalProperties")
|
||||
private List<String> additionalProperties;
|
||||
|
||||
/**
|
||||
* A map of server variable overrides for specs that support server URL templating
|
||||
*/
|
||||
@Parameter(name = "serverVariableOverrides", property = "openapi.generator.maven.plugin.serverVariableOverrides")
|
||||
private List<String> serverVariableOverrides;
|
||||
|
||||
/**
|
||||
* A map of reserved names and how they should be escaped
|
||||
*/
|
||||
@@ -615,6 +610,10 @@ public class CodeGenMojo extends AbstractMojo {
|
||||
configurator);
|
||||
}
|
||||
|
||||
if (serverVariableOverrides == null && configOptions.containsKey("server-variables")) {
|
||||
applyServerVariablesKvp(configOptions.get("server-variables").toString(), configurator);
|
||||
}
|
||||
|
||||
// Retained for backwards-compataibility with configOptions -> reserved-words-mappings
|
||||
if (reservedWordsMappings == null && configOptions.containsKey("reserved-words-mappings")) {
|
||||
applyReservedWordsMappingsKvp(configOptions.get("reserved-words-mappings")
|
||||
@@ -648,6 +647,10 @@ public class CodeGenMojo extends AbstractMojo {
|
||||
applyAdditionalPropertiesKvpList(additionalProperties, configurator);
|
||||
}
|
||||
|
||||
if (serverVariableOverrides != null && (configOptions == null || !configOptions.containsKey("server-variables"))) {
|
||||
applyServerVariablesKvpList(serverVariableOverrides, configurator);
|
||||
}
|
||||
|
||||
// Apply Reserved Words Mappings
|
||||
if (reservedWordsMappings != null && (configOptions == null || !configOptions.containsKey("reserved-words-mappings"))) {
|
||||
applyReservedWordsMappingsKvpList(reservedWordsMappings, configurator);
|
||||
|
||||
@@ -268,6 +268,12 @@
|
||||
<!-- <version>${testng-version}</version> -->
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.github.javaparser</groupId>
|
||||
<artifactId>javaparser-core</artifactId>
|
||||
<version>3.14.11</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.reflections</groupId>
|
||||
<artifactId>reflections</artifactId>
|
||||
@@ -294,7 +300,7 @@
|
||||
<dependency>
|
||||
<groupId>org.mockito</groupId>
|
||||
<artifactId>mockito-core</artifactId>
|
||||
<version>2.23.0</version>
|
||||
<version>3.0.0</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
|
||||
@@ -43,6 +43,8 @@ public interface CodegenConfig {
|
||||
|
||||
Map<String, Object> additionalProperties();
|
||||
|
||||
Map<String, String> serverVariableOverrides();
|
||||
|
||||
Map<String, Object> vendorExtensions();
|
||||
|
||||
String testPackage();
|
||||
|
||||
@@ -308,4 +308,7 @@ public class CodegenConstants {
|
||||
|
||||
public static final String EXCEPTION_ON_FAILURE = "returnExceptionOnFailure";
|
||||
public static final String EXCEPTION_ON_FAILURE_DESC = "Throw an exception on non success response codes";
|
||||
|
||||
public static final String ENUM_CLASS_PREFIX = "enumClassPrefix";
|
||||
public static final String ENUM_CLASS_PREFIX_DESC = "Prefix enum with class name";
|
||||
}
|
||||
|
||||
@@ -7,4 +7,5 @@ public class CodegenServerVariable {
|
||||
public String defaultValue;
|
||||
public String description;
|
||||
public List<String> enumValues;
|
||||
public String value;
|
||||
}
|
||||
|
||||
@@ -97,6 +97,7 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
protected String embeddedTemplateDir;
|
||||
protected String commonTemplateDir = "_common";
|
||||
protected Map<String, Object> additionalProperties = new HashMap<String, Object>();
|
||||
protected Map<String, String> serverVariables = new HashMap<String, String>();
|
||||
protected Map<String, Object> vendorExtensions = new HashMap<String, Object>();
|
||||
protected List<SupportingFile> supportingFiles = new ArrayList<SupportingFile>();
|
||||
protected List<CliOption> cliOptions = new ArrayList<CliOption>();
|
||||
@@ -503,12 +504,12 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
public void postProcessParameter(CodegenParameter parameter) {
|
||||
}
|
||||
|
||||
//override with any special handling of the entire swagger spec
|
||||
//override with any special handling of the entire OpenAPI spec document
|
||||
@SuppressWarnings("unused")
|
||||
public void preprocessOpenAPI(OpenAPI openAPI) {
|
||||
}
|
||||
|
||||
// override with any special handling of the entire swagger spec
|
||||
// override with any special handling of the entire OpenAPI spec document
|
||||
@SuppressWarnings("unused")
|
||||
public void processOpenAPI(OpenAPI openAPI) {
|
||||
}
|
||||
@@ -722,6 +723,10 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
return additionalProperties;
|
||||
}
|
||||
|
||||
public Map<String, String> serverVariableOverrides() {
|
||||
return serverVariables;
|
||||
}
|
||||
|
||||
public Map<String, Object> vendorExtensions() {
|
||||
return vendorExtensions;
|
||||
}
|
||||
@@ -1822,6 +1827,7 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
} else {
|
||||
// composition
|
||||
addProperties(properties, required, refSchema);
|
||||
addProperties(allProperties, allRequired, refSchema);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2653,11 +2659,13 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
CodegenParameter bodyParam = null;
|
||||
RequestBody requestBody = operation.getRequestBody();
|
||||
if (requestBody != null) {
|
||||
if (getContentType(requestBody) != null &&
|
||||
(getContentType(requestBody).toLowerCase(Locale.ROOT).startsWith("application/x-www-form-urlencoded") ||
|
||||
getContentType(requestBody).toLowerCase(Locale.ROOT).startsWith("multipart/form-data"))) {
|
||||
String contentType = getContentType(requestBody);
|
||||
if (contentType != null &&
|
||||
(contentType.toLowerCase(Locale.ROOT).startsWith("application/x-www-form-urlencoded") ||
|
||||
contentType.toLowerCase(Locale.ROOT).startsWith("multipart"))) {
|
||||
// process form parameters
|
||||
formParams = fromRequestBodyToFormParameters(requestBody, imports);
|
||||
op.isMultipart = contentType.toLowerCase(Locale.ROOT).startsWith("multipart");
|
||||
for (CodegenParameter cp : formParams) {
|
||||
postProcessParameter(cp);
|
||||
}
|
||||
@@ -4457,8 +4465,8 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
|
||||
for (String consume : consumesInfo) {
|
||||
if (consume != null &&
|
||||
consume.toLowerCase(Locale.ROOT).startsWith("application/x-www-form-urlencoded") ||
|
||||
consume.toLowerCase(Locale.ROOT).startsWith("multipart/form-data")) {
|
||||
(consume.toLowerCase(Locale.ROOT).startsWith("application/x-www-form-urlencoded") ||
|
||||
consume.toLowerCase(Locale.ROOT).startsWith("multipart"))) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -4878,6 +4886,17 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
imports.add(codegenParameter.baseType);
|
||||
} else {
|
||||
CodegenProperty codegenProperty = fromProperty("property", schema);
|
||||
|
||||
if (codegenProperty != null && codegenProperty.getComplexType() != null && codegenProperty.getComplexType().contains(" | ")) {
|
||||
List<String> parts = Arrays.asList(codegenProperty.getComplexType().split(" \\| "));
|
||||
imports.addAll(parts);
|
||||
String codegenModelName = codegenProperty.getComplexType();
|
||||
codegenParameter.baseName = codegenModelName;
|
||||
codegenParameter.paramName = toParamName(codegenParameter.baseName);
|
||||
codegenParameter.baseType = codegenParameter.baseName;
|
||||
codegenParameter.dataType = getTypeDeclaration(codegenModelName);
|
||||
codegenParameter.description = codegenProperty.getDescription();
|
||||
} else {
|
||||
if (ModelUtils.getAdditionalProperties(schema) != null) {// http body is map
|
||||
LOGGER.error("Map should be supported. Please report to openapi-generator github repo about the issue.");
|
||||
} else if (codegenProperty != null) {
|
||||
@@ -4890,7 +4909,7 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
LOGGER.warn("The following schema has undefined (null) baseType. " +
|
||||
"It could be due to form parameter defined in OpenAPI v2 spec with incorrect consumes. " +
|
||||
"A correct 'consumes' for form parameters should be " +
|
||||
"'application/x-www-form-urlencoded' or 'multipart/form-data'");
|
||||
"'application/x-www-form-urlencoded' or 'multipart/?'");
|
||||
LOGGER.warn("schema: " + schema);
|
||||
LOGGER.warn("codegenModel is null. Default to UNKNOWN_BASE_TYPE");
|
||||
codegenModelName = "UNKNOWN_BASE_TYPE";
|
||||
@@ -4913,6 +4932,8 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
imports.add(codegenProperty.complexType);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
setParameterBooleanFlagWithCodegenProperty(codegenParameter, codegenProperty);
|
||||
// set nullable
|
||||
setParameterNullable(codegenParameter, codegenProperty);
|
||||
@@ -4999,11 +5020,7 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
protected void generateJSONSpecFile(Map<String, Object> objs) {
|
||||
OpenAPI openAPI = (OpenAPI) objs.get("openAPI");
|
||||
if (openAPI != null) {
|
||||
try {
|
||||
objs.put("openapi-json", Json.pretty().writeValueAsString(openAPI).replace("\r\n", "\n"));
|
||||
} catch (JsonProcessingException e) {
|
||||
LOGGER.error(e.getMessage(), e);
|
||||
}
|
||||
objs.put("openapi-json", SerializerUtils.toJsonString(openAPI));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5053,14 +5070,34 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
if (variables == null) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
Map<String, String> variableOverrides = serverVariableOverrides();
|
||||
|
||||
List<CodegenServerVariable> codegenServerVariables = new LinkedList<>();
|
||||
for (Entry<String, ServerVariable> variableEntry : variables.entrySet()) {
|
||||
CodegenServerVariable codegenServerVariable = new CodegenServerVariable();
|
||||
ServerVariable variable = variableEntry.getValue();
|
||||
List<String> enums = variable.getEnum();
|
||||
|
||||
codegenServerVariable.defaultValue = variable.getDefault();
|
||||
codegenServerVariable.description = escapeText(variable.getDescription());
|
||||
codegenServerVariable.enumValues = variable.getEnum();
|
||||
codegenServerVariable.enumValues = enums;
|
||||
codegenServerVariable.name = variableEntry.getKey();
|
||||
|
||||
// Sets the override value for a server variable pattern.
|
||||
// NOTE: OpenAPI Specification doesn't prevent multiple server URLs with variables. If multiple objects have the same
|
||||
// variables pattern, user overrides will apply to _all_ of these patterns. We may want to consider indexed overrides.
|
||||
if (variableOverrides != null && !variableOverrides.isEmpty()) {
|
||||
String value = variableOverrides.getOrDefault(variableEntry.getKey(), variable.getDefault());
|
||||
codegenServerVariable.value = value;
|
||||
|
||||
if (enums != null && !enums.isEmpty() && !enums.contains(value)) {
|
||||
LOGGER.warn("Variable override of '{}' is not listed in the enum of allowed values ({}).", value, StringUtils.join(enums, ","));
|
||||
}
|
||||
} else {
|
||||
codegenServerVariable.value = variable.getDefault();
|
||||
}
|
||||
|
||||
codegenServerVariables.add(codegenServerVariable);
|
||||
}
|
||||
return codegenServerVariables;
|
||||
|
||||
@@ -37,6 +37,7 @@ import org.openapitools.codegen.api.TemplatingEngineAdapter;
|
||||
import org.openapitools.codegen.ignore.CodegenIgnoreProcessor;
|
||||
import org.openapitools.codegen.meta.GeneratorMetadata;
|
||||
import org.openapitools.codegen.meta.Stability;
|
||||
import org.openapitools.codegen.serializer.SerializerUtils;
|
||||
import org.openapitools.codegen.templating.MustacheEngineAdapter;
|
||||
import org.openapitools.codegen.utils.ImplementationVersion;
|
||||
import org.openapitools.codegen.utils.ModelUtils;
|
||||
@@ -183,12 +184,12 @@ public class DefaultGenerator extends AbstractGenerator implements Generator {
|
||||
}
|
||||
|
||||
if (GlobalSettings.getProperty("debugOpenAPI") != null) {
|
||||
Json.prettyPrint(openAPI);
|
||||
SerializerUtils.toJsonString(openAPI);
|
||||
} else if (GlobalSettings.getProperty("debugSwagger") != null) {
|
||||
// This exists for backward compatibility
|
||||
// We fall to this block only if debugOpenAPI is null. No need to dump this twice.
|
||||
LOGGER.info("Please use system property 'debugOpenAPI' instead of 'debugSwagger'.");
|
||||
Json.prettyPrint(openAPI);
|
||||
SerializerUtils.toJsonString(openAPI);
|
||||
}
|
||||
|
||||
config.processOpts();
|
||||
@@ -207,10 +208,12 @@ public class DefaultGenerator extends AbstractGenerator implements Generator {
|
||||
config.vendorExtensions().putAll(openAPI.getExtensions());
|
||||
}
|
||||
|
||||
URL url = URLPathUtils.getServerURL(openAPI);
|
||||
// TODO: Allow user to define _which_ servers object in the array to target.
|
||||
// Configures contextPath/basePath according to api document's servers
|
||||
URL url = URLPathUtils.getServerURL(openAPI, config.serverVariableOverrides());
|
||||
contextPath = config.escapeText(url.getPath()).replaceAll("/$", ""); // for backward compatibility
|
||||
basePathWithoutHost = contextPath;
|
||||
basePath = config.escapeText(URLPathUtils.getHost(openAPI)).replaceAll("/$", "");
|
||||
basePath = config.escapeText(URLPathUtils.getHost(openAPI, config.serverVariableOverrides())).replaceAll("/$", "");
|
||||
}
|
||||
|
||||
private void configureOpenAPIInfo() {
|
||||
@@ -548,7 +551,7 @@ public class DefaultGenerator extends AbstractGenerator implements Generator {
|
||||
}
|
||||
});
|
||||
Map<String, Object> operation = processOperations(config, tag, ops, allModels);
|
||||
URL url = URLPathUtils.getServerURL(openAPI);
|
||||
URL url = URLPathUtils.getServerURL(openAPI, config.serverVariableOverrides());
|
||||
operation.put("basePath", basePath);
|
||||
operation.put("basePathWithoutHost", config.encodePath(url.getPath()).replaceAll("/$", ""));
|
||||
operation.put("contextPath", contextPath);
|
||||
@@ -819,7 +822,7 @@ public class DefaultGenerator extends AbstractGenerator implements Generator {
|
||||
Map<String, Object> apis = new HashMap<String, Object>();
|
||||
apis.put("apis", allOperations);
|
||||
|
||||
URL url = URLPathUtils.getServerURL(openAPI);
|
||||
URL url = URLPathUtils.getServerURL(openAPI, config.serverVariableOverrides());
|
||||
|
||||
bundle.put("openAPI", openAPI);
|
||||
bundle.put("basePath", basePath);
|
||||
@@ -972,6 +975,7 @@ public class DefaultGenerator extends AbstractGenerator implements Generator {
|
||||
processOperation(resourcePath, "delete", path.getDelete(), ops, path);
|
||||
processOperation(resourcePath, "patch", path.getPatch(), ops, path);
|
||||
processOperation(resourcePath, "options", path.getOptions(), ops, path);
|
||||
processOperation(resourcePath, "trace", path.getTrace(), ops, path);
|
||||
}
|
||||
return ops;
|
||||
}
|
||||
@@ -1191,7 +1195,7 @@ public class DefaultGenerator extends AbstractGenerator implements Generator {
|
||||
for (String key : definitions.keySet()) {
|
||||
Schema schema = definitions.get(key);
|
||||
if (schema == null)
|
||||
throw new RuntimeException("schema cannot be null in processMoels");
|
||||
throw new RuntimeException("schema cannot be null in processModels");
|
||||
CodegenModel cm = config.fromModel(key, schema);
|
||||
Map<String, Object> mo = new HashMap<String, Object>();
|
||||
mo.put("model", cm);
|
||||
|
||||
@@ -19,6 +19,7 @@ package org.openapitools.codegen;
|
||||
|
||||
import io.swagger.v3.core.util.Json;
|
||||
import io.swagger.v3.oas.models.*;
|
||||
import io.swagger.v3.oas.models.callbacks.Callback;
|
||||
import io.swagger.v3.oas.models.media.*;
|
||||
import io.swagger.v3.oas.models.parameters.Parameter;
|
||||
import io.swagger.v3.oas.models.parameters.RequestBody;
|
||||
@@ -29,6 +30,7 @@ import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class InlineModelResolver {
|
||||
private OpenAPI openapi;
|
||||
@@ -64,7 +66,20 @@ public class InlineModelResolver {
|
||||
|
||||
for (String pathname : paths.keySet()) {
|
||||
PathItem path = paths.get(pathname);
|
||||
List<Operation> operations = new ArrayList<>(path.readOperations());
|
||||
|
||||
// Include callback operation as well
|
||||
for (Operation operation : path.readOperations()) {
|
||||
Map<String, Callback> callbacks = operation.getCallbacks();
|
||||
if (callbacks != null) {
|
||||
operations.addAll(callbacks.values().stream()
|
||||
.flatMap(callback -> callback.values().stream())
|
||||
.flatMap(pathItem -> pathItem.readOperations().stream())
|
||||
.collect(Collectors.toList()));
|
||||
}
|
||||
}
|
||||
|
||||
for (Operation operation : operations) {
|
||||
flattenRequestBody(openAPI, pathname, operation);
|
||||
flattenParameters(openAPI, pathname, operation);
|
||||
flattenResponses(openAPI, pathname, operation);
|
||||
|
||||
@@ -67,6 +67,7 @@ public class CodegenConfigurator {
|
||||
private Map<String, String> importMappings = new HashMap<>();
|
||||
private Set<String> languageSpecificPrimitives = new HashSet<>();
|
||||
private Map<String, String> reservedWordMappings = new HashMap<>();
|
||||
private Map<String, String> serverVariables = new HashMap<>();
|
||||
private String auth;
|
||||
|
||||
public CodegenConfigurator() {
|
||||
@@ -90,6 +91,7 @@ public class CodegenConfigurator {
|
||||
DynamicSettings settings = mapper.readValue(new File(configFile), DynamicSettings.class);
|
||||
CodegenConfigurator configurator = new CodegenConfigurator();
|
||||
configurator.generatorSettingsBuilder = GeneratorSettings.newBuilder(settings.getGeneratorSettings());
|
||||
configurator.workflowSettingsBuilder = WorkflowSettings.newBuilder(settings.getWorkflowSettings());
|
||||
return configurator;
|
||||
} catch (IOException ex) {
|
||||
LOGGER.error("Unable to deserialize config file: " + configFile, ex);
|
||||
@@ -98,6 +100,12 @@ public class CodegenConfigurator {
|
||||
return null;
|
||||
}
|
||||
|
||||
public CodegenConfigurator addServerVariable(String key, String value) {
|
||||
this.serverVariables.put(key, value);
|
||||
generatorSettingsBuilder.withServerVariable(key, value);
|
||||
return this;
|
||||
}
|
||||
|
||||
public CodegenConfigurator addAdditionalProperty(String key, Object value) {
|
||||
this.additionalProperties.put(key, value);
|
||||
generatorSettingsBuilder.withAdditionalProperty(key, value);
|
||||
@@ -146,6 +154,18 @@ public class CodegenConfigurator {
|
||||
return this;
|
||||
}
|
||||
|
||||
public CodegenConfigurator setServerVariables(Map<String, String> serverVariables) {
|
||||
this.serverVariables = serverVariables;
|
||||
generatorSettingsBuilder.withServerVariables(serverVariables);
|
||||
return this;
|
||||
}
|
||||
|
||||
public CodegenConfigurator setReservedWordsMappings(Map<String, String> reservedWordMappings) {
|
||||
this.reservedWordMappings = reservedWordMappings;
|
||||
generatorSettingsBuilder.withReservedWordMappings(reservedWordMappings);
|
||||
return this;
|
||||
}
|
||||
|
||||
public CodegenConfigurator setApiPackage(String apiPackage) {
|
||||
generatorSettingsBuilder.withApiPackage(apiPackage);
|
||||
return this;
|
||||
@@ -247,6 +267,7 @@ public class CodegenConfigurator {
|
||||
|
||||
public CodegenConfigurator setLanguageSpecificPrimitives(
|
||||
Set<String> languageSpecificPrimitives) {
|
||||
this.languageSpecificPrimitives = languageSpecificPrimitives;
|
||||
generatorSettingsBuilder.withLanguageSpecificPrimitives(languageSpecificPrimitives);
|
||||
return this;
|
||||
}
|
||||
@@ -296,12 +317,6 @@ public class CodegenConfigurator {
|
||||
return this;
|
||||
}
|
||||
|
||||
public CodegenConfigurator setReservedWordsMappings(Map<String, String> reservedWordMappings) {
|
||||
this.reservedWordMappings = reservedWordMappings;
|
||||
generatorSettingsBuilder.withReservedWordMappings(reservedWordMappings);
|
||||
return this;
|
||||
}
|
||||
|
||||
public CodegenConfigurator setSkipOverwrite(boolean skipOverwrite) {
|
||||
workflowSettingsBuilder.withSkipOverwrite(skipOverwrite);
|
||||
return this;
|
||||
@@ -459,6 +474,13 @@ public class CodegenConfigurator {
|
||||
config.reservedWordsMappings().putAll(generatorSettings.getReservedWordMappings());
|
||||
config.additionalProperties().putAll(generatorSettings.getAdditionalProperties());
|
||||
|
||||
Map<String, String> serverVariables = generatorSettings.getServerVariables();
|
||||
if (!serverVariables.isEmpty()) {
|
||||
// This is currently experimental due to vagueness in the specification
|
||||
LOGGER.warn("user-defined server variable support is experimental.");
|
||||
config.serverVariableOverrides().putAll(serverVariables);
|
||||
}
|
||||
|
||||
// any other additional properties?
|
||||
String templateDir = workflowSettings.getTemplateDir();
|
||||
if (templateDir != null) {
|
||||
|
||||
@@ -107,6 +107,19 @@ public final class CodegenConfiguratorUtils {
|
||||
}
|
||||
}
|
||||
|
||||
public static void applyServerVariablesKvpList(List<String> values, CodegenConfigurator configurator) {
|
||||
for(String value : values) {
|
||||
applyServerVariablesKvp(value, configurator);
|
||||
}
|
||||
}
|
||||
|
||||
public static void applyServerVariablesKvp(String values, CodegenConfigurator configurator) {
|
||||
final Map<String, String> map = createMapFromKeyValuePairs(values);
|
||||
for (Map.Entry<String, String> entry : map.entrySet()) {
|
||||
configurator.addServerVariable(entry.getKey(), entry.getValue());
|
||||
}
|
||||
}
|
||||
|
||||
public static void applyLanguageSpecificPrimitivesCsvList(List<String> languageSpecificPrimitives, CodegenConfigurator configurator) {
|
||||
for(String propString : languageSpecificPrimitives) {
|
||||
applyLanguageSpecificPrimitivesCsv(propString, configurator);
|
||||
|
||||
@@ -296,7 +296,7 @@ abstract public class AbstractCppCodegen extends DefaultCodegen implements Codeg
|
||||
|
||||
@Override
|
||||
public void preprocessOpenAPI(OpenAPI openAPI) {
|
||||
URL url = URLPathUtils.getServerURL(openAPI);
|
||||
URL url = URLPathUtils.getServerURL(openAPI, serverVariableOverrides());
|
||||
String port = URLPathUtils.getPort(url, "");
|
||||
String host = url.getHost();
|
||||
if(!port.isEmpty()) {
|
||||
|
||||
@@ -38,6 +38,7 @@ public abstract class AbstractGoCodegen extends DefaultCodegen implements Codege
|
||||
|
||||
protected boolean withGoCodegenComment = false;
|
||||
protected boolean withXml = false;
|
||||
protected boolean enumClassPrefix = false;
|
||||
|
||||
protected String packageName = "openapi";
|
||||
|
||||
@@ -389,6 +390,11 @@ public abstract class AbstractGoCodegen extends DefaultCodegen implements Codege
|
||||
}
|
||||
}
|
||||
|
||||
// import "reflect" package if the parameter is collectionFormat=multi
|
||||
if (param.isCollectionFormatMulti) {
|
||||
imports.add(createMapping("import", "reflect"));
|
||||
}
|
||||
|
||||
// import "optionals" package if the parameter is optional
|
||||
if (!param.required) {
|
||||
if (!addedOptionalImport) {
|
||||
@@ -613,6 +619,10 @@ public abstract class AbstractGoCodegen extends DefaultCodegen implements Codege
|
||||
this.withXml = withXml;
|
||||
}
|
||||
|
||||
public void setEnumClassPrefix(boolean enumClassPrefix) {
|
||||
this.enumClassPrefix = enumClassPrefix;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toDefaultValue(Schema schema) {
|
||||
if (schema.getDefault() != null) {
|
||||
|
||||
@@ -417,6 +417,8 @@ public abstract class AbstractJavaCodegen extends DefaultCodegen implements Code
|
||||
importMapping.put("JsonTypeInfo", "com.fasterxml.jackson.annotation.JsonTypeInfo");
|
||||
importMapping.put("JsonCreator", "com.fasterxml.jackson.annotation.JsonCreator");
|
||||
importMapping.put("JsonValue", "com.fasterxml.jackson.annotation.JsonValue");
|
||||
importMapping.put("JsonIgnore", "com.fasterxml.jackson.annotation.JsonIgnore");
|
||||
importMapping.put("JsonInclude", "com.fasterxml.jackson.annotation.JsonInclude");
|
||||
importMapping.put("SerializedName", "com.google.gson.annotations.SerializedName");
|
||||
importMapping.put("TypeAdapter", "com.google.gson.TypeAdapter");
|
||||
importMapping.put("JsonAdapter", "com.google.gson.annotations.JsonAdapter");
|
||||
@@ -716,7 +718,6 @@ public abstract class AbstractJavaCodegen extends DefaultCodegen implements Code
|
||||
public String toDefaultValue(Schema p) {
|
||||
p = ModelUtils.getReferencedSchema(this.openAPI, p);
|
||||
if (ModelUtils.isArraySchema(p)) {
|
||||
final ArraySchema ap = (ArraySchema) p;
|
||||
final String pattern;
|
||||
if (fullJavaUtil) {
|
||||
pattern = "new java.util.ArrayList<%s>()";
|
||||
@@ -724,13 +725,15 @@ public abstract class AbstractJavaCodegen extends DefaultCodegen implements Code
|
||||
pattern = "new ArrayList<%s>()";
|
||||
}
|
||||
|
||||
if (ap.getItems() == null) {
|
||||
LOGGER.error("`{}` (array property) does not have a proper inner type defined. Default to type:string", ap.getName());
|
||||
Schema inner = new StringSchema().description("TODO default missing array inner type to string");
|
||||
ap.setItems(inner);
|
||||
Schema<?> items;
|
||||
if (p instanceof ArraySchema && ((ArraySchema) p).getItems() != null) {
|
||||
items = ((ArraySchema) p).getItems();
|
||||
} else {
|
||||
LOGGER.error("`{}` (array property) does not have a proper inner type defined. Default to type:string", p.getName());
|
||||
items = new StringSchema().description("TODO default missing array inner type to string");
|
||||
}
|
||||
|
||||
String typeDeclaration = getTypeDeclaration(ap.getItems());
|
||||
String typeDeclaration = getTypeDeclaration(items);
|
||||
Object java8obj = additionalProperties.get("java8");
|
||||
if (java8obj != null) {
|
||||
Boolean java8 = Boolean.valueOf(java8obj.toString());
|
||||
@@ -800,7 +803,13 @@ public abstract class AbstractJavaCodegen extends DefaultCodegen implements Code
|
||||
}
|
||||
}
|
||||
return null;
|
||||
} else if (ModelUtils.isObjectSchema(p)) {
|
||||
if (p.getDefault() != null) {
|
||||
return super.toDefaultValue(p);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
return super.toDefaultValue(p);
|
||||
}
|
||||
|
||||
|
||||
@@ -110,7 +110,7 @@ public abstract class AbstractJavaJAXRSServerCodegen extends AbstractJavaCodegen
|
||||
*/
|
||||
|
||||
if (!this.additionalProperties.containsKey(SERVER_PORT)) {
|
||||
URL url = URLPathUtils.getServerURL(openAPI);
|
||||
URL url = URLPathUtils.getServerURL(openAPI, serverVariableOverrides());
|
||||
// 8080 is the default value for a JEE Server:
|
||||
this.additionalProperties.put(SERVER_PORT, URLPathUtils.getPort(url, serverPort));
|
||||
}
|
||||
|
||||
@@ -612,6 +612,7 @@ public abstract class AbstractKotlinCodegen extends DefaultCodegen implements Co
|
||||
StringBuilder instantiationType = new StringBuilder(arrayType);
|
||||
Schema items = arr.getItems();
|
||||
String nestedType = getTypeDeclaration(items);
|
||||
additionalProperties.put("nestedType", nestedType);
|
||||
// TODO: We may want to differentiate here between generics and primitive arrays.
|
||||
instantiationType.append("<").append(nestedType).append(">");
|
||||
return instantiationType.toString();
|
||||
|
||||
@@ -268,7 +268,7 @@ public class AspNetCoreServerCodegen extends AbstractCSharpCodegen {
|
||||
@Override
|
||||
public void preprocessOpenAPI(OpenAPI openAPI) {
|
||||
super.preprocessOpenAPI(openAPI);
|
||||
URL url = URLPathUtils.getServerURL(openAPI);
|
||||
URL url = URLPathUtils.getServerURL(openAPI, serverVariableOverrides());
|
||||
additionalProperties.put("serverHost", url.getHost());
|
||||
additionalProperties.put("serverPort", URLPathUtils.getPort(url, 8080));
|
||||
}
|
||||
|
||||
@@ -0,0 +1,135 @@
|
||||
/*
|
||||
* Copyright 2019 OpenAPI-Generator Contributors (https://openapi-generator.tech)
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.openapitools.codegen.languages;
|
||||
|
||||
import org.openapitools.codegen.*;
|
||||
import org.openapitools.codegen.meta.GeneratorMetadata;
|
||||
import org.openapitools.codegen.meta.Stability;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashSet;
|
||||
import java.util.Map;
|
||||
|
||||
import static org.openapitools.codegen.utils.StringUtils.camelize;
|
||||
|
||||
public class AvroSchemaCodegen extends DefaultCodegen implements CodegenConfig {
|
||||
private static final String AVRO = "avro-schema";
|
||||
protected String packageName = "model";
|
||||
|
||||
public AvroSchemaCodegen() {
|
||||
super();
|
||||
|
||||
generatorMetadata = GeneratorMetadata.newBuilder(generatorMetadata)
|
||||
.stability(Stability.BETA)
|
||||
.build();
|
||||
|
||||
outputFolder = "generated-code/avro-schema";
|
||||
modelTemplateFiles.put("model.mustache", ".avsc");
|
||||
apiPackage = "api";
|
||||
modelPackage = "model";
|
||||
importMapping.clear();
|
||||
embeddedTemplateDir = templateDir = AVRO;
|
||||
|
||||
// default HIDE_GENERATION_TIMESTAMP to true
|
||||
hideGenerationTimestamp = Boolean.TRUE;
|
||||
|
||||
languageSpecificPrimitives = new HashSet<>(
|
||||
Arrays.asList("null", "boolean", "int", "integer", "long", "float", "double", "bytes", "string",
|
||||
"BigDecimal", "UUID", "number", "date", "DateTime")
|
||||
);
|
||||
defaultIncludes = new HashSet<>(languageSpecificPrimitives);
|
||||
|
||||
instantiationTypes.put("array", "Array");
|
||||
instantiationTypes.put("list", "Array");
|
||||
instantiationTypes.put("map", "Object");
|
||||
typeMapping.clear();
|
||||
typeMapping.put("number", "double");
|
||||
typeMapping.put("DateTime", "string");
|
||||
typeMapping.put("date", "string");
|
||||
typeMapping.put("short", "int");
|
||||
typeMapping.put("char", "string");
|
||||
typeMapping.put("integer", "int");
|
||||
typeMapping.put("ByteArray", "bytes");
|
||||
typeMapping.put("binary", "File");
|
||||
typeMapping.put("file", "File");
|
||||
typeMapping.put("UUID", "string");
|
||||
typeMapping.put("BigDecimal", "string");
|
||||
|
||||
cliOptions.add(new CliOption(CodegenConstants.PACKAGE_NAME, CodegenConstants.PACKAGE_NAME_DESC));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void processOpts() {
|
||||
super.processOpts();
|
||||
if (additionalProperties.containsKey(CodegenConstants.PACKAGE_NAME)) {
|
||||
packageName = (String) additionalProperties.get(CodegenConstants.PACKAGE_NAME);
|
||||
}
|
||||
|
||||
additionalProperties.put("packageName", packageName);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public CodegenType getTag() {
|
||||
return CodegenType.SCHEMA;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "avro-schema";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getHelp() {
|
||||
return "Generates a Avro model (beta).";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String modelFileFolder() {
|
||||
return outputFolder + File.separator;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Object> postProcessModels(Map<String, Object> objs) {
|
||||
return postProcessModelsEnum(objs);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void setNonArrayMapProperty(CodegenProperty property, String type) {
|
||||
super.setNonArrayMapProperty(property, type);
|
||||
if (property.isModel) {
|
||||
property.dataType = camelize(modelNamePrefix + property.dataType + modelNameSuffix);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String escapeUnsafeCharacters(String input) {
|
||||
// do nothing as it's a schema conversion
|
||||
return input;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String escapeQuotationMark(String input) {
|
||||
// do nothing as it's a schema conversion
|
||||
return input;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -359,7 +359,7 @@ public class CSharpNancyFXServerCodegen extends AbstractCSharpCodegen {
|
||||
|
||||
@Override
|
||||
public void preprocessOpenAPI(final OpenAPI openAPI) {
|
||||
URL url = URLPathUtils.getServerURL(openAPI);
|
||||
URL url = URLPathUtils.getServerURL(openAPI, serverVariableOverrides());
|
||||
String path = URLPathUtils.getPath(url, "/");
|
||||
final String packageContextOption = (String) additionalProperties.get(PACKAGE_CONTEXT);
|
||||
additionalProperties.put("packageContext", packageContextOption == null ? sanitizeName(path) : packageContextOption);
|
||||
|
||||
@@ -65,7 +65,7 @@ public class CSharpNetCoreClientCodegen extends AbstractCSharpCodegen {
|
||||
protected String modelDocPath = "docs/";
|
||||
|
||||
// Defines TargetFrameworkVersion in csproj files
|
||||
protected String targetFramework = defaultFramework.dotNetFrameworkVersion;
|
||||
protected String targetFramework = defaultFramework.name;
|
||||
|
||||
// Defines nuget identifiers for target framework
|
||||
protected String targetFrameworkNuget = targetFramework;
|
||||
@@ -78,6 +78,8 @@ public class CSharpNetCoreClientCodegen extends AbstractCSharpCodegen {
|
||||
// By default, generated code is considered public
|
||||
protected boolean nonPublicApi = Boolean.FALSE;
|
||||
|
||||
protected boolean caseInsensitiveResponseHeaders = Boolean.FALSE;
|
||||
|
||||
public CSharpNetCoreClientCodegen() {
|
||||
super();
|
||||
|
||||
@@ -206,6 +208,10 @@ public class CSharpNetCoreClientCodegen extends AbstractCSharpCodegen {
|
||||
CodegenConstants.VALIDATABLE_DESC,
|
||||
this.validatable);
|
||||
|
||||
addSwitch(CodegenConstants.CASE_INSENSITIVE_RESPONSE_HEADERS,
|
||||
CodegenConstants.CASE_INSENSITIVE_RESPONSE_HEADERS_DESC,
|
||||
this.caseInsensitiveResponseHeaders);
|
||||
|
||||
regexModifiers = new HashMap<>();
|
||||
regexModifiers.put('i', "IgnoreCase");
|
||||
regexModifiers.put('m', "Multiline");
|
||||
@@ -470,7 +476,7 @@ public class CSharpNetCoreClientCodegen extends AbstractCSharpCodegen {
|
||||
}
|
||||
clientPackage = "Client";
|
||||
|
||||
String framework = (String) additionalProperties.getOrDefault(CodegenConstants.DOTNET_FRAMEWORK, defaultFramework.dotNetFrameworkVersion);
|
||||
String framework = (String) additionalProperties.getOrDefault(CodegenConstants.DOTNET_FRAMEWORK, defaultFramework.name);
|
||||
FrameworkStrategy strategy = defaultFramework;
|
||||
for (FrameworkStrategy frameworkStrategy : frameworkStrategies) {
|
||||
if (framework.equals(frameworkStrategy.name)) {
|
||||
@@ -481,7 +487,7 @@ public class CSharpNetCoreClientCodegen extends AbstractCSharpCodegen {
|
||||
strategy.configureAdditionalProperties(additionalProperties);
|
||||
|
||||
setTargetFrameworkNuget(strategy.getNugetFrameworkIdentifier());
|
||||
setTargetFramework(strategy.dotNetFrameworkVersion);
|
||||
setTargetFramework(strategy.name);
|
||||
|
||||
if (strategy != FrameworkStrategy.NETSTANDARD_2_0) {
|
||||
LOGGER.warn("If using built-in templates-RestSharp only supports netstandard 2.0 or later.");
|
||||
@@ -640,6 +646,10 @@ public class CSharpNetCoreClientCodegen extends AbstractCSharpCodegen {
|
||||
this.validatable = validatable;
|
||||
}
|
||||
|
||||
public void setCaseInsensitiveResponseHeaders(final Boolean caseInsensitiveResponseHeaders) {
|
||||
this.caseInsensitiveResponseHeaders = caseInsensitiveResponseHeaders;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toEnumVarName(String value, String datatype) {
|
||||
if (value.length() == 0) {
|
||||
@@ -800,7 +810,7 @@ public class CSharpNetCoreClientCodegen extends AbstractCSharpCodegen {
|
||||
}
|
||||
|
||||
protected void configureAdditionalProperties(final Map<String, Object> properties) {
|
||||
properties.putIfAbsent(CodegenConstants.DOTNET_FRAMEWORK, this.dotNetFrameworkVersion);
|
||||
properties.putIfAbsent(CodegenConstants.DOTNET_FRAMEWORK, this.name);
|
||||
|
||||
// not intended to be user-settable
|
||||
properties.put(TARGET_FRAMEWORK_IDENTIFIER, this.getTargetFrameworkIdentifier());
|
||||
|
||||
@@ -118,13 +118,13 @@ public class DartClientCodegen extends DefaultCodegen implements CodegenConfig {
|
||||
typeMapping.put("URI", "String");
|
||||
typeMapping.put("ByteArray", "String");
|
||||
|
||||
cliOptions.add(new CliOption(BROWSER_CLIENT, "Is the client browser based"));
|
||||
cliOptions.add(new CliOption(BROWSER_CLIENT, "Is the client browser based (for Dart 1.x only)"));
|
||||
cliOptions.add(new CliOption(PUB_NAME, "Name in generated pubspec"));
|
||||
cliOptions.add(new CliOption(PUB_VERSION, "Version in generated pubspec"));
|
||||
cliOptions.add(new CliOption(PUB_DESCRIPTION, "Description in generated pubspec"));
|
||||
cliOptions.add(new CliOption(USE_ENUM_EXTENSION, "Allow the 'x-enum-values' extension for enums"));
|
||||
cliOptions.add(new CliOption(CodegenConstants.SOURCE_FOLDER, "source folder for generated code"));
|
||||
cliOptions.add(CliOption.newBoolean(SUPPORT_DART2, "support dart2").defaultValue(Boolean.TRUE.toString()));
|
||||
cliOptions.add(new CliOption(CodegenConstants.SOURCE_FOLDER, "Source folder for generated code"));
|
||||
cliOptions.add(CliOption.newBoolean(SUPPORT_DART2, "Support Dart 2.x").defaultValue(Boolean.TRUE.toString()));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -23,20 +23,14 @@ import org.openapitools.codegen.CodegenConstants;
|
||||
import org.openapitools.codegen.CodegenOperation;
|
||||
import org.openapitools.codegen.CodegenType;
|
||||
import org.openapitools.codegen.SupportingFile;
|
||||
import org.openapitools.codegen.CodegenModel;
|
||||
import org.openapitools.codegen.CodegenProperty;
|
||||
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.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.List;
|
||||
import java.util.ArrayList;
|
||||
|
||||
import static java.util.UUID.randomUUID;
|
||||
|
||||
@@ -165,7 +159,7 @@ public class FsharpGiraffeServerCodegen extends AbstractFSharpCodegen {
|
||||
@Override
|
||||
public void preprocessOpenAPI(OpenAPI openAPI) {
|
||||
super.preprocessOpenAPI(openAPI);
|
||||
URL url = URLPathUtils.getServerURL(openAPI);
|
||||
URL url = URLPathUtils.getServerURL(openAPI, serverVariableOverrides());
|
||||
additionalProperties.put("serverHost", url.getHost());
|
||||
additionalProperties.put("serverPort", URLPathUtils.getPort(url, 8080));
|
||||
}
|
||||
|
||||
@@ -55,7 +55,7 @@ public class GoClientCodegen extends AbstractGoCodegen {
|
||||
cliOptions.add(CliOption.newBoolean(CodegenConstants.IS_GO_SUBMODULE, CodegenConstants.IS_GO_SUBMODULE_DESC));
|
||||
cliOptions.add(CliOption.newBoolean(WITH_GO_CODEGEN_COMMENT, "whether to include Go codegen comment to disable Go Lint and collapse by default GitHub in PRs and diffs"));
|
||||
cliOptions.add(CliOption.newBoolean(WITH_XML, "whether to include support for application/xml content type and include XML annotations in the model (works with libraries that provide support for JSON and XML)"));
|
||||
|
||||
cliOptions.add(CliOption.newBoolean(CodegenConstants.ENUM_CLASS_PREFIX, CodegenConstants.ENUM_CLASS_PREFIX_DESC));
|
||||
|
||||
// option to change the order of form/body parameter
|
||||
cliOptions.add(CliOption.newBoolean(
|
||||
@@ -114,6 +114,13 @@ public class GoClientCodegen extends AbstractGoCodegen {
|
||||
}
|
||||
}
|
||||
|
||||
if (additionalProperties.containsKey(CodegenConstants.ENUM_CLASS_PREFIX)) {
|
||||
setEnumClassPrefix(Boolean.parseBoolean(additionalProperties.get(CodegenConstants.ENUM_CLASS_PREFIX).toString()));
|
||||
if (enumClassPrefix) {
|
||||
additionalProperties.put(CodegenConstants.ENUM_CLASS_PREFIX, "true");
|
||||
}
|
||||
}
|
||||
|
||||
if (additionalProperties.containsKey(CodegenConstants.IS_GO_SUBMODULE)) {
|
||||
setIsGoSubmodule(Boolean.parseBoolean(additionalProperties.get(CodegenConstants.IS_GO_SUBMODULE).toString()));
|
||||
if (isGoSubmodule) {
|
||||
|
||||
@@ -19,6 +19,8 @@ package org.openapitools.codegen.languages;
|
||||
import org.openapitools.codegen.CodegenModel;
|
||||
import org.openapitools.codegen.CodegenProperty;
|
||||
import org.openapitools.codegen.SupportingFile;
|
||||
import org.openapitools.codegen.meta.GeneratorMetadata;
|
||||
import org.openapitools.codegen.meta.Stability;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
@@ -33,6 +35,10 @@ public class GoClientExperimentalCodegen extends GoClientCodegen {
|
||||
super();
|
||||
outputFolder = "generated-code/go-experimental";
|
||||
embeddedTemplateDir = templateDir = "go-experimental";
|
||||
|
||||
generatorMetadata = GeneratorMetadata.newBuilder(generatorMetadata)
|
||||
.stability(Stability.EXPERIMENTAL)
|
||||
.build();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -1065,13 +1065,14 @@ public class HaskellHttpClientCodegen extends DefaultCodegen implements CodegenC
|
||||
case "tsv":
|
||||
return "TabSeparated";
|
||||
case "ssv":
|
||||
case "space":
|
||||
return "SpaceSeparated";
|
||||
case "pipes":
|
||||
return "PipeSeparated";
|
||||
case "multi":
|
||||
return "MultiParamArray";
|
||||
default:
|
||||
throw new UnsupportedOperationException();
|
||||
throw new UnsupportedOperationException(collectionFormat + " (collection format) not supported");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -549,6 +549,7 @@ public class HaskellServantCodegen extends DefaultCodegen implements CodegenConf
|
||||
return "(QueryList 'CommaSeparated (" + type + "))";
|
||||
case "tsv":
|
||||
return "(QueryList 'TabSeparated (" + type + "))";
|
||||
case "space":
|
||||
case "ssv":
|
||||
return "(QueryList 'SpaceSeparated (" + type + "))";
|
||||
case "pipes":
|
||||
@@ -556,7 +557,7 @@ public class HaskellServantCodegen extends DefaultCodegen implements CodegenConf
|
||||
case "multi":
|
||||
return "(QueryList 'MultiParamArray (" + type + "))";
|
||||
default:
|
||||
throw new UnsupportedOperationException();
|
||||
throw new UnsupportedOperationException(collectionFormat + " (collection format) not supported");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -24,6 +24,7 @@ import org.openapitools.codegen.languages.features.BeanValidationFeatures;
|
||||
import org.openapitools.codegen.languages.features.GzipFeatures;
|
||||
import org.openapitools.codegen.languages.features.PerformBeanValidationFeatures;
|
||||
import org.openapitools.codegen.templating.mustache.CaseFormatLambda;
|
||||
import org.openapitools.codegen.utils.ModelUtils;
|
||||
import org.openapitools.codegen.utils.ProcessUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
@@ -77,6 +78,10 @@ public class JavaClientCodegen extends AbstractJavaCodegen
|
||||
public static final String RETROFIT_2 = "retrofit2";
|
||||
public static final String VERTX = "vertx";
|
||||
|
||||
public static final String SERIALIZATION_LIBRARY = "serializationLibrary";
|
||||
public static final String SERIALIZATION_LIBRARY_GSON = "gson";
|
||||
public static final String SERIALIZATION_LIBRARY_JACKSON = "jackson";
|
||||
|
||||
protected String gradleWrapperPackage = "gradle.wrapper";
|
||||
protected boolean useRxJava = false;
|
||||
protected boolean useRxJava2 = false;
|
||||
@@ -94,6 +99,8 @@ public class JavaClientCodegen extends AbstractJavaCodegen
|
||||
protected boolean useReflectionEqualsHashCode = false;
|
||||
protected boolean caseInsensitiveResponseHeaders = false;
|
||||
protected String authFolder;
|
||||
protected String serializationLibrary = null;
|
||||
|
||||
|
||||
public JavaClientCodegen() {
|
||||
super();
|
||||
@@ -127,7 +134,6 @@ public class JavaClientCodegen extends AbstractJavaCodegen
|
||||
cliOptions.add(CliOption.newBoolean(USE_REFLECTION_EQUALS_HASHCODE, "Use org.apache.commons.lang3.builder for equals and hashCode in the models. WARNING: This will fail under a security manager, unless the appropriate permissions are set up correctly and also there's potential performance impact."));
|
||||
cliOptions.add(CliOption.newBoolean(CASE_INSENSITIVE_RESPONSE_HEADERS, "Make API response's headers case-insensitive. Available on " + OKHTTP_GSON + ", " + JERSEY2 + " libraries"));
|
||||
|
||||
|
||||
supportedLibraries.put(JERSEY1, "HTTP client: Jersey client 1.19.x. JSON processing: Jackson 2.8.x. Enable Java6 support using '-DsupportJava6=true'. Enable gzip request encoding using '-DuseGzipFeature=true'. IMPORTANT NOTE: jersey 1.x is no longer actively maintained so please upgrade to 'jersey2' or other HTTP libaries instead.");
|
||||
supportedLibraries.put(JERSEY2, "HTTP client: Jersey client 2.25.1. JSON processing: Jackson 2.8.x");
|
||||
supportedLibraries.put(FEIGN, "HTTP client: OpenFeign 9.x or 10.x. JSON processing: Jackson 2.8.x. To enable OpenFeign 10.x, set the 'feignVersion' option to '10.x'");
|
||||
@@ -149,6 +155,12 @@ public class JavaClientCodegen extends AbstractJavaCodegen
|
||||
cliOptions.add(libraryOption);
|
||||
setLibrary(OKHTTP_GSON);
|
||||
|
||||
CliOption serializationLibrary = new CliOption(SERIALIZATION_LIBRARY, "Serialization library, default depends from the library");
|
||||
Map<String, String> serializationOptions = new HashMap<>();
|
||||
serializationOptions.put(SERIALIZATION_LIBRARY_GSON, "Use Gson as serialization library");
|
||||
serializationOptions.put(SERIALIZATION_LIBRARY_JACKSON, "Use Jackson as serialization library");
|
||||
serializationLibrary.setEnum(serializationOptions);
|
||||
cliOptions.add(serializationLibrary);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -283,6 +295,10 @@ public class JavaClientCodegen extends AbstractJavaCodegen
|
||||
"BeanValidationException.java"));
|
||||
}
|
||||
|
||||
if (additionalProperties.containsKey(SERIALIZATION_LIBRARY)) {
|
||||
setSerializationLibrary(additionalProperties.get(SERIALIZATION_LIBRARY).toString());
|
||||
}
|
||||
|
||||
//TODO: add doc to retrofit1 and feign
|
||||
if (FEIGN.equals(getLibrary()) || RETROFIT_1.equals(getLibrary())) {
|
||||
modelDocTemplateFiles.remove("model_doc.mustache");
|
||||
@@ -300,7 +316,7 @@ public class JavaClientCodegen extends AbstractJavaCodegen
|
||||
}
|
||||
|
||||
if (FEIGN.equals(getLibrary())) {
|
||||
additionalProperties.put("jackson", "true");
|
||||
forceSerializationLibrary(SERIALIZATION_LIBRARY_JACKSON);
|
||||
supportingFiles.add(new SupportingFile("ParamExpander.mustache", invokerFolder, "ParamExpander.java"));
|
||||
supportingFiles.add(new SupportingFile("EncodingUtils.mustache", invokerFolder, "EncodingUtils.java"));
|
||||
} else if (OKHTTP_GSON.equals(getLibrary()) || StringUtils.isEmpty(getLibrary())) {
|
||||
@@ -315,48 +331,48 @@ public class JavaClientCodegen extends AbstractJavaCodegen
|
||||
// NOTE: below moved to postProcessOpoerationsWithModels
|
||||
//supportingFiles.add(new SupportingFile("auth/OAuthOkHttpClient.mustache", authFolder, "OAuthOkHttpClient.java"));
|
||||
//supportingFiles.add(new SupportingFile("auth/RetryingOAuth.mustache", authFolder, "RetryingOAuth.java"));
|
||||
additionalProperties.put("gson", "true");
|
||||
forceSerializationLibrary(SERIALIZATION_LIBRARY_GSON);
|
||||
} else if (usesAnyRetrofitLibrary()) {
|
||||
supportingFiles.add(new SupportingFile("auth/OAuthOkHttpClient.mustache", authFolder, "OAuthOkHttpClient.java"));
|
||||
supportingFiles.add(new SupportingFile("CollectionFormats.mustache", invokerFolder, "CollectionFormats.java"));
|
||||
additionalProperties.put("gson", "true");
|
||||
forceSerializationLibrary(SERIALIZATION_LIBRARY_GSON);
|
||||
if ("retrofit2".equals(getLibrary()) && !usePlayWS) {
|
||||
supportingFiles.add(new SupportingFile("JSON.mustache", invokerFolder, "JSON.java"));
|
||||
}
|
||||
} else if (JERSEY2.equals(getLibrary())) {
|
||||
supportingFiles.add(new SupportingFile("JSON.mustache", invokerFolder, "JSON.java"));
|
||||
supportingFiles.add(new SupportingFile("ApiResponse.mustache", invokerFolder, "ApiResponse.java"));
|
||||
additionalProperties.put("jackson", "true");
|
||||
forceSerializationLibrary(SERIALIZATION_LIBRARY_JACKSON);
|
||||
} else if (NATIVE.equals(getLibrary())) {
|
||||
setJava8Mode(true);
|
||||
additionalProperties.put("java8", "true");
|
||||
additionalProperties.put("jackson", "true");
|
||||
forceSerializationLibrary(SERIALIZATION_LIBRARY_JACKSON);
|
||||
} else if (RESTEASY.equals(getLibrary())) {
|
||||
supportingFiles.add(new SupportingFile("JSON.mustache", invokerFolder, "JSON.java"));
|
||||
additionalProperties.put("jackson", "true");
|
||||
forceSerializationLibrary(SERIALIZATION_LIBRARY_JACKSON);
|
||||
} else if (JERSEY1.equals(getLibrary())) {
|
||||
additionalProperties.put("jackson", "true");
|
||||
forceSerializationLibrary(SERIALIZATION_LIBRARY_JACKSON);
|
||||
} else if (RESTTEMPLATE.equals(getLibrary())) {
|
||||
additionalProperties.put("jackson", "true");
|
||||
forceSerializationLibrary(SERIALIZATION_LIBRARY_JACKSON);
|
||||
supportingFiles.add(new SupportingFile("auth/Authentication.mustache", authFolder, "Authentication.java"));
|
||||
} else if (WEBCLIENT.equals(getLibrary())) {
|
||||
setJava8Mode(true);
|
||||
additionalProperties.put("java8", "true");
|
||||
additionalProperties.put("jackson", "true");
|
||||
forceSerializationLibrary(SERIALIZATION_LIBRARY_JACKSON);
|
||||
} else if (VERTX.equals(getLibrary())) {
|
||||
typeMapping.put("file", "AsyncFile");
|
||||
importMapping.put("AsyncFile", "io.vertx.core.file.AsyncFile");
|
||||
setJava8Mode(true);
|
||||
additionalProperties.put("java8", "true");
|
||||
additionalProperties.put("jackson", "true");
|
||||
forceSerializationLibrary(SERIALIZATION_LIBRARY_JACKSON);
|
||||
apiTemplateFiles.put("apiImpl.mustache", "Impl.java");
|
||||
apiTemplateFiles.put("rxApiImpl.mustache", ".java");
|
||||
supportingFiles.remove(new SupportingFile("manifest.mustache", projectFolder, "AndroidManifest.xml"));
|
||||
} else if (GOOGLE_API_CLIENT.equals(getLibrary())) {
|
||||
additionalProperties.put("jackson", "true");
|
||||
forceSerializationLibrary(SERIALIZATION_LIBRARY_JACKSON);
|
||||
|
||||
} else if (REST_ASSURED.equals(getLibrary())) {
|
||||
additionalProperties.put("gson", "true");
|
||||
forceSerializationLibrary(SERIALIZATION_LIBRARY_GSON);
|
||||
additionalProperties.put("convert", new CaseFormatLambda(LOWER_CAMEL, UPPER_UNDERSCORE));
|
||||
apiTemplateFiles.put("api.mustache", ".java");
|
||||
supportingFiles.add(new SupportingFile("ResponseSpecBuilders.mustache", invokerFolder, "ResponseSpecBuilders.java"));
|
||||
@@ -414,16 +430,30 @@ public class JavaClientCodegen extends AbstractJavaCodegen
|
||||
supportingFiles.add(new SupportingFile("auth/Authentication.mustache", authFolder, "Authentication.java"));
|
||||
supportingFiles.add(new SupportingFile("Pair.mustache", invokerFolder, "Pair.java"));
|
||||
|
||||
additionalProperties.put("jackson", "true");
|
||||
additionalProperties.remove("gson");
|
||||
forceSerializationLibrary(SERIALIZATION_LIBRARY_JACKSON);
|
||||
}
|
||||
|
||||
if (additionalProperties.containsKey("jackson") && !NATIVE.equals(getLibrary())) {
|
||||
if(getSerializationLibrary() == null) {
|
||||
LOGGER.info("No serializationLibrary configured, using '"+SERIALIZATION_LIBRARY_GSON+"' as fallback");
|
||||
setSerializationLibrary(SERIALIZATION_LIBRARY_GSON);
|
||||
}
|
||||
if(SERIALIZATION_LIBRARY_JACKSON.equals(getSerializationLibrary())) {
|
||||
additionalProperties.put(SERIALIZATION_LIBRARY_JACKSON, "true");
|
||||
additionalProperties.remove(SERIALIZATION_LIBRARY_GSON);
|
||||
if (!NATIVE.equals(getLibrary())) {
|
||||
supportingFiles.add(new SupportingFile("RFC3339DateFormat.mustache", invokerFolder, "RFC3339DateFormat.java"));
|
||||
if ("threetenbp".equals(dateLibrary) && !usePlayWS) {
|
||||
supportingFiles.add(new SupportingFile("CustomInstantDeserializer.mustache", invokerFolder, "CustomInstantDeserializer.java"));
|
||||
}
|
||||
}
|
||||
} else if (SERIALIZATION_LIBRARY_GSON.equals(getSerializationLibrary())) {
|
||||
additionalProperties.put(SERIALIZATION_LIBRARY_GSON, "true");
|
||||
additionalProperties.remove(SERIALIZATION_LIBRARY_JACKSON);
|
||||
} else {
|
||||
additionalProperties.remove(SERIALIZATION_LIBRARY_JACKSON);
|
||||
additionalProperties.remove(SERIALIZATION_LIBRARY_GSON);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private boolean usesAnyRetrofitLibrary() {
|
||||
@@ -580,11 +610,12 @@ public class JavaClientCodegen extends AbstractJavaCodegen
|
||||
if (!BooleanUtils.toBoolean(model.isEnum)) {
|
||||
//final String lib = getLibrary();
|
||||
//Needed imports for Jackson based libraries
|
||||
if (additionalProperties.containsKey("jackson")) {
|
||||
if (additionalProperties.containsKey(SERIALIZATION_LIBRARY_JACKSON)) {
|
||||
model.imports.add("JsonProperty");
|
||||
model.imports.add("JsonValue");
|
||||
model.imports.add("JsonInclude");
|
||||
}
|
||||
if (additionalProperties.containsKey("gson")) {
|
||||
if (additionalProperties.containsKey(SERIALIZATION_LIBRARY_GSON)) {
|
||||
model.imports.add("SerializedName");
|
||||
model.imports.add("TypeAdapter");
|
||||
model.imports.add("JsonAdapter");
|
||||
@@ -594,7 +625,7 @@ public class JavaClientCodegen extends AbstractJavaCodegen
|
||||
}
|
||||
} else { // enum class
|
||||
//Needed imports for Jackson's JsonCreator
|
||||
if (additionalProperties.containsKey("jackson")) {
|
||||
if (additionalProperties.containsKey(SERIALIZATION_LIBRARY_JACKSON)) {
|
||||
model.imports.add("JsonValue");
|
||||
model.imports.add("JsonCreator");
|
||||
}
|
||||
@@ -605,7 +636,7 @@ public class JavaClientCodegen extends AbstractJavaCodegen
|
||||
public Map<String, Object> postProcessModelsEnum(Map<String, Object> objs) {
|
||||
objs = super.postProcessModelsEnum(objs);
|
||||
//Needed import for Gson based libraries
|
||||
if (additionalProperties.containsKey("gson")) {
|
||||
if (additionalProperties.containsKey(SERIALIZATION_LIBRARY_GSON)) {
|
||||
List<Map<String, String>> imports = (List<Map<String, String>>) objs.get("imports");
|
||||
List<Object> models = (List<Object>) objs.get("models");
|
||||
for (Object _mo : models) {
|
||||
@@ -623,6 +654,39 @@ public class JavaClientCodegen extends AbstractJavaCodegen
|
||||
return objs;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Object> postProcessModels(Map<String, Object> objs) {
|
||||
objs = super.postProcessModels(objs);
|
||||
if (additionalProperties.containsKey(SERIALIZATION_LIBRARY_JACKSON) && !JERSEY1.equals(getLibrary())) {
|
||||
List<Map<String, String>> imports = (List<Map<String, String>>) objs.get("imports");
|
||||
List<Object> models = (List<Object>) objs.get("models");
|
||||
for (Object _mo : models) {
|
||||
Map<String, Object> mo = (Map<String, Object>) _mo;
|
||||
CodegenModel cm = (CodegenModel) mo.get("model");
|
||||
boolean addImports = false;
|
||||
for (CodegenProperty var : cm.vars) {
|
||||
boolean isOptionalNullable = Boolean.FALSE.equals(var.required) && Boolean.TRUE.equals(var.isNullable);
|
||||
// only add JsonNullable and related imports to optional and nullable values
|
||||
addImports |= isOptionalNullable;
|
||||
var.getVendorExtensions().put("isJacksonOptionalNullable", isOptionalNullable);
|
||||
}
|
||||
if (addImports) {
|
||||
cm.imports.add("JsonNullable");
|
||||
Map<String, String> itemJsonNullable = new HashMap<String, String>();
|
||||
itemJsonNullable.put("import", "org.openapitools.jackson.nullable.JsonNullable");
|
||||
imports.add(itemJsonNullable);
|
||||
|
||||
cm.imports.add("NoSuchElementException");
|
||||
Map<String, String> itemExc = new HashMap<String, String>();
|
||||
itemExc.put("import", "java.util.NoSuchElementException");
|
||||
imports.add(itemExc);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return objs;
|
||||
}
|
||||
|
||||
public void setUseRxJava(boolean useRxJava) {
|
||||
this.useRxJava = useRxJava;
|
||||
doNotUseRx = false;
|
||||
@@ -677,6 +741,31 @@ public class JavaClientCodegen extends AbstractJavaCodegen
|
||||
this.caseInsensitiveResponseHeaders = caseInsensitiveResponseHeaders;
|
||||
}
|
||||
|
||||
/**
|
||||
* Serialization library.
|
||||
* @return 'gson' or 'jackson'
|
||||
*/
|
||||
public String getSerializationLibrary() {
|
||||
return serializationLibrary;
|
||||
}
|
||||
|
||||
public void setSerializationLibrary(String serializationLibrary) {
|
||||
if(SERIALIZATION_LIBRARY_JACKSON.equalsIgnoreCase(serializationLibrary)) {
|
||||
this.serializationLibrary = SERIALIZATION_LIBRARY_JACKSON;
|
||||
} else if(SERIALIZATION_LIBRARY_GSON.equalsIgnoreCase(serializationLibrary)) {
|
||||
this.serializationLibrary = SERIALIZATION_LIBRARY_GSON;
|
||||
} else {
|
||||
throw new IllegalArgumentException("Unexpected serializationLibrary value: " + serializationLibrary);
|
||||
}
|
||||
}
|
||||
|
||||
public void forceSerializationLibrary(String serializationLibrary) {
|
||||
if((this.serializationLibrary != null) && !this.serializationLibrary.equalsIgnoreCase(serializationLibrary)) {
|
||||
LOGGER.warn("The configured serializationLibrary '" + this.serializationLibrary + "', is not supported by the library: '" + getLibrary() + "', switching back to: " + serializationLibrary);
|
||||
}
|
||||
setSerializationLibrary(serializationLibrary);
|
||||
}
|
||||
|
||||
final private static Pattern JSON_MIME_PATTERN = Pattern.compile("(?i)application\\/json(;.*)?");
|
||||
final private static Pattern JSON_VENDOR_MIME_PATTERN = Pattern.compile("(?i)application\\/vnd.(.*)+json(;.*)?");
|
||||
|
||||
|
||||
@@ -538,7 +538,7 @@ public class JavaPKMSTServerCodegen extends AbstractJavaCodegen {
|
||||
additionalProperties.put(TITLE, this.title);
|
||||
}
|
||||
|
||||
URL url = URLPathUtils.getServerURL(openAPI);
|
||||
URL url = URLPathUtils.getServerURL(openAPI, serverVariableOverrides());
|
||||
this.additionalProperties.put("serverPort", URLPathUtils.getPort(url, 8080));
|
||||
|
||||
if (openAPI.getPaths() != null) {
|
||||
|
||||
@@ -221,7 +221,7 @@ public class JavaVertXServerCodegen extends AbstractJavaCodegen {
|
||||
super.preprocessOpenAPI(openAPI);
|
||||
|
||||
// add server port from the swagger file, 8080 by default
|
||||
URL url = URLPathUtils.getServerURL(openAPI);
|
||||
URL url = URLPathUtils.getServerURL(openAPI, serverVariableOverrides());
|
||||
this.additionalProperties.put("serverPort", URLPathUtils.getPort(url, 8080));
|
||||
|
||||
// retrieve api version from swagger file, 1.0.0-SNAPSHOT by default
|
||||
|
||||
@@ -149,6 +149,7 @@ public class KotlinClientCodegen extends AbstractKotlinCodegen {
|
||||
if (CollectionType.LIST.value.equals(collectionType)) {
|
||||
typeMapping.put("array", "kotlin.collections.List");
|
||||
typeMapping.put("list", "kotlin.collections.List");
|
||||
additionalProperties.put("isList", true);
|
||||
}
|
||||
|
||||
supportingFiles.add(new SupportingFile("README.mustache", "", "README.md"));
|
||||
|
||||
@@ -407,7 +407,7 @@ public class KotlinSpringServerCodegen extends AbstractKotlinCodegen
|
||||
}
|
||||
|
||||
if (!additionalProperties.containsKey(SERVER_PORT)) {
|
||||
URL url = URLPathUtils.getServerURL(openAPI);
|
||||
URL url = URLPathUtils.getServerURL(openAPI, serverVariableOverrides());
|
||||
this.additionalProperties.put(SERVER_PORT, URLPathUtils.getPort(url, 8080));
|
||||
}
|
||||
|
||||
|
||||
@@ -300,7 +300,7 @@ public class NodeJSExpressServerCodegen extends DefaultCodegen implements Codege
|
||||
|
||||
@Override
|
||||
public void preprocessOpenAPI(OpenAPI openAPI) {
|
||||
URL url = URLPathUtils.getServerURL(openAPI);
|
||||
URL url = URLPathUtils.getServerURL(openAPI, serverVariableOverrides());
|
||||
String host = URLPathUtils.getProtocolAndHost(url);
|
||||
String port = URLPathUtils.getPort(url, defaultServerPort) ;
|
||||
String basePath = url.getPath();
|
||||
|
||||
@@ -358,7 +358,7 @@ public class NodeJSServerCodegen extends DefaultCodegen implements CodegenConfig
|
||||
|
||||
@Override
|
||||
public void preprocessOpenAPI(OpenAPI openAPI) {
|
||||
URL url = URLPathUtils.getServerURL(openAPI);
|
||||
URL url = URLPathUtils.getServerURL(openAPI, serverVariableOverrides());
|
||||
String host = URLPathUtils.getProtocolAndHost(url);
|
||||
String port = URLPathUtils.getPort(url, defaultServerPort) ;
|
||||
String basePath = url.getPath();
|
||||
|
||||
@@ -17,13 +17,13 @@
|
||||
|
||||
package org.openapitools.codegen.languages;
|
||||
|
||||
import io.swagger.v3.core.util.Json;
|
||||
import io.swagger.v3.oas.models.OpenAPI;
|
||||
import org.apache.commons.io.FileUtils;
|
||||
import org.openapitools.codegen.CodegenConfig;
|
||||
import org.openapitools.codegen.CodegenType;
|
||||
import org.openapitools.codegen.DefaultCodegen;
|
||||
import org.openapitools.codegen.SupportingFile;
|
||||
import org.openapitools.codegen.serializer.SerializerUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
@@ -58,11 +58,11 @@ public class OpenAPIGenerator extends DefaultCodegen implements CodegenConfig {
|
||||
|
||||
@Override
|
||||
public void processOpenAPI(OpenAPI openAPI) {
|
||||
String swaggerString = Json.pretty(openAPI);
|
||||
String jsonOpenAPI = SerializerUtils.toJsonString(openAPI);
|
||||
|
||||
try {
|
||||
String outputFile = outputFolder + File.separator + "openapi.json";
|
||||
FileUtils.writeStringToFile(new File(outputFile), swaggerString);
|
||||
FileUtils.writeStringToFile(new File(outputFile), jsonOpenAPI);
|
||||
LOGGER.info("wrote file to " + outputFile);
|
||||
} catch (Exception e) {
|
||||
LOGGER.error(e.getMessage(), e);
|
||||
|
||||
@@ -18,6 +18,9 @@ package org.openapitools.codegen.languages;
|
||||
|
||||
import java.text.DateFormat;
|
||||
import java.text.SimpleDateFormat;
|
||||
|
||||
import org.openapitools.codegen.meta.GeneratorMetadata;
|
||||
import org.openapitools.codegen.meta.Stability;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
@@ -39,6 +42,10 @@ public class PythonClientExperimentalCodegen extends PythonClientCodegen {
|
||||
apiTemplateFiles.put("python-experimental/api.mustache", ".py");
|
||||
modelDocTemplateFiles.put("python-experimental/model_doc.mustache", ".md");
|
||||
modelTemplateFiles.put("python-experimental/model.mustache", ".py");
|
||||
|
||||
generatorMetadata = GeneratorMetadata.newBuilder(generatorMetadata)
|
||||
.stability(Stability.EXPERIMENTAL)
|
||||
.build();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -24,9 +24,7 @@ import io.swagger.v3.oas.models.info.Info;
|
||||
import io.swagger.v3.oas.models.media.ArraySchema;
|
||||
import io.swagger.v3.oas.models.media.FileSchema;
|
||||
import io.swagger.v3.oas.models.media.Schema;
|
||||
import io.swagger.v3.oas.models.media.StringSchema;
|
||||
import io.swagger.v3.oas.models.media.XML;
|
||||
import io.swagger.v3.oas.models.parameters.Parameter;
|
||||
import io.swagger.v3.oas.models.parameters.RequestBody;
|
||||
import io.swagger.v3.oas.models.servers.Server;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
@@ -291,7 +289,7 @@ public class RustServerCodegen extends DefaultCodegen implements CodegenConfig {
|
||||
}
|
||||
info.setVersion(StringUtils.join(versionComponents, "."));
|
||||
|
||||
URL url = URLPathUtils.getServerURL(openAPI);
|
||||
URL url = URLPathUtils.getServerURL(openAPI, serverVariableOverrides());
|
||||
additionalProperties.put("serverHost", url.getHost());
|
||||
additionalProperties.put("serverPort", URLPathUtils.getPort(url, 80));
|
||||
}
|
||||
@@ -617,10 +615,6 @@ public class RustServerCodegen extends DefaultCodegen implements CodegenConfig {
|
||||
}
|
||||
|
||||
for (CodegenParameter param : op.headerParams) {
|
||||
// If a header uses UUIDs, we need to import the UUID package.
|
||||
if (param.dataType.equals(uuidType)) {
|
||||
additionalProperties.put("apiUsesUuid", true);
|
||||
}
|
||||
processParam(param, op);
|
||||
|
||||
// Give header params a name in camel case. CodegenParameters don't have a nameInCamelCase property.
|
||||
@@ -756,10 +750,21 @@ public class RustServerCodegen extends DefaultCodegen implements CodegenConfig {
|
||||
}
|
||||
|
||||
if (op.authMethods != null) {
|
||||
boolean headerAuthMethods = false;
|
||||
|
||||
for (CodegenSecurity s : op.authMethods) {
|
||||
if (s.isApiKey && s.isKeyInHeader) {
|
||||
s.vendorExtensions.put("x-apiKeyName", toModelName(s.keyParamName));
|
||||
headerAuthMethods = true;
|
||||
}
|
||||
|
||||
if (s.isBasicBasic || s.isBasicBearer || s.isOAuth) {
|
||||
headerAuthMethods = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (headerAuthMethods) {
|
||||
op.vendorExtensions.put("hasHeaderAuthMethods", "true");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -927,7 +932,15 @@ public class RustServerCodegen extends DefaultCodegen implements CodegenConfig {
|
||||
String modelName = entry.getKey();
|
||||
CodegenModel model = entry.getValue();
|
||||
|
||||
if (uuidType.equals(model.dataType)) {
|
||||
additionalProperties.put("apiUsesUuid", true);
|
||||
}
|
||||
|
||||
for (CodegenProperty prop : model.vars) {
|
||||
if (prop.dataType.equals(uuidType)) {
|
||||
additionalProperties.put("apiUsesUuid", true);
|
||||
}
|
||||
|
||||
String xmlName = modelXmlNames.get(prop.dataType);
|
||||
if (xmlName != null) {
|
||||
prop.vendorExtensions.put("itemXmlName", xmlName);
|
||||
@@ -1134,6 +1147,11 @@ public class RustServerCodegen extends DefaultCodegen implements CodegenConfig {
|
||||
private void processParam(CodegenParameter param, CodegenOperation op) {
|
||||
String example = null;
|
||||
|
||||
// If a parameter uses UUIDs, we need to import the UUID package.
|
||||
if (param.dataType.equals(uuidType)) {
|
||||
additionalProperties.put("apiUsesUuid", true);
|
||||
}
|
||||
|
||||
if (param.isString) {
|
||||
param.vendorExtensions.put("formatString", "\\\"{}\\\"");
|
||||
example = "\"" + ((param.example != null) ? param.example : "") + "\".to_string()";
|
||||
|
||||
@@ -516,7 +516,7 @@ public class SpringCodegen extends AbstractJavaCodegen
|
||||
}
|
||||
|
||||
if(!additionalProperties.containsKey(SERVER_PORT)) {
|
||||
URL url = URLPathUtils.getServerURL(openAPI);
|
||||
URL url = URLPathUtils.getServerURL(openAPI, serverVariableOverrides());
|
||||
this.additionalProperties.put(SERVER_PORT, URLPathUtils.getPort(url, 8080));
|
||||
}
|
||||
|
||||
|
||||
@@ -52,7 +52,7 @@ public class TypeScriptAngularClientCodegen extends AbstractTypeScriptClientCode
|
||||
public static final String STRING_ENUMS = "stringEnums";
|
||||
public static final String STRING_ENUMS_DESC = "Generate string enums instead of objects for enum values.";
|
||||
|
||||
protected String ngVersion = "7.0.0";
|
||||
protected String ngVersion = "8.0.0";
|
||||
protected String npmRepository = null;
|
||||
protected String serviceSuffix = "Service";
|
||||
protected String serviceFileSuffix = ".service";
|
||||
@@ -209,8 +209,9 @@ public class TypeScriptAngularClientCodegen extends AbstractTypeScriptClientCode
|
||||
}
|
||||
|
||||
// Set the typescript version compatible to the Angular version
|
||||
if (ngVersion.atLeast("7.0.0")) {
|
||||
// Angular v7 requires typescript ">=3.1.1 <3.2.0"
|
||||
if (ngVersion.atLeast("8.0.0")) {
|
||||
additionalProperties.put("tsVersion", ">=3.4.0 <3.6.0");
|
||||
} else if (ngVersion.atLeast("7.0.0")) {
|
||||
additionalProperties.put("tsVersion", ">=3.1.1 <3.2.0");
|
||||
} else if (ngVersion.atLeast("6.0.0")) {
|
||||
additionalProperties.put("tsVersion", ">=2.7.2 and <2.10.0");
|
||||
@@ -222,7 +223,9 @@ public class TypeScriptAngularClientCodegen extends AbstractTypeScriptClientCode
|
||||
}
|
||||
|
||||
// Set the rxJS version compatible to the Angular version
|
||||
if (ngVersion.atLeast("7.0.0")) {
|
||||
if (ngVersion.atLeast("8.0.0")) {
|
||||
additionalProperties.put("rxjsVersion", "6.5.0");
|
||||
} else if (ngVersion.atLeast("7.0.0")) {
|
||||
additionalProperties.put("rxjsVersion", "6.3.0");
|
||||
} else if (ngVersion.atLeast("6.0.0")) {
|
||||
additionalProperties.put("rxjsVersion", "6.1.0");
|
||||
@@ -250,7 +253,10 @@ public class TypeScriptAngularClientCodegen extends AbstractTypeScriptClientCode
|
||||
additionalProperties.put("useOldNgPackagr", !ngVersion.atLeast("5.0.0"));
|
||||
|
||||
// Specific ng-packagr configuration
|
||||
if (ngVersion.atLeast("7.0.0")) {
|
||||
if (ngVersion.atLeast("8.0.0")) {
|
||||
additionalProperties.put("ngPackagrVersion", "5.4.0");
|
||||
additionalProperties.put("tsickleVersion", "0.35.0");
|
||||
} else if (ngVersion.atLeast("7.0.0")) {
|
||||
// compatible versions with typescript version
|
||||
additionalProperties.put("ngPackagrVersion", "5.1.0");
|
||||
additionalProperties.put("tsickleVersion", "0.34.0");
|
||||
@@ -268,7 +274,9 @@ public class TypeScriptAngularClientCodegen extends AbstractTypeScriptClientCode
|
||||
}
|
||||
|
||||
// set zone.js version
|
||||
if (ngVersion.atLeast("5.0.0")) {
|
||||
if (ngVersion.atLeast("8.0.0")) {
|
||||
additionalProperties.put("zonejsVersion", "0.9.1");
|
||||
} else if (ngVersion.atLeast("5.0.0")) {
|
||||
// compatible versions to Angular 5+
|
||||
additionalProperties.put("zonejsVersion", "0.8.26");
|
||||
} else {
|
||||
@@ -659,3 +667,4 @@ public class TypeScriptAngularClientCodegen extends AbstractTypeScriptClientCode
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -33,9 +33,11 @@ public class TypeScriptFetchClientCodegen extends AbstractTypeScriptClientCodege
|
||||
public static final String NPM_REPOSITORY = "npmRepository";
|
||||
public static final String WITH_INTERFACES = "withInterfaces";
|
||||
public static final String USE_SINGLE_REQUEST_PARAMETER = "useSingleRequestParameter";
|
||||
public static final String PREFIX_PARAMETER_INTERFACES = "prefixParameterInterfaces";
|
||||
|
||||
protected String npmRepository = null;
|
||||
private boolean useSingleRequestParameter = true;
|
||||
private boolean prefixParameterInterfaces = false;
|
||||
protected boolean addedApiIndex = false;
|
||||
protected boolean addedModelIndex = false;
|
||||
|
||||
@@ -59,6 +61,7 @@ public class TypeScriptFetchClientCodegen extends AbstractTypeScriptClientCodege
|
||||
this.cliOptions.add(new CliOption(NPM_REPOSITORY, "Use this property to set an url your private npmRepo in the package.json"));
|
||||
this.cliOptions.add(new CliOption(WITH_INTERFACES, "Setting this property to true will generate interfaces next to the default class implementations.", SchemaTypeUtil.BOOLEAN_TYPE).defaultValue(Boolean.FALSE.toString()));
|
||||
this.cliOptions.add(new CliOption(USE_SINGLE_REQUEST_PARAMETER, "Setting this property to true will generate functions with a single argument containing all API endpoint parameters instead of one argument per parameter.", SchemaTypeUtil.BOOLEAN_TYPE).defaultValue(Boolean.TRUE.toString()));
|
||||
this.cliOptions.add(new CliOption(PREFIX_PARAMETER_INTERFACES, "Setting this property to true will generate parameter interface declarations prefixed with API class name to avoid name conflicts.", SchemaTypeUtil.BOOLEAN_TYPE).defaultValue(Boolean.FALSE.toString()));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -94,6 +97,11 @@ public class TypeScriptFetchClientCodegen extends AbstractTypeScriptClientCodege
|
||||
}
|
||||
writePropertyBack(USE_SINGLE_REQUEST_PARAMETER, getUseSingleRequestParameter());
|
||||
|
||||
if (additionalProperties.containsKey(PREFIX_PARAMETER_INTERFACES)) {
|
||||
this.setPrefixParameterInterfaces(convertPropertyToBoolean(PREFIX_PARAMETER_INTERFACES));
|
||||
}
|
||||
writePropertyBack(PREFIX_PARAMETER_INTERFACES, getPrefixParameterInterfaces());
|
||||
|
||||
if (additionalProperties.containsKey(NPM_NAME)) {
|
||||
addNpmPackageGeneration();
|
||||
}
|
||||
@@ -208,6 +216,7 @@ public class TypeScriptFetchClientCodegen extends AbstractTypeScriptClientCodege
|
||||
this.addOperationModelImportInfomation(operations);
|
||||
this.updateOperationParameterEnumInformation(operations);
|
||||
this.addOperationObjectResponseInformation(operations);
|
||||
this.addOperationPrefixParameterInterfacesInformation(operations);
|
||||
return operations;
|
||||
}
|
||||
|
||||
@@ -254,6 +263,11 @@ public class TypeScriptFetchClientCodegen extends AbstractTypeScriptClientCodege
|
||||
}
|
||||
}
|
||||
|
||||
private void addOperationPrefixParameterInterfacesInformation(Map<String, Object> operations) {
|
||||
Map<String, Object> _operations = (Map<String, Object>) operations.get("operations");
|
||||
operations.put("prefixParameterInterfaces", getPrefixParameterInterfaces());
|
||||
}
|
||||
|
||||
private void addExtraReservedWords() {
|
||||
this.reservedWords.add("BASE_PATH");
|
||||
this.reservedWords.add("BaseAPI");
|
||||
@@ -289,4 +303,12 @@ public class TypeScriptFetchClientCodegen extends AbstractTypeScriptClientCodege
|
||||
private void setUseSingleRequestParameter(boolean useSingleRequestParameter) {
|
||||
this.useSingleRequestParameter = useSingleRequestParameter;
|
||||
}
|
||||
|
||||
private boolean getPrefixParameterInterfaces() {
|
||||
return prefixParameterInterfaces;
|
||||
}
|
||||
|
||||
private void setPrefixParameterInterfaces(boolean prefixParameterInterfaces) {
|
||||
this.prefixParameterInterfaces = prefixParameterInterfaces;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@ import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
import com.fasterxml.jackson.databind.MapperFeature;
|
||||
import com.fasterxml.jackson.databind.module.SimpleModule;
|
||||
import io.swagger.v3.core.util.Yaml;
|
||||
import io.swagger.v3.core.util.Json;
|
||||
import io.swagger.v3.oas.models.OpenAPI;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
@@ -15,9 +16,7 @@ public class SerializerUtils {
|
||||
if(openAPI == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
SimpleModule module = new SimpleModule("OpenAPIModule");
|
||||
module.addSerializer(OpenAPI.class, new OpenAPISerializer());
|
||||
SimpleModule module = createModule();
|
||||
try {
|
||||
return Yaml.mapper()
|
||||
.registerModule(module)
|
||||
@@ -29,4 +28,30 @@ public class SerializerUtils {
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static String toJsonString(OpenAPI openAPI) {
|
||||
if (openAPI == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
SimpleModule module = createModule();
|
||||
try {
|
||||
return Json.mapper()
|
||||
.copy()
|
||||
.registerModule(module)
|
||||
.configure(MapperFeature.SORT_PROPERTIES_ALPHABETICALLY, true)
|
||||
.writerWithDefaultPrettyPrinter()
|
||||
.writeValueAsString(openAPI)
|
||||
.replace("\r\n", "\n");
|
||||
} catch (JsonProcessingException e) {
|
||||
LOGGER.warn("Can not create json content", e);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private static SimpleModule createModule() {
|
||||
SimpleModule module = new SimpleModule("OpenAPIModule");
|
||||
module.addSerializer(OpenAPI.class, new OpenAPISerializer());
|
||||
return module;
|
||||
}
|
||||
}
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user