Compare commits

..

2 Commits

Author SHA1 Message Date
William Cheng
a049e4c271 better comment 2019-08-19 18:06:27 +08:00
William Cheng
eee7a40629 remove dollar sign from java const name 2019-08-19 15:42:59 +08:00
3502 changed files with 26137 additions and 40340 deletions

View File

@@ -145,6 +145,12 @@
"Documentation: Cwiki"
]
},
{
"input": "dart-flutter-petstore.sh",
"matches": [
"Client: Dart"
]
},
{
"input": "dart-jaguar-petstore.sh",
"matches": [

View File

@@ -94,8 +94,6 @@ 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

View File

@@ -2,32 +2,12 @@ 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: openjdk:11.0
image: hirokimatsumoto/alpine-openjdk-11
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

View File

@@ -14,6 +14,14 @@ 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`
@@ -21,6 +29,12 @@ 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

View File

@@ -1,73 +0,0 @@
<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>

View File

@@ -2,7 +2,7 @@
<div align="center">
[Master](https://github.com/OpenAPITools/openapi-generator/tree/master) (`4.1.1`): [![Build Status](https://img.shields.io/travis/OpenAPITools/openapi-generator/master.svg?label=Integration%20Test)](https://travis-ci.org/OpenAPITools/openapi-generator)
[Master](https://github.com/OpenAPITools/openapi-generator/tree/master) (`4.1.0`): [![Build Status](https://img.shields.io/travis/OpenAPITools/openapi-generator/master.svg?label=Integration%20Test)](https://travis-ci.org/OpenAPITools/openapi-generator)
[![Integration Test2](https://circleci.com/gh/OpenAPITools/openapi-generator.svg?style=shield)](https://circleci.com/gh/OpenAPITools/openapi-generator)
[![Run Status](https://api.shippable.com/projects/5af6bf74e790f4070084a115/badge?branch=master)](https://app.shippable.com/github/OpenAPITools/openapi-generator)
[![Windows Test](https://ci.appveyor.com/api/projects/status/github/openapitools/openapi-generator?branch=master&svg=true&passingText=Windows%20Test%20-%20OK&failingText=Windows%20Test%20-%20Fails)](https://ci.appveyor.com/project/WilliamCheng/openapi-generator-wh2wu)
@@ -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, .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 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 documentation generators** | **HTML**, **Confluence Wiki**
**Configuration files** | [**Apache2**](https://httpd.apache.org/)
**Others** | **GraphQL**, **JMeter**, **MySQL Schema**, **Protocol Buffer**
**Others** | **GraphQL**, **JMeter**, **MySQL Schema**
## 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.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)
4.1.1 (upcoming minor release) [SNAPSHOT](https://oss.sonatype.org/content/repositories/snapshots/org/openapitools/openapi-generator-cli/4.1.1-SNAPSHOT/)| 23.08.2019 | Patch release (bug fixes, enhancements)
[4.1.0](https://github.com/OpenAPITools/openapi-generator/releases/tag/v4.1.0) (latest stable release) | 09.08.2019 | Minor release (breaking changes with fallbacks)
OpenAPI Spec compatibility: 1.0, 1.1, 1.2, 2.0, 3.0
@@ -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.1/openapi-generator-cli-4.1.1.jar`
JAR location: `http://central.maven.org/maven2/org/openapitools/openapi-generator-cli/4.1.0/openapi-generator-cli-4.1.0.jar`
For **Mac/Linux** users:
```sh
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
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
```
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.1/openapi-generator-cli-4.1.1.jar
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
```
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.1):
Or install a particular OpenAPI Generator version (e.g. v4.1.0):
```sh
npm install @openapitools/openapi-generator-cli@cli-4.1.1 -g
npm install @openapitools/openapi-generator-cli@cli-4.1.0 -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.1/openapi-generator-cli-4.1.1.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.0/openapi-generator-cli-4.1.0.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,7 +560,6 @@ 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)
@@ -570,8 +569,6 @@ 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)
@@ -629,13 +626,6 @@ 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)
@@ -765,10 +755,8 @@ 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
@@ -812,7 +800,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) @nickmeinhold (2019/09) |
| Dart | @ircecho (2017/07) @swipesight (2018/09) @jaumard (2018/09) |
| Eiffel | @jvelilla (2017/09) |
| Elixir | @mrmstn (2018/12) |
| Elm | @eriktim (2018/09) |

50
bin/dart-flutter-petstore.sh Executable file
View File

@@ -0,0 +1,50 @@
#!/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.

View File

@@ -28,6 +28,23 @@ fi
# if you've executed sbt assembly previously it will use that instead.
export JAVA_OPTS="${JAVA_OPTS} -Xmx1024M -DloggerPath=conf/log4j.properties"
# Generate client
ags="generate -t modules/openapi-generator/src/main/resources/dart2 -i modules/openapi-generator/src/test/resources/2_0/petstore.yaml -g dart -o samples/client/petstore/dart2/openapi --additional-properties hideGenerationTimestamp=true $@"
# 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 $@"
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.

View File

@@ -22,7 +22,7 @@ executable="./modules/openapi-generator-cli/target/openapi-generator-cli.jar"
if [ ! -f "$executable" ]
then
./mvnw -B clean package
mvn -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
./mvnw clean package -f samples/meta-codegen/pom.xml
mvn 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 $@"

View File

@@ -1,32 +0,0 @@
#!/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

View File

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

View File

@@ -4,4 +4,3 @@
./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

View File

@@ -1,32 +0,0 @@
#!/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

View File

@@ -1,10 +0,0 @@
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%

View File

@@ -1,32 +0,0 @@
#!/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

View File

@@ -2,6 +2,5 @@
"gemName": "petstore",
"moduleName": "Petstore",
"library": "faraday",
"gemVersion": "1.0.0",
"strictSpecBehavior": false
"gemVersion": "1.0.0"
}

View File

@@ -2,6 +2,5 @@
"gemName": "petstore",
"library": "typhoeus",
"moduleName": "Petstore",
"gemVersion": "1.0.0",
"strictSpecBehavior": false
"gemVersion": "1.0.0"
}

View File

@@ -4,6 +4,4 @@
./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-prefix-parameter-interfaces.sh
./bin/typescript-fetch-petstore-typescript-three-plus.sh
./bin/typescript-fetch-petstore-multiple-parameters.sh

View File

@@ -1,7 +0,0 @@
{
"npmName": "@openapitools/typescript-fetch-petstore",
"npmVersion": "1.0.0",
"npmRepository" : "https://skimdb.npmjs.com/registry",
"snapshot" : false,
"prefixParameterInterfaces": true
}

View File

@@ -1,34 +0,0 @@
#!/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

View File

@@ -1,7 +0,0 @@
{
"npmName": "@openapitools/typescript-fetch-petstore",
"npmVersion": "1.0.0",
"npmRepository" : "https://skimdb.npmjs.com/registry",
"snapshot" : false,
"typescriptThreePlus": true
}

View File

@@ -1,32 +0,0 @@
#!/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

View File

@@ -59,9 +59,6 @@ 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

View File

