forked from loafle/openapi-generator-original
Merge remote-tracking branch 'origin/4.2.x' into 5.0.x
This commit is contained in:
commit
5eb67d471b
6
.github/.test/samples.json
vendored
6
.github/.test/samples.json
vendored
@ -145,12 +145,6 @@
|
|||||||
"Documentation: Cwiki"
|
"Documentation: Cwiki"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
|
||||||
"input": "dart-flutter-petstore.sh",
|
|
||||||
"matches": [
|
|
||||||
"Client: Dart"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"input": "dart-jaguar-petstore.sh",
|
"input": "dart-jaguar-petstore.sh",
|
||||||
"matches": [
|
"matches": [
|
||||||
|
1
.gitignore
vendored
1
.gitignore
vendored
@ -186,6 +186,7 @@ samples/client/petstore/kotlin-string/build
|
|||||||
samples/openapi3/client/petstore/kotlin/build
|
samples/openapi3/client/petstore/kotlin/build
|
||||||
samples/server/petstore/kotlin-server/ktor/build
|
samples/server/petstore/kotlin-server/ktor/build
|
||||||
samples/server/petstore/kotlin-springboot/build
|
samples/server/petstore/kotlin-springboot/build
|
||||||
|
samples/client/petstore/kotlin-multiplatform/build/
|
||||||
\?
|
\?
|
||||||
|
|
||||||
# haskell
|
# haskell
|
||||||
|
@ -2,6 +2,11 @@ kind: pipeline
|
|||||||
name: default
|
name: default
|
||||||
|
|
||||||
steps:
|
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
|
# test Dart 2.x petstore client
|
||||||
- name: dart2x-test
|
- name: dart2x-test
|
||||||
image: google/dart
|
image: google/dart
|
||||||
|
43
README.md
43
README.md
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
<div align="center">
|
<div align="center">
|
||||||
|
|
||||||
[Master](https://github.com/OpenAPITools/openapi-generator/tree/master) (`4.1.1`): [](https://travis-ci.org/OpenAPITools/openapi-generator)
|
[Master](https://github.com/OpenAPITools/openapi-generator/tree/master) (`4.1.3-SNAPSHOT`): [](https://travis-ci.org/OpenAPITools/openapi-generator)
|
||||||
[](https://circleci.com/gh/OpenAPITools/openapi-generator)
|
[](https://circleci.com/gh/OpenAPITools/openapi-generator)
|
||||||
[](https://app.shippable.com/github/OpenAPITools/openapi-generator)
|
[](https://app.shippable.com/github/OpenAPITools/openapi-generator)
|
||||||
[](https://ci.appveyor.com/project/WilliamCheng/openapi-generator-wh2wu)
|
[](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 |
|
| | Languages/Frameworks |
|
||||||
|-|-|
|
|-|-|
|
||||||
**API clients** | **ActionScript**, **Ada**, **Apex**, **Bash**, **C**, **C#** (.net 2.0, 3.5 or later), **C++** (cpp-restsdk, Qt5, Tizen), **Clojure**, **Dart (1.x, 2.x)**, **Elixir**, **Elm**, **Eiffel**, **Erlang**, **Go**, **Groovy**, **Haskell** (http-client, Servant), **Java** (Jersey1.x, Jersey2.x, OkHttp, Retrofit1.x, Retrofit2.x, Feign, RestTemplate, RESTEasy, Vertx, Google API Client Library for Java, Rest-assured, Spring 5 Web Client), **Kotlin**, **Lua**, **Node.js/JavaScript** (ES5, ES6, AngularJS with Google Closure Compiler annotations, Flow types), **Objective-C**, **OCaml**, **Perl**, **PHP**, **PowerShell**, **Python**, **R**, **Ruby**, **Rust** (rust, rust-server), **Scala** (akka, http4s, scalaz, swagger-async-httpclient), **Swift** (2.x, 3.x, 4.x), **Typescript** (AngularJS, Angular (2.x - 8.x), Aurelia, Axios, Fetch, Inversify, jQuery, Node, Rxjs)
|
**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**, **Nim**, **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)
|
**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, Vertx), **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**
|
**API documentation generators** | **HTML**, **Confluence Wiki**, **Asciidoc**
|
||||||
**Configuration files** | [**Apache2**](https://httpd.apache.org/)
|
**Configuration files** | [**Apache2**](https://httpd.apache.org/)
|
||||||
**Others** | **GraphQL**, **JMeter**, **MySQL Schema**
|
**Others** | **GraphQL**, **JMeter**, **MySQL Schema**, **Protocol Buffer**
|
||||||
|
|
||||||
## Table of contents
|
## 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)
|
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.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.2 (upcoming minor release) [SNAPSHOT](https://oss.sonatype.org/content/repositories/snapshots/org/openapitools/openapi-generator-cli/4.1.2-SNAPSHOT/)| 13.09.2019 | Patch release (bug fixes, enhancements)
|
4.1.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.1](https://github.com/OpenAPITools/openapi-generator/releases/tag/v4.1.1) (latest stable release) | 26.08.2019 | Minor release (breaking changes with fallbacks)
|
[4.1.2](https://github.com/OpenAPITools/openapi-generator/releases/tag/v4.1.2) (latest stable release) | 12.09.2019 | Patch release (bug fixes, enhancements)
|
||||||
|
|
||||||
OpenAPI Spec compatibility: 1.0, 1.1, 1.2, 2.0, 3.0
|
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 -->
|
<!-- 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):
|
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.2/openapi-generator-cli-4.1.2.jar`
|
||||||
|
|
||||||
For **Mac/Linux** users:
|
For **Mac/Linux** users:
|
||||||
```sh
|
```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.2/openapi-generator-cli-4.1.2.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.
|
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.2/openapi-generator-cli-4.1.2.jar
|
||||||
```
|
```
|
||||||
|
|
||||||
After downloading the JAR, run `java -jar openapi-generator-cli.jar help` to show the usage.
|
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 -->
|
<!-- 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.2):
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
npm install @openapitools/openapi-generator-cli@cli-4.1.1 -g
|
npm install @openapitools/openapi-generator-cli@cli-4.1.2 -g
|
||||||
```
|
```
|
||||||
|
|
||||||
Or install it as dev-dependency:
|
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`)
|
(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 -->
|
<!-- 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.2/openapi-generator-cli-4.1.2.jar)
|
||||||
<!-- /RELEASE_VERSION -->
|
<!-- /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`
|
To get a list of **general** options available, please run `java -jar modules/openapi-generator-cli/target/openapi-generator-cli.jar help generate`
|
||||||
@ -560,6 +560,7 @@ Here are some companies/projects (alphabetical order) using OpenAPI Generator in
|
|||||||
- [Commencis](https://www.commencis.com/)
|
- [Commencis](https://www.commencis.com/)
|
||||||
- [Cupix](https://www.cupix.com/)
|
- [Cupix](https://www.cupix.com/)
|
||||||
- [DB Systel](https://www.dbsystel.de)
|
- [DB Systel](https://www.dbsystel.de)
|
||||||
|
- [Element AI](https://www.elementai.com/)
|
||||||
- [FormAPI](https://formapi.io/)
|
- [FormAPI](https://formapi.io/)
|
||||||
- [Fuse](https://www.fuse.no/)
|
- [Fuse](https://www.fuse.no/)
|
||||||
- [GenFlow](https://github.com/RepreZen/GenFlow)
|
- [GenFlow](https://github.com/RepreZen/GenFlow)
|
||||||
@ -567,9 +568,11 @@ Here are some companies/projects (alphabetical order) using OpenAPI Generator in
|
|||||||
- [GoDaddy](https://godaddy.com)
|
- [GoDaddy](https://godaddy.com)
|
||||||
- [JustStar](https://www.juststarinfo.com)
|
- [JustStar](https://www.juststarinfo.com)
|
||||||
- [Klarna](https://www.klarna.com/)
|
- [Klarna](https://www.klarna.com/)
|
||||||
|
- [Médiavision](https://www.mediavision.fr/)
|
||||||
- [Metaswitch](https://www.metaswitch.com/)
|
- [Metaswitch](https://www.metaswitch.com/)
|
||||||
- [Myworkout](https://myworkout.com)
|
- [Myworkout](https://myworkout.com)
|
||||||
- [Paxos](https://www.paxos.com)
|
- [Paxos](https://www.paxos.com)
|
||||||
|
- [Pricefx](https://www.pricefx.com/)
|
||||||
- [Prometheus/Alertmanager](https://github.com/prometheus/alertmanager)
|
- [Prometheus/Alertmanager](https://github.com/prometheus/alertmanager)
|
||||||
- [Raiffeisen Schweiz Genossenschaft](https://www.raiffeisen.ch)
|
- [Raiffeisen Schweiz Genossenschaft](https://www.raiffeisen.ch)
|
||||||
- [RepreZen API Studio](https://www.reprezen.com/swagger-openapi-code-generation-api-first-microservices-enterprise-development)
|
- [RepreZen API Studio](https://www.reprezen.com/swagger-openapi-code-generation-api-first-microservices-enterprise-development)
|
||||||
@ -629,7 +632,13 @@ Here are some companies/projects (alphabetical order) using OpenAPI Generator in
|
|||||||
- 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-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-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-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-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)
|
||||||
|
- 2019-09-14 - [Generating and Configuring a Mastercard API Client](https://developer.mastercard.com/platform/documentation/generating-and-configuring-a-mastercard-api-client/) at [Mastercard Developers Platform](https://developer.mastercard.com/platform/documentation/)
|
||||||
|
- 2019-09-15 - [OpenAPI(Swagger)導入下調べ](https://qiita.com/ShoichiKuraoka/items/f1f7a3c2376f7cd9c56a) by [Shoichi Kuraoka](https://qiita.com/ShoichiKuraoka)
|
||||||
|
|
||||||
## [6 - About Us](#table-of-contents)
|
## [6 - About Us](#table-of-contents)
|
||||||
|
|
||||||
@ -692,7 +701,9 @@ Here is a list of template creators:
|
|||||||
* Javascript (Flow types) @jaypea
|
* Javascript (Flow types) @jaypea
|
||||||
* JMeter: @davidkiss
|
* JMeter: @davidkiss
|
||||||
* Kotlin: @jimschubert [:heart:](https://www.patreon.com/jimschubert)
|
* Kotlin: @jimschubert [:heart:](https://www.patreon.com/jimschubert)
|
||||||
|
* Kotlin (MultiPlatform): @andrewemery
|
||||||
* Lua: @daurnimator
|
* Lua: @daurnimator
|
||||||
|
* Nim: @hokamoto
|
||||||
* OCaml: @cgensoul
|
* OCaml: @cgensoul
|
||||||
* Perl: @wing328 [:heart:](https://www.patreon.com/wing328)
|
* Perl: @wing328 [:heart:](https://www.patreon.com/wing328)
|
||||||
* PHP (Guzzle): @baartosz
|
* PHP (Guzzle): @baartosz
|
||||||
@ -741,6 +752,7 @@ Here is a list of template creators:
|
|||||||
* JAX-RS RestEasy (JBoss EAP): @jfiala
|
* JAX-RS RestEasy (JBoss EAP): @jfiala
|
||||||
* Kotlin: @jimschubert [:heart:](https://www.patreon.com/jimschubert)
|
* Kotlin: @jimschubert [:heart:](https://www.patreon.com/jimschubert)
|
||||||
* Kotlin (Spring Boot): @dr4ke616
|
* Kotlin (Spring Boot): @dr4ke616
|
||||||
|
* Kotlin (Vertx): @Wooyme
|
||||||
* NodeJS Express: @YishTish
|
* NodeJS Express: @YishTish
|
||||||
* PHP Laravel: @renepardon
|
* PHP Laravel: @renepardon
|
||||||
* PHP Lumen: @abcsun
|
* PHP Lumen: @abcsun
|
||||||
@ -754,6 +766,7 @@ Here is a list of template creators:
|
|||||||
* Scala Lagom: @gmkumar2005
|
* Scala Lagom: @gmkumar2005
|
||||||
* Scala Play: @adigerber
|
* Scala Play: @adigerber
|
||||||
* Documentation
|
* Documentation
|
||||||
|
* AsciiDoc: @man-at-home
|
||||||
* HTML Doc 2: @jhitchcock
|
* HTML Doc 2: @jhitchcock
|
||||||
* Confluence Wiki: @jhitchcock
|
* Confluence Wiki: @jhitchcock
|
||||||
* Configuration
|
* Configuration
|
||||||
@ -762,6 +775,7 @@ Here is a list of template creators:
|
|||||||
* Avro: @sgadouar
|
* Avro: @sgadouar
|
||||||
* GraphQL: @wing328 [:heart:](https://www.patreon.com/wing328)
|
* GraphQL: @wing328 [:heart:](https://www.patreon.com/wing328)
|
||||||
* MySQL: @ybelenko
|
* MySQL: @ybelenko
|
||||||
|
* Protocol Buffer: @wing328
|
||||||
|
|
||||||
:heart: = Link to support the contributor directly
|
:heart: = Link to support the contributor directly
|
||||||
|
|
||||||
@ -805,7 +819,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++ | @ravinikam (2017/07) @stkrwork (2017/07) @etherealjoy (2018/02) @martindelille (2018/03) @muttleyxd (2019/08) |
|
||||||
| C# | @mandrean (2017/08), @jimschubert (2017/09) [:heart:](https://www.patreon.com/jimschubert) |
|
| C# | @mandrean (2017/08), @jimschubert (2017/09) [:heart:](https://www.patreon.com/jimschubert) |
|
||||||
| Clojure | |
|
| Clojure | |
|
||||||
| Dart | @ircecho (2017/07) @swipesight (2018/09) @jaumard (2018/09) |
|
| Dart | @ircecho (2017/07) @swipesight (2018/09) @jaumard (2018/09) @nickmeinhold (2019/09) |
|
||||||
| Eiffel | @jvelilla (2017/09) |
|
| Eiffel | @jvelilla (2017/09) |
|
||||||
| Elixir | @mrmstn (2018/12) |
|
| Elixir | @mrmstn (2018/12) |
|
||||||
| Elm | @eriktim (2018/09) |
|
| Elm | @eriktim (2018/09) |
|
||||||
@ -818,6 +832,7 @@ If you want to join the committee, please kindly apply by sending an email to te
|
|||||||
| Java | @bbdouglas (2017/07) @sreeshas (2017/08) @jfiala (2017/08) @lukoyanov (2017/09) @cbornet (2017/09) @jeff9finger (2018/01) @karismann (2019/03) @Zomzog (2019/04) |
|
| Java | @bbdouglas (2017/07) @sreeshas (2017/08) @jfiala (2017/08) @lukoyanov (2017/09) @cbornet (2017/09) @jeff9finger (2018/01) @karismann (2019/03) @Zomzog (2019/04) |
|
||||||
| Kotlin | @jimschubert (2017/09) [:heart:](https://www.patreon.com/jimschubert), @dr4ke616 (2018/08) @karismann (2019/03) @Zomzog (2019/04) |
|
| Kotlin | @jimschubert (2017/09) [:heart:](https://www.patreon.com/jimschubert), @dr4ke616 (2018/08) @karismann (2019/03) @Zomzog (2019/04) |
|
||||||
| Lua | @daurnimator (2017/08) |
|
| Lua | @daurnimator (2017/08) |
|
||||||
|
| Nim | |
|
||||||
| NodeJS/Javascript | @CodeNinjai (2017/07) @frol (2017/07) @cliffano (2017/07) |
|
| NodeJS/Javascript | @CodeNinjai (2017/07) @frol (2017/07) @cliffano (2017/07) |
|
||||||
| ObjC | |
|
| ObjC | |
|
||||||
| OCaml | @cgensoul (2019/08) |
|
| OCaml | @cgensoul (2019/08) |
|
||||||
|
31
bin/asciidoc-documentation-petstore.sh
Executable file
31
bin/asciidoc-documentation-petstore.sh
Executable file
@ -0,0 +1,31 @@
|
|||||||
|
#!/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 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/asciidoc-documentation --additional-properties=specDir=modules/openapi-generator/src/main/resources/asciidoc-documentation,snippetDir=. -i modules/openapi-generator/src/test/resources/2_0/petstore.yaml -g asciidoc -o samples/documentation/asciidoc"
|
||||||
|
|
||||||
|
java ${JAVA_OPTS} -jar ${executable} ${ags}
|
@ -1,50 +0,0 @@
|
|||||||
#!/bin/sh
|
|
||||||
|
|
||||||
SCRIPT="$0"
|
|
||||||
|
|
||||||
while [ -h "$SCRIPT" ] ; do
|
|
||||||
ls=`ls -ld "$SCRIPT"`
|
|
||||||
link=`expr "$ls" : '.*-> \(.*\)$'`
|
|
||||||
if expr "$link" : '/.*' > /dev/null; then
|
|
||||||
SCRIPT="$link"
|
|
||||||
else
|
|
||||||
SCRIPT=`dirname "$SCRIPT"`/"$link"
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
|
|
||||||
if [ ! -d "${APP_DIR}" ]; then
|
|
||||||
APP_DIR=`dirname "$SCRIPT"`/..
|
|
||||||
APP_DIR=`cd "${APP_DIR}"; pwd`
|
|
||||||
fi
|
|
||||||
|
|
||||||
executable="./modules/openapi-generator-cli/target/openapi-generator-cli.jar"
|
|
||||||
|
|
||||||
if [ ! -f "$executable" ]
|
|
||||||
then
|
|
||||||
mvn -B clean package
|
|
||||||
fi
|
|
||||||
|
|
||||||
# if you've executed sbt assembly previously it will use that instead.
|
|
||||||
export JAVA_OPTS="${JAVA_OPTS} -Xmx1024M -DloggerPath=conf/log4j.properties"
|
|
||||||
|
|
||||||
## Generate non-browserClient
|
|
||||||
#ags="generate -t modules/openapi-generator/src/main/resources/dart -i modules/openapi-generator/src/test/resources/2_0/petstore.yaml -g dart -o samples/client/petstore/dart/swagger --additional-properties hideGenerationTimestamp=true,browserClient=false $@"
|
|
||||||
#
|
|
||||||
## then options to generate the library for vm would be:
|
|
||||||
##ags="generate -i modules/openapi-generator/src/test/resources/2_0/petstore.yaml -g dart -o samples/client/petstore/dart/swagger_vm --additional-properties browserClient=false,pubName=swagger_vm $@"
|
|
||||||
#java $JAVA_OPTS -jar $executable $ags
|
|
||||||
#
|
|
||||||
## Generate browserClient
|
|
||||||
#ags="generate -t modules/openapi-generator/src/main/resources/dart -i modules/openapi-generator/src/test/resources/2_0/petstore.yaml -g dart -o samples/client/petstore/dart/swagger-browser-client --additional-properties hideGenerationTimestamp=true,browserClient=true $@"
|
|
||||||
#java $JAVA_OPTS -jar $executable $ags
|
|
||||||
|
|
||||||
# Generate non-browserClient and put it to the flutter sample app
|
|
||||||
ags="generate -t modules/openapi-generator/src/main/resources/dart -i modules/openapi-generator/src/test/resources/2_0/petstore.yaml -g dart -o samples/client/petstore/dart/flutter_petstore/swagger --additional-properties hideGenerationTimestamp=true,browserClient=false $@"
|
|
||||||
java $JAVA_OPTS -jar $executable $ags
|
|
||||||
|
|
||||||
# There is a proposal to allow importing different libraries depending on the environment:
|
|
||||||
# https://github.com/munificent/dep-interface-libraries
|
|
||||||
# When this is implemented there will only be one library.
|
|
||||||
|
|
||||||
# The current petstore test will then work for both: the browser library and the vm library.
|
|
||||||
|
|
@ -28,23 +28,6 @@ fi
|
|||||||
# if you've executed sbt assembly previously it will use that instead.
|
# if you've executed sbt assembly previously it will use that instead.
|
||||||
export JAVA_OPTS="${JAVA_OPTS} -Xmx1024M -DloggerPath=conf/log4j.properties"
|
export JAVA_OPTS="${JAVA_OPTS} -Xmx1024M -DloggerPath=conf/log4j.properties"
|
||||||
|
|
||||||
# Generate non-browserClient
|
# Generate client
|
||||||
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 $@"
|
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 $@"
|
||||||
|
|
||||||
# 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
|
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.
|
|
||||||
|
32
bin/kotlin-client-petstore-multiplatform.sh
Executable file
32
bin/kotlin-client-petstore-multiplatform.sh
Executable file
@ -0,0 +1,32 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
SCRIPT="$0"
|
||||||
|
echo "# START SCRIPT: $SCRIPT"
|
||||||
|
|
||||||
|
while [ -h "$SCRIPT" ] ; do
|
||||||
|
ls=$(ls -ld "$SCRIPT")
|
||||||
|
link=$(expr "$ls" : '.*-> \(.*\)$')
|
||||||
|
if expr "$link" : '/.*' > /dev/null; then
|
||||||
|
SCRIPT="$link"
|
||||||
|
else
|
||||||
|
SCRIPT=$(dirname "$SCRIPT")/"$link"
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
if [ ! -d "${APP_DIR}" ]; then
|
||||||
|
APP_DIR=$(dirname "$SCRIPT")/..
|
||||||
|
APP_DIR=$(cd "${APP_DIR}"; pwd)
|
||||||
|
fi
|
||||||
|
|
||||||
|
executable="./modules/openapi-generator-cli/target/openapi-generator-cli.jar"
|
||||||
|
|
||||||
|
if [ ! -f "$executable" ]
|
||||||
|
then
|
||||||
|
mvn -B clean package
|
||||||
|
fi
|
||||||
|
|
||||||
|
# if you've executed sbt assembly previously it will use that instead.
|
||||||
|
export JAVA_OPTS="${JAVA_OPTS} -Xmx1024M -DloggerPath=conf/log4j.properties"
|
||||||
|
ags="generate -t modules/openapi-generator/src/main/resources/kotlin-client -i modules/openapi-generator/src/test/resources/2_0/petstore.yaml -g kotlin --artifact-id kotlin-client-petstore-multiplatform --library multiplatform -o samples/client/petstore/kotlin-multiplatform $@"
|
||||||
|
|
||||||
|
java ${JAVA_OPTS} -jar ${executable} ${ags}
|
31
bin/kotlin-vertx-server-petstore.sh
Executable file
31
bin/kotlin-vertx-server-petstore.sh
Executable file
@ -0,0 +1,31 @@
|
|||||||
|
#!/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 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 kotlin-vertx -o samples/server/petstore/kotlin/vertx"
|
||||||
|
|
||||||
|
java ${JAVA_OPTS} -jar ${executable} ${ags}
|
31
bin/nim-client-petstore.sh
Executable file
31
bin/nim-client-petstore.sh
Executable file
@ -0,0 +1,31 @@
|
|||||||
|
#!/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 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/nim-client -i modules/openapi-generator/src/test/resources/2_0/petstore.yaml --additional-properties packageName=petstore -g nim -o samples/client/petstore/nim"
|
||||||
|
|
||||||
|
java ${JAVA_OPTS} -jar ${executable} ${ags}
|
35
bin/openapi3/kotlin-client-petstore-multiplatform.sh
Executable file
35
bin/openapi3/kotlin-client-petstore-multiplatform.sh
Executable file
@ -0,0 +1,35 @@
|
|||||||
|
#!/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
|
||||||
|
|
||||||
|
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-client-petstore-multiplatform --library multiplatform -o samples/openapi3/client/petstore/kotlin-multiplatform $@"
|
||||||
|
|
||||||
|
echo "Cleaning previously generated files if any from samples/openapi3/client/petstore/kotlin-multiplatform"
|
||||||
|
rm -rf samples/openapi3/client/petstore/kotlin-multiplatform
|
||||||
|
|
||||||
|
echo "Generating Kotling client..."
|
||||||
|
java $JAVA_OPTS -jar $executable $ags
|
@ -26,7 +26,7 @@ then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
export JAVA_OPTS="${JAVA_OPTS} -Xmx1024M -DloggerPath=conf/log4j.properties"
|
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"
|
echo "Cleaning previously generated files if any from samples/openapi3/client/petstore/kotlin"
|
||||||
rm -rf samples/openapi3/client/petstore/kotlin
|
rm -rf samples/openapi3/client/petstore/kotlin
|
||||||
|
10
bin/openapi3/windows/nodejs-express-server-petstore.bat
Executable file
10
bin/openapi3/windows/nodejs-express-server-petstore.bat
Executable file
@ -0,0 +1,10 @@
|
|||||||
|
set executable=.\modules\openapi-generator-cli\target\openapi-generator-cli.jar
|
||||||
|
|
||||||
|
If Not Exist %executable% (
|
||||||
|
mvn clean package
|
||||||
|
)
|
||||||
|
|
||||||
|
REM set JAVA_OPTS=%JAVA_OPTS% -Xmx1024M -DloggerPath=conf/log4j.properties
|
||||||
|
set ags=generate -i modules\openapi-generator\src\test\resources\3_0\petstore.yaml -g nodejs-express-server -o samples\openapi3\server\petstore\nodejs-express-server
|
||||||
|
|
||||||
|
java %JAVA_OPTS% -jar %executable% %ags%
|
32
bin/protobuf-schema-petstore.sh
Executable file
32
bin/protobuf-schema-petstore.sh
Executable file
@ -0,0 +1,32 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
SCRIPT="$0"
|
||||||
|
echo "# START SCRIPT: $SCRIPT"
|
||||||
|
|
||||||
|
while [ -h "$SCRIPT" ] ; do
|
||||||
|
ls=`ls -ld "$SCRIPT"`
|
||||||
|
link=`expr "$ls" : '.*-> \(.*\)$'`
|
||||||
|
if expr "$link" : '/.*' > /dev/null; then
|
||||||
|
SCRIPT="$link"
|
||||||
|
else
|
||||||
|
SCRIPT=`dirname "$SCRIPT"`/"$link"
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
if [ ! -d "${APP_DIR}" ]; then
|
||||||
|
APP_DIR=`dirname "$SCRIPT"`/..
|
||||||
|
APP_DIR=`cd "${APP_DIR}"; pwd`
|
||||||
|
fi
|
||||||
|
|
||||||
|
executable="./modules/openapi-generator-cli/target/openapi-generator-cli.jar"
|
||||||
|
|
||||||
|
if [ ! -f "$executable" ]
|
||||||
|
then
|
||||||
|
mvn -B clean package
|
||||||
|
fi
|
||||||
|
|
||||||
|
# if you've executed sbt assembly previously it will use that instead.
|
||||||
|
export JAVA_OPTS="${JAVA_OPTS} -Xmx1024M -DloggerPath=conf/log4j.properties $@"
|
||||||
|
ags="generate -t modules/openapi-generator/src/main/resources/protobuf-schema -i modules/openapi-generator/src/test/resources/2_0/petstore.yaml -g protobuf-schema -o samples/config/petstore/protobuf-schema --additional-properties packageName=petstore $@"
|
||||||
|
|
||||||
|
java $JAVA_OPTS -jar $executable $ags
|
@ -6,3 +6,4 @@
|
|||||||
./bin/typescript-fetch-petstore.sh
|
./bin/typescript-fetch-petstore.sh
|
||||||
./bin/typescript-fetch-petstore-multiple-parameters.sh
|
./bin/typescript-fetch-petstore-multiple-parameters.sh
|
||||||
./bin/typescript-fetch-petstore-prefix-parameter-interfaces.sh
|
./bin/typescript-fetch-petstore-prefix-parameter-interfaces.sh
|
||||||
|
./bin/typescript-fetch-petstore-typescript-three-plus.sh
|
||||||
|
7
bin/typescript-fetch-petstore-typescript-three-plus.json
Normal file
7
bin/typescript-fetch-petstore-typescript-three-plus.json
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
{
|
||||||
|
"npmName": "@openapitools/typescript-fetch-petstore",
|
||||||
|
"npmVersion": "1.0.0",
|
||||||
|
"npmRepository" : "https://skimdb.npmjs.com/registry",
|
||||||
|
"snapshot" : false,
|
||||||
|
"typescriptThreePlus": true
|
||||||
|
}
|
32
bin/typescript-fetch-petstore-typescript-three-plus.sh
Executable file
32
bin/typescript-fetch-petstore-typescript-three-plus.sh
Executable file
@ -0,0 +1,32 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
SCRIPT="$0"
|
||||||
|
echo "# START SCRIPT: $SCRIPT"
|
||||||
|
|
||||||
|
while [ -h "$SCRIPT" ] ; do
|
||||||
|
ls=`ls -ld "$SCRIPT"`
|
||||||
|
link=`expr "$ls" : '.*-> \(.*\)$'`
|
||||||
|
if expr "$link" : '/.*' > /dev/null; then
|
||||||
|
SCRIPT="$link"
|
||||||
|
else
|
||||||
|
SCRIPT=`dirname "$SCRIPT"`/"$link"
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
if [ ! -d "${APP_DIR}" ]; then
|
||||||
|
APP_DIR=`dirname "$SCRIPT"`/..
|
||||||
|
APP_DIR=`cd "${APP_DIR}"; pwd`
|
||||||
|
fi
|
||||||
|
|
||||||
|
executable="./modules/openapi-generator-cli/target/openapi-generator-cli.jar"
|
||||||
|
|
||||||
|
if [ ! -f "$executable" ]
|
||||||
|
then
|
||||||
|
mvn -B clean package
|
||||||
|
fi
|
||||||
|
|
||||||
|
# if you've executed sbt assembly previously it will use that instead.
|
||||||
|
export JAVA_OPTS="${JAVA_OPTS} -Xmx1024M -DloggerPath=conf/log4j.properties"
|
||||||
|
ags="generate -i modules/openapi-generator/src/test/resources/2_0/petstore.yaml -g typescript-fetch -c bin/typescript-fetch-petstore-typescript-three-plus.json -o samples/client/petstore/typescript-fetch/builds/typescript-three-plus $@"
|
||||||
|
|
||||||
|
java $JAVA_OPTS -jar $executable $ags
|
@ -21,6 +21,7 @@ declare -a scripts=(
|
|||||||
"./bin/openapi3/jaxrs-jersey-petstore.sh"
|
"./bin/openapi3/jaxrs-jersey-petstore.sh"
|
||||||
"./bin/spring-all-petstore.sh"
|
"./bin/spring-all-petstore.sh"
|
||||||
"./bin/javascript-petstore-all.sh"
|
"./bin/javascript-petstore-all.sh"
|
||||||
|
"./bin/kotlin-client-petstore-multiplatform.sh"
|
||||||
"./bin/kotlin-client-petstore.sh"
|
"./bin/kotlin-client-petstore.sh"
|
||||||
"./bin/kotlin-client-string.sh"
|
"./bin/kotlin-client-string.sh"
|
||||||
"./bin/kotlin-client-threetenbp.sh"
|
"./bin/kotlin-client-threetenbp.sh"
|
||||||
@ -28,6 +29,7 @@ declare -a scripts=(
|
|||||||
"./bin/kotlin-springboot-petstore-server.sh"
|
"./bin/kotlin-springboot-petstore-server.sh"
|
||||||
"./bin/kotlin-springboot-petstore-server-reactive.sh"
|
"./bin/kotlin-springboot-petstore-server-reactive.sh"
|
||||||
"./bin/mysql-schema-petstore.sh"
|
"./bin/mysql-schema-petstore.sh"
|
||||||
|
"./bin/nim-client-petstore.sh"
|
||||||
"./bin/python-petstore-all.sh"
|
"./bin/python-petstore-all.sh"
|
||||||
"./bin/openapi3/python-petstore.sh"
|
"./bin/openapi3/python-petstore.sh"
|
||||||
"./bin/php-petstore.sh"
|
"./bin/php-petstore.sh"
|
||||||
@ -59,7 +61,6 @@ declare -a scripts=(
|
|||||||
"./bin/apex-petstore.sh"
|
"./bin/apex-petstore.sh"
|
||||||
"./bin/perl-petstore-all.sh"
|
"./bin/perl-petstore-all.sh"
|
||||||
"./bin/dart-jaguar-petstore.sh"
|
"./bin/dart-jaguar-petstore.sh"
|
||||||
"./bin/dart-flutter-petstore.sh"
|
|
||||||
"./bin/dart-petstore.sh"
|
"./bin/dart-petstore.sh"
|
||||||
"./bin/dart2-petstore.sh"
|
"./bin/dart2-petstore.sh"
|
||||||
"./bin/java-play-framework-petstore-server-all.sh"
|
"./bin/java-play-framework-petstore-server-all.sh"
|
||||||
|
10
bin/windows/asciidoc-documentation-petstore.bat
Normal file
10
bin/windows/asciidoc-documentation-petstore.bat
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
set executable=.\modules\openapi-generator-cli\target\openapi-generator-cli.jar
|
||||||
|
|
||||||
|
If Not Exist %executable% (
|
||||||
|
mvn clean package
|
||||||
|
)
|
||||||
|
|
||||||
|
REM set JAVA_OPTS=%JAVA_OPTS% -Xmx1024M -DloggerPath=conf/log4j.properties
|
||||||
|
set ags=generate --artifact-id "asciidoc-petstore-documentation" -t modules\openapi-generator\src\main\resources\asciidoc-documentation --additional-properties=specDir=modules\openapi-generator\src\main\resources\asciidoc-documentation,snippetDir=. -i modules\openapi-generator\src\test\resources\2_0\petstore.yaml -g asciidoc -o samples\documentation\asciidoc
|
||||||
|
|
||||||
|
java %JAVA_OPTS% -jar %executable% %ags%
|
10
bin/windows/kotlin-client-petstore-multiplatform.bat
Normal file
10
bin/windows/kotlin-client-petstore-multiplatform.bat
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
set executable=.\modules\openapi-generator-cli\target\openapi-generator-cli.jar
|
||||||
|
|
||||||
|
If Not Exist %executable% (
|
||||||
|
mvn clean package
|
||||||
|
)
|
||||||
|
|
||||||
|
REM set JAVA_OPTS=%JAVA_OPTS% -Xmx1024M -DloggerPath=conf/log4j.properties
|
||||||
|
set ags=generate --artifact-id "kotlin-client-petstore-multiplatform" -i modules\openapi-generator\src\test\resources\2_0\petstore.yaml -g kotlin --library multiplatform -o samples\client\petstore\kotlin-multiplatform
|
||||||
|
|
||||||
|
java %JAVA_OPTS% -jar %executable% %ags%
|
10
bin/windows/kotlin-vertx-server-petstore.bat
Normal file
10
bin/windows/kotlin-vertx-server-petstore.bat
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
set executable=.\modules\openapi-generator-cli\target\openapi-generator-cli.jar
|
||||||
|
|
||||||
|
If Not Exist %executable% (
|
||||||
|
mvn clean package
|
||||||
|
)
|
||||||
|
|
||||||
|
REM set JAVA_OPTS=%JAVA_OPTS% -Xmx1024M -DloggerPath=conf/log4j.properties
|
||||||
|
set ags=generate --artifact-id "kotlin-vertx-petstore-server" -i modules\openapi-generator\src\test\resources\2_0\petstore.yaml -g kotlin-vertx -o samples\server\petstore\kotlin\vertx
|
||||||
|
|
||||||
|
java %JAVA_OPTS% -jar %executable% %ags%
|
10
bin/windows/nim-client-petstore.bat
Normal file
10
bin/windows/nim-client-petstore.bat
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
set executable=.\modules\openapi-generator-cli\target\openapi-generator-cli.jar
|
||||||
|
|
||||||
|
If Not Exist %executable% (
|
||||||
|
mvn clean package
|
||||||
|
)
|
||||||
|
|
||||||
|
REM set JAVA_OPTS=%JAVA_OPTS% -Xmx1024M -DloggerPath=conf/log4j.properties
|
||||||
|
set ags=generate --artifact-id "nim-petstore-client" -i modules\openapi-generator\src\test\resources\2_0\petstore.yaml --additional-properties packageName=petstore -g nim -o samples\client\petstore\nim
|
||||||
|
|
||||||
|
java %JAVA_OPTS% -jar %executable% %ags%
|
10
bin/windows/protobuf-schema-petstore.bat
Executable file
10
bin/windows/protobuf-schema-petstore.bat
Executable file
@ -0,0 +1,10 @@
|
|||||||
|
set executable=.\modules\openapi-generator-cli\target\openapi-generator-cli.jar
|
||||||
|
|
||||||
|
If Not Exist %executable% (
|
||||||
|
mvn clean package
|
||||||
|
)
|
||||||
|
|
||||||
|
REM set JAVA_OPTS=%JAVA_OPTS% -Xmx1024M
|
||||||
|
set ags=generate -t modules\openapi-generator\src\main\resources\protobuf-schema -i modules\openapi-generator\src\test\resources\2_0\petstore.yaml -g protobuf-schema -o samples\config\petstore\protobuf-schema
|
||||||
|
|
||||||
|
java %JAVA_OPTS% -jar %executable% %ags%
|
@ -6,3 +6,4 @@ call bin\windows\typescript-fetch-petstore-with-npm-version.bat
|
|||||||
call bin\windows\typescript-fetch-petstore-interfaces.bat
|
call bin\windows\typescript-fetch-petstore-interfaces.bat
|
||||||
call bin\windows\typescript-fetch-petstore-multiple-parameters.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-prefix-parameter-interfaces.bat
|
||||||
|
call bin\windows\typescript-fetch-petstore-typescript-three-plus.bat
|
@ -0,0 +1,12 @@
|
|||||||
|
@ECHO OFF
|
||||||
|
|
||||||
|
set executable=.\modules\openapi-generator-cli\target\openapi-generator-cli.jar
|
||||||
|
|
||||||
|
If Not Exist %executable% (
|
||||||
|
mvn clean package
|
||||||
|
)
|
||||||
|
|
||||||
|
REM set JAVA_OPTS=%JAVA_OPTS% -Xmx1024M
|
||||||
|
set ags=generate -i modules\openapi-generator\src\test\resources\2_0\petstore.yaml -g typescript-fetch -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%
|
@ -38,6 +38,7 @@ The following generators are available:
|
|||||||
* [jmeter](generators/jmeter)
|
* [jmeter](generators/jmeter)
|
||||||
* [kotlin](generators/kotlin)
|
* [kotlin](generators/kotlin)
|
||||||
* [lua](generators/lua)
|
* [lua](generators/lua)
|
||||||
|
* [nim (beta)](generators/nim)
|
||||||
* [objc](generators/objc)
|
* [objc](generators/objc)
|
||||||
* [ocaml](generators/ocaml)
|
* [ocaml](generators/ocaml)
|
||||||
* [perl](generators/perl)
|
* [perl](generators/perl)
|
||||||
@ -94,6 +95,7 @@ The following generators are available:
|
|||||||
* [jaxrs-spec](generators/jaxrs-spec)
|
* [jaxrs-spec](generators/jaxrs-spec)
|
||||||
* [kotlin-server](generators/kotlin-server)
|
* [kotlin-server](generators/kotlin-server)
|
||||||
* [kotlin-spring](generators/kotlin-spring)
|
* [kotlin-spring](generators/kotlin-spring)
|
||||||
|
* [kotlin-vertx (beta)](generators/kotlin-vertx)
|
||||||
* [nodejs-express-server (beta)](generators/nodejs-express-server)
|
* [nodejs-express-server (beta)](generators/nodejs-express-server)
|
||||||
* [nodejs-server-deprecated (deprecated)](generators/nodejs-server-deprecated)
|
* [nodejs-server-deprecated (deprecated)](generators/nodejs-server-deprecated)
|
||||||
* [php-laravel](generators/php-laravel)
|
* [php-laravel](generators/php-laravel)
|
||||||
@ -116,6 +118,7 @@ The following generators are available:
|
|||||||
|
|
||||||
|
|
||||||
## DOCUMENTATION generators
|
## DOCUMENTATION generators
|
||||||
|
* [asciidoc](generators/asciidoc)
|
||||||
* [cwiki](generators/cwiki)
|
* [cwiki](generators/cwiki)
|
||||||
* [dynamic-html](generators/dynamic-html)
|
* [dynamic-html](generators/dynamic-html)
|
||||||
* [html](generators/html)
|
* [html](generators/html)
|
||||||
@ -132,6 +135,7 @@ The following generators are available:
|
|||||||
## CONFIG generators
|
## CONFIG generators
|
||||||
* [apache2](generators/apache2)
|
* [apache2](generators/apache2)
|
||||||
* [graphql-schema](generators/graphql-schema)
|
* [graphql-schema](generators/graphql-schema)
|
||||||
|
* [protobuf-schema (beta)](generators/protobuf-schema)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
25
docs/generators/asciidoc.md
Normal file
25
docs/generators/asciidoc.md
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
|
||||||
|
---
|
||||||
|
id: generator-opts-documentation-asciidoc
|
||||||
|
title: Config Options for asciidoc
|
||||||
|
sidebar_label: asciidoc
|
||||||
|
---
|
||||||
|
|
||||||
|
| 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|
|
||||||
|
|appName|short name of the application| |null|
|
||||||
|
|appDescription|description of the application| |null|
|
||||||
|
|infoUrl|a URL where users can get more information about the application| |null|
|
||||||
|
|infoEmail|an email address to contact for inquiries about the application| |null|
|
||||||
|
|licenseInfo|a short description of the license| |null|
|
||||||
|
|licenseUrl|a URL pointing to the full license| |null|
|
||||||
|
|invokerPackage|root package for generated code| |null|
|
||||||
|
|groupId|groupId in generated pom.xml| |null|
|
||||||
|
|artifactId|artifactId in generated pom.xml. This also becomes part of the generated library's filename| |null|
|
||||||
|
|artifactVersion|artifact version in generated pom.xml. This also becomes part of the generated library's filename| |null|
|
||||||
|
|snippetDir|path with includable markup snippets (e.g. test output generated by restdoc, default: .| |.|
|
||||||
|
|specDir|path with includable markup spec files (e.g. handwritten additional docs, default: .| |..|
|
@ -17,6 +17,6 @@ sidebar_label: dart-jaguar
|
|||||||
|pubDescription|Description in generated pubspec| |null|
|
|pubDescription|Description in generated pubspec| |null|
|
||||||
|useEnumExtension|Allow the 'x-enum-values' extension for enums| |null|
|
|useEnumExtension|Allow the 'x-enum-values' extension for enums| |null|
|
||||||
|sourceFolder|Source folder for generated code| |null|
|
|sourceFolder|Source folder for generated code| |null|
|
||||||
|supportDart2|Support Dart 2.x| |true|
|
|supportDart2|Support Dart 2.x (Dart 1.x support has been deprecated)| |true|
|
||||||
|nullableFields|Is the null fields should be in the JSON payload| |null|
|
|nullableFields|Is the null fields should be in the JSON payload| |null|
|
||||||
|serialization|Choose serialization format JSON or PROTO is supported| |null|
|
|serialization|Choose serialization format JSON or PROTO is supported| |null|
|
||||||
|
@ -17,4 +17,4 @@ sidebar_label: dart
|
|||||||
|pubDescription|Description in generated pubspec| |null|
|
|pubDescription|Description in generated pubspec| |null|
|
||||||
|useEnumExtension|Allow the 'x-enum-values' extension for enums| |null|
|
|useEnumExtension|Allow the 'x-enum-values' extension for enums| |null|
|
||||||
|sourceFolder|Source folder for generated code| |null|
|
|sourceFolder|Source folder for generated code| |null|
|
||||||
|supportDart2|Support Dart 2.x| |true|
|
|supportDart2|Support Dart 2.x (Dart 1.x support has been deprecated)| |true|
|
||||||
|
9
docs/generators/grpc-schema.md
Normal file
9
docs/generators/grpc-schema.md
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
|
||||||
|
---
|
||||||
|
id: generator-opts-config-grpc-schema
|
||||||
|
title: Config Options for grpc-schema
|
||||||
|
sidebar_label: grpc-schema
|
||||||
|
---
|
||||||
|
|
||||||
|
| Option | Description | Values | Default |
|
||||||
|
| ------ | ----------- | ------ | ------- |
|
@ -55,5 +55,5 @@ sidebar_label: java
|
|||||||
|feignVersion|Version of OpenFeign: '10.x', '9.x' (default)| |false|
|
|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|
|
|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|
|
|caseInsensitiveResponseHeaders|Make API response's headers case-insensitive. Available on okhttp-gson, jersey2 libraries| |false|
|
||||||
|library|library template (sub-template) to use|<dl><dt>**jersey1**</dt><dd>HTTP client: Jersey client 1.19.x. JSON processing: Jackson 2.8.x. Enable Java6 support using '-DsupportJava6=true'. Enable gzip request encoding using '-DuseGzipFeature=true'. IMPORTANT NOTE: jersey 1.x is no longer actively maintained so please upgrade to 'jersey2' or other HTTP libaries instead.</dd><dt>**jersey2**</dt><dd>HTTP client: Jersey client 2.25.1. JSON processing: Jackson 2.8.x</dd><dt>**feign**</dt><dd>HTTP client: OpenFeign 9.x or 10.x. JSON processing: Jackson 2.8.x. To enable OpenFeign 10.x, set the 'feignVersion' option to '10.x'</dd><dt>**okhttp-gson**</dt><dd>[DEFAULT] HTTP client: OkHttp 3.x. JSON processing: Gson 2.8.x. Enable Parcelable models on Android using '-DparcelableModel=true'. Enable gzip request encoding using '-DuseGzipFeature=true'.</dd><dt>**retrofit**</dt><dd>HTTP client: OkHttp 2.x. JSON processing: Gson 2.x (Retrofit 1.9.0). IMPORTANT NOTE: retrofit1.x is no longer actively maintained so please upgrade to 'retrofit2' instead.</dd><dt>**retrofit2**</dt><dd>HTTP client: OkHttp 3.x. JSON processing: Gson 2.x (Retrofit 2.3.0). Enable the RxJava adapter using '-DuseRxJava[2]=true'. (RxJava 1.x or 2.x)</dd><dt>**resttemplate**</dt><dd>HTTP client: Spring RestTemplate 4.x. JSON processing: Jackson 2.8.x</dd><dt>**webclient**</dt><dd>HTTP client: Spring WebClient 5.x. JSON processing: Jackson 2.9.x</dd><dt>**resteasy**</dt><dd>HTTP client: Resteasy client 3.x. JSON processing: Jackson 2.8.x</dd><dt>**vertx**</dt><dd>HTTP client: VertX client 3.x. JSON processing: Jackson 2.8.x</dd><dt>**google-api-client**</dt><dd>HTTP client: Google API client 1.x. JSON processing: Jackson 2.8.x</dd><dt>**rest-assured**</dt><dd>HTTP client: rest-assured : 4.x. JSON processing: Gson 2.x. Only for Java8</dd><dt>**native**</dt><dd>HTTP client: Java native HttpClient. JSON processing: Jackson 2.9.x. Only for Java11+</dd><dl>|okhttp-gson|
|
|library|library template (sub-template) to use|<dl><dt>**jersey1**</dt><dd>HTTP client: Jersey client 1.19.x. JSON processing: Jackson 2.9.x. Enable Java6 support using '-DsupportJava6=true'. Enable gzip request encoding using '-DuseGzipFeature=true'. IMPORTANT NOTE: jersey 1.x is no longer actively maintained so please upgrade to 'jersey2' or other HTTP libaries instead.</dd><dt>**jersey2**</dt><dd>HTTP client: Jersey client 2.25.1. JSON processing: Jackson 2.9.x</dd><dt>**feign**</dt><dd>HTTP client: OpenFeign 9.x or 10.x. JSON processing: Jackson 2.9.x. To enable OpenFeign 10.x, set the 'feignVersion' option to '10.x'</dd><dt>**okhttp-gson**</dt><dd>[DEFAULT] HTTP client: OkHttp 3.x. JSON processing: Gson 2.8.x. Enable Parcelable models on Android using '-DparcelableModel=true'. Enable gzip request encoding using '-DuseGzipFeature=true'.</dd><dt>**retrofit**</dt><dd>HTTP client: OkHttp 2.x. JSON processing: Gson 2.x (Retrofit 1.9.0). IMPORTANT NOTE: retrofit1.x is no longer actively maintained so please upgrade to 'retrofit2' instead.</dd><dt>**retrofit2**</dt><dd>HTTP client: OkHttp 3.x. JSON processing: Gson 2.x (Retrofit 2.3.0). Enable the RxJava adapter using '-DuseRxJava[2]=true'. (RxJava 1.x or 2.x)</dd><dt>**resttemplate**</dt><dd>HTTP client: Spring RestTemplate 4.x. JSON processing: Jackson 2.9.x</dd><dt>**webclient**</dt><dd>HTTP client: Spring WebClient 5.x. JSON processing: Jackson 2.9.x</dd><dt>**resteasy**</dt><dd>HTTP client: Resteasy client 3.x. JSON processing: Jackson 2.9.x</dd><dt>**vertx**</dt><dd>HTTP client: VertX client 3.x. JSON processing: Jackson 2.9.x</dd><dt>**google-api-client**</dt><dd>HTTP client: Google API client 1.x. JSON processing: Jackson 2.9.x</dd><dt>**rest-assured**</dt><dd>HTTP client: rest-assured : 4.x. JSON processing: Gson 2.x or Jackson 2.9.x. Only for Java8</dd><dt>**native**</dt><dd>HTTP client: Java native HttpClient. JSON processing: Jackson 2.9.x. Only for Java11+</dd><dl>|okhttp-gson|
|
||||||
|serializationLibrary|Serialization library, default depends from the library|<dl><dt>**jackson**</dt><dd>Use Jackson as serialization library</dd><dt>**gson**</dt><dd>Use Gson as serialization library</dd><dl>|null|
|
|serializationLibrary|Serialization library, default depends from the library|<dl><dt>**jackson**</dt><dd>Use Jackson as serialization library</dd><dt>**gson**</dt><dd>Use Gson as serialization library</dd><dl>|null|
|
||||||
|
@ -14,6 +14,7 @@ sidebar_label: kotlin-server
|
|||||||
|artifactId|Generated artifact id (name of jar).| |kotlin-server|
|
|artifactId|Generated artifact id (name of jar).| |kotlin-server|
|
||||||
|artifactVersion|Generated artifact's package version.| |1.0.0|
|
|artifactVersion|Generated artifact's package version.| |1.0.0|
|
||||||
|enumPropertyNaming|Naming convention for enum properties: 'camelCase', 'PascalCase', 'snake_case', 'UPPERCASE', and 'original'| |camelCase|
|
|enumPropertyNaming|Naming convention for enum properties: 'camelCase', 'PascalCase', 'snake_case', 'UPPERCASE', and 'original'| |camelCase|
|
||||||
|
|serializationLibrary|What serialization library to use: 'moshi' (default), or 'gson'| |moshi|
|
||||||
|parcelizeModels|toggle "@Parcelize" for generated models| |null|
|
|parcelizeModels|toggle "@Parcelize" for generated models| |null|
|
||||||
|library|library template (sub-template)|<dl><dt>**ktor**</dt><dd>ktor framework</dd><dl>|ktor|
|
|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|
|
|featureAutoHead|Automatically provide responses to HEAD requests for existing routes that have the GET verb defined.| |true|
|
||||||
|
@ -14,6 +14,7 @@ sidebar_label: kotlin-spring
|
|||||||
|artifactId|Generated artifact id (name of jar).| |openapi-spring|
|
|artifactId|Generated artifact id (name of jar).| |openapi-spring|
|
||||||
|artifactVersion|Generated artifact's package version.| |1.0.0|
|
|artifactVersion|Generated artifact's package version.| |1.0.0|
|
||||||
|enumPropertyNaming|Naming convention for enum properties: 'camelCase', 'PascalCase', 'snake_case', 'UPPERCASE', and 'original'| |camelCase|
|
|enumPropertyNaming|Naming convention for enum properties: 'camelCase', 'PascalCase', 'snake_case', 'UPPERCASE', and 'original'| |camelCase|
|
||||||
|
|serializationLibrary|What serialization library to use: 'moshi' (default), or 'gson'| |moshi|
|
||||||
|parcelizeModels|toggle "@Parcelize" for generated models| |null|
|
|parcelizeModels|toggle "@Parcelize" for generated models| |null|
|
||||||
|title|server title name or client service name| |OpenAPI Kotlin Spring|
|
|title|server title name or client service name| |OpenAPI Kotlin Spring|
|
||||||
|basePackage|base package (invokerPackage) for generated code| |org.openapitools|
|
|basePackage|base package (invokerPackage) for generated code| |org.openapitools|
|
||||||
|
18
docs/generators/kotlin-vertx.md
Normal file
18
docs/generators/kotlin-vertx.md
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
|
||||||
|
---
|
||||||
|
id: generator-opts-server-kotlin-vertx
|
||||||
|
title: Config Options for kotlin-vertx
|
||||||
|
sidebar_label: kotlin-vertx
|
||||||
|
---
|
||||||
|
|
||||||
|
| Option | Description | Values | Default |
|
||||||
|
| ------ | ----------- | ------ | ------- |
|
||||||
|
|sourceFolder|source folder for generated code| |src/main/kotlin|
|
||||||
|
|packageName|Generated artifact package name.| |org.openapitools|
|
||||||
|
|apiSuffix|suffix for api classes| |Api|
|
||||||
|
|groupId|Generated artifact package's organization (i.e. maven groupId).| |org.openapitools|
|
||||||
|
|artifactId|Generated artifact id (name of jar).| |null|
|
||||||
|
|artifactVersion|Generated artifact's package version.| |1.0.0|
|
||||||
|
|enumPropertyNaming|Naming convention for enum properties: 'camelCase', 'PascalCase', 'snake_case', 'UPPERCASE', and 'original'| |camelCase|
|
||||||
|
|serializationLibrary|What serialization library to use: 'moshi' (default), or 'gson'| |moshi|
|
||||||
|
|parcelizeModels|toggle "@Parcelize" for generated models| |null|
|
@ -14,6 +14,8 @@ sidebar_label: kotlin
|
|||||||
|artifactId|Generated artifact id (name of jar).| |kotlin-client|
|
|artifactId|Generated artifact id (name of jar).| |kotlin-client|
|
||||||
|artifactVersion|Generated artifact's package version.| |1.0.0|
|
|artifactVersion|Generated artifact's package version.| |1.0.0|
|
||||||
|enumPropertyNaming|Naming convention for enum properties: 'camelCase', 'PascalCase', 'snake_case', 'UPPERCASE', and 'original'| |camelCase|
|
|enumPropertyNaming|Naming convention for enum properties: 'camelCase', 'PascalCase', 'snake_case', 'UPPERCASE', and 'original'| |camelCase|
|
||||||
|
|serializationLibrary|What serialization library to use: 'moshi' (default), or 'gson'| |moshi|
|
||||||
|parcelizeModels|toggle "@Parcelize" for generated models| |null|
|
|parcelizeModels|toggle "@Parcelize" for generated models| |null|
|
||||||
|dateLibrary|Option. Date library to use|<dl><dt>**string**</dt><dd>String</dd><dt>**java8**</dt><dd>Java 8 native JSR310</dd><dt>**threetenbp**</dt><dd>Threetenbp</dd><dl>|java8|
|
|dateLibrary|Option. Date library to use|<dl><dt>**string**</dt><dd>String</dd><dt>**java8**</dt><dd>Java 8 native JSR310 (jvm only)</dd><dt>**threetenbp**</dt><dd>Threetenbp (jvm only)</dd><dl>|java8|
|
||||||
|collectionType|Option. Collection type to use|<dl><dt>**array**</dt><dd>kotlin.Array</dd><dt>**list**</dt><dd>kotlin.collections.List</dd><dl>|array|
|
|collectionType|Option. Collection type to use|<dl><dt>**array**</dt><dd>kotlin.Array</dd><dt>**list**</dt><dd>kotlin.collections.List</dd><dl>|array|
|
||||||
|
|library|Library template (sub-template) to use|<dl><dt>**jvm**</dt><dd>Platform: Java Virtual Machine. HTTP client: OkHttp 2.7.5. JSON processing: Gson 2.8.1.</dd><dt>**multiplatform**</dt><dd>Platform: Kotlin multiplatform. HTTP client: Ktor 1.2.4. JSON processing: Kotlinx Serialization: 0.12.0.</dd><dl>|jvm|
|
||||||
|
13
docs/generators/nim.md
Normal file
13
docs/generators/nim.md
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
|
||||||
|
---
|
||||||
|
id: generator-opts-client-nim
|
||||||
|
title: Config Options for nim
|
||||||
|
sidebar_label: nim
|
||||||
|
---
|
||||||
|
|
||||||
|
| 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|
|
9
docs/generators/protobuf-schema.md
Normal file
9
docs/generators/protobuf-schema.md
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
|
||||||
|
---
|
||||||
|
id: generator-opts-config-protobuf-schema
|
||||||
|
title: Config Options for protobuf-schema
|
||||||
|
sidebar_label: protobuf-schema
|
||||||
|
---
|
||||||
|
|
||||||
|
| Option | Description | Values | Default |
|
||||||
|
| ------ | ----------- | ------ | ------- |
|
@ -20,3 +20,4 @@ sidebar_label: typescript-fetch
|
|||||||
|withInterfaces|Setting this property to true will generate interfaces next to the default class implementations.| |false|
|
|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|
|
|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|
|
|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|
|
||||||
|
@ -178,6 +178,10 @@ public class Generate implements Runnable {
|
|||||||
@Option(name = {"--library"}, title = "library", description = CodegenConstants.LIBRARY_DESC)
|
@Option(name = {"--library"}, title = "library", description = CodegenConstants.LIBRARY_DESC)
|
||||||
private String library;
|
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",
|
@Option(name = {"--git-user-id"}, title = "git user id",
|
||||||
description = CodegenConstants.GIT_USER_ID_DESC)
|
description = CodegenConstants.GIT_USER_ID_DESC)
|
||||||
private String gitUserId;
|
private String gitUserId;
|
||||||
@ -343,6 +347,10 @@ public class Generate implements Runnable {
|
|||||||
configurator.setLibrary(library);
|
configurator.setLibrary(library);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (isNotEmpty(gitHost)) {
|
||||||
|
configurator.setGitHost(gitHost);
|
||||||
|
}
|
||||||
|
|
||||||
if (isNotEmpty(gitUserId)) {
|
if (isNotEmpty(gitUserId)) {
|
||||||
configurator.setGitUserId(gitUserId);
|
configurator.setGitUserId(gitUserId);
|
||||||
}
|
}
|
||||||
|
@ -30,6 +30,7 @@ import java.util.*;
|
|||||||
public final class GeneratorSettings implements Serializable {
|
public final class GeneratorSettings implements Serializable {
|
||||||
|
|
||||||
private static final Logger LOGGER = LoggerFactory.getLogger(GeneratorSettings.class);
|
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_USER_ID = "GIT_USER_ID";
|
||||||
private static String DEFAULT_GIT_REPO_ID = "GIT_REPO_ID";
|
private static String DEFAULT_GIT_REPO_ID = "GIT_REPO_ID";
|
||||||
private static String DEFAULT_RELEASE_NOTE = "Minor update";
|
private static String DEFAULT_RELEASE_NOTE = "Minor update";
|
||||||
@ -54,6 +55,7 @@ public final class GeneratorSettings implements Serializable {
|
|||||||
private ImmutableMap<String, String> reservedWordMappings;
|
private ImmutableMap<String, String> reservedWordMappings;
|
||||||
private ImmutableMap<String, String> serverVariables;
|
private ImmutableMap<String, String> serverVariables;
|
||||||
|
|
||||||
|
private String gitHost;
|
||||||
private String gitUserId;
|
private String gitUserId;
|
||||||
private String gitRepoId;
|
private String gitRepoId;
|
||||||
private String releaseNote;
|
private String releaseNote;
|
||||||
@ -256,6 +258,17 @@ public final class GeneratorSettings implements Serializable {
|
|||||||
return serverVariables;
|
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>.
|
* Gets git user id. e.g. <strong>openapitools</strong>.
|
||||||
@ -324,6 +337,7 @@ public final class GeneratorSettings implements Serializable {
|
|||||||
languageSpecificPrimitives = ImmutableSet.copyOf(builder.languageSpecificPrimitives);
|
languageSpecificPrimitives = ImmutableSet.copyOf(builder.languageSpecificPrimitives);
|
||||||
reservedWordMappings = ImmutableMap.copyOf(builder.reservedWordMappings);
|
reservedWordMappings = ImmutableMap.copyOf(builder.reservedWordMappings);
|
||||||
serverVariables = ImmutableMap.copyOf(builder.serverVariables);
|
serverVariables = ImmutableMap.copyOf(builder.serverVariables);
|
||||||
|
gitHost = builder.gitHost;
|
||||||
gitUserId = builder.gitUserId;
|
gitUserId = builder.gitUserId;
|
||||||
gitRepoId = builder.gitRepoId;
|
gitRepoId = builder.gitRepoId;
|
||||||
releaseNote = builder.releaseNote;
|
releaseNote = builder.releaseNote;
|
||||||
@ -358,6 +372,9 @@ public final class GeneratorSettings implements Serializable {
|
|||||||
if (isNotEmpty(modelNameSuffix)) {
|
if (isNotEmpty(modelNameSuffix)) {
|
||||||
additional.put("modelNameSuffix", modelNameSuffix);
|
additional.put("modelNameSuffix", modelNameSuffix);
|
||||||
}
|
}
|
||||||
|
if (isNotEmpty(gitHost)) {
|
||||||
|
additional.put("gitHost", gitHost);
|
||||||
|
}
|
||||||
if (isNotEmpty(gitUserId)) {
|
if (isNotEmpty(gitUserId)) {
|
||||||
additional.put("gitUserId", gitUserId);
|
additional.put("gitUserId", gitUserId);
|
||||||
}
|
}
|
||||||
@ -390,6 +407,7 @@ public final class GeneratorSettings implements Serializable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void setDefaults() {
|
private void setDefaults() {
|
||||||
|
gitHost = DEFAULT_GIT_HOST;
|
||||||
gitUserId = DEFAULT_GIT_USER_ID;
|
gitUserId = DEFAULT_GIT_USER_ID;
|
||||||
gitRepoId = DEFAULT_GIT_REPO_ID;
|
gitRepoId = DEFAULT_GIT_REPO_ID;
|
||||||
releaseNote = DEFAULT_RELEASE_NOTE;
|
releaseNote = DEFAULT_RELEASE_NOTE;
|
||||||
@ -442,6 +460,7 @@ public final class GeneratorSettings implements Serializable {
|
|||||||
if (copy.getServerVariables() != null) {
|
if (copy.getServerVariables() != null) {
|
||||||
builder.serverVariables.putAll(copy.getServerVariables());
|
builder.serverVariables.putAll(copy.getServerVariables());
|
||||||
}
|
}
|
||||||
|
builder.gitHost = copy.getGitHost();
|
||||||
builder.gitUserId = copy.getGitUserId();
|
builder.gitUserId = copy.getGitUserId();
|
||||||
builder.gitRepoId = copy.getGitRepoId();
|
builder.gitRepoId = copy.getGitRepoId();
|
||||||
builder.releaseNote = copy.getReleaseNote();
|
builder.releaseNote = copy.getReleaseNote();
|
||||||
@ -473,6 +492,7 @@ public final class GeneratorSettings implements Serializable {
|
|||||||
private Set<String> languageSpecificPrimitives;
|
private Set<String> languageSpecificPrimitives;
|
||||||
private Map<String, String> reservedWordMappings;
|
private Map<String, String> reservedWordMappings;
|
||||||
private Map<String, String> serverVariables;
|
private Map<String, String> serverVariables;
|
||||||
|
private String gitHost;
|
||||||
private String gitUserId;
|
private String gitUserId;
|
||||||
private String gitRepoId;
|
private String gitRepoId;
|
||||||
private String releaseNote;
|
private String releaseNote;
|
||||||
@ -490,6 +510,7 @@ public final class GeneratorSettings implements Serializable {
|
|||||||
reservedWordMappings = new HashMap<>();
|
reservedWordMappings = new HashMap<>();
|
||||||
serverVariables = new HashMap<>();
|
serverVariables = new HashMap<>();
|
||||||
|
|
||||||
|
gitHost = DEFAULT_GIT_HOST;
|
||||||
gitUserId = DEFAULT_GIT_USER_ID;
|
gitUserId = DEFAULT_GIT_USER_ID;
|
||||||
gitRepoId = DEFAULT_GIT_REPO_ID;
|
gitRepoId = DEFAULT_GIT_REPO_ID;
|
||||||
releaseNote = DEFAULT_RELEASE_NOTE;
|
releaseNote = DEFAULT_RELEASE_NOTE;
|
||||||
@ -783,6 +804,17 @@ public final class GeneratorSettings implements Serializable {
|
|||||||
return this;
|
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.
|
* Sets the {@code gitUserId} and returns a reference to this Builder so that the methods can be chained together.
|
||||||
*
|
*
|
||||||
@ -860,6 +892,7 @@ public final class GeneratorSettings implements Serializable {
|
|||||||
", importMappings=" + importMappings +
|
", importMappings=" + importMappings +
|
||||||
", languageSpecificPrimitives=" + languageSpecificPrimitives +
|
", languageSpecificPrimitives=" + languageSpecificPrimitives +
|
||||||
", reservedWordMappings=" + reservedWordMappings +
|
", reservedWordMappings=" + reservedWordMappings +
|
||||||
|
", gitHost='" + gitHost + '\'' +
|
||||||
", gitUserId='" + gitUserId + '\'' +
|
", gitUserId='" + gitUserId + '\'' +
|
||||||
", gitRepoId='" + gitRepoId + '\'' +
|
", gitRepoId='" + gitRepoId + '\'' +
|
||||||
", releaseNote='" + releaseNote + '\'' +
|
", releaseNote='" + releaseNote + '\'' +
|
||||||
@ -889,6 +922,7 @@ public final class GeneratorSettings implements Serializable {
|
|||||||
Objects.equals(getImportMappings(), that.getImportMappings()) &&
|
Objects.equals(getImportMappings(), that.getImportMappings()) &&
|
||||||
Objects.equals(getLanguageSpecificPrimitives(), that.getLanguageSpecificPrimitives()) &&
|
Objects.equals(getLanguageSpecificPrimitives(), that.getLanguageSpecificPrimitives()) &&
|
||||||
Objects.equals(getReservedWordMappings(), that.getReservedWordMappings()) &&
|
Objects.equals(getReservedWordMappings(), that.getReservedWordMappings()) &&
|
||||||
|
Objects.equals(getGitHost(), that.getGitHost()) &&
|
||||||
Objects.equals(getGitUserId(), that.getGitUserId()) &&
|
Objects.equals(getGitUserId(), that.getGitUserId()) &&
|
||||||
Objects.equals(getGitRepoId(), that.getGitRepoId()) &&
|
Objects.equals(getGitRepoId(), that.getGitRepoId()) &&
|
||||||
Objects.equals(getReleaseNote(), that.getReleaseNote()) &&
|
Objects.equals(getReleaseNote(), that.getReleaseNote()) &&
|
||||||
@ -915,6 +949,7 @@ public final class GeneratorSettings implements Serializable {
|
|||||||
getImportMappings(),
|
getImportMappings(),
|
||||||
getLanguageSpecificPrimitives(),
|
getLanguageSpecificPrimitives(),
|
||||||
getReservedWordMappings(),
|
getReservedWordMappings(),
|
||||||
|
getGitHost(),
|
||||||
getGitUserId(),
|
getGitUserId(),
|
||||||
getGitRepoId(),
|
getGitRepoId(),
|
||||||
getReleaseNote(),
|
getReleaseNote(),
|
||||||
|
@ -202,6 +202,11 @@ apply plugin: 'org.openapi.generator'
|
|||||||
|None
|
|None
|
||||||
|Reference the library template (sub-template) of a generator.
|
|Reference the library template (sub-template) of a generator.
|
||||||
|
|
||||||
|
|gitHost
|
||||||
|
|String
|
||||||
|
|github.com
|
||||||
|
|Git user ID, e.g. gitlab.com.
|
||||||
|
|
||||||
|gitUserId
|
|gitUserId
|
||||||
|String
|
|String
|
||||||
|None
|
|None
|
||||||
|
@ -116,6 +116,7 @@ class OpenApiGeneratorPlugin : Plugin<Project> {
|
|||||||
id.set(generate.id)
|
id.set(generate.id)
|
||||||
version.set(generate.version)
|
version.set(generate.version)
|
||||||
library.set(generate.library)
|
library.set(generate.library)
|
||||||
|
gitHost.set(generate.gitHost)
|
||||||
gitUserId.set(generate.gitUserId)
|
gitUserId.set(generate.gitUserId)
|
||||||
gitRepoId.set(generate.gitRepoId)
|
gitRepoId.set(generate.gitRepoId)
|
||||||
releaseNote.set(generate.releaseNote)
|
releaseNote.set(generate.releaseNote)
|
||||||
|
@ -160,6 +160,11 @@ open class OpenApiGeneratorGenerateExtension(project: Project) {
|
|||||||
*/
|
*/
|
||||||
val library = project.objects.property<String?>()
|
val library = project.objects.property<String?>()
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Git host, e.g. gitlab.com.
|
||||||
|
*/
|
||||||
|
val gitHost = project.objects.property<String?>()
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Git user ID, e.g. openapitools.
|
* Git user ID, e.g. openapitools.
|
||||||
*/
|
*/
|
||||||
|
@ -204,6 +204,12 @@ open class GenerateTask : DefaultTask() {
|
|||||||
@get:Internal
|
@get:Internal
|
||||||
val library = project.objects.property<String?>()
|
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.
|
* Git user ID, e.g. openapitools.
|
||||||
*/
|
*/
|
||||||
@ -510,6 +516,10 @@ open class GenerateTask : DefaultTask() {
|
|||||||
configurator.setLibrary(value)
|
configurator.setLibrary(value)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
gitHost.ifNotEmpty { value ->
|
||||||
|
configurator.setGitHost(value)
|
||||||
|
}
|
||||||
|
|
||||||
gitUserId.ifNotEmpty { value ->
|
gitUserId.ifNotEmpty { value ->
|
||||||
configurator.setGitUserId(value)
|
configurator.setGitUserId(value)
|
||||||
}
|
}
|
||||||
|
@ -91,6 +91,7 @@ mvn clean compile
|
|||||||
| `reservedWordsMappings` | `openapi.generator.maven.plugin.reservedWordsMappings` | specifies how a reserved name should be escaped to. Otherwise, the default `_<name>` is used. For example `id=identifier`. You can also have multiple occurrences of this option
|
| `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)
|
| `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)
|
| `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
|
### Custom Generator
|
||||||
|
@ -13,10 +13,11 @@
|
|||||||
<groupId>org.openapitools</groupId>
|
<groupId>org.openapitools</groupId>
|
||||||
<artifactId>openapi-generator-maven-plugin</artifactId>
|
<artifactId>openapi-generator-maven-plugin</artifactId>
|
||||||
<!-- RELEASE_VERSION -->
|
<!-- RELEASE_VERSION -->
|
||||||
<version>4.1.2-SNAPSHOT</version>
|
<version>4.1.3-SNAPSHOT</version>
|
||||||
<!-- /RELEASE_VERSION -->
|
<!-- /RELEASE_VERSION -->
|
||||||
<executions>
|
<executions>
|
||||||
<execution>
|
<execution>
|
||||||
|
<id>default</id>
|
||||||
<goals>
|
<goals>
|
||||||
<goal>generate</goal>
|
<goal>generate</goal>
|
||||||
</goals>
|
</goals>
|
||||||
@ -39,6 +40,36 @@
|
|||||||
<library>jersey2</library>
|
<library>jersey2</library>
|
||||||
</configuration>
|
</configuration>
|
||||||
</execution>
|
</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>
|
</executions>
|
||||||
</plugin>
|
</plugin>
|
||||||
<plugin>
|
<plugin>
|
||||||
|
@ -66,7 +66,7 @@
|
|||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
<artifactId>maven-plugin-plugin</artifactId>
|
<artifactId>maven-plugin-plugin</artifactId>
|
||||||
<version>3.5.2</version>
|
<version>3.6.0</version>
|
||||||
<configuration>
|
<configuration>
|
||||||
<skipErrorNoDescriptorsFound>true</skipErrorNoDescriptorsFound>
|
<skipErrorNoDescriptorsFound>true</skipErrorNoDescriptorsFound>
|
||||||
</configuration>
|
</configuration>
|
||||||
|
@ -20,7 +20,18 @@ package org.openapitools.codegen.plugin;
|
|||||||
import static org.apache.commons.lang3.StringUtils.isNotEmpty;
|
import static org.apache.commons.lang3.StringUtils.isNotEmpty;
|
||||||
import static org.openapitools.codegen.config.CodegenConfiguratorUtils.*;
|
import static org.openapitools.codegen.config.CodegenConfiguratorUtils.*;
|
||||||
|
|
||||||
|
import io.swagger.v3.parser.core.models.AuthorizationValue;
|
||||||
import java.io.File;
|
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.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
@ -42,6 +53,7 @@ import org.openapitools.codegen.ClientOptInput;
|
|||||||
import org.openapitools.codegen.CodegenConfig;
|
import org.openapitools.codegen.CodegenConfig;
|
||||||
import org.openapitools.codegen.CodegenConstants;
|
import org.openapitools.codegen.CodegenConstants;
|
||||||
import org.openapitools.codegen.DefaultGenerator;
|
import org.openapitools.codegen.DefaultGenerator;
|
||||||
|
import org.openapitools.codegen.auth.AuthParser;
|
||||||
import org.openapitools.codegen.config.CodegenConfigurator;
|
import org.openapitools.codegen.config.CodegenConfigurator;
|
||||||
import org.openapitools.codegen.config.GlobalSettings;
|
import org.openapitools.codegen.config.GlobalSettings;
|
||||||
import org.sonatype.plexus.build.incremental.BuildContext;
|
import org.sonatype.plexus.build.incremental.BuildContext;
|
||||||
@ -97,6 +109,12 @@ public class CodeGenMojo extends AbstractMojo {
|
|||||||
@Parameter(name = "inputSpec", property = "openapi.generator.maven.plugin.inputSpec", required = true)
|
@Parameter(name = "inputSpec", property = "openapi.generator.maven.plugin.inputSpec", required = true)
|
||||||
private String inputSpec;
|
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.
|
* Git user ID, e.g. swagger-api.
|
||||||
*/
|
*/
|
||||||
@ -206,6 +224,12 @@ public class CodeGenMojo extends AbstractMojo {
|
|||||||
@Parameter(name = "ignoreFileOverride", property = "openapi.generator.maven.plugin.ignoreFileOverride", required = false)
|
@Parameter(name = "ignoreFileOverride", property = "openapi.generator.maven.plugin.ignoreFileOverride", required = false)
|
||||||
private String ignoreFileOverride;
|
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)
|
* To remove operationId prefix (e.g. user_getName => getName)
|
||||||
*/
|
*/
|
||||||
@ -417,7 +441,7 @@ public class CodeGenMojo extends AbstractMojo {
|
|||||||
if (inputSpecFile.exists()) {
|
if (inputSpecFile.exists()) {
|
||||||
File storedInputSpecHashFile = getHashFile(inputSpecFile);
|
File storedInputSpecHashFile = getHashFile(inputSpecFile);
|
||||||
if(storedInputSpecHashFile.exists()) {
|
if(storedInputSpecHashFile.exists()) {
|
||||||
String inputSpecHash = Files.asByteSource(inputSpecFile).hash(Hashing.sha256()).toString();
|
String inputSpecHash = calculateInputSpecHash(inputSpecFile);
|
||||||
String storedInputSpecHash = Files.asCharSource(storedInputSpecHashFile, Charsets.UTF_8).read();
|
String storedInputSpecHash = Files.asCharSource(storedInputSpecHashFile, Charsets.UTF_8).read();
|
||||||
if (inputSpecHash.equals(storedInputSpecHash)) {
|
if (inputSpecHash.equals(storedInputSpecHash)) {
|
||||||
getLog().info(
|
getLog().info(
|
||||||
@ -450,6 +474,10 @@ public class CodeGenMojo extends AbstractMojo {
|
|||||||
configurator.setInputSpec(inputSpec);
|
configurator.setInputSpec(inputSpec);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (isNotEmpty(gitHost)) {
|
||||||
|
configurator.setGitHost(gitHost);
|
||||||
|
}
|
||||||
|
|
||||||
if (isNotEmpty(gitUserId)) {
|
if (isNotEmpty(gitUserId)) {
|
||||||
configurator.setGitUserId(gitUserId);
|
configurator.setGitUserId(gitUserId);
|
||||||
}
|
}
|
||||||
@ -462,6 +490,10 @@ public class CodeGenMojo extends AbstractMojo {
|
|||||||
configurator.setIgnoreFileOverride(ignoreFileOverride);
|
configurator.setIgnoreFileOverride(ignoreFileOverride);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (isNotEmpty(httpUserAgent)) {
|
||||||
|
configurator.setHttpUserAgent(httpUserAgent);
|
||||||
|
}
|
||||||
|
|
||||||
if (skipValidateSpec != null) {
|
if (skipValidateSpec != null) {
|
||||||
configurator.setValidateSpec(!skipValidateSpec);
|
configurator.setValidateSpec(!skipValidateSpec);
|
||||||
}
|
}
|
||||||
@ -700,12 +732,7 @@ public class CodeGenMojo extends AbstractMojo {
|
|||||||
|
|
||||||
// Store a checksum of the input spec
|
// Store a checksum of the input spec
|
||||||
File storedInputSpecHashFile = getHashFile(inputSpecFile);
|
File storedInputSpecHashFile = getHashFile(inputSpecFile);
|
||||||
ByteSource inputSpecByteSource =
|
String inputSpecHash = calculateInputSpecHash(inputSpecFile);
|
||||||
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()) {
|
if (storedInputSpecHashFile.getParent() != null && !new File(storedInputSpecHashFile.getParent()).exists()) {
|
||||||
File parent = new File(storedInputSpecHashFile.getParent());
|
File parent = new File(storedInputSpecHashFile.getParent());
|
||||||
@ -726,8 +753,75 @@ public class CodeGenMojo extends AbstractMojo {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Calculate openapi specification file hash. If specification is hosted on remote resource it is downloaded first
|
||||||
|
*
|
||||||
|
* @param inputSpecFile - Openapi specification input file to calculate it's hash.
|
||||||
|
* Does not taken into account if input spec is hosted on remote resource
|
||||||
|
* @return openapi specification file hash
|
||||||
|
* @throws IOException
|
||||||
|
*/
|
||||||
|
private String calculateInputSpecHash(File inputSpecFile) throws IOException {
|
||||||
|
|
||||||
|
URL inputSpecRemoteUrl = inputSpecRemoteUrl();
|
||||||
|
|
||||||
|
File inputSpecTempFile = inputSpecFile;
|
||||||
|
|
||||||
|
if (inputSpecRemoteUrl != null) {
|
||||||
|
inputSpecTempFile = File.createTempFile("openapi-spec", ".tmp");
|
||||||
|
|
||||||
|
URLConnection conn = inputSpecRemoteUrl.openConnection();
|
||||||
|
if (isNotEmpty(auth)) {
|
||||||
|
List<AuthorizationValue> authList = AuthParser.parse(auth);
|
||||||
|
for (AuthorizationValue auth : authList) {
|
||||||
|
conn.setRequestProperty(auth.getKeyName(), auth.getValue());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
ReadableByteChannel readableByteChannel = Channels.newChannel(conn.getInputStream());
|
||||||
|
|
||||||
|
FileOutputStream fileOutputStream = new FileOutputStream(inputSpecTempFile);
|
||||||
|
FileChannel fileChannel = fileOutputStream.getChannel();
|
||||||
|
|
||||||
|
fileChannel.transferFrom(readableByteChannel, 0, Long.MAX_VALUE);
|
||||||
|
}
|
||||||
|
|
||||||
|
ByteSource inputSpecByteSource =
|
||||||
|
inputSpecTempFile.exists()
|
||||||
|
? Files.asByteSource(inputSpecTempFile)
|
||||||
|
: CharSource.wrap(ClasspathHelper.loadFileFromClasspath(inputSpecTempFile.toString().replaceAll("\\\\","/")))
|
||||||
|
.asByteSource(Charsets.UTF_8);
|
||||||
|
|
||||||
|
return inputSpecByteSource.hash(Hashing.sha256()).toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Try to parse inputSpec setting string into URL
|
||||||
|
* @return A valid URL or null if inputSpec is not a valid URL
|
||||||
|
*/
|
||||||
|
private URL inputSpecRemoteUrl(){
|
||||||
|
try {
|
||||||
|
return new URI(inputSpec).toURL();
|
||||||
|
} catch (URISyntaxException | MalformedURLException | IllegalArgumentException e) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get specification hash file
|
||||||
|
* @param inputSpecFile - Openapi specification input file to calculate it's hash.
|
||||||
|
* Does not taken into account if input spec is hosted on remote resource
|
||||||
|
* @return a file with previously calculated hash
|
||||||
|
*/
|
||||||
private File getHashFile(File inputSpecFile) {
|
private File getHashFile(File inputSpecFile) {
|
||||||
return new File(output.getPath() + File.separator + ".openapi-generator" + File.separator + inputSpecFile.getName() + ".sha256");
|
String name = inputSpecFile.getName();
|
||||||
|
|
||||||
|
URL url = inputSpecRemoteUrl();
|
||||||
|
if (url != null) {
|
||||||
|
String[] segments = url.getPath().split("/");
|
||||||
|
name = Files.getNameWithoutExtension(segments[segments.length - 1]);
|
||||||
|
}
|
||||||
|
|
||||||
|
return new File(output.getPath() + File.separator + ".openapi-generator" + File.separator + name + ".sha256");
|
||||||
}
|
}
|
||||||
|
|
||||||
private String getCompileSourceRoot() {
|
private String getCompileSourceRoot() {
|
||||||
@ -737,8 +831,7 @@ public class CodeGenMojo extends AbstractMojo {
|
|||||||
final String sourceFolder =
|
final String sourceFolder =
|
||||||
sourceFolderObject == null ? "src/main/java" : sourceFolderObject.toString();
|
sourceFolderObject == null ? "src/main/java" : sourceFolderObject.toString();
|
||||||
|
|
||||||
String sourceJavaFolder = output.toString() + "/" + sourceFolder;
|
return output.toString() + "/" + sourceFolder;
|
||||||
return sourceJavaFolder;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void addCompileSourceRootIfConfigured() {
|
private void addCompileSourceRootIfConfigured() {
|
||||||
@ -783,4 +876,4 @@ public class CodeGenMojo extends AbstractMojo {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -74,7 +74,7 @@
|
|||||||
</plugin>
|
</plugin>
|
||||||
<plugin>
|
<plugin>
|
||||||
<artifactId>maven-compiler-plugin</artifactId>
|
<artifactId>maven-compiler-plugin</artifactId>
|
||||||
<version>3.5.1</version>
|
<version>3.8.1</version>
|
||||||
<configuration>
|
<configuration>
|
||||||
<source>1.8</source>
|
<source>1.8</source>
|
||||||
<target>1.8</target>
|
<target>1.8</target>
|
||||||
|
@ -222,6 +222,10 @@ public interface CodegenConfig {
|
|||||||
*/
|
*/
|
||||||
String getLibrary();
|
String getLibrary();
|
||||||
|
|
||||||
|
void setGitHost(String gitHost);
|
||||||
|
|
||||||
|
String getGitHost();
|
||||||
|
|
||||||
void setGitUserId(String gitUserId);
|
void setGitUserId(String gitUserId);
|
||||||
|
|
||||||
String getGitUserId();
|
String getGitUserId();
|
||||||
|
@ -202,12 +202,19 @@ public class CodegenConstants {
|
|||||||
public static final String ENUM_PROPERTY_NAMING = "enumPropertyNaming";
|
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'";
|
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 = "modelNamePrefix";
|
||||||
public static final String MODEL_NAME_PREFIX_DESC = "Prefix that will be prepended to all model names.";
|
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 = "modelNameSuffix";
|
||||||
public static final String MODEL_NAME_SUFFIX_DESC = "Suffix that will be appended to all model names.";
|
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 = "gitUserId";
|
||||||
public static final String GIT_USER_ID_DESC = "Git user ID, e.g. openapitools.";
|
public static final String GIT_USER_ID_DESC = "Git user ID, e.g. openapitools.";
|
||||||
|
|
||||||
|
@ -111,7 +111,7 @@ public class DefaultCodegen implements CodegenConfig {
|
|||||||
protected Boolean sortParamsByRequiredFlag = true;
|
protected Boolean sortParamsByRequiredFlag = true;
|
||||||
protected Boolean ensureUniqueParams = true;
|
protected Boolean ensureUniqueParams = true;
|
||||||
protected Boolean allowUnicodeIdentifiers = false;
|
protected Boolean allowUnicodeIdentifiers = false;
|
||||||
protected String gitUserId, gitRepoId, releaseNote;
|
protected String gitHost, gitUserId, gitRepoId, releaseNote;
|
||||||
protected String httpUserAgent;
|
protected String httpUserAgent;
|
||||||
protected Boolean hideGenerationTimestamp = true;
|
protected Boolean hideGenerationTimestamp = true;
|
||||||
// How to encode special characters like $
|
// How to encode special characters like $
|
||||||
@ -1247,7 +1247,7 @@ public class DefaultCodegen implements CodegenConfig {
|
|||||||
return instantiationTypes.get("map") + "<String, " + inner + ">";
|
return instantiationTypes.get("map") + "<String, " + inner + ">";
|
||||||
} else if (ModelUtils.isArraySchema(schema)) {
|
} else if (ModelUtils.isArraySchema(schema)) {
|
||||||
ArraySchema arraySchema = (ArraySchema) schema;
|
ArraySchema arraySchema = (ArraySchema) schema;
|
||||||
String inner = getSchemaType(arraySchema.getItems());
|
String inner = getSchemaType(getSchemaItems(arraySchema));
|
||||||
return instantiationTypes.get("array") + "<" + inner + ">";
|
return instantiationTypes.get("array") + "<" + inner + ">";
|
||||||
} else {
|
} else {
|
||||||
return null;
|
return null;
|
||||||
@ -1462,6 +1462,15 @@ public class DefaultCodegen implements CodegenConfig {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected Schema<?> getSchemaItems(ArraySchema schema) {
|
||||||
|
if (schema.getItems() != null) {
|
||||||
|
return schema.getItems();
|
||||||
|
} else {
|
||||||
|
LOGGER.error("Undefined array inner type for `{}`. Default to String.", schema.getName());
|
||||||
|
return new StringSchema().description("TODO default missing array inner type to string");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the name of the allOf schema
|
* Return the name of the allOf schema
|
||||||
*
|
*
|
||||||
@ -2180,11 +2189,10 @@ public class DefaultCodegen implements CodegenConfig {
|
|||||||
property.isFreeFormObject = true;
|
property.isFreeFormObject = true;
|
||||||
} else if (ModelUtils.isArraySchema(p)) {
|
} else if (ModelUtils.isArraySchema(p)) {
|
||||||
// default to string if inner item is undefined
|
// default to string if inner item is undefined
|
||||||
Schema innerSchema = ModelUtils.unaliasSchema(this.openAPI, ((ArraySchema) p).getItems());
|
ArraySchema arraySchema = (ArraySchema) p;
|
||||||
if (innerSchema == null) {
|
Schema innerSchema = ModelUtils.unaliasSchema(this.openAPI, getSchemaItems(arraySchema));
|
||||||
LOGGER.error("Undefined array inner type for `{}`. Default to String.", p.getName());
|
if (arraySchema.getItems() == null) {
|
||||||
innerSchema = new StringSchema().description("//TODO automatically added by openapi-generator due to undefined type");
|
arraySchema.setItems(innerSchema);
|
||||||
((ArraySchema) p).setItems(innerSchema);
|
|
||||||
}
|
}
|
||||||
} else if (ModelUtils.isMapSchema(p)) {
|
} else if (ModelUtils.isMapSchema(p)) {
|
||||||
Schema innerSchema = ModelUtils.unaliasSchema(this.openAPI, ModelUtils.getAdditionalProperties(p));
|
Schema innerSchema = ModelUtils.unaliasSchema(this.openAPI, ModelUtils.getAdditionalProperties(p));
|
||||||
@ -2262,11 +2270,10 @@ public class DefaultCodegen implements CodegenConfig {
|
|||||||
if (itemName == null) {
|
if (itemName == null) {
|
||||||
itemName = property.name;
|
itemName = property.name;
|
||||||
}
|
}
|
||||||
Schema innerSchema = ModelUtils.unaliasSchema(this.openAPI, ((ArraySchema) p).getItems());
|
ArraySchema arraySchema = (ArraySchema) p;
|
||||||
if (innerSchema == null) {
|
Schema innerSchema = ModelUtils.unaliasSchema(this.openAPI, getSchemaItems(arraySchema));
|
||||||
LOGGER.error("Undefined array inner type for `{}`. Default to String.", p.getName());
|
if (arraySchema.getItems() == null) {
|
||||||
innerSchema = new StringSchema().description("//TODO automatically added by openapi-generator due to undefined type");
|
arraySchema.setItems(innerSchema);
|
||||||
((ArraySchema) p).setItems(innerSchema);
|
|
||||||
}
|
}
|
||||||
CodegenProperty cp = fromProperty(itemName, innerSchema);
|
CodegenProperty cp = fromProperty(itemName, innerSchema);
|
||||||
updatePropertyForArray(property, cp);
|
updatePropertyForArray(property, cp);
|
||||||
@ -2296,8 +2303,9 @@ public class DefaultCodegen implements CodegenConfig {
|
|||||||
// property.baseType = getSimpleRef(p.get$ref());
|
// property.baseType = getSimpleRef(p.get$ref());
|
||||||
//}
|
//}
|
||||||
// --END of revision
|
// --END of revision
|
||||||
property.isModel = ModelUtils.isModel(p);
|
|
||||||
setNonArrayMapProperty(property, type);
|
setNonArrayMapProperty(property, type);
|
||||||
|
Schema refOrCurrent = ModelUtils.getReferencedSchema(this.openAPI, p);
|
||||||
|
property.isModel = (ModelUtils.isComposedSchema(refOrCurrent) || ModelUtils.isObjectSchema(refOrCurrent)) && ModelUtils.isModel(refOrCurrent);
|
||||||
}
|
}
|
||||||
|
|
||||||
LOGGER.debug("debugging from property return: " + property);
|
LOGGER.debug("debugging from property return: " + property);
|
||||||
@ -2584,7 +2592,7 @@ public class DefaultCodegen implements CodegenConfig {
|
|||||||
|
|
||||||
if (ModelUtils.isArraySchema(responseSchema)) {
|
if (ModelUtils.isArraySchema(responseSchema)) {
|
||||||
ArraySchema as = (ArraySchema) responseSchema;
|
ArraySchema as = (ArraySchema) responseSchema;
|
||||||
CodegenProperty innerProperty = fromProperty("response", as.getItems());
|
CodegenProperty innerProperty = fromProperty("response", getSchemaItems(as));
|
||||||
op.returnBaseType = innerProperty.baseType;
|
op.returnBaseType = innerProperty.baseType;
|
||||||
} else if (ModelUtils.isMapSchema(responseSchema)) {
|
} else if (ModelUtils.isMapSchema(responseSchema)) {
|
||||||
CodegenProperty innerProperty = fromProperty("response", ModelUtils.getAdditionalProperties(responseSchema));
|
CodegenProperty innerProperty = fromProperty("response", ModelUtils.getAdditionalProperties(responseSchema));
|
||||||
@ -2854,7 +2862,7 @@ public class DefaultCodegen implements CodegenConfig {
|
|||||||
|
|
||||||
if (ModelUtils.isArraySchema(responseSchema)) {
|
if (ModelUtils.isArraySchema(responseSchema)) {
|
||||||
ArraySchema as = (ArraySchema) responseSchema;
|
ArraySchema as = (ArraySchema) responseSchema;
|
||||||
CodegenProperty innerProperty = fromProperty("response", as.getItems());
|
CodegenProperty innerProperty = fromProperty("response", getSchemaItems(as));
|
||||||
CodegenProperty innerCp = innerProperty;
|
CodegenProperty innerCp = innerProperty;
|
||||||
while (innerCp != null) {
|
while (innerCp != null) {
|
||||||
r.baseType = innerCp.baseType;
|
r.baseType = innerCp.baseType;
|
||||||
@ -3062,10 +3070,8 @@ public class DefaultCodegen implements CodegenConfig {
|
|||||||
String collectionFormat = null;
|
String collectionFormat = null;
|
||||||
if (ModelUtils.isArraySchema(parameterSchema)) { // for array parameter
|
if (ModelUtils.isArraySchema(parameterSchema)) { // for array parameter
|
||||||
final ArraySchema arraySchema = (ArraySchema) parameterSchema;
|
final ArraySchema arraySchema = (ArraySchema) parameterSchema;
|
||||||
Schema inner = arraySchema.getItems();
|
Schema inner = getSchemaItems(arraySchema);
|
||||||
if (inner == null) {
|
if (arraySchema.getItems() == 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);
|
arraySchema.setItems(inner);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -3901,6 +3907,24 @@ public class DefaultCodegen implements CodegenConfig {
|
|||||||
return library;
|
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.
|
* Set Git user ID.
|
||||||
*
|
*
|
||||||
@ -4598,10 +4622,8 @@ public class DefaultCodegen implements CodegenConfig {
|
|||||||
// array of schema
|
// array of schema
|
||||||
if (ModelUtils.isArraySchema(s)) {
|
if (ModelUtils.isArraySchema(s)) {
|
||||||
final ArraySchema arraySchema = (ArraySchema) s;
|
final ArraySchema arraySchema = (ArraySchema) s;
|
||||||
Schema inner = arraySchema.getItems();
|
Schema inner = getSchemaItems(arraySchema);
|
||||||
if (inner == null) {
|
if (arraySchema.getItems() == 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);
|
arraySchema.setItems(inner);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -4798,10 +4820,8 @@ public class DefaultCodegen implements CodegenConfig {
|
|||||||
setParameterNullable(codegenParameter, codegenProperty);
|
setParameterNullable(codegenParameter, codegenProperty);
|
||||||
} else if (ModelUtils.isArraySchema(schema)) {
|
} else if (ModelUtils.isArraySchema(schema)) {
|
||||||
final ArraySchema arraySchema = (ArraySchema) schema;
|
final ArraySchema arraySchema = (ArraySchema) schema;
|
||||||
Schema inner = arraySchema.getItems();
|
Schema inner = getSchemaItems(arraySchema);
|
||||||
if (inner == null) {
|
if (arraySchema.getItems() == 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);
|
arraySchema.setItems(inner);
|
||||||
}
|
}
|
||||||
CodegenProperty codegenProperty = fromProperty("property", arraySchema);
|
CodegenProperty codegenProperty = fromProperty("property", arraySchema);
|
||||||
|
@ -222,6 +222,11 @@ public class CodegenConfigurator {
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public CodegenConfigurator setGitHost(String gitHost) {
|
||||||
|
generatorSettingsBuilder.withGitHost(gitHost);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
public CodegenConfigurator setGitUserId(String gitUserId) {
|
public CodegenConfigurator setGitUserId(String gitUserId) {
|
||||||
generatorSettingsBuilder.withGitUserId(gitUserId);
|
generatorSettingsBuilder.withGitUserId(gitUserId);
|
||||||
return this;
|
return this;
|
||||||
|
@ -374,6 +374,7 @@ public abstract class AbstractGoCodegen extends DefaultCodegen implements Codege
|
|||||||
boolean addedOptionalImport = false;
|
boolean addedOptionalImport = false;
|
||||||
boolean addedTimeImport = false;
|
boolean addedTimeImport = false;
|
||||||
boolean addedOSImport = false;
|
boolean addedOSImport = false;
|
||||||
|
boolean addedReflectImport = false;
|
||||||
for (CodegenOperation operation : operations) {
|
for (CodegenOperation operation : operations) {
|
||||||
for (CodegenParameter param : operation.allParams) {
|
for (CodegenParameter param : operation.allParams) {
|
||||||
// import "os" if the operation uses files
|
// import "os" if the operation uses files
|
||||||
@ -391,8 +392,9 @@ public abstract class AbstractGoCodegen extends DefaultCodegen implements Codege
|
|||||||
}
|
}
|
||||||
|
|
||||||
// import "reflect" package if the parameter is collectionFormat=multi
|
// import "reflect" package if the parameter is collectionFormat=multi
|
||||||
if (param.isCollectionFormatMulti) {
|
if (!addedReflectImport && param.isCollectionFormatMulti) {
|
||||||
imports.add(createMapping("import", "reflect"));
|
imports.add(createMapping("import", "reflect"));
|
||||||
|
addedReflectImport = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// import "optionals" package if the parameter is optional
|
// import "optionals" package if the parameter is optional
|
||||||
|
@ -686,14 +686,8 @@ public abstract class AbstractJavaCodegen extends DefaultCodegen implements Code
|
|||||||
@Override
|
@Override
|
||||||
public String getTypeDeclaration(Schema p) {
|
public String getTypeDeclaration(Schema p) {
|
||||||
if (ModelUtils.isArraySchema(p)) {
|
if (ModelUtils.isArraySchema(p)) {
|
||||||
ArraySchema ap = (ArraySchema) p;
|
Schema<?> items = getSchemaItems((ArraySchema) p);
|
||||||
Schema inner = ap.getItems();
|
return getSchemaType(p) + "<" + getTypeDeclaration(items) + ">";
|
||||||
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)) {
|
} else if (ModelUtils.isMapSchema(p)) {
|
||||||
Schema inner = ModelUtils.getAdditionalProperties(p);
|
Schema inner = ModelUtils.getAdditionalProperties(p);
|
||||||
if (inner == null) {
|
if (inner == null) {
|
||||||
@ -725,13 +719,7 @@ public abstract class AbstractJavaCodegen extends DefaultCodegen implements Code
|
|||||||
pattern = "new ArrayList<%s>()";
|
pattern = "new ArrayList<%s>()";
|
||||||
}
|
}
|
||||||
|
|
||||||
Schema<?> items;
|
Schema<?> items = getSchemaItems((ArraySchema) p);
|
||||||
if (p instanceof ArraySchema && ((ArraySchema) p).getItems() != null) {
|
|
||||||
items = ((ArraySchema) p).getItems();
|
|
||||||
} else {
|
|
||||||
LOGGER.error("`{}` (array property) does not have a proper inner type defined. Default to type:string", p.getName());
|
|
||||||
items = new StringSchema().description("TODO default missing array inner type to string");
|
|
||||||
}
|
|
||||||
|
|
||||||
String typeDeclaration = getTypeDeclaration(items);
|
String typeDeclaration = getTypeDeclaration(items);
|
||||||
Object java8obj = additionalProperties.get("java8");
|
Object java8obj = additionalProperties.get("java8");
|
||||||
|
@ -35,6 +35,10 @@ import java.util.*;
|
|||||||
import static org.openapitools.codegen.utils.StringUtils.*;
|
import static org.openapitools.codegen.utils.StringUtils.*;
|
||||||
|
|
||||||
public abstract class AbstractKotlinCodegen extends DefaultCodegen implements CodegenConfig {
|
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);
|
private static final Logger LOGGER = LoggerFactory.getLogger(AbstractKotlinCodegen.class);
|
||||||
|
|
||||||
protected String artifactId;
|
protected String artifactId;
|
||||||
@ -51,6 +55,7 @@ public abstract class AbstractKotlinCodegen extends DefaultCodegen implements Co
|
|||||||
protected boolean parcelizeModels = false;
|
protected boolean parcelizeModels = false;
|
||||||
|
|
||||||
protected CodegenConstants.ENUM_PROPERTY_NAMING_TYPE enumPropertyNaming = CodegenConstants.ENUM_PROPERTY_NAMING_TYPE.camelCase;
|
protected CodegenConstants.ENUM_PROPERTY_NAMING_TYPE enumPropertyNaming = CodegenConstants.ENUM_PROPERTY_NAMING_TYPE.camelCase;
|
||||||
|
protected SERIALIZATION_LIBRARY_TYPE serializationLibrary = SERIALIZATION_LIBRARY_TYPE.moshi;
|
||||||
|
|
||||||
public AbstractKotlinCodegen() {
|
public AbstractKotlinCodegen() {
|
||||||
super();
|
super();
|
||||||
@ -205,6 +210,10 @@ public abstract class AbstractKotlinCodegen extends DefaultCodegen implements Co
|
|||||||
|
|
||||||
CliOption enumPropertyNamingOpt = new CliOption(CodegenConstants.ENUM_PROPERTY_NAMING, CodegenConstants.ENUM_PROPERTY_NAMING_DESC);
|
CliOption enumPropertyNamingOpt = new CliOption(CodegenConstants.ENUM_PROPERTY_NAMING, CodegenConstants.ENUM_PROPERTY_NAMING_DESC);
|
||||||
cliOptions.add(enumPropertyNamingOpt.defaultValue(enumPropertyNaming.name()));
|
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));
|
cliOptions.add(new CliOption(CodegenConstants.PARCELIZE_MODELS, CodegenConstants.PARCELIZE_MODELS_DESC));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -244,6 +253,10 @@ public abstract class AbstractKotlinCodegen extends DefaultCodegen implements Co
|
|||||||
return this.enumPropertyNaming;
|
return this.enumPropertyNaming;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public SERIALIZATION_LIBRARY_TYPE getSerializationLibrary() {
|
||||||
|
return this.serializationLibrary;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the naming convention for Kotlin enum properties
|
* Sets the naming convention for Kotlin enum properties
|
||||||
*
|
*
|
||||||
@ -261,6 +274,24 @@ public abstract class AbstractKotlinCodegen extends DefaultCodegen implements Co
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the serialization engine for Kotlin
|
||||||
|
*
|
||||||
|
* @param enumSerializationLibrary The string representation of the serialization library as defined by
|
||||||
|
* {@link org.openapitools.codegen.languages.AbstractKotlinCodegen.SERIALIZATION_LIBRARY_TYPE}
|
||||||
|
*/
|
||||||
|
public void setSerializationLibrary(final String enumSerializationLibrary) {
|
||||||
|
try {
|
||||||
|
this.serializationLibrary = SERIALIZATION_LIBRARY_TYPE.valueOf(enumSerializationLibrary);
|
||||||
|
} catch (IllegalArgumentException ex) {
|
||||||
|
StringBuilder sb = new StringBuilder(enumSerializationLibrary + " is an invalid enum property naming option. Please choose from:");
|
||||||
|
for (SERIALIZATION_LIBRARY_TYPE t : SERIALIZATION_LIBRARY_TYPE.values()) {
|
||||||
|
sb.append("\n ").append(t.name());
|
||||||
|
}
|
||||||
|
throw new RuntimeException(sb.toString());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* returns the swagger type for the property
|
* returns the swagger type for the property
|
||||||
*
|
*
|
||||||
@ -330,6 +361,14 @@ public abstract class AbstractKotlinCodegen extends DefaultCodegen implements Co
|
|||||||
setEnumPropertyNaming((String) additionalProperties.get(CodegenConstants.ENUM_PROPERTY_NAMING));
|
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)) {
|
if (additionalProperties.containsKey(CodegenConstants.SOURCE_FOLDER)) {
|
||||||
this.setSourceFolder((String) additionalProperties.get(CodegenConstants.SOURCE_FOLDER));
|
this.setSourceFolder((String) additionalProperties.get(CodegenConstants.SOURCE_FOLDER));
|
||||||
} else {
|
} else {
|
||||||
|
@ -0,0 +1,274 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2018 OpenAPI-Generator Contributors (https://openapi-generator.tech)
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package org.openapitools.codegen.languages;
|
||||||
|
|
||||||
|
import org.openapitools.codegen.*;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.Writer;
|
||||||
|
import java.nio.file.Files;
|
||||||
|
import java.nio.file.Path;
|
||||||
|
import java.nio.file.Paths;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.HashSet;
|
||||||
|
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
|
import com.samskivert.mustache.Mustache;
|
||||||
|
import com.samskivert.mustache.Template;
|
||||||
|
|
||||||
|
import io.swagger.v3.oas.models.OpenAPI;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* basic asciidoc markup generator.
|
||||||
|
*
|
||||||
|
* @see <a href="https://asciidoctor.org">asciidoctor</a>
|
||||||
|
*/
|
||||||
|
public class AsciidocDocumentationCodegen extends DefaultCodegen implements CodegenConfig {
|
||||||
|
|
||||||
|
private static final Logger LOGGER = LoggerFactory.getLogger(AsciidocDocumentationCodegen.class);
|
||||||
|
|
||||||
|
public static final String SPEC_DIR = "specDir";
|
||||||
|
public static final String SNIPPET_DIR = "snippetDir";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Lambda emitting an asciidoc "include::filename.adoc[]" if file is found in
|
||||||
|
* path. Use:
|
||||||
|
*
|
||||||
|
* <pre>
|
||||||
|
* {{#includemarkup}}{{name}}/description.adoc{{/includemarkup}}
|
||||||
|
* </pre>
|
||||||
|
*/
|
||||||
|
public class IncludeMarkupLambda implements Mustache.Lambda {
|
||||||
|
|
||||||
|
private long includeCount = 0;
|
||||||
|
private long notFoundCount = 0;
|
||||||
|
private String basePath;
|
||||||
|
|
||||||
|
public IncludeMarkupLambda(final String basePath) {
|
||||||
|
this.basePath = basePath;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String resetCounter() {
|
||||||
|
String msg = "included: " + includeCount + " notFound: " + notFoundCount + " from " + basePath;
|
||||||
|
includeCount = 0;
|
||||||
|
notFoundCount = 0;
|
||||||
|
return msg;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void execute(final Template.Fragment frag, final Writer out) throws IOException {
|
||||||
|
|
||||||
|
final String relativeFileName = AsciidocDocumentationCodegen.sanitize(frag.execute());
|
||||||
|
final Path filePathToInclude = Paths.get(basePath, relativeFileName).toAbsolutePath();
|
||||||
|
|
||||||
|
if (Files.isRegularFile(filePathToInclude)) {
|
||||||
|
LOGGER.debug(
|
||||||
|
"including " + ++includeCount + ". file into markup from: " + filePathToInclude.toString());
|
||||||
|
out.write("\ninclude::" + relativeFileName + "[]\n");
|
||||||
|
} else {
|
||||||
|
LOGGER.debug(++notFoundCount + ". file not found, skip include for: " + filePathToInclude.toString());
|
||||||
|
out.write("\n// markup not found, no include ::" + relativeFileName + "[]\n");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Lambda emitting an asciidoc "http link" if file is found in path. Use:
|
||||||
|
*
|
||||||
|
* <pre>
|
||||||
|
* {{#snippetLink}}markup until koma, /{{name}}.json{{/snippetLink}}
|
||||||
|
* </pre>
|
||||||
|
*/
|
||||||
|
public class LinkMarkupLambda implements Mustache.Lambda {
|
||||||
|
|
||||||
|
private long linkedCount = 0;
|
||||||
|
private long notFoundLinkCount = 0;
|
||||||
|
private String basePath;
|
||||||
|
|
||||||
|
public LinkMarkupLambda(final String basePath) {
|
||||||
|
this.basePath = basePath;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String resetCounter() {
|
||||||
|
String msg = "linked:" + linkedCount + " notFound: " + notFoundLinkCount + " from " + basePath;
|
||||||
|
linkedCount = 0;
|
||||||
|
notFoundLinkCount = 0;
|
||||||
|
return msg;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void execute(final Template.Fragment frag, final Writer out) throws IOException {
|
||||||
|
|
||||||
|
final String content = frag.execute();
|
||||||
|
final String[] tokens = content.split(",", 2);
|
||||||
|
|
||||||
|
final String linkName = tokens.length > 0 ? tokens[0] : "";
|
||||||
|
|
||||||
|
final String relativeFileName = AsciidocDocumentationCodegen
|
||||||
|
.sanitize(tokens.length > 1 ? tokens[1] : linkName);
|
||||||
|
|
||||||
|
final Path filePathToLinkTo = Paths.get(basePath, relativeFileName).toAbsolutePath();
|
||||||
|
|
||||||
|
if (Files.isRegularFile(filePathToLinkTo)) {
|
||||||
|
LOGGER.debug("linking " + ++linkedCount + ". file into markup from: " + filePathToLinkTo.toString());
|
||||||
|
out.write("\n" + linkName + " link:" + relativeFileName + "[]\n");
|
||||||
|
} else {
|
||||||
|
LOGGER.debug(++notFoundLinkCount + ". file not found, skip link for: " + filePathToLinkTo.toString());
|
||||||
|
out.write("\n// file not found, no " + linkName + " link :" + relativeFileName + "[]\n");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected String invokerPackage = "org.openapitools.client";
|
||||||
|
protected String groupId = "org.openapitools";
|
||||||
|
protected String artifactId = "openapi-client";
|
||||||
|
protected String artifactVersion = "1.0.0";
|
||||||
|
|
||||||
|
private IncludeMarkupLambda includeSpecMarkupLambda;
|
||||||
|
private IncludeMarkupLambda includeSnippetMarkupLambda;
|
||||||
|
private LinkMarkupLambda linkSnippetMarkupLambda;
|
||||||
|
|
||||||
|
public CodegenType getTag() {
|
||||||
|
return CodegenType.DOCUMENTATION;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* extracted filter value should be relative to be of use as link or include
|
||||||
|
* file.
|
||||||
|
*
|
||||||
|
* @param name filename to sanitize
|
||||||
|
* @return trimmed and striped path part or empty string.
|
||||||
|
*/
|
||||||
|
static String sanitize(final String name) {
|
||||||
|
String sanitized = name == null ? "" : name.trim();
|
||||||
|
return sanitized.startsWith(File.separator) || sanitized.startsWith("/") ? sanitized.substring(1) : sanitized;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getName() {
|
||||||
|
return "asciidoc";
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getHelp() {
|
||||||
|
return "Generates asciidoc markup based documentation.";
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getSpecDir() {
|
||||||
|
return additionalProperties.get("specDir").toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getSnippetDir() {
|
||||||
|
return additionalProperties.get("snippetDir").toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
public AsciidocDocumentationCodegen() {
|
||||||
|
super();
|
||||||
|
|
||||||
|
LOGGER.trace("start asciidoc codegen");
|
||||||
|
|
||||||
|
outputFolder = "generated-code" + File.separator + "asciidoc";
|
||||||
|
embeddedTemplateDir = templateDir = "asciidoc-documentation";
|
||||||
|
|
||||||
|
defaultIncludes = new HashSet<String>();
|
||||||
|
|
||||||
|
cliOptions.add(new CliOption("appName", "short name of the application"));
|
||||||
|
cliOptions.add(new CliOption("appDescription", "description of the application"));
|
||||||
|
cliOptions.add(new CliOption("infoUrl", "a URL where users can get more information about the application"));
|
||||||
|
cliOptions.add(new CliOption("infoEmail", "an email address to contact for inquiries about the application"));
|
||||||
|
cliOptions.add(new CliOption("licenseInfo", "a short description of the license"));
|
||||||
|
cliOptions.add(new CliOption(CodegenConstants.LICENSE_URL, "a URL pointing to the full license"));
|
||||||
|
cliOptions.add(new CliOption(CodegenConstants.INVOKER_PACKAGE, CodegenConstants.INVOKER_PACKAGE_DESC));
|
||||||
|
cliOptions.add(new CliOption(CodegenConstants.GROUP_ID, CodegenConstants.GROUP_ID_DESC));
|
||||||
|
cliOptions.add(new CliOption(CodegenConstants.ARTIFACT_ID, CodegenConstants.ARTIFACT_ID_DESC));
|
||||||
|
cliOptions.add(new CliOption(CodegenConstants.ARTIFACT_VERSION, CodegenConstants.ARTIFACT_VERSION_DESC));
|
||||||
|
|
||||||
|
cliOptions.add(new CliOption(SNIPPET_DIR,
|
||||||
|
"path with includable markup snippets (e.g. test output generated by restdoc, default: .")
|
||||||
|
.defaultValue("."));
|
||||||
|
cliOptions.add(new CliOption(SPEC_DIR,
|
||||||
|
"path with includable markup spec files (e.g. handwritten additional docs, default: .")
|
||||||
|
.defaultValue(".."));
|
||||||
|
|
||||||
|
additionalProperties.put("appName", "OpenAPI Sample description");
|
||||||
|
additionalProperties.put("appDescription", "A sample OpenAPI documentation");
|
||||||
|
additionalProperties.put("infoUrl", "https://openapi-generator.tech");
|
||||||
|
additionalProperties.put("infoEmail", "team@openapitools.org");
|
||||||
|
additionalProperties.put("licenseInfo", "All rights reserved");
|
||||||
|
additionalProperties.put(CodegenConstants.LICENSE_URL, "http://apache.org/licenses/LICENSE-2.0.html");
|
||||||
|
additionalProperties.put(CodegenConstants.INVOKER_PACKAGE, invokerPackage);
|
||||||
|
additionalProperties.put(CodegenConstants.GROUP_ID, groupId);
|
||||||
|
additionalProperties.put(CodegenConstants.ARTIFACT_ID, artifactId);
|
||||||
|
additionalProperties.put(CodegenConstants.ARTIFACT_VERSION, artifactVersion);
|
||||||
|
|
||||||
|
supportingFiles.add(new SupportingFile("index.mustache", "", "index.adoc"));
|
||||||
|
reservedWords = new HashSet<String>();
|
||||||
|
|
||||||
|
languageSpecificPrimitives = new HashSet<String>();
|
||||||
|
importMapping = new HashMap<String, String>();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String escapeQuotationMark(String input) {
|
||||||
|
return input; // just return the original string
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String escapeUnsafeCharacters(String input) {
|
||||||
|
return input; // just return the original string
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void processOpts() {
|
||||||
|
super.processOpts();
|
||||||
|
|
||||||
|
String specDir = this.additionalProperties.get(SPEC_DIR) + "";
|
||||||
|
if (!Files.isDirectory(Paths.get(specDir))) {
|
||||||
|
LOGGER.warn("base part for include markup lambda not found: " + specDir + " as "
|
||||||
|
+ Paths.get(specDir).toAbsolutePath());
|
||||||
|
}
|
||||||
|
|
||||||
|
this.includeSpecMarkupLambda = new IncludeMarkupLambda(specDir);
|
||||||
|
additionalProperties.put("specinclude", this.includeSpecMarkupLambda);
|
||||||
|
|
||||||
|
String snippetDir = this.additionalProperties.get(SNIPPET_DIR) + "";
|
||||||
|
if (!Files.isDirectory(Paths.get(snippetDir))) {
|
||||||
|
LOGGER.warn("base part for include markup lambda not found: " + snippetDir + " as "
|
||||||
|
+ Paths.get(snippetDir).toAbsolutePath());
|
||||||
|
}
|
||||||
|
|
||||||
|
this.includeSnippetMarkupLambda = new IncludeMarkupLambda(snippetDir);
|
||||||
|
additionalProperties.put("snippetinclude", this.includeSnippetMarkupLambda);
|
||||||
|
|
||||||
|
this.linkSnippetMarkupLambda = new LinkMarkupLambda(snippetDir);
|
||||||
|
additionalProperties.put("snippetlink", this.linkSnippetMarkupLambda);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void processOpenAPI(OpenAPI openAPI) {
|
||||||
|
if (this.includeSpecMarkupLambda != null) {
|
||||||
|
LOGGER.debug("specs: " + ": " + this.includeSpecMarkupLambda.resetCounter());
|
||||||
|
}
|
||||||
|
if (this.includeSnippetMarkupLambda != null) {
|
||||||
|
LOGGER.debug("snippets: " + ": " + this.includeSnippetMarkupLambda.resetCounter());
|
||||||
|
}
|
||||||
|
super.processOpenAPI(openAPI);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -26,7 +26,7 @@ public class CppQt5AbstractCodegen extends AbstractCppCodegen implements Codegen
|
|||||||
protected Set<String> systemIncludes = new HashSet<String>();
|
protected Set<String> systemIncludes = new HashSet<String>();
|
||||||
|
|
||||||
protected Set<String> nonFrameworkPrimitives = new HashSet<String>();
|
protected Set<String> nonFrameworkPrimitives = new HashSet<String>();
|
||||||
|
|
||||||
public CppQt5AbstractCodegen() {
|
public CppQt5AbstractCodegen() {
|
||||||
super();
|
super();
|
||||||
// set modelNamePrefix as default for QHttpEngine Server
|
// set modelNamePrefix as default for QHttpEngine Server
|
||||||
@ -61,10 +61,10 @@ public class CppQt5AbstractCodegen extends AbstractCppCodegen implements Codegen
|
|||||||
"double")
|
"double")
|
||||||
);
|
);
|
||||||
nonFrameworkPrimitives.addAll(languageSpecificPrimitives);
|
nonFrameworkPrimitives.addAll(languageSpecificPrimitives);
|
||||||
|
|
||||||
foundationClasses.addAll(
|
foundationClasses.addAll(
|
||||||
Arrays.asList(
|
Arrays.asList(
|
||||||
"QString",
|
"QString",
|
||||||
"QDate",
|
"QDate",
|
||||||
"QDateTime",
|
"QDateTime",
|
||||||
"QByteArray")
|
"QByteArray")
|
||||||
@ -78,7 +78,7 @@ public class CppQt5AbstractCodegen extends AbstractCppCodegen implements Codegen
|
|||||||
typeMapping.put("integer", "qint32");
|
typeMapping.put("integer", "qint32");
|
||||||
typeMapping.put("long", "qint64");
|
typeMapping.put("long", "qint64");
|
||||||
typeMapping.put("boolean", "bool");
|
typeMapping.put("boolean", "bool");
|
||||||
typeMapping.put("number", "double");
|
typeMapping.put("number", "double");
|
||||||
typeMapping.put("array", "QList");
|
typeMapping.put("array", "QList");
|
||||||
typeMapping.put("map", "QMap");
|
typeMapping.put("map", "QMap");
|
||||||
typeMapping.put("object", PREFIX + "Object");
|
typeMapping.put("object", PREFIX + "Object");
|
||||||
@ -90,8 +90,8 @@ public class CppQt5AbstractCodegen extends AbstractCppCodegen implements Codegen
|
|||||||
// modifications on multiple templates)
|
// modifications on multiple templates)
|
||||||
typeMapping.put("UUID", "QString");
|
typeMapping.put("UUID", "QString");
|
||||||
typeMapping.put("URI", "QString");
|
typeMapping.put("URI", "QString");
|
||||||
typeMapping.put("file", "QIODevice");
|
typeMapping.put("file", "QByteArray");
|
||||||
typeMapping.put("binary", "QIODevice");
|
typeMapping.put("binary", "QByteArray");
|
||||||
importMapping = new HashMap<String, String>();
|
importMapping = new HashMap<String, String>();
|
||||||
namespaces = new HashMap<String, String>();
|
namespaces = new HashMap<String, String>();
|
||||||
|
|
||||||
@ -101,7 +101,6 @@ public class CppQt5AbstractCodegen extends AbstractCppCodegen implements Codegen
|
|||||||
systemIncludes.add("QDate");
|
systemIncludes.add("QDate");
|
||||||
systemIncludes.add("QDateTime");
|
systemIncludes.add("QDateTime");
|
||||||
systemIncludes.add("QByteArray");
|
systemIncludes.add("QByteArray");
|
||||||
systemIncludes.add("QIODevice");
|
|
||||||
}
|
}
|
||||||
@Override
|
@Override
|
||||||
public void processOpts() {
|
public void processOpts() {
|
||||||
@ -119,7 +118,7 @@ public class CppQt5AbstractCodegen extends AbstractCppCodegen implements Codegen
|
|||||||
additionalProperties().put("prefix", modelNamePrefix);
|
additionalProperties().put("prefix", modelNamePrefix);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toModelImport(String name) {
|
public String toModelImport(String name) {
|
||||||
if( name.isEmpty() ) {
|
if( name.isEmpty() ) {
|
||||||
@ -140,7 +139,7 @@ public class CppQt5AbstractCodegen extends AbstractCppCodegen implements Codegen
|
|||||||
|
|
||||||
return "#include \"" + folder + name + ".h\"";
|
return "#include \"" + folder + name + ".h\"";
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Optional - type declaration. This is a String which is used by the templates to instantiate your
|
* Optional - type declaration. This is a String which is used by the templates to instantiate your
|
||||||
* types. There is typically special handling for different property types
|
* types. There is typically special handling for different property types
|
||||||
@ -160,9 +159,9 @@ public class CppQt5AbstractCodegen extends AbstractCppCodegen implements Codegen
|
|||||||
Schema inner = ModelUtils.getAdditionalProperties(p);
|
Schema inner = ModelUtils.getAdditionalProperties(p);
|
||||||
return getSchemaType(p) + "<QString, " + getTypeDeclaration(inner) + ">";
|
return getSchemaType(p) + "<QString, " + getTypeDeclaration(inner) + ">";
|
||||||
} else if (ModelUtils.isBinarySchema(p)) {
|
} else if (ModelUtils.isBinarySchema(p)) {
|
||||||
return getSchemaType(p) + "*";
|
return getSchemaType(p);
|
||||||
} else if (ModelUtils.isFileSchema(p)) {
|
} else if (ModelUtils.isFileSchema(p)) {
|
||||||
return getSchemaType(p) + "*";
|
return getSchemaType(p);
|
||||||
}
|
}
|
||||||
if (foundationClasses.contains(openAPIType)) {
|
if (foundationClasses.contains(openAPIType)) {
|
||||||
return openAPIType;
|
return openAPIType;
|
||||||
@ -174,7 +173,7 @@ public class CppQt5AbstractCodegen extends AbstractCppCodegen implements Codegen
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@SuppressWarnings("rawtypes")
|
@SuppressWarnings("rawtypes")
|
||||||
public String toDefaultValue(Schema p) {
|
public String toDefaultValue(Schema p) {
|
||||||
if (ModelUtils.isBooleanSchema(p)) {
|
if (ModelUtils.isBooleanSchema(p)) {
|
||||||
return "false";
|
return "false";
|
||||||
@ -211,7 +210,7 @@ public class CppQt5AbstractCodegen extends AbstractCppCodegen implements Codegen
|
|||||||
public String toModelFilename(String name) {
|
public String toModelFilename(String name) {
|
||||||
return toModelName(name);
|
return toModelName(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Optional - OpenAPI type conversion. This is used to map OpenAPI types in a `Schema` into
|
* Optional - OpenAPI type conversion. This is used to map OpenAPI types in a `Schema` into
|
||||||
* either language specific types via `typeMapping` or into complex models if there is not a mapping.
|
* either language specific types via `typeMapping` or into complex models if there is not a mapping.
|
||||||
@ -219,7 +218,7 @@ public class CppQt5AbstractCodegen extends AbstractCppCodegen implements Codegen
|
|||||||
* @return a string value of the type or complex model for this property
|
* @return a string value of the type or complex model for this property
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
@SuppressWarnings("rawtypes")
|
@SuppressWarnings("rawtypes")
|
||||||
public String getSchemaType(Schema p) {
|
public String getSchemaType(Schema p) {
|
||||||
String openAPIType = super.getSchemaType(p);
|
String openAPIType = super.getSchemaType(p);
|
||||||
|
|
||||||
@ -242,7 +241,7 @@ public class CppQt5AbstractCodegen extends AbstractCppCodegen implements Codegen
|
|||||||
public String toVarName(String name) {
|
public String toVarName(String name) {
|
||||||
// sanitize name
|
// sanitize name
|
||||||
String varName = name;
|
String varName = name;
|
||||||
varName = sanitizeName(name);
|
varName = sanitizeName(name);
|
||||||
|
|
||||||
// if it's all uppper case, convert to lower case
|
// if it's all uppper case, convert to lower case
|
||||||
if (varName.matches("^[A-Z_]*$")) {
|
if (varName.matches("^[A-Z_]*$")) {
|
||||||
@ -270,7 +269,7 @@ public class CppQt5AbstractCodegen extends AbstractCppCodegen implements Codegen
|
|||||||
public String getTypeDeclaration(String str) {
|
public String getTypeDeclaration(String str) {
|
||||||
return str;
|
return str;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected boolean needToImport(String type) {
|
protected boolean needToImport(String type) {
|
||||||
return StringUtils.isNotBlank(type) && !defaultIncludes.contains(type)
|
return StringUtils.isNotBlank(type) && !defaultIncludes.contains(type)
|
||||||
@ -283,7 +282,7 @@ public class CppQt5AbstractCodegen extends AbstractCppCodegen implements Codegen
|
|||||||
public Map<String, Object> postProcessOperationsWithModels(Map<String, Object> objs, List<Object> allModels) {
|
public Map<String, Object> postProcessOperationsWithModels(Map<String, Object> objs, List<Object> allModels) {
|
||||||
Map<String, Object> objectMap = (Map<String, Object>) objs.get("operations");
|
Map<String, Object> objectMap = (Map<String, Object>) objs.get("operations");
|
||||||
List<CodegenOperation> operations = (List<CodegenOperation>) objectMap.get("operation");
|
List<CodegenOperation> operations = (List<CodegenOperation>) objectMap.get("operation");
|
||||||
|
|
||||||
List<Map<String, String>> imports = (List<Map<String, String>>) objs.get("imports");
|
List<Map<String, String>> imports = (List<Map<String, String>>) objs.get("imports");
|
||||||
Map<String, CodegenModel> codegenModels = new HashMap<String, CodegenModel> ();
|
Map<String, CodegenModel> codegenModels = new HashMap<String, CodegenModel> ();
|
||||||
for(Object moObj : allModels) {
|
for(Object moObj : allModels) {
|
||||||
@ -298,7 +297,7 @@ public class CppQt5AbstractCodegen extends AbstractCppCodegen implements Codegen
|
|||||||
operation.vendorExtensions.put("returnsEnum", true);
|
operation.vendorExtensions.put("returnsEnum", true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Check all return parameter baseType if there is a necessity to include, include it if not
|
// Check all return parameter baseType if there is a necessity to include, include it if not
|
||||||
// already done
|
// already done
|
||||||
if (operation.returnBaseType != null && needToImport(operation.returnBaseType)) {
|
if (operation.returnBaseType != null && needToImport(operation.returnBaseType)) {
|
||||||
if(!isIncluded(operation.returnBaseType, imports)) {
|
if(!isIncluded(operation.returnBaseType, imports)) {
|
||||||
@ -308,7 +307,7 @@ public class CppQt5AbstractCodegen extends AbstractCppCodegen implements Codegen
|
|||||||
List<CodegenParameter> params = new ArrayList<CodegenParameter>();
|
List<CodegenParameter> params = new ArrayList<CodegenParameter>();
|
||||||
if (operation.allParams != null)params.addAll(operation.allParams);
|
if (operation.allParams != null)params.addAll(operation.allParams);
|
||||||
|
|
||||||
// Check all parameter baseType if there is a necessity to include, include it if not
|
// Check all parameter baseType if there is a necessity to include, include it if not
|
||||||
// already done
|
// already done
|
||||||
for(CodegenParameter param : params) {
|
for(CodegenParameter param : params) {
|
||||||
if(param.isPrimitiveType && needToImport(param.baseType)) {
|
if(param.isPrimitiveType && needToImport(param.baseType)) {
|
||||||
@ -321,7 +320,7 @@ public class CppQt5AbstractCodegen extends AbstractCppCodegen implements Codegen
|
|||||||
// We use QString to pass path params, add it to include
|
// We use QString to pass path params, add it to include
|
||||||
if(!isIncluded("QString", imports)) {
|
if(!isIncluded("QString", imports)) {
|
||||||
imports.add(createMapping("import", "QString"));
|
imports.add(createMapping("import", "QString"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(isIncluded("QMap", imports)) {
|
if(isIncluded("QMap", imports)) {
|
||||||
@ -332,7 +331,7 @@ public class CppQt5AbstractCodegen extends AbstractCppCodegen implements Codegen
|
|||||||
}
|
}
|
||||||
return objs;
|
return objs;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Map<String, Object> postProcessModels(Map<String, Object> objs) {
|
public Map<String, Object> postProcessModels(Map<String, Object> objs) {
|
||||||
return postProcessModelsEnum(objs);
|
return postProcessModelsEnum(objs);
|
||||||
@ -342,18 +341,18 @@ public class CppQt5AbstractCodegen extends AbstractCppCodegen implements Codegen
|
|||||||
public String toEnumValue(String value, String datatype) {
|
public String toEnumValue(String value, String datatype) {
|
||||||
return escapeText(value);
|
return escapeText(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isDataTypeString(String dataType) {
|
public boolean isDataTypeString(String dataType) {
|
||||||
return "QString".equals(dataType);
|
return "QString".equals(dataType);
|
||||||
}
|
}
|
||||||
|
|
||||||
private Map<String, String> createMapping(String key, String value) {
|
private Map<String, String> createMapping(String key, String value) {
|
||||||
Map<String, String> customImport = new HashMap<String, String>();
|
Map<String, String> customImport = new HashMap<String, String>();
|
||||||
customImport.put(key, toModelImport(value));
|
customImport.put(key, toModelImport(value));
|
||||||
return customImport;
|
return customImport;
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean isIncluded(String type, List<Map<String, String>> imports) {
|
private boolean isIncluded(String type, List<Map<String, String>> imports) {
|
||||||
boolean included = false;
|
boolean included = false;
|
||||||
String inclStr = toModelImport(type);
|
String inclStr = toModelImport(type);
|
||||||
|
@ -76,14 +76,15 @@ public class CppQt5ClientCodegen extends CppQt5AbstractCodegen implements Codege
|
|||||||
supportingFiles.add(new SupportingFile("helpers-body.mustache", sourceFolder, PREFIX + "Helpers.cpp"));
|
supportingFiles.add(new SupportingFile("helpers-body.mustache", sourceFolder, PREFIX + "Helpers.cpp"));
|
||||||
supportingFiles.add(new SupportingFile("HttpRequest.h.mustache", sourceFolder, PREFIX + "HttpRequest.h"));
|
supportingFiles.add(new SupportingFile("HttpRequest.h.mustache", sourceFolder, PREFIX + "HttpRequest.h"));
|
||||||
supportingFiles.add(new SupportingFile("HttpRequest.cpp.mustache", sourceFolder, PREFIX + "HttpRequest.cpp"));
|
supportingFiles.add(new SupportingFile("HttpRequest.cpp.mustache", sourceFolder, PREFIX + "HttpRequest.cpp"));
|
||||||
|
supportingFiles.add(new SupportingFile("HttpFileElement.h.mustache", sourceFolder, PREFIX + "HttpFileElement.h"));
|
||||||
|
supportingFiles.add(new SupportingFile("HttpFileElement.cpp.mustache", sourceFolder, PREFIX + "HttpFileElement.cpp"));
|
||||||
supportingFiles.add(new SupportingFile("object.mustache", sourceFolder, PREFIX + "Object.h"));
|
supportingFiles.add(new SupportingFile("object.mustache", sourceFolder, PREFIX + "Object.h"));
|
||||||
supportingFiles.add(new SupportingFile("enum.mustache", sourceFolder, PREFIX + "Enum.h"));
|
supportingFiles.add(new SupportingFile("enum.mustache", sourceFolder, PREFIX + "Enum.h"));
|
||||||
if (optionalProjectFileFlag) {
|
if (optionalProjectFileFlag) {
|
||||||
supportingFiles.add(new SupportingFile("Project.mustache", sourceFolder, "client.pri"));
|
supportingFiles.add(new SupportingFile("Project.mustache", sourceFolder, "client.pri"));
|
||||||
}
|
}
|
||||||
typeMapping.put("file", PREFIX + "HttpRequestInputFileElement");
|
typeMapping.put("file", PREFIX + "HttpFileElement");
|
||||||
typeMapping.put("binary", PREFIX +"HttpRequestInputFileElement");
|
importMapping.put(PREFIX + "HttpFileElement", "#include \"" + PREFIX + "HttpFileElement.h\"");
|
||||||
importMapping.put(PREFIX + "HttpRequestInputFileElement", "#include \"" + PREFIX + "HttpRequest.h\"");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -95,7 +96,7 @@ public class CppQt5ClientCodegen extends CppQt5AbstractCodegen implements Codege
|
|||||||
} else {
|
} else {
|
||||||
additionalProperties.put(CodegenConstants.OPTIONAL_PROJECT_FILE, optionalProjectFileFlag);
|
additionalProperties.put(CodegenConstants.OPTIONAL_PROJECT_FILE, optionalProjectFileFlag);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (additionalProperties.containsKey("modelNamePrefix")) {
|
if (additionalProperties.containsKey("modelNamePrefix")) {
|
||||||
supportingFiles.clear();
|
supportingFiles.clear();
|
||||||
supportingFiles.add(new SupportingFile("helpers-header.mustache", sourceFolder, modelNamePrefix + "Helpers.h"));
|
supportingFiles.add(new SupportingFile("helpers-header.mustache", sourceFolder, modelNamePrefix + "Helpers.h"));
|
||||||
@ -103,11 +104,10 @@ public class CppQt5ClientCodegen extends CppQt5AbstractCodegen implements Codege
|
|||||||
supportingFiles.add(new SupportingFile("HttpRequest.h.mustache", sourceFolder, modelNamePrefix + "HttpRequest.h"));
|
supportingFiles.add(new SupportingFile("HttpRequest.h.mustache", sourceFolder, modelNamePrefix + "HttpRequest.h"));
|
||||||
supportingFiles.add(new SupportingFile("HttpRequest.cpp.mustache", sourceFolder, modelNamePrefix + "HttpRequest.cpp"));
|
supportingFiles.add(new SupportingFile("HttpRequest.cpp.mustache", sourceFolder, modelNamePrefix + "HttpRequest.cpp"));
|
||||||
supportingFiles.add(new SupportingFile("object.mustache", sourceFolder, modelNamePrefix + "Object.h"));
|
supportingFiles.add(new SupportingFile("object.mustache", sourceFolder, modelNamePrefix + "Object.h"));
|
||||||
supportingFiles.add(new SupportingFile("enum.mustache", sourceFolder, modelNamePrefix + "Enum.h"));
|
supportingFiles.add(new SupportingFile("enum.mustache", sourceFolder, modelNamePrefix + "Enum.h"));
|
||||||
|
|
||||||
typeMapping.put("file", modelNamePrefix + "HttpRequestInputFileElement");
|
typeMapping.put("file", modelNamePrefix + "HttpFileElement");
|
||||||
typeMapping.put("binary", modelNamePrefix + "HttpRequestInputFileElement");
|
importMapping.put(modelNamePrefix + "HttpFileElement", "#include \"" + modelNamePrefix + "HttpFileElement.h\"");
|
||||||
importMapping.put(modelNamePrefix + "HttpRequestInputFileElement", "#include \"" + modelNamePrefix + "HttpRequest.h\"");
|
|
||||||
if (optionalProjectFileFlag) {
|
if (optionalProjectFileFlag) {
|
||||||
supportingFiles.add(new SupportingFile("Project.mustache", sourceFolder, modelNamePrefix + "client.pri"));
|
supportingFiles.add(new SupportingFile("Project.mustache", sourceFolder, modelNamePrefix + "client.pri"));
|
||||||
}
|
}
|
||||||
|
@ -76,7 +76,7 @@ public class CppQt5QHttpEngineServerCodegen extends CppQt5AbstractCodegen implem
|
|||||||
apiTemplateFiles.put(
|
apiTemplateFiles.put(
|
||||||
"apirequest.h.mustache", // the template to use
|
"apirequest.h.mustache", // the template to use
|
||||||
".h"); // the extension for each file to write
|
".h"); // the extension for each file to write
|
||||||
|
|
||||||
apiTemplateFiles.put(
|
apiTemplateFiles.put(
|
||||||
"apirequest.cpp.mustache", // the template to use
|
"apirequest.cpp.mustache", // the template to use
|
||||||
".cpp"); // the extension for each file to write
|
".cpp"); // the extension for each file to write
|
||||||
@ -86,11 +86,13 @@ public class CppQt5QHttpEngineServerCodegen extends CppQt5AbstractCodegen implem
|
|||||||
* will use the resource stream to attempt to read the templates.
|
* will use the resource stream to attempt to read the templates.
|
||||||
*/
|
*/
|
||||||
embeddedTemplateDir = templateDir = "cpp-qt5-qhttpengine-server";
|
embeddedTemplateDir = templateDir = "cpp-qt5-qhttpengine-server";
|
||||||
|
|
||||||
supportingFiles.add(new SupportingFile("helpers-header.mustache", sourceFolder + MODEL_DIR, PREFIX + "Helpers.h"));
|
supportingFiles.add(new SupportingFile("helpers-header.mustache", sourceFolder + MODEL_DIR, PREFIX + "Helpers.h"));
|
||||||
supportingFiles.add(new SupportingFile("helpers-body.mustache", sourceFolder + MODEL_DIR, PREFIX + "Helpers.cpp"));
|
supportingFiles.add(new SupportingFile("helpers-body.mustache", sourceFolder + MODEL_DIR, PREFIX + "Helpers.cpp"));
|
||||||
supportingFiles.add(new SupportingFile("object.mustache", sourceFolder + MODEL_DIR, PREFIX + "Object.h"));
|
supportingFiles.add(new SupportingFile("object.mustache", sourceFolder + MODEL_DIR, PREFIX + "Object.h"));
|
||||||
supportingFiles.add(new SupportingFile("enum.mustache", sourceFolder + MODEL_DIR, PREFIX + "Enum.h"));
|
supportingFiles.add(new SupportingFile("enum.mustache", sourceFolder + MODEL_DIR, PREFIX + "Enum.h"));
|
||||||
|
supportingFiles.add(new SupportingFile("HttpFileElement.h.mustache", sourceFolder + MODEL_DIR, PREFIX + "HttpFileElement.h"));
|
||||||
|
supportingFiles.add(new SupportingFile("HttpFileElement.cpp.mustache", sourceFolder + MODEL_DIR, PREFIX + "HttpFileElement.cpp"));
|
||||||
supportingFiles.add(new SupportingFile("apirouter.h.mustache", sourceFolder + APIHANDLER_DIR, PREFIX + "ApiRouter.h"));
|
supportingFiles.add(new SupportingFile("apirouter.h.mustache", sourceFolder + APIHANDLER_DIR, PREFIX + "ApiRouter.h"));
|
||||||
supportingFiles.add(new SupportingFile("apirouter.cpp.mustache", sourceFolder + APIHANDLER_DIR, PREFIX + "ApiRouter.cpp"));
|
supportingFiles.add(new SupportingFile("apirouter.cpp.mustache", sourceFolder + APIHANDLER_DIR, PREFIX + "ApiRouter.cpp"));
|
||||||
|
|
||||||
@ -102,6 +104,8 @@ public class CppQt5QHttpEngineServerCodegen extends CppQt5AbstractCodegen implem
|
|||||||
supportingFiles.add(new SupportingFile("CMakeLists.txt.mustache", sourceFolder, "CMakeLists.txt"));
|
supportingFiles.add(new SupportingFile("CMakeLists.txt.mustache", sourceFolder, "CMakeLists.txt"));
|
||||||
supportingFiles.add(new SupportingFile("Dockerfile.mustache", sourceFolder, "Dockerfile"));
|
supportingFiles.add(new SupportingFile("Dockerfile.mustache", sourceFolder, "Dockerfile"));
|
||||||
supportingFiles.add(new SupportingFile("LICENSE.txt.mustache", sourceFolder, "LICENSE.txt"));
|
supportingFiles.add(new SupportingFile("LICENSE.txt.mustache", sourceFolder, "LICENSE.txt"));
|
||||||
|
typeMapping.put("file", PREFIX + "HttpFileElement");
|
||||||
|
importMapping.put(PREFIX + "HttpFileElement", "#include \"" + PREFIX + "HttpFileElement.h\"");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -115,9 +119,12 @@ public class CppQt5QHttpEngineServerCodegen extends CppQt5AbstractCodegen implem
|
|||||||
supportingFiles.add(new SupportingFile("helpers-body.mustache", sourceFolder + MODEL_DIR, modelNamePrefix + "Helpers.cpp"));
|
supportingFiles.add(new SupportingFile("helpers-body.mustache", sourceFolder + MODEL_DIR, modelNamePrefix + "Helpers.cpp"));
|
||||||
supportingFiles.add(new SupportingFile("object.mustache", sourceFolder + MODEL_DIR, modelNamePrefix + "Object.h"));
|
supportingFiles.add(new SupportingFile("object.mustache", sourceFolder + MODEL_DIR, modelNamePrefix + "Object.h"));
|
||||||
supportingFiles.add(new SupportingFile("enum.mustache", sourceFolder + MODEL_DIR, modelNamePrefix + "Enum.h"));
|
supportingFiles.add(new SupportingFile("enum.mustache", sourceFolder + MODEL_DIR, modelNamePrefix + "Enum.h"));
|
||||||
|
supportingFiles.add(new SupportingFile("HttpFileElement.h.mustache", sourceFolder + MODEL_DIR, modelNamePrefix + "HttpFileElement.h"));
|
||||||
|
supportingFiles.add(new SupportingFile("HttpFileElement.cpp.mustache", sourceFolder + MODEL_DIR, modelNamePrefix + "HttpFileElement.cpp"));
|
||||||
supportingFiles.add(new SupportingFile("apirouter.h.mustache", sourceFolder + APIHANDLER_DIR, modelNamePrefix + "ApiRouter.h"));
|
supportingFiles.add(new SupportingFile("apirouter.h.mustache", sourceFolder + APIHANDLER_DIR, modelNamePrefix + "ApiRouter.h"));
|
||||||
supportingFiles.add(new SupportingFile("apirouter.cpp.mustache", sourceFolder + APIHANDLER_DIR, modelNamePrefix + "ApiRouter.cpp"));
|
supportingFiles.add(new SupportingFile("apirouter.cpp.mustache", sourceFolder + APIHANDLER_DIR, modelNamePrefix + "ApiRouter.cpp"));
|
||||||
|
|
||||||
|
|
||||||
supportingFiles.add(new SupportingFile("main.cpp.mustache", sourceFolder + SRC_DIR, "main.cpp"));
|
supportingFiles.add(new SupportingFile("main.cpp.mustache", sourceFolder + SRC_DIR, "main.cpp"));
|
||||||
supportingFiles.add(new SupportingFile("src-CMakeLists.txt.mustache", sourceFolder + SRC_DIR, "CMakeLists.txt"));
|
supportingFiles.add(new SupportingFile("src-CMakeLists.txt.mustache", sourceFolder + SRC_DIR, "CMakeLists.txt"));
|
||||||
supportingFiles.add(new SupportingFile("README.md.mustache", sourceFolder, "README.MD"));
|
supportingFiles.add(new SupportingFile("README.md.mustache", sourceFolder, "README.MD"));
|
||||||
@ -125,6 +132,8 @@ public class CppQt5QHttpEngineServerCodegen extends CppQt5AbstractCodegen implem
|
|||||||
supportingFiles.add(new SupportingFile("CMakeLists.txt.mustache", sourceFolder, "CMakeLists.txt"));
|
supportingFiles.add(new SupportingFile("CMakeLists.txt.mustache", sourceFolder, "CMakeLists.txt"));
|
||||||
supportingFiles.add(new SupportingFile("Dockerfile.mustache", sourceFolder, "Dockerfile"));
|
supportingFiles.add(new SupportingFile("Dockerfile.mustache", sourceFolder, "Dockerfile"));
|
||||||
supportingFiles.add(new SupportingFile("LICENSE.txt.mustache", sourceFolder, "LICENSE.txt"));
|
supportingFiles.add(new SupportingFile("LICENSE.txt.mustache", sourceFolder, "LICENSE.txt"));
|
||||||
|
typeMapping.put("file", modelNamePrefix + "HttpFileElement");
|
||||||
|
importMapping.put(modelNamePrefix + "HttpFileElement", "#include \"" + modelNamePrefix + "HttpFileElement.h\"");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -160,7 +169,7 @@ public class CppQt5QHttpEngineServerCodegen extends CppQt5AbstractCodegen implem
|
|||||||
public String getHelp() {
|
public String getHelp() {
|
||||||
return "Generates a Qt5 C++ Server using the QHTTPEngine HTTP Library.";
|
return "Generates a Qt5 C++ Server using the QHTTPEngine HTTP Library.";
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Location to write model files. You can use the modelPackage() as defined when the class is
|
* Location to write model files. You can use the modelPackage() as defined when the class is
|
||||||
* instantiated
|
* instantiated
|
||||||
@ -182,7 +191,7 @@ public class CppQt5QHttpEngineServerCodegen extends CppQt5AbstractCodegen implem
|
|||||||
private String requestFileFolder() {
|
private String requestFileFolder() {
|
||||||
return outputFolder + "/" + sourceFolder + APIREQUEST_DIR + "/" + apiPackage().replace("::", File.separator);
|
return outputFolder + "/" + sourceFolder + APIREQUEST_DIR + "/" + apiPackage().replace("::", File.separator);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String apiFilename(String templateName, String tag) {
|
public String apiFilename(String templateName, String tag) {
|
||||||
String result = super.apiFilename(templateName, tag);
|
String result = super.apiFilename(templateName, tag);
|
||||||
@ -193,7 +202,7 @@ public class CppQt5QHttpEngineServerCodegen extends CppQt5AbstractCodegen implem
|
|||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toApiFilename(String name) {
|
public String toApiFilename(String name) {
|
||||||
return modelNamePrefix + sanitizeName(camelize(name)) + "ApiHandler";
|
return modelNamePrefix + sanitizeName(camelize(name)) + "ApiHandler";
|
||||||
|
@ -242,7 +242,7 @@ public class CppRestSdkClientCodegen extends AbstractCppCodegen {
|
|||||||
if (response != null) {
|
if (response != null) {
|
||||||
CodegenProperty cm = fromProperty("response", response);
|
CodegenProperty cm = fromProperty("response", response);
|
||||||
op.vendorExtensions.put("x-codegen-response", cm);
|
op.vendorExtensions.put("x-codegen-response", cm);
|
||||||
if ("HttpContent".equals(cm.dataType)) {
|
if ("std::shared_ptr<HttpContent>".equals(cm.dataType)) {
|
||||||
op.vendorExtensions.put("x-codegen-response-ishttpcontent", true);
|
op.vendorExtensions.put("x-codegen-response-ishttpcontent", true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -62,7 +62,7 @@ public class DartClientCodegen extends DefaultCodegen implements CodegenConfig {
|
|||||||
outputFolder = "generated-code/dart";
|
outputFolder = "generated-code/dart";
|
||||||
modelTemplateFiles.put("model.mustache", ".dart");
|
modelTemplateFiles.put("model.mustache", ".dart");
|
||||||
apiTemplateFiles.put("api.mustache", ".dart");
|
apiTemplateFiles.put("api.mustache", ".dart");
|
||||||
embeddedTemplateDir = templateDir = "dart";
|
embeddedTemplateDir = templateDir = "dart2";
|
||||||
apiPackage = "lib.api";
|
apiPackage = "lib.api";
|
||||||
modelPackage = "lib.model";
|
modelPackage = "lib.model";
|
||||||
modelDocTemplateFiles.put("object_doc.mustache", ".md");
|
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(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(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(new CliOption(CodegenConstants.SOURCE_FOLDER, "Source folder for generated code"));
|
||||||
cliOptions.add(CliOption.newBoolean(SUPPORT_DART2, "Support Dart 2.x").defaultValue(Boolean.TRUE.toString()));
|
cliOptions.add(CliOption.newBoolean(SUPPORT_DART2, "Support Dart 2.x (Dart 1.x support has been deprecated)").defaultValue(Boolean.TRUE.toString()));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -139,7 +139,7 @@ public class DartClientCodegen extends DefaultCodegen implements CodegenConfig {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getHelp() {
|
public String getHelp() {
|
||||||
return "Generates a Dart (1.x or 2.x) client library.";
|
return "Generates a Dart (1.x (deprecated) or 2.x) client library.";
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -202,7 +202,10 @@ public class DartClientCodegen extends DefaultCodegen implements CodegenConfig {
|
|||||||
} else {
|
} else {
|
||||||
// dart 2.x
|
// dart 2.x
|
||||||
LOGGER.info("Dart version: 2.x");
|
LOGGER.info("Dart version: 2.x");
|
||||||
embeddedTemplateDir = templateDir = "dart2";
|
// check to not overwrite a custom templateDir
|
||||||
|
if (templateDir == null) {
|
||||||
|
embeddedTemplateDir = templateDir = "dart2";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
final String libFolder = sourceFolder + File.separator + "lib";
|
final String libFolder = sourceFolder + File.separator + "lib";
|
||||||
|
@ -45,7 +45,7 @@ public class DartJaguarClientCodegen extends DartClientCodegen {
|
|||||||
modelToIgnore.add("object");
|
modelToIgnore.add("object");
|
||||||
modelToIgnore.add("list");
|
modelToIgnore.add("list");
|
||||||
modelToIgnore.add("file");
|
modelToIgnore.add("file");
|
||||||
modelToIgnore.add("uint8list");
|
modelToIgnore.add("list<int>");
|
||||||
}
|
}
|
||||||
|
|
||||||
private static final String SERIALIZATION_JSON = "json";
|
private static final String SERIALIZATION_JSON = "json";
|
||||||
@ -63,8 +63,8 @@ public class DartJaguarClientCodegen extends DartClientCodegen {
|
|||||||
cliOptions.add(new CliOption(NULLABLE_FIELDS, "Is the null fields should be in the JSON payload"));
|
cliOptions.add(new CliOption(NULLABLE_FIELDS, "Is the null fields should be in the JSON payload"));
|
||||||
cliOptions.add(new CliOption(SERIALIZATION_FORMAT, "Choose serialization format JSON or PROTO is supported"));
|
cliOptions.add(new CliOption(SERIALIZATION_FORMAT, "Choose serialization format JSON or PROTO is supported"));
|
||||||
|
|
||||||
typeMapping.put("file", "Uint8List");
|
typeMapping.put("file", "List<int>");
|
||||||
typeMapping.put("binary", "Uint8List");
|
typeMapping.put("binary", "List<int>");
|
||||||
|
|
||||||
protoTypeMapping.put("Array", "repeated");
|
protoTypeMapping.put("Array", "repeated");
|
||||||
protoTypeMapping.put("array", "repeated");
|
protoTypeMapping.put("array", "repeated");
|
||||||
@ -247,19 +247,19 @@ public class DartJaguarClientCodegen extends DartClientCodegen {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for (CodegenParameter param : op.allParams) {
|
for (CodegenParameter param : op.allParams) {
|
||||||
if (param.baseType != null && param.baseType.equalsIgnoreCase("Uint8List") && isMultipart) {
|
if (param.baseType != null && param.baseType.equalsIgnoreCase("List<int>") && isMultipart) {
|
||||||
param.baseType = "MultipartFile";
|
param.baseType = "MultipartFile";
|
||||||
param.dataType = "MultipartFile";
|
param.dataType = "MultipartFile";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (CodegenParameter param : op.formParams) {
|
for (CodegenParameter param : op.formParams) {
|
||||||
if (param.baseType != null && param.baseType.equalsIgnoreCase("Uint8List") && isMultipart) {
|
if (param.baseType != null && param.baseType.equalsIgnoreCase("List<int>") && isMultipart) {
|
||||||
param.baseType = "MultipartFile";
|
param.baseType = "MultipartFile";
|
||||||
param.dataType = "MultipartFile";
|
param.dataType = "MultipartFile";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (CodegenParameter param : op.bodyParams) {
|
for (CodegenParameter param : op.bodyParams) {
|
||||||
if (param.baseType != null && param.baseType.equalsIgnoreCase("Uint8List") && isMultipart) {
|
if (param.baseType != null && param.baseType.equalsIgnoreCase("List<int>") && isMultipart) {
|
||||||
param.baseType = "MultipartFile";
|
param.baseType = "MultipartFile";
|
||||||
param.dataType = "MultipartFile";
|
param.dataType = "MultipartFile";
|
||||||
}
|
}
|
||||||
@ -274,8 +274,6 @@ public class DartJaguarClientCodegen extends DartClientCodegen {
|
|||||||
for (String item : op.imports) {
|
for (String item : op.imports) {
|
||||||
if (!modelToIgnore.contains(item.toLowerCase(Locale.ROOT))) {
|
if (!modelToIgnore.contains(item.toLowerCase(Locale.ROOT))) {
|
||||||
imports.add(underscore(item));
|
imports.add(underscore(item));
|
||||||
} else if (item.equalsIgnoreCase("Uint8List")) {
|
|
||||||
fullImports.add("dart:typed_data");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
modelImports.addAll(imports);
|
modelImports.addAll(imports);
|
||||||
|
@ -78,7 +78,6 @@ public class JavaClientCodegen extends AbstractJavaCodegen
|
|||||||
public static final String RETROFIT_2 = "retrofit2";
|
public static final String RETROFIT_2 = "retrofit2";
|
||||||
public static final String VERTX = "vertx";
|
public static final String VERTX = "vertx";
|
||||||
|
|
||||||
public static final String SERIALIZATION_LIBRARY = "serializationLibrary";
|
|
||||||
public static final String SERIALIZATION_LIBRARY_GSON = "gson";
|
public static final String SERIALIZATION_LIBRARY_GSON = "gson";
|
||||||
public static final String SERIALIZATION_LIBRARY_JACKSON = "jackson";
|
public static final String SERIALIZATION_LIBRARY_JACKSON = "jackson";
|
||||||
|
|
||||||
@ -101,7 +100,6 @@ public class JavaClientCodegen extends AbstractJavaCodegen
|
|||||||
protected String authFolder;
|
protected String authFolder;
|
||||||
protected String serializationLibrary = null;
|
protected String serializationLibrary = null;
|
||||||
|
|
||||||
|
|
||||||
public JavaClientCodegen() {
|
public JavaClientCodegen() {
|
||||||
super();
|
super();
|
||||||
|
|
||||||
@ -134,18 +132,18 @@ public class JavaClientCodegen extends AbstractJavaCodegen
|
|||||||
cliOptions.add(CliOption.newBoolean(USE_REFLECTION_EQUALS_HASHCODE, "Use org.apache.commons.lang3.builder for equals and hashCode in the models. WARNING: This will fail under a security manager, unless the appropriate permissions are set up correctly and also there's potential performance impact."));
|
cliOptions.add(CliOption.newBoolean(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"));
|
cliOptions.add(CliOption.newBoolean(CASE_INSENSITIVE_RESPONSE_HEADERS, "Make API response's headers case-insensitive. Available on " + OKHTTP_GSON + ", " + JERSEY2 + " libraries"));
|
||||||
|
|
||||||
supportedLibraries.put(JERSEY1, "HTTP client: Jersey client 1.19.x. JSON processing: Jackson 2.8.x. Enable Java6 support using '-DsupportJava6=true'. Enable gzip request encoding using '-DuseGzipFeature=true'. IMPORTANT NOTE: jersey 1.x is no longer actively maintained so please upgrade to 'jersey2' or other HTTP libaries instead.");
|
supportedLibraries.put(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.8.x");
|
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.8.x. To enable OpenFeign 10.x, set the 'feignVersion' option to '10.x'");
|
supportedLibraries.put(FEIGN, "HTTP client: OpenFeign 9.x or 10.x. JSON processing: Jackson 2.9.x. To enable OpenFeign 10.x, set the 'feignVersion' option to '10.x'");
|
||||||
supportedLibraries.put(OKHTTP_GSON, "[DEFAULT] HTTP client: OkHttp 3.x. JSON processing: Gson 2.8.x. Enable Parcelable models on Android using '-DparcelableModel=true'. Enable gzip request encoding using '-DuseGzipFeature=true'.");
|
supportedLibraries.put(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_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(RETROFIT_2, "HTTP client: OkHttp 3.x. JSON processing: Gson 2.x (Retrofit 2.3.0). Enable the RxJava adapter using '-DuseRxJava[2]=true'. (RxJava 1.x or 2.x)");
|
||||||
supportedLibraries.put(RESTTEMPLATE, "HTTP client: Spring RestTemplate 4.x. JSON processing: Jackson 2.8.x");
|
supportedLibraries.put(RESTTEMPLATE, "HTTP client: Spring RestTemplate 4.x. JSON processing: Jackson 2.9.x");
|
||||||
supportedLibraries.put(WEBCLIENT, "HTTP client: Spring WebClient 5.x. JSON processing: Jackson 2.9.x");
|
supportedLibraries.put(WEBCLIENT, "HTTP client: Spring WebClient 5.x. JSON processing: Jackson 2.9.x");
|
||||||
supportedLibraries.put(RESTEASY, "HTTP client: Resteasy client 3.x. JSON processing: Jackson 2.8.x");
|
supportedLibraries.put(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.8.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.8.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. Only for Java8");
|
supportedLibraries.put(REST_ASSURED, "HTTP client: rest-assured : 4.x. JSON processing: Gson 2.x or Jackson 2.9.x. Only for Java8");
|
||||||
supportedLibraries.put(NATIVE, "HTTP client: Java native HttpClient. JSON processing: Jackson 2.9.x. Only for Java11+");
|
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");
|
CliOption libraryOption = new CliOption(CodegenConstants.LIBRARY, "library template (sub-template) to use");
|
||||||
@ -155,7 +153,7 @@ public class JavaClientCodegen extends AbstractJavaCodegen
|
|||||||
cliOptions.add(libraryOption);
|
cliOptions.add(libraryOption);
|
||||||
setLibrary(OKHTTP_GSON);
|
setLibrary(OKHTTP_GSON);
|
||||||
|
|
||||||
CliOption serializationLibrary = new CliOption(SERIALIZATION_LIBRARY, "Serialization library, default depends from the library");
|
CliOption serializationLibrary = new CliOption(CodegenConstants.SERIALIZATION_LIBRARY, "Serialization library, default depends from the library");
|
||||||
Map<String, String> serializationOptions = new HashMap<>();
|
Map<String, String> serializationOptions = new HashMap<>();
|
||||||
serializationOptions.put(SERIALIZATION_LIBRARY_GSON, "Use Gson as serialization library");
|
serializationOptions.put(SERIALIZATION_LIBRARY_GSON, "Use Gson as serialization library");
|
||||||
serializationOptions.put(SERIALIZATION_LIBRARY_JACKSON, "Use Jackson as serialization library");
|
serializationOptions.put(SERIALIZATION_LIBRARY_JACKSON, "Use Jackson as serialization library");
|
||||||
@ -295,8 +293,8 @@ public class JavaClientCodegen extends AbstractJavaCodegen
|
|||||||
"BeanValidationException.java"));
|
"BeanValidationException.java"));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (additionalProperties.containsKey(SERIALIZATION_LIBRARY)) {
|
if (additionalProperties.containsKey(CodegenConstants.SERIALIZATION_LIBRARY)) {
|
||||||
setSerializationLibrary(additionalProperties.get(SERIALIZATION_LIBRARY).toString());
|
setSerializationLibrary(additionalProperties.get(CodegenConstants.SERIALIZATION_LIBRARY).toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
//TODO: add doc to retrofit1 and feign
|
//TODO: add doc to retrofit1 and feign
|
||||||
@ -372,12 +370,19 @@ public class JavaClientCodegen extends AbstractJavaCodegen
|
|||||||
forceSerializationLibrary(SERIALIZATION_LIBRARY_JACKSON);
|
forceSerializationLibrary(SERIALIZATION_LIBRARY_JACKSON);
|
||||||
|
|
||||||
} else if (REST_ASSURED.equals(getLibrary())) {
|
} else if (REST_ASSURED.equals(getLibrary())) {
|
||||||
forceSerializationLibrary(SERIALIZATION_LIBRARY_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())) {
|
||||||
|
supportingFiles.add(new SupportingFile("JacksonObjectMapper.mustache", invokerFolder, "JacksonObjectMapper.java"));
|
||||||
|
} else if (SERIALIZATION_LIBRARY_GSON.equals(getSerializationLibrary())) {
|
||||||
|
supportingFiles.add(new SupportingFile("JSON.mustache", invokerFolder, "JSON.java"));
|
||||||
|
supportingFiles.add(new SupportingFile("GsonObjectMapper.mustache", invokerFolder, "GsonObjectMapper.java"));
|
||||||
|
}
|
||||||
additionalProperties.put("convert", new CaseFormatLambda(LOWER_CAMEL, UPPER_UNDERSCORE));
|
additionalProperties.put("convert", new CaseFormatLambda(LOWER_CAMEL, UPPER_UNDERSCORE));
|
||||||
apiTemplateFiles.put("api.mustache", ".java");
|
apiTemplateFiles.put("api.mustache", ".java");
|
||||||
supportingFiles.add(new SupportingFile("ResponseSpecBuilders.mustache", invokerFolder, "ResponseSpecBuilders.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 {
|
} else {
|
||||||
LOGGER.error("Unknown library option (-l/--library): " + getLibrary());
|
LOGGER.error("Unknown library option (-l/--library): " + getLibrary());
|
||||||
}
|
}
|
||||||
|
@ -239,6 +239,9 @@ public class JavaJAXRSSpecServerCodegen extends AbstractJavaJAXRSServerCodegen {
|
|||||||
public String toApiName(final String name) {
|
public String toApiName(final String name) {
|
||||||
String computed = name;
|
String computed = name;
|
||||||
if (computed.length() == 0) {
|
if (computed.length() == 0) {
|
||||||
|
if (primaryResourceName == null) {
|
||||||
|
return "DefaultApi";
|
||||||
|
}
|
||||||
return primaryResourceName + "Api";
|
return primaryResourceName + "Api";
|
||||||
}
|
}
|
||||||
computed = sanitizeName(computed);
|
computed = sanitizeName(computed);
|
||||||
|
@ -19,21 +19,42 @@ package org.openapitools.codegen.languages;
|
|||||||
|
|
||||||
import org.openapitools.codegen.CliOption;
|
import org.openapitools.codegen.CliOption;
|
||||||
import org.openapitools.codegen.CodegenConstants;
|
import org.openapitools.codegen.CodegenConstants;
|
||||||
|
import org.openapitools.codegen.CodegenModel;
|
||||||
|
import org.openapitools.codegen.CodegenOperation;
|
||||||
|
import org.openapitools.codegen.CodegenProperty;
|
||||||
import org.openapitools.codegen.CodegenType;
|
import org.openapitools.codegen.CodegenType;
|
||||||
import org.openapitools.codegen.SupportingFile;
|
import org.openapitools.codegen.SupportingFile;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
import java.util.HashSet;
|
||||||
|
import java.util.Iterator;
|
||||||
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.Set;
|
||||||
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
public class KotlinClientCodegen extends AbstractKotlinCodegen {
|
public class KotlinClientCodegen extends AbstractKotlinCodegen {
|
||||||
|
|
||||||
|
protected static final String VENDOR_EXTENSION_ESCAPED_NAME = "x-escapedName";
|
||||||
|
|
||||||
|
protected static final String JVM = "jvm";
|
||||||
|
protected static final String MULTIPLATFORM = "multiplatform";
|
||||||
|
|
||||||
public static final String DATE_LIBRARY = "dateLibrary";
|
public static final String DATE_LIBRARY = "dateLibrary";
|
||||||
public static final String COLLECTION_TYPE = "collectionType";
|
public static final String COLLECTION_TYPE = "collectionType";
|
||||||
|
|
||||||
protected String dateLibrary = DateLibrary.JAVA8.value;
|
protected String dateLibrary = DateLibrary.JAVA8.value;
|
||||||
protected String collectionType = CollectionType.ARRAY.value;
|
protected String collectionType = CollectionType.ARRAY.value;
|
||||||
|
|
||||||
|
// https://kotlinlang.org/docs/reference/grammar.html#Identifier
|
||||||
|
protected static final Pattern IDENTIFIER_PATTERN =
|
||||||
|
Pattern.compile("[\\p{Ll}\\p{Lm}\\p{Lo}\\p{Lt}\\p{Lu}\\p{Nl}_][\\p{Ll}\\p{Lm}\\p{Lo}\\p{Lt}\\p{Lu}\\p{Nl}\\p{Nd}_]*");
|
||||||
|
|
||||||
|
// https://kotlinlang.org/docs/reference/grammar.html#Identifier
|
||||||
|
protected static final String IDENTIFIER_REPLACEMENTS =
|
||||||
|
"[.;:/\\[\\]<>]";
|
||||||
|
|
||||||
public enum DateLibrary {
|
public enum DateLibrary {
|
||||||
STRING("string"),
|
STRING("string"),
|
||||||
THREETENBP("threetenbp"),
|
THREETENBP("threetenbp"),
|
||||||
@ -81,9 +102,9 @@ public class KotlinClientCodegen extends AbstractKotlinCodegen {
|
|||||||
|
|
||||||
CliOption dateLibrary = new CliOption(DATE_LIBRARY, "Option. Date library to use");
|
CliOption dateLibrary = new CliOption(DATE_LIBRARY, "Option. Date library to use");
|
||||||
Map<String, String> dateOptions = new HashMap<>();
|
Map<String, String> dateOptions = new HashMap<>();
|
||||||
dateOptions.put(DateLibrary.THREETENBP.value, "Threetenbp");
|
dateOptions.put(DateLibrary.THREETENBP.value, "Threetenbp (jvm only)");
|
||||||
dateOptions.put(DateLibrary.STRING.value, "String");
|
dateOptions.put(DateLibrary.STRING.value, "String");
|
||||||
dateOptions.put(DateLibrary.JAVA8.value, "Java 8 native JSR310");
|
dateOptions.put(DateLibrary.JAVA8.value, "Java 8 native JSR310 (jvm only)");
|
||||||
dateLibrary.setEnum(dateOptions);
|
dateLibrary.setEnum(dateOptions);
|
||||||
dateLibrary.setDefault(this.dateLibrary);
|
dateLibrary.setDefault(this.dateLibrary);
|
||||||
cliOptions.add(dateLibrary);
|
cliOptions.add(dateLibrary);
|
||||||
@ -95,6 +116,15 @@ public class KotlinClientCodegen extends AbstractKotlinCodegen {
|
|||||||
collectionType.setEnum(collectionOptions);
|
collectionType.setEnum(collectionOptions);
|
||||||
collectionType.setDefault(this.collectionType);
|
collectionType.setDefault(this.collectionType);
|
||||||
cliOptions.add(collectionType);
|
cliOptions.add(collectionType);
|
||||||
|
|
||||||
|
supportedLibraries.put(JVM, "Platform: Java Virtual Machine. HTTP client: OkHttp 2.7.5. JSON processing: Gson 2.8.1.");
|
||||||
|
supportedLibraries.put(MULTIPLATFORM, "Platform: Kotlin multiplatform. HTTP client: Ktor 1.2.4. JSON processing: Kotlinx Serialization: 0.12.0.");
|
||||||
|
|
||||||
|
CliOption libraryOption = new CliOption(CodegenConstants.LIBRARY, "Library template (sub-template) to use");
|
||||||
|
libraryOption.setEnum(supportedLibraries);
|
||||||
|
libraryOption.setDefault(JVM);
|
||||||
|
cliOptions.add(libraryOption);
|
||||||
|
setLibrary(JVM);
|
||||||
}
|
}
|
||||||
|
|
||||||
public CodegenType getTag() {
|
public CodegenType getTag() {
|
||||||
@ -121,10 +151,80 @@ public class KotlinClientCodegen extends AbstractKotlinCodegen {
|
|||||||
public void processOpts() {
|
public void processOpts() {
|
||||||
super.processOpts();
|
super.processOpts();
|
||||||
|
|
||||||
|
if (MULTIPLATFORM.equals(getLibrary())) {
|
||||||
|
sourceFolder = "src/commonMain/kotlin";
|
||||||
|
}
|
||||||
|
|
||||||
|
// infrastructure destination folder
|
||||||
|
final String infrastructureFolder = (sourceFolder + File.separator + packageName + File.separator + "infrastructure").replace(".", "/");
|
||||||
|
|
||||||
|
// additional properties
|
||||||
if (additionalProperties.containsKey(DATE_LIBRARY)) {
|
if (additionalProperties.containsKey(DATE_LIBRARY)) {
|
||||||
setDateLibrary(additionalProperties.get(DATE_LIBRARY).toString());
|
setDateLibrary(additionalProperties.get(DATE_LIBRARY).toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// common (jvm/multiplatform) supporting files
|
||||||
|
supportingFiles.add(new SupportingFile("README.mustache", "", "README.md"));
|
||||||
|
supportingFiles.add(new SupportingFile("build.gradle.mustache", "", "build.gradle"));
|
||||||
|
supportingFiles.add(new SupportingFile("settings.gradle.mustache", "", "settings.gradle"));
|
||||||
|
supportingFiles.add(new SupportingFile("infrastructure/ApiClient.kt.mustache", infrastructureFolder, "ApiClient.kt"));
|
||||||
|
supportingFiles.add(new SupportingFile("infrastructure/ApiAbstractions.kt.mustache", infrastructureFolder, "ApiAbstractions.kt"));
|
||||||
|
supportingFiles.add(new SupportingFile("infrastructure/RequestConfig.kt.mustache", infrastructureFolder, "RequestConfig.kt"));
|
||||||
|
supportingFiles.add(new SupportingFile("infrastructure/RequestMethod.kt.mustache", infrastructureFolder, "RequestMethod.kt"));
|
||||||
|
|
||||||
|
if (JVM.equals(getLibrary())) {
|
||||||
|
additionalProperties.put(JVM, true);
|
||||||
|
|
||||||
|
// jvm specific supporting files
|
||||||
|
supportingFiles.add(new SupportingFile("infrastructure/ApplicationDelegates.kt.mustache", infrastructureFolder, "ApplicationDelegates.kt"));
|
||||||
|
supportingFiles.add(new SupportingFile("infrastructure/Errors.kt.mustache", infrastructureFolder, "Errors.kt"));
|
||||||
|
supportingFiles.add(new SupportingFile("infrastructure/ResponseExtensions.kt.mustache", infrastructureFolder, "ResponseExtensions.kt"));
|
||||||
|
supportingFiles.add(new SupportingFile("infrastructure/Serializer.kt.mustache", infrastructureFolder, "Serializer.kt"));
|
||||||
|
supportingFiles.add(new SupportingFile("infrastructure/ApiInfrastructureResponse.kt.mustache", infrastructureFolder, "ApiInfrastructureResponse.kt"));
|
||||||
|
supportingFiles.add(new SupportingFile("infrastructure/ByteArrayAdapter.kt.mustache", infrastructureFolder, "ByteArrayAdapter.kt"));
|
||||||
|
supportingFiles.add(new SupportingFile("infrastructure/LocalDateAdapter.kt.mustache", infrastructureFolder, "LocalDateAdapter.kt"));
|
||||||
|
supportingFiles.add(new SupportingFile("infrastructure/LocalDateTimeAdapter.kt.mustache", infrastructureFolder, "LocalDateTimeAdapter.kt"));
|
||||||
|
supportingFiles.add(new SupportingFile("infrastructure/UUIDAdapter.kt.mustache", infrastructureFolder, "UUIDAdapter.kt"));
|
||||||
|
|
||||||
|
} else if (MULTIPLATFORM.equals(getLibrary())) {
|
||||||
|
additionalProperties.put(MULTIPLATFORM, true);
|
||||||
|
setDateLibrary(DateLibrary.STRING.value);
|
||||||
|
|
||||||
|
// multiplatform default includes
|
||||||
|
defaultIncludes.add("io.ktor.client.request.forms.InputProvider");
|
||||||
|
|
||||||
|
// multiplatform type mapping
|
||||||
|
typeMapping.put("number", "kotlin.Double");
|
||||||
|
typeMapping.put("file", "InputProvider");
|
||||||
|
|
||||||
|
// multiplatform import mapping
|
||||||
|
importMapping.put("BigDecimal", "kotlin.Double");
|
||||||
|
importMapping.put("UUID", "kotlin.String");
|
||||||
|
importMapping.put("URI", "kotlin.String");
|
||||||
|
importMapping.put("InputProvider", "io.ktor.client.request.forms.InputProvider");
|
||||||
|
importMapping.put("File", "io.ktor.client.request.forms.InputProvider");
|
||||||
|
importMapping.put("Timestamp", "kotlin.String");
|
||||||
|
importMapping.put("LocalDateTime", "kotlin.String");
|
||||||
|
importMapping.put("LocalDate", "kotlin.String");
|
||||||
|
importMapping.put("LocalTime", "kotlin.String");
|
||||||
|
|
||||||
|
// multiplatform specific supporting files
|
||||||
|
supportingFiles.add(new SupportingFile("infrastructure/HttpResponse.kt.mustache", infrastructureFolder, "HttpResponse.kt"));
|
||||||
|
|
||||||
|
// multiplatform specific testing files
|
||||||
|
final String testFolder = (sourceFolder + File.separator + packageName + File.separator + "infrastructure").replace(".", "/");
|
||||||
|
supportingFiles.add(new SupportingFile("commonTest/coroutine.mustache", "src/commonTest/kotlin/util", "Coroutine.kt"));
|
||||||
|
supportingFiles.add(new SupportingFile("iosTest/coroutine.mustache", "src/iosTest/kotlin/util", "Coroutine.kt"));
|
||||||
|
supportingFiles.add(new SupportingFile("jvmTest/coroutine.mustache", "src/jvmTest/kotlin/util", "Coroutine.kt"));
|
||||||
|
|
||||||
|
// gradle wrapper supporting files
|
||||||
|
supportingFiles.add(new SupportingFile("gradlew.mustache", "", "gradlew"));
|
||||||
|
supportingFiles.add(new SupportingFile("gradlew.bat.mustache", "", "gradlew.bat"));
|
||||||
|
supportingFiles.add(new SupportingFile("gradle-wrapper.properties.mustache", "gradle.wrapper".replace(".", File.separator), "gradle-wrapper.properties"));
|
||||||
|
supportingFiles.add(new SupportingFile("gradle-wrapper.jar", "gradle.wrapper".replace(".", File.separator), "gradle-wrapper.jar"));
|
||||||
|
}
|
||||||
|
|
||||||
|
// date library processing
|
||||||
if (DateLibrary.THREETENBP.value.equals(dateLibrary)) {
|
if (DateLibrary.THREETENBP.value.equals(dateLibrary)) {
|
||||||
additionalProperties.put(DateLibrary.THREETENBP.value, true);
|
additionalProperties.put(DateLibrary.THREETENBP.value, true);
|
||||||
typeMapping.put("date", "LocalDate");
|
typeMapping.put("date", "LocalDate");
|
||||||
@ -151,25 +251,83 @@ public class KotlinClientCodegen extends AbstractKotlinCodegen {
|
|||||||
typeMapping.put("list", "kotlin.collections.List");
|
typeMapping.put("list", "kotlin.collections.List");
|
||||||
additionalProperties.put("isList", true);
|
additionalProperties.put("isList", true);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
supportingFiles.add(new SupportingFile("README.mustache", "", "README.md"));
|
@Override
|
||||||
supportingFiles.add(new SupportingFile("build.gradle.mustache", "", "build.gradle"));
|
public Map<String, Object> postProcessModels(Map<String, Object> objs) {
|
||||||
supportingFiles.add(new SupportingFile("settings.gradle.mustache", "", "settings.gradle"));
|
objs = super.postProcessModels(objs);
|
||||||
|
return postProcessModelsEscapeNames(objs);
|
||||||
|
}
|
||||||
|
|
||||||
final String infrastructureFolder = (sourceFolder + File.separator + packageName + File.separator + "infrastructure").replace(".", "/");
|
@SuppressWarnings("unchecked")
|
||||||
|
private static Map<String, Object> postProcessModelsEscapeNames(Map<String, Object> objs) {
|
||||||
|
List<Object> models = (List<Object>) objs.get("models");
|
||||||
|
for (Object _mo : models) {
|
||||||
|
Map<String, Object> mo = (Map<String, Object>) _mo;
|
||||||
|
CodegenModel cm = (CodegenModel) mo.get("model");
|
||||||
|
|
||||||
supportingFiles.add(new SupportingFile("infrastructure/ApiClient.kt.mustache", infrastructureFolder, "ApiClient.kt"));
|
if (cm.vars != null) {
|
||||||
supportingFiles.add(new SupportingFile("infrastructure/ApiAbstractions.kt.mustache", infrastructureFolder, "ApiAbstractions.kt"));
|
for (CodegenProperty var : cm.vars) {
|
||||||
supportingFiles.add(new SupportingFile("infrastructure/ApiInfrastructureResponse.kt.mustache", infrastructureFolder, "ApiInfrastructureResponse.kt"));
|
var.vendorExtensions.put(VENDOR_EXTENSION_ESCAPED_NAME, escapeIdentifier(var.name));
|
||||||
supportingFiles.add(new SupportingFile("infrastructure/ApplicationDelegates.kt.mustache", infrastructureFolder, "ApplicationDelegates.kt"));
|
}
|
||||||
supportingFiles.add(new SupportingFile("infrastructure/RequestConfig.kt.mustache", infrastructureFolder, "RequestConfig.kt"));
|
}
|
||||||
supportingFiles.add(new SupportingFile("infrastructure/RequestMethod.kt.mustache", infrastructureFolder, "RequestMethod.kt"));
|
if (cm.requiredVars != null) {
|
||||||
supportingFiles.add(new SupportingFile("infrastructure/ResponseExtensions.kt.mustache", infrastructureFolder, "ResponseExtensions.kt"));
|
for (CodegenProperty var : cm.requiredVars) {
|
||||||
supportingFiles.add(new SupportingFile("infrastructure/Serializer.kt.mustache", infrastructureFolder, "Serializer.kt"));
|
var.vendorExtensions.put(VENDOR_EXTENSION_ESCAPED_NAME, escapeIdentifier(var.name));
|
||||||
supportingFiles.add(new SupportingFile("infrastructure/Errors.kt.mustache", infrastructureFolder, "Errors.kt"));
|
}
|
||||||
supportingFiles.add(new SupportingFile("infrastructure/ByteArrayAdapter.kt.mustache", infrastructureFolder, "ByteArrayAdapter.kt"));
|
}
|
||||||
supportingFiles.add(new SupportingFile("infrastructure/LocalDateAdapter.kt.mustache", infrastructureFolder, "LocalDateAdapter.kt"));
|
if (cm.optionalVars != null) {
|
||||||
supportingFiles.add(new SupportingFile("infrastructure/LocalDateTimeAdapter.kt.mustache", infrastructureFolder, "LocalDateTimeAdapter.kt"));
|
for (CodegenProperty var : cm.optionalVars) {
|
||||||
supportingFiles.add(new SupportingFile("infrastructure/UUIDAdapter.kt.mustache", infrastructureFolder, "UUIDAdapter.kt"));
|
var.vendorExtensions.put(VENDOR_EXTENSION_ESCAPED_NAME, escapeIdentifier(var.name));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return objs;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static String escapeIdentifier(String identifier) {
|
||||||
|
|
||||||
|
// the kotlin grammar permits a wider set of characters in their identifiers that all target
|
||||||
|
// platforms permit (namely jvm). in order to remain compatible with target platforms, we
|
||||||
|
// initially replace all illegal target characters before escaping the identifier if required.
|
||||||
|
identifier = identifier.replaceAll(IDENTIFIER_REPLACEMENTS, "_");
|
||||||
|
if (IDENTIFIER_PATTERN.matcher(identifier).matches()) return identifier;
|
||||||
|
return '`' + identifier + '`';
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void removeDuplicates(List<CodegenProperty> list) {
|
||||||
|
Set<String> set = new HashSet<>();
|
||||||
|
Iterator<CodegenProperty> iterator = list.iterator();
|
||||||
|
while (iterator.hasNext()) {
|
||||||
|
CodegenProperty item = iterator.next();
|
||||||
|
if (set.contains(item.name)) iterator.remove();
|
||||||
|
else set.add(item.name);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
|
public Map<String, Object> postProcessOperationsWithModels(Map<String, Object> objs, List<Object> allModels) {
|
||||||
|
super.postProcessOperationsWithModels(objs, allModels);
|
||||||
|
Map<String, Object> operations = (Map<String, Object>) objs.get("operations");
|
||||||
|
if (operations != null) {
|
||||||
|
List<CodegenOperation> ops = (List<CodegenOperation>) operations.get("operation");
|
||||||
|
for (CodegenOperation operation : ops) {
|
||||||
|
if (operation.hasConsumes == Boolean.TRUE) {
|
||||||
|
if (isMultipartType(operation.consumes)) {
|
||||||
|
operation.isMultipart = Boolean.TRUE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return operations;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static boolean isMultipartType(List<Map<String, String>> consumes) {
|
||||||
|
Map<String, String> firstType = consumes.get(0);
|
||||||
|
if (firstType != null) {
|
||||||
|
return "multipart/form-data".equals(firstType.get("mediaType"));
|
||||||
|
}
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,87 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2018 OpenAPI-Generator Contributors (https://openapi-generator.tech)
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package org.openapitools.codegen.languages;
|
||||||
|
|
||||||
|
import org.openapitools.codegen.CodegenConstants;
|
||||||
|
import org.openapitools.codegen.CodegenType;
|
||||||
|
import org.openapitools.codegen.SupportingFile;
|
||||||
|
import org.openapitools.codegen.meta.GeneratorMetadata;
|
||||||
|
import org.openapitools.codegen.meta.Stability;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.util.Locale;
|
||||||
|
|
||||||
|
public class KotlinVertxServerCodegen extends AbstractKotlinCodegen {
|
||||||
|
|
||||||
|
protected String rootPackage = "org.openapitools.server.api";
|
||||||
|
protected String apiVersion = "1.0.0-SNAPSHOT";
|
||||||
|
|
||||||
|
public static final String ROOT_PACKAGE = "rootPackage";
|
||||||
|
|
||||||
|
public static final String PROJECT_NAME = "projectName";
|
||||||
|
|
||||||
|
static Logger LOGGER = LoggerFactory.getLogger(KotlinVertxServerCodegen.class);
|
||||||
|
|
||||||
|
public CodegenType getTag() {
|
||||||
|
return CodegenType.SERVER;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getName() {
|
||||||
|
return "kotlin-vertx";
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getHelp() {
|
||||||
|
return "Generates a kotlin-vertx server.";
|
||||||
|
}
|
||||||
|
|
||||||
|
public KotlinVertxServerCodegen() {
|
||||||
|
super();
|
||||||
|
|
||||||
|
generatorMetadata = GeneratorMetadata.newBuilder(generatorMetadata)
|
||||||
|
.stability(Stability.BETA)
|
||||||
|
.build();
|
||||||
|
|
||||||
|
outputFolder = "generated-code" + File.separator + "kotlin-vertx";
|
||||||
|
modelTemplateFiles.put("model.mustache", ".kt");
|
||||||
|
|
||||||
|
apiTestTemplateFiles.clear();
|
||||||
|
modelDocTemplateFiles.clear();
|
||||||
|
supportingFiles.clear();
|
||||||
|
|
||||||
|
apiTemplateFiles.clear();
|
||||||
|
apiTemplateFiles.put("api.mustache", ".kt");
|
||||||
|
apiTemplateFiles.put("apiProxy.mustache", "VertxProxyHandler.kt");
|
||||||
|
apiTemplateFiles.put("api_verticle.mustache", "Verticle.kt");
|
||||||
|
|
||||||
|
embeddedTemplateDir = templateDir = "kotlin-vertx-server";
|
||||||
|
apiPackage = rootPackage + ".verticle";
|
||||||
|
modelPackage = rootPackage + ".model";
|
||||||
|
artifactId = "openapi-kotlin-vertx-server";
|
||||||
|
artifactVersion = apiVersion;
|
||||||
|
|
||||||
|
updateOption(CodegenConstants.API_PACKAGE, apiPackage);
|
||||||
|
updateOption(CodegenConstants.MODEL_PACKAGE, modelPackage);
|
||||||
|
additionalProperties.put(ROOT_PACKAGE, rootPackage);
|
||||||
|
|
||||||
|
supportingFiles.add(new SupportingFile("pom.mustache", "", "pom.xml"));
|
||||||
|
supportingFiles.add(new SupportingFile("README.mustache", "", "README.md"));
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,331 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2018 OpenAPI-Generator Contributors (https://openapi-generator.tech)
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package org.openapitools.codegen.languages;
|
||||||
|
|
||||||
|
import io.swagger.v3.oas.models.media.ArraySchema;
|
||||||
|
import io.swagger.v3.oas.models.media.Schema;
|
||||||
|
import io.swagger.v3.oas.models.media.StringSchema;
|
||||||
|
import org.openapitools.codegen.*;
|
||||||
|
import org.openapitools.codegen.meta.GeneratorMetadata;
|
||||||
|
import org.openapitools.codegen.meta.Stability;
|
||||||
|
import org.openapitools.codegen.utils.ModelUtils;
|
||||||
|
import org.openapitools.codegen.utils.StringUtils;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.util.*;
|
||||||
|
|
||||||
|
import static org.openapitools.codegen.utils.StringUtils.camelize;
|
||||||
|
import static org.openapitools.codegen.utils.StringUtils.underscore;
|
||||||
|
|
||||||
|
public class NimClientCodegen extends DefaultCodegen implements CodegenConfig {
|
||||||
|
static Logger LOGGER = LoggerFactory.getLogger(NimClientCodegen.class);
|
||||||
|
|
||||||
|
public static final String PROJECT_NAME = "projectName";
|
||||||
|
|
||||||
|
protected String packageName = "openapiclient";
|
||||||
|
protected String packageVersion = "1.0.0";
|
||||||
|
|
||||||
|
public CodegenType getTag() {
|
||||||
|
return CodegenType.CLIENT;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getName() {
|
||||||
|
return "nim";
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getHelp() {
|
||||||
|
return "Generates a nim client (beta).";
|
||||||
|
}
|
||||||
|
|
||||||
|
public NimClientCodegen() {
|
||||||
|
super();
|
||||||
|
|
||||||
|
generatorMetadata = GeneratorMetadata.newBuilder(generatorMetadata)
|
||||||
|
.stability(Stability.BETA)
|
||||||
|
.build();
|
||||||
|
|
||||||
|
outputFolder = "generated-code" + File.separator + "nim";
|
||||||
|
modelTemplateFiles.put("model.mustache", ".nim");
|
||||||
|
apiTemplateFiles.put("api.mustache", ".nim");
|
||||||
|
embeddedTemplateDir = templateDir = "nim-client";
|
||||||
|
apiPackage = File.separator + packageName + File.separator + "apis";
|
||||||
|
modelPackage = File.separator + packageName + File.separator + "models";
|
||||||
|
supportingFiles.add(new SupportingFile("README.mustache", "", "README.md"));
|
||||||
|
supportingFiles.add(new SupportingFile("sample_client.mustache", "", "sample_client.nim"));
|
||||||
|
supportingFiles.add(new SupportingFile("config.mustache", "", "config.nim"));
|
||||||
|
|
||||||
|
setReservedWordsLowerCase(
|
||||||
|
Arrays.asList(
|
||||||
|
"addr", "and", "as", "asm",
|
||||||
|
"bind", "block", "break",
|
||||||
|
"case", "cast", "concept", "const", "continue", "converter",
|
||||||
|
"defer", "discard", "distinct", "div", "do",
|
||||||
|
"elif", "else", "end", "enum", "except", "export",
|
||||||
|
"finally", "for", "from", "func",
|
||||||
|
"if", "import", "in", "include", "interface", "is", "isnot", "iterator",
|
||||||
|
"let",
|
||||||
|
"macro", "method", "mixin", "mod",
|
||||||
|
"nil", "not", "notin",
|
||||||
|
"object", "of", "or", "out",
|
||||||
|
"proc", "ptr",
|
||||||
|
"raise", "ref", "return",
|
||||||
|
"shl", "shr", "static",
|
||||||
|
"template", "try", "tuple", "type",
|
||||||
|
"using",
|
||||||
|
"var",
|
||||||
|
"when", "while",
|
||||||
|
"xor",
|
||||||
|
"yield"
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
defaultIncludes = new HashSet<String>(
|
||||||
|
Arrays.asList(
|
||||||
|
"array"
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
languageSpecificPrimitives = new HashSet<String>(
|
||||||
|
Arrays.asList(
|
||||||
|
"int",
|
||||||
|
"int8",
|
||||||
|
"int16",
|
||||||
|
"int32",
|
||||||
|
"int64",
|
||||||
|
"uint",
|
||||||
|
"uint8",
|
||||||
|
"uint16",
|
||||||
|
"uint32",
|
||||||
|
"uint64",
|
||||||
|
"float",
|
||||||
|
"float32",
|
||||||
|
"float64",
|
||||||
|
"bool",
|
||||||
|
"char",
|
||||||
|
"string",
|
||||||
|
"cstring",
|
||||||
|
"pointer")
|
||||||
|
);
|
||||||
|
|
||||||
|
typeMapping.clear();
|
||||||
|
typeMapping.put("integer", "int");
|
||||||
|
typeMapping.put("long", "int64");
|
||||||
|
typeMapping.put("number", "float");
|
||||||
|
typeMapping.put("float", "float");
|
||||||
|
typeMapping.put("double", "float64");
|
||||||
|
typeMapping.put("boolean", "bool");
|
||||||
|
typeMapping.put("UUID", "string");
|
||||||
|
typeMapping.put("URI", "string");
|
||||||
|
typeMapping.put("date", "string");
|
||||||
|
typeMapping.put("DateTime", "string");
|
||||||
|
typeMapping.put("password", "string");
|
||||||
|
typeMapping.put("file", "string");
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPackageName(String packageName) {
|
||||||
|
this.packageName = packageName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPackageVersion(String packageVersion) {
|
||||||
|
this.packageVersion = packageVersion;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Map<String, Object> postProcessModels(Map<String, Object> objs) {
|
||||||
|
return postProcessModelsEnum(objs);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void processOpts() {
|
||||||
|
super.processOpts();
|
||||||
|
|
||||||
|
if (additionalProperties.containsKey(CodegenConstants.PACKAGE_NAME)) {
|
||||||
|
setPackageName((String) additionalProperties.get(CodegenConstants.PACKAGE_NAME));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (additionalProperties.containsKey(CodegenConstants.PACKAGE_VERSION)) {
|
||||||
|
setPackageVersion((String) additionalProperties.get(CodegenConstants.PACKAGE_VERSION));
|
||||||
|
}
|
||||||
|
|
||||||
|
additionalProperties.put(CodegenConstants.PACKAGE_NAME, packageName);
|
||||||
|
additionalProperties.put(CodegenConstants.PACKAGE_VERSION, packageVersion);
|
||||||
|
|
||||||
|
apiPackage = File.separator + packageName + File.separator + "apis";
|
||||||
|
modelPackage = File.separator + packageName + File.separator + "models";
|
||||||
|
supportingFiles.add(new SupportingFile("lib.mustache", "", packageName + ".nim"));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String escapeReservedWord(String name) {
|
||||||
|
LOGGER.warn("A reserved word \"" + name + "\" is used. Consider renaming the field name");
|
||||||
|
if (this.reservedWordsMappings().containsKey(name)) {
|
||||||
|
return this.reservedWordsMappings().get(name);
|
||||||
|
}
|
||||||
|
return "`" + name + "`";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String escapeQuotationMark(String input) {
|
||||||
|
return input.replace("\"", "");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String escapeUnsafeCharacters(String input) {
|
||||||
|
return input.replace("*/", "*_/").replace("/*", "/_*");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toModelImport(String name) {
|
||||||
|
name = name.replaceAll("-", "_");
|
||||||
|
if (importMapping.containsKey(name)) {
|
||||||
|
return "model_" + StringUtils.underscore(importMapping.get(name));
|
||||||
|
} else {
|
||||||
|
return "model_" + StringUtils.underscore(name);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toApiImport(String name) {
|
||||||
|
name = name.replaceAll("-", "_");
|
||||||
|
if (importMapping.containsKey(name)) {
|
||||||
|
return "api_" + StringUtils.underscore(importMapping.get(name));
|
||||||
|
} else {
|
||||||
|
return "api_" + StringUtils.underscore(name);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toModelFilename(String name) {
|
||||||
|
name = name.replaceAll("-", "_");
|
||||||
|
return "model_" + StringUtils.underscore(name);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toApiFilename(String name) {
|
||||||
|
name = name.replaceAll("-", "_");
|
||||||
|
return "api_" + StringUtils.underscore(name);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toOperationId(String operationId) {
|
||||||
|
String sanitizedOperationId = sanitizeName(operationId);
|
||||||
|
|
||||||
|
if (isReservedWord(sanitizedOperationId)) {
|
||||||
|
sanitizedOperationId = "call" + StringUtils.camelize(sanitizedOperationId, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
return StringUtils.camelize(sanitizedOperationId, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Map<String, Object> postProcessOperationsWithModels(Map<String, Object> objs, List<Object> allModels) {
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
|
Map<String, Object> objectMap = (Map<String, Object>) objs.get("operations");
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
|
List<CodegenOperation> operations = (List<CodegenOperation>) objectMap.get("operation");
|
||||||
|
for (CodegenOperation operation : operations) {
|
||||||
|
operation.httpMethod = operation.httpMethod.toLowerCase(Locale.ROOT);
|
||||||
|
}
|
||||||
|
|
||||||
|
return objs;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getTypeDeclaration(Schema p) {
|
||||||
|
if (ModelUtils.isArraySchema(p)) {
|
||||||
|
ArraySchema ap = (ArraySchema) p;
|
||||||
|
Schema inner = ap.getItems();
|
||||||
|
if (inner == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return "seq[" + getTypeDeclaration(inner) + "]";
|
||||||
|
} else if (ModelUtils.isMapSchema(p)) {
|
||||||
|
Schema inner = ModelUtils.getAdditionalProperties(p);
|
||||||
|
if (inner == null) {
|
||||||
|
inner = new StringSchema();
|
||||||
|
}
|
||||||
|
return "Table[string, " + getTypeDeclaration(inner) + "]";
|
||||||
|
}
|
||||||
|
|
||||||
|
String schemaType = getSchemaType(p);
|
||||||
|
if (typeMapping.containsKey(schemaType)) {
|
||||||
|
return typeMapping.get(schemaType);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (schemaType.matches("\\d.*")) { // starts with number
|
||||||
|
return "`" + schemaType + "`";
|
||||||
|
} else {
|
||||||
|
return schemaType;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toVarName(String name) {
|
||||||
|
if (isReservedWord(name)) {
|
||||||
|
name = escapeReservedWord(name);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (name.matches("^\\d.*")) {
|
||||||
|
name = "`" + name + "`";
|
||||||
|
}
|
||||||
|
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toParamName(String name) {
|
||||||
|
return toVarName(name);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected boolean needToImport(String type) {
|
||||||
|
if (defaultIncludes.contains(type)) {
|
||||||
|
return false;
|
||||||
|
} else if (languageSpecificPrimitives.contains(type)) {
|
||||||
|
return false;
|
||||||
|
} else if (typeMapping.containsKey(type) && languageSpecificPrimitives.contains(typeMapping.get(type))) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toEnumName(CodegenProperty property) {
|
||||||
|
String name = StringUtils.camelize(property.name, false);
|
||||||
|
|
||||||
|
if (name.matches("\\d.*")) { // starts with number
|
||||||
|
return "`" + name + "`";
|
||||||
|
} else {
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toEnumVarName(String name, String datatype) {
|
||||||
|
name = name.replace(" ", "_");
|
||||||
|
name = StringUtils.camelize(name, false);
|
||||||
|
|
||||||
|
if (name.matches("\\d.*")) { // starts with number
|
||||||
|
return "`" + name + "`";
|
||||||
|
} else {
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -163,11 +163,11 @@ public class NodeJSExpressServerCodegen extends DefaultCodegen implements Codege
|
|||||||
if (templateName.equals("service.mustache")) {
|
if (templateName.equals("service.mustache")) {
|
||||||
String stringToMatch = File.separator + "controllers" + File.separator;
|
String stringToMatch = File.separator + "controllers" + File.separator;
|
||||||
String replacement = File.separator + implFolder + File.separator;
|
String replacement = File.separator + implFolder + File.separator;
|
||||||
result = result.replaceAll(Pattern.quote(stringToMatch), replacement);
|
result = result.replace(stringToMatch, replacement);
|
||||||
|
|
||||||
stringToMatch = "Controller.js";
|
stringToMatch = "Controller.js";
|
||||||
replacement = "Service.js";
|
replacement = "Service.js";
|
||||||
result = result.replaceAll(Pattern.quote(stringToMatch), replacement);
|
result = result.replace(stringToMatch, replacement);
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,458 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2019 OpenAPI-Generator Contributors (https://openapi-generator.tech)
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package org.openapitools.codegen.languages;
|
||||||
|
|
||||||
|
import io.swagger.v3.oas.models.media.ArraySchema;
|
||||||
|
import io.swagger.v3.oas.models.media.Schema;
|
||||||
|
|
||||||
|
import org.openapitools.codegen.CliOption;
|
||||||
|
import org.openapitools.codegen.CodegenConfig;
|
||||||
|
import org.openapitools.codegen.CodegenConstants;
|
||||||
|
import org.openapitools.codegen.CodegenType;
|
||||||
|
import org.openapitools.codegen.*;
|
||||||
|
import org.openapitools.codegen.meta.GeneratorMetadata;
|
||||||
|
import org.openapitools.codegen.meta.Stability;
|
||||||
|
import org.openapitools.codegen.utils.ProcessUtils;
|
||||||
|
import org.openapitools.codegen.utils.ModelUtils;
|
||||||
|
|
||||||
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.util.*;
|
||||||
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
|
import static org.openapitools.codegen.utils.StringUtils.camelize;
|
||||||
|
import static org.openapitools.codegen.utils.StringUtils.underscore;
|
||||||
|
|
||||||
|
public class ProtobufSchemaCodegen extends DefaultCodegen implements CodegenConfig {
|
||||||
|
|
||||||
|
private static final Logger LOGGER = LoggerFactory.getLogger(ProtobufSchemaCodegen.class);
|
||||||
|
|
||||||
|
protected String packageName = "openapitools";
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public CodegenType getTag() {
|
||||||
|
return CodegenType.CONFIG;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getName() {
|
||||||
|
return "protobuf-schema";
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getHelp() {
|
||||||
|
return "Generates gRPC and protocol buffer schema files (beta)";
|
||||||
|
}
|
||||||
|
|
||||||
|
public ProtobufSchemaCodegen() {
|
||||||
|
super();
|
||||||
|
|
||||||
|
generatorMetadata = GeneratorMetadata.newBuilder(generatorMetadata)
|
||||||
|
.stability(Stability.BETA)
|
||||||
|
.build();
|
||||||
|
|
||||||
|
outputFolder = "generated-code/protobuf-schema";
|
||||||
|
modelTemplateFiles.put("model.mustache", ".proto");
|
||||||
|
apiTemplateFiles.put("api.mustache", ".proto");
|
||||||
|
embeddedTemplateDir = templateDir = "protobuf-schema";
|
||||||
|
hideGenerationTimestamp = Boolean.TRUE;
|
||||||
|
modelPackage = "messages";
|
||||||
|
apiPackage = "services";
|
||||||
|
|
||||||
|
/*setReservedWordsLowerCase(
|
||||||
|
Arrays.asList(
|
||||||
|
// data type
|
||||||
|
"nil", "string", "boolean", "number", "userdata", "thread",
|
||||||
|
"table",
|
||||||
|
|
||||||
|
// reserved words: http://www.lua.org/manual/5.1/manual.html#2.1
|
||||||
|
"and", "break", "do", "else", "elseif",
|
||||||
|
"end", "false", "for", "function", "if",
|
||||||
|
"in", "local", "nil", "not", "or",
|
||||||
|
"repeat", "return", "then", "true", "until", "while"
|
||||||
|
)
|
||||||
|
);*/
|
||||||
|
|
||||||
|
defaultIncludes = new HashSet<String>(
|
||||||
|
Arrays.asList(
|
||||||
|
"map",
|
||||||
|
"array")
|
||||||
|
);
|
||||||
|
|
||||||
|
languageSpecificPrimitives = new HashSet<String>(
|
||||||
|
Arrays.asList(
|
||||||
|
"map",
|
||||||
|
"array",
|
||||||
|
"bool",
|
||||||
|
"bytes",
|
||||||
|
"string",
|
||||||
|
"int32",
|
||||||
|
"int64",
|
||||||
|
"uint32",
|
||||||
|
"uint64",
|
||||||
|
"sint32",
|
||||||
|
"sint64",
|
||||||
|
"fixed32",
|
||||||
|
"fixed64",
|
||||||
|
"sfixed32",
|
||||||
|
"sfixed64",
|
||||||
|
"float",
|
||||||
|
"double")
|
||||||
|
);
|
||||||
|
|
||||||
|
instantiationTypes.clear();
|
||||||
|
instantiationTypes.put("array", "repeat");
|
||||||
|
//instantiationTypes.put("map", "map");
|
||||||
|
|
||||||
|
// ref: https://developers.google.com/protocol-buffers/docs/proto
|
||||||
|
typeMapping.clear();
|
||||||
|
typeMapping.put("array", "array");
|
||||||
|
typeMapping.put("map", "map");
|
||||||
|
typeMapping.put("integer", "int32");
|
||||||
|
typeMapping.put("long", "int64");
|
||||||
|
typeMapping.put("number", "float");
|
||||||
|
typeMapping.put("float", "float");
|
||||||
|
typeMapping.put("double", "double");
|
||||||
|
typeMapping.put("boolean", "bool");
|
||||||
|
typeMapping.put("string", "string");
|
||||||
|
typeMapping.put("UUID", "string");
|
||||||
|
typeMapping.put("URI", "string");
|
||||||
|
typeMapping.put("date", "string");
|
||||||
|
typeMapping.put("DateTime", "string");
|
||||||
|
typeMapping.put("password", "string");
|
||||||
|
// TODO fix file mapping
|
||||||
|
typeMapping.put("file", "string");
|
||||||
|
typeMapping.put("binary", "string");
|
||||||
|
typeMapping.put("ByteArray", "bytes");
|
||||||
|
typeMapping.put("object", "TODO_OBJECT_MAPPING");
|
||||||
|
|
||||||
|
importMapping.clear();
|
||||||
|
/*
|
||||||
|
importMapping = new HashMap<String, String>();
|
||||||
|
importMapping.put("time.Time", "time");
|
||||||
|
importMapping.put("*os.File", "os");
|
||||||
|
importMapping.put("os", "io/ioutil");
|
||||||
|
*/
|
||||||
|
|
||||||
|
modelDocTemplateFiles.put("model_doc.mustache", ".md");
|
||||||
|
apiDocTemplateFiles.put("api_doc.mustache", ".md");
|
||||||
|
|
||||||
|
cliOptions.clear();
|
||||||
|
/*cliOptions.add(new CliOption(CodegenConstants.PACKAGE_NAME, "GraphQL package name (convention: lowercase).")
|
||||||
|
.defaultValue("openapi2graphql"));
|
||||||
|
cliOptions.add(new CliOption(CodegenConstants.PACKAGE_VERSION, "GraphQL package version.")
|
||||||
|
.defaultValue("1.0.0"));
|
||||||
|
cliOptions.add(new CliOption(CodegenConstants.HIDE_GENERATION_TIMESTAMP, CodegenConstants.HIDE_GENERATION_TIMESTAMP_DESC)
|
||||||
|
.defaultValue(Boolean.TRUE.toString()));*/
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void processOpts() {
|
||||||
|
super.processOpts();
|
||||||
|
|
||||||
|
//apiTestTemplateFiles.put("api_test.mustache", ".proto");
|
||||||
|
//modelTestTemplateFiles.put("model_test.mustache", ".proto");
|
||||||
|
|
||||||
|
apiDocTemplateFiles.clear(); // TODO: add api doc template
|
||||||
|
modelDocTemplateFiles.clear(); // TODO: add model doc template
|
||||||
|
|
||||||
|
modelPackage = "models";
|
||||||
|
apiPackage = "services";
|
||||||
|
|
||||||
|
if (additionalProperties.containsKey(CodegenConstants.PACKAGE_NAME)) {
|
||||||
|
setPackageName((String) additionalProperties.get(CodegenConstants.PACKAGE_NAME));
|
||||||
|
}
|
||||||
|
|
||||||
|
supportingFiles.add(new SupportingFile("README.mustache", "", "README.md"));
|
||||||
|
//supportingFiles.add(new SupportingFile("root.mustache", "", packageName + ".proto"));
|
||||||
|
//supportingFiles.add(new SupportingFile("git_push.sh.mustache", "", "git_push.sh"));
|
||||||
|
//supportingFiles.add(new SupportingFile("gitignore.mustache", "", ".gitignore"))
|
||||||
|
//supportingFiles.add(new SupportingFile(".travis.yml", "", ".travis.yml"));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toOperationId(String operationId) {
|
||||||
|
// throw exception if method name is empty (should not occur as an auto-generated method name will be used)
|
||||||
|
if (StringUtils.isEmpty(operationId)) {
|
||||||
|
throw new RuntimeException("Empty method name (operationId) not allowed");
|
||||||
|
}
|
||||||
|
|
||||||
|
// method name cannot use reserved keyword, e.g. return
|
||||||
|
if (isReservedWord(operationId)) {
|
||||||
|
LOGGER.warn(operationId + " (reserved word) cannot be used as method name. Renamed to " + camelize(sanitizeName("call_" + operationId)));
|
||||||
|
operationId = "call_" + operationId;
|
||||||
|
}
|
||||||
|
|
||||||
|
return camelize(sanitizeName(operationId));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Map<String, Object> postProcessModels(Map<String, Object> objs) {
|
||||||
|
objs = postProcessModelsEnum(objs);
|
||||||
|
List<Object> models = (List<Object>) objs.get("models");
|
||||||
|
// add x-index to properties
|
||||||
|
ProcessUtils.addIndexToProperties(models, 1);
|
||||||
|
|
||||||
|
for (Object _mo : models) {
|
||||||
|
Map<String, Object> mo = (Map<String, Object>) _mo;
|
||||||
|
CodegenModel cm = (CodegenModel) mo.get("model");
|
||||||
|
|
||||||
|
for (CodegenProperty var : cm.vars) {
|
||||||
|
// add x-protobuf-type: repeated if it's an array
|
||||||
|
if (Boolean.TRUE.equals(var.isListContainer)) {
|
||||||
|
var.vendorExtensions.put("x-protobuf-type", "repeated");
|
||||||
|
}
|
||||||
|
|
||||||
|
// add x-protobuf-data-type
|
||||||
|
// ref: https://developers.google.com/protocol-buffers/docs/proto3
|
||||||
|
if (!var.vendorExtensions.containsKey("x-protobuf-data-type")) {
|
||||||
|
if (var.isListContainer) {
|
||||||
|
var.vendorExtensions.put("x-protobuf-data-type", var.items.dataType);
|
||||||
|
} else {
|
||||||
|
var.vendorExtensions.put("x-protobuf-data-type", var.dataType);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (var.isEnum && var.allowableValues.containsKey("enumVars")) {
|
||||||
|
List<Map<String, Object>> enumVars = (List<Map<String, Object>>) var.allowableValues.get("enumVars");
|
||||||
|
int enumIndex = 0;
|
||||||
|
for (Map<String, Object> enumVar : enumVars) {
|
||||||
|
enumVar.put("protobuf-enum-index", enumIndex);
|
||||||
|
enumIndex++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return objs;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String escapeUnsafeCharacters(String input) {
|
||||||
|
return input;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String escapeQuotationMark(String input) {
|
||||||
|
return input;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return the default value of the property
|
||||||
|
*
|
||||||
|
* @param p OpenAPI property object
|
||||||
|
* @return string presentation of the default value of the property
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public String toDefaultValue(Schema p) {
|
||||||
|
if (ModelUtils.isBooleanSchema(p)) {
|
||||||
|
if (p.getDefault() != null) {
|
||||||
|
if (Boolean.valueOf(p.getDefault().toString()) == false)
|
||||||
|
return "false";
|
||||||
|
else
|
||||||
|
return "true";
|
||||||
|
}
|
||||||
|
} else if (ModelUtils.isDateSchema(p)) {
|
||||||
|
// TODO
|
||||||
|
} else if (ModelUtils.isDateTimeSchema(p)) {
|
||||||
|
// TODO
|
||||||
|
} else if (ModelUtils.isNumberSchema(p)) {
|
||||||
|
if (p.getDefault() != null) {
|
||||||
|
return p.getDefault().toString();
|
||||||
|
}
|
||||||
|
} else if (ModelUtils.isIntegerSchema(p)) {
|
||||||
|
if (p.getDefault() != null) {
|
||||||
|
return p.getDefault().toString();
|
||||||
|
}
|
||||||
|
} else if (ModelUtils.isStringSchema(p)) {
|
||||||
|
if (p.getDefault() != null) {
|
||||||
|
if (Pattern.compile("\r\n|\r|\n").matcher((String) p.getDefault()).find())
|
||||||
|
return "'''" + p.getDefault() + "'''";
|
||||||
|
else
|
||||||
|
return "'" + p.getDefault() + "'";
|
||||||
|
}
|
||||||
|
} else if (ModelUtils.isArraySchema(p)) {
|
||||||
|
if (p.getDefault() != null) {
|
||||||
|
return p.getDefault().toString();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String apiFileFolder() {
|
||||||
|
return outputFolder + File.separatorChar + apiPackage;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String modelFileFolder() {
|
||||||
|
return outputFolder + File.separatorChar + modelPackage;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toApiFilename(String name) {
|
||||||
|
// replace - with _ e.g. created-at => created_at
|
||||||
|
name = name.replaceAll("-", "_");
|
||||||
|
|
||||||
|
// e.g. PhoneNumber => phone_number
|
||||||
|
return underscore(name) + "_service";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toApiName(String name) {
|
||||||
|
if (name.length() == 0) {
|
||||||
|
return "DefaultService";
|
||||||
|
}
|
||||||
|
// e.g. phone_number => PhoneNumber
|
||||||
|
return camelize(name) + "Service";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toApiVarName(String name) {
|
||||||
|
if (name.length() == 0) {
|
||||||
|
return "default_service";
|
||||||
|
}
|
||||||
|
return underscore(name) + "_service";
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPackageName(String packageName) {
|
||||||
|
this.packageName = packageName;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toModelFilename(String name) {
|
||||||
|
// underscore the model file name
|
||||||
|
// PhoneNumber => phone_number
|
||||||
|
return underscore(toModelName(name));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toModelName(String name) {
|
||||||
|
name = sanitizeName(name); // FIXME: a parameter should not be assigned. Also declare the methods parameters as 'final'.
|
||||||
|
// remove dollar sign
|
||||||
|
name = name.replaceAll("$", "");
|
||||||
|
|
||||||
|
// model name cannot use reserved keyword, e.g. return
|
||||||
|
if (isReservedWord(name)) {
|
||||||
|
LOGGER.warn(name + " (reserved word) cannot be used as model name. Renamed to " + camelize("model_" + name));
|
||||||
|
name = "model_" + name; // e.g. return => ModelReturn (after camelize)
|
||||||
|
}
|
||||||
|
|
||||||
|
// model name starts with number
|
||||||
|
if (name.matches("^\\d.*")) {
|
||||||
|
LOGGER.warn(name + " (model name starts with number) cannot be used as model name. Renamed to " + camelize("model_" + name));
|
||||||
|
name = "model_" + name; // e.g. 200Response => Model200Response (after camelize)
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!StringUtils.isEmpty(modelNamePrefix)) {
|
||||||
|
name = modelNamePrefix + "_" + name;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!StringUtils.isEmpty(modelNameSuffix)) {
|
||||||
|
name = name + "_" + modelNameSuffix;
|
||||||
|
}
|
||||||
|
|
||||||
|
// camelize the model name
|
||||||
|
// phone_number => PhoneNumber
|
||||||
|
return camelize(name);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getSchemaType(Schema p) {
|
||||||
|
String schemaType = super.getSchemaType(p);
|
||||||
|
String type = null;
|
||||||
|
if (typeMapping.containsKey(schemaType)) {
|
||||||
|
type = typeMapping.get(schemaType);
|
||||||
|
if (languageSpecificPrimitives.contains(type)) {
|
||||||
|
return type;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
type = toModelName(schemaType);
|
||||||
|
}
|
||||||
|
return type;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Map<String, Object> postProcessOperationsWithModels(Map<String, Object> objs, List<Object> allModels) {
|
||||||
|
Map<String, Object> operations = (Map<String, Object>) objs.get("operations");
|
||||||
|
List<CodegenOperation> operationList = (List<CodegenOperation>) operations.get("operation");
|
||||||
|
for (CodegenOperation op : operationList) {
|
||||||
|
int index = 1;
|
||||||
|
for (CodegenParameter p : op.allParams) {
|
||||||
|
// add x-protobuf-type: repeated if it's an array
|
||||||
|
if (Boolean.TRUE.equals(p.isListContainer)) {
|
||||||
|
p.vendorExtensions.put("x-protobuf-type", "repeated");
|
||||||
|
} else if (Boolean.TRUE.equals(p.isMapContainer)) {
|
||||||
|
LOGGER.warn("Map parameter (name: {}, operation ID: {}) not yet supported", p.paramName, op.operationId);
|
||||||
|
}
|
||||||
|
|
||||||
|
// add x-protobuf-data-type
|
||||||
|
// ref: https://developers.google.com/protocol-buffers/docs/proto3
|
||||||
|
if (!p.vendorExtensions.containsKey("x-protobuf-data-type")) {
|
||||||
|
if (Boolean.TRUE.equals(p.isListContainer)) {
|
||||||
|
p.vendorExtensions.put("x-protobuf-data-type", p.items.dataType);
|
||||||
|
} else {
|
||||||
|
p.vendorExtensions.put("x-protobuf-data-type", p.dataType);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
p.vendorExtensions.put("x-index", index);
|
||||||
|
index++;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (StringUtils.isEmpty(op.returnType)) {
|
||||||
|
op.vendorExtensions.put("x-grpc-response", "google.protobuf.Empty");
|
||||||
|
} else {
|
||||||
|
if (Boolean.FALSE.equals(op.returnTypeIsPrimitive) && StringUtils.isEmpty(op.returnContainer)) {
|
||||||
|
op.vendorExtensions.put("x-grpc-response", op.returnType);
|
||||||
|
} else {
|
||||||
|
if ("map".equals(op.returnContainer)) {
|
||||||
|
LOGGER.warn("Map response (operation ID: {}) not yet supported", op.operationId);
|
||||||
|
op.vendorExtensions.put("x-grpc-response-type", op.returnBaseType);
|
||||||
|
} else if ("array".equals(op.returnContainer)) {
|
||||||
|
op.vendorExtensions.put("x-grpc-response-type", "repeated " + op.returnBaseType);
|
||||||
|
} else { // primitive type
|
||||||
|
op.vendorExtensions.put("x-grpc-response-type", op.returnBaseType);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return objs;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toModelImport(String name) {
|
||||||
|
return underscore(name);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getTypeDeclaration(Schema p) {
|
||||||
|
if (ModelUtils.isArraySchema(p)) {
|
||||||
|
ArraySchema ap = (ArraySchema) p;
|
||||||
|
Schema inner = ap.getItems();
|
||||||
|
return getSchemaType(p) + "[" + getTypeDeclaration(inner) + "]";
|
||||||
|
} else if (ModelUtils.isMapSchema(p)) {
|
||||||
|
Schema inner = ModelUtils.getAdditionalProperties(p);
|
||||||
|
return getSchemaType(p) + "[str, " + getTypeDeclaration(inner) + "]";
|
||||||
|
}
|
||||||
|
return super.getTypeDeclaration(p);
|
||||||
|
}
|
||||||
|
}
|
@ -909,6 +909,12 @@ public class RustServerCodegen extends DefaultCodegen implements CodegenConfig {
|
|||||||
additionalProperties.put("usesXmlNamespaces", true);
|
additionalProperties.put("usesXmlNamespaces", true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Schema additionalProperties = ModelUtils.getAdditionalProperties(model);
|
||||||
|
|
||||||
|
if (additionalProperties != null) {
|
||||||
|
mdl.additionalPropertiesType = getSchemaType(additionalProperties);
|
||||||
|
}
|
||||||
|
|
||||||
return mdl;
|
return mdl;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1123,20 +1129,34 @@ public class RustServerCodegen extends DefaultCodegen implements CodegenConfig {
|
|||||||
// 'null'. This ensures that we treat this model as a struct
|
// 'null'. This ensures that we treat this model as a struct
|
||||||
// with multiple parameters.
|
// with multiple parameters.
|
||||||
cm.dataType = null;
|
cm.dataType = null;
|
||||||
} else if (cm.dataType != null) {
|
} else if (cm.dataType != null && cm.dataType.equals("map")) {
|
||||||
if (cm.dataType.equals("map")) {
|
if (!cm.allVars.isEmpty() || cm.additionalPropertiesType == null) {
|
||||||
// We don't yet support `additionalProperties`. We ignore
|
// We don't yet support `additionalProperties` that also have
|
||||||
// the `additionalProperties` type ('map') and warn the
|
// properties. If we see variables, we ignore the
|
||||||
// user. This will produce code that compiles, but won't
|
// `additionalProperties` type ('map') and warn the user. This
|
||||||
// feature the `additionalProperties`.
|
// will produce code that compiles, but won't feature the
|
||||||
|
// `additionalProperties` - but that's likely more useful to
|
||||||
|
// the user than the alternative.
|
||||||
|
LOGGER.warn("Ignoring additionalProperties (see https://github.com/OpenAPITools/openapi-generator/issues/318) alongside defined properties");
|
||||||
cm.dataType = null;
|
cm.dataType = null;
|
||||||
LOGGER.warn("Ignoring unsupported additionalProperties (see https://github.com/OpenAPITools/openapi-generator/issues/318)");
|
|
||||||
} else {
|
|
||||||
// We need to hack about with single-parameter models to
|
|
||||||
// get them recognised correctly.
|
|
||||||
cm.isAlias = false;
|
|
||||||
cm.dataType = typeMapping.get(cm.dataType);
|
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
String type;
|
||||||
|
|
||||||
|
if (typeMapping.containsKey(cm.additionalPropertiesType)) {
|
||||||
|
type = typeMapping.get(cm.additionalPropertiesType);
|
||||||
|
} else {
|
||||||
|
type = toModelName(cm.additionalPropertiesType);
|
||||||
|
}
|
||||||
|
|
||||||
|
cm.dataType = "HashMap<String, " + type + ">";
|
||||||
|
}
|
||||||
|
} else if (cm.dataType != null) {
|
||||||
|
// We need to hack about with single-parameter models to
|
||||||
|
// get them recognised correctly.
|
||||||
|
cm.isAlias = false;
|
||||||
|
cm.dataType = typeMapping.get(cm.dataType);
|
||||||
}
|
}
|
||||||
|
|
||||||
cm.vendorExtensions.put("isString", "String".equals(cm.dataType));
|
cm.vendorExtensions.put("isString", "String".equals(cm.dataType));
|
||||||
|
@ -67,6 +67,8 @@ public class TypeScriptAngularClientCodegen extends AbstractTypeScriptClientCode
|
|||||||
super();
|
super();
|
||||||
this.outputFolder = "generated-code/typescript-angular";
|
this.outputFolder = "generated-code/typescript-angular";
|
||||||
|
|
||||||
|
supportsMultipleInheritance = true;
|
||||||
|
|
||||||
embeddedTemplateDir = templateDir = "typescript-angular";
|
embeddedTemplateDir = templateDir = "typescript-angular";
|
||||||
modelTemplateFiles.put("model.mustache", ".ts");
|
modelTemplateFiles.put("model.mustache", ".ts");
|
||||||
apiTemplateFiles.put("api.service.mustache", ".ts");
|
apiTemplateFiles.put("api.service.mustache", ".ts");
|
||||||
|
@ -34,12 +34,14 @@ public class TypeScriptFetchClientCodegen extends AbstractTypeScriptClientCodege
|
|||||||
public static final String WITH_INTERFACES = "withInterfaces";
|
public static final String WITH_INTERFACES = "withInterfaces";
|
||||||
public static final String USE_SINGLE_REQUEST_PARAMETER = "useSingleRequestParameter";
|
public static final String USE_SINGLE_REQUEST_PARAMETER = "useSingleRequestParameter";
|
||||||
public static final String PREFIX_PARAMETER_INTERFACES = "prefixParameterInterfaces";
|
public static final String PREFIX_PARAMETER_INTERFACES = "prefixParameterInterfaces";
|
||||||
|
public static final String TYPESCRIPT_THREE_PLUS = "typescriptThreePlus";
|
||||||
|
|
||||||
protected String npmRepository = null;
|
protected String npmRepository = null;
|
||||||
private boolean useSingleRequestParameter = true;
|
private boolean useSingleRequestParameter = true;
|
||||||
private boolean prefixParameterInterfaces = false;
|
private boolean prefixParameterInterfaces = false;
|
||||||
protected boolean addedApiIndex = false;
|
protected boolean addedApiIndex = false;
|
||||||
protected boolean addedModelIndex = false;
|
protected boolean addedModelIndex = false;
|
||||||
|
protected boolean typescriptThreePlus = false;
|
||||||
|
|
||||||
|
|
||||||
public TypeScriptFetchClientCodegen() {
|
public TypeScriptFetchClientCodegen() {
|
||||||
@ -62,6 +64,7 @@ public class TypeScriptFetchClientCodegen extends AbstractTypeScriptClientCodege
|
|||||||
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(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(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(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
|
@Override
|
||||||
@ -82,6 +85,14 @@ public class TypeScriptFetchClientCodegen extends AbstractTypeScriptClientCodege
|
|||||||
this.npmRepository = npmRepository;
|
this.npmRepository = npmRepository;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Boolean getTypescriptThreePlus() {
|
||||||
|
return typescriptThreePlus;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setTypescriptThreePlus(Boolean typescriptThreePlus) {
|
||||||
|
this.typescriptThreePlus = typescriptThreePlus;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void processOpts() {
|
public void processOpts() {
|
||||||
super.processOpts();
|
super.processOpts();
|
||||||
@ -105,6 +116,10 @@ public class TypeScriptFetchClientCodegen extends AbstractTypeScriptClientCodege
|
|||||||
if (additionalProperties.containsKey(NPM_NAME)) {
|
if (additionalProperties.containsKey(NPM_NAME)) {
|
||||||
addNpmPackageGeneration();
|
addNpmPackageGeneration();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (additionalProperties.containsKey(TYPESCRIPT_THREE_PLUS)) {
|
||||||
|
this.setTypescriptThreePlus(convertPropertyToBoolean(TYPESCRIPT_THREE_PLUS));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -359,14 +359,7 @@ public class ModelUtils {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isArraySchema(Schema schema) {
|
public static boolean isArraySchema(Schema schema) {
|
||||||
if (schema instanceof ArraySchema) {
|
return (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) {
|
public static boolean isStringSchema(Schema schema) {
|
||||||
@ -896,6 +889,8 @@ public class ModelUtils {
|
|||||||
public static String getParentName(ComposedSchema composedSchema, Map<String, Schema> allSchemas) {
|
public static String getParentName(ComposedSchema composedSchema, Map<String, Schema> allSchemas) {
|
||||||
List<Schema> interfaces = getInterfaces(composedSchema);
|
List<Schema> interfaces = getInterfaces(composedSchema);
|
||||||
|
|
||||||
|
List<String> refedParentNames = new ArrayList<>();
|
||||||
|
|
||||||
if (interfaces != null && !interfaces.isEmpty()) {
|
if (interfaces != null && !interfaces.isEmpty()) {
|
||||||
for (Schema schema : interfaces) {
|
for (Schema schema : interfaces) {
|
||||||
// get the actual schema
|
// get the actual schema
|
||||||
@ -911,6 +906,7 @@ public class ModelUtils {
|
|||||||
} else {
|
} else {
|
||||||
LOGGER.debug("Not a parent since discriminator.propertyName is not set {}", s.get$ref());
|
LOGGER.debug("Not a parent since discriminator.propertyName is not set {}", s.get$ref());
|
||||||
// not a parent since discriminator.propertyName is not set
|
// not a parent since discriminator.propertyName is not set
|
||||||
|
refedParentNames.add(parentName);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// not a ref, doing nothing
|
// not a ref, doing nothing
|
||||||
@ -918,6 +914,13 @@ public class ModelUtils {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// parent name only makes sense when there is a single obvious parent
|
||||||
|
if (refedParentNames.size() == 1) {
|
||||||
|
LOGGER.warn("[deprecated] inheritance without use of 'discriminator.propertyName' is deprecated " +
|
||||||
|
"and will be removed in a future release. Generating model for {}", composedSchema.getName());
|
||||||
|
return refedParentNames.get(0);
|
||||||
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -138,6 +138,7 @@ ext {
|
|||||||
swagger_annotations_version = "1.5.22"
|
swagger_annotations_version = "1.5.22"
|
||||||
jackson_version = "{{^threetenbp}}2.9.9{{/threetenbp}}{{#threetenbp}}2.6.4{{/threetenbp}}"
|
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_version = "{{^threetenbp}}2.9.9{{/threetenbp}}{{#threetenbp}}2.6.4{{/threetenbp}}"
|
||||||
|
jackson-databind-nullable-version = "0.2.0"
|
||||||
jersey_version = "1.19.4"
|
jersey_version = "1.19.4"
|
||||||
jodatime_version = "2.9.9"
|
jodatime_version = "2.9.9"
|
||||||
junit_version = "4.12"
|
junit_version = "4.12"
|
||||||
@ -152,6 +153,7 @@ dependencies {
|
|||||||
compile "com.fasterxml.jackson.core:jackson-annotations:$jackson_version"
|
compile "com.fasterxml.jackson.core:jackson-annotations:$jackson_version"
|
||||||
compile "com.fasterxml.jackson.core:jackson-databind:$jackson_databind_version"
|
compile "com.fasterxml.jackson.core:jackson-databind:$jackson_databind_version"
|
||||||
compile "com.fasterxml.jackson.jaxrs:jackson-jaxrs-json-provider:$jackson_version"
|
compile "com.fasterxml.jackson.jaxrs:jackson-jaxrs-json-provider:$jackson_version"
|
||||||
|
compile "org.openapitools:jackson-databind-nullable:$jackson-databind-nullable-version"
|
||||||
{{#joda}}
|
{{#joda}}
|
||||||
compile "com.fasterxml.jackson.datatype:jackson-datatype-joda:$jackson_version"
|
compile "com.fasterxml.jackson.datatype:jackson-datatype-joda:$jackson_version"
|
||||||
{{/joda}}
|
{{/joda}}
|
||||||
|
@ -1,11 +1,17 @@
|
|||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
# ref: https://help.github.com/articles/adding-an-existing-project-to-github-using-the-command-line/
|
# ref: https://help.github.com/articles/adding-an-existing-project-to-github-using-the-command-line/
|
||||||
#
|
#
|
||||||
# Usage example: /bin/sh ./git_push.sh wing328 openapi-pestore-perl "minor update"
|
# Usage example: /bin/sh ./git_push.sh wing328 openapi-pestore-perl "minor update" "gitlab.com"
|
||||||
|
|
||||||
git_user_id=$1
|
git_user_id=$1
|
||||||
git_repo_id=$2
|
git_repo_id=$2
|
||||||
release_note=$3
|
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
|
if [ "$git_user_id" = "" ]; then
|
||||||
git_user_id="{{{gitUserId}}}"
|
git_user_id="{{{gitUserId}}}"
|
||||||
@ -28,7 +34,7 @@ git init
|
|||||||
# Adds the files in the local repository and stages them for commit.
|
# Adds the files in the local repository and stages them for commit.
|
||||||
git add .
|
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"
|
git commit -m "$release_note"
|
||||||
|
|
||||||
# Sets the new remote
|
# Sets the new remote
|
||||||
@ -37,9 +43,9 @@ if [ "$git_remote" = "" ]; then # git remote not defined
|
|||||||
|
|
||||||
if [ "$GIT_TOKEN" = "" ]; then
|
if [ "$GIT_TOKEN" = "" ]; then
|
||||||
echo "[INFO] \$GIT_TOKEN (environment variable) is not set. Using the git credential in your environment."
|
echo "[INFO] \$GIT_TOKEN (environment variable) is not set. Using the git credential in your environment."
|
||||||
git remote add origin https://github.com/${git_user_id}/${git_repo_id}.git
|
git remote add origin https://${git_host}/${git_user_id}/${git_repo_id}.git
|
||||||
else
|
else
|
||||||
git remote add origin https://${git_user_id}:${GIT_TOKEN}@github.com/${git_user_id}/${git_repo_id}.git
|
git remote add origin https://${git_user_id}:${GIT_TOKEN}@${git_host}/${git_user_id}/${git_repo_id}.git
|
||||||
fi
|
fi
|
||||||
|
|
||||||
fi
|
fi
|
||||||
@ -47,6 +53,6 @@ fi
|
|||||||
git pull origin master
|
git pull origin master
|
||||||
|
|
||||||
# Pushes (Forces) the changes in the local repository up to the remote repository
|
# Pushes (Forces) the changes in the local repository up to the remote repository
|
||||||
echo "Git pushing to https://github.com/${git_user_id}/${git_repo_id}.git"
|
echo "Git pushing to https://${git_host}/${git_user_id}/${git_repo_id}.git"
|
||||||
git push origin master 2>&1 | grep -v 'To https'
|
git push origin master 2>&1 | grep -v 'To https'
|
||||||
|
|
||||||
|
@ -122,6 +122,7 @@ ext {
|
|||||||
swagger_annotations_version = "1.5.22"
|
swagger_annotations_version = "1.5.22"
|
||||||
jackson_version = "2.9.9"
|
jackson_version = "2.9.9"
|
||||||
jackson_databind_version = "2.9.9"
|
jackson_databind_version = "2.9.9"
|
||||||
|
jackson-databind-nullable-version = "0.2.0"
|
||||||
{{#threetenbp}}
|
{{#threetenbp}}
|
||||||
threepane_version = "2.6.4"
|
threepane_version = "2.6.4"
|
||||||
{{/threetenbp}}
|
{{/threetenbp}}
|
||||||
@ -141,6 +142,7 @@ dependencies {
|
|||||||
compile "com.fasterxml.jackson.core:jackson-core:$jackson_version"
|
compile "com.fasterxml.jackson.core:jackson-core:$jackson_version"
|
||||||
compile "com.fasterxml.jackson.core:jackson-annotations:$jackson_version"
|
compile "com.fasterxml.jackson.core:jackson-annotations:$jackson_version"
|
||||||
compile "com.fasterxml.jackson.core:jackson-databind:$jackson_databind_version"
|
compile "com.fasterxml.jackson.core:jackson-databind:$jackson_databind_version"
|
||||||
|
compile "org.openapitools:jackson-databind-nullable:$jackson-databind-nullable-version"
|
||||||
{{#joda}}
|
{{#joda}}
|
||||||
compile "com.fasterxml.jackson.datatype:jackson-datatype-joda:$jackson_version"
|
compile "com.fasterxml.jackson.datatype:jackson-datatype-joda:$jackson_version"
|
||||||
{{/joda}}
|
{{/joda}}
|
||||||
|
@ -122,6 +122,7 @@ ext {
|
|||||||
swagger_annotations_version = "1.5.22"
|
swagger_annotations_version = "1.5.22"
|
||||||
jackson_version = "2.9.9"
|
jackson_version = "2.9.9"
|
||||||
jackson_databind_version = "2.9.9"
|
jackson_databind_version = "2.9.9"
|
||||||
|
jackson-databind-nullable-version = "0.2.0"
|
||||||
google_api_client_version = "1.23.0"
|
google_api_client_version = "1.23.0"
|
||||||
jersey_common_version = "2.25.1"
|
jersey_common_version = "2.25.1"
|
||||||
jodatime_version = "2.9.9"
|
jodatime_version = "2.9.9"
|
||||||
@ -140,6 +141,7 @@ dependencies {
|
|||||||
compile "com.fasterxml.jackson.core:jackson-annotations:$jackson_version"
|
compile "com.fasterxml.jackson.core:jackson-annotations:$jackson_version"
|
||||||
compile "com.fasterxml.jackson.core:jackson-databind:$jackson_databind_version"
|
compile "com.fasterxml.jackson.core:jackson-databind:$jackson_databind_version"
|
||||||
compile "com.fasterxml.jackson.jaxrs:jackson-jaxrs-json-provider:$jackson_version"
|
compile "com.fasterxml.jackson.jaxrs:jackson-jaxrs-json-provider:$jackson_version"
|
||||||
|
compile "org.openapitools:jackson-databind-nullable:$jackson-databind-nullable-version"
|
||||||
{{#java8}}
|
{{#java8}}
|
||||||
compile "com.fasterxml.jackson.datatype:jackson-datatype-jsr310:$jackson_version"
|
compile "com.fasterxml.jackson.datatype:jackson-datatype-jsr310:$jackson_version"
|
||||||
{{/java8}}
|
{{/java8}}
|
||||||
|
@ -304,7 +304,7 @@
|
|||||||
<properties>
|
<properties>
|
||||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||||
<swagger-annotations-version>1.5.22</swagger-annotations-version>
|
<swagger-annotations-version>1.5.22</swagger-annotations-version>
|
||||||
<google-api-client-version>1.23.0</google-api-client-version>
|
<google-api-client-version>1.30.2</google-api-client-version>
|
||||||
<jersey-common-version>2.25.1</jersey-common-version>
|
<jersey-common-version>2.25.1</jersey-common-version>
|
||||||
<jackson-version>2.9.9</jackson-version>
|
<jackson-version>2.9.9</jackson-version>
|
||||||
<jackson-databind-version>2.9.9</jackson-databind-version>
|
<jackson-databind-version>2.9.9</jackson-databind-version>
|
||||||
|
@ -121,6 +121,7 @@ ext {
|
|||||||
swagger_annotations_version = "1.5.22"
|
swagger_annotations_version = "1.5.22"
|
||||||
jackson_version = "2.9.9"
|
jackson_version = "2.9.9"
|
||||||
jackson_databind_version = "2.9.9"
|
jackson_databind_version = "2.9.9"
|
||||||
|
jackson-databind-nullable-version = "0.2.0"
|
||||||
{{#supportJava6}}
|
{{#supportJava6}}
|
||||||
jersey_version = "2.6"
|
jersey_version = "2.6"
|
||||||
commons_io_version=2.5
|
commons_io_version=2.5
|
||||||
@ -144,6 +145,7 @@ dependencies {
|
|||||||
compile "com.fasterxml.jackson.core:jackson-core:$jackson_version"
|
compile "com.fasterxml.jackson.core:jackson-core:$jackson_version"
|
||||||
compile "com.fasterxml.jackson.core:jackson-annotations:$jackson_version"
|
compile "com.fasterxml.jackson.core:jackson-annotations:$jackson_version"
|
||||||
compile "com.fasterxml.jackson.core:jackson-databind:$jackson_databind_version"
|
compile "com.fasterxml.jackson.core:jackson-databind:$jackson_databind_version"
|
||||||
|
compile "org.openapitools:jackson-databind-nullable:$jackson-databind-nullable-version"
|
||||||
{{#joda}}
|
{{#joda}}
|
||||||
compile "com.fasterxml.jackson.datatype:jackson-datatype-joda:$jackson_version"
|
compile "com.fasterxml.jackson.datatype:jackson-datatype-joda:$jackson_version"
|
||||||
{{/joda}}
|
{{/joda}}
|
||||||
|
@ -13,7 +13,8 @@ import java.util.function.Supplier;
|
|||||||
|
|
||||||
import static io.restassured.config.ObjectMapperConfig.objectMapperConfig;
|
import static io.restassured.config.ObjectMapperConfig.objectMapperConfig;
|
||||||
import static io.restassured.config.RestAssuredConfig.config;
|
import static io.restassured.config.RestAssuredConfig.config;
|
||||||
import static {{invokerPackage}}.GsonObjectMapper.gson;
|
import static {{invokerPackage}}.{{#gson}}GsonObjectMapper.gson{{/gson}}{{#jackson}}JacksonObjectMapper.jackson{{/jackson}};
|
||||||
|
|
||||||
{{/fullJavaUtil}}
|
{{/fullJavaUtil}}
|
||||||
|
|
||||||
public class ApiClient {
|
public class ApiClient {
|
||||||
@ -42,7 +43,7 @@ public class ApiClient {
|
|||||||
public static class Config {
|
public static class Config {
|
||||||
private Supplier<RequestSpecBuilder> reqSpecSupplier = () -> new RequestSpecBuilder()
|
private Supplier<RequestSpecBuilder> reqSpecSupplier = () -> new RequestSpecBuilder()
|
||||||
{{#basePath}}.setBaseUri(BASE_URI){{/basePath}}
|
{{#basePath}}.setBaseUri(BASE_URI){{/basePath}}
|
||||||
.setConfig(config().objectMapperConfig(objectMapperConfig().defaultObjectMapper(gson())));
|
.setConfig(config().objectMapperConfig(objectMapperConfig().defaultObjectMapper({{#gson}}gson(){{/gson}}{{#jackson}}jackson(){{/jackson}})));
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Use common specification for all operations
|
* Use common specification for all operations
|
||||||
|
@ -0,0 +1,64 @@
|
|||||||
|
{{>licenseInfo}}
|
||||||
|
|
||||||
|
package {{invokerPackage}};
|
||||||
|
|
||||||
|
{{#threetenbp}}
|
||||||
|
import org.threeten.bp.*;
|
||||||
|
{{/threetenbp}}
|
||||||
|
import com.fasterxml.jackson.annotation.*;
|
||||||
|
import com.fasterxml.jackson.databind.*;
|
||||||
|
import org.openapitools.jackson.nullable.JsonNullableModule;
|
||||||
|
{{#java8}}
|
||||||
|
import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule;
|
||||||
|
{{/java8}}
|
||||||
|
{{#joda}}
|
||||||
|
import com.fasterxml.jackson.datatype.joda.JodaModule;
|
||||||
|
{{/joda}}
|
||||||
|
{{#threetenbp}}
|
||||||
|
import com.fasterxml.jackson.datatype.threetenbp.ThreeTenModule;
|
||||||
|
{{/threetenbp}}
|
||||||
|
|
||||||
|
import io.restassured.internal.mapping.Jackson2Mapper;
|
||||||
|
import io.restassured.path.json.mapper.factory.Jackson2ObjectMapperFactory;
|
||||||
|
|
||||||
|
|
||||||
|
public class JacksonObjectMapper extends Jackson2Mapper {
|
||||||
|
|
||||||
|
private JacksonObjectMapper() {
|
||||||
|
super(createFactory());
|
||||||
|
}
|
||||||
|
|
||||||
|
private static Jackson2ObjectMapperFactory createFactory() {
|
||||||
|
return (cls, charset) -> {
|
||||||
|
ObjectMapper mapper = new ObjectMapper();
|
||||||
|
mapper = new ObjectMapper();
|
||||||
|
mapper.setSerializationInclusion(JsonInclude.Include.NON_NULL);
|
||||||
|
mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
|
||||||
|
mapper.configure(DeserializationFeature.FAIL_ON_INVALID_SUBTYPE, false);
|
||||||
|
mapper.disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS);
|
||||||
|
mapper.enable(SerializationFeature.WRITE_ENUMS_USING_TO_STRING);
|
||||||
|
mapper.enable(DeserializationFeature.READ_ENUMS_USING_TO_STRING);
|
||||||
|
mapper.setDateFormat(new RFC3339DateFormat());
|
||||||
|
{{#java8}}
|
||||||
|
mapper.registerModule(new JavaTimeModule());
|
||||||
|
{{/java8}}
|
||||||
|
{{#joda}}
|
||||||
|
mapper.registerModule(new JodaModule());
|
||||||
|
{{/joda}}
|
||||||
|
{{#threetenbp}}
|
||||||
|
ThreeTenModule module = new ThreeTenModule();
|
||||||
|
module.addDeserializer(Instant.class, CustomInstantDeserializer.INSTANT);
|
||||||
|
module.addDeserializer(OffsetDateTime.class, CustomInstantDeserializer.OFFSET_DATE_TIME);
|
||||||
|
module.addDeserializer(ZonedDateTime.class, CustomInstantDeserializer.ZONED_DATE_TIME);
|
||||||
|
mapper.registerModule(module);
|
||||||
|
{{/threetenbp}}
|
||||||
|
JsonNullableModule jnm = new JsonNullableModule();
|
||||||
|
mapper.registerModule(jnm);
|
||||||
|
return mapper;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
public static JacksonObjectMapper jackson() {
|
||||||
|
return new JacksonObjectMapper();
|
||||||
|
}
|
||||||
|
}
|
@ -2,7 +2,9 @@
|
|||||||
|
|
||||||
package {{package}};
|
package {{package}};
|
||||||
|
|
||||||
|
{{#gson}}
|
||||||
import com.google.gson.reflect.TypeToken;
|
import com.google.gson.reflect.TypeToken;
|
||||||
|
{{/gson}}
|
||||||
{{#imports}}import {{import}};
|
{{#imports}}import {{import}};
|
||||||
{{/imports}}
|
{{/imports}}
|
||||||
|
|
||||||
@ -15,6 +17,9 @@ import java.util.Map;
|
|||||||
import io.restassured.RestAssured;
|
import io.restassured.RestAssured;
|
||||||
import io.restassured.builder.RequestSpecBuilder;
|
import io.restassured.builder.RequestSpecBuilder;
|
||||||
import io.restassured.builder.ResponseSpecBuilder;
|
import io.restassured.builder.ResponseSpecBuilder;
|
||||||
|
{{#jackson}}
|
||||||
|
import io.restassured.common.mapper.TypeRef;
|
||||||
|
{{/jackson}}
|
||||||
import io.restassured.http.Method;
|
import io.restassured.http.Method;
|
||||||
import io.restassured.response.Response;
|
import io.restassured.response.Response;
|
||||||
import io.swagger.annotations.*;
|
import io.swagger.annotations.*;
|
||||||
@ -24,8 +29,9 @@ import java.util.function.Consumer;
|
|||||||
import java.util.function.Function;
|
import java.util.function.Function;
|
||||||
import java.util.function.Supplier;
|
import java.util.function.Supplier;
|
||||||
{{/fullJavaUtil}}
|
{{/fullJavaUtil}}
|
||||||
|
{{#gson}}
|
||||||
import {{invokerPackage}}.JSON;
|
import {{invokerPackage}}.JSON;
|
||||||
|
{{/gson}}
|
||||||
import static io.restassured.http.Method.*;
|
import static io.restassured.http.Method.*;
|
||||||
|
|
||||||
@Api(value = "{{{baseName}}}")
|
@Api(value = "{{{baseName}}}")
|
||||||
@ -139,8 +145,9 @@ public class {{classname}} {
|
|||||||
* @return {{returnType}}
|
* @return {{returnType}}
|
||||||
*/
|
*/
|
||||||
public {{{returnType}}} executeAs(Function<Response, Response> handler) {
|
public {{{returnType}}} executeAs(Function<Response, Response> handler) {
|
||||||
Type type = new TypeToken<{{{returnType}}}>(){}.getType();
|
{{#gson}}Type type = new TypeToken<{{{returnType}}}>(){}.getType();
|
||||||
return execute(handler).as(type);
|
{{/gson}}{{#jackson}}TypeRef<{{{returnType}}}> type = new TypeRef<{{{returnType}}}>(){};
|
||||||
|
{{/jackson}}return execute(handler).as(type);
|
||||||
}
|
}
|
||||||
{{/returnType}}
|
{{/returnType}}
|
||||||
{{#bodyParams}}
|
{{#bodyParams}}
|
||||||
|
@ -20,7 +20,7 @@ import java.util.Map;
|
|||||||
{{/fullJavaUtil}}
|
{{/fullJavaUtil}}
|
||||||
import static io.restassured.config.ObjectMapperConfig.objectMapperConfig;
|
import static io.restassured.config.ObjectMapperConfig.objectMapperConfig;
|
||||||
import static io.restassured.config.RestAssuredConfig.config;
|
import static io.restassured.config.RestAssuredConfig.config;
|
||||||
import static {{invokerPackage}}.GsonObjectMapper.gson;
|
import static {{invokerPackage}}.{{#gson}}GsonObjectMapper.gson{{/gson}}{{#jackson}}JacksonObjectMapper.jackson{{/jackson}};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* API tests for {{classname}}
|
* API tests for {{classname}}
|
||||||
@ -33,7 +33,8 @@ public class {{classname}}Test {
|
|||||||
@Before
|
@Before
|
||||||
public void createApi() {
|
public void createApi() {
|
||||||
api = ApiClient.api(ApiClient.Config.apiConfig().reqSpecSupplier(
|
api = ApiClient.api(ApiClient.Config.apiConfig().reqSpecSupplier(
|
||||||
() -> new RequestSpecBuilder().setConfig(config().objectMapperConfig(objectMapperConfig().defaultObjectMapper(gson())))
|
() -> new RequestSpecBuilder()
|
||||||
|
.setConfig(config().objectMapperConfig(objectMapperConfig().defaultObjectMapper({{#gson}}gson(){{/gson}}{{#jackson}}jackson(){{/jackson}})))
|
||||||
.addFilter(new ErrorLoggingFilter())
|
.addFilter(new ErrorLoggingFilter())
|
||||||
.setBaseUri("{{{basePath}}}"))).{{classVarName}}();
|
.setBaseUri("{{{basePath}}}"))).{{classVarName}}();
|
||||||
}
|
}
|
||||||
|
@ -98,8 +98,15 @@ ext {
|
|||||||
swagger_annotations_version = "1.5.21"
|
swagger_annotations_version = "1.5.21"
|
||||||
rest_assured_version = "4.0.0"
|
rest_assured_version = "4.0.0"
|
||||||
junit_version = "4.12"
|
junit_version = "4.12"
|
||||||
|
{{#jackson}}
|
||||||
|
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
|
||||||
|
{{/jackson}}
|
||||||
|
{{#gson}}
|
||||||
gson_version = "2.8.5"
|
gson_version = "2.8.5"
|
||||||
gson_fire_version = "1.8.3"
|
gson_fire_version = "1.8.3"
|
||||||
|
{{/gson}}
|
||||||
{{#joda}}
|
{{#joda}}
|
||||||
jodatime_version = "2.9.9"
|
jodatime_version = "2.9.9"
|
||||||
{{/joda}}
|
{{/joda}}
|
||||||
@ -113,10 +120,19 @@ dependencies {
|
|||||||
compile "io.swagger:swagger-annotations:$swagger_annotations_version"
|
compile "io.swagger:swagger-annotations:$swagger_annotations_version"
|
||||||
compile "com.google.code.findbugs:jsr305:3.0.2"
|
compile "com.google.code.findbugs:jsr305:3.0.2"
|
||||||
compile "io.rest-assured:scala-support:$rest_assured_version"
|
compile "io.rest-assured:scala-support:$rest_assured_version"
|
||||||
|
{{#jackson}}
|
||||||
|
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 "com.fasterxml.jackson.jaxrs:jackson-jaxrs-json-provider:$jackson_version"
|
||||||
|
compile "org.openapitools:jackson-databind-nullable:$jackson-databind-nullable-version"
|
||||||
|
{{/jackson}}
|
||||||
|
{{#gson}}
|
||||||
compile "io.gsonfire:gson-fire:$gson_fire_version"
|
compile "io.gsonfire:gson-fire:$gson_fire_version"
|
||||||
|
compile 'com.google.code.gson:gson:$gson_version'
|
||||||
|
{{/gson}}
|
||||||
{{#joda}}
|
{{#joda}}
|
||||||
compile "joda-time:joda-time:$jodatime_version"
|
compile "joda-time:joda-time:$jodatime_version"
|
||||||
compile 'com.google.code.gson:gson:$gson_version'
|
|
||||||
{{/joda}}
|
{{/joda}}
|
||||||
{{#threetenbp}}
|
{{#threetenbp}}
|
||||||
compile "org.threeten:threetenbp:$threetenbp_version"
|
compile "org.threeten:threetenbp:$threetenbp_version"
|
||||||
|
@ -11,8 +11,15 @@ lazy val root = (project in file(".")).
|
|||||||
libraryDependencies ++= Seq(
|
libraryDependencies ++= Seq(
|
||||||
"io.swagger" % "swagger-annotations" % "1.5.21",
|
"io.swagger" % "swagger-annotations" % "1.5.21",
|
||||||
"io.rest-assured" % "scala-support" % "4.0.0",
|
"io.rest-assured" % "scala-support" % "4.0.0",
|
||||||
|
{{#jackson}}
|
||||||
|
"com.fasterxml.jackson.core" % "jackson-core" % "2.9.9" % "compile",
|
||||||
|
"com.fasterxml.jackson.core" % "jackson-annotations" % "2.9.9" % "compile",
|
||||||
|
"com.fasterxml.jackson.core" % "jackson-databind" % "2.9.9" % "compile",
|
||||||
|
{{/jackson}}
|
||||||
|
{{#gson}}
|
||||||
"com.google.code.gson" % "gson" % "2.8.5",
|
"com.google.code.gson" % "gson" % "2.8.5",
|
||||||
"io.gsonfire" % "gson-fire" % "1.8.3" % "compile",
|
"io.gsonfire" % "gson-fire" % "1.8.3" % "compile",
|
||||||
|
{{/gson}}
|
||||||
{{#joda}}
|
{{#joda}}
|
||||||
"joda-time" % "joda-time" % "2.9.9" % "compile",
|
"joda-time" % "joda-time" % "2.9.9" % "compile",
|
||||||
{{/joda}}
|
{{/joda}}
|
||||||
|
@ -217,11 +217,13 @@
|
|||||||
<artifactId>rest-assured</artifactId>
|
<artifactId>rest-assured</artifactId>
|
||||||
<version>${rest-assured.version}</version>
|
<version>${rest-assured.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
{{#gson}}
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.google.code.gson</groupId>
|
<groupId>com.google.code.gson</groupId>
|
||||||
<artifactId>gson</artifactId>
|
<artifactId>gson</artifactId>
|
||||||
<version>${gson-version}</version>
|
<version>${gson-version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
{{/gson}}
|
||||||
{{#joda}}
|
{{#joda}}
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>joda-time</groupId>
|
<groupId>joda-time</groupId>
|
||||||
@ -236,16 +238,69 @@
|
|||||||
<version>${threetenbp-version}</version>
|
<version>${threetenbp-version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
{{/threetenbp}}
|
{{/threetenbp}}
|
||||||
|
{{#gson}}
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>io.gsonfire</groupId>
|
<groupId>io.gsonfire</groupId>
|
||||||
<artifactId>gson-fire</artifactId>
|
<artifactId>gson-fire</artifactId>
|
||||||
<version>${gson-fire-version}</version>
|
<version>${gson-fire-version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
{{/gson}}
|
||||||
<groupId>com.squareup.okio</groupId>
|
{{#jackson}}
|
||||||
<artifactId>okio</artifactId>
|
<!-- JSON processing: jackson -->
|
||||||
<version>${okio-version}</version>
|
<dependency>
|
||||||
</dependency>
|
<groupId>com.fasterxml.jackson.core</groupId>
|
||||||
|
<artifactId>jackson-core</artifactId>
|
||||||
|
<version>${jackson-version}</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.fasterxml.jackson.core</groupId>
|
||||||
|
<artifactId>jackson-annotations</artifactId>
|
||||||
|
<version>${jackson-version}</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.fasterxml.jackson.core</groupId>
|
||||||
|
<artifactId>jackson-databind</artifactId>
|
||||||
|
<version>${jackson-databind-version}</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.openapitools</groupId>
|
||||||
|
<artifactId>jackson-databind-nullable</artifactId>
|
||||||
|
<version>${jackson-databind-nullable-version}</version>
|
||||||
|
</dependency>
|
||||||
|
{{#withXml}}
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.fasterxml.jackson.dataformat</groupId>
|
||||||
|
<artifactId>jackson-dataformat-xml</artifactId>
|
||||||
|
<version>${jackson-version}</version>
|
||||||
|
</dependency>
|
||||||
|
{{/withXml}}
|
||||||
|
{{#joda}}
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.fasterxml.jackson.datatype</groupId>
|
||||||
|
<artifactId>jackson-datatype-joda</artifactId>
|
||||||
|
<version>${jackson-version}</version>
|
||||||
|
</dependency>
|
||||||
|
{{/joda}}
|
||||||
|
{{#java8}}
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.fasterxml.jackson.datatype</groupId>
|
||||||
|
<artifactId>jackson-datatype-jsr310</artifactId>
|
||||||
|
<version>${jackson-version}</version>
|
||||||
|
</dependency>
|
||||||
|
{{/java8}}
|
||||||
|
{{#threetenbp}}
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.github.joschi.jackson</groupId>
|
||||||
|
<artifactId>jackson-datatype-threetenbp</artifactId>
|
||||||
|
<version>${jackson-threetenbp-version}</version>
|
||||||
|
</dependency>
|
||||||
|
{{/threetenbp}}
|
||||||
|
{{/jackson}}
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.squareup.okio</groupId>
|
||||||
|
<artifactId>okio</artifactId>
|
||||||
|
<version>${okio-version}</version>
|
||||||
|
</dependency>
|
||||||
<!-- test dependencies -->
|
<!-- test dependencies -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>junit</groupId>
|
<groupId>junit</groupId>
|
||||||
@ -267,6 +322,14 @@
|
|||||||
{{#threetenbp}}
|
{{#threetenbp}}
|
||||||
<threetenbp-version>1.3.8</threetenbp-version>
|
<threetenbp-version>1.3.8</threetenbp-version>
|
||||||
{{/threetenbp}}
|
{{/threetenbp}}
|
||||||
|
{{#jackson}}
|
||||||
|
<jackson-version>2.9.9</jackson-version>
|
||||||
|
<jackson-databind-version>2.9.9</jackson-databind-version>
|
||||||
|
<jackson-databind-nullable-version>0.2.0</jackson-databind-nullable-version>
|
||||||
|
{{#threetenbp}}
|
||||||
|
<jackson-threetenbp-version>2.6.4</jackson-threetenbp-version>
|
||||||
|
{{/threetenbp}}
|
||||||
|
{{/jackson}}
|
||||||
<okio-version>1.13.0</okio-version>
|
<okio-version>1.13.0</okio-version>
|
||||||
<junit-version>4.12</junit-version>
|
<junit-version>4.12</junit-version>
|
||||||
</properties>
|
</properties>
|
||||||
|
@ -121,6 +121,7 @@ ext {
|
|||||||
swagger_annotations_version = "1.5.22"
|
swagger_annotations_version = "1.5.22"
|
||||||
jackson_version = "2.9.9"
|
jackson_version = "2.9.9"
|
||||||
jackson_databind_version = "2.9.9"
|
jackson_databind_version = "2.9.9"
|
||||||
|
jackson-databind-nullable-version = "0.2.0"
|
||||||
threetenbp_version = "2.6.4"
|
threetenbp_version = "2.6.4"
|
||||||
resteasy_version = "3.1.3.Final"
|
resteasy_version = "3.1.3.Final"
|
||||||
{{^java8}}
|
{{^java8}}
|
||||||
@ -143,6 +144,7 @@ dependencies {
|
|||||||
compile "com.fasterxml.jackson.core:jackson-annotations:$jackson_version"
|
compile "com.fasterxml.jackson.core:jackson-annotations:$jackson_version"
|
||||||
compile "com.fasterxml.jackson.core:jackson-databind:$jackson_databind_version"
|
compile "com.fasterxml.jackson.core:jackson-databind:$jackson_databind_version"
|
||||||
compile "com.github.joschi.jackson:jackson-datatype-threetenbp:$threetenbp_version"
|
compile "com.github.joschi.jackson:jackson-datatype-threetenbp:$threetenbp_version"
|
||||||
|
compile "org.openapitools:jackson-databind-nullable:$jackson-databind-nullable-version"
|
||||||
{{#java8}}
|
{{#java8}}
|
||||||
compile "com.fasterxml.jackson.datatype:jackson-datatype-jsr310:$jackson_version"
|
compile "com.fasterxml.jackson.datatype:jackson-datatype-jsr310:$jackson_version"
|
||||||
{{/java8}}
|
{{/java8}}
|
||||||
|
@ -122,6 +122,7 @@ ext {
|
|||||||
swagger_annotations_version = "1.5.22"
|
swagger_annotations_version = "1.5.22"
|
||||||
jackson_version = "2.9.9"
|
jackson_version = "2.9.9"
|
||||||
jackson_databind_version = "2.9.9"
|
jackson_databind_version = "2.9.9"
|
||||||
|
jackson-databind-nullable-version = "0.2.0"
|
||||||
spring_web_version = "4.3.9.RELEASE"
|
spring_web_version = "4.3.9.RELEASE"
|
||||||
jodatime_version = "2.9.9"
|
jodatime_version = "2.9.9"
|
||||||
junit_version = "4.12"
|
junit_version = "4.12"
|
||||||
@ -138,6 +139,7 @@ dependencies {
|
|||||||
compile "com.fasterxml.jackson.core:jackson-annotations:$jackson_version"
|
compile "com.fasterxml.jackson.core:jackson-annotations:$jackson_version"
|
||||||
compile "com.fasterxml.jackson.core:jackson-databind:$jackson_databind_version"
|
compile "com.fasterxml.jackson.core:jackson-databind:$jackson_databind_version"
|
||||||
compile "com.fasterxml.jackson.jaxrs:jackson-jaxrs-json-provider:$jackson_version"
|
compile "com.fasterxml.jackson.jaxrs:jackson-jaxrs-json-provider:$jackson_version"
|
||||||
|
compile "org.openapitools:jackson-databind-nullable:$jackson-databind-nullable-version"
|
||||||
{{#java8}}
|
{{#java8}}
|
||||||
compile "com.fasterxml.jackson.datatype:jackson-datatype-jsr310:$jackson_version"
|
compile "com.fasterxml.jackson.datatype:jackson-datatype-jsr310:$jackson_version"
|
||||||
{{/java8}}
|
{{/java8}}
|
||||||
|
@ -133,6 +133,7 @@ ext {
|
|||||||
{{#play26}}
|
{{#play26}}
|
||||||
jackson_version = "2.9.9"
|
jackson_version = "2.9.9"
|
||||||
jackson_databind_version = "2.9.9"
|
jackson_databind_version = "2.9.9"
|
||||||
|
jackson-databind-nullable-version = "0.2.0"
|
||||||
play_version = "2.6.7"
|
play_version = "2.6.7"
|
||||||
{{/play26}}
|
{{/play26}}
|
||||||
{{/usePlayWS}}
|
{{/usePlayWS}}
|
||||||
@ -189,6 +190,7 @@ dependencies {
|
|||||||
compile "com.fasterxml.jackson.core:jackson-core:$jackson_version"
|
compile "com.fasterxml.jackson.core:jackson-core:$jackson_version"
|
||||||
compile "com.fasterxml.jackson.core:jackson-annotations:$jackson_version"
|
compile "com.fasterxml.jackson.core:jackson-annotations:$jackson_version"
|
||||||
compile "com.fasterxml.jackson.core:jackson-databind:$jackson_databind_version"
|
compile "com.fasterxml.jackson.core:jackson-databind:$jackson_databind_version"
|
||||||
|
compile "org.openapitools:jackson-databind-nullable:$jackson-databind-nullable-version"
|
||||||
compile "com.fasterxml.jackson.datatype:jackson-datatype-{{^java8}}joda{{/java8}}{{#java8}}jsr310{{/java8}}:$jackson_version"
|
compile "com.fasterxml.jackson.datatype:jackson-datatype-{{^java8}}joda{{/java8}}{{#java8}}jsr310{{/java8}}:$jackson_version"
|
||||||
{{/usePlayWS}}
|
{{/usePlayWS}}
|
||||||
|
|
||||||
|
@ -20,6 +20,7 @@ import {{import}};
|
|||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
{{/serializableModel}}
|
{{/serializableModel}}
|
||||||
{{#jackson}}
|
{{#jackson}}
|
||||||
|
import com.fasterxml.jackson.annotation.JsonPropertyOrder;
|
||||||
{{#withXml}}
|
{{#withXml}}
|
||||||
import com.fasterxml.jackson.dataformat.xml.annotation.*;
|
import com.fasterxml.jackson.dataformat.xml.annotation.*;
|
||||||
{{/withXml}}
|
{{/withXml}}
|
||||||
|
@ -56,7 +56,7 @@
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public {{#datatypeWithEnum}}{{{.}}}{{/datatypeWithEnum}}{{^datatypeWithEnum}}{{classname}}{{/datatypeWithEnum}} read(final JsonReader jsonReader) throws IOException {
|
public {{#datatypeWithEnum}}{{{.}}}{{/datatypeWithEnum}}{{^datatypeWithEnum}}{{classname}}{{/datatypeWithEnum}} read(final JsonReader jsonReader) throws IOException {
|
||||||
{{^isNumber}}{{{dataType}}}{{/isNumber}}{{#isNumber}}String{{/isNumber}} value = jsonReader.{{#isNumber}}nextString(){{/isNumber}}{{#isInteger}}nextInt(){{/isInteger}}{{^isNumber}}{{^isInteger}}next{{{dataType}}}(){{/isInteger}}{{/isNumber}};
|
{{^isNumber}}{{{dataType}}}{{/isNumber}}{{#isNumber}}String{{/isNumber}} value = {{#isFloat}}(float){{/isFloat}} jsonReader.{{#isNumber}}nextString(){{/isNumber}}{{#isInteger}}nextInt(){{/isInteger}}{{^isNumber}}{{^isInteger}}{{#isFloat}}nextDouble{{/isFloat}}{{^isFloat}}next{{{dataType}}}{{/isFloat}}(){{/isInteger}}{{/isNumber}};
|
||||||
return {{#datatypeWithEnum}}{{{.}}}{{/datatypeWithEnum}}{{^datatypeWithEnum}}{{classname}}{{/datatypeWithEnum}}.fromValue({{#isNumber}}new BigDecimal({{/isNumber}}value{{#isNumber}}){{/isNumber}});
|
return {{#datatypeWithEnum}}{{{.}}}{{/datatypeWithEnum}}{{^datatypeWithEnum}}{{classname}}{{/datatypeWithEnum}}.fromValue({{#isNumber}}new BigDecimal({{/isNumber}}value{{#isNumber}}){{/isNumber}});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2,6 +2,13 @@
|
|||||||
* {{#description}}{{.}}{{/description}}{{^description}}{{classname}}{{/description}}
|
* {{#description}}{{.}}{{/description}}{{^description}}{{classname}}{{/description}}
|
||||||
*/{{#description}}
|
*/{{#description}}
|
||||||
@ApiModel(description = "{{{description}}}"){{/description}}
|
@ApiModel(description = "{{{description}}}"){{/description}}
|
||||||
|
{{#jackson}}
|
||||||
|
@JsonPropertyOrder({
|
||||||
|
{{#vars}}
|
||||||
|
{{classname}}.JSON_PROPERTY_{{nameInSnakeCase}}{{^-last}},{{/-last}}
|
||||||
|
{{/vars}}
|
||||||
|
})
|
||||||
|
{{/jackson}}
|
||||||
{{>generatedAnnotation}}{{#discriminator}}{{>typeInfoAnnotation}}{{/discriminator}}{{>xmlAnnotation}}
|
{{>generatedAnnotation}}{{#discriminator}}{{>typeInfoAnnotation}}{{/discriminator}}{{>xmlAnnotation}}
|
||||||
public class {{classname}} {{#parent}}extends {{{parent}}} {{/parent}}{{#parcelableModel}}implements Parcelable {{#serializableModel}}, Serializable {{/serializableModel}}{{/parcelableModel}}{{^parcelableModel}}{{#serializableModel}}implements Serializable {{/serializableModel}}{{/parcelableModel}}{
|
public class {{classname}} {{#parent}}extends {{{parent}}} {{/parent}}{{#parcelableModel}}implements Parcelable {{#serializableModel}}, Serializable {{/serializableModel}}{{/parcelableModel}}{{^parcelableModel}}{{#serializableModel}}implements Serializable {{/serializableModel}}{{/parcelableModel}}{
|
||||||
{{#serializableModel}}
|
{{#serializableModel}}
|
||||||
|
@ -10,6 +10,9 @@ import org.apache.commons.lang3.ObjectUtils;
|
|||||||
{{/supportJava6}}
|
{{/supportJava6}}
|
||||||
{{#imports}}import {{import}};
|
{{#imports}}import {{import}};
|
||||||
{{/imports}}
|
{{/imports}}
|
||||||
|
{{#jackson}}
|
||||||
|
import com.fasterxml.jackson.annotation.JsonPropertyOrder;
|
||||||
|
{{/jackson}}
|
||||||
{{#serializableModel}}
|
{{#serializableModel}}
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
{{/serializableModel}}
|
{{/serializableModel}}
|
||||||
|
@ -2,6 +2,13 @@
|
|||||||
* {{#description}}{{.}}{{/description}}{{^description}}{{classname}}{{/description}}
|
* {{#description}}{{.}}{{/description}}{{^description}}{{classname}}{{/description}}
|
||||||
*/{{#description}}
|
*/{{#description}}
|
||||||
@ApiModel(description = "{{{description}}}"){{/description}}
|
@ApiModel(description = "{{{description}}}"){{/description}}
|
||||||
|
{{#jackson}}
|
||||||
|
@JsonPropertyOrder({
|
||||||
|
{{#vars}}
|
||||||
|
{{classname}}.JSON_PROPERTY_{{nameInSnakeCase}}{{^-last}},{{/-last}}
|
||||||
|
{{/vars}}
|
||||||
|
})
|
||||||
|
{{/jackson}}
|
||||||
{{>generatedAnnotation}}{{#discriminator}}{{>typeInfoAnnotation}}{{/discriminator}}
|
{{>generatedAnnotation}}{{#discriminator}}{{>typeInfoAnnotation}}{{/discriminator}}
|
||||||
public class {{classname}} {{#parent}}extends {{{parent}}}{{/parent}} {{#serializableModel}}implements Serializable{{/serializableModel}} {
|
public class {{classname}} {{#parent}}extends {{{parent}}}{{/parent}} {{#serializableModel}}implements Serializable{{/serializableModel}} {
|
||||||
{{#vars}}
|
{{#vars}}
|
||||||
|
@ -1 +1 @@
|
|||||||
{{#isQueryParam}}{{#useBeanValidation}}{{>beanValidationQueryParams}}{{/useBeanValidation}}@ApiParam(value = "{{{description}}}"{{#required}}, required = true{{/required}}{{#allowableValues}}, allowableValues = "{{#values}}{{{.}}}{{^-last}}, {{/-last}}{{#-last}}{{/-last}}{{/values}}"{{/allowableValues}}{{^isContainer}}{{#defaultValue}}, defaultValue = {{^isString}}"{{/isString}}{{#isString}}{{#isEnum}}"{{/isEnum}}{{/isString}}{{{defaultValue}}}{{^isString}}"{{/isString}}{{#isString}}{{#isEnum}}"{{/isEnum}}{{/isString}}{{/defaultValue}}{{/isContainer}}) {{#useBeanValidation}}@Valid{{/useBeanValidation}}{{^isModel}} @RequestParam(value = "{{baseName}}"{{#required}}, required = true{{/required}}{{^required}}, required = false{{/required}}{{^isContainer}}{{#defaultValue}}, defaultValue={{^isString}}"{{/isString}}{{#isString}}{{#isEnum}}"{{/isEnum}}{{/isString}}{{{defaultValue}}}{{^isString}}"{{/isString}}{{#isString}}{{#isEnum}}"{{/isEnum}}{{/isString}}{{/defaultValue}}{{/isContainer}}){{/isModel}} {{>optionalDataType}} {{paramName}}{{/isQueryParam}}
|
{{#isQueryParam}}{{#useBeanValidation}}{{>beanValidationQueryParams}}{{/useBeanValidation}}@ApiParam(value = "{{{description}}}"{{#required}}, required = true{{/required}}{{#allowableValues}}, allowableValues = "{{#values}}{{{.}}}{{^-last}}, {{/-last}}{{#-last}}{{/-last}}{{/values}}"{{/allowableValues}}{{^isContainer}}{{#defaultValue}}, defaultValue = {{^isString}}"{{/isString}}{{#isString}}{{#isEnum}}"{{/isEnum}}{{/isString}}{{{defaultValue}}}{{^isString}}"{{/isString}}{{#isString}}{{#isEnum}}"{{/isEnum}}{{/isString}}{{/defaultValue}}{{/isContainer}}) {{#useBeanValidation}}@Valid{{/useBeanValidation}}{{^isModel}} @RequestParam(value = "{{baseName}}"{{#required}}, required = true{{/required}}{{^required}}, required = false{{/required}}{{^isContainer}}{{#defaultValue}}, defaultValue={{^isString}}"{{/isString}}{{#isString}}{{#isEnum}}"{{/isEnum}}{{/isString}}{{{defaultValue}}}{{^isString}}"{{/isString}}{{#isString}}{{#isEnum}}"{{/isEnum}}{{/isString}}{{/defaultValue}}{{/isContainer}}){{/isModel}}{{#isDate}} @org.springframework.format.annotation.DateTimeFormat(iso = org.springframework.format.annotation.DateTimeFormat.ISO.DATE){{/isDate}}{{#isDateTime}} @org.springframework.format.annotation.DateTimeFormat(iso = org.springframework.format.annotation.DateTimeFormat.ISO.DATE_TIME){{/isDateTime}} {{>optionalDataType}} {{paramName}}{{/isQueryParam}}
|
@ -14,7 +14,7 @@
|
|||||||
<java.version>1.8</java.version>
|
<java.version>1.8</java.version>
|
||||||
<junit.version>4.12</junit.version>
|
<junit.version>4.12</junit.version>
|
||||||
<vertx.version>3.4.1</vertx.version>
|
<vertx.version>3.4.1</vertx.version>
|
||||||
<maven-compiler-plugin.version>3.3</maven-compiler-plugin.version>
|
<maven-compiler-plugin.version>3.8.1</maven-compiler-plugin.version>
|
||||||
<vertx-swagger-router.version>{{vertxSwaggerRouterVersion}}</vertx-swagger-router.version>
|
<vertx-swagger-router.version>{{vertxSwaggerRouterVersion}}</vertx-swagger-router.version>
|
||||||
<maven-shade-plugin.version>2.3</maven-shade-plugin.version>
|
<maven-shade-plugin.version>2.3</maven-shade-plugin.version>
|
||||||
<jackson-datatype-jsr310.version>2.7.4</jackson-datatype-jsr310.version>
|
<jackson-datatype-jsr310.version>2.7.4</jackson-datatype-jsr310.version>
|
||||||
|
@ -1,11 +1,17 @@
|
|||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
# ref: https://help.github.com/articles/adding-an-existing-project-to-github-using-the-command-line/
|
# ref: https://help.github.com/articles/adding-an-existing-project-to-github-using-the-command-line/
|
||||||
#
|
#
|
||||||
# Usage example: /bin/sh ./git_push.sh wing328 openapi-pestore-perl "minor update"
|
# Usage example: /bin/sh ./git_push.sh wing328 openapi-pestore-perl "minor update" "gitlab.com"
|
||||||
|
|
||||||
git_user_id=$1
|
git_user_id=$1
|
||||||
git_repo_id=$2
|
git_repo_id=$2
|
||||||
release_note=$3
|
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
|
if [ "$git_user_id" = "" ]; then
|
||||||
git_user_id="{{{gitUserId}}}"
|
git_user_id="{{{gitUserId}}}"
|
||||||
@ -28,7 +34,7 @@ git init
|
|||||||
# Adds the files in the local repository and stages them for commit.
|
# Adds the files in the local repository and stages them for commit.
|
||||||
git add .
|
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"
|
git commit -m "$release_note"
|
||||||
|
|
||||||
# Sets the new remote
|
# Sets the new remote
|
||||||
@ -36,10 +42,10 @@ git_remote=`git remote`
|
|||||||
if [ "$git_remote" = "" ]; then # git remote not defined
|
if [ "$git_remote" = "" ]; then # git remote not defined
|
||||||
|
|
||||||
if [ "$GIT_TOKEN" = "" ]; then
|
if [ "$GIT_TOKEN" = "" ]; then
|
||||||
echo "[INFO] \$GIT_TOKEN (environment variable) is not set. Using the Git credential in your environment."
|
echo "[INFO] \$GIT_TOKEN (environment variable) is not set. Using the git credential in your environment."
|
||||||
git remote add origin https://github.com/${git_user_id}/${git_repo_id}.git
|
git remote add origin https://${git_host}/${git_user_id}/${git_repo_id}.git
|
||||||
else
|
else
|
||||||
git remote add origin https://${git_user_id}:${GIT_TOKEN}@github.com/${git_user_id}/${git_repo_id}.git
|
git remote add origin https://${git_user_id}:${GIT_TOKEN}@${git_host}/${git_user_id}/${git_repo_id}.git
|
||||||
fi
|
fi
|
||||||
|
|
||||||
fi
|
fi
|
||||||
@ -47,6 +53,6 @@ fi
|
|||||||
git pull origin master
|
git pull origin master
|
||||||
|
|
||||||
# Pushes (Forces) the changes in the local repository up to the remote repository
|
# Pushes (Forces) the changes in the local repository up to the remote repository
|
||||||
echo "Git pushing to https://github.com/${git_user_id}/${git_repo_id}.git"
|
echo "Git pushing to https://${git_host}/${git_user_id}/${git_repo_id}.git"
|
||||||
git push origin master 2>&1 | grep -v 'To https'
|
git push origin master 2>&1 | grep -v 'To https'
|
||||||
|
|
||||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user