forked from loafle/openapi-generator-original
Compare commits
110 Commits
java_fix_e
...
v4.1.2
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
3ebefccfa9 | ||
|
|
e73bf9be1d | ||
|
|
d46bff9e78 | ||
|
|
e18f361534 | ||
|
|
8d67acc3ed | ||
|
|
9ca4bac881 | ||
|
|
f2fe4fc200 | ||
|
|
096f2d0fc8 | ||
|
|
239d68df36 | ||
|
|
5fd15b8b18 | ||
|
|
640e2ca825 | ||
|
|
ddf0e3e225 | ||
|
|
dd152eefcc | ||
|
|
c7d4a965c7 | ||
|
|
458d47b4ae | ||
|
|
9cc7bd15f2 | ||
|
|
c63cf7e5f3 | ||
|
|
6a4e92887a | ||
|
|
03edb64030 | ||
|
|
ec7f2a0450 | ||
|
|
2a2eefe93d | ||
|
|
cec2818e1f | ||
|
|
91daca36ef | ||
|
|
12ba8174d1 | ||
|
|
8f13b88ed9 | ||
|
|
3be1196264 | ||
|
|
911cdd8d0c | ||
|
|
1b12b89fd8 | ||
|
|
d21b3390fe | ||
|
|
806141297b | ||
|
|
e39b420fa8 | ||
|
|
f25c6da856 | ||
|
|
b0549fe6da | ||
|
|
87727de079 | ||
|
|
8236424aff | ||
|
|
e4b39ce95e | ||
|
|
026612fed7 | ||
|
|
8f7e43b500 | ||
|
|
1443f01709 | ||
|
|
c2f786b8ad | ||
|
|
44d8b49dee | ||
|
|
f4d3df762a | ||
|
|
ceccb4f83a | ||
|
|
34ec98d17b | ||
|
|
2016bc086f | ||
|
|
28cf0b279d | ||
|
|
31d7bf9d18 | ||
|
|
d36dd47b12 | ||
|
|
5a54aa5726 | ||
|
|
60e4c923dd | ||
|
|
dc7bcbdb85 | ||
|
|
7c480446e6 | ||
|
|
45d70e1bf3 | ||
|
|
f94ff32b0c | ||
|
|
e1116814c4 | ||
|
|
5bd63074c4 | ||
|
|
d0d545bbdd | ||
|
|
c290555e5e | ||
|
|
197294a167 | ||
|
|
7afd350616 | ||
|
|
7e772e1b71 | ||
|
|
ee7c8a82e8 | ||
|
|
136c1407ac | ||
|
|
5289262aec | ||
|
|
cba2d3b8cf | ||
|
|
cd6b844d75 | ||
|
|
16ac05dcdf | ||
|
|
859df23428 | ||
|
|
e12459f3bd | ||
|
|
8cd5a4187b | ||
|
|
a05f68431a | ||
|
|
15f680e1eb | ||
|
|
0beb8caa85 | ||
|
|
1f5aa22f5c | ||
|
|
dfb4c133d8 | ||
|
|
286ddf38f7 | ||
|
|
761e435248 | ||
|
|
1188d0f141 | ||
|
|
a390676cc6 | ||
|
|
b8f9e995ce | ||
|
|
158cdfeb3c | ||
|
|
1fc03c88b2 | ||
|
|
d64ec14ab4 | ||
|
|
73eae09738 | ||
|
|
96dd31a462 | ||
|
|
14a39349d5 | ||
|
|
4898ffa4e9 | ||
|
|
62ca0c78ff | ||
|
|
a748e1ff9a | ||
|
|
8741a8ca35 | ||
|
|
870bb1c858 | ||
|
|
f6ead7b877 | ||
|
|
abfef86c8b | ||
|
|
b323b0a0af | ||
|
|
1a808dd644 | ||
|
|
d09e097e4e | ||
|
|
9de908a386 | ||
|
|
57236bc846 | ||
|
|
6924b3c710 | ||
|
|
bb5cd4c42d | ||
|
|
94eb6860aa | ||
|
|
10a310ef69 | ||
|
|
50253f2b15 | ||
|
|
99d7b4e70b | ||
|
|
2ee0c34347 | ||
|
|
4575b3074a | ||
|
|
7abd2e141a | ||
|
|
1adb0ba588 | ||
|
|
6addd76e11 | ||
|
|
8c498fb08a |
6
.github/.test/samples.json
vendored
6
.github/.test/samples.json
vendored
@@ -145,12 +145,6 @@
|
||||
"Documentation: Cwiki"
|
||||
]
|
||||
},
|
||||
{
|
||||
"input": "dart-flutter-petstore.sh",
|
||||
"matches": [
|
||||
"Client: Dart"
|
||||
]
|
||||
},
|
||||
{
|
||||
"input": "dart-jaguar-petstore.sh",
|
||||
"matches": [
|
||||
|
||||
@@ -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,32 @@ kind: pipeline
|
||||
name: default
|
||||
|
||||
steps:
|
||||
# test haskell client
|
||||
- name: haskell-client-test
|
||||
image: haskell:8.6.5
|
||||
commands:
|
||||
- (cd samples/client/petstore/haskell-http-client/ && stack --install-ghc --no-haddock-deps haddock --fast && stack test --fast)
|
||||
# test Dart 2.x petstore client
|
||||
- name: dart2x-test
|
||||
image: google/dart
|
||||
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
|
||||
|
||||
@@ -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>
|
||||
38
README.md
38
README.md
@@ -2,7 +2,7 @@
|
||||
|
||||
<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)
|
||||
@@ -65,11 +65,11 @@ OpenAPI Generator allows generation of API client libraries (SDK generation), se
|
||||
|
||||
| | Languages/Frameworks |
|
||||
|-|-|
|
||||
**API clients** | **ActionScript**, **Ada**, **Apex**, **Bash**, **C**, **C#** (.net 2.0, 3.5 or later), **C++** (cpp-restsdk, Qt5, Tizen), **Clojure**, **Dart (1.x, 2.x)**, **Elixir**, **Elm**, **Eiffel**, **Erlang**, **Go**, **Groovy**, **Haskell** (http-client, Servant), **Java** (Jersey1.x, Jersey2.x, OkHttp, Retrofit1.x, Retrofit2.x, Feign, RestTemplate, RESTEasy, Vertx, Google API Client Library for Java, Rest-assured, Spring 5 Web Client), **Kotlin**, **Lua**, **Node.js/JavaScript** (ES5, ES6, AngularJS with Google Closure Compiler annotations, Flow types), **Objective-C**, **OCaml**, **Perl**, **PHP**, **PowerShell**, **Python**, **R**, **Ruby**, **Rust** (rust, rust-server), **Scala** (akka, http4s, scalaz, swagger-async-httpclient), **Swift** (2.x, 3.x, 4.x), **Typescript** (AngularJS, Angular (2.x - 8.x), Aurelia, Axios, Fetch, Inversify, jQuery, Node, Rxjs)
|
||||
**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, .NET Standard 1.3 - 2.0, .NET Core 2.0), **C++** (cpp-restsdk, Qt5, Tizen), **Clojure**, **Dart (1.x, 2.x)**, **Elixir**, **Elm**, **Eiffel**, **Erlang**, **Go**, **Groovy**, **Haskell** (http-client, Servant), **Java** (Jersey1.x, Jersey2.x, OkHttp, Retrofit1.x, Retrofit2.x, Feign, RestTemplate, RESTEasy, Vertx, Google API Client Library for Java, Rest-assured, Spring 5 Web Client), **Kotlin**, **Lua**, **Node.js/JavaScript** (ES5, ES6, AngularJS with Google Closure Compiler annotations, Flow types), **Objective-C**, **OCaml**, **Perl**, **PHP**, **PowerShell**, **Python**, **R**, **Ruby**, **Rust** (rust, rust-server), **Scala** (akka, http4s, scalaz, swagger-async-httpclient), **Swift** (2.x, 3.x, 4.x), **Typescript** (AngularJS, Angular (2.x - 8.x), Aurelia, Axios, Fetch, Inversify, jQuery, Node, Rxjs)
|
||||
**Server stubs** | **Ada**, **C#** (ASP.NET Core, NancyFx), **C++** (Pistache, Restbed, Qt5 QHTTPEngine), **Erlang**, **F#** (Giraffe), **Go** (net/http, Gin), **Haskell** (Servant), **Java** (MSF4J, Spring, Undertow, JAX-RS: CDI, CXF, Inflector, Jersey, RestEasy, Play Framework, [PKMST](https://github.com/ProKarma-Inc/pkmst-getting-started-examples)), **Kotlin** (Spring Boot, Ktor), **PHP** (Laravel, Lumen, Slim, Silex, [Symfony](https://symfony.com/), [Zend Expressive](https://github.com/zendframework/zend-expressive)), **Python** (Flask), **NodeJS**, **Ruby** (Sinatra, Rails5), **Rust** (rust-server), **Scala** ([Finch](https://github.com/finagle/finch), [Lagom](https://github.com/lagom/lagom), [Play](https://www.playframework.com/), Scalatra)
|
||||
**API documentation generators** | **HTML**, **Confluence Wiki**
|
||||
**Configuration files** | [**Apache2**](https://httpd.apache.org/)
|
||||
**Others** | **GraphQL**, **JMeter**, **MySQL Schema**
|
||||
**Others** | **GraphQL**, **JMeter**, **MySQL Schema**, **Protocol Buffer**
|
||||
|
||||
## Table of contents
|
||||
|
||||
@@ -108,8 +108,8 @@ OpenAPI Generator Version | Release Date | Notes
|
||||
---------------------------- | ------------ | -----
|
||||
5.0.0 (upcoming major release) [SNAPSHOT](https://oss.sonatype.org/content/repositories/snapshots/org/openapitools/openapi-generator-cli/5.0.0-SNAPSHOT/)| 13.05.2020 | Major release with breaking changes (no fallback)
|
||||
4.2.0 (upcoming minor release) [SNAPSHOT](https://oss.sonatype.org/content/repositories/snapshots/org/openapitools/openapi-generator-cli/4.2.0-SNAPSHOT/)| 09.10.2019 | Minor release (breaking changes with fallbacks)
|
||||
4.1.1 (upcoming minor release) [SNAPSHOT](https://oss.sonatype.org/content/repositories/snapshots/org/openapitools/openapi-generator-cli/4.1.1-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.3 (upcoming minor release) [SNAPSHOT](https://oss.sonatype.org/content/repositories/snapshots/org/openapitools/openapi-generator-cli/4.1.3-SNAPSHOT/)| 30.09.2019 | Patch release (bug fixes, enhancements)
|
||||
[4.1.2](https://github.com/OpenAPITools/openapi-generator/releases/tag/v4.1.2) (latest stable release) | 11.09.2019 | Minor release (breaking changes with fallbacks)
|
||||
|
||||
OpenAPI Spec compatibility: 1.0, 1.1, 1.2, 2.0, 3.0
|
||||
|
||||
@@ -165,16 +165,16 @@ See the different versions of the [openapi-generator-cli](https://mvnrepository.
|
||||
<!-- RELEASE_VERSION -->
|
||||
If you're looking for the latest stable version, you can grab it directly from Maven.org (Java 8 runtime at a minimum):
|
||||
|
||||
JAR location: `http://central.maven.org/maven2/org/openapitools/openapi-generator-cli/4.1.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.
|
||||
@@ -389,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:
|
||||
@@ -416,7 +416,7 @@ java -jar modules/openapi-generator-cli/target/openapi-generator-cli.jar generat
|
||||
(if you're on Windows, replace the last command with `java -jar modules\openapi-generator-cli\target\openapi-generator-cli.jar generate -i https://raw.githubusercontent.com/openapitools/openapi-generator/master/modules/openapi-generator/src/test/resources/2_0/petstore.yaml -g php -o c:\temp\php_api_client`)
|
||||
|
||||
<!-- RELEASE_VERSION -->
|
||||
You can also download the JAR (latest release) directly from [maven.org](http://central.maven.org/maven2/org/openapitools/openapi-generator-cli/4.1.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`
|
||||
@@ -560,6 +560,7 @@ Here are some companies/projects (alphabetical order) using OpenAPI Generator in
|
||||
- [Commencis](https://www.commencis.com/)
|
||||
- [Cupix](https://www.cupix.com/)
|
||||
- [DB Systel](https://www.dbsystel.de)
|
||||
- [Element AI](https://www.elementai.com/)
|
||||
- [FormAPI](https://formapi.io/)
|
||||
- [Fuse](https://www.fuse.no/)
|
||||
- [GenFlow](https://github.com/RepreZen/GenFlow)
|
||||
@@ -569,6 +570,8 @@ 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)
|
||||
- [Pricefx](https://www.pricefx.com/)
|
||||
- [Prometheus/Alertmanager](https://github.com/prometheus/alertmanager)
|
||||
- [Raiffeisen Schweiz Genossenschaft](https://www.raiffeisen.ch)
|
||||
- [RepreZen API Studio](https://www.reprezen.com/swagger-openapi-code-generation-api-first-microservices-enterprise-development)
|
||||
@@ -626,6 +629,13 @@ 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-22 - [マイクロサービスにおけるWeb APIスキーマの管理─ GraphQL、gRPC、OpenAPIの特徴と使いどころ](https://employment.en-japan.com/engineerhub/entry/2019/08/22/103000) by [@ota42y](https://twitter.com/ota42y)
|
||||
- 2019-08-24 - [SwaggerドキュメントからOpenAPI Generatorを使ってモックサーバー作成](https://qiita.com/masayoshi0222/items/4845e4c715d04587c104) by [坂本正義](https://qiita.com/masayoshi0222)
|
||||
- 2019-08-29 - [OpenAPI初探](https://cloud.tencent.com/developer/article/1495986) by [peakxie](https://cloud.tencent.com/developer/user/1113152) at [腾讯云社区](https://cloud.tencent.com/developer)
|
||||
- 2019-08-29 - [全面进化:Kubernetes CRD 1.16 GA前瞻](https://www.servicemesher.com/blog/kubernetes-1.16-crd-ga-preview/) by [Min Kim](https://github.com/yue9944882) at [ServiceMesher Blog](https://www.servicemesher.com/blog/)
|
||||
- 2019-09-01 - [Creating a PHP-Slim server using OpenAPI (Youtube video)](https://www.youtube.com/watch?v=5cJtbIrsYkg) by [Daniel Persson](https://www.youtube.com/channel/UCnG-TN23lswO6QbvWhMtxpA)
|
||||
|
||||
## [6 - About Us](#table-of-contents)
|
||||
|
||||
@@ -755,8 +765,10 @@ Here is a list of template creators:
|
||||
* Configuration
|
||||
* Apache2: @stkrwork
|
||||
* Schema
|
||||
* Avro: @sgadouar
|
||||
* GraphQL: @wing328 [:heart:](https://www.patreon.com/wing328)
|
||||
* MySQL: @ybelenko
|
||||
* Protocol Buffer: @wing328
|
||||
|
||||
:heart: = Link to support the contributor directly
|
||||
|
||||
@@ -800,7 +812,7 @@ If you want to join the committee, please kindly apply by sending an email to te
|
||||
| C++ | @ravinikam (2017/07) @stkrwork (2017/07) @etherealjoy (2018/02) @martindelille (2018/03) @muttleyxd (2019/08) |
|
||||
| C# | @mandrean (2017/08), @jimschubert (2017/09) [:heart:](https://www.patreon.com/jimschubert) |
|
||||
| Clojure | |
|
||||
| Dart | @ircecho (2017/07) @swipesight (2018/09) @jaumard (2018/09) |
|
||||
| Dart | @ircecho (2017/07) @swipesight (2018/09) @jaumard (2018/09) @nickmeinhold (2019/09) |
|
||||
| Eiffel | @jvelilla (2017/09) |
|
||||
| Elixir | @mrmstn (2018/12) |
|
||||
| Elm | @eriktim (2018/09) |
|
||||
|
||||
@@ -1,50 +0,0 @@
|
||||
#!/bin/sh
|
||||
|
||||
SCRIPT="$0"
|
||||
|
||||
while [ -h "$SCRIPT" ] ; do
|
||||
ls=`ls -ld "$SCRIPT"`
|
||||
link=`expr "$ls" : '.*-> \(.*\)$'`
|
||||
if expr "$link" : '/.*' > /dev/null; then
|
||||
SCRIPT="$link"
|
||||
else
|
||||
SCRIPT=`dirname "$SCRIPT"`/"$link"
|
||||
fi
|
||||
done
|
||||
|
||||
if [ ! -d "${APP_DIR}" ]; then
|
||||
APP_DIR=`dirname "$SCRIPT"`/..
|
||||
APP_DIR=`cd "${APP_DIR}"; pwd`
|
||||
fi
|
||||
|
||||
executable="./modules/openapi-generator-cli/target/openapi-generator-cli.jar"
|
||||
|
||||
if [ ! -f "$executable" ]
|
||||
then
|
||||
mvn -B clean package
|
||||
fi
|
||||
|
||||
# if you've executed sbt assembly previously it will use that instead.
|
||||
export JAVA_OPTS="${JAVA_OPTS} -Xmx1024M -DloggerPath=conf/log4j.properties"
|
||||
|
||||
## Generate non-browserClient
|
||||
#ags="generate -t modules/openapi-generator/src/main/resources/dart -i modules/openapi-generator/src/test/resources/2_0/petstore.yaml -g dart -o samples/client/petstore/dart/swagger --additional-properties hideGenerationTimestamp=true,browserClient=false $@"
|
||||
#
|
||||
## then options to generate the library for vm would be:
|
||||
##ags="generate -i modules/openapi-generator/src/test/resources/2_0/petstore.yaml -g dart -o samples/client/petstore/dart/swagger_vm --additional-properties browserClient=false,pubName=swagger_vm $@"
|
||||
#java $JAVA_OPTS -jar $executable $ags
|
||||
#
|
||||
## Generate browserClient
|
||||
#ags="generate -t modules/openapi-generator/src/main/resources/dart -i modules/openapi-generator/src/test/resources/2_0/petstore.yaml -g dart -o samples/client/petstore/dart/swagger-browser-client --additional-properties hideGenerationTimestamp=true,browserClient=true $@"
|
||||
#java $JAVA_OPTS -jar $executable $ags
|
||||
|
||||
# Generate non-browserClient and put it to the flutter sample app
|
||||
ags="generate -t modules/openapi-generator/src/main/resources/dart -i modules/openapi-generator/src/test/resources/2_0/petstore.yaml -g dart -o samples/client/petstore/dart/flutter_petstore/swagger --additional-properties hideGenerationTimestamp=true,browserClient=false $@"
|
||||
java $JAVA_OPTS -jar $executable $ags
|
||||
|
||||
# There is a proposal to allow importing different libraries depending on the environment:
|
||||
# https://github.com/munificent/dep-interface-libraries
|
||||
# When this is implemented there will only be one library.
|
||||
|
||||
# The current petstore test will then work for both: the browser library and the vm library.
|
||||
|
||||
@@ -28,23 +28,6 @@ fi
|
||||
# if you've executed sbt assembly previously it will use that instead.
|
||||
export JAVA_OPTS="${JAVA_OPTS} -Xmx1024M -DloggerPath=conf/log4j.properties"
|
||||
|
||||
# Generate non-browserClient
|
||||
ags="generate -t modules/openapi-generator/src/main/resources/dart -i modules/openapi-generator/src/test/resources/2_0/petstore.yaml -g dart -o samples/client/petstore/dart2/openapi --additional-properties hideGenerationTimestamp=true,browserClient=false $@"
|
||||
|
||||
# then options to generate the library for vm would be:
|
||||
#ags="generate -i modules/openapi-generator/src/test/resources/2_0/petstore.yaml -g dart -o samples/client/petstore/dart2/openapi_vm --additional-properties browserClient=false,pubName=openapi_vm $@"
|
||||
# Generate client
|
||||
ags="generate -t modules/openapi-generator/src/main/resources/dart2 -i modules/openapi-generator/src/test/resources/2_0/petstore.yaml -g dart -o samples/client/petstore/dart2/openapi --additional-properties hideGenerationTimestamp=true $@"
|
||||
java $JAVA_OPTS -jar $executable $ags
|
||||
|
||||
# Generate browserClient
|
||||
ags="generate -t modules/openapi-generator/src/main/resources/dart -i modules/openapi-generator/src/test/resources/2_0/petstore.yaml -g dart -o samples/client/petstore/dart2/openapi-browser-client --additional-properties hideGenerationTimestamp=true,browserClient=true $@"
|
||||
java $JAVA_OPTS -jar $executable $ags
|
||||
|
||||
# Generate non-browserClient and put it to the flutter sample app
|
||||
ags="generate -t modules/openapi-generator/src/main/resources/dart -i modules/openapi-generator/src/test/resources/2_0/petstore.yaml -g dart -o samples/client/petstore/dart2/flutter_petstore/openapi --additional-properties hideGenerationTimestamp=true,browserClient=false $@"
|
||||
java $JAVA_OPTS -jar $executable $ags
|
||||
|
||||
# There is a proposal to allow importing different libraries depending on the environment:
|
||||
# https://github.com/munificent/dep-interface-libraries
|
||||
# When this is implemented there will only be one library.
|
||||
|
||||
# The current petstore test will then work for both: the browser library and the vm library.
|
||||
|
||||
@@ -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
|
||||
@@ -26,7 +26,7 @@ then
|
||||
fi
|
||||
|
||||
export JAVA_OPTS="${JAVA_OPTS} -Xmx1024M -DloggerPath=conf/log4j.properties"
|
||||
ags="$@ generate -i modules/openapi-generator/src/test/resources/3_0/petstore-with-fake-endpoints-models-for-testing.yaml -t modules/openapi-generator/src/main/resources/kotlin-client -g kotlin --artifact-id kotlin-petstore-client --additional-properties dateLibrary=java8 -o samples/openapi3/client/petstore/kotlin $@"
|
||||
ags="generate -i modules/openapi-generator/src/test/resources/3_0/petstore-with-fake-endpoints-models-for-testing.yaml -t modules/openapi-generator/src/main/resources/kotlin-client -g kotlin --artifact-id kotlin-petstore-client --additional-properties dateLibrary=java8 -o samples/openapi3/client/petstore/kotlin $@"
|
||||
|
||||
echo "Cleaning previously generated files if any from samples/openapi3/client/petstore/kotlin"
|
||||
rm -rf samples/openapi3/client/petstore/kotlin
|
||||
|
||||
@@ -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
|
||||
10
bin/openapi3/windows/nodejs-express-server-petstore.bat
Executable file
10
bin/openapi3/windows/nodejs-express-server-petstore.bat
Executable file
@@ -0,0 +1,10 @@
|
||||
set executable=.\modules\openapi-generator-cli\target\openapi-generator-cli.jar
|
||||
|
||||
If Not Exist %executable% (
|
||||
mvn clean package
|
||||
)
|
||||
|
||||
REM set JAVA_OPTS=%JAVA_OPTS% -Xmx1024M -DloggerPath=conf/log4j.properties
|
||||
set ags=generate -i modules\openapi-generator\src\test\resources\3_0\petstore.yaml -g nodejs-express-server -o samples\openapi3\server\petstore\nodejs-express-server
|
||||
|
||||
java %JAVA_OPTS% -jar %executable% %ags%
|
||||
32
bin/protobuf-schema-petstore.sh
Executable file
32
bin/protobuf-schema-petstore.sh
Executable file
@@ -0,0 +1,32 @@
|
||||
#!/bin/sh
|
||||
|
||||
SCRIPT="$0"
|
||||
echo "# START SCRIPT: $SCRIPT"
|
||||
|
||||
while [ -h "$SCRIPT" ] ; do
|
||||
ls=`ls -ld "$SCRIPT"`
|
||||
link=`expr "$ls" : '.*-> \(.*\)$'`
|
||||
if expr "$link" : '/.*' > /dev/null; then
|
||||
SCRIPT="$link"
|
||||
else
|
||||
SCRIPT=`dirname "$SCRIPT"`/"$link"
|
||||
fi
|
||||
done
|
||||
|
||||
if [ ! -d "${APP_DIR}" ]; then
|
||||
APP_DIR=`dirname "$SCRIPT"`/..
|
||||
APP_DIR=`cd "${APP_DIR}"; pwd`
|
||||
fi
|
||||
|
||||
executable="./modules/openapi-generator-cli/target/openapi-generator-cli.jar"
|
||||
|
||||
if [ ! -f "$executable" ]
|
||||
then
|
||||
mvn -B clean package
|
||||
fi
|
||||
|
||||
# if you've executed sbt assembly previously it will use that instead.
|
||||
export JAVA_OPTS="${JAVA_OPTS} -Xmx1024M -DloggerPath=conf/log4j.properties $@"
|
||||
ags="generate -t modules/openapi-generator/src/main/resources/protobuf-schema -i modules/openapi-generator/src/test/resources/2_0/petstore.yaml -g protobuf-schema -o samples/config/petstore/protobuf-schema --additional-properties packageName=petstore $@"
|
||||
|
||||
java $JAVA_OPTS -jar $executable $ags
|
||||
@@ -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
|
||||
}
|
||||
|
||||
@@ -4,4 +4,6 @@
|
||||
./bin/typescript-fetch-petstore-with-npm-version.sh
|
||||
./bin/typescript-fetch-petstore-interfaces.sh
|
||||
./bin/typescript-fetch-petstore.sh
|
||||
./bin/typescript-fetch-petstore-multiple-parameters.sh
|
||||
./bin/typescript-fetch-petstore-multiple-parameters.sh
|
||||
./bin/typescript-fetch-petstore-prefix-parameter-interfaces.sh
|
||||
./bin/typescript-fetch-petstore-typescript-three-plus.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
|
||||
7
bin/typescript-fetch-petstore-typescript-three-plus.json
Normal file
7
bin/typescript-fetch-petstore-typescript-three-plus.json
Normal file
@@ -0,0 +1,7 @@
|
||||
{
|
||||
"npmName": "@openapitools/typescript-fetch-petstore",
|
||||
"npmVersion": "1.0.0",
|
||||
"npmRepository" : "https://skimdb.npmjs.com/registry",
|
||||
"snapshot" : false,
|
||||
"typescriptThreePlus": true
|
||||
}
|
||||
32
bin/typescript-fetch-petstore-typescript-three-plus.sh
Executable file
32
bin/typescript-fetch-petstore-typescript-three-plus.sh
Executable file
@@ -0,0 +1,32 @@
|
||||
#!/bin/sh
|
||||
|
||||
SCRIPT="$0"
|
||||
echo "# START SCRIPT: $SCRIPT"
|
||||
|
||||
while [ -h "$SCRIPT" ] ; do
|
||||
ls=`ls -ld "$SCRIPT"`
|
||||
link=`expr "$ls" : '.*-> \(.*\)$'`
|
||||
if expr "$link" : '/.*' > /dev/null; then
|
||||
SCRIPT="$link"
|
||||
else
|
||||
SCRIPT=`dirname "$SCRIPT"`/"$link"
|
||||
fi
|
||||
done
|
||||
|
||||
if [ ! -d "${APP_DIR}" ]; then
|
||||
APP_DIR=`dirname "$SCRIPT"`/..
|
||||
APP_DIR=`cd "${APP_DIR}"; pwd`
|
||||
fi
|
||||
|
||||
executable="./modules/openapi-generator-cli/target/openapi-generator-cli.jar"
|
||||
|
||||
if [ ! -f "$executable" ]
|
||||
then
|
||||
mvn -B clean package
|
||||
fi
|
||||
|
||||
# if you've executed sbt assembly previously it will use that instead.
|
||||
export JAVA_OPTS="${JAVA_OPTS} -Xmx1024M -DloggerPath=conf/log4j.properties"
|
||||
ags="generate -i modules/openapi-generator/src/test/resources/2_0/petstore.yaml -g typescript-fetch -c bin/typescript-fetch-petstore-typescript-three-plus.json -o samples/client/petstore/typescript-fetch/builds/typescript-three-plus $@"
|
||||
|
||||
java $JAVA_OPTS -jar $executable $ags
|
||||
@@ -59,6 +59,9 @@ declare -a scripts=(
|
||||
"./bin/apex-petstore.sh"
|
||||
"./bin/perl-petstore-all.sh"
|
||||
"./bin/dart-jaguar-petstore.sh"
|
||||
"./bin/dart-petstore.sh"
|
||||
"./bin/dart2-petstore.sh"
|
||||
"./bin/java-play-framework-petstore-server-all.sh"
|
||||
#"./bin/elm-petstore-all.sh"
|
||||
"./bin/meta-codegen.sh"
|
||||
# OTHERS
|
||||
|
||||
10
bin/windows/protobuf-schema-petstore.bat
Executable file
10
bin/windows/protobuf-schema-petstore.bat
Executable file
@@ -0,0 +1,10 @@
|
||||
set executable=.\modules\openapi-generator-cli\target\openapi-generator-cli.jar
|
||||
|
||||
If Not Exist %executable% (
|
||||
mvn clean package
|
||||
)
|
||||
|
||||
REM set JAVA_OPTS=%JAVA_OPTS% -Xmx1024M
|
||||
set ags=generate -t modules\openapi-generator\src\main\resources\protobuf-schema -i modules\openapi-generator\src\test\resources\2_0\petstore.yaml -g protobuf-schema -o samples\config\petstore\protobuf-schema
|
||||
|
||||
java %JAVA_OPTS% -jar %executable% %ags%
|
||||
@@ -5,3 +5,5 @@ 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
|
||||
call bin\windows\typescript-fetch-petstore-typescript-three-plus.bat
|
||||
@@ -0,0 +1,12 @@
|
||||
@ECHO OFF
|
||||
|
||||
set executable=.\modules\openapi-generator-cli\target\openapi-generator-cli.jar
|
||||
|
||||
If Not Exist %executable% (
|
||||
mvn clean package
|
||||
)
|
||||
|
||||
REM set JAVA_OPTS=%JAVA_OPTS% -Xmx1024M
|
||||
set ags=generate -i modules\openapi-generator\src\test\resources\2_0\petstore.yaml -g typescript-fetch -o samples\client\petstore\typescript-fetch\builds\prefix-parameter-interfaces --additional-properties prefixParameterInterfaces=true
|
||||
|
||||
java %JAVA_OPTS% -jar %executable% %ags%
|
||||
@@ -0,0 +1,12 @@
|
||||
@ECHO OFF
|
||||
|
||||
set executable=.\modules\openapi-generator-cli\target\openapi-generator-cli.jar
|
||||
|
||||
If Not Exist %executable% (
|
||||
mvn clean package
|
||||
)
|
||||
|
||||
REM set JAVA_OPTS=%JAVA_OPTS% -Xmx1024M
|
||||
set ags=generate -i modules\openapi-generator\src\test\resources\2_0\petstore.yaml -g typescript-fetch -c bin/typescript-fetch-petstore-typescript-three-plus.json -o samples\client\petstore\typescript-fetch\builds\typescript-three-plus
|
||||
|
||||
java %JAVA_OPTS% -jar %executable% %ags%
|
||||
@@ -125,12 +125,14 @@ The following generators are available:
|
||||
|
||||
|
||||
## SCHEMA generators
|
||||
* [avro-schema (beta)](generators/avro-schema)
|
||||
* [mysql-schema](generators/mysql-schema)
|
||||
|
||||
|
||||
## CONFIG generators
|
||||
* [apache2](generators/apache2)
|
||||
* [graphql-schema](generators/graphql-schema)
|
||||
* [protobuf-schema (beta)](generators/protobuf-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|
|
||||
|
||||
@@ -17,6 +17,6 @@ sidebar_label: dart-jaguar
|
||||
|pubDescription|Description in generated pubspec| |null|
|
||||
|useEnumExtension|Allow the 'x-enum-values' extension for enums| |null|
|
||||
|sourceFolder|Source folder for generated code| |null|
|
||||
|supportDart2|Support Dart 2.x| |true|
|
||||
|supportDart2|Support Dart 2.x (Dart 1.x support has been deprecated)| |true|
|
||||
|nullableFields|Is the null fields should be in the JSON payload| |null|
|
||||
|serialization|Choose serialization format JSON or PROTO is supported| |null|
|
||||
|
||||
@@ -17,4 +17,4 @@ sidebar_label: dart
|
||||
|pubDescription|Description in generated pubspec| |null|
|
||||
|useEnumExtension|Allow the 'x-enum-values' extension for enums| |null|
|
||||
|sourceFolder|Source folder for generated code| |null|
|
||||
|supportDart2|Support Dart 2.x| |true|
|
||||
|supportDart2|Support Dart 2.x (Dart 1.x support has been deprecated)| |true|
|
||||
|
||||
@@ -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|
|
||||
|
||||
9
docs/generators/grpc-schema.md
Normal file
9
docs/generators/grpc-schema.md
Normal file
@@ -0,0 +1,9 @@
|
||||
|
||||
---
|
||||
id: generator-opts-config-grpc-schema
|
||||
title: Config Options for grpc-schema
|
||||
sidebar_label: grpc-schema
|
||||
---
|
||||
|
||||
| Option | Description | Values | Default |
|
||||
| ------ | ----------- | ------ | ------- |
|
||||
@@ -55,4 +55,5 @@ sidebar_label: java
|
||||
|feignVersion|Version of OpenFeign: '10.x', '9.x' (default)| |false|
|
||||
|useReflectionEqualsHashCode|Use org.apache.commons.lang3.builder for equals and hashCode in the models. WARNING: This will fail under a security manager, unless the appropriate permissions are set up correctly and also there's potential performance impact.| |false|
|
||||
|caseInsensitiveResponseHeaders|Make API response's headers case-insensitive. Available on okhttp-gson, jersey2 libraries| |false|
|
||||
|library|library template (sub-template) to use|<dl><dt>**jersey1**</dt><dd>HTTP client: Jersey client 1.19.x. JSON processing: Jackson 2.8.x. Enable Java6 support using '-DsupportJava6=true'. Enable gzip request encoding using '-DuseGzipFeature=true'. IMPORTANT NOTE: jersey 1.x is no longer actively maintained so please upgrade to 'jersey2' or other HTTP libaries instead.</dd><dt>**jersey2**</dt><dd>HTTP client: Jersey client 2.25.1. JSON processing: Jackson 2.8.x</dd><dt>**feign**</dt><dd>HTTP client: OpenFeign 9.x or 10.x. JSON processing: Jackson 2.8.x. To enable OpenFeign 10.x, set the 'feignVersion' option to '10.x'</dd><dt>**okhttp-gson**</dt><dd>[DEFAULT] HTTP client: OkHttp 3.x. JSON processing: Gson 2.8.x. Enable Parcelable models on Android using '-DparcelableModel=true'. Enable gzip request encoding using '-DuseGzipFeature=true'.</dd><dt>**retrofit**</dt><dd>HTTP client: OkHttp 2.x. JSON processing: Gson 2.x (Retrofit 1.9.0). IMPORTANT NOTE: retrofit1.x is no longer actively maintained so please upgrade to 'retrofit2' instead.</dd><dt>**retrofit2**</dt><dd>HTTP client: OkHttp 3.x. JSON processing: Gson 2.x (Retrofit 2.3.0). Enable the RxJava adapter using '-DuseRxJava[2]=true'. (RxJava 1.x or 2.x)</dd><dt>**resttemplate**</dt><dd>HTTP client: Spring RestTemplate 4.x. JSON processing: Jackson 2.8.x</dd><dt>**webclient**</dt><dd>HTTP client: Spring WebClient 5.x. JSON processing: Jackson 2.9.x</dd><dt>**resteasy**</dt><dd>HTTP client: Resteasy client 3.x. JSON processing: Jackson 2.8.x</dd><dt>**vertx**</dt><dd>HTTP client: VertX client 3.x. JSON processing: Jackson 2.8.x</dd><dt>**google-api-client**</dt><dd>HTTP client: Google API client 1.x. JSON processing: Jackson 2.8.x</dd><dt>**rest-assured**</dt><dd>HTTP client: rest-assured : 4.x. JSON processing: Gson 2.x. Only for Java8</dd><dt>**native**</dt><dd>HTTP client: Java native HttpClient. JSON processing: Jackson 2.9.x. Only for Java11+</dd><dl>|okhttp-gson|
|
||||
|library|library template (sub-template) to use|<dl><dt>**jersey1**</dt><dd>HTTP client: Jersey client 1.19.x. JSON processing: Jackson 2.9.x. Enable Java6 support using '-DsupportJava6=true'. Enable gzip request encoding using '-DuseGzipFeature=true'. IMPORTANT NOTE: jersey 1.x is no longer actively maintained so please upgrade to 'jersey2' or other HTTP libaries instead.</dd><dt>**jersey2**</dt><dd>HTTP client: Jersey client 2.25.1. JSON processing: Jackson 2.9.x</dd><dt>**feign**</dt><dd>HTTP client: OpenFeign 9.x or 10.x. JSON processing: Jackson 2.9.x. To enable OpenFeign 10.x, set the 'feignVersion' option to '10.x'</dd><dt>**okhttp-gson**</dt><dd>[DEFAULT] HTTP client: OkHttp 3.x. JSON processing: Gson 2.8.x. Enable Parcelable models on Android using '-DparcelableModel=true'. Enable gzip request encoding using '-DuseGzipFeature=true'.</dd><dt>**retrofit**</dt><dd>HTTP client: OkHttp 2.x. JSON processing: Gson 2.x (Retrofit 1.9.0). IMPORTANT NOTE: retrofit1.x is no longer actively maintained so please upgrade to 'retrofit2' instead.</dd><dt>**retrofit2**</dt><dd>HTTP client: OkHttp 3.x. JSON processing: Gson 2.x (Retrofit 2.3.0). Enable the RxJava adapter using '-DuseRxJava[2]=true'. (RxJava 1.x or 2.x)</dd><dt>**resttemplate**</dt><dd>HTTP client: Spring RestTemplate 4.x. JSON processing: Jackson 2.9.x</dd><dt>**webclient**</dt><dd>HTTP client: Spring WebClient 5.x. JSON processing: Jackson 2.9.x</dd><dt>**resteasy**</dt><dd>HTTP client: Resteasy client 3.x. JSON processing: Jackson 2.9.x</dd><dt>**vertx**</dt><dd>HTTP client: VertX client 3.x. JSON processing: Jackson 2.9.x</dd><dt>**google-api-client**</dt><dd>HTTP client: Google API client 1.x. JSON processing: Jackson 2.9.x</dd><dt>**rest-assured**</dt><dd>HTTP client: rest-assured : 4.x. JSON processing: Gson 2.x or Jackson 2.9.x. Only for Java8</dd><dt>**native**</dt><dd>HTTP client: Java native HttpClient. JSON processing: Jackson 2.9.x. Only for Java11+</dd><dl>|okhttp-gson|
|
||||
|serializationLibrary|Serialization library, default depends from the library|<dl><dt>**jackson**</dt><dd>Use Jackson as serialization library</dd><dt>**gson**</dt><dd>Use Gson as serialization library</dd><dl>|null|
|
||||
|
||||
@@ -14,6 +14,7 @@ sidebar_label: kotlin-server
|
||||
|artifactId|Generated artifact id (name of jar).| |kotlin-server|
|
||||
|artifactVersion|Generated artifact's package version.| |1.0.0|
|
||||
|enumPropertyNaming|Naming convention for enum properties: 'camelCase', 'PascalCase', 'snake_case', 'UPPERCASE', and 'original'| |camelCase|
|
||||
|serializationLibrary|What serialization library to use: 'moshi' (default), or 'gson'| |moshi|
|
||||
|parcelizeModels|toggle "@Parcelize" for generated models| |null|
|
||||
|library|library template (sub-template)|<dl><dt>**ktor**</dt><dd>ktor framework</dd><dl>|ktor|
|
||||
|featureAutoHead|Automatically provide responses to HEAD requests for existing routes that have the GET verb defined.| |true|
|
||||
|
||||
@@ -14,6 +14,7 @@ sidebar_label: kotlin-spring
|
||||
|artifactId|Generated artifact id (name of jar).| |openapi-spring|
|
||||
|artifactVersion|Generated artifact's package version.| |1.0.0|
|
||||
|enumPropertyNaming|Naming convention for enum properties: 'camelCase', 'PascalCase', 'snake_case', 'UPPERCASE', and 'original'| |camelCase|
|
||||
|serializationLibrary|What serialization library to use: 'moshi' (default), or 'gson'| |moshi|
|
||||
|parcelizeModels|toggle "@Parcelize" for generated models| |null|
|
||||
|title|server title name or client service name| |OpenAPI Kotlin Spring|
|
||||
|basePackage|base package (invokerPackage) for generated code| |org.openapitools|
|
||||
|
||||
@@ -14,6 +14,7 @@ sidebar_label: kotlin
|
||||
|artifactId|Generated artifact id (name of jar).| |kotlin-client|
|
||||
|artifactVersion|Generated artifact's package version.| |1.0.0|
|
||||
|enumPropertyNaming|Naming convention for enum properties: 'camelCase', 'PascalCase', 'snake_case', 'UPPERCASE', and 'original'| |camelCase|
|
||||
|serializationLibrary|What serialization library to use: 'moshi' (default), or 'gson'| |moshi|
|
||||
|parcelizeModels|toggle "@Parcelize" for generated models| |null|
|
||||
|dateLibrary|Option. Date library to use|<dl><dt>**string**</dt><dd>String</dd><dt>**java8**</dt><dd>Java 8 native JSR310</dd><dt>**threetenbp**</dt><dd>Threetenbp</dd><dl>|java8|
|
||||
|collectionType|Option. Collection type to use|<dl><dt>**array**</dt><dd>kotlin.Array</dd><dt>**list**</dt><dd>kotlin.collections.List</dd><dl>|array|
|
||||
|
||||
9
docs/generators/protobuf-schema.md
Normal file
9
docs/generators/protobuf-schema.md
Normal file
@@ -0,0 +1,9 @@
|
||||
|
||||
---
|
||||
id: generator-opts-config-protobuf-schema
|
||||
title: Config Options for protobuf-schema
|
||||
sidebar_label: protobuf-schema
|
||||
---
|
||||
|
||||
| Option | Description | Values | Default |
|
||||
| ------ | ----------- | ------ | ------- |
|
||||
@@ -19,3 +19,5 @@ 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|
|
||||
|typescriptThreePlus|Setting this property to true will generate TypeScript 3.6+ compatible code.| |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.
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
<groupId>org.openapitools</groupId>
|
||||
<artifactId>openapi-generator-project</artifactId>
|
||||
<!-- RELEASE_VERSION -->
|
||||
<version>4.1.1-SNAPSHOT</version>
|
||||
<version>4.1.2</version>
|
||||
<!-- /RELEASE_VERSION -->
|
||||
<relativePath>../..</relativePath>
|
||||
</parent>
|
||||
|
||||
@@ -178,6 +178,10 @@ public class Generate implements Runnable {
|
||||
@Option(name = {"--library"}, title = "library", description = CodegenConstants.LIBRARY_DESC)
|
||||
private String library;
|
||||
|
||||
@Option(name = {"--git-host"}, title = "git host",
|
||||
description = CodegenConstants.GIT_HOST_DESC)
|
||||
private String gitHost;
|
||||
|
||||
@Option(name = {"--git-user-id"}, title = "git user id",
|
||||
description = CodegenConstants.GIT_USER_ID_DESC)
|
||||
private String gitUserId;
|
||||
@@ -343,6 +347,10 @@ public class Generate implements Runnable {
|
||||
configurator.setLibrary(library);
|
||||
}
|
||||
|
||||
if (isNotEmpty(gitHost)) {
|
||||
configurator.setGitHost(gitHost);
|
||||
}
|
||||
|
||||
if (isNotEmpty(gitUserId)) {
|
||||
configurator.setGitUserId(gitUserId);
|
||||
}
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
<artifactId>openapi-generator-project</artifactId>
|
||||
<groupId>org.openapitools</groupId>
|
||||
<!-- RELEASE_VERSION -->
|
||||
<version>4.1.1-SNAPSHOT</version>
|
||||
<version>4.1.2</version>
|
||||
<!-- /RELEASE_VERSION -->
|
||||
<relativePath>../..</relativePath>
|
||||
</parent>
|
||||
|
||||
@@ -30,6 +30,7 @@ import java.util.*;
|
||||
public final class GeneratorSettings implements Serializable {
|
||||
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(GeneratorSettings.class);
|
||||
private static String DEFAULT_GIT_HOST = "github.com";
|
||||
private static String DEFAULT_GIT_USER_ID = "GIT_USER_ID";
|
||||
private static String DEFAULT_GIT_REPO_ID = "GIT_REPO_ID";
|
||||
private static String DEFAULT_RELEASE_NOTE = "Minor update";
|
||||
@@ -54,6 +55,7 @@ public final class GeneratorSettings implements Serializable {
|
||||
private ImmutableMap<String, String> reservedWordMappings;
|
||||
private ImmutableMap<String, String> serverVariables;
|
||||
|
||||
private String gitHost;
|
||||
private String gitUserId;
|
||||
private String gitRepoId;
|
||||
private String releaseNote;
|
||||
@@ -256,6 +258,17 @@ public final class GeneratorSettings implements Serializable {
|
||||
return serverVariables;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets git host. e.g. <strong>gitlab.com</strong>.
|
||||
* <p>
|
||||
* Generally used by git_push.sh in generated sources which support it.
|
||||
* This value may also be used by templates in maven style references, READMEs, or other documentation.
|
||||
*
|
||||
* @return the git host
|
||||
*/
|
||||
public String getGitHost() {
|
||||
return gitHost;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets git user id. e.g. <strong>openapitools</strong>.
|
||||
@@ -324,6 +337,7 @@ public final class GeneratorSettings implements Serializable {
|
||||
languageSpecificPrimitives = ImmutableSet.copyOf(builder.languageSpecificPrimitives);
|
||||
reservedWordMappings = ImmutableMap.copyOf(builder.reservedWordMappings);
|
||||
serverVariables = ImmutableMap.copyOf(builder.serverVariables);
|
||||
gitHost = builder.gitHost;
|
||||
gitUserId = builder.gitUserId;
|
||||
gitRepoId = builder.gitRepoId;
|
||||
releaseNote = builder.releaseNote;
|
||||
@@ -358,6 +372,9 @@ public final class GeneratorSettings implements Serializable {
|
||||
if (isNotEmpty(modelNameSuffix)) {
|
||||
additional.put("modelNameSuffix", modelNameSuffix);
|
||||
}
|
||||
if (isNotEmpty(gitHost)) {
|
||||
additional.put("gitHost", gitHost);
|
||||
}
|
||||
if (isNotEmpty(gitUserId)) {
|
||||
additional.put("gitUserId", gitUserId);
|
||||
}
|
||||
@@ -390,6 +407,7 @@ public final class GeneratorSettings implements Serializable {
|
||||
}
|
||||
|
||||
private void setDefaults() {
|
||||
gitHost = DEFAULT_GIT_HOST;
|
||||
gitUserId = DEFAULT_GIT_USER_ID;
|
||||
gitRepoId = DEFAULT_GIT_REPO_ID;
|
||||
releaseNote = DEFAULT_RELEASE_NOTE;
|
||||
@@ -421,13 +439,28 @@ 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());
|
||||
builder.serverVariables = new HashMap<>(copy.getServerVariables());
|
||||
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.gitHost = copy.getGitHost();
|
||||
builder.gitUserId = copy.getGitUserId();
|
||||
builder.gitRepoId = copy.getGitRepoId();
|
||||
builder.releaseNote = copy.getReleaseNote();
|
||||
@@ -459,6 +492,7 @@ public final class GeneratorSettings implements Serializable {
|
||||
private Set<String> languageSpecificPrimitives;
|
||||
private Map<String, String> reservedWordMappings;
|
||||
private Map<String, String> serverVariables;
|
||||
private String gitHost;
|
||||
private String gitUserId;
|
||||
private String gitRepoId;
|
||||
private String releaseNote;
|
||||
@@ -476,6 +510,7 @@ public final class GeneratorSettings implements Serializable {
|
||||
reservedWordMappings = new HashMap<>();
|
||||
serverVariables = new HashMap<>();
|
||||
|
||||
gitHost = DEFAULT_GIT_HOST;
|
||||
gitUserId = DEFAULT_GIT_USER_ID;
|
||||
gitRepoId = DEFAULT_GIT_REPO_ID;
|
||||
releaseNote = DEFAULT_RELEASE_NOTE;
|
||||
@@ -769,6 +804,17 @@ public final class GeneratorSettings implements Serializable {
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the {@code gitHost} and returns a reference to this Builder so that the methods can be chained together.
|
||||
*
|
||||
* @param gitHost the {@code gitHost} to set
|
||||
* @return a reference to this Builder
|
||||
*/
|
||||
public Builder withGitHost(String gitHost) {
|
||||
this.gitHost = gitHost;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the {@code gitUserId} and returns a reference to this Builder so that the methods can be chained together.
|
||||
*
|
||||
@@ -846,6 +892,7 @@ public final class GeneratorSettings implements Serializable {
|
||||
", importMappings=" + importMappings +
|
||||
", languageSpecificPrimitives=" + languageSpecificPrimitives +
|
||||
", reservedWordMappings=" + reservedWordMappings +
|
||||
", gitHost='" + gitHost + '\'' +
|
||||
", gitUserId='" + gitUserId + '\'' +
|
||||
", gitRepoId='" + gitRepoId + '\'' +
|
||||
", releaseNote='" + releaseNote + '\'' +
|
||||
@@ -875,6 +922,7 @@ public final class GeneratorSettings implements Serializable {
|
||||
Objects.equals(getImportMappings(), that.getImportMappings()) &&
|
||||
Objects.equals(getLanguageSpecificPrimitives(), that.getLanguageSpecificPrimitives()) &&
|
||||
Objects.equals(getReservedWordMappings(), that.getReservedWordMappings()) &&
|
||||
Objects.equals(getGitHost(), that.getGitHost()) &&
|
||||
Objects.equals(getGitUserId(), that.getGitUserId()) &&
|
||||
Objects.equals(getGitRepoId(), that.getGitRepoId()) &&
|
||||
Objects.equals(getReleaseNote(), that.getReleaseNote()) &&
|
||||
@@ -901,6 +949,7 @@ public final class GeneratorSettings implements Serializable {
|
||||
getImportMappings(),
|
||||
getLanguageSpecificPrimitives(),
|
||||
getReservedWordMappings(),
|
||||
getGitHost(),
|
||||
getGitUserId(),
|
||||
getGitRepoId(),
|
||||
getReleaseNote(),
|
||||
|
||||
@@ -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() {
|
||||
@@ -87,7 +90,7 @@ public class WorkflowSettings {
|
||||
}
|
||||
|
||||
public static Builder newBuilder(WorkflowSettings copy) {
|
||||
Builder builder = new Builder();
|
||||
Builder builder = newBuilder();
|
||||
builder.inputSpec = copy.getInputSpec();
|
||||
builder.outputDir = copy.getOutputDir();
|
||||
builder.verbose = copy.isVerbose();
|
||||
@@ -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) {
|
||||
this.inputSpec = 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) {
|
||||
this.systemProperties = systemProperties;
|
||||
if (systemProperties != null) {
|
||||
this.systemProperties = systemProperties;
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
@@ -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"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -202,6 +202,11 @@ apply plugin: 'org.openapi.generator'
|
||||
|None
|
||||
|Reference the library template (sub-template) of a generator.
|
||||
|
||||
|gitHost
|
||||
|String
|
||||
|github.com
|
||||
|Git user ID, e.g. gitlab.com.
|
||||
|
||||
|gitUserId
|
||||
|String
|
||||
|None
|
||||
@@ -621,7 +626,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,5 +1,5 @@
|
||||
# RELEASE_VERSION
|
||||
openApiGeneratorVersion=4.1.1-SNAPSHOT
|
||||
openApiGeneratorVersion=4.1.2
|
||||
# /RELEASE_VERSION
|
||||
|
||||
# BEGIN placeholders
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
<groupId>org.openapitools</groupId>
|
||||
<artifactId>openapi-generator-project</artifactId>
|
||||
<!-- RELEASE_VERSION -->
|
||||
<version>4.1.1-SNAPSHOT</version>
|
||||
<version>4.1.2</version>
|
||||
<!-- /RELEASE_VERSION -->
|
||||
<relativePath>../..</relativePath>
|
||||
</parent>
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -116,6 +116,7 @@ class OpenApiGeneratorPlugin : Plugin<Project> {
|
||||
id.set(generate.id)
|
||||
version.set(generate.version)
|
||||
library.set(generate.library)
|
||||
gitHost.set(generate.gitHost)
|
||||
gitUserId.set(generate.gitUserId)
|
||||
gitRepoId.set(generate.gitRepoId)
|
||||
releaseNote.set(generate.releaseNote)
|
||||
|
||||
@@ -160,6 +160,11 @@ open class OpenApiGeneratorGenerateExtension(project: Project) {
|
||||
*/
|
||||
val library = project.objects.property<String?>()
|
||||
|
||||
/**
|
||||
* Git host, e.g. gitlab.com.
|
||||
*/
|
||||
val gitHost = project.objects.property<String?>()
|
||||
|
||||
/**
|
||||
* Git user ID, e.g. openapitools.
|
||||
*/
|
||||
|
||||
@@ -204,6 +204,12 @@ open class GenerateTask : DefaultTask() {
|
||||
@get:Internal
|
||||
val library = project.objects.property<String?>()
|
||||
|
||||
/**
|
||||
* Git host, e.g. gitlab.com.
|
||||
*/
|
||||
@get:Internal
|
||||
val gitHost = project.objects.property<String?>()
|
||||
|
||||
/**
|
||||
* Git user ID, e.g. openapitools.
|
||||
*/
|
||||
@@ -510,6 +516,10 @@ open class GenerateTask : DefaultTask() {
|
||||
configurator.setLibrary(value)
|
||||
}
|
||||
|
||||
gitHost.ifNotEmpty { value ->
|
||||
configurator.setGitHost(value)
|
||||
}
|
||||
|
||||
gitUserId.ifNotEmpty { value ->
|
||||
configurator.setGitUserId(value)
|
||||
}
|
||||
|
||||
@@ -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>
|
||||
@@ -91,6 +91,7 @@ mvn clean compile
|
||||
| `reservedWordsMappings` | `openapi.generator.maven.plugin.reservedWordsMappings` | specifies how a reserved name should be escaped to. Otherwise, the default `_<name>` is used. For example `id=identifier`. You can also have multiple occurrences of this option
|
||||
| `skipIfSpecIsUnchanged` | `codegen.skipIfSpecIsUnchanged` | Skip the execution if the source file is older than the output folder (`false` by default. Can also be set globally through the `codegen.skipIfSpecIsUnchanged` property)
|
||||
| `engine` | `openapi.generator.maven.plugin.engine` | The name of templating engine to use, "mustache" (default) or "handlebars" (beta)
|
||||
| `httpUserAgent` | `openapi.generator.maven.plugin.httpUserAgent` | Sets custom User-Agent header value
|
||||
|
||||
|
||||
### Custom Generator
|
||||
|
||||
@@ -13,10 +13,11 @@
|
||||
<groupId>org.openapitools</groupId>
|
||||
<artifactId>openapi-generator-maven-plugin</artifactId>
|
||||
<!-- RELEASE_VERSION -->
|
||||
<version>4.1.1-SNAPSHOT</version>
|
||||
<version>4.1.2-SNAPSHOT</version>
|
||||
<!-- /RELEASE_VERSION -->
|
||||
<executions>
|
||||
<execution>
|
||||
<id>default</id>
|
||||
<goals>
|
||||
<goal>generate</goal>
|
||||
</goals>
|
||||
@@ -39,6 +40,36 @@
|
||||
<library>jersey2</library>
|
||||
</configuration>
|
||||
</execution>
|
||||
<execution>
|
||||
<id>remote</id>
|
||||
<phase>generate-sources</phase>
|
||||
<goals>
|
||||
<goal>generate</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<!-- specify the swagger yaml -->
|
||||
<inputSpec>https://raw.githubusercontent.com/OpenAPITools/openapi-generator/master/modules/openapi-generator/src/test/resources/2_0/petstore.yaml</inputSpec>
|
||||
|
||||
<!-- target to generate java client code -->
|
||||
<generatorName>java</generatorName>
|
||||
|
||||
<!-- hint: if you want to generate java server code, e.g. based on Spring Boot,
|
||||
you can use the following target: <generatorName>spring</generatorName> -->
|
||||
|
||||
<!-- pass any necessary config options -->
|
||||
<configOptions>
|
||||
<dateLibrary>joda</dateLibrary>
|
||||
</configOptions>
|
||||
|
||||
<!-- override the default library to jersey2 -->
|
||||
<library>jersey2</library>
|
||||
|
||||
<output>${project.build.directory}/generated-sources/remote-openapi</output>
|
||||
<apiPackage>remote.org.openapitools.client.api</apiPackage>
|
||||
<modelPackage>remote.org.openapitools.client.model</modelPackage>
|
||||
<invokerPackage>remote.org.openapitools.client</invokerPackage>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<plugin>
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
<groupId>org.openapitools</groupId>
|
||||
<artifactId>openapi-generator-maven-plugin</artifactId>
|
||||
<!-- RELEASE_VERSION -->
|
||||
<version>4.1.1-SNAPSHOT</version>
|
||||
<version>4.1.2-SNAPSHOT</version>
|
||||
<!-- /RELEASE_VERSION -->
|
||||
<dependencies>
|
||||
<dependency>
|
||||
|
||||
@@ -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>
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
<groupId>org.openapitools</groupId>
|
||||
<artifactId>openapi-generator-project</artifactId>
|
||||
<!-- RELEASE_VERSION -->
|
||||
<version>4.1.1-SNAPSHOT</version>
|
||||
<version>4.1.2</version>
|
||||
<!-- /RELEASE_VERSION -->
|
||||
<relativePath>../..</relativePath>
|
||||
</parent>
|
||||
@@ -66,7 +66,7 @@
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-plugin-plugin</artifactId>
|
||||
<version>3.5.2</version>
|
||||
<version>3.6.0</version>
|
||||
<configuration>
|
||||
<skipErrorNoDescriptorsFound>true</skipErrorNoDescriptorsFound>
|
||||
</configuration>
|
||||
|
||||
@@ -20,7 +20,18 @@ package org.openapitools.codegen.plugin;
|
||||
import static org.apache.commons.lang3.StringUtils.isNotEmpty;
|
||||
import static org.openapitools.codegen.config.CodegenConfiguratorUtils.*;
|
||||
|
||||
import io.swagger.v3.parser.core.models.AuthorizationValue;
|
||||
import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.net.MalformedURLException;
|
||||
import java.net.URI;
|
||||
import java.net.URISyntaxException;
|
||||
import java.net.URL;
|
||||
import java.net.URLConnection;
|
||||
import java.nio.channels.Channels;
|
||||
import java.nio.channels.FileChannel;
|
||||
import java.nio.channels.ReadableByteChannel;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
@@ -42,6 +53,7 @@ import org.openapitools.codegen.ClientOptInput;
|
||||
import org.openapitools.codegen.CodegenConfig;
|
||||
import org.openapitools.codegen.CodegenConstants;
|
||||
import org.openapitools.codegen.DefaultGenerator;
|
||||
import org.openapitools.codegen.auth.AuthParser;
|
||||
import org.openapitools.codegen.config.CodegenConfigurator;
|
||||
import org.openapitools.codegen.config.GlobalSettings;
|
||||
import org.sonatype.plexus.build.incremental.BuildContext;
|
||||
@@ -97,6 +109,12 @@ public class CodeGenMojo extends AbstractMojo {
|
||||
@Parameter(name = "inputSpec", property = "openapi.generator.maven.plugin.inputSpec", required = true)
|
||||
private String inputSpec;
|
||||
|
||||
/**
|
||||
* Git host, e.g. gitlab.com.
|
||||
*/
|
||||
@Parameter(name = "gitHost", property = "openapi.generator.maven.plugin.gitHost", required = false)
|
||||
private String gitHost;
|
||||
|
||||
/**
|
||||
* Git user ID, e.g. swagger-api.
|
||||
*/
|
||||
@@ -206,6 +224,12 @@ public class CodeGenMojo extends AbstractMojo {
|
||||
@Parameter(name = "ignoreFileOverride", property = "openapi.generator.maven.plugin.ignoreFileOverride", required = false)
|
||||
private String ignoreFileOverride;
|
||||
|
||||
/**
|
||||
* Sets custom User-Agent header value
|
||||
*/
|
||||
@Parameter(name = "httpUserAgent", property = "openapi.generator.maven.plugin.httpUserAgent", required = false)
|
||||
private String httpUserAgent;
|
||||
|
||||
/**
|
||||
* To remove operationId prefix (e.g. user_getName => getName)
|
||||
*/
|
||||
@@ -417,7 +441,7 @@ public class CodeGenMojo extends AbstractMojo {
|
||||
if (inputSpecFile.exists()) {
|
||||
File storedInputSpecHashFile = getHashFile(inputSpecFile);
|
||||
if(storedInputSpecHashFile.exists()) {
|
||||
String inputSpecHash = Files.asByteSource(inputSpecFile).hash(Hashing.sha256()).toString();
|
||||
String inputSpecHash = calculateInputSpecHash(inputSpecFile);
|
||||
String storedInputSpecHash = Files.asCharSource(storedInputSpecHashFile, Charsets.UTF_8).read();
|
||||
if (inputSpecHash.equals(storedInputSpecHash)) {
|
||||
getLog().info(
|
||||
@@ -450,6 +474,10 @@ public class CodeGenMojo extends AbstractMojo {
|
||||
configurator.setInputSpec(inputSpec);
|
||||
}
|
||||
|
||||
if (isNotEmpty(gitHost)) {
|
||||
configurator.setGitHost(gitHost);
|
||||
}
|
||||
|
||||
if (isNotEmpty(gitUserId)) {
|
||||
configurator.setGitUserId(gitUserId);
|
||||
}
|
||||
@@ -462,6 +490,10 @@ public class CodeGenMojo extends AbstractMojo {
|
||||
configurator.setIgnoreFileOverride(ignoreFileOverride);
|
||||
}
|
||||
|
||||
if (isNotEmpty(httpUserAgent)) {
|
||||
configurator.setHttpUserAgent(httpUserAgent);
|
||||
}
|
||||
|
||||
if (skipValidateSpec != null) {
|
||||
configurator.setValidateSpec(!skipValidateSpec);
|
||||
}
|
||||
@@ -700,12 +732,7 @@ public class CodeGenMojo extends AbstractMojo {
|
||||
|
||||
// Store a checksum of the input spec
|
||||
File storedInputSpecHashFile = getHashFile(inputSpecFile);
|
||||
ByteSource inputSpecByteSource =
|
||||
inputSpecFile.exists()
|
||||
? Files.asByteSource(inputSpecFile)
|
||||
: CharSource.wrap(ClasspathHelper.loadFileFromClasspath(inputSpecFile.toString().replaceAll("\\\\","/")))
|
||||
.asByteSource(Charsets.UTF_8);
|
||||
String inputSpecHash =inputSpecByteSource.hash(Hashing.sha256()).toString();
|
||||
String inputSpecHash = calculateInputSpecHash(inputSpecFile);
|
||||
|
||||
if (storedInputSpecHashFile.getParent() != null && !new File(storedInputSpecHashFile.getParent()).exists()) {
|
||||
File parent = new File(storedInputSpecHashFile.getParent());
|
||||
@@ -726,8 +753,75 @@ public class CodeGenMojo extends AbstractMojo {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Calculate openapi specification file hash. If specification is hosted on remote resource it is downloaded first
|
||||
*
|
||||
* @param inputSpecFile - Openapi specification input file to calculate it's hash.
|
||||
* Does not taken into account if input spec is hosted on remote resource
|
||||
* @return openapi specification file hash
|
||||
* @throws IOException
|
||||
*/
|
||||
private String calculateInputSpecHash(File inputSpecFile) throws IOException {
|
||||
|
||||
URL inputSpecRemoteUrl = inputSpecRemoteUrl();
|
||||
|
||||
File inputSpecTempFile = inputSpecFile;
|
||||
|
||||
if (inputSpecRemoteUrl != null) {
|
||||
inputSpecTempFile = File.createTempFile("openapi-spec", ".tmp");
|
||||
|
||||
URLConnection conn = inputSpecRemoteUrl.openConnection();
|
||||
if (isNotEmpty(auth)) {
|
||||
List<AuthorizationValue> authList = AuthParser.parse(auth);
|
||||
for (AuthorizationValue auth : authList) {
|
||||
conn.setRequestProperty(auth.getKeyName(), auth.getValue());
|
||||
}
|
||||
}
|
||||
ReadableByteChannel readableByteChannel = Channels.newChannel(conn.getInputStream());
|
||||
|
||||
FileOutputStream fileOutputStream = new FileOutputStream(inputSpecTempFile);
|
||||
FileChannel fileChannel = fileOutputStream.getChannel();
|
||||
|
||||
fileChannel.transferFrom(readableByteChannel, 0, Long.MAX_VALUE);
|
||||
}
|
||||
|
||||
ByteSource inputSpecByteSource =
|
||||
inputSpecTempFile.exists()
|
||||
? Files.asByteSource(inputSpecTempFile)
|
||||
: CharSource.wrap(ClasspathHelper.loadFileFromClasspath(inputSpecTempFile.toString().replaceAll("\\\\","/")))
|
||||
.asByteSource(Charsets.UTF_8);
|
||||
|
||||
return inputSpecByteSource.hash(Hashing.sha256()).toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* Try to parse inputSpec setting string into URL
|
||||
* @return A valid URL or null if inputSpec is not a valid URL
|
||||
*/
|
||||
private URL inputSpecRemoteUrl(){
|
||||
try {
|
||||
return new URI(inputSpec).toURL();
|
||||
} catch (URISyntaxException | MalformedURLException | IllegalArgumentException e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get specification hash file
|
||||
* @param inputSpecFile - Openapi specification input file to calculate it's hash.
|
||||
* Does not taken into account if input spec is hosted on remote resource
|
||||
* @return a file with previously calculated hash
|
||||
*/
|
||||
private File getHashFile(File inputSpecFile) {
|
||||
return new File(output.getPath() + File.separator + ".openapi-generator" + File.separator + inputSpecFile.getName() + ".sha256");
|
||||
String name = inputSpecFile.getName();
|
||||
|
||||
URL url = inputSpecRemoteUrl();
|
||||
if (url != null) {
|
||||
String[] segments = url.getPath().split("/");
|
||||
name = Files.getNameWithoutExtension(segments[segments.length - 1]);
|
||||
}
|
||||
|
||||
return new File(output.getPath() + File.separator + ".openapi-generator" + File.separator + name + ".sha256");
|
||||
}
|
||||
|
||||
private String getCompileSourceRoot() {
|
||||
@@ -737,8 +831,7 @@ public class CodeGenMojo extends AbstractMojo {
|
||||
final String sourceFolder =
|
||||
sourceFolderObject == null ? "src/main/java" : sourceFolderObject.toString();
|
||||
|
||||
String sourceJavaFolder = output.toString() + "/" + sourceFolder;
|
||||
return sourceJavaFolder;
|
||||
return output.toString() + "/" + sourceFolder;
|
||||
}
|
||||
|
||||
private void addCompileSourceRootIfConfigured() {
|
||||
@@ -783,4 +876,4 @@ public class CodeGenMojo extends AbstractMojo {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -4,7 +4,7 @@
|
||||
<groupId>org.openapitools</groupId>
|
||||
<artifactId>openapi-generator-project</artifactId>
|
||||
<!-- RELEASE_VERSION -->
|
||||
<version>4.1.1-SNAPSHOT</version>
|
||||
<version>4.1.2</version>
|
||||
<!-- /RELEASE_VERSION -->
|
||||
<relativePath>../..</relativePath>
|
||||
</parent>
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
<groupId>org.openapitools</groupId>
|
||||
<artifactId>openapi-generator-project</artifactId>
|
||||
<!-- RELEASE_VERSION -->
|
||||
<version>4.1.1-SNAPSHOT</version>
|
||||
<version>4.1.2</version>
|
||||
<!-- /RELEASE_VERSION -->
|
||||
<relativePath>../..</relativePath>
|
||||
</parent>
|
||||
@@ -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>
|
||||
|
||||
@@ -222,6 +222,10 @@ public interface CodegenConfig {
|
||||
*/
|
||||
String getLibrary();
|
||||
|
||||
void setGitHost(String gitHost);
|
||||
|
||||
String getGitHost();
|
||||
|
||||
void setGitUserId(String gitUserId);
|
||||
|
||||
String getGitUserId();
|
||||
|
||||
@@ -202,12 +202,19 @@ public class CodegenConstants {
|
||||
public static final String ENUM_PROPERTY_NAMING = "enumPropertyNaming";
|
||||
public static final String ENUM_PROPERTY_NAMING_DESC = "Naming convention for enum properties: 'camelCase', 'PascalCase', 'snake_case', 'UPPERCASE', and 'original'";
|
||||
|
||||
// Allow different language generators to offer an option of serialization library. Each language specific
|
||||
// Codegen constants should define a description and provide proper input validation for the value of serializationLibrary
|
||||
public static final String SERIALIZATION_LIBRARY = "serializationLibrary";
|
||||
|
||||
public static final String MODEL_NAME_PREFIX = "modelNamePrefix";
|
||||
public static final String MODEL_NAME_PREFIX_DESC = "Prefix that will be prepended to all model names.";
|
||||
|
||||
public static final String MODEL_NAME_SUFFIX = "modelNameSuffix";
|
||||
public static final String MODEL_NAME_SUFFIX_DESC = "Suffix that will be appended to all model names.";
|
||||
|
||||
public static final String GIT_HOST = "gitHost";
|
||||
public static final String GIT_HOST_DESC = "Git host, e.g. gitlab.com.";
|
||||
|
||||
public static final String GIT_USER_ID = "gitUserId";
|
||||
public static final String GIT_USER_ID_DESC = "Git user ID, e.g. openapitools.";
|
||||
|
||||
@@ -308,4 +315,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";
|
||||
}
|
||||
|
||||
@@ -111,7 +111,7 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
protected Boolean sortParamsByRequiredFlag = true;
|
||||
protected Boolean ensureUniqueParams = true;
|
||||
protected Boolean allowUnicodeIdentifiers = false;
|
||||
protected String gitUserId, gitRepoId, releaseNote;
|
||||
protected String gitHost, gitUserId, gitRepoId, releaseNote;
|
||||
protected String httpUserAgent;
|
||||
protected Boolean hideGenerationTimestamp = true;
|
||||
// How to encode special characters like $
|
||||
@@ -1247,7 +1247,7 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
return instantiationTypes.get("map") + "<String, " + inner + ">";
|
||||
} else if (ModelUtils.isArraySchema(schema)) {
|
||||
ArraySchema arraySchema = (ArraySchema) schema;
|
||||
String inner = getSchemaType(arraySchema.getItems());
|
||||
String inner = getSchemaType(getSchemaItems(arraySchema));
|
||||
return instantiationTypes.get("array") + "<" + inner + ">";
|
||||
} else {
|
||||
return null;
|
||||
@@ -1462,6 +1462,15 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
|
||||
}
|
||||
|
||||
protected Schema<?> getSchemaItems(ArraySchema schema) {
|
||||
if (schema.getItems() != null) {
|
||||
return schema.getItems();
|
||||
} else {
|
||||
LOGGER.error("Undefined array inner type for `{}`. Default to String.", schema.getName());
|
||||
return new StringSchema().description("TODO default missing array inner type to string");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the name of the allOf schema
|
||||
*
|
||||
@@ -2180,11 +2189,10 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
property.isFreeFormObject = true;
|
||||
} else if (ModelUtils.isArraySchema(p)) {
|
||||
// default to string if inner item is undefined
|
||||
Schema innerSchema = ModelUtils.unaliasSchema(this.openAPI, ((ArraySchema) p).getItems());
|
||||
if (innerSchema == null) {
|
||||
LOGGER.error("Undefined array inner type for `{}`. Default to String.", p.getName());
|
||||
innerSchema = new StringSchema().description("//TODO automatically added by openapi-generator due to undefined type");
|
||||
((ArraySchema) p).setItems(innerSchema);
|
||||
ArraySchema arraySchema = (ArraySchema) p;
|
||||
Schema innerSchema = ModelUtils.unaliasSchema(this.openAPI, getSchemaItems(arraySchema));
|
||||
if (arraySchema.getItems() == null) {
|
||||
arraySchema.setItems(innerSchema);
|
||||
}
|
||||
} else if (ModelUtils.isMapSchema(p)) {
|
||||
Schema innerSchema = ModelUtils.unaliasSchema(this.openAPI, ModelUtils.getAdditionalProperties(p));
|
||||
@@ -2262,11 +2270,10 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
if (itemName == null) {
|
||||
itemName = property.name;
|
||||
}
|
||||
Schema innerSchema = ModelUtils.unaliasSchema(this.openAPI, ((ArraySchema) p).getItems());
|
||||
if (innerSchema == null) {
|
||||
LOGGER.error("Undefined array inner type for `{}`. Default to String.", p.getName());
|
||||
innerSchema = new StringSchema().description("//TODO automatically added by openapi-generator due to undefined type");
|
||||
((ArraySchema) p).setItems(innerSchema);
|
||||
ArraySchema arraySchema = (ArraySchema) p;
|
||||
Schema innerSchema = ModelUtils.unaliasSchema(this.openAPI, getSchemaItems(arraySchema));
|
||||
if (arraySchema.getItems() == null) {
|
||||
arraySchema.setItems(innerSchema);
|
||||
}
|
||||
CodegenProperty cp = fromProperty(itemName, innerSchema);
|
||||
updatePropertyForArray(property, cp);
|
||||
@@ -2584,7 +2591,7 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
|
||||
if (ModelUtils.isArraySchema(responseSchema)) {
|
||||
ArraySchema as = (ArraySchema) responseSchema;
|
||||
CodegenProperty innerProperty = fromProperty("response", as.getItems());
|
||||
CodegenProperty innerProperty = fromProperty("response", getSchemaItems(as));
|
||||
op.returnBaseType = innerProperty.baseType;
|
||||
} else if (ModelUtils.isMapSchema(responseSchema)) {
|
||||
CodegenProperty innerProperty = fromProperty("response", ModelUtils.getAdditionalProperties(responseSchema));
|
||||
@@ -2659,11 +2666,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);
|
||||
}
|
||||
@@ -2852,7 +2861,7 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
|
||||
if (ModelUtils.isArraySchema(responseSchema)) {
|
||||
ArraySchema as = (ArraySchema) responseSchema;
|
||||
CodegenProperty innerProperty = fromProperty("response", as.getItems());
|
||||
CodegenProperty innerProperty = fromProperty("response", getSchemaItems(as));
|
||||
CodegenProperty innerCp = innerProperty;
|
||||
while (innerCp != null) {
|
||||
r.baseType = innerCp.baseType;
|
||||
@@ -3060,10 +3069,8 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
String collectionFormat = null;
|
||||
if (ModelUtils.isArraySchema(parameterSchema)) { // for array parameter
|
||||
final ArraySchema arraySchema = (ArraySchema) parameterSchema;
|
||||
Schema inner = arraySchema.getItems();
|
||||
if (inner == null) {
|
||||
LOGGER.warn("warning! No inner type supplied for array parameter \"" + parameter.getName() + "\", using String");
|
||||
inner = new StringSchema().description("//TODO automatically added by openapi-generator due to missing iner type definition in the spec");
|
||||
Schema inner = getSchemaItems(arraySchema);
|
||||
if (arraySchema.getItems() == null) {
|
||||
arraySchema.setItems(inner);
|
||||
}
|
||||
|
||||
@@ -3899,6 +3906,24 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
return library;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Git host.
|
||||
*
|
||||
* @param gitHost Git host
|
||||
*/
|
||||
public void setGitHost(String gitHost) {
|
||||
this.gitHost = gitHost;
|
||||
}
|
||||
|
||||
/**
|
||||
* Git host.
|
||||
*
|
||||
* @return Git host
|
||||
*/
|
||||
public String getGitHost() {
|
||||
return gitHost;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Git user ID.
|
||||
*
|
||||
@@ -4463,8 +4488,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;
|
||||
}
|
||||
}
|
||||
@@ -4596,10 +4621,8 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
// array of schema
|
||||
if (ModelUtils.isArraySchema(s)) {
|
||||
final ArraySchema arraySchema = (ArraySchema) s;
|
||||
Schema inner = arraySchema.getItems();
|
||||
if (inner == null) {
|
||||
LOGGER.error("No inner type supplied for array parameter `{}`. Default to type:string", s.getName());
|
||||
inner = new StringSchema().description("//TODO automatically added by openapi-generator due to missing inner type definition in the spec");
|
||||
Schema inner = getSchemaItems(arraySchema);
|
||||
if (arraySchema.getItems() == null) {
|
||||
arraySchema.setItems(inner);
|
||||
}
|
||||
|
||||
@@ -4796,10 +4819,8 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
setParameterNullable(codegenParameter, codegenProperty);
|
||||
} else if (ModelUtils.isArraySchema(schema)) {
|
||||
final ArraySchema arraySchema = (ArraySchema) schema;
|
||||
Schema inner = arraySchema.getItems();
|
||||
if (inner == null) {
|
||||
LOGGER.error("No inner type supplied for array parameter `{}`. Default to type:string", schema.getName());
|
||||
inner = new StringSchema().description("//TODO automatically added by openapi-generator due to undefined type");
|
||||
Schema inner = getSchemaItems(arraySchema);
|
||||
if (arraySchema.getItems() == null) {
|
||||
arraySchema.setItems(inner);
|
||||
}
|
||||
CodegenProperty codegenProperty = fromProperty("property", arraySchema);
|
||||
@@ -4907,7 +4928,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";
|
||||
@@ -5018,11 +5039,7 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
protected void generateJSONSpecFile(Map<String, Object> objs) {
|
||||
OpenAPI openAPI = (OpenAPI) objs.get("openAPI");
|
||||
if (openAPI != null) {
|
||||
try {
|
||||
objs.put("openapi-json", Json.pretty().writeValueAsString(openAPI).replace("\r\n", "\n"));
|
||||
} catch (JsonProcessingException e) {
|
||||
LOGGER.error(e.getMessage(), e);
|
||||
}
|
||||
objs.put("openapi-json", SerializerUtils.toJsonString(openAPI));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -37,6 +37,7 @@ import org.openapitools.codegen.api.TemplatingEngineAdapter;
|
||||
import org.openapitools.codegen.ignore.CodegenIgnoreProcessor;
|
||||
import org.openapitools.codegen.meta.GeneratorMetadata;
|
||||
import org.openapitools.codegen.meta.Stability;
|
||||
import org.openapitools.codegen.serializer.SerializerUtils;
|
||||
import org.openapitools.codegen.templating.MustacheEngineAdapter;
|
||||
import org.openapitools.codegen.utils.ImplementationVersion;
|
||||
import org.openapitools.codegen.utils.ModelUtils;
|
||||
@@ -183,12 +184,12 @@ public class DefaultGenerator extends AbstractGenerator implements Generator {
|
||||
}
|
||||
|
||||
if (GlobalSettings.getProperty("debugOpenAPI") != null) {
|
||||
Json.prettyPrint(openAPI);
|
||||
SerializerUtils.toJsonString(openAPI);
|
||||
} else if (GlobalSettings.getProperty("debugSwagger") != null) {
|
||||
// This exists for backward compatibility
|
||||
// We fall to this block only if debugOpenAPI is null. No need to dump this twice.
|
||||
LOGGER.info("Please use system property 'debugOpenAPI' instead of 'debugSwagger'.");
|
||||
Json.prettyPrint(openAPI);
|
||||
SerializerUtils.toJsonString(openAPI);
|
||||
}
|
||||
|
||||
config.processOpts();
|
||||
|
||||
@@ -91,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);
|
||||
@@ -221,6 +222,11 @@ public class CodegenConfigurator {
|
||||
return this;
|
||||
}
|
||||
|
||||
public CodegenConfigurator setGitHost(String gitHost) {
|
||||
generatorSettingsBuilder.withGitHost(gitHost);
|
||||
return this;
|
||||
}
|
||||
|
||||
public CodegenConfigurator setGitUserId(String gitUserId) {
|
||||
generatorSettingsBuilder.withGitUserId(gitUserId);
|
||||
return this;
|
||||
|
||||
@@ -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";
|
||||
|
||||
@@ -373,6 +374,7 @@ public abstract class AbstractGoCodegen extends DefaultCodegen implements Codege
|
||||
boolean addedOptionalImport = false;
|
||||
boolean addedTimeImport = false;
|
||||
boolean addedOSImport = false;
|
||||
boolean addedReflectImport = false;
|
||||
for (CodegenOperation operation : operations) {
|
||||
for (CodegenParameter param : operation.allParams) {
|
||||
// import "os" if the operation uses files
|
||||
@@ -390,8 +392,9 @@ public abstract class AbstractGoCodegen extends DefaultCodegen implements Codege
|
||||
}
|
||||
|
||||
// import "reflect" package if the parameter is collectionFormat=multi
|
||||
if (param.isCollectionFormatMulti) {
|
||||
if (!addedReflectImport && param.isCollectionFormatMulti) {
|
||||
imports.add(createMapping("import", "reflect"));
|
||||
addedReflectImport = true;
|
||||
}
|
||||
|
||||
// import "optionals" package if the parameter is optional
|
||||
@@ -618,6 +621,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) {
|
||||
|
||||
@@ -686,14 +686,8 @@ public abstract class AbstractJavaCodegen extends DefaultCodegen implements Code
|
||||
@Override
|
||||
public String getTypeDeclaration(Schema p) {
|
||||
if (ModelUtils.isArraySchema(p)) {
|
||||
ArraySchema ap = (ArraySchema) p;
|
||||
Schema inner = ap.getItems();
|
||||
if (inner == null) {
|
||||
LOGGER.error("`{}` (array property) does not have a proper inner type defined. Default to type:string", ap.getName());
|
||||
inner = new StringSchema().description("TODO default missing array inner type to string");
|
||||
ap.setItems(inner);
|
||||
}
|
||||
return getSchemaType(p) + "<" + getTypeDeclaration(inner) + ">";
|
||||
Schema<?> items = getSchemaItems((ArraySchema) p);
|
||||
return getSchemaType(p) + "<" + getTypeDeclaration(items) + ">";
|
||||
} else if (ModelUtils.isMapSchema(p)) {
|
||||
Schema inner = ModelUtils.getAdditionalProperties(p);
|
||||
if (inner == null) {
|
||||
@@ -718,7 +712,6 @@ public abstract class AbstractJavaCodegen extends DefaultCodegen implements Code
|
||||
public String toDefaultValue(Schema p) {
|
||||
p = ModelUtils.getReferencedSchema(this.openAPI, p);
|
||||
if (ModelUtils.isArraySchema(p)) {
|
||||
final ArraySchema ap = (ArraySchema) p;
|
||||
final String pattern;
|
||||
if (fullJavaUtil) {
|
||||
pattern = "new java.util.ArrayList<%s>()";
|
||||
@@ -726,13 +719,9 @@ public abstract class AbstractJavaCodegen extends DefaultCodegen implements Code
|
||||
pattern = "new ArrayList<%s>()";
|
||||
}
|
||||
|
||||
if (ap.getItems() == null) {
|
||||
LOGGER.error("`{}` (array property) does not have a proper inner type defined. Default to type:string", ap.getName());
|
||||
Schema inner = new StringSchema().description("TODO default missing array inner type to string");
|
||||
ap.setItems(inner);
|
||||
}
|
||||
Schema<?> items = getSchemaItems((ArraySchema) p);
|
||||
|
||||
String typeDeclaration = getTypeDeclaration(ap.getItems());
|
||||
String typeDeclaration = getTypeDeclaration(items);
|
||||
Object java8obj = additionalProperties.get("java8");
|
||||
if (java8obj != null) {
|
||||
Boolean java8 = Boolean.valueOf(java8obj.toString());
|
||||
|
||||
@@ -35,6 +35,10 @@ import java.util.*;
|
||||
import static org.openapitools.codegen.utils.StringUtils.*;
|
||||
|
||||
public abstract class AbstractKotlinCodegen extends DefaultCodegen implements CodegenConfig {
|
||||
|
||||
public static final String SERIALIZATION_LIBRARY_DESC = "What serialization library to use: 'moshi' (default), or 'gson'";
|
||||
public enum SERIALIZATION_LIBRARY_TYPE {moshi, gson}
|
||||
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(AbstractKotlinCodegen.class);
|
||||
|
||||
protected String artifactId;
|
||||
@@ -51,6 +55,7 @@ public abstract class AbstractKotlinCodegen extends DefaultCodegen implements Co
|
||||
protected boolean parcelizeModels = false;
|
||||
|
||||
protected CodegenConstants.ENUM_PROPERTY_NAMING_TYPE enumPropertyNaming = CodegenConstants.ENUM_PROPERTY_NAMING_TYPE.camelCase;
|
||||
protected SERIALIZATION_LIBRARY_TYPE serializationLibrary = SERIALIZATION_LIBRARY_TYPE.moshi;
|
||||
|
||||
public AbstractKotlinCodegen() {
|
||||
super();
|
||||
@@ -205,6 +210,10 @@ public abstract class AbstractKotlinCodegen extends DefaultCodegen implements Co
|
||||
|
||||
CliOption enumPropertyNamingOpt = new CliOption(CodegenConstants.ENUM_PROPERTY_NAMING, CodegenConstants.ENUM_PROPERTY_NAMING_DESC);
|
||||
cliOptions.add(enumPropertyNamingOpt.defaultValue(enumPropertyNaming.name()));
|
||||
|
||||
CliOption serializationLibraryOpt = new CliOption(CodegenConstants.SERIALIZATION_LIBRARY, SERIALIZATION_LIBRARY_DESC);
|
||||
cliOptions.add(serializationLibraryOpt.defaultValue(serializationLibrary.name()));
|
||||
|
||||
cliOptions.add(new CliOption(CodegenConstants.PARCELIZE_MODELS, CodegenConstants.PARCELIZE_MODELS_DESC));
|
||||
}
|
||||
|
||||
@@ -244,6 +253,10 @@ public abstract class AbstractKotlinCodegen extends DefaultCodegen implements Co
|
||||
return this.enumPropertyNaming;
|
||||
}
|
||||
|
||||
public SERIALIZATION_LIBRARY_TYPE getSerializationLibrary() {
|
||||
return this.serializationLibrary;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the naming convention for Kotlin enum properties
|
||||
*
|
||||
@@ -261,6 +274,24 @@ public abstract class AbstractKotlinCodegen extends DefaultCodegen implements Co
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the serialization engine for Kotlin
|
||||
*
|
||||
* @param enumSerializationLibrary The string representation of the serialization library as defined by
|
||||
* {@link org.openapitools.codegen.languages.AbstractKotlinCodegen.SERIALIZATION_LIBRARY_TYPE}
|
||||
*/
|
||||
public void setSerializationLibrary(final String enumSerializationLibrary) {
|
||||
try {
|
||||
this.serializationLibrary = SERIALIZATION_LIBRARY_TYPE.valueOf(enumSerializationLibrary);
|
||||
} catch (IllegalArgumentException ex) {
|
||||
StringBuilder sb = new StringBuilder(enumSerializationLibrary + " is an invalid enum property naming option. Please choose from:");
|
||||
for (SERIALIZATION_LIBRARY_TYPE t : SERIALIZATION_LIBRARY_TYPE.values()) {
|
||||
sb.append("\n ").append(t.name());
|
||||
}
|
||||
throw new RuntimeException(sb.toString());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* returns the swagger type for the property
|
||||
*
|
||||
@@ -330,6 +361,14 @@ public abstract class AbstractKotlinCodegen extends DefaultCodegen implements Co
|
||||
setEnumPropertyNaming((String) additionalProperties.get(CodegenConstants.ENUM_PROPERTY_NAMING));
|
||||
}
|
||||
|
||||
if (additionalProperties.containsKey(CodegenConstants.SERIALIZATION_LIBRARY)) {
|
||||
setSerializationLibrary((String) additionalProperties.get(CodegenConstants.SERIALIZATION_LIBRARY));
|
||||
additionalProperties.put(this.serializationLibrary.name(), true);
|
||||
}
|
||||
else {
|
||||
additionalProperties.put(this.serializationLibrary.name(), true);
|
||||
}
|
||||
|
||||
if (additionalProperties.containsKey(CodegenConstants.SOURCE_FOLDER)) {
|
||||
this.setSourceFolder((String) additionalProperties.get(CodegenConstants.SOURCE_FOLDER));
|
||||
} else {
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -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());
|
||||
|
||||
@@ -62,7 +62,7 @@ public class DartClientCodegen extends DefaultCodegen implements CodegenConfig {
|
||||
outputFolder = "generated-code/dart";
|
||||
modelTemplateFiles.put("model.mustache", ".dart");
|
||||
apiTemplateFiles.put("api.mustache", ".dart");
|
||||
embeddedTemplateDir = templateDir = "dart";
|
||||
embeddedTemplateDir = templateDir = "dart2";
|
||||
apiPackage = "lib.api";
|
||||
modelPackage = "lib.model";
|
||||
modelDocTemplateFiles.put("object_doc.mustache", ".md");
|
||||
@@ -124,7 +124,7 @@ public class DartClientCodegen extends DefaultCodegen implements CodegenConfig {
|
||||
cliOptions.add(new CliOption(PUB_DESCRIPTION, "Description in generated pubspec"));
|
||||
cliOptions.add(new CliOption(USE_ENUM_EXTENSION, "Allow the 'x-enum-values' extension for enums"));
|
||||
cliOptions.add(new CliOption(CodegenConstants.SOURCE_FOLDER, "Source folder for generated code"));
|
||||
cliOptions.add(CliOption.newBoolean(SUPPORT_DART2, "Support Dart 2.x").defaultValue(Boolean.TRUE.toString()));
|
||||
cliOptions.add(CliOption.newBoolean(SUPPORT_DART2, "Support Dart 2.x (Dart 1.x support has been deprecated)").defaultValue(Boolean.TRUE.toString()));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -139,7 +139,7 @@ public class DartClientCodegen extends DefaultCodegen implements CodegenConfig {
|
||||
|
||||
@Override
|
||||
public String getHelp() {
|
||||
return "Generates a Dart (1.x or 2.x) client library.";
|
||||
return "Generates a Dart (1.x (deprecated) or 2.x) client library.";
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -202,7 +202,10 @@ public class DartClientCodegen extends DefaultCodegen implements CodegenConfig {
|
||||
} else {
|
||||
// dart 2.x
|
||||
LOGGER.info("Dart version: 2.x");
|
||||
embeddedTemplateDir = templateDir = "dart2";
|
||||
// check to not overwrite a custom templateDir
|
||||
if (templateDir == null) {
|
||||
embeddedTemplateDir = templateDir = "dart2";
|
||||
}
|
||||
}
|
||||
|
||||
final String libFolder = sourceFolder + File.separator + "lib";
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -78,6 +78,9 @@ public class JavaClientCodegen extends AbstractJavaCodegen
|
||||
public static final String RETROFIT_2 = "retrofit2";
|
||||
public static final String VERTX = "vertx";
|
||||
|
||||
public static final String SERIALIZATION_LIBRARY_GSON = "gson";
|
||||
public static final String SERIALIZATION_LIBRARY_JACKSON = "jackson";
|
||||
|
||||
protected String gradleWrapperPackage = "gradle.wrapper";
|
||||
protected boolean useRxJava = false;
|
||||
protected boolean useRxJava2 = false;
|
||||
@@ -95,6 +98,7 @@ public class JavaClientCodegen extends AbstractJavaCodegen
|
||||
protected boolean useReflectionEqualsHashCode = false;
|
||||
protected boolean caseInsensitiveResponseHeaders = false;
|
||||
protected String authFolder;
|
||||
protected String serializationLibrary = null;
|
||||
|
||||
public JavaClientCodegen() {
|
||||
super();
|
||||
@@ -128,19 +132,18 @@ public class JavaClientCodegen extends AbstractJavaCodegen
|
||||
cliOptions.add(CliOption.newBoolean(USE_REFLECTION_EQUALS_HASHCODE, "Use org.apache.commons.lang3.builder for equals and hashCode in the models. WARNING: This will fail under a security manager, unless the appropriate permissions are set up correctly and also there's potential performance impact."));
|
||||
cliOptions.add(CliOption.newBoolean(CASE_INSENSITIVE_RESPONSE_HEADERS, "Make API response's headers case-insensitive. Available on " + OKHTTP_GSON + ", " + JERSEY2 + " libraries"));
|
||||
|
||||
|
||||
supportedLibraries.put(JERSEY1, "HTTP client: Jersey client 1.19.x. JSON processing: Jackson 2.8.x. Enable Java6 support using '-DsupportJava6=true'. Enable gzip request encoding using '-DuseGzipFeature=true'. IMPORTANT NOTE: jersey 1.x is no longer actively maintained so please upgrade to 'jersey2' or other HTTP libaries instead.");
|
||||
supportedLibraries.put(JERSEY2, "HTTP client: Jersey client 2.25.1. JSON processing: Jackson 2.8.x");
|
||||
supportedLibraries.put(FEIGN, "HTTP client: OpenFeign 9.x or 10.x. JSON processing: Jackson 2.8.x. To enable OpenFeign 10.x, set the 'feignVersion' option to '10.x'");
|
||||
supportedLibraries.put(JERSEY1, "HTTP client: Jersey client 1.19.x. JSON processing: Jackson 2.9.x. Enable Java6 support using '-DsupportJava6=true'. Enable gzip request encoding using '-DuseGzipFeature=true'. IMPORTANT NOTE: jersey 1.x is no longer actively maintained so please upgrade to 'jersey2' or other HTTP libaries instead.");
|
||||
supportedLibraries.put(JERSEY2, "HTTP client: Jersey client 2.25.1. JSON processing: Jackson 2.9.x");
|
||||
supportedLibraries.put(FEIGN, "HTTP client: OpenFeign 9.x or 10.x. JSON processing: Jackson 2.9.x. To enable OpenFeign 10.x, set the 'feignVersion' option to '10.x'");
|
||||
supportedLibraries.put(OKHTTP_GSON, "[DEFAULT] HTTP client: OkHttp 3.x. JSON processing: Gson 2.8.x. Enable Parcelable models on Android using '-DparcelableModel=true'. Enable gzip request encoding using '-DuseGzipFeature=true'.");
|
||||
supportedLibraries.put(RETROFIT_1, "HTTP client: OkHttp 2.x. JSON processing: Gson 2.x (Retrofit 1.9.0). IMPORTANT NOTE: retrofit1.x is no longer actively maintained so please upgrade to 'retrofit2' instead.");
|
||||
supportedLibraries.put(RETROFIT_2, "HTTP client: OkHttp 3.x. JSON processing: Gson 2.x (Retrofit 2.3.0). Enable the RxJava adapter using '-DuseRxJava[2]=true'. (RxJava 1.x or 2.x)");
|
||||
supportedLibraries.put(RESTTEMPLATE, "HTTP client: Spring RestTemplate 4.x. JSON processing: Jackson 2.8.x");
|
||||
supportedLibraries.put(RESTTEMPLATE, "HTTP client: Spring RestTemplate 4.x. JSON processing: Jackson 2.9.x");
|
||||
supportedLibraries.put(WEBCLIENT, "HTTP client: Spring WebClient 5.x. JSON processing: Jackson 2.9.x");
|
||||
supportedLibraries.put(RESTEASY, "HTTP client: Resteasy client 3.x. JSON processing: Jackson 2.8.x");
|
||||
supportedLibraries.put(VERTX, "HTTP client: VertX client 3.x. JSON processing: Jackson 2.8.x");
|
||||
supportedLibraries.put(GOOGLE_API_CLIENT, "HTTP client: Google API client 1.x. JSON processing: Jackson 2.8.x");
|
||||
supportedLibraries.put(REST_ASSURED, "HTTP client: rest-assured : 4.x. JSON processing: Gson 2.x. Only for Java8");
|
||||
supportedLibraries.put(RESTEASY, "HTTP client: Resteasy client 3.x. JSON processing: Jackson 2.9.x");
|
||||
supportedLibraries.put(VERTX, "HTTP client: VertX client 3.x. JSON processing: Jackson 2.9.x");
|
||||
supportedLibraries.put(GOOGLE_API_CLIENT, "HTTP client: Google API client 1.x. JSON processing: Jackson 2.9.x");
|
||||
supportedLibraries.put(REST_ASSURED, "HTTP client: rest-assured : 4.x. JSON processing: Gson 2.x or Jackson 2.9.x. Only for Java8");
|
||||
supportedLibraries.put(NATIVE, "HTTP client: Java native HttpClient. JSON processing: Jackson 2.9.x. Only for Java11+");
|
||||
|
||||
CliOption libraryOption = new CliOption(CodegenConstants.LIBRARY, "library template (sub-template) to use");
|
||||
@@ -150,6 +153,12 @@ public class JavaClientCodegen extends AbstractJavaCodegen
|
||||
cliOptions.add(libraryOption);
|
||||
setLibrary(OKHTTP_GSON);
|
||||
|
||||
CliOption serializationLibrary = new CliOption(CodegenConstants.SERIALIZATION_LIBRARY, "Serialization library, default depends from the library");
|
||||
Map<String, String> serializationOptions = new HashMap<>();
|
||||
serializationOptions.put(SERIALIZATION_LIBRARY_GSON, "Use Gson as serialization library");
|
||||
serializationOptions.put(SERIALIZATION_LIBRARY_JACKSON, "Use Jackson as serialization library");
|
||||
serializationLibrary.setEnum(serializationOptions);
|
||||
cliOptions.add(serializationLibrary);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -284,6 +293,10 @@ public class JavaClientCodegen extends AbstractJavaCodegen
|
||||
"BeanValidationException.java"));
|
||||
}
|
||||
|
||||
if (additionalProperties.containsKey(CodegenConstants.SERIALIZATION_LIBRARY)) {
|
||||
setSerializationLibrary(additionalProperties.get(CodegenConstants.SERIALIZATION_LIBRARY).toString());
|
||||
}
|
||||
|
||||
//TODO: add doc to retrofit1 and feign
|
||||
if (FEIGN.equals(getLibrary()) || RETROFIT_1.equals(getLibrary())) {
|
||||
modelDocTemplateFiles.remove("model_doc.mustache");
|
||||
@@ -301,7 +314,7 @@ public class JavaClientCodegen extends AbstractJavaCodegen
|
||||
}
|
||||
|
||||
if (FEIGN.equals(getLibrary())) {
|
||||
additionalProperties.put("jackson", "true");
|
||||
forceSerializationLibrary(SERIALIZATION_LIBRARY_JACKSON);
|
||||
supportingFiles.add(new SupportingFile("ParamExpander.mustache", invokerFolder, "ParamExpander.java"));
|
||||
supportingFiles.add(new SupportingFile("EncodingUtils.mustache", invokerFolder, "EncodingUtils.java"));
|
||||
} else if (OKHTTP_GSON.equals(getLibrary()) || StringUtils.isEmpty(getLibrary())) {
|
||||
@@ -316,53 +329,60 @@ public class JavaClientCodegen extends AbstractJavaCodegen
|
||||
// NOTE: below moved to postProcessOpoerationsWithModels
|
||||
//supportingFiles.add(new SupportingFile("auth/OAuthOkHttpClient.mustache", authFolder, "OAuthOkHttpClient.java"));
|
||||
//supportingFiles.add(new SupportingFile("auth/RetryingOAuth.mustache", authFolder, "RetryingOAuth.java"));
|
||||
additionalProperties.put("gson", "true");
|
||||
forceSerializationLibrary(SERIALIZATION_LIBRARY_GSON);
|
||||
} else if (usesAnyRetrofitLibrary()) {
|
||||
supportingFiles.add(new SupportingFile("auth/OAuthOkHttpClient.mustache", authFolder, "OAuthOkHttpClient.java"));
|
||||
supportingFiles.add(new SupportingFile("CollectionFormats.mustache", invokerFolder, "CollectionFormats.java"));
|
||||
additionalProperties.put("gson", "true");
|
||||
forceSerializationLibrary(SERIALIZATION_LIBRARY_GSON);
|
||||
if ("retrofit2".equals(getLibrary()) && !usePlayWS) {
|
||||
supportingFiles.add(new SupportingFile("JSON.mustache", invokerFolder, "JSON.java"));
|
||||
}
|
||||
} else if (JERSEY2.equals(getLibrary())) {
|
||||
supportingFiles.add(new SupportingFile("JSON.mustache", invokerFolder, "JSON.java"));
|
||||
supportingFiles.add(new SupportingFile("ApiResponse.mustache", invokerFolder, "ApiResponse.java"));
|
||||
additionalProperties.put("jackson", "true");
|
||||
forceSerializationLibrary(SERIALIZATION_LIBRARY_JACKSON);
|
||||
} else if (NATIVE.equals(getLibrary())) {
|
||||
setJava8Mode(true);
|
||||
additionalProperties.put("java8", "true");
|
||||
additionalProperties.put("jackson", "true");
|
||||
forceSerializationLibrary(SERIALIZATION_LIBRARY_JACKSON);
|
||||
} else if (RESTEASY.equals(getLibrary())) {
|
||||
supportingFiles.add(new SupportingFile("JSON.mustache", invokerFolder, "JSON.java"));
|
||||
additionalProperties.put("jackson", "true");
|
||||
forceSerializationLibrary(SERIALIZATION_LIBRARY_JACKSON);
|
||||
} else if (JERSEY1.equals(getLibrary())) {
|
||||
additionalProperties.put("jackson", "true");
|
||||
forceSerializationLibrary(SERIALIZATION_LIBRARY_JACKSON);
|
||||
} else if (RESTTEMPLATE.equals(getLibrary())) {
|
||||
additionalProperties.put("jackson", "true");
|
||||
forceSerializationLibrary(SERIALIZATION_LIBRARY_JACKSON);
|
||||
supportingFiles.add(new SupportingFile("auth/Authentication.mustache", authFolder, "Authentication.java"));
|
||||
} else if (WEBCLIENT.equals(getLibrary())) {
|
||||
setJava8Mode(true);
|
||||
additionalProperties.put("java8", "true");
|
||||
additionalProperties.put("jackson", "true");
|
||||
forceSerializationLibrary(SERIALIZATION_LIBRARY_JACKSON);
|
||||
} else if (VERTX.equals(getLibrary())) {
|
||||
typeMapping.put("file", "AsyncFile");
|
||||
importMapping.put("AsyncFile", "io.vertx.core.file.AsyncFile");
|
||||
setJava8Mode(true);
|
||||
additionalProperties.put("java8", "true");
|
||||
additionalProperties.put("jackson", "true");
|
||||
forceSerializationLibrary(SERIALIZATION_LIBRARY_JACKSON);
|
||||
apiTemplateFiles.put("apiImpl.mustache", "Impl.java");
|
||||
apiTemplateFiles.put("rxApiImpl.mustache", ".java");
|
||||
supportingFiles.remove(new SupportingFile("manifest.mustache", projectFolder, "AndroidManifest.xml"));
|
||||
} else if (GOOGLE_API_CLIENT.equals(getLibrary())) {
|
||||
additionalProperties.put("jackson", "true");
|
||||
forceSerializationLibrary(SERIALIZATION_LIBRARY_JACKSON);
|
||||
|
||||
} else if (REST_ASSURED.equals(getLibrary())) {
|
||||
additionalProperties.put("gson", "true");
|
||||
if(getSerializationLibrary() == null) {
|
||||
LOGGER.info("No serializationLibrary configured, using '"+SERIALIZATION_LIBRARY_GSON+"' as fallback");
|
||||
setSerializationLibrary(SERIALIZATION_LIBRARY_GSON);
|
||||
}
|
||||
if(SERIALIZATION_LIBRARY_JACKSON.equals(getSerializationLibrary())) {
|
||||
supportingFiles.add(new SupportingFile("JacksonObjectMapper.mustache", invokerFolder, "JacksonObjectMapper.java"));
|
||||
} else if (SERIALIZATION_LIBRARY_GSON.equals(getSerializationLibrary())) {
|
||||
supportingFiles.add(new SupportingFile("JSON.mustache", invokerFolder, "JSON.java"));
|
||||
supportingFiles.add(new SupportingFile("GsonObjectMapper.mustache", invokerFolder, "GsonObjectMapper.java"));
|
||||
}
|
||||
additionalProperties.put("convert", new CaseFormatLambda(LOWER_CAMEL, UPPER_UNDERSCORE));
|
||||
apiTemplateFiles.put("api.mustache", ".java");
|
||||
supportingFiles.add(new SupportingFile("ResponseSpecBuilders.mustache", invokerFolder, "ResponseSpecBuilders.java"));
|
||||
supportingFiles.add(new SupportingFile("JSON.mustache", invokerFolder, "JSON.java"));
|
||||
supportingFiles.add(new SupportingFile("GsonObjectMapper.mustache", invokerFolder, "GsonObjectMapper.java"));
|
||||
} else {
|
||||
LOGGER.error("Unknown library option (-l/--library): " + getLibrary());
|
||||
}
|
||||
@@ -415,16 +435,30 @@ public class JavaClientCodegen extends AbstractJavaCodegen
|
||||
supportingFiles.add(new SupportingFile("auth/Authentication.mustache", authFolder, "Authentication.java"));
|
||||
supportingFiles.add(new SupportingFile("Pair.mustache", invokerFolder, "Pair.java"));
|
||||
|
||||
additionalProperties.put("jackson", "true");
|
||||
additionalProperties.remove("gson");
|
||||
forceSerializationLibrary(SERIALIZATION_LIBRARY_JACKSON);
|
||||
}
|
||||
|
||||
if (additionalProperties.containsKey("jackson") && !NATIVE.equals(getLibrary())) {
|
||||
supportingFiles.add(new SupportingFile("RFC3339DateFormat.mustache", invokerFolder, "RFC3339DateFormat.java"));
|
||||
if ("threetenbp".equals(dateLibrary) && !usePlayWS) {
|
||||
supportingFiles.add(new SupportingFile("CustomInstantDeserializer.mustache", invokerFolder, "CustomInstantDeserializer.java"));
|
||||
}
|
||||
if(getSerializationLibrary() == null) {
|
||||
LOGGER.info("No serializationLibrary configured, using '"+SERIALIZATION_LIBRARY_GSON+"' as fallback");
|
||||
setSerializationLibrary(SERIALIZATION_LIBRARY_GSON);
|
||||
}
|
||||
if(SERIALIZATION_LIBRARY_JACKSON.equals(getSerializationLibrary())) {
|
||||
additionalProperties.put(SERIALIZATION_LIBRARY_JACKSON, "true");
|
||||
additionalProperties.remove(SERIALIZATION_LIBRARY_GSON);
|
||||
if (!NATIVE.equals(getLibrary())) {
|
||||
supportingFiles.add(new SupportingFile("RFC3339DateFormat.mustache", invokerFolder, "RFC3339DateFormat.java"));
|
||||
if ("threetenbp".equals(dateLibrary) && !usePlayWS) {
|
||||
supportingFiles.add(new SupportingFile("CustomInstantDeserializer.mustache", invokerFolder, "CustomInstantDeserializer.java"));
|
||||
}
|
||||
}
|
||||
} else if (SERIALIZATION_LIBRARY_GSON.equals(getSerializationLibrary())) {
|
||||
additionalProperties.put(SERIALIZATION_LIBRARY_GSON, "true");
|
||||
additionalProperties.remove(SERIALIZATION_LIBRARY_JACKSON);
|
||||
} else {
|
||||
additionalProperties.remove(SERIALIZATION_LIBRARY_JACKSON);
|
||||
additionalProperties.remove(SERIALIZATION_LIBRARY_GSON);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private boolean usesAnyRetrofitLibrary() {
|
||||
@@ -581,12 +615,12 @@ public class JavaClientCodegen extends AbstractJavaCodegen
|
||||
if (!BooleanUtils.toBoolean(model.isEnum)) {
|
||||
//final String lib = getLibrary();
|
||||
//Needed imports for Jackson based libraries
|
||||
if (additionalProperties.containsKey("jackson")) {
|
||||
if (additionalProperties.containsKey(SERIALIZATION_LIBRARY_JACKSON)) {
|
||||
model.imports.add("JsonProperty");
|
||||
model.imports.add("JsonValue");
|
||||
model.imports.add("JsonInclude");
|
||||
}
|
||||
if (additionalProperties.containsKey("gson")) {
|
||||
if (additionalProperties.containsKey(SERIALIZATION_LIBRARY_GSON)) {
|
||||
model.imports.add("SerializedName");
|
||||
model.imports.add("TypeAdapter");
|
||||
model.imports.add("JsonAdapter");
|
||||
@@ -596,7 +630,7 @@ public class JavaClientCodegen extends AbstractJavaCodegen
|
||||
}
|
||||
} else { // enum class
|
||||
//Needed imports for Jackson's JsonCreator
|
||||
if (additionalProperties.containsKey("jackson")) {
|
||||
if (additionalProperties.containsKey(SERIALIZATION_LIBRARY_JACKSON)) {
|
||||
model.imports.add("JsonValue");
|
||||
model.imports.add("JsonCreator");
|
||||
}
|
||||
@@ -607,7 +641,7 @@ public class JavaClientCodegen extends AbstractJavaCodegen
|
||||
public Map<String, Object> postProcessModelsEnum(Map<String, Object> objs) {
|
||||
objs = super.postProcessModelsEnum(objs);
|
||||
//Needed import for Gson based libraries
|
||||
if (additionalProperties.containsKey("gson")) {
|
||||
if (additionalProperties.containsKey(SERIALIZATION_LIBRARY_GSON)) {
|
||||
List<Map<String, String>> imports = (List<Map<String, String>>) objs.get("imports");
|
||||
List<Object> models = (List<Object>) objs.get("models");
|
||||
for (Object _mo : models) {
|
||||
@@ -628,7 +662,7 @@ public class JavaClientCodegen extends AbstractJavaCodegen
|
||||
@Override
|
||||
public Map<String, Object> postProcessModels(Map<String, Object> objs) {
|
||||
objs = super.postProcessModels(objs);
|
||||
if (additionalProperties.containsKey("jackson") && !JERSEY1.equals(getLibrary())) {
|
||||
if (additionalProperties.containsKey(SERIALIZATION_LIBRARY_JACKSON) && !JERSEY1.equals(getLibrary())) {
|
||||
List<Map<String, String>> imports = (List<Map<String, String>>) objs.get("imports");
|
||||
List<Object> models = (List<Object>) objs.get("models");
|
||||
for (Object _mo : models) {
|
||||
@@ -712,6 +746,31 @@ public class JavaClientCodegen extends AbstractJavaCodegen
|
||||
this.caseInsensitiveResponseHeaders = caseInsensitiveResponseHeaders;
|
||||
}
|
||||
|
||||
/**
|
||||
* Serialization library.
|
||||
* @return 'gson' or 'jackson'
|
||||
*/
|
||||
public String getSerializationLibrary() {
|
||||
return serializationLibrary;
|
||||
}
|
||||
|
||||
public void setSerializationLibrary(String serializationLibrary) {
|
||||
if(SERIALIZATION_LIBRARY_JACKSON.equalsIgnoreCase(serializationLibrary)) {
|
||||
this.serializationLibrary = SERIALIZATION_LIBRARY_JACKSON;
|
||||
} else if(SERIALIZATION_LIBRARY_GSON.equalsIgnoreCase(serializationLibrary)) {
|
||||
this.serializationLibrary = SERIALIZATION_LIBRARY_GSON;
|
||||
} else {
|
||||
throw new IllegalArgumentException("Unexpected serializationLibrary value: " + serializationLibrary);
|
||||
}
|
||||
}
|
||||
|
||||
public void forceSerializationLibrary(String serializationLibrary) {
|
||||
if((this.serializationLibrary != null) && !this.serializationLibrary.equalsIgnoreCase(serializationLibrary)) {
|
||||
LOGGER.warn("The configured serializationLibrary '" + this.serializationLibrary + "', is not supported by the library: '" + getLibrary() + "', switching back to: " + serializationLibrary);
|
||||
}
|
||||
setSerializationLibrary(serializationLibrary);
|
||||
}
|
||||
|
||||
final private static Pattern JSON_MIME_PATTERN = Pattern.compile("(?i)application\\/json(;.*)?");
|
||||
final private static Pattern JSON_VENDOR_MIME_PATTERN = Pattern.compile("(?i)application\\/vnd.(.*)+json(;.*)?");
|
||||
|
||||
|
||||
@@ -239,6 +239,9 @@ public class JavaJAXRSSpecServerCodegen extends AbstractJavaJAXRSServerCodegen {
|
||||
public String toApiName(final String name) {
|
||||
String computed = name;
|
||||
if (computed.length() == 0) {
|
||||
if (primaryResourceName == null) {
|
||||
return "DefaultApi";
|
||||
}
|
||||
return primaryResourceName + "Api";
|
||||
}
|
||||
computed = sanitizeName(computed);
|
||||
|
||||
@@ -163,11 +163,11 @@ public class NodeJSExpressServerCodegen extends DefaultCodegen implements Codege
|
||||
if (templateName.equals("service.mustache")) {
|
||||
String stringToMatch = File.separator + "controllers" + File.separator;
|
||||
String replacement = File.separator + implFolder + File.separator;
|
||||
result = result.replaceAll(Pattern.quote(stringToMatch), replacement);
|
||||
|
||||
result = result.replace(stringToMatch, replacement);
|
||||
|
||||
stringToMatch = "Controller.js";
|
||||
replacement = "Service.js";
|
||||
result = result.replaceAll(Pattern.quote(stringToMatch), replacement);
|
||||
result = result.replace(stringToMatch, replacement);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -17,13 +17,13 @@
|
||||
|
||||
package org.openapitools.codegen.languages;
|
||||
|
||||
import io.swagger.v3.core.util.Json;
|
||||
import io.swagger.v3.oas.models.OpenAPI;
|
||||
import org.apache.commons.io.FileUtils;
|
||||
import org.openapitools.codegen.CodegenConfig;
|
||||
import org.openapitools.codegen.CodegenType;
|
||||
import org.openapitools.codegen.DefaultCodegen;
|
||||
import org.openapitools.codegen.SupportingFile;
|
||||
import org.openapitools.codegen.serializer.SerializerUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
@@ -58,11 +58,11 @@ public class OpenAPIGenerator extends DefaultCodegen implements CodegenConfig {
|
||||
|
||||
@Override
|
||||
public void processOpenAPI(OpenAPI openAPI) {
|
||||
String swaggerString = Json.pretty(openAPI);
|
||||
String jsonOpenAPI = SerializerUtils.toJsonString(openAPI);
|
||||
|
||||
try {
|
||||
String outputFile = outputFolder + File.separator + "openapi.json";
|
||||
FileUtils.writeStringToFile(new File(outputFile), swaggerString);
|
||||
FileUtils.writeStringToFile(new File(outputFile), jsonOpenAPI);
|
||||
LOGGER.info("wrote file to " + outputFile);
|
||||
} catch (Exception e) {
|
||||
LOGGER.error(e.getMessage(), e);
|
||||
|
||||
@@ -0,0 +1,458 @@
|
||||
/*
|
||||
* Copyright 2019 OpenAPI-Generator Contributors (https://openapi-generator.tech)
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.openapitools.codegen.languages;
|
||||
|
||||
import io.swagger.v3.oas.models.media.ArraySchema;
|
||||
import io.swagger.v3.oas.models.media.Schema;
|
||||
|
||||
import org.openapitools.codegen.CliOption;
|
||||
import org.openapitools.codegen.CodegenConfig;
|
||||
import org.openapitools.codegen.CodegenConstants;
|
||||
import org.openapitools.codegen.CodegenType;
|
||||
import org.openapitools.codegen.*;
|
||||
import org.openapitools.codegen.meta.GeneratorMetadata;
|
||||
import org.openapitools.codegen.meta.Stability;
|
||||
import org.openapitools.codegen.utils.ProcessUtils;
|
||||
import org.openapitools.codegen.utils.ModelUtils;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.*;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import static org.openapitools.codegen.utils.StringUtils.camelize;
|
||||
import static org.openapitools.codegen.utils.StringUtils.underscore;
|
||||
|
||||
public class ProtobufSchemaCodegen extends DefaultCodegen implements CodegenConfig {
|
||||
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(ProtobufSchemaCodegen.class);
|
||||
|
||||
protected String packageName = "openapitools";
|
||||
|
||||
@Override
|
||||
public CodegenType getTag() {
|
||||
return CodegenType.CONFIG;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return "protobuf-schema";
|
||||
}
|
||||
|
||||
public String getHelp() {
|
||||
return "Generates gRPC and protocol buffer schema files (beta)";
|
||||
}
|
||||
|
||||
public ProtobufSchemaCodegen() {
|
||||
super();
|
||||
|
||||
generatorMetadata = GeneratorMetadata.newBuilder(generatorMetadata)
|
||||
.stability(Stability.BETA)
|
||||
.build();
|
||||
|
||||
outputFolder = "generated-code/protobuf-schema";
|
||||
modelTemplateFiles.put("model.mustache", ".proto");
|
||||
apiTemplateFiles.put("api.mustache", ".proto");
|
||||
embeddedTemplateDir = templateDir = "protobuf-schema";
|
||||
hideGenerationTimestamp = Boolean.TRUE;
|
||||
modelPackage = "messages";
|
||||
apiPackage = "services";
|
||||
|
||||
/*setReservedWordsLowerCase(
|
||||
Arrays.asList(
|
||||
// data type
|
||||
"nil", "string", "boolean", "number", "userdata", "thread",
|
||||
"table",
|
||||
|
||||
// reserved words: http://www.lua.org/manual/5.1/manual.html#2.1
|
||||
"and", "break", "do", "else", "elseif",
|
||||
"end", "false", "for", "function", "if",
|
||||
"in", "local", "nil", "not", "or",
|
||||
"repeat", "return", "then", "true", "until", "while"
|
||||
)
|
||||
);*/
|
||||
|
||||
defaultIncludes = new HashSet<String>(
|
||||
Arrays.asList(
|
||||
"map",
|
||||
"array")
|
||||
);
|
||||
|
||||
languageSpecificPrimitives = new HashSet<String>(
|
||||
Arrays.asList(
|
||||
"map",
|
||||
"array",
|
||||
"bool",
|
||||
"bytes",
|
||||
"string",
|
||||
"int32",
|
||||
"int64",
|
||||
"uint32",
|
||||
"uint64",
|
||||
"sint32",
|
||||
"sint64",
|
||||
"fixed32",
|
||||
"fixed64",
|
||||
"sfixed32",
|
||||
"sfixed64",
|
||||
"float",
|
||||
"double")
|
||||
);
|
||||
|
||||
instantiationTypes.clear();
|
||||
instantiationTypes.put("array", "repeat");
|
||||
//instantiationTypes.put("map", "map");
|
||||
|
||||
// ref: https://developers.google.com/protocol-buffers/docs/proto
|
||||
typeMapping.clear();
|
||||
typeMapping.put("array", "array");
|
||||
typeMapping.put("map", "map");
|
||||
typeMapping.put("integer", "int32");
|
||||
typeMapping.put("long", "int64");
|
||||
typeMapping.put("number", "float");
|
||||
typeMapping.put("float", "float");
|
||||
typeMapping.put("double", "double");
|
||||
typeMapping.put("boolean", "bool");
|
||||
typeMapping.put("string", "string");
|
||||
typeMapping.put("UUID", "string");
|
||||
typeMapping.put("URI", "string");
|
||||
typeMapping.put("date", "string");
|
||||
typeMapping.put("DateTime", "string");
|
||||
typeMapping.put("password", "string");
|
||||
// TODO fix file mapping
|
||||
typeMapping.put("file", "string");
|
||||
typeMapping.put("binary", "string");
|
||||
typeMapping.put("ByteArray", "bytes");
|
||||
typeMapping.put("object", "TODO_OBJECT_MAPPING");
|
||||
|
||||
importMapping.clear();
|
||||
/*
|
||||
importMapping = new HashMap<String, String>();
|
||||
importMapping.put("time.Time", "time");
|
||||
importMapping.put("*os.File", "os");
|
||||
importMapping.put("os", "io/ioutil");
|
||||
*/
|
||||
|
||||
modelDocTemplateFiles.put("model_doc.mustache", ".md");
|
||||
apiDocTemplateFiles.put("api_doc.mustache", ".md");
|
||||
|
||||
cliOptions.clear();
|
||||
/*cliOptions.add(new CliOption(CodegenConstants.PACKAGE_NAME, "GraphQL package name (convention: lowercase).")
|
||||
.defaultValue("openapi2graphql"));
|
||||
cliOptions.add(new CliOption(CodegenConstants.PACKAGE_VERSION, "GraphQL package version.")
|
||||
.defaultValue("1.0.0"));
|
||||
cliOptions.add(new CliOption(CodegenConstants.HIDE_GENERATION_TIMESTAMP, CodegenConstants.HIDE_GENERATION_TIMESTAMP_DESC)
|
||||
.defaultValue(Boolean.TRUE.toString()));*/
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void processOpts() {
|
||||
super.processOpts();
|
||||
|
||||
//apiTestTemplateFiles.put("api_test.mustache", ".proto");
|
||||
//modelTestTemplateFiles.put("model_test.mustache", ".proto");
|
||||
|
||||
apiDocTemplateFiles.clear(); // TODO: add api doc template
|
||||
modelDocTemplateFiles.clear(); // TODO: add model doc template
|
||||
|
||||
modelPackage = "models";
|
||||
apiPackage = "services";
|
||||
|
||||
if (additionalProperties.containsKey(CodegenConstants.PACKAGE_NAME)) {
|
||||
setPackageName((String) additionalProperties.get(CodegenConstants.PACKAGE_NAME));
|
||||
}
|
||||
|
||||
supportingFiles.add(new SupportingFile("README.mustache", "", "README.md"));
|
||||
//supportingFiles.add(new SupportingFile("root.mustache", "", packageName + ".proto"));
|
||||
//supportingFiles.add(new SupportingFile("git_push.sh.mustache", "", "git_push.sh"));
|
||||
//supportingFiles.add(new SupportingFile("gitignore.mustache", "", ".gitignore"))
|
||||
//supportingFiles.add(new SupportingFile(".travis.yml", "", ".travis.yml"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toOperationId(String operationId) {
|
||||
// throw exception if method name is empty (should not occur as an auto-generated method name will be used)
|
||||
if (StringUtils.isEmpty(operationId)) {
|
||||
throw new RuntimeException("Empty method name (operationId) not allowed");
|
||||
}
|
||||
|
||||
// method name cannot use reserved keyword, e.g. return
|
||||
if (isReservedWord(operationId)) {
|
||||
LOGGER.warn(operationId + " (reserved word) cannot be used as method name. Renamed to " + camelize(sanitizeName("call_" + operationId)));
|
||||
operationId = "call_" + operationId;
|
||||
}
|
||||
|
||||
return camelize(sanitizeName(operationId));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Object> postProcessModels(Map<String, Object> objs) {
|
||||
objs = postProcessModelsEnum(objs);
|
||||
List<Object> models = (List<Object>) objs.get("models");
|
||||
// add x-index to properties
|
||||
ProcessUtils.addIndexToProperties(models, 1);
|
||||
|
||||
for (Object _mo : models) {
|
||||
Map<String, Object> mo = (Map<String, Object>) _mo;
|
||||
CodegenModel cm = (CodegenModel) mo.get("model");
|
||||
|
||||
for (CodegenProperty var : cm.vars) {
|
||||
// add x-protobuf-type: repeated if it's an array
|
||||
if (Boolean.TRUE.equals(var.isListContainer)) {
|
||||
var.vendorExtensions.put("x-protobuf-type", "repeated");
|
||||
}
|
||||
|
||||
// add x-protobuf-data-type
|
||||
// ref: https://developers.google.com/protocol-buffers/docs/proto3
|
||||
if (!var.vendorExtensions.containsKey("x-protobuf-data-type")) {
|
||||
if (var.isListContainer) {
|
||||
var.vendorExtensions.put("x-protobuf-data-type", var.items.dataType);
|
||||
} else {
|
||||
var.vendorExtensions.put("x-protobuf-data-type", var.dataType);
|
||||
}
|
||||
}
|
||||
|
||||
if (var.isEnum && var.allowableValues.containsKey("enumVars")) {
|
||||
List<Map<String, Object>> enumVars = (List<Map<String, Object>>) var.allowableValues.get("enumVars");
|
||||
int enumIndex = 0;
|
||||
for (Map<String, Object> enumVar : enumVars) {
|
||||
enumVar.put("protobuf-enum-index", enumIndex);
|
||||
enumIndex++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return objs;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String escapeUnsafeCharacters(String input) {
|
||||
return input;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String escapeQuotationMark(String input) {
|
||||
return input;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the default value of the property
|
||||
*
|
||||
* @param p OpenAPI property object
|
||||
* @return string presentation of the default value of the property
|
||||
*/
|
||||
@Override
|
||||
public String toDefaultValue(Schema p) {
|
||||
if (ModelUtils.isBooleanSchema(p)) {
|
||||
if (p.getDefault() != null) {
|
||||
if (Boolean.valueOf(p.getDefault().toString()) == false)
|
||||
return "false";
|
||||
else
|
||||
return "true";
|
||||
}
|
||||
} else if (ModelUtils.isDateSchema(p)) {
|
||||
// TODO
|
||||
} else if (ModelUtils.isDateTimeSchema(p)) {
|
||||
// TODO
|
||||
} else if (ModelUtils.isNumberSchema(p)) {
|
||||
if (p.getDefault() != null) {
|
||||
return p.getDefault().toString();
|
||||
}
|
||||
} else if (ModelUtils.isIntegerSchema(p)) {
|
||||
if (p.getDefault() != null) {
|
||||
return p.getDefault().toString();
|
||||
}
|
||||
} else if (ModelUtils.isStringSchema(p)) {
|
||||
if (p.getDefault() != null) {
|
||||
if (Pattern.compile("\r\n|\r|\n").matcher((String) p.getDefault()).find())
|
||||
return "'''" + p.getDefault() + "'''";
|
||||
else
|
||||
return "'" + p.getDefault() + "'";
|
||||
}
|
||||
} else if (ModelUtils.isArraySchema(p)) {
|
||||
if (p.getDefault() != null) {
|
||||
return p.getDefault().toString();
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String apiFileFolder() {
|
||||
return outputFolder + File.separatorChar + apiPackage;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String modelFileFolder() {
|
||||
return outputFolder + File.separatorChar + modelPackage;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toApiFilename(String name) {
|
||||
// replace - with _ e.g. created-at => created_at
|
||||
name = name.replaceAll("-", "_");
|
||||
|
||||
// e.g. PhoneNumber => phone_number
|
||||
return underscore(name) + "_service";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toApiName(String name) {
|
||||
if (name.length() == 0) {
|
||||
return "DefaultService";
|
||||
}
|
||||
// e.g. phone_number => PhoneNumber
|
||||
return camelize(name) + "Service";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toApiVarName(String name) {
|
||||
if (name.length() == 0) {
|
||||
return "default_service";
|
||||
}
|
||||
return underscore(name) + "_service";
|
||||
}
|
||||
|
||||
public void setPackageName(String packageName) {
|
||||
this.packageName = packageName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toModelFilename(String name) {
|
||||
// underscore the model file name
|
||||
// PhoneNumber => phone_number
|
||||
return underscore(toModelName(name));
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toModelName(String name) {
|
||||
name = sanitizeName(name); // FIXME: a parameter should not be assigned. Also declare the methods parameters as 'final'.
|
||||
// remove dollar sign
|
||||
name = name.replaceAll("$", "");
|
||||
|
||||
// model name cannot use reserved keyword, e.g. return
|
||||
if (isReservedWord(name)) {
|
||||
LOGGER.warn(name + " (reserved word) cannot be used as model name. Renamed to " + camelize("model_" + name));
|
||||
name = "model_" + name; // e.g. return => ModelReturn (after camelize)
|
||||
}
|
||||
|
||||
// model name starts with number
|
||||
if (name.matches("^\\d.*")) {
|
||||
LOGGER.warn(name + " (model name starts with number) cannot be used as model name. Renamed to " + camelize("model_" + name));
|
||||
name = "model_" + name; // e.g. 200Response => Model200Response (after camelize)
|
||||
}
|
||||
|
||||
if (!StringUtils.isEmpty(modelNamePrefix)) {
|
||||
name = modelNamePrefix + "_" + name;
|
||||
}
|
||||
|
||||
if (!StringUtils.isEmpty(modelNameSuffix)) {
|
||||
name = name + "_" + modelNameSuffix;
|
||||
}
|
||||
|
||||
// camelize the model name
|
||||
// phone_number => PhoneNumber
|
||||
return camelize(name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSchemaType(Schema p) {
|
||||
String schemaType = super.getSchemaType(p);
|
||||
String type = null;
|
||||
if (typeMapping.containsKey(schemaType)) {
|
||||
type = typeMapping.get(schemaType);
|
||||
if (languageSpecificPrimitives.contains(type)) {
|
||||
return type;
|
||||
}
|
||||
} else {
|
||||
type = toModelName(schemaType);
|
||||
}
|
||||
return type;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Object> postProcessOperationsWithModels(Map<String, Object> objs, List<Object> allModels) {
|
||||
Map<String, Object> operations = (Map<String, Object>) objs.get("operations");
|
||||
List<CodegenOperation> operationList = (List<CodegenOperation>) operations.get("operation");
|
||||
for (CodegenOperation op : operationList) {
|
||||
int index = 1;
|
||||
for (CodegenParameter p : op.allParams) {
|
||||
// add x-protobuf-type: repeated if it's an array
|
||||
if (Boolean.TRUE.equals(p.isListContainer)) {
|
||||
p.vendorExtensions.put("x-protobuf-type", "repeated");
|
||||
} else if (Boolean.TRUE.equals(p.isMapContainer)) {
|
||||
LOGGER.warn("Map parameter (name: {}, operation ID: {}) not yet supported", p.paramName, op.operationId);
|
||||
}
|
||||
|
||||
// add x-protobuf-data-type
|
||||
// ref: https://developers.google.com/protocol-buffers/docs/proto3
|
||||
if (!p.vendorExtensions.containsKey("x-protobuf-data-type")) {
|
||||
if (Boolean.TRUE.equals(p.isListContainer)) {
|
||||
p.vendorExtensions.put("x-protobuf-data-type", p.items.dataType);
|
||||
} else {
|
||||
p.vendorExtensions.put("x-protobuf-data-type", p.dataType);
|
||||
}
|
||||
}
|
||||
|
||||
p.vendorExtensions.put("x-index", index);
|
||||
index++;
|
||||
}
|
||||
|
||||
if (StringUtils.isEmpty(op.returnType)) {
|
||||
op.vendorExtensions.put("x-grpc-response", "google.protobuf.Empty");
|
||||
} else {
|
||||
if (Boolean.FALSE.equals(op.returnTypeIsPrimitive) && StringUtils.isEmpty(op.returnContainer)) {
|
||||
op.vendorExtensions.put("x-grpc-response", op.returnType);
|
||||
} else {
|
||||
if ("map".equals(op.returnContainer)) {
|
||||
LOGGER.warn("Map response (operation ID: {}) not yet supported", op.operationId);
|
||||
op.vendorExtensions.put("x-grpc-response-type", op.returnBaseType);
|
||||
} else if ("array".equals(op.returnContainer)) {
|
||||
op.vendorExtensions.put("x-grpc-response-type", "repeated " + op.returnBaseType);
|
||||
} else { // primitive type
|
||||
op.vendorExtensions.put("x-grpc-response-type", op.returnBaseType);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return objs;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toModelImport(String name) {
|
||||
return underscore(name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTypeDeclaration(Schema p) {
|
||||
if (ModelUtils.isArraySchema(p)) {
|
||||
ArraySchema ap = (ArraySchema) p;
|
||||
Schema inner = ap.getItems();
|
||||
return getSchemaType(p) + "[" + getTypeDeclaration(inner) + "]";
|
||||
} else if (ModelUtils.isMapSchema(p)) {
|
||||
Schema inner = ModelUtils.getAdditionalProperties(p);
|
||||
return getSchemaType(p) + "[str, " + getTypeDeclaration(inner) + "]";
|
||||
}
|
||||
return super.getTypeDeclaration(p);
|
||||
}
|
||||
}
|
||||
@@ -67,6 +67,8 @@ public class TypeScriptAngularClientCodegen extends AbstractTypeScriptClientCode
|
||||
super();
|
||||
this.outputFolder = "generated-code/typescript-angular";
|
||||
|
||||
supportsMultipleInheritance = true;
|
||||
|
||||
embeddedTemplateDir = templateDir = "typescript-angular";
|
||||
modelTemplateFiles.put("model.mustache", ".ts");
|
||||
apiTemplateFiles.put("api.service.mustache", ".ts");
|
||||
|
||||
@@ -33,11 +33,15 @@ 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";
|
||||
public static final String TYPESCRIPT_THREE_PLUS = "typescriptThreePlus";
|
||||
|
||||
protected String npmRepository = null;
|
||||
private boolean useSingleRequestParameter = true;
|
||||
private boolean prefixParameterInterfaces = false;
|
||||
protected boolean addedApiIndex = false;
|
||||
protected boolean addedModelIndex = false;
|
||||
protected boolean typescriptThreePlus = false;
|
||||
|
||||
|
||||
public TypeScriptFetchClientCodegen() {
|
||||
@@ -59,6 +63,8 @@ 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()));
|
||||
this.cliOptions.add(new CliOption(TYPESCRIPT_THREE_PLUS, "Setting this property to true will generate TypeScript 3.6+ compatible code.", SchemaTypeUtil.BOOLEAN_TYPE).defaultValue(Boolean.FALSE.toString()));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -79,6 +85,14 @@ public class TypeScriptFetchClientCodegen extends AbstractTypeScriptClientCodege
|
||||
this.npmRepository = npmRepository;
|
||||
}
|
||||
|
||||
public Boolean getTypescriptThreePlus() {
|
||||
return typescriptThreePlus;
|
||||
}
|
||||
|
||||
public void setTypescriptThreePlus(Boolean typescriptThreePlus) {
|
||||
this.typescriptThreePlus = typescriptThreePlus;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void processOpts() {
|
||||
super.processOpts();
|
||||
@@ -94,9 +108,18 @@ 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();
|
||||
}
|
||||
|
||||
if (additionalProperties.containsKey(TYPESCRIPT_THREE_PLUS)) {
|
||||
this.setTypescriptThreePlus(convertPropertyToBoolean(TYPESCRIPT_THREE_PLUS));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -208,6 +231,7 @@ public class TypeScriptFetchClientCodegen extends AbstractTypeScriptClientCodege
|
||||
this.addOperationModelImportInfomation(operations);
|
||||
this.updateOperationParameterEnumInformation(operations);
|
||||
this.addOperationObjectResponseInformation(operations);
|
||||
this.addOperationPrefixParameterInterfacesInformation(operations);
|
||||
return operations;
|
||||
}
|
||||
|
||||
@@ -254,6 +278,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 +318,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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -359,14 +359,7 @@ public class ModelUtils {
|
||||
}
|
||||
|
||||
public static boolean isArraySchema(Schema schema) {
|
||||
if (schema instanceof ArraySchema) {
|
||||
return true;
|
||||
}
|
||||
// assume it's an array if maxItems, minItems is set
|
||||
if (schema != null && (schema.getMaxItems() != null || schema.getMinItems() != null)) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
return (schema instanceof ArraySchema);
|
||||
}
|
||||
|
||||
public static boolean isStringSchema(Schema schema) {
|
||||
@@ -896,6 +889,8 @@ public class ModelUtils {
|
||||
public static String getParentName(ComposedSchema composedSchema, Map<String, Schema> allSchemas) {
|
||||
List<Schema> interfaces = getInterfaces(composedSchema);
|
||||
|
||||
List<String> refedParentNames = new ArrayList<>();
|
||||
|
||||
if (interfaces != null && !interfaces.isEmpty()) {
|
||||
for (Schema schema : interfaces) {
|
||||
// get the actual schema
|
||||
@@ -911,6 +906,7 @@ public class ModelUtils {
|
||||
} else {
|
||||
LOGGER.debug("Not a parent since discriminator.propertyName is not set {}", s.get$ref());
|
||||
// not a parent since discriminator.propertyName is not set
|
||||
refedParentNames.add(parentName);
|
||||
}
|
||||
} else {
|
||||
// not a ref, doing nothing
|
||||
@@ -918,6 +914,13 @@ public class ModelUtils {
|
||||
}
|
||||
}
|
||||
|
||||
// parent name only makes sense when there is a single obvious parent
|
||||
if (refedParentNames.size() == 1) {
|
||||
LOGGER.warn("[deprecated] inheritance without use of 'discriminator.propertyName' is deprecated " +
|
||||
"and will be removed in a future release. Generating model for {}", composedSchema.getName());
|
||||
return refedParentNames.get(0);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@@ -138,6 +138,7 @@ ext {
|
||||
swagger_annotations_version = "1.5.22"
|
||||
jackson_version = "{{^threetenbp}}2.9.9{{/threetenbp}}{{#threetenbp}}2.6.4{{/threetenbp}}"
|
||||
jackson_databind_version = "{{^threetenbp}}2.9.9{{/threetenbp}}{{#threetenbp}}2.6.4{{/threetenbp}}"
|
||||
jackson-databind-nullable-version = "0.2.0"
|
||||
jersey_version = "1.19.4"
|
||||
jodatime_version = "2.9.9"
|
||||
junit_version = "4.12"
|
||||
@@ -152,6 +153,7 @@ dependencies {
|
||||
compile "com.fasterxml.jackson.core:jackson-annotations:$jackson_version"
|
||||
compile "com.fasterxml.jackson.core:jackson-databind:$jackson_databind_version"
|
||||
compile "com.fasterxml.jackson.jaxrs:jackson-jaxrs-json-provider:$jackson_version"
|
||||
compile "org.openapitools:jackson-databind-nullable:$jackson-databind-nullable-version"
|
||||
{{#joda}}
|
||||
compile "com.fasterxml.jackson.datatype:jackson-datatype-joda:$jackson_version"
|
||||
{{/joda}}
|
||||
|
||||
@@ -1,11 +1,17 @@
|
||||
#!/bin/sh
|
||||
# ref: https://help.github.com/articles/adding-an-existing-project-to-github-using-the-command-line/
|
||||
#
|
||||
# Usage example: /bin/sh ./git_push.sh wing328 openapi-pestore-perl "minor update"
|
||||
# Usage example: /bin/sh ./git_push.sh wing328 openapi-pestore-perl "minor update" "gitlab.com"
|
||||
|
||||
git_user_id=$1
|
||||
git_repo_id=$2
|
||||
release_note=$3
|
||||
git_host=$4
|
||||
|
||||
if [ "$git_host" = "" ]; then
|
||||
git_host="{{{gitHost}}}"
|
||||
echo "[INFO] No command line input provided. Set \$git_host to $git_host"
|
||||
fi
|
||||
|
||||
if [ "$git_user_id" = "" ]; then
|
||||
git_user_id="{{{gitUserId}}}"
|
||||
@@ -28,7 +34,7 @@ git init
|
||||
# Adds the files in the local repository and stages them for commit.
|
||||
git add .
|
||||
|
||||
# Commits the tracked changes and prepares them to be pushed to a remote repository.
|
||||
# Commits the tracked changes and prepares them to be pushed to a remote repository.
|
||||
git commit -m "$release_note"
|
||||
|
||||
# Sets the new remote
|
||||
@@ -37,9 +43,9 @@ if [ "$git_remote" = "" ]; then # git remote not defined
|
||||
|
||||
if [ "$GIT_TOKEN" = "" ]; then
|
||||
echo "[INFO] \$GIT_TOKEN (environment variable) is not set. Using the git credential in your environment."
|
||||
git remote add origin https://github.com/${git_user_id}/${git_repo_id}.git
|
||||
git remote add origin https://${git_host}/${git_user_id}/${git_repo_id}.git
|
||||
else
|
||||
git remote add origin https://${git_user_id}:${GIT_TOKEN}@github.com/${git_user_id}/${git_repo_id}.git
|
||||
git remote add origin https://${git_user_id}:${GIT_TOKEN}@${git_host}/${git_user_id}/${git_repo_id}.git
|
||||
fi
|
||||
|
||||
fi
|
||||
@@ -47,6 +53,6 @@ fi
|
||||
git pull origin master
|
||||
|
||||
# Pushes (Forces) the changes in the local repository up to the remote repository
|
||||
echo "Git pushing to https://github.com/${git_user_id}/${git_repo_id}.git"
|
||||
echo "Git pushing to https://${git_host}/${git_user_id}/${git_repo_id}.git"
|
||||
git push origin master 2>&1 | grep -v 'To https'
|
||||
|
||||
|
||||
@@ -122,6 +122,7 @@ ext {
|
||||
swagger_annotations_version = "1.5.22"
|
||||
jackson_version = "2.9.9"
|
||||
jackson_databind_version = "2.9.9"
|
||||
jackson-databind-nullable-version = "0.2.0"
|
||||
{{#threetenbp}}
|
||||
threepane_version = "2.6.4"
|
||||
{{/threetenbp}}
|
||||
@@ -141,6 +142,7 @@ dependencies {
|
||||
compile "com.fasterxml.jackson.core:jackson-core:$jackson_version"
|
||||
compile "com.fasterxml.jackson.core:jackson-annotations:$jackson_version"
|
||||
compile "com.fasterxml.jackson.core:jackson-databind:$jackson_databind_version"
|
||||
compile "org.openapitools:jackson-databind-nullable:$jackson-databind-nullable-version"
|
||||
{{#joda}}
|
||||
compile "com.fasterxml.jackson.datatype:jackson-datatype-joda:$jackson_version"
|
||||
{{/joda}}
|
||||
|
||||
@@ -6,6 +6,7 @@ import {{invokerPackage}}.ApiClient;
|
||||
{{/imports}}
|
||||
|
||||
import com.fasterxml.jackson.core.type.TypeReference;
|
||||
import com.google.api.client.http.EmptyContent;
|
||||
import com.google.api.client.http.GenericUrl;
|
||||
import com.google.api.client.http.HttpContent;
|
||||
import com.google.api.client.http.InputStreamContent;
|
||||
@@ -107,7 +108,7 @@ public class {{classname}} {
|
||||
String localVarUrl = uriBuilder{{#hasPathParams}}.buildFromMap(uriVariables).toString();{{/hasPathParams}}{{^hasPathParams}}.build().toString();{{/hasPathParams}}
|
||||
GenericUrl genericUrl = new GenericUrl(localVarUrl);
|
||||
|
||||
HttpContent content = {{#isBodyAllowed}}apiClient.new JacksonJsonHttpContent({{#bodyParam}}{{paramName}}{{/bodyParam}}{{^bodyParam}}null{{/bodyParam}}){{/isBodyAllowed}}{{^isBodyAllowed}}null{{/isBodyAllowed}};
|
||||
HttpContent content = {{#isBodyAllowed}}{{#bodyParam}}apiClient.new JacksonJsonHttpContent({{paramName}}){{/bodyParam}}{{^bodyParam}}new EmptyContent(){{/bodyParam}}{{/isBodyAllowed}}{{^isBodyAllowed}}null{{/isBodyAllowed}};
|
||||
return apiClient.getHttpRequestFactory().buildRequest(HttpMethods.{{httpMethod}}, genericUrl, content).execute();
|
||||
}{{#bodyParam}}
|
||||
|
||||
@@ -179,7 +180,7 @@ public class {{classname}} {
|
||||
String localVarUrl = uriBuilder{{#hasPathParams}}.buildFromMap(uriVariables).toString();{{/hasPathParams}}{{^hasPathParams}}.build().toString();{{/hasPathParams}}
|
||||
GenericUrl genericUrl = new GenericUrl(localVarUrl);
|
||||
|
||||
HttpContent content = {{#isBodyAllowed}}apiClient.new JacksonJsonHttpContent({{#bodyParam}}{{paramName}}{{/bodyParam}}{{^bodyParam}}null{{/bodyParam}}){{/isBodyAllowed}}{{^isBodyAllowed}}null{{/isBodyAllowed}};
|
||||
HttpContent content = {{#isBodyAllowed}}{{#bodyParam}}apiClient.new JacksonJsonHttpContent({{paramName}}){{/bodyParam}}{{^bodyParam}}new EmptyContent(){{/bodyParam}}{{/isBodyAllowed}}{{^isBodyAllowed}}null{{/isBodyAllowed}};
|
||||
return apiClient.getHttpRequestFactory().buildRequest(HttpMethods.{{httpMethod}}, genericUrl, content).execute();
|
||||
}
|
||||
|
||||
|
||||
@@ -122,6 +122,7 @@ ext {
|
||||
swagger_annotations_version = "1.5.22"
|
||||
jackson_version = "2.9.9"
|
||||
jackson_databind_version = "2.9.9"
|
||||
jackson-databind-nullable-version = "0.2.0"
|
||||
google_api_client_version = "1.23.0"
|
||||
jersey_common_version = "2.25.1"
|
||||
jodatime_version = "2.9.9"
|
||||
@@ -140,6 +141,7 @@ dependencies {
|
||||
compile "com.fasterxml.jackson.core:jackson-annotations:$jackson_version"
|
||||
compile "com.fasterxml.jackson.core:jackson-databind:$jackson_databind_version"
|
||||
compile "com.fasterxml.jackson.jaxrs:jackson-jaxrs-json-provider:$jackson_version"
|
||||
compile "org.openapitools:jackson-databind-nullable:$jackson-databind-nullable-version"
|
||||
{{#java8}}
|
||||
compile "com.fasterxml.jackson.datatype:jackson-datatype-jsr310:$jackson_version"
|
||||
{{/java8}}
|
||||
|
||||
@@ -704,7 +704,7 @@ public class ApiClient {
|
||||
}
|
||||
}
|
||||
|
||||
Entity<?> entity = serialize(body, formParams, contentType);
|
||||
Entity<?> entity = (body == null) ? Entity.json("") : serialize(body, formParams, contentType);
|
||||
|
||||
Response response = null;
|
||||
|
||||
@@ -716,11 +716,13 @@ public class ApiClient {
|
||||
} else if ("PUT".equals(method)) {
|
||||
response = invocationBuilder.put(entity);
|
||||
} else if ("DELETE".equals(method)) {
|
||||
response = invocationBuilder.delete();
|
||||
response = invocationBuilder.method("DELETE", entity);
|
||||
} else if ("PATCH".equals(method)) {
|
||||
response = invocationBuilder.method("PATCH", entity);
|
||||
} else if ("HEAD".equals(method)) {
|
||||
response = invocationBuilder.head();
|
||||
} else if ("OPTIONS".equals(method)) {
|
||||
response = invocationBuilder.options();
|
||||
} else if ("TRACE".equals(method)) {
|
||||
response = invocationBuilder.trace();
|
||||
} else {
|
||||
@@ -774,6 +776,8 @@ public class ApiClient {
|
||||
clientConfig.register(json);
|
||||
clientConfig.register(JacksonFeature.class);
|
||||
clientConfig.property(HttpUrlConnectorProvider.SET_METHOD_WORKAROUND, true);
|
||||
// turn off compliance validation to be able to send payloads with DELETE calls
|
||||
clientConfig.property(ClientProperties.SUPPRESS_HTTP_COMPLIANCE_VALIDATION, true);
|
||||
if (debugging) {
|
||||
{{^supportJava6}}
|
||||
clientConfig.register(new LoggingFeature(java.util.logging.Logger.getLogger(LoggingFeature.DEFAULT_LOGGER_NAME), java.util.logging.Level.INFO, LoggingFeature.Verbosity.PAYLOAD_ANY, 1024*50 /* Log payloads up to 50K */));
|
||||
@@ -784,6 +788,9 @@ public class ApiClient {
|
||||
{{#supportJava6}}
|
||||
clientConfig.register(new LoggingFilter(java.util.logging.Logger.getLogger(LoggingFilter.class.getName()), true));
|
||||
{{/supportJava6}}
|
||||
} else {
|
||||
// suppress warnings for payloads with DELETE calls:
|
||||
java.util.logging.Logger.getLogger("org.glassfish.jersey.client").setLevel(java.util.logging.Level.SEVERE);
|
||||
}
|
||||
performAdditionalClientConfiguration(clientConfig);
|
||||
return ClientBuilder.newClient(clientConfig);
|
||||
|
||||
@@ -107,7 +107,7 @@ public class {{classname}} {
|
||||
@Deprecated
|
||||
{{/isDeprecated}}
|
||||
public ApiResponse<{{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}Void{{/returnType}}> {{operationId}}WithHttpInfo({{#allParams}}{{{dataType}}} {{paramName}}{{#hasMore}}, {{/hasMore}}{{/allParams}}) throws ApiException {
|
||||
Object localVarPostBody = {{#bodyParam}}{{paramName}}{{/bodyParam}}{{^bodyParam}}new Object(){{/bodyParam}};
|
||||
Object localVarPostBody = {{#bodyParam}}{{paramName}}{{/bodyParam}}{{^bodyParam}}null{{/bodyParam}};
|
||||
{{#allParams}}{{#required}}
|
||||
// verify the required parameter '{{paramName}}' is set
|
||||
if ({{paramName}} == null) {
|
||||
|
||||
@@ -121,6 +121,7 @@ ext {
|
||||
swagger_annotations_version = "1.5.22"
|
||||
jackson_version = "2.9.9"
|
||||
jackson_databind_version = "2.9.9"
|
||||
jackson-databind-nullable-version = "0.2.0"
|
||||
{{#supportJava6}}
|
||||
jersey_version = "2.6"
|
||||
commons_io_version=2.5
|
||||
@@ -144,6 +145,7 @@ dependencies {
|
||||
compile "com.fasterxml.jackson.core:jackson-core:$jackson_version"
|
||||
compile "com.fasterxml.jackson.core:jackson-annotations:$jackson_version"
|
||||
compile "com.fasterxml.jackson.core:jackson-databind:$jackson_databind_version"
|
||||
compile "org.openapitools:jackson-databind-nullable:$jackson-databind-nullable-version"
|
||||
{{#joda}}
|
||||
compile "com.fasterxml.jackson.datatype:jackson-datatype-joda:$jackson_version"
|
||||
{{/joda}}
|
||||
|
||||
@@ -252,6 +252,17 @@ public class ApiClient {
|
||||
return scheme + "://" + host + (port == -1 ? "" : ":" + port) + basePath;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set a custom scheme for the target service, for example 'https'.
|
||||
*
|
||||
* @param scheme The scheme of the target service
|
||||
* @return This object.
|
||||
*/
|
||||
public ApiClient setScheme(String scheme){
|
||||
this.scheme = scheme;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set a custom request interceptor.
|
||||
*
|
||||
|
||||
@@ -90,7 +90,7 @@ public class {{classname}} {
|
||||
@Deprecated
|
||||
{{/isDeprecated}}
|
||||
public{{/vendorExtensions.x-group-parameters}}{{#vendorExtensions.x-group-parameters}}private{{/vendorExtensions.x-group-parameters}} okhttp3.Call {{operationId}}Call({{#allParams}}{{{dataType}}} {{paramName}}, {{/allParams}}final ApiCallback _callback) throws ApiException {
|
||||
Object localVarPostBody = {{#bodyParam}}{{paramName}}{{/bodyParam}}{{^bodyParam}}new Object(){{/bodyParam}};
|
||||
Object localVarPostBody = {{#bodyParam}}{{paramName}}{{/bodyParam}}{{^bodyParam}}null{{/bodyParam}};
|
||||
|
||||
// create path and map variables
|
||||
String localVarPath = "{{{path}}}"{{#pathParams}}
|
||||
|
||||
@@ -13,7 +13,8 @@ import java.util.function.Supplier;
|
||||
|
||||
import static io.restassured.config.ObjectMapperConfig.objectMapperConfig;
|
||||
import static io.restassured.config.RestAssuredConfig.config;
|
||||
import static {{invokerPackage}}.GsonObjectMapper.gson;
|
||||
import static {{invokerPackage}}.{{#gson}}GsonObjectMapper.gson{{/gson}}{{#jackson}}JacksonObjectMapper.jackson{{/jackson}};
|
||||
|
||||
{{/fullJavaUtil}}
|
||||
|
||||
public class ApiClient {
|
||||
@@ -42,7 +43,7 @@ public class ApiClient {
|
||||
public static class Config {
|
||||
private Supplier<RequestSpecBuilder> reqSpecSupplier = () -> new RequestSpecBuilder()
|
||||
{{#basePath}}.setBaseUri(BASE_URI){{/basePath}}
|
||||
.setConfig(config().objectMapperConfig(objectMapperConfig().defaultObjectMapper(gson())));
|
||||
.setConfig(config().objectMapperConfig(objectMapperConfig().defaultObjectMapper({{#gson}}gson(){{/gson}}{{#jackson}}jackson(){{/jackson}})));
|
||||
|
||||
/**
|
||||
* Use common specification for all operations
|
||||
|
||||
@@ -0,0 +1,64 @@
|
||||
{{>licenseInfo}}
|
||||
|
||||
package {{invokerPackage}};
|
||||
|
||||
{{#threetenbp}}
|
||||
import org.threeten.bp.*;
|
||||
{{/threetenbp}}
|
||||
import com.fasterxml.jackson.annotation.*;
|
||||
import com.fasterxml.jackson.databind.*;
|
||||
import org.openapitools.jackson.nullable.JsonNullableModule;
|
||||
{{#java8}}
|
||||
import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule;
|
||||
{{/java8}}
|
||||
{{#joda}}
|
||||
import com.fasterxml.jackson.datatype.joda.JodaModule;
|
||||
{{/joda}}
|
||||
{{#threetenbp}}
|
||||
import com.fasterxml.jackson.datatype.threetenbp.ThreeTenModule;
|
||||
{{/threetenbp}}
|
||||
|
||||
import io.restassured.internal.mapping.Jackson2Mapper;
|
||||
import io.restassured.path.json.mapper.factory.Jackson2ObjectMapperFactory;
|
||||
|
||||
|
||||
public class JacksonObjectMapper extends Jackson2Mapper {
|
||||
|
||||
private JacksonObjectMapper() {
|
||||
super(createFactory());
|
||||
}
|
||||
|
||||
private static Jackson2ObjectMapperFactory createFactory() {
|
||||
return (cls, charset) -> {
|
||||
ObjectMapper mapper = new ObjectMapper();
|
||||
mapper = new ObjectMapper();
|
||||
mapper.setSerializationInclusion(JsonInclude.Include.NON_NULL);
|
||||
mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
|
||||
mapper.configure(DeserializationFeature.FAIL_ON_INVALID_SUBTYPE, false);
|
||||
mapper.disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS);
|
||||
mapper.enable(SerializationFeature.WRITE_ENUMS_USING_TO_STRING);
|
||||
mapper.enable(DeserializationFeature.READ_ENUMS_USING_TO_STRING);
|
||||
mapper.setDateFormat(new RFC3339DateFormat());
|
||||
{{#java8}}
|
||||
mapper.registerModule(new JavaTimeModule());
|
||||
{{/java8}}
|
||||
{{#joda}}
|
||||
mapper.registerModule(new JodaModule());
|
||||
{{/joda}}
|
||||
{{#threetenbp}}
|
||||
ThreeTenModule module = new ThreeTenModule();
|
||||
module.addDeserializer(Instant.class, CustomInstantDeserializer.INSTANT);
|
||||
module.addDeserializer(OffsetDateTime.class, CustomInstantDeserializer.OFFSET_DATE_TIME);
|
||||
module.addDeserializer(ZonedDateTime.class, CustomInstantDeserializer.ZONED_DATE_TIME);
|
||||
mapper.registerModule(module);
|
||||
{{/threetenbp}}
|
||||
JsonNullableModule jnm = new JsonNullableModule();
|
||||
mapper.registerModule(jnm);
|
||||
return mapper;
|
||||
};
|
||||
}
|
||||
|
||||
public static JacksonObjectMapper jackson() {
|
||||
return new JacksonObjectMapper();
|
||||
}
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user