@@ -1,10 +0,0 @@
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%

View File

@@ -5,5 +5,3 @@ 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

View File

@@ -1,12 +0,0 @@
@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%

View File

@@ -1,12 +0,0 @@
@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%

View File

@@ -125,14 +125,12 @@ 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)

View File

@@ -1,14 +0,0 @@
---
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|

View File

@@ -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>|netstandard2.0|
|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|
|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,4 +26,3 @@ 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|

View File

@@ -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 (Dart 1.x support has been deprecated)| |true|
|supportDart2|Support Dart 2.x| |true|
|nullableFields|Is the null fields should be in the JSON payload| |null|
|serialization|Choose serialization format JSON or PROTO is supported| |null|

View File

@@ -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 (Dart 1.x support has been deprecated)| |true|
|supportDart2|Support Dart 2.x| |true|

View File

@@ -13,5 +13,4 @@ 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|

View File

@@ -13,5 +13,4 @@ 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|

View File

@@ -1,9 +0,0 @@
---
id: generator-opts-config-grpc-schema
title: Config Options for grpc-schema
sidebar_label: grpc-schema
---
| Option | Description | Values | Default |
| ------ | ----------- | ------ | ------- |

View File

@@ -55,5 +55,4 @@ 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.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|
|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|

View File

@@ -14,7 +14,6 @@ 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 &quot;@Parcelize&quot; for generated models| |null|
|library|library template (sub-template)|<dl><dt>**ktor**</dt><dd>ktor framework</dd><dl>|ktor|
|featureAutoHead|Automatically provide responses to HEAD requests for existing routes that have the GET verb defined.| |true|

View File

@@ -14,7 +14,6 @@ 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 &quot;@Parcelize&quot; for generated models| |null|
|title|server title name or client service name| |OpenAPI Kotlin Spring|
|basePackage|base package (invokerPackage) for generated code| |org.openapitools|

View File

@@ -14,7 +14,6 @@ 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 &quot;@Parcelize&quot; for generated models| |null|
|dateLibrary|Option. Date library to use|<dl><dt>**string**</dt><dd>String</dd><dt>**java8**</dt><dd>Java 8 native JSR310</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|

View File

@@ -1,9 +0,0 @@
---
id: generator-opts-config-protobuf-schema
title: Config Options for protobuf-schema
sidebar_label: protobuf-schema
---
| Option | Description | Values | Default |
| ------ | ----------- | ------ | ------- |

View File

@@ -19,5 +19,3 @@ 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|

View File

@@ -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`. For the reasons behind the fork, please refer to the [Q&A](https://github.com/OpenAPITools/openapi-generator/blob/master/docs/qna.md).
OpenAPI Generator is a fork of `swagger-codegen` between version `2.3.1` and `2.4.0`.
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,7 +22,6 @@ 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
@@ -251,7 +250,3 @@ 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.

View File

@@ -4,7 +4,7 @@
<groupId>org.openapitools</groupId>
<artifactId>openapi-generator-project</artifactId>
<!-- RELEASE_VERSION -->
<version>4.1.2</version>
<version>4.1.1-SNAPSHOT</version>
<!-- /RELEASE_VERSION -->
<relativePath>../..</relativePath>
</parent>

View File

@@ -178,10 +178,6 @@ 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;
@@ -347,10 +343,6 @@ public class Generate implements Runnable {
configurator.setLibrary(library);
}
if (isNotEmpty(gitHost)) {
configurator.setGitHost(gitHost);
}
if (isNotEmpty(gitUserId)) {
configurator.setGitUserId(gitUserId);
}

View File

@@ -6,7 +6,7 @@
<artifactId>openapi-generator-project</artifactId>
<groupId>org.openapitools</groupId>
<!-- RELEASE_VERSION -->
<version>4.1.2</version>
<version>4.1.1-SNAPSHOT</version>
<!-- /RELEASE_VERSION -->
<relativePath>../..</relativePath>
</parent>

View File

@@ -30,7 +30,6 @@ 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";
@@ -55,7 +54,6 @@ 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;
@@ -258,17 +256,6 @@ 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>.
@@ -337,7 +324,6 @@ 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;
@@ -372,9 +358,6 @@ 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);
}
@@ -407,7 +390,6 @@ 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;
@@ -439,28 +421,13 @@ public final class GeneratorSettings implements Serializable {
builder.artifactId = copy.getArtifactId();
builder.artifactVersion = copy.getArtifactVersion();
builder.library = copy.getLibrary();
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.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());
builder.gitUserId = copy.getGitUserId();
builder.gitRepoId = copy.getGitRepoId();
builder.releaseNote = copy.getReleaseNote();
@@ -492,7 +459,6 @@ 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;
@@ -510,7 +476,6 @@ 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;
@@ -804,17 +769,6 @@ 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.
*
@@ -892,7 +846,6 @@ public final class GeneratorSettings implements Serializable {
", importMappings=" + importMappings +
", languageSpecificPrimitives=" + languageSpecificPrimitives +
", reservedWordMappings=" + reservedWordMappings +
", gitHost='" + gitHost + '\'' +
", gitUserId='" + gitUserId + '\'' +
", gitRepoId='" + gitRepoId + '\'' +
", releaseNote='" + releaseNote + '\'' +
@@ -922,7 +875,6 @@ 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()) &&
@@ -949,7 +901,6 @@ public final class GeneratorSettings implements Serializable {
getImportMappings(),
getLanguageSpecificPrimitives(),
getReservedWordMappings(),
getGitHost(),
getGitUserId(),
getGitRepoId(),
getReleaseNote(),

View File

@@ -33,48 +33,38 @@ 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 = 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 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 templateDir;
private String templatingEngineName = DEFAULT_TEMPLATING_ENGINE_NAME;
private String templatingEngineName;
private String ignoreFileOverride;
private ImmutableMap<String, String> systemProperties = DEFAULT_SYSTEM_PROPERTIES;
private ImmutableMap<String, String> systemProperties;
private WorkflowSettings(Builder builder) {
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);
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);
}
/**
@@ -82,7 +72,14 @@ public class WorkflowSettings {
*/
@SuppressWarnings("unused")
public WorkflowSettings() {
setDefaults();
systemProperties = ImmutableMap.of();
}
private void setDefaults(){
validateSpec = true;
strictSpecBehavior = true;
outputDir = ".";
}
public static Builder newBuilder() {
@@ -90,7 +87,7 @@ public class WorkflowSettings {
}
public static Builder newBuilder(WorkflowSettings copy) {
Builder builder = newBuilder();
Builder builder = new Builder();
builder.inputSpec = copy.getInputSpec();
builder.outputDir = copy.getOutputDir();
builder.verbose = copy.isVerbose();
@@ -260,24 +257,24 @@ public class WorkflowSettings {
@SuppressWarnings("unused")
public static final class Builder {
private String inputSpec;
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 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 templateDir;
private String templatingEngineName = DEFAULT_TEMPLATING_ENGINE_NAME;
private String templatingEngineName;
private String ignoreFileOverride;
private Map<String, String> systemProperties = new HashMap<>();;
private Map<String, String> systemProperties;
private Builder() {
systemProperties = new HashMap<>();
}
/**
* Sets the {@code inputSpec} and returns a reference to this Builder so that the methods can be chained together.
*
@@ -285,9 +282,7 @@ public class WorkflowSettings {
* @return a reference to this Builder
*/
public Builder withInputSpec(String inputSpec) {
if (inputSpec != null) {
this.inputSpec = inputSpec;
}
this.inputSpec = inputSpec;
return this;
}
@@ -298,11 +293,7 @@ public class WorkflowSettings {
* @return a reference to this Builder
*/
public Builder withOutputDir(String outputDir) {
if (outputDir != null ) {
this.outputDir = Paths.get(outputDir).toAbsolutePath().toString();
} else {
this.outputDir = DEFAULT_OUTPUT_DIR;
}
this.outputDir = Paths.get(outputDir).toAbsolutePath().toString();;
return this;
}
@@ -312,8 +303,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 != null ? verbose : Boolean.valueOf(DEFAULT_VERBOSE);
public Builder withVerbose(boolean verbose) {
this.verbose = verbose;
return this;
}
@@ -323,8 +314,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 != null ? skipOverwrite : Boolean.valueOf(DEFAULT_SKIP_OVERWRITE);
public Builder withSkipOverwrite(boolean skipOverwrite) {
this.skipOverwrite = skipOverwrite;
return this;
}
@@ -334,8 +325,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 != null ? removeOperationIdPrefix : Boolean.valueOf(DEFAULT_REMOVE_OPERATION_ID_PREFIX);
public Builder withRemoveOperationIdPrefix(boolean removeOperationIdPrefix) {
this.removeOperationIdPrefix = removeOperationIdPrefix;
return this;
}
@@ -345,8 +336,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 != null ? logToStderr : Boolean.valueOf(DEFAULT_LOG_TO_STDERR);
public Builder withLogToStderr(boolean logToStderr) {
this.logToStderr = logToStderr;
return this;
}
@@ -356,8 +347,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 != null ? validateSpec : Boolean.valueOf(DEFAULT_VALIDATE_SPEC);
public Builder withValidateSpec(boolean validateSpec) {
this.validateSpec = validateSpec;
return this;
}
@@ -367,8 +358,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 != null ? enablePostProcessFile : Boolean.valueOf(DEFAULT_ENABLE_POST_PROCESS_FILE);
public Builder withEnablePostProcessFile(boolean enablePostProcessFile) {
this.enablePostProcessFile = enablePostProcessFile;
return this;
}
@@ -378,8 +369,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 != null ? enableMinimalUpdate : Boolean.valueOf(DEFAULT_ENABLE_MINIMAL_UPDATE);
public Builder withEnableMinimalUpdate(boolean enableMinimalUpdate) {
this.enableMinimalUpdate = enableMinimalUpdate;
return this;
}
@@ -389,8 +380,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 != null ? strictSpecBehavior : Boolean.valueOf(DEFAULT_STRICT_SPEC_BEHAVIOR);
public Builder withStrictSpecBehavior(boolean strictSpecBehavior) {
this.strictSpecBehavior = strictSpecBehavior;
return this;
}
@@ -401,7 +392,9 @@ public class WorkflowSettings {
* @return a reference to this Builder
*/
public Builder withTemplateDir(String templateDir) {
if (templateDir != null) {
if (templateDir == null) {
this.templateDir = null;
} else {
File f = new File(templateDir);
// check to see if the folder exists
@@ -423,7 +416,7 @@ public class WorkflowSettings {
* @return a reference to this Builder
*/
public Builder withTemplatingEngineName(String templatingEngineName) {
this.templatingEngineName = templatingEngineName != null ? templatingEngineName : DEFAULT_TEMPLATING_ENGINE_NAME;
this.templatingEngineName = templatingEngineName;
return this;
}
@@ -445,9 +438,7 @@ public class WorkflowSettings {
* @return a reference to this Builder
*/
public Builder withSystemProperties(Map<String, String> systemProperties) {
if (systemProperties != null) {
this.systemProperties = systemProperties;
}
this.systemProperties = systemProperties;
return this;
}

View File

@@ -1,103 +0,0 @@
/*
* 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);
}
}

View File

@@ -45,7 +45,7 @@ compileJava.dependsOn tasks.openApiGenerate
[source,group]
----
plugins {
id "org.openapi.generator" version "4.1.1"
id "org.openapi.generator" version "4.1.0"
}
----
@@ -61,7 +61,7 @@ buildscript {
// url "https://plugins.gradle.org/m2/"
}
dependencies {
classpath "org.openapitools:openapi-generator-gradle-plugin:4.1.1"
classpath "org.openapitools:openapi-generator-gradle-plugin:4.1.0"
}
}
@@ -202,11 +202,6 @@ 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
@@ -626,7 +621,7 @@ buildscript {
}
dependencies {
classpath 'com.android.tools.build:gradle:3.2.1'
classpath('org.openapitools:openapi-generator-gradle-plugin:4.1.1') {
classpath('org.openapitools:openapi-generator-gradle-plugin:4.1.0') {
exclude group: 'com.google.guava'
}
}

View File

@@ -1,5 +1,5 @@
# RELEASE_VERSION
openApiGeneratorVersion=4.1.2
openApiGeneratorVersion=4.1.1-SNAPSHOT
# /RELEASE_VERSION
# BEGIN placeholders

View File

@@ -4,7 +4,7 @@
<groupId>org.openapitools</groupId>
<artifactId>openapi-generator-project</artifactId>
<!-- RELEASE_VERSION -->
<version>4.1.2</version>
<version>4.1.1-SNAPSHOT</version>
<!-- /RELEASE_VERSION -->
<relativePath>../..</relativePath>
</parent>

View File

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

View File

@@ -1,3 +1,3 @@
# RELEASE_VERSION
openApiGeneratorVersion=4.1.1
openApiGeneratorVersion=4.1.0
# /RELEASE_VERSION

View File

@@ -116,7 +116,6 @@ 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)

View File

@@ -160,11 +160,6 @@ 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.
*/

View File

@@ -204,12 +204,6 @@ 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.
*/
@@ -516,10 +510,6 @@ open class GenerateTask : DefaultTask() {
configurator.setLibrary(value)
}
gitHost.ifNotEmpty { value ->
configurator.setGitHost(value)
}
gitUserId.ifNotEmpty { value ->
configurator.setGitUserId(value)
}

View File

@@ -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.1</version>
<version>4.1.0</version>
<!-- /RELEASE_VERSION -->
<executions>
<execution>
@@ -91,7 +91,6 @@ 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

View File

@@ -13,11 +13,10 @@
<groupId>org.openapitools</groupId>
<artifactId>openapi-generator-maven-plugin</artifactId>
<!-- RELEASE_VERSION -->
<version>4.1.2-SNAPSHOT</version>
<version>4.1.1-SNAPSHOT</version>
<!-- /RELEASE_VERSION -->
<executions>
<execution>
<id>default</id>
<goals>
<goal>generate</goal>
</goals>
@@ -40,36 +39,6 @@
<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>

View File

@@ -19,7 +19,7 @@
<groupId>org.openapitools</groupId>
<artifactId>openapi-generator-maven-plugin</artifactId>
<!-- RELEASE_VERSION -->
<version>4.1.2-SNAPSHOT</version>
<version>4.1.1-SNAPSHOT</version>
<!-- /RELEASE_VERSION -->
<dependencies>
<dependency>

View File

@@ -13,7 +13,7 @@
<groupId>org.openapitools</groupId>
<artifactId>openapi-generator-maven-plugin</artifactId>
<!-- RELEASE_VERSION -->
<version>4.1.1</version>
<version>4.1.0</version>
<!-- /RELEASE_VERSION -->
<executions>
<execution>

View File

@@ -13,7 +13,7 @@
<groupId>org.openapitools</groupId>
<artifactId>openapi-generator-maven-plugin</artifactId>
<!-- RELEASE_VERSION -->
<version>4.1.1</version>
<version>4.1.0</version>
<!-- /RELEASE_VERSION -->
<executions>
<execution>

View File

@@ -5,7 +5,7 @@
<groupId>org.openapitools</groupId>
<artifactId>openapi-generator-project</artifactId>
<!-- RELEASE_VERSION -->
<version>4.1.2</version>
<version>4.1.1-SNAPSHOT</version>
<!-- /RELEASE_VERSION -->
<relativePath>../..</relativePath>
</parent>
@@ -66,7 +66,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-plugin-plugin</artifactId>
<version>3.6.0</version>
<version>3.5.2</version>
<configuration>
<skipErrorNoDescriptorsFound>true</skipErrorNoDescriptorsFound>
</configuration>

View File

@@ -20,18 +20,7 @@ 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;
@@ -53,7 +42,6 @@ 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;
@@ -109,12 +97,6 @@ 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.
*/
@@ -224,12 +206,6 @@ 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)
*/
@@ -441,7 +417,7 @@ public class CodeGenMojo extends AbstractMojo {
if (inputSpecFile.exists()) {
File storedInputSpecHashFile = getHashFile(inputSpecFile);
if(storedInputSpecHashFile.exists()) {
String inputSpecHash = calculateInputSpecHash(inputSpecFile);
String inputSpecHash = Files.asByteSource(inputSpecFile).hash(Hashing.sha256()).toString();
String storedInputSpecHash = Files.asCharSource(storedInputSpecHashFile, Charsets.UTF_8).read();
if (inputSpecHash.equals(storedInputSpecHash)) {
getLog().info(
@@ -474,10 +450,6 @@ public class CodeGenMojo extends AbstractMojo {
configurator.setInputSpec(inputSpec);
}
if (isNotEmpty(gitHost)) {
configurator.setGitHost(gitHost);
}
if (isNotEmpty(gitUserId)) {
configurator.setGitUserId(gitUserId);
}
@@ -490,10 +462,6 @@ public class CodeGenMojo extends AbstractMojo {
configurator.setIgnoreFileOverride(ignoreFileOverride);
}
if (isNotEmpty(httpUserAgent)) {
configurator.setHttpUserAgent(httpUserAgent);
}
if (skipValidateSpec != null) {
configurator.setValidateSpec(!skipValidateSpec);
}
@@ -732,7 +700,12 @@ public class CodeGenMojo extends AbstractMojo {
// Store a checksum of the input spec
File storedInputSpecHashFile = getHashFile(inputSpecFile);
String inputSpecHash = calculateInputSpecHash(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();
if (storedInputSpecHashFile.getParent() != null && !new File(storedInputSpecHashFile.getParent()).exists()) {
File parent = new File(storedInputSpecHashFile.getParent());
@@ -753,75 +726,8 @@ 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) {
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");
return new File(output.getPath() + File.separator + ".openapi-generator" + File.separator + inputSpecFile.getName() + ".sha256");
}
private String getCompileSourceRoot() {
@@ -831,7 +737,8 @@ public class CodeGenMojo extends AbstractMojo {
final String sourceFolder =
sourceFolderObject == null ? "src/main/java" : sourceFolderObject.toString();
return output.toString() + "/" + sourceFolder;
String sourceJavaFolder = output.toString() + "/" + sourceFolder;
return sourceJavaFolder;
}
private void addCompileSourceRootIfConfigured() {
@@ -876,4 +783,4 @@ public class CodeGenMojo extends AbstractMojo {
}
}
}
}
}

View File

@@ -4,7 +4,7 @@
<groupId>org.openapitools</groupId>
<artifactId>openapi-generator-project</artifactId>
<!-- RELEASE_VERSION -->
<version>4.1.2</version>
<version>4.1.1-SNAPSHOT</version>
<!-- /RELEASE_VERSION -->
<relativePath>../..</relativePath>
</parent>

View File

@@ -4,7 +4,7 @@
<groupId>org.openapitools</groupId>
<artifactId>openapi-generator-project</artifactId>
<!-- RELEASE_VERSION -->
<version>4.1.2</version>
<version>4.1.1-SNAPSHOT</version>
<!-- /RELEASE_VERSION -->
<relativePath>../..</relativePath>
</parent>
@@ -268,12 +268,6 @@
<!-- <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>
@@ -300,7 +294,7 @@
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
<version>3.0.0</version>
<version>2.23.0</version>
<scope>test</scope>
</dependency>
<dependency>

View File

@@ -222,10 +222,6 @@ public interface CodegenConfig {
*/
String getLibrary();
void setGitHost(String gitHost);
String getGitHost();
void setGitUserId(String gitUserId);
String getGitUserId();

View File

@@ -202,19 +202,12 @@ 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.";
@@ -315,7 +308,4 @@ 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";
}

View File

@@ -111,7 +111,7 @@ public class DefaultCodegen implements CodegenConfig {
protected Boolean sortParamsByRequiredFlag = true;
protected Boolean ensureUniqueParams = true;
protected Boolean allowUnicodeIdentifiers = false;
protected String gitHost, gitUserId, gitRepoId, releaseNote;
protected String 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(getSchemaItems(arraySchema));
String inner = getSchemaType(arraySchema.getItems());
return instantiationTypes.get("array") + "<" + inner + ">";
} else {
return null;
@@ -1462,15 +1462,6 @@ 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
*
@@ -2189,10 +2180,11 @@ public class DefaultCodegen implements CodegenConfig {
property.isFreeFormObject = true;
} else if (ModelUtils.isArraySchema(p)) {
// default to string if inner item is undefined
ArraySchema arraySchema = (ArraySchema) p;
Schema innerSchema = ModelUtils.unaliasSchema(this.openAPI, getSchemaItems(arraySchema));
if (arraySchema.getItems() == null) {
arraySchema.setItems(innerSchema);
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);
}
} else if (ModelUtils.isMapSchema(p)) {
Schema innerSchema = ModelUtils.unaliasSchema(this.openAPI, ModelUtils.getAdditionalProperties(p));
@@ -2270,10 +2262,11 @@ public class DefaultCodegen implements CodegenConfig {
if (itemName == null) {
itemName = property.name;
}
ArraySchema arraySchema = (ArraySchema) p;
Schema innerSchema = ModelUtils.unaliasSchema(this.openAPI, getSchemaItems(arraySchema));
if (arraySchema.getItems() == null) {
arraySchema.setItems(innerSchema);
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);
}
CodegenProperty cp = fromProperty(itemName, innerSchema);
updatePropertyForArray(property, cp);
@@ -2591,7 +2584,7 @@ public class DefaultCodegen implements CodegenConfig {
if (ModelUtils.isArraySchema(responseSchema)) {
ArraySchema as = (ArraySchema) responseSchema;
CodegenProperty innerProperty = fromProperty("response", getSchemaItems(as));
CodegenProperty innerProperty = fromProperty("response", as.getItems());
op.returnBaseType = innerProperty.baseType;
} else if (ModelUtils.isMapSchema(responseSchema)) {
CodegenProperty innerProperty = fromProperty("response", ModelUtils.getAdditionalProperties(responseSchema));
@@ -2666,13 +2659,11 @@ public class DefaultCodegen implements CodegenConfig {
CodegenParameter bodyParam = null;
RequestBody requestBody = operation.getRequestBody();
if (requestBody != null) {
String contentType = getContentType(requestBody);
if (contentType != null &&
(contentType.toLowerCase(Locale.ROOT).startsWith("application/x-www-form-urlencoded") ||
contentType.toLowerCase(Locale.ROOT).startsWith("multipart"))) {
if (getContentType(requestBody) != null &&
(getContentType(requestBody).toLowerCase(Locale.ROOT).startsWith("application/x-www-form-urlencoded") ||
getContentType(requestBody).toLowerCase(Locale.ROOT).startsWith("multipart/form-data"))) {
// process form parameters
formParams = fromRequestBodyToFormParameters(requestBody, imports);
op.isMultipart = contentType.toLowerCase(Locale.ROOT).startsWith("multipart");
for (CodegenParameter cp : formParams) {
postProcessParameter(cp);
}
@@ -2861,7 +2852,7 @@ public class DefaultCodegen implements CodegenConfig {
if (ModelUtils.isArraySchema(responseSchema)) {
ArraySchema as = (ArraySchema) responseSchema;
CodegenProperty innerProperty = fromProperty("response", getSchemaItems(as));
CodegenProperty innerProperty = fromProperty("response", as.getItems());
CodegenProperty innerCp = innerProperty;
while (innerCp != null) {
r.baseType = innerCp.baseType;
@@ -3069,8 +3060,10 @@ public class DefaultCodegen implements CodegenConfig {
String collectionFormat = null;
if (ModelUtils.isArraySchema(parameterSchema)) { // for array parameter
final ArraySchema arraySchema = (ArraySchema) parameterSchema;
Schema inner = getSchemaItems(arraySchema);
if (arraySchema.getItems() == null) {
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");
arraySchema.setItems(inner);
}
@@ -3906,24 +3899,6 @@ 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.
*
@@ -4488,8 +4463,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"))) {
consume.toLowerCase(Locale.ROOT).startsWith("application/x-www-form-urlencoded") ||
consume.toLowerCase(Locale.ROOT).startsWith("multipart/form-data")) {
return true;
}
}
@@ -4621,8 +4596,10 @@ public class DefaultCodegen implements CodegenConfig {
// array of schema
if (ModelUtils.isArraySchema(s)) {
final ArraySchema arraySchema = (ArraySchema) s;
Schema inner = getSchemaItems(arraySchema);
if (arraySchema.getItems() == null) {
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");
arraySchema.setItems(inner);
}
@@ -4819,8 +4796,10 @@ public class DefaultCodegen implements CodegenConfig {
setParameterNullable(codegenParameter, codegenProperty);
} else if (ModelUtils.isArraySchema(schema)) {
final ArraySchema arraySchema = (ArraySchema) schema;
Schema inner = getSchemaItems(arraySchema);
if (arraySchema.getItems() == null) {
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");
arraySchema.setItems(inner);
}
CodegenProperty codegenProperty = fromProperty("property", arraySchema);
@@ -4928,7 +4907,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/?'");
"'application/x-www-form-urlencoded' or 'multipart/form-data'");
LOGGER.warn("schema: " + schema);
LOGGER.warn("codegenModel is null. Default to UNKNOWN_BASE_TYPE");
codegenModelName = "UNKNOWN_BASE_TYPE";
@@ -5039,7 +5018,11 @@ public class DefaultCodegen implements CodegenConfig {
protected void generateJSONSpecFile(Map<String, Object> objs) {
OpenAPI openAPI = (OpenAPI) objs.get("openAPI");
if (openAPI != null) {
objs.put("openapi-json", SerializerUtils.toJsonString(openAPI));
try {
objs.put("openapi-json", Json.pretty().writeValueAsString(openAPI).replace("\r\n", "\n"));
} catch (JsonProcessingException e) {
LOGGER.error(e.getMessage(), e);
}
}
}

View File

@@ -37,7 +37,6 @@ 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;
@@ -184,12 +183,12 @@ public class DefaultGenerator extends AbstractGenerator implements Generator {
}
if (GlobalSettings.getProperty("debugOpenAPI") != null) {
SerializerUtils.toJsonString(openAPI);
Json.prettyPrint(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'.");
SerializerUtils.toJsonString(openAPI);
Json.prettyPrint(openAPI);
}
config.processOpts();

View File

@@ -91,7 +91,6 @@ 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);
@@ -222,11 +221,6 @@ 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;

View File

@@ -38,7 +38,6 @@ public abstract class AbstractGoCodegen extends DefaultCodegen implements Codege
protected boolean withGoCodegenComment = false;
protected boolean withXml = false;
protected boolean enumClassPrefix = false;
protected String packageName = "openapi";
@@ -374,7 +373,6 @@ 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
@@ -392,9 +390,8 @@ public abstract class AbstractGoCodegen extends DefaultCodegen implements Codege
}
// import "reflect" package if the parameter is collectionFormat=multi
if (!addedReflectImport && param.isCollectionFormatMulti) {
if (param.isCollectionFormatMulti) {
imports.add(createMapping("import", "reflect"));
addedReflectImport = true;
}
// import "optionals" package if the parameter is optional
@@ -621,10 +618,6 @@ 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) {

View File

@@ -17,6 +17,7 @@
package org.openapitools.codegen.languages;
import com.google.common.base.CaseFormat;
import com.google.common.base.Strings;
import io.swagger.v3.oas.models.OpenAPI;
import io.swagger.v3.oas.models.Operation;
@@ -686,8 +687,14 @@ public abstract class AbstractJavaCodegen extends DefaultCodegen implements Code
@Override
public String getTypeDeclaration(Schema p) {
if (ModelUtils.isArraySchema(p)) {
Schema<?> items = getSchemaItems((ArraySchema) p);
return getSchemaType(p) + "<" + getTypeDeclaration(items) + ">";
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) + ">";
} else if (ModelUtils.isMapSchema(p)) {
Schema inner = ModelUtils.getAdditionalProperties(p);
if (inner == null) {
@@ -712,6 +719,7 @@ 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>()";
@@ -719,9 +727,13 @@ public abstract class AbstractJavaCodegen extends DefaultCodegen implements Code
pattern = "new ArrayList<%s>()";
}
Schema<?> items = getSchemaItems((ArraySchema) p);
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);
}
String typeDeclaration = getTypeDeclaration(items);
String typeDeclaration = getTypeDeclaration(ap.getItems());
Object java8obj = additionalProperties.get("java8");
if (java8obj != null) {
Boolean java8 = Boolean.valueOf(java8obj.toString());
@@ -973,6 +985,9 @@ public abstract class AbstractJavaCodegen extends DefaultCodegen implements Code
model.imports.add("ApiModelProperty");
model.imports.add("ApiModel");
}
// store java constant property name in vendor extension, remove dollar sign from the constant name
property.vendorExtensions.put("x-java-const-name", CaseFormat.UPPER_CAMEL.to(CaseFormat.UPPER_UNDERSCORE, property.nameInCamelCase.replaceAll("\\$", "")));
}
@Override

View File

@@ -35,10 +35,6 @@ 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;
@@ -55,7 +51,6 @@ 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();
@@ -210,10 +205,6 @@ 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));
}
@@ -253,10 +244,6 @@ 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
*
@@ -274,24 +261,6 @@ 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
*
@@ -361,14 +330,6 @@ 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 {

View File

@@ -1,135 +0,0 @@
/*
* 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;
}
}

View File

@@ -65,7 +65,7 @@ public class CSharpNetCoreClientCodegen extends AbstractCSharpCodegen {
protected String modelDocPath = "docs/";
// Defines TargetFrameworkVersion in csproj files
protected String targetFramework = defaultFramework.name;
protected String targetFramework = defaultFramework.dotNetFrameworkVersion;
// Defines nuget identifiers for target framework
protected String targetFrameworkNuget = targetFramework;
@@ -78,8 +78,6 @@ 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();
@@ -208,10 +206,6 @@ 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");
@@ -476,7 +470,7 @@ public class CSharpNetCoreClientCodegen extends AbstractCSharpCodegen {
}
clientPackage = "Client";
String framework = (String) additionalProperties.getOrDefault(CodegenConstants.DOTNET_FRAMEWORK, defaultFramework.name);
String framework = (String) additionalProperties.getOrDefault(CodegenConstants.DOTNET_FRAMEWORK, defaultFramework.dotNetFrameworkVersion);
FrameworkStrategy strategy = defaultFramework;
for (FrameworkStrategy frameworkStrategy : frameworkStrategies) {
if (framework.equals(frameworkStrategy.name)) {
@@ -487,7 +481,7 @@ public class CSharpNetCoreClientCodegen extends AbstractCSharpCodegen {
strategy.configureAdditionalProperties(additionalProperties);
setTargetFrameworkNuget(strategy.getNugetFrameworkIdentifier());
setTargetFramework(strategy.name);
setTargetFramework(strategy.dotNetFrameworkVersion);
if (strategy != FrameworkStrategy.NETSTANDARD_2_0) {
LOGGER.warn("If using built-in templates-RestSharp only supports netstandard 2.0 or later.");
@@ -646,10 +640,6 @@ 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) {
@@ -810,7 +800,7 @@ public class CSharpNetCoreClientCodegen extends AbstractCSharpCodegen {
}
protected void configureAdditionalProperties(final Map<String, Object> properties) {
properties.putIfAbsent(CodegenConstants.DOTNET_FRAMEWORK, this.name);
properties.putIfAbsent(CodegenConstants.DOTNET_FRAMEWORK, this.dotNetFrameworkVersion);
// not intended to be user-settable
properties.put(TARGET_FRAMEWORK_IDENTIFIER, this.getTargetFrameworkIdentifier());

View File

@@ -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 = "dart2";
embeddedTemplateDir = templateDir = "dart";
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 (Dart 1.x support has been deprecated)").defaultValue(Boolean.TRUE.toString()));
cliOptions.add(CliOption.newBoolean(SUPPORT_DART2, "Support Dart 2.x").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 (deprecated) or 2.x) client library.";
return "Generates a Dart (1.x or 2.x) client library.";
}
@Override
@@ -202,10 +202,7 @@ public class DartClientCodegen extends DefaultCodegen implements CodegenConfig {
} else {
// dart 2.x
LOGGER.info("Dart version: 2.x");
// check to not overwrite a custom templateDir
if (templateDir == null) {
embeddedTemplateDir = templateDir = "dart2";
}
embeddedTemplateDir = templateDir = "dart2";
}
final String libFolder = sourceFolder + File.separator + "lib";

View File

@@ -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,13 +114,6 @@ 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) {

View File

@@ -78,9 +78,6 @@ 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;
@@ -98,7 +95,6 @@ public class JavaClientCodegen extends AbstractJavaCodegen
protected boolean useReflectionEqualsHashCode = false;
protected boolean caseInsensitiveResponseHeaders = false;
protected String authFolder;
protected String serializationLibrary = null;
public JavaClientCodegen() {
super();
@@ -132,18 +128,19 @@ 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.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(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(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.9.x");
supportedLibraries.put(RESTTEMPLATE, "HTTP client: Spring RestTemplate 4.x. JSON processing: Jackson 2.8.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.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(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(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");
@@ -153,12 +150,6 @@ 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
@@ -293,10 +284,6 @@ 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");
@@ -314,7 +301,7 @@ public class JavaClientCodegen extends AbstractJavaCodegen
}
if (FEIGN.equals(getLibrary())) {
forceSerializationLibrary(SERIALIZATION_LIBRARY_JACKSON);
additionalProperties.put("jackson", "true");
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())) {
@@ -329,60 +316,53 @@ 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"));
forceSerializationLibrary(SERIALIZATION_LIBRARY_GSON);
additionalProperties.put("gson", "true");
} else if (usesAnyRetrofitLibrary()) {
supportingFiles.add(new SupportingFile("auth/OAuthOkHttpClient.mustache", authFolder, "OAuthOkHttpClient.java"));
supportingFiles.add(new SupportingFile("CollectionFormats.mustache", invokerFolder, "CollectionFormats.java"));
forceSerializationLibrary(SERIALIZATION_LIBRARY_GSON);
additionalProperties.put("gson", "true");
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"));
forceSerializationLibrary(SERIALIZATION_LIBRARY_JACKSON);
additionalProperties.put("jackson", "true");
} else if (NATIVE.equals(getLibrary())) {
setJava8Mode(true);
additionalProperties.put("java8", "true");
forceSerializationLibrary(SERIALIZATION_LIBRARY_JACKSON);
additionalProperties.put("jackson", "true");
} else if (RESTEASY.equals(getLibrary())) {
supportingFiles.add(new SupportingFile("JSON.mustache", invokerFolder, "JSON.java"));
forceSerializationLibrary(SERIALIZATION_LIBRARY_JACKSON);
additionalProperties.put("jackson", "true");
} else if (JERSEY1.equals(getLibrary())) {
forceSerializationLibrary(SERIALIZATION_LIBRARY_JACKSON);
additionalProperties.put("jackson", "true");
} else if (RESTTEMPLATE.equals(getLibrary())) {
forceSerializationLibrary(SERIALIZATION_LIBRARY_JACKSON);
additionalProperties.put("jackson", "true");
supportingFiles.add(new SupportingFile("auth/Authentication.mustache", authFolder, "Authentication.java"));
} else if (WEBCLIENT.equals(getLibrary())) {
setJava8Mode(true);
additionalProperties.put("java8", "true");
forceSerializationLibrary(SERIALIZATION_LIBRARY_JACKSON);
additionalProperties.put("jackson", "true");
} else if (VERTX.equals(getLibrary())) {
typeMapping.put("file", "AsyncFile");
importMapping.put("AsyncFile", "io.vertx.core.file.AsyncFile");
setJava8Mode(true);
additionalProperties.put("java8", "true");
forceSerializationLibrary(SERIALIZATION_LIBRARY_JACKSON);
additionalProperties.put("jackson", "true");
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())) {
forceSerializationLibrary(SERIALIZATION_LIBRARY_JACKSON);
additionalProperties.put("jackson", "true");
} else if (REST_ASSURED.equals(getLibrary())) {
if(getSerializationLibrary() == null) {
LOGGER.info("No serializationLibrary configured, using '"+SERIALIZATION_LIBRARY_GSON+"' as fallback");
setSerializationLibrary(SERIALIZATION_LIBRARY_GSON);
}
if(SERIALIZATION_LIBRARY_JACKSON.equals(getSerializationLibrary())) {
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("gson", "true");
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());
}
@@ -435,30 +415,16 @@ public class JavaClientCodegen extends AbstractJavaCodegen
supportingFiles.add(new SupportingFile("auth/Authentication.mustache", authFolder, "Authentication.java"));
supportingFiles.add(new SupportingFile("Pair.mustache", invokerFolder, "Pair.java"));
forceSerializationLibrary(SERIALIZATION_LIBRARY_JACKSON);
additionalProperties.put("jackson", "true");
additionalProperties.remove("gson");
}
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"));
}
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"));
}
} 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() {
@@ -615,12 +581,12 @@ public class JavaClientCodegen extends AbstractJavaCodegen
if (!BooleanUtils.toBoolean(model.isEnum)) {
//final String lib = getLibrary();
//Needed imports for Jackson based libraries
if (additionalProperties.containsKey(SERIALIZATION_LIBRARY_JACKSON)) {
if (additionalProperties.containsKey("jackson")) {
model.imports.add("JsonProperty");
model.imports.add("JsonValue");
model.imports.add("JsonInclude");
}
if (additionalProperties.containsKey(SERIALIZATION_LIBRARY_GSON)) {
if (additionalProperties.containsKey("gson")) {
model.imports.add("SerializedName");
model.imports.add("TypeAdapter");
model.imports.add("JsonAdapter");
@@ -630,7 +596,7 @@ public class JavaClientCodegen extends AbstractJavaCodegen
}
} else { // enum class
//Needed imports for Jackson's JsonCreator
if (additionalProperties.containsKey(SERIALIZATION_LIBRARY_JACKSON)) {
if (additionalProperties.containsKey("jackson")) {
model.imports.add("JsonValue");
model.imports.add("JsonCreator");
}
@@ -641,7 +607,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(SERIALIZATION_LIBRARY_GSON)) {
if (additionalProperties.containsKey("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) {
@@ -662,7 +628,7 @@ public class JavaClientCodegen extends AbstractJavaCodegen
@Override
public Map<String, Object> postProcessModels(Map<String, Object> objs) {
objs = super.postProcessModels(objs);
if (additionalProperties.containsKey(SERIALIZATION_LIBRARY_JACKSON) && !JERSEY1.equals(getLibrary())) {
if (additionalProperties.containsKey("jackson") && !JERSEY1.equals(getLibrary())) {
List<Map<String, String>> imports = (List<Map<String, String>>) objs.get("imports");
List<Object> models = (List<Object>) objs.get("models");
for (Object _mo : models) {
@@ -746,31 +712,6 @@ 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(;.*)?");

View File

@@ -239,9 +239,6 @@ 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);

View File

@@ -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.replace(stringToMatch, replacement);
result = result.replaceAll(Pattern.quote(stringToMatch), replacement);
stringToMatch = "Controller.js";
replacement = "Service.js";
result = result.replace(stringToMatch, replacement);
result = result.replaceAll(Pattern.quote(stringToMatch), replacement);
}
return result;
}

View File

@@ -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 jsonOpenAPI = SerializerUtils.toJsonString(openAPI);
String swaggerString = Json.pretty(openAPI);
try {
String outputFile = outputFolder + File.separator + "openapi.json";
FileUtils.writeStringToFile(new File(outputFile), jsonOpenAPI);
FileUtils.writeStringToFile(new File(outputFile), swaggerString);
LOGGER.info("wrote file to " + outputFile);
} catch (Exception e) {
LOGGER.error(e.getMessage(), e);

View File

@@ -1,458 +0,0 @@
/*
* 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);
}
}

View File

@@ -67,8 +67,6 @@ 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");

View File

@@ -33,15 +33,11 @@ public class TypeScriptFetchClientCodegen extends AbstractTypeScriptClientCodege
public static final String NPM_REPOSITORY = "npmRepository";
public static final String WITH_INTERFACES = "withInterfaces";
public static final String USE_SINGLE_REQUEST_PARAMETER = "useSingleRequestParameter";
public static final String PREFIX_PARAMETER_INTERFACES = "prefixParameterInterfaces";
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() {
@@ -63,8 +59,6 @@ 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
@@ -85,14 +79,6 @@ 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();
@@ -108,18 +94,9 @@ 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
@@ -231,7 +208,6 @@ public class TypeScriptFetchClientCodegen extends AbstractTypeScriptClientCodege
this.addOperationModelImportInfomation(operations);
this.updateOperationParameterEnumInformation(operations);
this.addOperationObjectResponseInformation(operations);
this.addOperationPrefixParameterInterfacesInformation(operations);
return operations;
}
@@ -278,11 +254,6 @@ 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");
@@ -318,12 +289,4 @@ 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;
}
}

View File

@@ -4,7 +4,6 @@ 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;
@@ -16,7 +15,9 @@ public class SerializerUtils {
if(openAPI == null) {
return null;
}
SimpleModule module = createModule();
SimpleModule module = new SimpleModule("OpenAPIModule");
module.addSerializer(OpenAPI.class, new OpenAPISerializer());
try {
return Yaml.mapper()
.registerModule(module)
@@ -28,30 +29,4 @@ 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;
}
}

View File

@@ -359,7 +359,14 @@ public class ModelUtils {
}
public static boolean isArraySchema(Schema schema) {
return (schema instanceof ArraySchema);
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;
}
public static boolean isStringSchema(Schema schema) {
@@ -889,8 +896,6 @@ 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
@@ -906,7 +911,6 @@ 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
@@ -914,13 +918,6 @@ 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;
}

View File

@@ -138,7 +138,6 @@ 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"
@@ -153,7 +152,6 @@ 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}}

View File

@@ -1,17 +1,11 @@
#!/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" "gitlab.com"
# Usage example: /bin/sh ./git_push.sh wing328 openapi-pestore-perl "minor update"
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}}}"
@@ -34,7 +28,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
@@ -43,9 +37,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://${git_host}/${git_user_id}/${git_repo_id}.git
git remote add origin https://github.com/${git_user_id}/${git_repo_id}.git
else
git remote add origin https://${git_user_id}:${GIT_TOKEN}@${git_host}/${git_user_id}/${git_repo_id}.git
git remote add origin https://${git_user_id}:${GIT_TOKEN}@github.com/${git_user_id}/${git_repo_id}.git
fi
fi
@@ -53,6 +47,6 @@ fi
git pull origin master
# Pushes (Forces) the changes in the local repository up to the remote repository
echo "Git pushing to https://${git_host}/${git_user_id}/${git_repo_id}.git"
echo "Git pushing to https://github.com/${git_user_id}/${git_repo_id}.git"
git push origin master 2>&1 | grep -v 'To https'

View File

@@ -4,7 +4,7 @@
* If the field is required, always include it, even if it is null.
* Else use custom behaviour, IOW use whatever is defined on the object mapper
}}
@JsonProperty(JSON_PROPERTY_{{nameInSnakeCase}})
@JsonProperty(JSON_PROPERTY_{{vendorExtensions.x-java-const-name}})
@JsonInclude({{#isMapContainer}}{{#items.isNullable}}content = JsonInclude.Include.ALWAYS, {{/items.isNullable}}{{/isMapContainer}}value = JsonInclude.Include.{{#required}}ALWAYS{{/required}}{{^required}}USE_DEFAULTS{{/required}})
{{#withXml}}
{{^isContainer}}
@@ -16,4 +16,4 @@
@JacksonXmlElementWrapper(useWrapping = {{isXmlWrapped}}, {{#xmlNamespace}}namespace="{{xmlNamespace}}", {{/xmlNamespace}}localName = "{{#items.xmlName}}{{items.xmlName}}{{/items.xmlName}}{{^items.xmlName}}{{items.baseName}}{{/items.xmlName}}")
{{/isXmlWrapped}}
{{/isContainer}}
{{/withXml}}
{{/withXml}}

View File

@@ -122,7 +122,6 @@ 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}}
@@ -142,7 +141,6 @@ 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}}

View File

@@ -6,7 +6,6 @@ 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;
@@ -108,7 +107,7 @@ public class {{classname}} {
String localVarUrl = uriBuilder{{#hasPathParams}}.buildFromMap(uriVariables).toString();{{/hasPathParams}}{{^hasPathParams}}.build().toString();{{/hasPathParams}}
GenericUrl genericUrl = new GenericUrl(localVarUrl);
HttpContent content = {{#isBodyAllowed}}{{#bodyParam}}apiClient.new JacksonJsonHttpContent({{paramName}}){{/bodyParam}}{{^bodyParam}}new EmptyContent(){{/bodyParam}}{{/isBodyAllowed}}{{^isBodyAllowed}}null{{/isBodyAllowed}};
HttpContent content = {{#isBodyAllowed}}apiClient.new JacksonJsonHttpContent({{#bodyParam}}{{paramName}}{{/bodyParam}}{{^bodyParam}}null{{/bodyParam}}){{/isBodyAllowed}}{{^isBodyAllowed}}null{{/isBodyAllowed}};
return apiClient.getHttpRequestFactory().buildRequest(HttpMethods.{{httpMethod}}, genericUrl, content).execute();
}{{#bodyParam}}
@@ -180,7 +179,7 @@ public class {{classname}} {
String localVarUrl = uriBuilder{{#hasPathParams}}.buildFromMap(uriVariables).toString();{{/hasPathParams}}{{^hasPathParams}}.build().toString();{{/hasPathParams}}
GenericUrl genericUrl = new GenericUrl(localVarUrl);
HttpContent content = {{#isBodyAllowed}}{{#bodyParam}}apiClient.new JacksonJsonHttpContent({{paramName}}){{/bodyParam}}{{^bodyParam}}new EmptyContent(){{/bodyParam}}{{/isBodyAllowed}}{{^isBodyAllowed}}null{{/isBodyAllowed}};
HttpContent content = {{#isBodyAllowed}}apiClient.new JacksonJsonHttpContent({{#bodyParam}}{{paramName}}{{/bodyParam}}{{^bodyParam}}null{{/bodyParam}}){{/isBodyAllowed}}{{^isBodyAllowed}}null{{/isBodyAllowed}};
return apiClient.getHttpRequestFactory().buildRequest(HttpMethods.{{httpMethod}}, genericUrl, content).execute();
}

View File

@@ -122,7 +122,6 @@ 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"
@@ -141,7 +140,6 @@ 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}}

View File

@@ -704,7 +704,7 @@ public class ApiClient {
}
}
Entity<?> entity = (body == null) ? Entity.json("") : serialize(body, formParams, contentType);
Entity<?> entity = serialize(body, formParams, contentType);
Response response = null;
@@ -716,13 +716,11 @@ public class ApiClient {
} else if ("PUT".equals(method)) {
response = invocationBuilder.put(entity);
} else if ("DELETE".equals(method)) {
response = invocationBuilder.method("DELETE", entity);
response = invocationBuilder.delete();
} 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 {
@@ -776,8 +774,6 @@ 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 */));
@@ -788,9 +784,6 @@ 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);

View File

@@ -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}}null{{/bodyParam}};
Object localVarPostBody = {{#bodyParam}}{{paramName}}{{/bodyParam}}{{^bodyParam}}new Object(){{/bodyParam}};
{{#allParams}}{{#required}}
// verify the required parameter '{{paramName}}' is set
if ({{paramName}} == null) {

View File

@@ -121,7 +121,6 @@ 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
@@ -145,7 +144,6 @@ 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}}

View File

@@ -252,17 +252,6 @@ 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.
*

View File

@@ -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}}null{{/bodyParam}};
Object localVarPostBody = {{#bodyParam}}{{paramName}}{{/bodyParam}}{{^bodyParam}}new Object(){{/bodyParam}};
// create path and map variables
String localVarPath = "{{{path}}}"{{#pathParams}}

View File

@@ -13,8 +13,7 @@ import java.util.function.Supplier;
import static io.restassured.config.ObjectMapperConfig.objectMapperConfig;
import static io.restassured.config.RestAssuredConfig.config;
import static {{invokerPackage}}.{{#gson}}GsonObjectMapper.gson{{/gson}}{{#jackson}}JacksonObjectMapper.jackson{{/jackson}};
import static {{invokerPackage}}.GsonObjectMapper.gson;
{{/fullJavaUtil}}
public class ApiClient {
@@ -43,7 +42,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}}gson(){{/gson}}{{#jackson}}jackson(){{/jackson}})));
.setConfig(config().objectMapperConfig(objectMapperConfig().defaultObjectMapper(gson())));
/**
* Use common specification for all operations

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