forked from loafle/openapi-generator-original
Compare commits
101 Commits
v4.1.2
...
swift_null
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
cfeff0c31c | ||
|
|
d933a69aed | ||
|
|
8b2e25e4da | ||
|
|
0c8481b8c7 | ||
|
|
213efd8e84 | ||
|
|
0029d9aa91 | ||
|
|
d4500b307f | ||
|
|
f955966b09 | ||
|
|
711a210423 | ||
|
|
f13043e433 | ||
|
|
08a5e81797 | ||
|
|
83d64b7e38 | ||
|
|
60567bddd6 | ||
|
|
cc1bfe5fef | ||
|
|
0ebc2f720e | ||
|
|
ebc9e291c3 | ||
|
|
7c7fa68737 | ||
|
|
5c24a54173 | ||
|
|
2b72df2135 | ||
|
|
88ed52fa88 | ||
|
|
c136b83bdb | ||
|
|
2272743c1d | ||
|
|
0c7820ccbe | ||
|
|
41acae19e4 | ||
|
|
8383f26616 | ||
|
|
cb38de9afa | ||
|
|
baa53cbf57 | ||
|
|
31827f5f35 | ||
|
|
af9eb8d7da | ||
|
|
9ae49db670 | ||
|
|
d2b299860d | ||
|
|
243589ec80 | ||
|
|
44f482f21a | ||
|
|
c8ac41c051 | ||
|
|
775d96c8e6 | ||
|
|
7a95c9e20d | ||
|
|
600a81f76e | ||
|
|
7dbda049f0 | ||
|
|
c8d5701089 | ||
|
|
b5fb92d5a8 | ||
|
|
8212e80d0e | ||
|
|
5dcd959f30 | ||
|
|
8293902134 | ||
|
|
0bf9926066 | ||
|
|
e901132ea9 | ||
|
|
7bb3579345 | ||
|
|
eb793ae279 | ||
|
|
5f6e53fc60 | ||
|
|
2664c628a3 | ||
|
|
078d7a38c0 | ||
|
|
af74f3443f | ||
|
|
cb5720e4d7 | ||
|
|
4317ac0297 | ||
|
|
bd992a4218 | ||
|
|
e20af77944 | ||
|
|
8408232d1a | ||
|
|
252c3e58be | ||
|
|
002da8d9f9 | ||
|
|
85b4ddea39 | ||
|
|
81fdc2abbd | ||
|
|
431aba8747 | ||
|
|
6f1b8ef658 | ||
|
|
b867a6c3d5 | ||
|
|
1a55020194 | ||
|
|
3019b5a5e1 | ||
|
|
ee2e4395a9 | ||
|
|
91a610ec0e | ||
|
|
21e0e0d5d5 | ||
|
|
0ea1ead59e | ||
|
|
aadaac7e17 | ||
|
|
b793a95765 | ||
|
|
5610610d44 | ||
|
|
1dfa61231c | ||
|
|
0b6dfdcd99 | ||
|
|
3fe0281d3b | ||
|
|
ba7fc2396b | ||
|
|
3f9d1b1fec | ||
|
|
a8826816fb | ||
|
|
667a6097b5 | ||
|
|
4538db92a2 | ||
|
|
9647416032 | ||
|
|
2ac46eda9f | ||
|
|
334d0dcb48 | ||
|
|
87dce1bfe1 | ||
|
|
8f43373948 | ||
|
|
e0b56502a3 | ||
|
|
8055231400 | ||
|
|
ec5df2e1c0 | ||
|
|
95c4a05b70 | ||
|
|
f15f814d9b | ||
|
|
f27ff79e93 | ||
|
|
763e7a0c14 | ||
|
|
e56bfe4af3 | ||
|
|
dc2907aced | ||
|
|
3242949e1a | ||
|
|
ea029b4029 | ||
|
|
68967b8705 | ||
|
|
3e6b72bcde | ||
|
|
9182784955 | ||
|
|
e5912b4925 | ||
|
|
01222268e8 |
2
.gitignore
vendored
2
.gitignore
vendored
@@ -174,6 +174,7 @@ samples/client/petstore/python-tornado/.venv/
|
||||
samples/client/petstore/typescript-angular2/npm/npm-debug.log
|
||||
samples/client/petstore/typescript-node/npm/npm-debug.log
|
||||
samples/client/petstore/typescript-angular/tsd-debug.log
|
||||
samples/client/petstore/typescript-fetch/tests/**/dist/
|
||||
|
||||
# aspnetcore
|
||||
samples/server/petstore/aspnetcore/.vs/
|
||||
@@ -186,6 +187,7 @@ samples/client/petstore/kotlin-string/build
|
||||
samples/openapi3/client/petstore/kotlin/build
|
||||
samples/server/petstore/kotlin-server/ktor/build
|
||||
samples/server/petstore/kotlin-springboot/build
|
||||
samples/client/petstore/kotlin-multiplatform/build/
|
||||
\?
|
||||
|
||||
# haskell
|
||||
|
||||
@@ -13,7 +13,7 @@ steps:
|
||||
commands:
|
||||
- (cd samples/client/petstore/dart-jaguar/openapi && pub get && pub run build_runner build --delete-conflicting-outputs)
|
||||
- (cd samples/client/petstore/dart-jaguar/flutter_petstore/openapi && pub get && pub run build_runner build --delete-conflicting-outputs)
|
||||
- (cd samples/client/petstore/dart2/openapi && pub get && pub run test)
|
||||
- (cd samples/client/petstore/dart2/petstore && pub get && pub run test)
|
||||
# test Java 11 HTTP client
|
||||
- name: java11-test
|
||||
image: openjdk:11.0
|
||||
|
||||
42
README.md
42
README.md
@@ -2,7 +2,7 @@
|
||||
|
||||
<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://app.shippable.com/github/OpenAPITools/openapi-generator)
|
||||
[](https://ci.appveyor.com/project/WilliamCheng/openapi-generator-wh2wu)
|
||||
@@ -65,9 +65,9 @@ OpenAPI Generator allows generation of API client libraries (SDK generation), se
|
||||
|
||||
| | Languages/Frameworks |
|
||||
|-|-|
|
||||
**API clients** | **ActionScript**, **Ada**, **Apex**, **Bash**, **C**, **C#** (.net 2.0, 3.5 or later, .NET Standard 1.3 - 2.0, .NET Core 2.0), **C++** (cpp-restsdk, Qt5, Tizen), **Clojure**, **Dart (1.x, 2.x)**, **Elixir**, **Elm**, **Eiffel**, **Erlang**, **Go**, **Groovy**, **Haskell** (http-client, Servant), **Java** (Jersey1.x, Jersey2.x, OkHttp, Retrofit1.x, Retrofit2.x, Feign, RestTemplate, RESTEasy, Vertx, Google API Client Library for Java, Rest-assured, Spring 5 Web Client), **Kotlin**, **Lua**, **Node.js/JavaScript** (ES5, ES6, AngularJS with Google Closure Compiler annotations, Flow types), **Objective-C**, **OCaml**, **Perl**, **PHP**, **PowerShell**, **Python**, **R**, **Ruby**, **Rust** (rust, rust-server), **Scala** (akka, http4s, scalaz, swagger-async-httpclient), **Swift** (2.x, 3.x, 4.x), **Typescript** (AngularJS, Angular (2.x - 8.x), Aurelia, Axios, Fetch, Inversify, jQuery, Node, Rxjs)
|
||||
**Server stubs** | **Ada**, **C#** (ASP.NET Core, NancyFx), **C++** (Pistache, Restbed, Qt5 QHTTPEngine), **Erlang**, **F#** (Giraffe), **Go** (net/http, Gin), **Haskell** (Servant), **Java** (MSF4J, Spring, Undertow, JAX-RS: CDI, CXF, Inflector, Jersey, RestEasy, Play Framework, [PKMST](https://github.com/ProKarma-Inc/pkmst-getting-started-examples)), **Kotlin** (Spring Boot, Ktor), **PHP** (Laravel, Lumen, Slim, Silex, [Symfony](https://symfony.com/), [Zend Expressive](https://github.com/zendframework/zend-expressive)), **Python** (Flask), **NodeJS**, **Ruby** (Sinatra, Rails5), **Rust** (rust-server), **Scala** ([Finch](https://github.com/finagle/finch), [Lagom](https://github.com/lagom/lagom), [Play](https://www.playframework.com/), Scalatra)
|
||||
**API documentation generators** | **HTML**, **Confluence Wiki**
|
||||
**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, 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**, **Asciidoc**
|
||||
**Configuration files** | [**Apache2**](https://httpd.apache.org/)
|
||||
**Others** | **GraphQL**, **JMeter**, **MySQL Schema**, **Protocol Buffer**
|
||||
|
||||
@@ -109,7 +109,7 @@ OpenAPI Generator Version | Release Date | Notes
|
||||
5.0.0 (upcoming major release) [SNAPSHOT](https://oss.sonatype.org/content/repositories/snapshots/org/openapitools/openapi-generator-cli/5.0.0-SNAPSHOT/)| 13.05.2020 | Major release with breaking changes (no fallback)
|
||||
4.2.0 (upcoming minor release) [SNAPSHOT](https://oss.sonatype.org/content/repositories/snapshots/org/openapitools/openapi-generator-cli/4.2.0-SNAPSHOT/)| 09.10.2019 | Minor release (breaking changes with fallbacks)
|
||||
4.1.3 (upcoming minor release) [SNAPSHOT](https://oss.sonatype.org/content/repositories/snapshots/org/openapitools/openapi-generator-cli/4.1.3-SNAPSHOT/)| 30.09.2019 | Patch release (bug fixes, enhancements)
|
||||
[4.1.2](https://github.com/OpenAPITools/openapi-generator/releases/tag/v4.1.2) (latest stable release) | 11.09.2019 | Minor release (breaking changes with fallbacks)
|
||||
[4.1.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
|
||||
|
||||
@@ -165,16 +165,16 @@ See the different versions of the [openapi-generator-cli](https://mvnrepository.
|
||||
<!-- RELEASE_VERSION -->
|
||||
If you're looking for the latest stable version, you can grab it directly from Maven.org (Java 8 runtime at a minimum):
|
||||
|
||||
JAR location: `http://central.maven.org/maven2/org/openapitools/openapi-generator-cli/4.1.1/openapi-generator-cli-4.1.1.jar`
|
||||
JAR location: `http://central.maven.org/maven2/org/openapitools/openapi-generator-cli/4.1.3/openapi-generator-cli-4.1.3.jar`
|
||||
|
||||
For **Mac/Linux** users:
|
||||
```sh
|
||||
wget http://central.maven.org/maven2/org/openapitools/openapi-generator-cli/4.1.1/openapi-generator-cli-4.1.1.jar -O openapi-generator-cli.jar
|
||||
wget http://central.maven.org/maven2/org/openapitools/openapi-generator-cli/4.1.3/openapi-generator-cli-4.1.3.jar -O openapi-generator-cli.jar
|
||||
```
|
||||
|
||||
For **Windows** users, you will need to install [wget](http://gnuwin32.sourceforge.net/packages/wget.htm) or you can use Invoke-WebRequest in PowerShell (3.0+), e.g.
|
||||
```
|
||||
Invoke-WebRequest -OutFile openapi-generator-cli.jar http://central.maven.org/maven2/org/openapitools/openapi-generator-cli/4.1.1/openapi-generator-cli-4.1.1.jar
|
||||
Invoke-WebRequest -OutFile openapi-generator-cli.jar http://central.maven.org/maven2/org/openapitools/openapi-generator-cli/4.1.3/openapi-generator-cli-4.1.3.jar
|
||||
```
|
||||
|
||||
After downloading the JAR, run `java -jar openapi-generator-cli.jar help` to show the usage.
|
||||
@@ -389,10 +389,10 @@ openapi-generator version
|
||||
```
|
||||
|
||||
<!-- RELEASE_VERSION -->
|
||||
Or install a particular OpenAPI Generator version (e.g. v4.1.1):
|
||||
Or install a particular OpenAPI Generator version (e.g. v4.1.3):
|
||||
|
||||
```sh
|
||||
npm install @openapitools/openapi-generator-cli@cli-4.1.1 -g
|
||||
npm install @openapitools/openapi-generator-cli@cli-4.1.3 -g
|
||||
```
|
||||
|
||||
Or install it as dev-dependency:
|
||||
@@ -416,7 +416,7 @@ java -jar modules/openapi-generator-cli/target/openapi-generator-cli.jar generat
|
||||
(if you're on Windows, replace the last command with `java -jar modules\openapi-generator-cli\target\openapi-generator-cli.jar generate -i https://raw.githubusercontent.com/openapitools/openapi-generator/master/modules/openapi-generator/src/test/resources/2_0/petstore.yaml -g php -o c:\temp\php_api_client`)
|
||||
|
||||
<!-- RELEASE_VERSION -->
|
||||
You can also download the JAR (latest release) directly from [maven.org](http://central.maven.org/maven2/org/openapitools/openapi-generator-cli/4.1.1/openapi-generator-cli-4.1.1.jar)
|
||||
You can also download the JAR (latest release) directly from [maven.org](http://central.maven.org/maven2/org/openapitools/openapi-generator-cli/4.1.3/openapi-generator-cli-4.1.3.jar)
|
||||
<!-- /RELEASE_VERSION -->
|
||||
|
||||
To get a list of **general** options available, please run `java -jar modules/openapi-generator-cli/target/openapi-generator-cli.jar help generate`
|
||||
@@ -455,6 +455,7 @@ NAME
|
||||
SYNOPSIS
|
||||
openapi-generator-cli generate
|
||||
[(-a <authorization> | --auth <authorization>)]
|
||||
[--api-name-suffix <api name suffix>]
|
||||
[--api-package <api package>] [--artifact-id <artifact id>]
|
||||
[--artifact-version <artifact version>]
|
||||
[(-c <configuration file> | --config <configuration file>)]
|
||||
@@ -563,11 +564,13 @@ Here are some companies/projects (alphabetical order) using OpenAPI Generator in
|
||||
- [Element AI](https://www.elementai.com/)
|
||||
- [FormAPI](https://formapi.io/)
|
||||
- [Fuse](https://www.fuse.no/)
|
||||
- [Gantner](https://www.gantner.com)
|
||||
- [GenFlow](https://github.com/RepreZen/GenFlow)
|
||||
- [GMO Pepabo](https://pepabo.com/en/)
|
||||
- [GoDaddy](https://godaddy.com)
|
||||
- [JustStar](https://www.juststarinfo.com)
|
||||
- [Klarna](https://www.klarna.com/)
|
||||
- [Médiavision](https://www.mediavision.fr/)
|
||||
- [Metaswitch](https://www.metaswitch.com/)
|
||||
- [Myworkout](https://myworkout.com)
|
||||
- [Paxos](https://www.paxos.com)
|
||||
@@ -636,6 +639,16 @@ Here are some companies/projects (alphabetical order) using OpenAPI Generator in
|
||||
- 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-06 - [Vert.x and OpenAPI](https://wissel.net/blog/2019/09/vertx-and-openapi.html) by [Stephan H Wissel](https://twitter.com/notessensei) at [wissel.net blog](https://wissel.net)
|
||||
- 2019-09-09 - [Cloud-native development - Creating RESTful microservices](https://cloud.ibm.com/docs/cloud-native?topic=cloud-native-rest-api) in [IBM Cloud Docs](https://cloud.ibm.com/docs)
|
||||
- 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)
|
||||
- 2019-09-17 - [Tutorial: Documenting http4k APIs with OpenApi3](https://www.http4k.org/tutorials/documenting_apis_with_openapi/) by [http4k](https://www.http4k.org/)
|
||||
- 2019-09-22 - [OpenAPI 3を完全に理解できる本](https://booth.pm/ja/items/1571902) by [@ota42y](https://twitter.com/ota42y)
|
||||
- 2019-09-22 - [RESTful APIs: Tutorial of OpenAPI Specification](https://medium.com/@amirm.lavasani/restful-apis-tutorial-of-openapi-specification-eeada0e3901d) by [Amir Lavasani](https://medium.com/@amirm.lavasani)
|
||||
- 2019-09-22 - [Redefining SDKs as software diversity kits](https://devrel.net/dev-rel/redefining-sdks-as-software-diversity-kits) by [Sid Maestre (Xero)](https://twitter.com/sidneyallen) at [DevRelCon San Francisco 2019](https://sf2019.devrel.net/)
|
||||
- 2019-09-23 - [swaggerからOpenApi GeneratorでSpringのコードを自動生成](https://qiita.com/littleFeet/items/492df2ad68a0799a5e5e) by [@littleFeet](https://qiita.com/littleFeet) at [Qiita](https://qiita.com/)
|
||||
|
||||
|
||||
## [6 - About Us](#table-of-contents)
|
||||
|
||||
@@ -698,7 +711,9 @@ Here is a list of template creators:
|
||||
* Javascript (Flow types) @jaypea
|
||||
* JMeter: @davidkiss
|
||||
* Kotlin: @jimschubert [:heart:](https://www.patreon.com/jimschubert)
|
||||
* Kotlin (MultiPlatform): @andrewemery
|
||||
* Lua: @daurnimator
|
||||
* Nim: @hokamoto
|
||||
* OCaml: @cgensoul
|
||||
* Perl: @wing328 [:heart:](https://www.patreon.com/wing328)
|
||||
* PHP (Guzzle): @baartosz
|
||||
@@ -747,6 +762,7 @@ Here is a list of template creators:
|
||||
* JAX-RS RestEasy (JBoss EAP): @jfiala
|
||||
* Kotlin: @jimschubert [:heart:](https://www.patreon.com/jimschubert)
|
||||
* Kotlin (Spring Boot): @dr4ke616
|
||||
* Kotlin (Vertx): @Wooyme
|
||||
* NodeJS Express: @YishTish
|
||||
* PHP Laravel: @renepardon
|
||||
* PHP Lumen: @abcsun
|
||||
@@ -760,6 +776,7 @@ Here is a list of template creators:
|
||||
* Scala Lagom: @gmkumar2005
|
||||
* Scala Play: @adigerber
|
||||
* Documentation
|
||||
* AsciiDoc: @man-at-home
|
||||
* HTML Doc 2: @jhitchcock
|
||||
* Confluence Wiki: @jhitchcock
|
||||
* Configuration
|
||||
@@ -810,7 +827,7 @@ If you want to join the committee, please kindly apply by sending an email to te
|
||||
| Bash | @frol (2017/07) @bkryza (2017/08) @kenjones-cisco (2017/09) |
|
||||
| C | @zhemant (2018/11) |
|
||||
| C++ | @ravinikam (2017/07) @stkrwork (2017/07) @etherealjoy (2018/02) @martindelille (2018/03) @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) @frankyjuang (2019/09) |
|
||||
| Clojure | |
|
||||
| Dart | @ircecho (2017/07) @swipesight (2018/09) @jaumard (2018/09) @nickmeinhold (2019/09) |
|
||||
| Eiffel | @jvelilla (2017/09) |
|
||||
@@ -825,6 +842,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) |
|
||||
| Kotlin | @jimschubert (2017/09) [:heart:](https://www.patreon.com/jimschubert), @dr4ke616 (2018/08) @karismann (2019/03) @Zomzog (2019/04) |
|
||||
| Lua | @daurnimator (2017/08) |
|
||||
| Nim | |
|
||||
| NodeJS/Javascript | @CodeNinjai (2017/07) @frol (2017/07) @cliffano (2017/07) |
|
||||
| ObjC | |
|
||||
| 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}
|
||||
@@ -27,6 +27,6 @@ fi
|
||||
|
||||
# if you've executed sbt assembly previously it will use that instead.
|
||||
export JAVA_OPTS="${JAVA_OPTS} -Xmx1024M -DloggerPath=conf/log4j.properties"
|
||||
ags="generate -g cpp-pistache-server -t modules/openapi-generator/src/main/resources/cpp-pistache-server -i modules/openapi-generator/src/test/resources/2_0/petstore.yaml --additional-properties addExternalLibs=true -o samples/server/petstore/cpp-pistache $@"
|
||||
ags="generate -g cpp-pistache-server -t modules/openapi-generator/src/main/resources/cpp-pistache-server -i modules/openapi-generator/src/test/resources/2_0/petstore.yaml --additional-properties addExternalLibs=true --additional-properties useStructModel=false -o samples/server/petstore/cpp-pistache $@"
|
||||
|
||||
java $JAVA_OPTS -jar $executable $ags
|
||||
|
||||
@@ -29,5 +29,5 @@ fi
|
||||
export JAVA_OPTS="${JAVA_OPTS} -Xmx1024M -DloggerPath=conf/log4j.properties"
|
||||
|
||||
# Generate client
|
||||
ags="generate -t modules/openapi-generator/src/main/resources/dart2 -i modules/openapi-generator/src/test/resources/2_0/petstore.yaml -g dart -o samples/client/petstore/dart2/openapi --additional-properties hideGenerationTimestamp=true $@"
|
||||
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/petstore_client_lib --additional-properties hideGenerationTimestamp=true $@"
|
||||
java $JAVA_OPTS -jar $executable $ags
|
||||
|
||||
31
bin/fsharp-functions-server-petstore.sh
Executable file
31
bin/fsharp-functions-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} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties"
|
||||
ags="$@ generate -i modules/openapi-generator/src/test/resources/2_0/petstore.yaml -g fsharp-functions -o samples/server/petstore/fsharp-functions"
|
||||
|
||||
java ${JAVA_OPTS} -jar ${executable} ${ags}
|
||||
@@ -27,6 +27,6 @@ fi
|
||||
|
||||
# if you've executed sbt assembly previously it will use that instead.
|
||||
export JAVA_OPTS="${JAVA_OPTS} -Xmx1024M -DloggerPath=conf/log4j.properties"
|
||||
ags="generate -t modules/openapi-generator/src/main/resources/rust -i modules/openapi-generator/src/test/resources/2_0/petstore.yaml -g rust -o samples/client/petstore/rust-reqwest --additional-properties packageName=petstore_client --library=reqwest $@"
|
||||
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}
|
||||
@@ -27,6 +27,6 @@ fi
|
||||
|
||||
# if you've executed sbt assembly previously it will use that instead.
|
||||
export JAVA_OPTS="${JAVA_OPTS} -Xmx1024M -DloggerPath=conf/log4j.properties"
|
||||
ags="generate -t modules/openapi-generator/src/main/resources/kotlin-client -i modules/openapi-generator/src/test/resources/2_0/petstore.yaml -g kotlin --artifact-id kotlin-petstore-client --additional-properties dateLibrary=java8 -o samples/client/petstore/kotlin $@"
|
||||
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-petstore-client --additional-properties dateLibrary=java8,serializableModel=true -o samples/client/petstore/kotlin $@"
|
||||
|
||||
java ${JAVA_OPTS} -jar ${executable} ${ags}
|
||||
|
||||
@@ -27,7 +27,7 @@ fi
|
||||
|
||||
# if you've executed sbt assembly previously it will use that instead.
|
||||
export JAVA_OPTS="${JAVA_OPTS} -Xmx1024M -DloggerPath=conf/log4j.properties"
|
||||
ags="generate -t modules/openapi-generator/src/main/resources/kotlin-client -i modules/openapi-generator/src/test/resources/2_0/petstore.yaml -g kotlin --artifact-id kotlin-petstore-string --additional-properties dateLibrary=string -o samples/client/petstore/kotlin-string $@"
|
||||
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-petstore-string --additional-properties dateLibrary=string,serializableModel=true -o samples/client/petstore/kotlin-string $@"
|
||||
|
||||
java ${JAVA_OPTS} -jar ${executable} ${ags}
|
||||
|
||||
|
||||
@@ -27,7 +27,7 @@ fi
|
||||
|
||||
# if you've executed sbt assembly previously it will use that instead.
|
||||
export JAVA_OPTS="${JAVA_OPTS} -Xmx1024M -DloggerPath=conf/log4j.properties"
|
||||
ags="generate -i modules/openapi-generator/src/test/resources/2_0/petstore.yaml -t modules/openapi-generator/src/main/resources/kotlin-server -g kotlin-server --library=ktor -o samples/server/petstore/kotlin-server/ktor --additional-properties hideGenerationTimestamp=true $@"
|
||||
ags="generate -i modules/openapi-generator/src/test/resources/2_0/petstore.yaml -t modules/openapi-generator/src/main/resources/kotlin-server -g kotlin-server --library=ktor -o samples/server/petstore/kotlin-server/ktor --additional-properties hideGenerationTimestamp=true,serializableModel=true $@"
|
||||
|
||||
java ${JAVA_OPTS} -jar ${executable} ${ags}
|
||||
|
||||
|
||||
@@ -26,7 +26,7 @@ then
|
||||
fi
|
||||
|
||||
export JAVA_OPTS="${JAVA_OPTS} -Xmx1024M -DloggerPath=conf/log4j.properties"
|
||||
ags="$@ generate -i modules/openapi-generator/src/test/resources/2_0/petstore.yaml -t modules/openapi-generator/src/main/resources/kotlin-spring -g kotlin-spring -o samples/server/petstore/kotlin-springboot --additional-properties=library=spring-boot,beanValidations=true,swaggerAnnotations=true,serviceImplementation=true"
|
||||
ags="$@ generate -i modules/openapi-generator/src/test/resources/2_0/petstore.yaml -t modules/openapi-generator/src/main/resources/kotlin-spring -g kotlin-spring -o samples/server/petstore/kotlin-springboot --additional-properties=library=spring-boot,beanValidations=true,swaggerAnnotations=true,serviceImplementation=true,serializableModel=true"
|
||||
|
||||
echo "Cleaning previously generated files if any from samples/server/petstore/kotlin-springboot"
|
||||
rm -rf samples/server/petstore/kotlin-springboot
|
||||
|
||||
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
|
||||
|
||||
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,serializableModel=true -o samples/openapi3/client/petstore/kotlin $@"
|
||||
|
||||
echo "Cleaning previously generated files if any from samples/openapi3/client/petstore/kotlin"
|
||||
rm -rf samples/openapi3/client/petstore/kotlin
|
||||
|
||||
@@ -26,7 +26,7 @@ then
|
||||
fi
|
||||
|
||||
export JAVA_OPTS="${JAVA_OPTS} -Xmx1024M -DloggerPath=conf/log4j.properties"
|
||||
ags="$@ generate -i modules/openapi-generator/src/test/resources/3_0/petstore.yaml -t modules/openapi-generator/src/main/resources/kotlin-spring -g kotlin-spring -o samples/openapi3/server/petstore/kotlin-springboot --additional-properties=library=spring-boot,beanValidations=true,swaggerAnnotations=true,serviceImplementation=true"
|
||||
ags="$@ generate -i modules/openapi-generator/src/test/resources/3_0/petstore.yaml -t modules/openapi-generator/src/main/resources/kotlin-spring -g kotlin-spring -o samples/openapi3/server/petstore/kotlin-springboot --additional-properties=library=spring-boot,beanValidations=true,swaggerAnnotations=true,serviceImplementation=true,serializableModel=true"
|
||||
|
||||
echo "Cleaning previously generated files if any from samples/server/openapi3/petstore/kotlin-springboot"
|
||||
rm -rf samples/server/openapi3/petstore/kotlin-springboot
|
||||
|
||||
@@ -27,6 +27,6 @@ fi
|
||||
|
||||
# if you've executed sbt assembly previously it will use that instead.
|
||||
export JAVA_OPTS="${JAVA_OPTS} -Xmx1024M -DloggerPath=conf/log4j.properties"
|
||||
ags="generate -t modules/openapi-generator/src/main/resources/python -i modules/openapi-generator/src/test/resources/2_0/python-client-experimental/petstore-with-fake-endpoints-models-for-testing.yaml -g python-experimental -o samples/client/petstore/python-experimental -DpackageName=petstore_api $@"
|
||||
ags="generate -t modules/openapi-generator/src/main/resources/python -i modules/openapi-generator/src/test/resources/2_0/python-client-experimental/petstore-with-fake-endpoints-models-for-testing.yaml -g python-experimental -o samples/client/petstore/python-experimental --additional-properties packageName=petstore_api $@"
|
||||
|
||||
java $JAVA_OPTS -jar $executable $ags
|
||||
|
||||
@@ -27,6 +27,21 @@ 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/rust -i modules/openapi-generator/src/test/resources/2_0/petstore.yaml -g rust -o samples/client/petstore/rust --additional-properties packageName=petstore_client --library=hyper $@"
|
||||
|
||||
java ${JAVA_OPTS} -jar ${executable} ${ags}
|
||||
for spec_path in \
|
||||
modules/openapi-generator/src/test/resources/2_0/petstore.yaml \
|
||||
modules/openapi-generator/src/test/resources/3_0/rust/rust-test.yaml \
|
||||
modules/openapi-generator/src/test/resources/2_0/fileResponseTest.json\
|
||||
; do
|
||||
spec=$(basename "$spec_path" | sed 's/.yaml//' | sed 's/.json//' )
|
||||
|
||||
for library in hyper reqwest; do
|
||||
args="generate --template-dir modules/openapi-generator/src/main/resources/rust
|
||||
--input-spec $spec_path
|
||||
--generator-name rust
|
||||
--output samples/client/petstore/rust/$library/$spec
|
||||
--additional-properties packageName=${spec}-${library}
|
||||
--library=$library $@"
|
||||
java ${JAVA_OPTS} -jar ${executable} ${args} || exit 1
|
||||
done
|
||||
done
|
||||
|
||||
@@ -21,6 +21,7 @@ declare -a scripts=(
|
||||
"./bin/openapi3/jaxrs-jersey-petstore.sh"
|
||||
"./bin/spring-all-petstore.sh"
|
||||
"./bin/javascript-petstore-all.sh"
|
||||
"./bin/kotlin-client-petstore-multiplatform.sh"
|
||||
"./bin/kotlin-client-petstore.sh"
|
||||
"./bin/kotlin-client-string.sh"
|
||||
"./bin/kotlin-client-threetenbp.sh"
|
||||
@@ -28,6 +29,7 @@ declare -a scripts=(
|
||||
"./bin/kotlin-springboot-petstore-server.sh"
|
||||
"./bin/kotlin-springboot-petstore-server-reactive.sh"
|
||||
"./bin/mysql-schema-petstore.sh"
|
||||
"./bin/nim-client-petstore.sh"
|
||||
"./bin/python-petstore-all.sh"
|
||||
"./bin/openapi3/python-petstore.sh"
|
||||
"./bin/php-petstore.sh"
|
||||
@@ -52,6 +54,8 @@ declare -a scripts=(
|
||||
"./bin/csharp-petstore.sh"
|
||||
"./bin/csharp-netcore-petstore-all.sh"
|
||||
"./bin/elixir-petstore.sh"
|
||||
"./bin/openapi3/go-petstore.sh"
|
||||
"./bin/go-experimental-petstore.sh"
|
||||
"./bin/go-petstore.sh"
|
||||
"./bin/go-petstore-withxml.sh"
|
||||
"./bin/go-gin-petstore-server.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/fsharp-functions-server-petstore.bat
Normal file
10
bin/windows/fsharp-functions-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 "fsharp-functions-petstore-server" -i modules\openapi-generator\src\test\resources\2_0\petstore.yaml -g fsharp-functions -o samples\server\petstore\fsharp-functions
|
||||
|
||||
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%
|
||||
@@ -5,7 +5,7 @@ title: FAQ: General
|
||||
|
||||
## Do you have a chat room?
|
||||
|
||||
[](https://gitter.im/OpenAPITools/openapi-generator)
|
||||
[](https://join.slack.com/t/openapi-generator/shared_invite/enQtNzAyNDMyOTU0OTE1LTY5ZDBiNDI5NzI5ZjQ1Y2E5OWVjMjZkYzY1ZGM2MWQ4YWFjMzcyNDY5MGI4NjQxNDBiMTlmZTc5NjY2ZTQ5MGM)
|
||||
|
||||
## What is the governance structure of the OpenAPI Generator project?
|
||||
|
||||
|
||||
@@ -38,6 +38,7 @@ The following generators are available:
|
||||
* [jmeter](generators/jmeter)
|
||||
* [kotlin](generators/kotlin)
|
||||
* [lua](generators/lua)
|
||||
* [nim (beta)](generators/nim)
|
||||
* [objc](generators/objc)
|
||||
* [ocaml](generators/ocaml)
|
||||
* [perl](generators/perl)
|
||||
@@ -74,7 +75,8 @@ The following generators are available:
|
||||
* [cpp-restbed-server](generators/cpp-restbed-server)
|
||||
* [csharp-nancyfx](generators/csharp-nancyfx)
|
||||
* [erlang-server](generators/erlang-server)
|
||||
* [fsharp-giraffe-server](generators/fsharp-giraffe-server)
|
||||
* [fsharp-functions (beta)](generators/fsharp-functions)
|
||||
* [fsharp-giraffe-server (beta)](generators/fsharp-giraffe-server)
|
||||
* [go-gin-server](generators/go-gin-server)
|
||||
* [go-server](generators/go-server)
|
||||
* [graphql-nodejs-express-server](generators/graphql-nodejs-express-server)
|
||||
@@ -94,6 +96,7 @@ The following generators are available:
|
||||
* [jaxrs-spec](generators/jaxrs-spec)
|
||||
* [kotlin-server](generators/kotlin-server)
|
||||
* [kotlin-spring](generators/kotlin-spring)
|
||||
* [kotlin-vertx (beta)](generators/kotlin-vertx)
|
||||
* [nodejs-express-server (beta)](generators/nodejs-express-server)
|
||||
* [nodejs-server-deprecated (deprecated)](generators/nodejs-server-deprecated)
|
||||
* [php-laravel](generators/php-laravel)
|
||||
@@ -116,6 +119,7 @@ The following generators are available:
|
||||
|
||||
|
||||
## DOCUMENTATION generators
|
||||
* [asciidoc](generators/asciidoc)
|
||||
* [cwiki](generators/cwiki)
|
||||
* [dynamic-html](generators/dynamic-html)
|
||||
* [html](generators/html)
|
||||
|
||||
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: .| |..|
|
||||
@@ -9,3 +9,4 @@ sidebar_label: cpp-pistache-server
|
||||
| ------ | ----------- | ------ | ------- |
|
||||
|addExternalLibs|Add the Possibility to fetch and compile external Libraries needed by this Framework.| |true|
|
||||
|helpersPackage|Specify the package name to be used for the helpers (e.g. org.openapitools.server.helpers).| |org.openapitools.server.helpers|
|
||||
|useStructModel|Use struct-based model template instead of get/set-based model template| |false|
|
||||
|
||||
22
docs/generators/fsharp-functions.md
Normal file
22
docs/generators/fsharp-functions.md
Normal file
@@ -0,0 +1,22 @@
|
||||
|
||||
---
|
||||
id: generator-opts-server-fsharp-functions
|
||||
title: Config Options for fsharp-functions
|
||||
sidebar_label: fsharp-functions
|
||||
---
|
||||
|
||||
| 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|
|
||||
|licenseUrl|The URL of the license| |http://localhost|
|
||||
|licenseName|The name of the license| |NoLicense|
|
||||
|packageCopyright|Specifies an AssemblyCopyright for the .NET Framework global assembly attributes stored in the AssemblyInfo file.| |No Copyright|
|
||||
|packageAuthors|Specifies Authors property in the .NET Core project file.| |OpenAPI|
|
||||
|packageTitle|Specifies an AssemblyTitle for the .NET Framework global assembly attributes stored in the AssemblyInfo file.| |OpenAPI Library|
|
||||
|packageName|F# module name (convention: Title.Case).| |OpenAPI|
|
||||
|packageVersion|F# package version.| |1.0.0|
|
||||
|packageGuid|The GUID that will be associated with the C# project| |null|
|
||||
|sourceFolder|source folder for generated code| |OpenAPI/src|
|
||||
@@ -28,6 +28,7 @@ sidebar_label: haskell-http-client
|
||||
|strictFields|Add strictness annotations to all model fields| |true|
|
||||
|useKatip|Sets the default value for the UseKatip cabal flag. If true, the katip package provides logging instead of monad-logger| |true|
|
||||
|dateTimeFormat|format string used to parse/render a datetime| |null|
|
||||
|dateTimeParseFormat|overrides the format string used to parse a datetime| |null|
|
||||
|dateFormat|format string used to parse/render a date| |%Y-%m-%d|
|
||||
|customTestInstanceModule|test module used to provide typeclass instances for types not known by the generator| |null|
|
||||
|hideGenerationTimestamp|Hides the generation timestamp when files are generated.| |true|
|
||||
|
||||
@@ -46,7 +46,7 @@ sidebar_label: jaxrs-cxf-cdi
|
||||
|title|a title describing the application| |OpenAPI Server|
|
||||
|useBeanValidation|Use BeanValidation API annotations| |true|
|
||||
|serverPort|The port on which the server should be started| |8080|
|
||||
|library|library template (sub-template)|<dl><dt>**<default>**</dt><dd>JAXRS</dd><dl>|<default>|
|
||||
|library|library template (sub-template)|<dl><dt>**<default>**</dt><dd>JAXRS spec only, to be deployed in an app server (TomEE, JBoss, WLS, ...)</dd><dt>**quarkus**</dt><dd>Server using Quarkus</dd><dt>**thorntail**</dt><dd>Server using Thorntail</dd><dt>**openliberty**</dt><dd>Server using Open Liberty</dd><dt>**helidon**</dt><dd>Server using Helidon</dd><dl>|<default>|
|
||||
|generatePom|Whether to generate pom.xml if the file does not already exist.| |true|
|
||||
|interfaceOnly|Whether to generate only API interface stubs without the server files.| |false|
|
||||
|returnResponse|Whether generate API interface should return javax.ws.rs.core.Response instead of a deserialized entity. Only useful if interfaceOnly is true.| |false|
|
||||
|
||||
@@ -46,7 +46,7 @@ sidebar_label: jaxrs-spec
|
||||
|title|a title describing the application| |OpenAPI Server|
|
||||
|useBeanValidation|Use BeanValidation API annotations| |true|
|
||||
|serverPort|The port on which the server should be started| |8080|
|
||||
|library|library template (sub-template)|<dl><dt>**<default>**</dt><dd>JAXRS</dd><dl>|<default>|
|
||||
|library|library template (sub-template)|<dl><dt>**<default>**</dt><dd>JAXRS spec only, to be deployed in an app server (TomEE, JBoss, WLS, ...)</dd><dt>**quarkus**</dt><dd>Server using Quarkus</dd><dt>**thorntail**</dt><dd>Server using Thorntail</dd><dt>**openliberty**</dt><dd>Server using Open Liberty</dd><dt>**helidon**</dt><dd>Server using Helidon</dd><dl>|<default>|
|
||||
|generatePom|Whether to generate pom.xml if the file does not already exist.| |true|
|
||||
|interfaceOnly|Whether to generate only API interface stubs without the server files.| |false|
|
||||
|returnResponse|Whether generate API interface should return javax.ws.rs.core.Response instead of a deserialized entity. Only useful if interfaceOnly is true.| |false|
|
||||
|
||||
@@ -16,6 +16,7 @@ sidebar_label: kotlin-server
|
||||
|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|
|
||||
|serializableModel|boolean - toggle "implements Serializable" for generated models| |null|
|
||||
|library|library template (sub-template)|<dl><dt>**ktor**</dt><dd>ktor framework</dd><dl>|ktor|
|
||||
|featureAutoHead|Automatically provide responses to HEAD requests for existing routes that have the GET verb defined.| |true|
|
||||
|featureConditionalHeaders|Avoid sending content if client already has same content, by checking ETag or LastModified properties.| |false|
|
||||
|
||||
@@ -16,6 +16,7 @@ sidebar_label: kotlin-spring
|
||||
|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|
|
||||
|serializableModel|boolean - toggle "implements Serializable" for generated models| |null|
|
||||
|title|server title name or client service name| |OpenAPI Kotlin Spring|
|
||||
|basePackage|base package (invokerPackage) for generated code| |org.openapitools|
|
||||
|serverPort|configuration the port in which the sever is to run on| |8080|
|
||||
|
||||
19
docs/generators/kotlin-vertx.md
Normal file
19
docs/generators/kotlin-vertx.md
Normal file
@@ -0,0 +1,19 @@
|
||||
|
||||
---
|
||||
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|
|
||||
|serializableModel|boolean - toggle "implements Serializable" for generated models| |null|
|
||||
@@ -16,5 +16,7 @@ sidebar_label: kotlin
|
||||
|enumPropertyNaming|Naming convention for enum properties: 'camelCase', 'PascalCase', 'snake_case', 'UPPERCASE', and 'original'| |camelCase|
|
||||
|serializationLibrary|What serialization library to use: 'moshi' (default), or 'gson'| |moshi|
|
||||
|parcelizeModels|toggle "@Parcelize" for generated models| |null|
|
||||
|dateLibrary|Option. Date library to use|<dl><dt>**string**</dt><dd>String</dd><dt>**java8**</dt><dd>Java 8 native JSR310</dd><dt>**threetenbp**</dt><dd>Threetenbp</dd><dl>|java8|
|
||||
|serializableModel|boolean - toggle "implements Serializable" 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 (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|
|
||||
|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|
|
||||
@@ -13,7 +13,6 @@ sidebar_label: swift4
|
||||
|prependFormOrBodyParameters|Add form or body parameters to the beginning of the parameter list.| |false|
|
||||
|projectName|Project name in Xcode| |null|
|
||||
|responseAs|Optionally use libraries to manage response. Currently PromiseKit, RxSwift are available.| |null|
|
||||
|unwrapRequired|Treat 'required' properties in response as non-optional (which would crash the app if api returns null as opposed to required option specified in json schema| |null|
|
||||
|objcCompatible|Add additional properties and methods for Objective-C compatibility (default: false)| |null|
|
||||
|podSource|Source information used for Podspec| |null|
|
||||
|podVersion|Version used for Podspec| |null|
|
||||
|
||||
@@ -20,7 +20,7 @@ sidebar_label: typescript-angular
|
||||
|withInterfaces|Setting this property to true will generate interfaces next to the default class implementations.| |false|
|
||||
|taggedUnions|Use discriminators to create tagged unions instead of extending interfaces.| |false|
|
||||
|providedInRoot|Use this property to provide Injectables in root (it is only valid in angular version greater or equal to 6.0.0).| |false|
|
||||
|ngVersion|The version of Angular.| |7.0.0|
|
||||
|ngVersion|The version of Angular.| |8.0.0|
|
||||
|serviceSuffix|The suffix of the generated service.| |Service|
|
||||
|serviceFileSuffix|The suffix of the file of the generated service (service<suffix>.ts).| |.service|
|
||||
|modelSuffix|The suffix of the generated model.| |null|
|
||||
|
||||
@@ -54,10 +54,7 @@
|
||||
<property name="tokens" value="LITERAL_TRY, LITERAL_FINALLY, LITERAL_IF, LITERAL_ELSE, LITERAL_SWITCH"/>
|
||||
</module>
|
||||
<module name="NeedBraces"/>
|
||||
<module name="LeftCurly">
|
||||
<property name="maxLineLength" value="100"/>
|
||||
</module>
|
||||
<module name="RightCurly"/>
|
||||
<module name="LeftCurly"/>
|
||||
<module name="RightCurly">
|
||||
<property name="option" value="alone"/>
|
||||
<property name="tokens" value="CLASS_DEF, METHOD_DEF, CTOR_DEF, LITERAL_FOR, LITERAL_WHILE, LITERAL_DO, STATIC_INIT, INSTANCE_INIT"/>
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
<groupId>org.openapitools</groupId>
|
||||
<artifactId>openapi-generator-project</artifactId>
|
||||
<!-- RELEASE_VERSION -->
|
||||
<version>4.1.2</version>
|
||||
<version>4.2.0-SNAPSHOT</version>
|
||||
<!-- /RELEASE_VERSION -->
|
||||
<relativePath>../..</relativePath>
|
||||
</parent>
|
||||
|
||||
@@ -65,7 +65,7 @@ public class Generate implements Runnable {
|
||||
private String templateDir;
|
||||
|
||||
@Option(name = {"-e", "--engine"}, title = "templating engine",
|
||||
description = "templating engine: \"mustache\" (default) or \"handlebars\" (beta)")
|
||||
description = "templating engine: \"mustache\" (default) or \"handlebars\" (beta)")
|
||||
private String templatingEngine;
|
||||
|
||||
@Option(
|
||||
@@ -109,6 +109,10 @@ public class Generate implements Runnable {
|
||||
description = CodegenConstants.MODEL_PACKAGE_DESC)
|
||||
private String modelPackage;
|
||||
|
||||
@Option(name = {"--api-name-suffix"}, title = "api name suffix",
|
||||
description = CodegenConstants.API_NAME_SUFFIX_DESC)
|
||||
private String apiNameSuffix;
|
||||
|
||||
@Option(name = {"--model-name-prefix"}, title = "model name prefix",
|
||||
description = CodegenConstants.MODEL_NAME_PREFIX_DESC)
|
||||
private String modelNamePrefix;
|
||||
@@ -319,6 +323,10 @@ public class Generate implements Runnable {
|
||||
configurator.setModelPackage(modelPackage);
|
||||
}
|
||||
|
||||
if (isNotEmpty(apiNameSuffix)) {
|
||||
configurator.setApiNameSuffix(apiNameSuffix);
|
||||
}
|
||||
|
||||
if (isNotEmpty(modelNamePrefix)) {
|
||||
configurator.setModelNamePrefix(modelNamePrefix);
|
||||
}
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
<artifactId>openapi-generator-project</artifactId>
|
||||
<groupId>org.openapitools</groupId>
|
||||
<!-- RELEASE_VERSION -->
|
||||
<version>4.1.2</version>
|
||||
<version>4.2.0-SNAPSHOT</version>
|
||||
<!-- /RELEASE_VERSION -->
|
||||
<relativePath>../..</relativePath>
|
||||
</parent>
|
||||
|
||||
@@ -40,6 +40,7 @@ public final class GeneratorSettings implements Serializable {
|
||||
private String modelPackage;
|
||||
private String invokerPackage;
|
||||
private String packageName;
|
||||
private String apiNameSuffix;
|
||||
private String modelNamePrefix;
|
||||
private String modelNameSuffix;
|
||||
private String groupId;
|
||||
@@ -106,6 +107,21 @@ public final class GeneratorSettings implements Serializable {
|
||||
return packageName;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a api name suffix for generated models. This name will be appended to a api name.
|
||||
* <p>
|
||||
* This option is often used to circumvent compilation issues where models match keywords.
|
||||
* <p>
|
||||
* Example:
|
||||
* <p>
|
||||
* Suffix <code>Gen</code> applied to <code>Object</code> results in a generated class named <code>ObjectGen</code>.
|
||||
*
|
||||
* @return the model name suffix
|
||||
*/
|
||||
public String getApiNameSuffix() {
|
||||
return apiNameSuffix;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a model name prefix for generated models. This name will be prefixed to a model name.
|
||||
* <p>
|
||||
@@ -325,6 +341,7 @@ public final class GeneratorSettings implements Serializable {
|
||||
modelPackage = builder.modelPackage;
|
||||
invokerPackage = builder.invokerPackage;
|
||||
packageName = builder.packageName;
|
||||
apiNameSuffix = builder.apiNameSuffix;
|
||||
modelNamePrefix = builder.modelNamePrefix;
|
||||
modelNameSuffix = builder.modelNameSuffix;
|
||||
groupId = builder.groupId;
|
||||
@@ -366,6 +383,9 @@ public final class GeneratorSettings implements Serializable {
|
||||
if (isNotEmpty(artifactVersion)) {
|
||||
additional.put("artifactVersion", artifactVersion);
|
||||
}
|
||||
if (isNotEmpty(apiNameSuffix)) {
|
||||
additional.put("apiNameSuffix", apiNameSuffix);
|
||||
}
|
||||
if (isNotEmpty(modelNamePrefix)) {
|
||||
additional.put("modelNamePrefix", modelNamePrefix);
|
||||
}
|
||||
@@ -433,6 +453,7 @@ public final class GeneratorSettings implements Serializable {
|
||||
builder.modelPackage = copy.getModelPackage();
|
||||
builder.invokerPackage = copy.getInvokerPackage();
|
||||
builder.packageName = copy.getPackageName();
|
||||
builder.apiNameSuffix = copy.getApiNameSuffix();
|
||||
builder.modelNamePrefix = copy.getModelNamePrefix();
|
||||
builder.modelNameSuffix = copy.getModelNameSuffix();
|
||||
builder.groupId = copy.getGroupId();
|
||||
@@ -479,6 +500,7 @@ public final class GeneratorSettings implements Serializable {
|
||||
private String modelPackage;
|
||||
private String invokerPackage;
|
||||
private String packageName;
|
||||
private String apiNameSuffix;
|
||||
private String modelNamePrefix;
|
||||
private String modelNameSuffix;
|
||||
private String groupId;
|
||||
@@ -571,6 +593,17 @@ public final class GeneratorSettings implements Serializable {
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the {@code apiNameSuffix} and returns a reference to this Builder so that the methods can be chained together.
|
||||
*
|
||||
* @param apiNameSuffix the {@code apiNameSuffix} to set
|
||||
* @return a reference to this Builder
|
||||
*/
|
||||
public Builder withApiNameSuffix(String apiNameSuffix) {
|
||||
this.apiNameSuffix = apiNameSuffix;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the {@code modelNamePrefix} and returns a reference to this Builder so that the methods can be chained together.
|
||||
*
|
||||
@@ -880,6 +913,7 @@ public final class GeneratorSettings implements Serializable {
|
||||
", modelPackage='" + modelPackage + '\'' +
|
||||
", invokerPackage='" + invokerPackage + '\'' +
|
||||
", packageName='" + packageName + '\'' +
|
||||
", apiNameSuffix='" + apiNameSuffix + '\'' +
|
||||
", modelNamePrefix='" + modelNamePrefix + '\'' +
|
||||
", modelNameSuffix='" + modelNameSuffix + '\'' +
|
||||
", groupId='" + groupId + '\'' +
|
||||
@@ -910,6 +944,7 @@ public final class GeneratorSettings implements Serializable {
|
||||
Objects.equals(getModelPackage(), that.getModelPackage()) &&
|
||||
Objects.equals(getInvokerPackage(), that.getInvokerPackage()) &&
|
||||
Objects.equals(getPackageName(), that.getPackageName()) &&
|
||||
Objects.equals(getApiNameSuffix(), that.getApiNameSuffix()) &&
|
||||
Objects.equals(getModelNamePrefix(), that.getModelNamePrefix()) &&
|
||||
Objects.equals(getModelNameSuffix(), that.getModelNameSuffix()) &&
|
||||
Objects.equals(getGroupId(), that.getGroupId()) &&
|
||||
@@ -937,6 +972,7 @@ public final class GeneratorSettings implements Serializable {
|
||||
getModelPackage(),
|
||||
getInvokerPackage(),
|
||||
getPackageName(),
|
||||
getApiNameSuffix(),
|
||||
getModelNamePrefix(),
|
||||
getModelNameSuffix(),
|
||||
getGroupId(),
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
# RELEASE_VERSION
|
||||
openApiGeneratorVersion=4.1.2
|
||||
openApiGeneratorVersion=4.2.0-SNAPSHOT
|
||||
# /RELEASE_VERSION
|
||||
|
||||
# BEGIN placeholders
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
<groupId>org.openapitools</groupId>
|
||||
<artifactId>openapi-generator-project</artifactId>
|
||||
<!-- RELEASE_VERSION -->
|
||||
<version>4.1.2</version>
|
||||
<version>4.2.0-SNAPSHOT</version>
|
||||
<!-- /RELEASE_VERSION -->
|
||||
<relativePath>../..</relativePath>
|
||||
</parent>
|
||||
@@ -20,6 +20,20 @@
|
||||
<gradleVersion>4.10.2</gradleVersion>
|
||||
</properties>
|
||||
|
||||
<pluginRepositories>
|
||||
<pluginRepository>
|
||||
<id>Gradle Releases</id>
|
||||
<name>Gradle Releases repository</name>
|
||||
<url>https://repo.gradle.org/gradle/libs-releases-local/</url>
|
||||
<releases>
|
||||
<enabled>true</enabled>
|
||||
</releases>
|
||||
<snapshots>
|
||||
<enabled>false</enabled>
|
||||
</snapshots>
|
||||
</pluginRepository>
|
||||
</pluginRepositories>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.openapitools</groupId>
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
<groupId>org.openapitools</groupId>
|
||||
<artifactId>openapi-generator-maven-plugin</artifactId>
|
||||
<!-- RELEASE_VERSION -->
|
||||
<version>4.1.2-SNAPSHOT</version>
|
||||
<version>4.1.3-SNAPSHOT</version>
|
||||
<!-- /RELEASE_VERSION -->
|
||||
<executions>
|
||||
<execution>
|
||||
@@ -75,11 +75,11 @@
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<version>3.6.1</version>
|
||||
<version>3.8.1</version>
|
||||
<configuration>
|
||||
<source>1.7</source>
|
||||
<target>1.7</target>
|
||||
<proc>none</proc>
|
||||
<source>1.7</source>
|
||||
<target>1.7</target>
|
||||
<proc>none</proc>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
<groupId>org.openapitools</groupId>
|
||||
<artifactId>openapi-generator-maven-plugin</artifactId>
|
||||
<!-- RELEASE_VERSION -->
|
||||
<version>4.1.2-SNAPSHOT</version>
|
||||
<version>4.1.3-SNAPSHOT</version>
|
||||
<!-- /RELEASE_VERSION -->
|
||||
<dependencies>
|
||||
<dependency>
|
||||
@@ -57,11 +57,11 @@
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<version>3.6.1</version>
|
||||
<version>3.8.1</version>
|
||||
<configuration>
|
||||
<source>1.7</source>
|
||||
<target>1.7</target>
|
||||
<proc>none</proc>
|
||||
<source>1.7</source>
|
||||
<target>1.7</target>
|
||||
<proc>none</proc>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
<groupId>org.openapitools</groupId>
|
||||
<artifactId>openapi-generator-project</artifactId>
|
||||
<!-- RELEASE_VERSION -->
|
||||
<version>4.1.2</version>
|
||||
<version>4.2.0-SNAPSHOT</version>
|
||||
<!-- /RELEASE_VERSION -->
|
||||
<relativePath>../..</relativePath>
|
||||
</parent>
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
<groupId>org.openapitools</groupId>
|
||||
<artifactId>openapi-generator-project</artifactId>
|
||||
<!-- RELEASE_VERSION -->
|
||||
<version>4.1.2</version>
|
||||
<version>4.2.0-SNAPSHOT</version>
|
||||
<!-- /RELEASE_VERSION -->
|
||||
<relativePath>../..</relativePath>
|
||||
</parent>
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
<groupId>org.openapitools</groupId>
|
||||
<artifactId>openapi-generator-project</artifactId>
|
||||
<!-- RELEASE_VERSION -->
|
||||
<version>4.1.2</version>
|
||||
<version>4.2.0-SNAPSHOT</version>
|
||||
<!-- /RELEASE_VERSION -->
|
||||
<relativePath>../..</relativePath>
|
||||
</parent>
|
||||
@@ -74,7 +74,7 @@
|
||||
</plugin>
|
||||
<plugin>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<version>3.5.1</version>
|
||||
<version>3.8.1</version>
|
||||
<configuration>
|
||||
<source>1.8</source>
|
||||
<target>1.8</target>
|
||||
@@ -300,7 +300,7 @@
|
||||
<dependency>
|
||||
<groupId>org.mockito</groupId>
|
||||
<artifactId>mockito-core</artifactId>
|
||||
<version>3.0.0</version>
|
||||
<version>3.1.0</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
|
||||
@@ -206,6 +206,9 @@ public class CodegenConstants {
|
||||
// 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 API_NAME_SUFFIX = "apiNameSuffix";
|
||||
public static final String API_NAME_SUFFIX_DESC = "Suffix that will be appended to all API names ('tags'). Default: Api. e.g. Pet => PetApi. Note: Only ruby, python, jaxrs generators suppport this feature at the moment.";
|
||||
|
||||
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.";
|
||||
|
||||
|
||||
@@ -85,6 +85,7 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
protected Map<String, String> importMapping = new HashMap<String, String>();
|
||||
protected String modelPackage = "", apiPackage = "", fileSuffix;
|
||||
protected String modelNamePrefix = "", modelNameSuffix = "";
|
||||
protected String apiNameSuffix = "Api";
|
||||
protected String testPackage = "";
|
||||
protected Map<String, String> apiTemplateFiles = new HashMap<String, String>();
|
||||
protected Map<String, String> modelTemplateFiles = new HashMap<String, String>();
|
||||
@@ -180,6 +181,10 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
.get(CodegenConstants.ALLOW_UNICODE_IDENTIFIERS).toString()));
|
||||
}
|
||||
|
||||
if (additionalProperties.containsKey(CodegenConstants.API_NAME_SUFFIX)) {
|
||||
this.setApiNameSuffix((String) additionalProperties.get(CodegenConstants.API_NAME_SUFFIX));
|
||||
}
|
||||
|
||||
if (additionalProperties.containsKey(CodegenConstants.MODEL_NAME_PREFIX)) {
|
||||
this.setModelNamePrefix((String) additionalProperties.get(CodegenConstants.MODEL_NAME_PREFIX));
|
||||
}
|
||||
@@ -779,6 +784,14 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
this.modelNameSuffix = modelNameSuffix;
|
||||
}
|
||||
|
||||
public String getApiNameSuffix() {
|
||||
return apiNameSuffix;
|
||||
}
|
||||
|
||||
public void setApiNameSuffix(String apiNameSuffix) {
|
||||
this.apiNameSuffix = apiNameSuffix;
|
||||
}
|
||||
|
||||
public void setApiPackage(String apiPackage) {
|
||||
this.apiPackage = apiPackage;
|
||||
}
|
||||
@@ -1068,8 +1081,7 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
typeMapping.put("file", "File");
|
||||
typeMapping.put("UUID", "UUID");
|
||||
typeMapping.put("URI", "URI");
|
||||
//typeMapping.put("BigDecimal", "BigDecimal"); //TODO need the mapping?
|
||||
|
||||
typeMapping.put("BigDecimal", "BigDecimal");
|
||||
|
||||
instantiationTypes = new HashMap<String, String>();
|
||||
|
||||
@@ -1693,17 +1705,17 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
}
|
||||
|
||||
/**
|
||||
* Output the API (class) name (capitalized) ending with "Api"
|
||||
* Output the API (class) name (capitalized) ending with the specified or default suffix
|
||||
* Return DefaultApi if name is empty
|
||||
*
|
||||
* @param name the name of the Api
|
||||
* @return capitalized Api name ending with "Api"
|
||||
* @return capitalized Api name
|
||||
*/
|
||||
public String toApiName(String name) {
|
||||
if (name.length() == 0) {
|
||||
return "DefaultApi";
|
||||
}
|
||||
return camelize(name) + "Api";
|
||||
return camelize(name + "_" + apiNameSuffix);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -2303,8 +2315,9 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
// property.baseType = getSimpleRef(p.get$ref());
|
||||
//}
|
||||
// --END of revision
|
||||
property.isModel = ModelUtils.isModel(p);
|
||||
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);
|
||||
@@ -2492,6 +2505,76 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
return responses.get(code);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set op's returnBaseType, returnType, examples etc.
|
||||
*
|
||||
* @param operation endpoint Operation
|
||||
* @param schemas a map of the schemas in the openapi spec
|
||||
* @param op endpoint CodegenOperation
|
||||
* @param methodResponse the default ApiResponse for the endpoint
|
||||
*/
|
||||
protected void handleMethodResponse(Operation operation,
|
||||
Map<String, Schema> schemas,
|
||||
CodegenOperation op,
|
||||
ApiResponse methodResponse) {
|
||||
Schema responseSchema = ModelUtils.unaliasSchema(this.openAPI, ModelUtils.getSchemaFromResponse(methodResponse));
|
||||
|
||||
if (responseSchema != null) {
|
||||
CodegenProperty cm = fromProperty("response", responseSchema);
|
||||
|
||||
if (ModelUtils.isArraySchema(responseSchema)) {
|
||||
ArraySchema as = (ArraySchema) responseSchema;
|
||||
CodegenProperty innerProperty = fromProperty("response", getSchemaItems(as));
|
||||
op.returnBaseType = innerProperty.baseType;
|
||||
} else if (ModelUtils.isMapSchema(responseSchema)) {
|
||||
CodegenProperty innerProperty = fromProperty("response", ModelUtils.getAdditionalProperties(responseSchema));
|
||||
op.returnBaseType = innerProperty.baseType;
|
||||
} else {
|
||||
if (cm.complexType != null) {
|
||||
op.returnBaseType = cm.complexType;
|
||||
} else {
|
||||
op.returnBaseType = cm.baseType;
|
||||
}
|
||||
}
|
||||
|
||||
// generate examples
|
||||
String exampleStatusCode = "200";
|
||||
for (String key : operation.getResponses().keySet()) {
|
||||
if (operation.getResponses().get(key) == methodResponse && !key.equals("default")) {
|
||||
exampleStatusCode = key;
|
||||
}
|
||||
}
|
||||
op.examples = new ExampleGenerator(schemas, this.openAPI).generateFromResponseSchema(exampleStatusCode, responseSchema, getProducesInfo(this.openAPI, operation));
|
||||
op.defaultResponse = toDefaultValue(responseSchema);
|
||||
op.returnType = cm.dataType;
|
||||
op.hasReference = schemas.containsKey(op.returnBaseType);
|
||||
|
||||
// lookup discriminator
|
||||
Schema schema = schemas.get(op.returnBaseType);
|
||||
if (schema != null) {
|
||||
CodegenModel cmod = fromModel(op.returnBaseType, schema);
|
||||
op.discriminator = cmod.discriminator;
|
||||
}
|
||||
|
||||
if (cm.isContainer) {
|
||||
op.returnContainer = cm.containerType;
|
||||
if ("map".equals(cm.containerType)) {
|
||||
op.isMapContainer = true;
|
||||
} else if ("list".equalsIgnoreCase(cm.containerType)) {
|
||||
op.isListContainer = true;
|
||||
} else if ("array".equalsIgnoreCase(cm.containerType)) {
|
||||
op.isListContainer = true;
|
||||
}
|
||||
} else {
|
||||
op.returnSimpleType = true;
|
||||
}
|
||||
if (languageSpecificPrimitives().contains(op.returnBaseType) || op.returnBaseType == null) {
|
||||
op.returnTypeIsPrimitive = true;
|
||||
}
|
||||
}
|
||||
addHeaders(methodResponse, op.responseHeaders);
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert OAS Operation object to Codegen Operation object
|
||||
*
|
||||
@@ -2584,62 +2667,7 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
op.responses.get(op.responses.size() - 1).hasMore = false;
|
||||
|
||||
if (methodResponse != null) {
|
||||
Schema responseSchema = ModelUtils.unaliasSchema(this.openAPI, ModelUtils.getSchemaFromResponse(methodResponse));
|
||||
|
||||
if (responseSchema != null) {
|
||||
CodegenProperty cm = fromProperty("response", responseSchema);
|
||||
|
||||
if (ModelUtils.isArraySchema(responseSchema)) {
|
||||
ArraySchema as = (ArraySchema) responseSchema;
|
||||
CodegenProperty innerProperty = fromProperty("response", getSchemaItems(as));
|
||||
op.returnBaseType = innerProperty.baseType;
|
||||
} else if (ModelUtils.isMapSchema(responseSchema)) {
|
||||
CodegenProperty innerProperty = fromProperty("response", ModelUtils.getAdditionalProperties(responseSchema));
|
||||
op.returnBaseType = innerProperty.baseType;
|
||||
} else {
|
||||
if (cm.complexType != null) {
|
||||
op.returnBaseType = cm.complexType;
|
||||
} else {
|
||||
op.returnBaseType = cm.baseType;
|
||||
}
|
||||
}
|
||||
|
||||
// generate examples
|
||||
String exampleStatusCode = "200";
|
||||
for (String key : operation.getResponses().keySet()) {
|
||||
if (operation.getResponses().get(key) == methodResponse && !key.equals("default")) {
|
||||
exampleStatusCode = key;
|
||||
}
|
||||
}
|
||||
op.examples = new ExampleGenerator(schemas, this.openAPI).generateFromResponseSchema(exampleStatusCode, responseSchema, getProducesInfo(this.openAPI, operation));
|
||||
op.defaultResponse = toDefaultValue(responseSchema);
|
||||
op.returnType = cm.dataType;
|
||||
op.hasReference = schemas.containsKey(op.returnBaseType);
|
||||
|
||||
// lookup discriminator
|
||||
Schema schema = schemas.get(op.returnBaseType);
|
||||
if (schema != null) {
|
||||
CodegenModel cmod = fromModel(op.returnBaseType, schema);
|
||||
op.discriminator = cmod.discriminator;
|
||||
}
|
||||
|
||||
if (cm.isContainer) {
|
||||
op.returnContainer = cm.containerType;
|
||||
if ("map".equals(cm.containerType)) {
|
||||
op.isMapContainer = true;
|
||||
} else if ("list".equalsIgnoreCase(cm.containerType)) {
|
||||
op.isListContainer = true;
|
||||
} else if ("array".equalsIgnoreCase(cm.containerType)) {
|
||||
op.isListContainer = true;
|
||||
}
|
||||
} else {
|
||||
op.returnSimpleType = true;
|
||||
}
|
||||
if (languageSpecificPrimitives().contains(op.returnBaseType) || op.returnBaseType == null) {
|
||||
op.returnTypeIsPrimitive = true;
|
||||
}
|
||||
}
|
||||
addHeaders(methodResponse, op.responseHeaders);
|
||||
handleMethodResponse(operation, schemas, op, methodResponse);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3510,7 +3538,7 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
* @param response API response
|
||||
* @param properties list of codegen property
|
||||
*/
|
||||
private void addHeaders(ApiResponse response, List<CodegenProperty> properties) {
|
||||
protected void addHeaders(ApiResponse response, List<CodegenProperty> properties) {
|
||||
if (response.getHeaders() != null) {
|
||||
for (Map.Entry<String, Header> headerEntry : response.getHeaders().entrySet()) {
|
||||
String description = headerEntry.getValue().getDescription();
|
||||
@@ -4315,7 +4343,7 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
}
|
||||
}
|
||||
|
||||
private void updateEnumVarsWithExtensions(List<Map<String, Object>> enumVars, Map<String, Object> vendorExtensions) {
|
||||
protected void updateEnumVarsWithExtensions(List<Map<String, Object>> enumVars, Map<String, Object> vendorExtensions) {
|
||||
if (vendorExtensions != null) {
|
||||
updateEnumVarsWithExtensions(enumVars, vendorExtensions, "x-enum-varnames", "name");
|
||||
updateEnumVarsWithExtensions(enumVars, vendorExtensions, "x-enum-descriptions", "enumDescription");
|
||||
|
||||
@@ -35,6 +35,7 @@ import org.apache.commons.lang3.StringUtils;
|
||||
import org.openapitools.codegen.config.GlobalSettings;
|
||||
import org.openapitools.codegen.api.TemplatingEngineAdapter;
|
||||
import org.openapitools.codegen.ignore.CodegenIgnoreProcessor;
|
||||
import org.openapitools.codegen.languages.PythonClientExperimentalCodegen;
|
||||
import org.openapitools.codegen.meta.GeneratorMetadata;
|
||||
import org.openapitools.codegen.meta.Stability;
|
||||
import org.openapitools.codegen.serializer.SerializerUtils;
|
||||
@@ -490,10 +491,11 @@ public class DefaultGenerator extends AbstractGenerator implements Generator {
|
||||
|
||||
// TODO revise below as we've already performed unaliasing so that the isAlias check may be removed
|
||||
Map<String, Object> modelTemplate = (Map<String, Object>) ((List<Object>) models.get("models")).get(0);
|
||||
// Special handling of aliases only applies to Java
|
||||
if (modelTemplate != null && modelTemplate.containsKey("model")) {
|
||||
CodegenModel m = (CodegenModel) modelTemplate.get("model");
|
||||
if (m.isAlias) {
|
||||
if (m.isAlias && !(config instanceof PythonClientExperimentalCodegen)) {
|
||||
// alias to number, string, enum, etc, which should not be generated as model
|
||||
// for PythonClientExperimentalCodegen, all aliases are generated as models
|
||||
continue; // Don't create user-defined classes for aliases
|
||||
}
|
||||
}
|
||||
@@ -943,7 +945,6 @@ public class DefaultGenerator extends AbstractGenerator implements Generator {
|
||||
* Returns the path of a template, allowing access to the template where consuming literal contents aren't desirable or possible.
|
||||
*
|
||||
* @param name the template name (e.g. model.mustache)
|
||||
*
|
||||
* @return The {@link Path} to the template
|
||||
*/
|
||||
@Override
|
||||
@@ -1063,21 +1064,21 @@ public class DefaultGenerator extends AbstractGenerator implements Generator {
|
||||
if (authMethods != null && !authMethods.isEmpty()) {
|
||||
codegenOperation.authMethods = config.fromSecurity(authMethods);
|
||||
List<Map<String, Object>> scopes = new ArrayList<Map<String, Object>>();
|
||||
if (codegenOperation.authMethods != null){
|
||||
for (CodegenSecurity security : codegenOperation.authMethods){
|
||||
if (codegenOperation.authMethods != null) {
|
||||
for (CodegenSecurity security : codegenOperation.authMethods) {
|
||||
if (security != null && security.isBasicBearer != null && security.isBasicBearer &&
|
||||
securities != null){
|
||||
for (SecurityRequirement req : securities){
|
||||
securities != null) {
|
||||
for (SecurityRequirement req : securities) {
|
||||
if (req == null) continue;
|
||||
for (String key : req.keySet()){
|
||||
if (security.name != null && key.equals(security.name)){
|
||||
for (String key : req.keySet()) {
|
||||
if (security.name != null && key.equals(security.name)) {
|
||||
int count = 0;
|
||||
for (String sc : req.get(key)){
|
||||
for (String sc : req.get(key)) {
|
||||
Map<String, Object> scope = new HashMap<String, Object>();
|
||||
scope.put("scope", sc);
|
||||
scope.put("description", "");
|
||||
count++;
|
||||
if (req.get(key) != null && count < req.get(key).size()){
|
||||
if (req.get(key) != null && count < req.get(key).size()) {
|
||||
scope.put("hasMore", "true");
|
||||
} else {
|
||||
scope.put("hasMore", null);
|
||||
|
||||
@@ -287,6 +287,11 @@ public class CodegenConfigurator {
|
||||
return this;
|
||||
}
|
||||
|
||||
public CodegenConfigurator setApiNameSuffix(String suffix) {
|
||||
generatorSettingsBuilder.withApiNameSuffix(suffix);
|
||||
return this;
|
||||
}
|
||||
|
||||
public CodegenConfigurator setModelNamePrefix(String prefix) {
|
||||
generatorSettingsBuilder.withModelNamePrefix(prefix);
|
||||
return this;
|
||||
|
||||
@@ -181,6 +181,7 @@ public abstract class AbstractCSharpCodegen extends DefaultCodegen implements Co
|
||||
typeMapping.put("long", "long?");
|
||||
typeMapping.put("double", "double?");
|
||||
typeMapping.put("number", "decimal?");
|
||||
typeMapping.put("BigDecimal", "decimal?");
|
||||
typeMapping.put("DateTime", "DateTime?");
|
||||
typeMapping.put("date", "DateTime?");
|
||||
typeMapping.put("file", "System.IO.Stream");
|
||||
|
||||
@@ -35,6 +35,7 @@ import org.slf4j.LoggerFactory;
|
||||
import java.io.File;
|
||||
import java.net.URL;
|
||||
import java.util.Arrays;
|
||||
import java.util.Map;
|
||||
|
||||
abstract public class AbstractCppCodegen extends DefaultCodegen implements CodegenConfig {
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(AbstractCppCodegen.class);
|
||||
@@ -150,7 +151,7 @@ abstract public class AbstractCppCodegen extends DefaultCodegen implements Codeg
|
||||
|
||||
@Override
|
||||
public String toApiName(String type) {
|
||||
return sanitizeName(modelNamePrefix + Character.toUpperCase(type.charAt(0)) + type.substring(1) + "Api");
|
||||
return sanitizeName(modelNamePrefix + super.toApiName(type));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -306,4 +307,9 @@ abstract public class AbstractCppCodegen extends DefaultCodegen implements Codeg
|
||||
this.additionalProperties.put("serverHost", host);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Object> postProcessModels(Map<String, Object> objs) {
|
||||
return postProcessModelsEnum(objs);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -30,10 +30,13 @@ import org.openapitools.codegen.utils.ModelUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.lang.Exception;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.*;
|
||||
|
||||
import static org.openapitools.codegen.utils.StringUtils.camelize;
|
||||
import static org.openapitools.codegen.utils.StringUtils.underscore;
|
||||
|
||||
public abstract class AbstractFSharpCodegen extends DefaultCodegen implements CodegenConfig {
|
||||
|
||||
@@ -246,11 +249,6 @@ public abstract class AbstractFSharpCodegen extends DefaultCodegen implements Co
|
||||
additionalProperties.put(CodegenConstants.PACKAGE_NAME, packageName);
|
||||
}
|
||||
|
||||
if (additionalProperties.containsKey(CodegenConstants.INVOKER_PACKAGE)) {
|
||||
LOGGER.warn(String.format(Locale.ROOT, "%s is not used by F# generators. Please use %s",
|
||||
CodegenConstants.INVOKER_PACKAGE, CodegenConstants.PACKAGE_NAME));
|
||||
}
|
||||
|
||||
// {{packageTitle}}
|
||||
if (additionalProperties.containsKey(CodegenConstants.PACKAGE_TITLE)) {
|
||||
setPackageTitle((String) additionalProperties.get(CodegenConstants.PACKAGE_TITLE));
|
||||
@@ -300,32 +298,8 @@ public abstract class AbstractFSharpCodegen extends DefaultCodegen implements Co
|
||||
additionalProperties.put(CodegenConstants.USE_DATETIME_OFFSET, useDateTimeOffsetFlag);
|
||||
}
|
||||
|
||||
if (additionalProperties.containsKey(CodegenConstants.USE_COLLECTION)) {
|
||||
setUseCollection(convertPropertyToBooleanAndWriteBack(CodegenConstants.USE_COLLECTION));
|
||||
} else {
|
||||
additionalProperties.put(CodegenConstants.USE_COLLECTION, useCollection);
|
||||
}
|
||||
|
||||
if (additionalProperties.containsKey(CodegenConstants.RETURN_ICOLLECTION)) {
|
||||
setReturnICollection(convertPropertyToBooleanAndWriteBack(CodegenConstants.RETURN_ICOLLECTION));
|
||||
} else {
|
||||
additionalProperties.put(CodegenConstants.RETURN_ICOLLECTION, returnICollection);
|
||||
}
|
||||
|
||||
if (additionalProperties.containsKey(CodegenConstants.NETCORE_PROJECT_FILE)) {
|
||||
setNetCoreProjectFileFlag(convertPropertyToBooleanAndWriteBack(CodegenConstants.NETCORE_PROJECT_FILE));
|
||||
} else {
|
||||
additionalProperties.put(CodegenConstants.NETCORE_PROJECT_FILE, netCoreProjectFileFlag);
|
||||
}
|
||||
|
||||
if (additionalProperties.containsKey(CodegenConstants.INTERFACE_PREFIX)) {
|
||||
String useInterfacePrefix = additionalProperties.get(CodegenConstants.INTERFACE_PREFIX).toString();
|
||||
if ("false".equals(useInterfacePrefix.toLowerCase(Locale.ROOT))) {
|
||||
setInterfacePrefix("");
|
||||
} else if (!"true".equals(useInterfacePrefix.toLowerCase(Locale.ROOT))) {
|
||||
// NOTE: if user passes "true" explicitly, we use the default I- prefix. The other supported case here is a custom prefix.
|
||||
setInterfacePrefix(sanitizeName(useInterfacePrefix));
|
||||
}
|
||||
if (additionalProperties.containsKey(CodegenConstants.MODEL_PROPERTY_NAMING)) {
|
||||
setModelPropertyNaming((String) additionalProperties.get(CodegenConstants.MODEL_PROPERTY_NAMING));
|
||||
}
|
||||
|
||||
// This either updates additionalProperties with the above fixes, or sets the default if the option was not specified.
|
||||
@@ -374,62 +348,46 @@ public abstract class AbstractFSharpCodegen extends DefaultCodegen implements Co
|
||||
/*
|
||||
* F# does not allow forward declarations, so files must be imported in the correct order.
|
||||
* Output of CodeGen models must therefore bein dependency order (rather than alphabetical order, which seems to be the default).
|
||||
* We achieve this by creating a comparator to check whether the first model contains any properties of the comparison model's type
|
||||
* This could probably be made more efficient if absolutely needed.
|
||||
*/
|
||||
@SuppressWarnings({"unchecked"})
|
||||
public Map<String, Object> postProcessDependencyOrders(final Map<String, Object> objs) {
|
||||
Comparator<String> comparator = new Comparator<String>() {
|
||||
@Override
|
||||
public int compare(String key1, String key2) {
|
||||
// Get the corresponding models
|
||||
CodegenModel model1 = ModelUtils.getModelByName(key1, objs);
|
||||
CodegenModel model2 = ModelUtils.getModelByName(key2, objs);
|
||||
|
||||
List<String> complexVars1 = new ArrayList<String>();
|
||||
List<String> complexVars2 = new ArrayList<String>();
|
||||
Map<String, Set<String>> dependencies = new HashMap<String, Set<String>>();
|
||||
|
||||
for (CodegenProperty prop : model1.vars) {
|
||||
if (prop.complexType != null)
|
||||
complexVars1.add(prop.complexType);
|
||||
}
|
||||
for (CodegenProperty prop : model2.vars) {
|
||||
if (prop.complexType != null)
|
||||
complexVars2.add(prop.complexType);
|
||||
}
|
||||
|
||||
// if first has complex vars and second has none, first is greater
|
||||
if (complexVars1.size() > 0 && complexVars2.size() == 0)
|
||||
return 1;
|
||||
|
||||
// if second has complex vars and first has none, first is lesser
|
||||
if (complexVars1.size() == 0 && complexVars2.size() > 0)
|
||||
return -1;
|
||||
|
||||
// if first has complex var that matches the second's key, first is greater
|
||||
if (complexVars1.contains(key2))
|
||||
return 1;
|
||||
|
||||
// if second has complex var that matches the first's key, first is lesser
|
||||
if (complexVars2.contains(key1))
|
||||
return -1;
|
||||
|
||||
// if none of the above, don't care
|
||||
return 0;
|
||||
List<String> classNames = new ArrayList<String>();
|
||||
|
||||
for (String k : objs.keySet()) {
|
||||
CodegenModel model = ModelUtils.getModelByName(k, objs);
|
||||
if (model == null || model.classname == null) {
|
||||
throw new RuntimeException("Null model encountered");
|
||||
}
|
||||
dependencies.put(model.classname, model.imports);
|
||||
|
||||
classNames.add(model.classname);
|
||||
}
|
||||
|
||||
Object[] sortedKeys = classNames.toArray();
|
||||
|
||||
for (int i1 = 0; i1 < sortedKeys.length; i1++) {
|
||||
String k1 = sortedKeys[i1].toString();
|
||||
for (int i2 = i1 + 1; i2 < sortedKeys.length; i2++) {
|
||||
String k2 = sortedKeys[i2].toString();
|
||||
if (dependencies.get(k2).contains(k1)) {
|
||||
sortedKeys[i2] = k1;
|
||||
sortedKeys[i1] = k2;
|
||||
i1 = -1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
};
|
||||
PriorityQueue<String> queue = new PriorityQueue<String>(objs.size(), comparator);
|
||||
for (Object k : objs.keySet()) {
|
||||
queue.add(k.toString());
|
||||
}
|
||||
|
||||
Map<String, Object> sorted = new LinkedHashMap<String, Object>();
|
||||
|
||||
while (queue.size() > 0) {
|
||||
String key = queue.poll();
|
||||
sorted.put(key, objs.get(key));
|
||||
for (int i = sortedKeys.length - 1; i >= 0; i--) {
|
||||
Object k = sortedKeys[i];
|
||||
sorted.put(k.toString(), objs.get(k));
|
||||
}
|
||||
|
||||
return sorted;
|
||||
}
|
||||
|
||||
@@ -684,6 +642,39 @@ public abstract class AbstractFSharpCodegen extends DefaultCodegen implements Co
|
||||
return camelize(sanitizeName(operationId));
|
||||
}
|
||||
|
||||
public String getModelPropertyNaming() {
|
||||
return this.modelPropertyNaming;
|
||||
}
|
||||
|
||||
public void setModelPropertyNaming(String naming) {
|
||||
if ("original".equals(naming) || "camelCase".equals(naming) ||
|
||||
"PascalCase".equals(naming) || "snake_case".equals(naming)) {
|
||||
this.modelPropertyNaming = naming;
|
||||
} else {
|
||||
throw new IllegalArgumentException("Invalid model property naming '" +
|
||||
naming + "'. Must be 'original', 'camelCase', " +
|
||||
"'PascalCase' or 'snake_case'");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public String getNameUsingModelPropertyNaming(String name) {
|
||||
switch (CodegenConstants.MODEL_PROPERTY_NAMING_TYPE.valueOf(getModelPropertyNaming())) {
|
||||
case original:
|
||||
return name;
|
||||
case camelCase:
|
||||
return camelize(name, true);
|
||||
case PascalCase:
|
||||
return camelize(name);
|
||||
case snake_case:
|
||||
return underscore(name);
|
||||
default:
|
||||
throw new IllegalArgumentException("Invalid model property naming '" +
|
||||
name + "'. Must be 'original', 'camelCase', " +
|
||||
"'PascalCase' or 'snake_case'");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toVarName(String name) {
|
||||
// sanitize name
|
||||
@@ -694,9 +685,8 @@ public abstract class AbstractFSharpCodegen extends DefaultCodegen implements Co
|
||||
return name;
|
||||
}
|
||||
|
||||
// camelize the variable name
|
||||
// pet_id => PetId
|
||||
name = camelize(name);
|
||||
name = getNameUsingModelPropertyNaming(name);
|
||||
|
||||
// for reserved word or word starting with number, append _
|
||||
if (isReservedWord(name) || name.matches("^\\d.*")) {
|
||||
name = escapeReservedWord(name);
|
||||
|
||||
@@ -96,6 +96,7 @@ public abstract class AbstractGoCodegen extends DefaultCodegen implements Codege
|
||||
typeMapping.put("number", "float32");
|
||||
typeMapping.put("float", "float32");
|
||||
typeMapping.put("double", "float64");
|
||||
typeMapping.put("BigDecimal", "float64");
|
||||
typeMapping.put("boolean", "bool");
|
||||
typeMapping.put("string", "string");
|
||||
typeMapping.put("UUID", "string");
|
||||
@@ -376,6 +377,11 @@ public abstract class AbstractGoCodegen extends DefaultCodegen implements Codege
|
||||
boolean addedOSImport = false;
|
||||
boolean addedReflectImport = false;
|
||||
for (CodegenOperation operation : operations) {
|
||||
// import "os" if the operation uses files
|
||||
if (!addedOSImport && "*os.File".equals(operation.returnType)) {
|
||||
imports.add(createMapping("import", "os"));
|
||||
addedOSImport = true;
|
||||
}
|
||||
for (CodegenParameter param : operation.allParams) {
|
||||
// import "os" if the operation uses files
|
||||
if (!addedOSImport && "*os.File".equals(param.dataType)) {
|
||||
@@ -489,7 +495,8 @@ public abstract class AbstractGoCodegen extends DefaultCodegen implements Codege
|
||||
if (v instanceof CodegenModel) {
|
||||
CodegenModel model = (CodegenModel) v;
|
||||
for (CodegenProperty param : model.vars) {
|
||||
if (!addedTimeImport && "time.Time".equals(param.baseType)) {
|
||||
if (!addedTimeImport
|
||||
&& "time.Time".equals(param.dataType) || ("[]time.Time".equals(param.dataType))) {
|
||||
imports.add(createMapping("import", "time"));
|
||||
addedTimeImport = true;
|
||||
}
|
||||
|
||||
@@ -43,6 +43,8 @@ import static org.openapitools.codegen.utils.StringUtils.*;
|
||||
public abstract class AbstractJavaCodegen extends DefaultCodegen implements CodegenConfig {
|
||||
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(AbstractJavaCodegen.class);
|
||||
private static final String ARTIFACT_VERSION_DEFAULT_VALUE = "1.0.0";
|
||||
|
||||
public static final String FULL_JAVA_UTIL = "fullJavaUtil";
|
||||
public static final String DEFAULT_LIBRARY = "<default>";
|
||||
public static final String DATE_LIBRARY = "dateLibrary";
|
||||
@@ -60,7 +62,7 @@ public abstract class AbstractJavaCodegen extends DefaultCodegen implements Code
|
||||
protected String invokerPackage = "org.openapitools";
|
||||
protected String groupId = "org.openapitools";
|
||||
protected String artifactId = "openapi-java";
|
||||
protected String artifactVersion = "1.0.0";
|
||||
protected String artifactVersion = null;
|
||||
protected String artifactUrl = "https://github.com/openapitools/openapi-generator";
|
||||
protected String artifactDescription = "OpenAPI Java";
|
||||
protected String developerName = "OpenAPI-Generator Contributors";
|
||||
@@ -144,7 +146,7 @@ public abstract class AbstractJavaCodegen extends DefaultCodegen implements Code
|
||||
cliOptions.add(new CliOption(CodegenConstants.INVOKER_PACKAGE, CodegenConstants.INVOKER_PACKAGE_DESC).defaultValue(this.getInvokerPackage()));
|
||||
cliOptions.add(new CliOption(CodegenConstants.GROUP_ID, CodegenConstants.GROUP_ID_DESC).defaultValue(this.getGroupId()));
|
||||
cliOptions.add(new CliOption(CodegenConstants.ARTIFACT_ID, CodegenConstants.ARTIFACT_ID_DESC).defaultValue(this.getArtifactId()));
|
||||
cliOptions.add(new CliOption(CodegenConstants.ARTIFACT_VERSION, CodegenConstants.ARTIFACT_VERSION_DESC).defaultValue(this.getArtifactVersion()));
|
||||
cliOptions.add(new CliOption(CodegenConstants.ARTIFACT_VERSION, CodegenConstants.ARTIFACT_VERSION_DESC).defaultValue(ARTIFACT_VERSION_DEFAULT_VALUE));
|
||||
cliOptions.add(new CliOption(CodegenConstants.ARTIFACT_URL, CodegenConstants.ARTIFACT_URL_DESC).defaultValue(this.getArtifactUrl()));
|
||||
cliOptions.add(new CliOption(CodegenConstants.ARTIFACT_DESCRIPTION, CodegenConstants.ARTIFACT_DESCRIPTION_DESC).defaultValue(this.getArtifactDescription()));
|
||||
cliOptions.add(new CliOption(CodegenConstants.SCM_CONNECTION, CodegenConstants.SCM_CONNECTION_DESC).defaultValue(this.getScmConnection()));
|
||||
@@ -1038,12 +1040,18 @@ public abstract class AbstractJavaCodegen extends DefaultCodegen implements Code
|
||||
}
|
||||
}
|
||||
|
||||
// If no artifactVersion is provided in additional properties, version from API specification is used.
|
||||
// If none of them is provided then fallbacks to default version
|
||||
if (additionalProperties.containsKey(CodegenConstants.ARTIFACT_VERSION)) {
|
||||
this.setArtifactVersion((String) additionalProperties.get(CodegenConstants.ARTIFACT_VERSION));
|
||||
} else if (openAPI.getInfo() != null && openAPI.getInfo().getVersion() != null) {
|
||||
this.setArtifactVersion(openAPI.getInfo().getVersion());
|
||||
if(artifactVersion == null) {
|
||||
// If no artifactVersion is provided in additional properties, version from API specification is used.
|
||||
// If none of them is provided then fallbacks to default version
|
||||
if (additionalProperties.containsKey(CodegenConstants.ARTIFACT_VERSION)) {
|
||||
this.setArtifactVersion((String) additionalProperties.get(CodegenConstants.ARTIFACT_VERSION));
|
||||
} else if (openAPI.getInfo() != null && openAPI.getInfo().getVersion() != null) {
|
||||
this.setArtifactVersion(openAPI.getInfo().getVersion());
|
||||
} else {
|
||||
this.setArtifactVersion(ARTIFACT_VERSION_DEFAULT_VALUE);
|
||||
}
|
||||
} else {
|
||||
additionalProperties.put(CodegenConstants.ARTIFACT_VERSION, artifactVersion);
|
||||
}
|
||||
|
||||
if (additionalProperties.containsKey(CodegenConstants.SNAPSHOT_VERSION)) {
|
||||
@@ -1433,7 +1441,10 @@ public abstract class AbstractJavaCodegen extends DefaultCodegen implements Code
|
||||
* @return SNAPSHOT version
|
||||
*/
|
||||
private String buildSnapshotVersion(String version) {
|
||||
return version + "-" + "SNAPSHOT";
|
||||
if(version.endsWith("-SNAPSHOT")) {
|
||||
return version;
|
||||
}
|
||||
return version + "-SNAPSHOT";
|
||||
}
|
||||
|
||||
public void setSupportJava6(boolean value) {
|
||||
|
||||
@@ -244,11 +244,10 @@ public abstract class AbstractJavaJAXRSServerCodegen extends AbstractJavaCodegen
|
||||
@Override
|
||||
public String toApiName(final String name) {
|
||||
String computed = name;
|
||||
if (computed.length() == 0) {
|
||||
return "DefaultApi";
|
||||
if (computed.length() > 0) {
|
||||
computed = sanitizeName(computed);
|
||||
}
|
||||
computed = sanitizeName(computed);
|
||||
return camelize(computed) + "Api";
|
||||
return super.toApiName(computed);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -54,6 +54,8 @@ public abstract class AbstractKotlinCodegen extends DefaultCodegen implements Co
|
||||
protected String modelDocPath = "docs/";
|
||||
protected boolean parcelizeModels = false;
|
||||
|
||||
protected boolean serializableModel = false;
|
||||
|
||||
protected CodegenConstants.ENUM_PROPERTY_NAMING_TYPE enumPropertyNaming = CodegenConstants.ENUM_PROPERTY_NAMING_TYPE.camelCase;
|
||||
protected SERIALIZATION_LIBRARY_TYPE serializationLibrary = SERIALIZATION_LIBRARY_TYPE.moshi;
|
||||
|
||||
@@ -215,6 +217,7 @@ public abstract class AbstractKotlinCodegen extends DefaultCodegen implements Co
|
||||
cliOptions.add(serializationLibraryOpt.defaultValue(serializationLibrary.name()));
|
||||
|
||||
cliOptions.add(new CliOption(CodegenConstants.PARCELIZE_MODELS, CodegenConstants.PARCELIZE_MODELS_DESC));
|
||||
cliOptions.add(new CliOption(CodegenConstants.SERIALIZABLE_MODEL, CodegenConstants.SERIALIZABLE_MODEL_DESC));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -411,16 +414,14 @@ public abstract class AbstractKotlinCodegen extends DefaultCodegen implements Co
|
||||
LOGGER.warn(CodegenConstants.INVOKER_PACKAGE + " with " + this.getName() + " generator is ignored. Use " + CodegenConstants.PACKAGE_NAME + ".");
|
||||
}
|
||||
|
||||
if (additionalProperties.containsKey(CodegenConstants.SERIALIZABLE_MODEL)) {
|
||||
this.setSerializableModel(Boolean.valueOf((String) additionalProperties.get(CodegenConstants.SERIALIZABLE_MODEL)));
|
||||
} else {
|
||||
additionalProperties.put(CodegenConstants.SERIALIZABLE_MODEL, serializableModel);
|
||||
}
|
||||
|
||||
if (additionalProperties.containsKey(CodegenConstants.PARCELIZE_MODELS)) {
|
||||
this.setParcelizeModels(Boolean.valueOf((String) additionalProperties.get(CodegenConstants.PARCELIZE_MODELS)));
|
||||
LOGGER.info(CodegenConstants.PARCELIZE_MODELS + " depends on the android framework and " +
|
||||
"experimental parcelize feature. Make sure your build applies the android plugin:\n" +
|
||||
"apply plugin: 'com.android.library' OR apply plugin: 'com.android.application'.\n" +
|
||||
"and enables the experimental features:\n" +
|
||||
"androidExtensions {\n" +
|
||||
" experimental = true\n" +
|
||||
"}"
|
||||
);
|
||||
} else {
|
||||
additionalProperties.put(CodegenConstants.PARCELIZE_MODELS, parcelizeModels);
|
||||
}
|
||||
@@ -468,6 +469,13 @@ public abstract class AbstractKotlinCodegen extends DefaultCodegen implements Co
|
||||
this.parcelizeModels = parcelizeModels;
|
||||
}
|
||||
|
||||
public boolean isSerializableModel() {
|
||||
return serializableModel;
|
||||
}
|
||||
|
||||
public void setSerializableModel(boolean serializableModel) {
|
||||
this.serializableModel = serializableModel;
|
||||
}
|
||||
/**
|
||||
* Return the sanitized variable name for enum
|
||||
*
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -95,6 +95,7 @@ public class CSharpClientCodegen extends AbstractCSharpCodegen {
|
||||
typeMapping.put("long", "long");
|
||||
typeMapping.put("double", "double");
|
||||
typeMapping.put("number", "decimal");
|
||||
typeMapping.put("BigDecimal", "decimal");
|
||||
typeMapping.put("DateTime", "DateTime");
|
||||
typeMapping.put("date", "DateTime");
|
||||
typeMapping.put("UUID", "Guid");
|
||||
|
||||
@@ -94,6 +94,7 @@ public class CSharpNetCoreClientCodegen extends AbstractCSharpCodegen {
|
||||
typeMapping.put("long", "long");
|
||||
typeMapping.put("double", "double");
|
||||
typeMapping.put("number", "decimal");
|
||||
typeMapping.put("BigDecimal", "decimal");
|
||||
typeMapping.put("DateTime", "DateTime");
|
||||
typeMapping.put("date", "DateTime");
|
||||
typeMapping.put("file", "System.IO.Stream");
|
||||
|
||||
@@ -27,6 +27,8 @@ import org.apache.commons.lang3.StringUtils;
|
||||
import org.openapitools.codegen.*;
|
||||
import org.openapitools.codegen.utils.ModelUtils;
|
||||
import org.openapitools.codegen.utils.URLPathUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.*;
|
||||
@@ -35,10 +37,15 @@ import java.net.URL;
|
||||
import static org.openapitools.codegen.utils.StringUtils.*;
|
||||
|
||||
public class CppPistacheServerCodegen extends AbstractCppCodegen {
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(CppPistacheServerCodegen.class);
|
||||
|
||||
protected String implFolder = "impl";
|
||||
protected boolean isAddExternalLibs = true;
|
||||
protected boolean isUseStructModel = false;
|
||||
public static final String OPTIONAL_EXTERNAL_LIB = "addExternalLibs";
|
||||
public static final String OPTIONAL_EXTERNAL_LIB_DESC = "Add the Possibility to fetch and compile external Libraries needed by this Framework.";
|
||||
public static final String OPTION_USE_STRUCT_MODEL = "useStructModel";
|
||||
public static final String OPTION_USE_STRUCT_MODEL_DESC = "Use struct-based model template instead of get/set-based model template";
|
||||
public static final String HELPERS_PACKAGE_NAME = "helpersPackage";
|
||||
public static final String HELPERS_PACKAGE_NAME_DESC = "Specify the package name to be used for the helpers (e.g. org.openapitools.server.helpers).";
|
||||
protected final String PREFIX = "";
|
||||
@@ -68,9 +75,6 @@ public class CppPistacheServerCodegen extends AbstractCppCodegen {
|
||||
apiPackage = "org.openapitools.server.api";
|
||||
modelPackage = "org.openapitools.server.model";
|
||||
|
||||
modelTemplateFiles.put("model-header.mustache", ".h");
|
||||
modelTemplateFiles.put("model-source.mustache", ".cpp");
|
||||
|
||||
apiTemplateFiles.put("api-header.mustache", ".h");
|
||||
apiTemplateFiles.put("api-source.mustache", ".cpp");
|
||||
apiTemplateFiles.put("api-impl-header.mustache", ".h");
|
||||
@@ -81,6 +85,7 @@ public class CppPistacheServerCodegen extends AbstractCppCodegen {
|
||||
cliOptions.clear();
|
||||
addSwitch(OPTIONAL_EXTERNAL_LIB, OPTIONAL_EXTERNAL_LIB_DESC, this.isAddExternalLibs);
|
||||
addOption(HELPERS_PACKAGE_NAME, HELPERS_PACKAGE_NAME_DESC, this.helpersPackage);
|
||||
addSwitch(OPTION_USE_STRUCT_MODEL, OPTION_USE_STRUCT_MODEL_DESC, this.isUseStructModel);
|
||||
|
||||
reservedWords = new HashSet<>();
|
||||
|
||||
@@ -144,6 +149,23 @@ public class CppPistacheServerCodegen extends AbstractCppCodegen {
|
||||
} else {
|
||||
additionalProperties.put(OPTIONAL_EXTERNAL_LIB, isAddExternalLibs);
|
||||
}
|
||||
|
||||
setupModelTemplate();
|
||||
}
|
||||
|
||||
private void setupModelTemplate() {
|
||||
if (additionalProperties.containsKey(OPTION_USE_STRUCT_MODEL))
|
||||
isUseStructModel = convertPropertyToBooleanAndWriteBack(OPTION_USE_STRUCT_MODEL);
|
||||
|
||||
if (isUseStructModel) {
|
||||
LOGGER.info("Using struct-based model template");
|
||||
modelTemplateFiles.put("model-struct-header.mustache", ".h");
|
||||
modelTemplateFiles.put("model-struct-source.mustache", ".cpp");
|
||||
} else {
|
||||
LOGGER.info("Using get/set-based model template");
|
||||
modelTemplateFiles.put("model-header.mustache", ".h");
|
||||
modelTemplateFiles.put("model-source.mustache", ".cpp");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -26,7 +26,7 @@ public class CppQt5AbstractCodegen extends AbstractCppCodegen implements Codegen
|
||||
protected Set<String> systemIncludes = new HashSet<String>();
|
||||
|
||||
protected Set<String> nonFrameworkPrimitives = new HashSet<String>();
|
||||
|
||||
|
||||
public CppQt5AbstractCodegen() {
|
||||
super();
|
||||
// set modelNamePrefix as default for QHttpEngine Server
|
||||
@@ -61,10 +61,10 @@ public class CppQt5AbstractCodegen extends AbstractCppCodegen implements Codegen
|
||||
"double")
|
||||
);
|
||||
nonFrameworkPrimitives.addAll(languageSpecificPrimitives);
|
||||
|
||||
|
||||
foundationClasses.addAll(
|
||||
Arrays.asList(
|
||||
"QString",
|
||||
"QString",
|
||||
"QDate",
|
||||
"QDateTime",
|
||||
"QByteArray")
|
||||
@@ -78,7 +78,7 @@ public class CppQt5AbstractCodegen extends AbstractCppCodegen implements Codegen
|
||||
typeMapping.put("integer", "qint32");
|
||||
typeMapping.put("long", "qint64");
|
||||
typeMapping.put("boolean", "bool");
|
||||
typeMapping.put("number", "double");
|
||||
typeMapping.put("number", "double");
|
||||
typeMapping.put("array", "QList");
|
||||
typeMapping.put("map", "QMap");
|
||||
typeMapping.put("object", PREFIX + "Object");
|
||||
@@ -90,8 +90,8 @@ public class CppQt5AbstractCodegen extends AbstractCppCodegen implements Codegen
|
||||
// modifications on multiple templates)
|
||||
typeMapping.put("UUID", "QString");
|
||||
typeMapping.put("URI", "QString");
|
||||
typeMapping.put("file", "QIODevice");
|
||||
typeMapping.put("binary", "QIODevice");
|
||||
typeMapping.put("file", "QByteArray");
|
||||
typeMapping.put("binary", "QByteArray");
|
||||
importMapping = 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("QDateTime");
|
||||
systemIncludes.add("QByteArray");
|
||||
systemIncludes.add("QIODevice");
|
||||
}
|
||||
@Override
|
||||
public void processOpts() {
|
||||
@@ -119,7 +118,7 @@ public class CppQt5AbstractCodegen extends AbstractCppCodegen implements Codegen
|
||||
additionalProperties().put("prefix", modelNamePrefix);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String toModelImport(String name) {
|
||||
if( name.isEmpty() ) {
|
||||
@@ -140,7 +139,7 @@ public class CppQt5AbstractCodegen extends AbstractCppCodegen implements Codegen
|
||||
|
||||
return "#include \"" + folder + name + ".h\"";
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 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
|
||||
@@ -160,9 +159,9 @@ public class CppQt5AbstractCodegen extends AbstractCppCodegen implements Codegen
|
||||
Schema inner = ModelUtils.getAdditionalProperties(p);
|
||||
return getSchemaType(p) + "<QString, " + getTypeDeclaration(inner) + ">";
|
||||
} else if (ModelUtils.isBinarySchema(p)) {
|
||||
return getSchemaType(p) + "*";
|
||||
return getSchemaType(p);
|
||||
} else if (ModelUtils.isFileSchema(p)) {
|
||||
return getSchemaType(p) + "*";
|
||||
return getSchemaType(p);
|
||||
}
|
||||
if (foundationClasses.contains(openAPIType)) {
|
||||
return openAPIType;
|
||||
@@ -174,7 +173,7 @@ public class CppQt5AbstractCodegen extends AbstractCppCodegen implements Codegen
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("rawtypes")
|
||||
@SuppressWarnings("rawtypes")
|
||||
public String toDefaultValue(Schema p) {
|
||||
if (ModelUtils.isBooleanSchema(p)) {
|
||||
return "false";
|
||||
@@ -211,7 +210,7 @@ public class CppQt5AbstractCodegen extends AbstractCppCodegen implements Codegen
|
||||
public String toModelFilename(String name) {
|
||||
return toModelName(name);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 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.
|
||||
@@ -219,7 +218,7 @@ public class CppQt5AbstractCodegen extends AbstractCppCodegen implements Codegen
|
||||
* @return a string value of the type or complex model for this property
|
||||
*/
|
||||
@Override
|
||||
@SuppressWarnings("rawtypes")
|
||||
@SuppressWarnings("rawtypes")
|
||||
public String getSchemaType(Schema p) {
|
||||
String openAPIType = super.getSchemaType(p);
|
||||
|
||||
@@ -242,7 +241,7 @@ public class CppQt5AbstractCodegen extends AbstractCppCodegen implements Codegen
|
||||
public String toVarName(String name) {
|
||||
// sanitize name
|
||||
String varName = name;
|
||||
varName = sanitizeName(name);
|
||||
varName = sanitizeName(name);
|
||||
|
||||
// if it's all uppper case, convert to lower case
|
||||
if (varName.matches("^[A-Z_]*$")) {
|
||||
@@ -270,7 +269,7 @@ public class CppQt5AbstractCodegen extends AbstractCppCodegen implements Codegen
|
||||
public String getTypeDeclaration(String str) {
|
||||
return str;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected boolean needToImport(String 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) {
|
||||
Map<String, Object> objectMap = (Map<String, Object>) objs.get("operations");
|
||||
List<CodegenOperation> operations = (List<CodegenOperation>) objectMap.get("operation");
|
||||
|
||||
|
||||
List<Map<String, String>> imports = (List<Map<String, String>>) objs.get("imports");
|
||||
Map<String, CodegenModel> codegenModels = new HashMap<String, CodegenModel> ();
|
||||
for(Object moObj : allModels) {
|
||||
@@ -298,7 +297,7 @@ public class CppQt5AbstractCodegen extends AbstractCppCodegen implements Codegen
|
||||
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
|
||||
if (operation.returnBaseType != null && needToImport(operation.returnBaseType)) {
|
||||
if(!isIncluded(operation.returnBaseType, imports)) {
|
||||
@@ -308,7 +307,7 @@ public class CppQt5AbstractCodegen extends AbstractCppCodegen implements Codegen
|
||||
List<CodegenParameter> params = new ArrayList<CodegenParameter>();
|
||||
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
|
||||
for(CodegenParameter param : params) {
|
||||
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
|
||||
if(!isIncluded("QString", imports)) {
|
||||
imports.add(createMapping("import", "QString"));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if(isIncluded("QMap", imports)) {
|
||||
@@ -332,28 +331,23 @@ public class CppQt5AbstractCodegen extends AbstractCppCodegen implements Codegen
|
||||
}
|
||||
return objs;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Object> postProcessModels(Map<String, Object> objs) {
|
||||
return postProcessModelsEnum(objs);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toEnumValue(String value, String datatype) {
|
||||
return escapeText(value);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean isDataTypeString(String dataType) {
|
||||
return "QString".equals(dataType);
|
||||
}
|
||||
|
||||
|
||||
private Map<String, String> createMapping(String key, String value) {
|
||||
Map<String, String> customImport = new HashMap<String, String>();
|
||||
customImport.put(key, toModelImport(value));
|
||||
return customImport;
|
||||
}
|
||||
|
||||
|
||||
private boolean isIncluded(String type, List<Map<String, String>> imports) {
|
||||
boolean included = false;
|
||||
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("HttpRequest.h.mustache", sourceFolder, PREFIX + "HttpRequest.h"));
|
||||
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("enum.mustache", sourceFolder, PREFIX + "Enum.h"));
|
||||
supportingFiles.add(new SupportingFile("enum.mustache", sourceFolder, PREFIX + "Enum.h"));
|
||||
if (optionalProjectFileFlag) {
|
||||
supportingFiles.add(new SupportingFile("Project.mustache", sourceFolder, "client.pri"));
|
||||
}
|
||||
typeMapping.put("file", PREFIX + "HttpRequestInputFileElement");
|
||||
typeMapping.put("binary", PREFIX +"HttpRequestInputFileElement");
|
||||
importMapping.put(PREFIX + "HttpRequestInputFileElement", "#include \"" + PREFIX + "HttpRequest.h\"");
|
||||
typeMapping.put("file", PREFIX + "HttpFileElement");
|
||||
importMapping.put(PREFIX + "HttpFileElement", "#include \"" + PREFIX + "HttpFileElement.h\"");
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -95,7 +96,7 @@ public class CppQt5ClientCodegen extends CppQt5AbstractCodegen implements Codege
|
||||
} else {
|
||||
additionalProperties.put(CodegenConstants.OPTIONAL_PROJECT_FILE, optionalProjectFileFlag);
|
||||
}
|
||||
|
||||
|
||||
if (additionalProperties.containsKey("modelNamePrefix")) {
|
||||
supportingFiles.clear();
|
||||
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.cpp.mustache", sourceFolder, modelNamePrefix + "HttpRequest.cpp"));
|
||||
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("binary", modelNamePrefix + "HttpRequestInputFileElement");
|
||||
importMapping.put(modelNamePrefix + "HttpRequestInputFileElement", "#include \"" + modelNamePrefix + "HttpRequest.h\"");
|
||||
typeMapping.put("file", modelNamePrefix + "HttpFileElement");
|
||||
importMapping.put(modelNamePrefix + "HttpFileElement", "#include \"" + modelNamePrefix + "HttpFileElement.h\"");
|
||||
if (optionalProjectFileFlag) {
|
||||
supportingFiles.add(new SupportingFile("Project.mustache", sourceFolder, modelNamePrefix + "client.pri"));
|
||||
}
|
||||
|
||||
@@ -76,7 +76,7 @@ public class CppQt5QHttpEngineServerCodegen extends CppQt5AbstractCodegen implem
|
||||
apiTemplateFiles.put(
|
||||
"apirequest.h.mustache", // the template to use
|
||||
".h"); // the extension for each file to write
|
||||
|
||||
|
||||
apiTemplateFiles.put(
|
||||
"apirequest.cpp.mustache", // the template to use
|
||||
".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.
|
||||
*/
|
||||
embeddedTemplateDir = templateDir = "cpp-qt5-qhttpengine-server";
|
||||
|
||||
|
||||
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("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("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.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("Dockerfile.mustache", sourceFolder, "Dockerfile"));
|
||||
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("object.mustache", sourceFolder + MODEL_DIR, modelNamePrefix + "Object.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.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("src-CMakeLists.txt.mustache", sourceFolder + SRC_DIR, "CMakeLists.txt"));
|
||||
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("Dockerfile.mustache", sourceFolder, "Dockerfile"));
|
||||
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() {
|
||||
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
|
||||
* instantiated
|
||||
@@ -182,7 +191,7 @@ public class CppQt5QHttpEngineServerCodegen extends CppQt5AbstractCodegen implem
|
||||
private String requestFileFolder() {
|
||||
return outputFolder + "/" + sourceFolder + APIREQUEST_DIR + "/" + apiPackage().replace("::", File.separator);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String apiFilename(String templateName, String tag) {
|
||||
String result = super.apiFilename(templateName, tag);
|
||||
@@ -193,7 +202,7 @@ public class CppQt5QHttpEngineServerCodegen extends CppQt5AbstractCodegen implem
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String toApiFilename(String name) {
|
||||
return modelNamePrefix + sanitizeName(camelize(name)) + "ApiHandler";
|
||||
|
||||
@@ -242,7 +242,7 @@ public class CppRestSdkClientCodegen extends AbstractCppCodegen {
|
||||
if (response != null) {
|
||||
CodegenProperty cm = fromProperty("response", response);
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -45,7 +45,7 @@ public class DartJaguarClientCodegen extends DartClientCodegen {
|
||||
modelToIgnore.add("object");
|
||||
modelToIgnore.add("list");
|
||||
modelToIgnore.add("file");
|
||||
modelToIgnore.add("uint8list");
|
||||
modelToIgnore.add("list<int>");
|
||||
}
|
||||
|
||||
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(SERIALIZATION_FORMAT, "Choose serialization format JSON or PROTO is supported"));
|
||||
|
||||
typeMapping.put("file", "Uint8List");
|
||||
typeMapping.put("binary", "Uint8List");
|
||||
typeMapping.put("file", "List<int>");
|
||||
typeMapping.put("binary", "List<int>");
|
||||
|
||||
protoTypeMapping.put("Array", "repeated");
|
||||
protoTypeMapping.put("array", "repeated");
|
||||
@@ -247,19 +247,19 @@ public class DartJaguarClientCodegen extends DartClientCodegen {
|
||||
}
|
||||
|
||||
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.dataType = "MultipartFile";
|
||||
}
|
||||
}
|
||||
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.dataType = "MultipartFile";
|
||||
}
|
||||
}
|
||||
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.dataType = "MultipartFile";
|
||||
}
|
||||
@@ -274,8 +274,6 @@ public class DartJaguarClientCodegen extends DartClientCodegen {
|
||||
for (String item : op.imports) {
|
||||
if (!modelToIgnore.contains(item.toLowerCase(Locale.ROOT))) {
|
||||
imports.add(underscore(item));
|
||||
} else if (item.equalsIgnoreCase("Uint8List")) {
|
||||
fullImports.add("dart:typed_data");
|
||||
}
|
||||
}
|
||||
modelImports.addAll(imports);
|
||||
|
||||
@@ -0,0 +1,151 @@
|
||||
/*
|
||||
* 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. x
|
||||
*/
|
||||
|
||||
package org.openapitools.codegen.languages;
|
||||
|
||||
import org.openapitools.codegen.*;
|
||||
import org.openapitools.codegen.meta.GeneratorMetadata;
|
||||
import org.openapitools.codegen.meta.Stability;
|
||||
import io.swagger.models.properties.ArrayProperty;
|
||||
import io.swagger.models.properties.MapProperty;
|
||||
import io.swagger.models.properties.Property;
|
||||
import io.swagger.models.parameters.Parameter;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.*;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
public class FsharpFunctionsServerCodegen extends AbstractFSharpCodegen {
|
||||
public static final String PROJECT_NAME = "projectName";
|
||||
|
||||
static Logger LOGGER = LoggerFactory.getLogger(FsharpFunctionsServerCodegen.class);
|
||||
|
||||
public CodegenType getTag() {
|
||||
return CodegenType.SERVER;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return "fsharp-functions";
|
||||
}
|
||||
|
||||
public String getHelp() {
|
||||
return "Generates a fsharp-functions server (beta).";
|
||||
}
|
||||
|
||||
public FsharpFunctionsServerCodegen() {
|
||||
super();
|
||||
|
||||
generatorMetadata = GeneratorMetadata.newBuilder(generatorMetadata)
|
||||
.stability(Stability.BETA)
|
||||
.build();
|
||||
|
||||
// CLI options
|
||||
addOption(CodegenConstants.LICENSE_URL,
|
||||
CodegenConstants.LICENSE_URL_DESC,
|
||||
licenseUrl);
|
||||
|
||||
addOption(CodegenConstants.LICENSE_NAME,
|
||||
CodegenConstants.LICENSE_NAME_DESC,
|
||||
licenseName);
|
||||
|
||||
addOption(CodegenConstants.PACKAGE_COPYRIGHT,
|
||||
CodegenConstants.PACKAGE_COPYRIGHT_DESC,
|
||||
packageCopyright);
|
||||
|
||||
addOption(CodegenConstants.PACKAGE_AUTHORS,
|
||||
CodegenConstants.PACKAGE_AUTHORS_DESC,
|
||||
packageAuthors);
|
||||
|
||||
addOption(CodegenConstants.PACKAGE_TITLE,
|
||||
CodegenConstants.PACKAGE_TITLE_DESC,
|
||||
packageTitle);
|
||||
|
||||
addOption(CodegenConstants.PACKAGE_NAME,
|
||||
"F# module name (convention: Title.Case).",
|
||||
packageName);
|
||||
|
||||
addOption(CodegenConstants.PACKAGE_VERSION,
|
||||
"F# package version.",
|
||||
packageVersion);
|
||||
|
||||
addOption(CodegenConstants.OPTIONAL_PROJECT_GUID,
|
||||
CodegenConstants.OPTIONAL_PROJECT_GUID_DESC,
|
||||
null);
|
||||
|
||||
addOption(CodegenConstants.SOURCE_FOLDER,
|
||||
CodegenConstants.SOURCE_FOLDER_DESC,
|
||||
sourceFolder);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void processOpts() {
|
||||
super.processOpts();
|
||||
|
||||
modelPackage = "Model";
|
||||
embeddedTemplateDir = templateDir = "fsharp-functions-server";
|
||||
|
||||
apiTemplateFiles.put("Handler.mustache", "Handler.fs");
|
||||
apiTemplateFiles.put("HandlerParams.mustache", "HandlerParams.fs");
|
||||
apiTemplateFiles.put("ServiceInterface.mustache", "ServiceInterface.fs");
|
||||
apiTemplateFiles.put("ServiceImpl.mustache", "Service.fs");
|
||||
modelTemplateFiles.put("Model.mustache", ".fs");
|
||||
|
||||
String implFolder = sourceFolder + File.separator + "impl";
|
||||
|
||||
supportingFiles.add(new SupportingFile("gitignore.mustache", "", ".gitignore"));
|
||||
supportingFiles.add(new SupportingFile("build.sh.mustache", projectFolder, "build.sh"));
|
||||
supportingFiles.add(new SupportingFile("build.bat.mustache", projectFolder, "build.bat"));
|
||||
supportingFiles.add(new SupportingFile("host.json", "", "host.json"));
|
||||
supportingFiles.add(new SupportingFile("local.settings.json", "", "local.settings.json"));
|
||||
supportingFiles.add(new SupportingFile("Project.fsproj.mustache", projectFolder, packageName + ".fsproj"));
|
||||
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public String modelFileFolder() {
|
||||
return super.modelFileFolder().replace("Model", "model");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String apiFileFolder() {
|
||||
return super.apiFileFolder() + File.separator + "api";
|
||||
}
|
||||
|
||||
private String implFileFolder() {
|
||||
return outputFolder + File.separator + sourceFolder + File.separator + "impl";
|
||||
}
|
||||
|
||||
@Override()
|
||||
public String toModelImport(String name) {
|
||||
return packageName + "." + modelPackage() + "." + name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String apiFilename(String templateName, String tag) {
|
||||
String result = super.apiFilename(templateName, tag);
|
||||
if (templateName.endsWith("Impl.mustache")) {
|
||||
int ix = result.lastIndexOf(File.separatorChar);
|
||||
result = result.substring(0, ix) + result.substring(ix, result.length() - 2) + "fs";
|
||||
result = result.replace(apiFileFolder(), implFileFolder());
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
@@ -22,6 +22,8 @@ import io.swagger.v3.oas.models.OpenAPI;
|
||||
import org.openapitools.codegen.CodegenConstants;
|
||||
import org.openapitools.codegen.CodegenOperation;
|
||||
import org.openapitools.codegen.CodegenType;
|
||||
import org.openapitools.codegen.meta.GeneratorMetadata;
|
||||
import org.openapitools.codegen.meta.Stability;
|
||||
import org.openapitools.codegen.SupportingFile;
|
||||
import org.openapitools.codegen.utils.URLPathUtils;
|
||||
import org.slf4j.Logger;
|
||||
@@ -59,6 +61,10 @@ public class FsharpGiraffeServerCodegen extends AbstractFSharpCodegen {
|
||||
public FsharpGiraffeServerCodegen() {
|
||||
super();
|
||||
|
||||
generatorMetadata = GeneratorMetadata.newBuilder(generatorMetadata)
|
||||
.stability(Stability.BETA)
|
||||
.build();
|
||||
|
||||
modelPackage = "Model";
|
||||
|
||||
apiTemplateFiles.put("Handler.mustache", "Handler.fs");
|
||||
@@ -187,7 +193,6 @@ public class FsharpGiraffeServerCodegen extends AbstractFSharpCodegen {
|
||||
LOGGER.warn("Library flag not currently supported.");
|
||||
|
||||
String authFolder = sourceFolder + File.separator + "auth";
|
||||
String serviceFolder = sourceFolder + File.separator + "services";
|
||||
String implFolder = sourceFolder + File.separator + "impl";
|
||||
String helperFolder = sourceFolder + File.separator + "helpers";
|
||||
|
||||
|
||||
@@ -63,6 +63,7 @@ public class HaskellHttpClientCodegen extends DefaultCodegen implements CodegenC
|
||||
public static final String PROP_CABAL_VERSION = "cabalVersion";
|
||||
public static final String PROP_CONFIG_TYPE = "configType";
|
||||
public static final String PROP_DATETIME_FORMAT = "dateTimeFormat";
|
||||
public static final String PROP_DATETIME_PARSE_FORMAT = "dateTimeParseFormat";
|
||||
public static final String PROP_CUSTOM_TEST_INSTANCE_MODULE = "customTestInstanceModule";
|
||||
public static final String PROP_DATE_FORMAT = "dateFormat";
|
||||
public static final String PROP_GENERATE_ENUMS = "generateEnums";
|
||||
@@ -222,6 +223,7 @@ public class HaskellHttpClientCodegen extends DefaultCodegen implements CodegenC
|
||||
typeMapping.put("float", "Float");
|
||||
typeMapping.put("double", "Double");
|
||||
typeMapping.put("number", "Double");
|
||||
typeMapping.put("BigDecimal", "Double");
|
||||
typeMapping.put("integer", "Int");
|
||||
typeMapping.put("file", "FilePath");
|
||||
// lib
|
||||
@@ -270,6 +272,7 @@ public class HaskellHttpClientCodegen extends DefaultCodegen implements CodegenC
|
||||
cliOptions.add(CliOption.newBoolean(PROP_USE_KATIP, "Sets the default value for the UseKatip cabal flag. If true, the katip package provides logging instead of monad-logger").defaultValue((Boolean.TRUE.toString())));
|
||||
|
||||
cliOptions.add(CliOption.newString(PROP_DATETIME_FORMAT, "format string used to parse/render a datetime"));
|
||||
cliOptions.add(CliOption.newString(PROP_DATETIME_PARSE_FORMAT, "overrides the format string used to parse a datetime"));
|
||||
cliOptions.add(CliOption.newString(PROP_DATE_FORMAT, "format string used to parse/render a date").defaultValue(defaultDateFormat));
|
||||
|
||||
cliOptions.add(CliOption.newString(PROP_CUSTOM_TEST_INSTANCE_MODULE, "test module used to provide typeclass instances for types not known by the generator"));
|
||||
@@ -320,9 +323,9 @@ public class HaskellHttpClientCodegen extends DefaultCodegen implements CodegenC
|
||||
}
|
||||
}
|
||||
|
||||
public void setDateTimeFormat(String value) {
|
||||
setStringProp(PROP_DATETIME_FORMAT, value);
|
||||
}
|
||||
public void setDateTimeFormat(String value) { setStringProp(PROP_DATETIME_FORMAT, value); }
|
||||
|
||||
public void setDateTimeParseFormat(String value) { setStringProp(PROP_DATETIME_PARSE_FORMAT, value); }
|
||||
|
||||
public void setDateFormat(String value) { setStringProp(PROP_DATE_FORMAT, value); }
|
||||
|
||||
@@ -437,6 +440,12 @@ public class HaskellHttpClientCodegen extends DefaultCodegen implements CodegenC
|
||||
setDateTimeFormat(null); // default should be null
|
||||
}
|
||||
|
||||
if (additionalProperties.containsKey(PROP_DATETIME_PARSE_FORMAT)) {
|
||||
setDateTimeParseFormat(additionalProperties.get(PROP_DATETIME_PARSE_FORMAT).toString());
|
||||
} else {
|
||||
setDateTimeParseFormat(null); // default should be null
|
||||
}
|
||||
|
||||
if (additionalProperties.containsKey(PROP_DATE_FORMAT)) {
|
||||
setDateFormat(additionalProperties.get(PROP_DATE_FORMAT).toString());
|
||||
} else {
|
||||
|
||||
@@ -171,6 +171,7 @@ public class HaskellServantCodegen extends DefaultCodegen implements CodegenConf
|
||||
typeMapping.put("file", "FilePath");
|
||||
typeMapping.put("binary", "FilePath");
|
||||
typeMapping.put("number", "Double");
|
||||
typeMapping.put("BigDecimal", "Double");
|
||||
typeMapping.put("any", "Value");
|
||||
typeMapping.put("UUID", "UUID");
|
||||
typeMapping.put("URI", "Text");
|
||||
|
||||
@@ -17,19 +17,23 @@
|
||||
|
||||
package org.openapitools.codegen.languages;
|
||||
|
||||
import static org.openapitools.codegen.utils.StringUtils.camelize;
|
||||
|
||||
import io.swagger.v3.oas.models.Operation;
|
||||
import io.swagger.v3.oas.models.media.Schema;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.openapitools.codegen.*;
|
||||
import org.openapitools.codegen.CliOption;
|
||||
import org.openapitools.codegen.CodegenConstants;
|
||||
import org.openapitools.codegen.CodegenModel;
|
||||
import org.openapitools.codegen.CodegenOperation;
|
||||
import org.openapitools.codegen.SupportingFile;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import static org.openapitools.codegen.utils.StringUtils.camelize;
|
||||
|
||||
public class JavaJAXRSSpecServerCodegen extends AbstractJavaJAXRSServerCodegen {
|
||||
|
||||
public static final String INTERFACE_ONLY = "interfaceOnly";
|
||||
@@ -39,6 +43,11 @@ public class JavaJAXRSSpecServerCodegen extends AbstractJavaJAXRSServerCodegen {
|
||||
public static final String JACKSON = "jackson";
|
||||
public static final String OPEN_API_SPEC_FILE_LOCATION = "openApiSpecFileLocation";
|
||||
|
||||
public static final String QUARKUS_LIBRARY = "quarkus";
|
||||
public static final String THORNTAIL_LIBRARY = "thorntail";
|
||||
public static final String OPEN_LIBERTY_LIBRARY = "openliberty";
|
||||
public static final String HELIDON_LIBRARY = "helidon";
|
||||
|
||||
private boolean interfaceOnly = false;
|
||||
private boolean returnResponse = false;
|
||||
private boolean generatePom = true;
|
||||
@@ -84,8 +93,11 @@ public class JavaJAXRSSpecServerCodegen extends AbstractJavaJAXRSServerCodegen {
|
||||
|
||||
removeOption(CodegenConstants.LIBRARY);
|
||||
CliOption library = new CliOption(CodegenConstants.LIBRARY, CodegenConstants.LIBRARY_DESC).defaultValue(DEFAULT_LIBRARY);
|
||||
Map<String, String> supportedLibraries = new LinkedHashMap<>();
|
||||
supportedLibraries.put(DEFAULT_LIBRARY, "JAXRS");
|
||||
supportedLibraries.put(DEFAULT_LIBRARY, "JAXRS spec only, to be deployed in an app server (TomEE, JBoss, WLS, ...)");
|
||||
supportedLibraries.put(QUARKUS_LIBRARY, "Server using Quarkus");
|
||||
supportedLibraries.put(THORNTAIL_LIBRARY, "Server using Thorntail");
|
||||
supportedLibraries.put(OPEN_LIBERTY_LIBRARY, "Server using Open Liberty");
|
||||
supportedLibraries.put(HELIDON_LIBRARY, "Server using Helidon");
|
||||
library.setEnum(supportedLibraries);
|
||||
|
||||
cliOptions.add(library);
|
||||
@@ -113,12 +125,20 @@ public class JavaJAXRSSpecServerCodegen extends AbstractJavaJAXRSServerCodegen {
|
||||
additionalProperties.remove(RETURN_RESPONSE);
|
||||
}
|
||||
}
|
||||
if (additionalProperties.containsKey(USE_SWAGGER_ANNOTATIONS)) {
|
||||
useSwaggerAnnotations = Boolean.valueOf(additionalProperties.get(USE_SWAGGER_ANNOTATIONS).toString());
|
||||
if(QUARKUS_LIBRARY.equals(library) || THORNTAIL_LIBRARY.equals(library) || HELIDON_LIBRARY.equals(library) || OPEN_LIBERTY_LIBRARY.equals(library)) {
|
||||
useSwaggerAnnotations = false;
|
||||
} else {
|
||||
if (additionalProperties.containsKey(USE_SWAGGER_ANNOTATIONS)) {
|
||||
useSwaggerAnnotations = Boolean.valueOf(additionalProperties.get(USE_SWAGGER_ANNOTATIONS).toString());
|
||||
}
|
||||
}
|
||||
writePropertyBack(USE_SWAGGER_ANNOTATIONS, useSwaggerAnnotations);
|
||||
if (additionalProperties.containsKey(OPEN_API_SPEC_FILE_LOCATION)) {
|
||||
openApiSpecFileLocation = additionalProperties.get(OPEN_API_SPEC_FILE_LOCATION).toString();
|
||||
} else if(QUARKUS_LIBRARY.equals(library) || THORNTAIL_LIBRARY.equals(library) || HELIDON_LIBRARY.equals(library)) {
|
||||
openApiSpecFileLocation = "src/main/resources/META-INF/openapi.yaml";
|
||||
} else if(OPEN_LIBERTY_LIBRARY.equals(library)) {
|
||||
openApiSpecFileLocation = "src/main/webapp/META-INF/openapi.yaml";
|
||||
}
|
||||
additionalProperties.put(OPEN_API_SPEC_FILE_LOCATION, openApiSpecFileLocation);
|
||||
|
||||
@@ -154,6 +174,26 @@ public class JavaJAXRSSpecServerCodegen extends AbstractJavaJAXRSServerCodegen {
|
||||
}
|
||||
supportingFiles.add(new SupportingFile("openapi.mustache", fileFolder, fileName));
|
||||
}
|
||||
|
||||
if(QUARKUS_LIBRARY.equals(library)) {
|
||||
writeOptional(outputFolder, new SupportingFile("application.properties.mustache", "src/main/resources", "application.properties"));
|
||||
|
||||
writeOptional(outputFolder, new SupportingFile("Dockerfile.jvm.mustache", "src/main/docker", "Dockerfile.jvm"));
|
||||
writeOptional(outputFolder, new SupportingFile("Dockerfile.native.mustache", "src/main/docker", "Dockerfile.native"));
|
||||
writeOptional(outputFolder, new SupportingFile("dockerignore.mustache", "", ".dockerignore"));
|
||||
} else if(OPEN_LIBERTY_LIBRARY.equals(library)) {
|
||||
writeOptional(outputFolder, new SupportingFile("server.xml.mustache", "src/main/liberty/config", "server.xml"));
|
||||
|
||||
writeOptional(outputFolder, new SupportingFile("beans.xml.mustache", "src/main/webapp/META-INF", "beans.xml"));
|
||||
writeOptional(outputFolder, new SupportingFile("MANIFEST.MF.mustache", "src/main/webapp/META-INF", "MANIFEST.MF"));
|
||||
writeOptional(outputFolder, new SupportingFile("microprofile-config.properties.mustache", "src/main/webapp/META-INF", "microprofile-config.properties"));
|
||||
|
||||
writeOptional(outputFolder, new SupportingFile("ibm-web-ext.xml.mustache", "src/main/webapp/WEB-INF", "ibm-web-ext.xml"));
|
||||
} else if(HELIDON_LIBRARY.equals(library)) {
|
||||
writeOptional(outputFolder, new SupportingFile("logging.properties.mustache", "src/main/resources", "logging.properties"));
|
||||
writeOptional(outputFolder, new SupportingFile("microprofile-config.properties.mustache", "src/main/resources/META-INF", "microprofile-config.properties"));
|
||||
writeOptional(outputFolder, new SupportingFile("beans.xml.mustache", "src/main/webapp/META-INF", "beans.xml"));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -144,6 +144,7 @@ public class JavascriptClientCodegen extends DefaultCodegen implements CodegenCo
|
||||
typeMapping.put("int", "Number");
|
||||
typeMapping.put("float", "Number");
|
||||
typeMapping.put("number", "Number");
|
||||
typeMapping.put("BigDecimal", "Number");
|
||||
typeMapping.put("DateTime", "Date");
|
||||
typeMapping.put("date", "Date");
|
||||
typeMapping.put("long", "Number");
|
||||
|
||||
@@ -19,15 +19,20 @@ package org.openapitools.codegen.languages;
|
||||
|
||||
import org.openapitools.codegen.CliOption;
|
||||
import org.openapitools.codegen.CodegenConstants;
|
||||
import org.openapitools.codegen.CodegenOperation;
|
||||
import org.openapitools.codegen.CodegenType;
|
||||
import org.openapitools.codegen.SupportingFile;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class KotlinClientCodegen extends AbstractKotlinCodegen {
|
||||
|
||||
protected static final String JVM = "jvm";
|
||||
protected static final String MULTIPLATFORM = "multiplatform";
|
||||
|
||||
public static final String DATE_LIBRARY = "dateLibrary";
|
||||
public static final String COLLECTION_TYPE = "collectionType";
|
||||
|
||||
@@ -81,9 +86,9 @@ public class KotlinClientCodegen extends AbstractKotlinCodegen {
|
||||
|
||||
CliOption dateLibrary = new CliOption(DATE_LIBRARY, "Option. Date library to use");
|
||||
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.JAVA8.value, "Java 8 native JSR310");
|
||||
dateOptions.put(DateLibrary.JAVA8.value, "Java 8 native JSR310 (jvm only)");
|
||||
dateLibrary.setEnum(dateOptions);
|
||||
dateLibrary.setDefault(this.dateLibrary);
|
||||
cliOptions.add(dateLibrary);
|
||||
@@ -95,6 +100,15 @@ public class KotlinClientCodegen extends AbstractKotlinCodegen {
|
||||
collectionType.setEnum(collectionOptions);
|
||||
collectionType.setDefault(this.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() {
|
||||
@@ -121,10 +135,79 @@ public class KotlinClientCodegen extends AbstractKotlinCodegen {
|
||||
public void 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)) {
|
||||
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
|
||||
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)) {
|
||||
additionalProperties.put(DateLibrary.THREETENBP.value, true);
|
||||
typeMapping.put("date", "LocalDate");
|
||||
@@ -151,25 +234,31 @@ public class KotlinClientCodegen extends AbstractKotlinCodegen {
|
||||
typeMapping.put("list", "kotlin.collections.List");
|
||||
additionalProperties.put("isList", true);
|
||||
}
|
||||
}
|
||||
|
||||
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"));
|
||||
@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;
|
||||
}
|
||||
|
||||
final String infrastructureFolder = (sourceFolder + File.separator + packageName + File.separator + "infrastructure").replace(".", "/");
|
||||
|
||||
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/ApiInfrastructureResponse.kt.mustache", infrastructureFolder, "ApiInfrastructureResponse.kt"));
|
||||
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"));
|
||||
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/Errors.kt.mustache", infrastructureFolder, "Errors.kt"));
|
||||
supportingFiles.add(new SupportingFile("infrastructure/ByteArrayAdapter.kt.mustache", infrastructureFolder, "ByteArrayAdapter.kt"));
|
||||
supportingFiles.add(new SupportingFile("infrastructure/LocalDateAdapter.kt.mustache", infrastructureFolder, "LocalDateAdapter.kt"));
|
||||
supportingFiles.add(new SupportingFile("infrastructure/LocalDateTimeAdapter.kt.mustache", infrastructureFolder, "LocalDateTimeAdapter.kt"));
|
||||
supportingFiles.add(new SupportingFile("infrastructure/UUIDAdapter.kt.mustache", infrastructureFolder, "UUIDAdapter.kt"));
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -531,7 +531,7 @@ public class PythonClientCodegen extends DefaultCodegen implements CodegenConfig
|
||||
name = name.replaceAll("-", "_");
|
||||
|
||||
// e.g. PhoneNumberApi.py => phone_number_api.py
|
||||
return underscore(name) + "_api";
|
||||
return underscore(name+ "_" + apiNameSuffix);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -541,11 +541,7 @@ public class PythonClientCodegen extends DefaultCodegen implements CodegenConfig
|
||||
|
||||
@Override
|
||||
public String toApiName(String name) {
|
||||
if (name.length() == 0) {
|
||||
return "DefaultApi";
|
||||
}
|
||||
// e.g. phone_number_api => PhoneNumberApi
|
||||
return camelize(name) + "Api";
|
||||
return super.toApiName(name);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -553,7 +549,7 @@ public class PythonClientCodegen extends DefaultCodegen implements CodegenConfig
|
||||
if (name.length() == 0) {
|
||||
return "default_api";
|
||||
}
|
||||
return underscore(name) + "_api";
|
||||
return underscore(name+ "_" + apiNameSuffix);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -16,31 +16,50 @@
|
||||
|
||||
package org.openapitools.codegen.languages;
|
||||
|
||||
import java.text.DateFormat;
|
||||
import java.text.SimpleDateFormat;
|
||||
|
||||
import io.swagger.v3.oas.models.Operation;
|
||||
import io.swagger.v3.oas.models.examples.Example;
|
||||
import io.swagger.v3.oas.models.media.*;
|
||||
import io.swagger.v3.oas.models.media.ArraySchema;
|
||||
import io.swagger.v3.oas.models.media.MediaType;
|
||||
import io.swagger.v3.oas.models.media.Schema;
|
||||
import io.swagger.v3.oas.models.parameters.Parameter;
|
||||
import io.swagger.v3.oas.models.parameters.RequestBody;
|
||||
import io.swagger.v3.oas.models.responses.ApiResponse;
|
||||
import org.apache.commons.io.FilenameUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.openapitools.codegen.*;
|
||||
import org.openapitools.codegen.examples.ExampleGenerator;
|
||||
import org.openapitools.codegen.utils.ModelUtils;
|
||||
import org.openapitools.codegen.meta.GeneratorMetadata;
|
||||
import org.openapitools.codegen.meta.Stability;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import io.swagger.v3.oas.models.media.Schema;
|
||||
import org.openapitools.codegen.*;
|
||||
import org.openapitools.codegen.utils.ModelUtils;
|
||||
|
||||
import java.text.DateFormat;
|
||||
import java.text.SimpleDateFormat;
|
||||
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 PythonClientExperimentalCodegen extends PythonClientCodegen {
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(PythonClientExperimentalCodegen.class);
|
||||
|
||||
public PythonClientExperimentalCodegen() {
|
||||
super();
|
||||
|
||||
supportingFiles.add(new SupportingFile("python-experimental/api_client.mustache", packagePath(), "api_client.py"));
|
||||
apiDocTemplateFiles.put("python-experimental/api_doc.mustache", ".md");
|
||||
apiTemplateFiles.remove("api.mustache");
|
||||
apiTemplateFiles.put("python-experimental/api.mustache", ".py");
|
||||
|
||||
apiDocTemplateFiles.remove("api_doc.mustache");
|
||||
apiDocTemplateFiles.put("python-experimental/api_doc.mustache", ".md");
|
||||
|
||||
modelDocTemplateFiles.remove("model_doc.mustache");
|
||||
modelDocTemplateFiles.put("python-experimental/model_doc.mustache", ".md");
|
||||
|
||||
modelTemplateFiles.remove("model.mustache");
|
||||
modelTemplateFiles.put("python-experimental/model.mustache", ".py");
|
||||
|
||||
generatorMetadata = GeneratorMetadata.newBuilder(generatorMetadata)
|
||||
@@ -48,6 +67,20 @@ public class PythonClientExperimentalCodegen extends PythonClientCodegen {
|
||||
.build();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void processOpts() {
|
||||
super.processOpts();
|
||||
|
||||
supportingFiles.remove(new SupportingFile("api_client.mustache", packagePath(), "api_client.py"));
|
||||
supportingFiles.add(new SupportingFile("python-experimental/api_client.mustache", packagePath(), "api_client.py"));
|
||||
|
||||
supportingFiles.add(new SupportingFile("python-experimental/model_utils.mustache", packagePath(), "model_utils.py"));
|
||||
|
||||
// default this to true so the python ModelSimple models will be generated
|
||||
ModelUtils.setGenerateAliasAsModel(true);
|
||||
LOGGER.info(CodegenConstants.GENERATE_ALIAS_AS_MODEL + " is hard coded to true in this generator. Alias models will only be generated if they contain validations or enums");
|
||||
}
|
||||
|
||||
/**
|
||||
* Configures a friendly name for the generator. This will be used by the
|
||||
* generator to select the library with the -g flag.
|
||||
@@ -72,6 +105,7 @@ public class PythonClientExperimentalCodegen extends PythonClientCodegen {
|
||||
|
||||
/**
|
||||
* Return the default value of the property
|
||||
*
|
||||
* @param p OpenAPI property object
|
||||
* @return string presentation of the default value of the property
|
||||
*/
|
||||
@@ -158,8 +192,401 @@ public class PythonClientExperimentalCodegen extends PythonClientCodegen {
|
||||
}
|
||||
return defaultValue;
|
||||
} else {
|
||||
return defaultObject.toString();
|
||||
return defaultObject.toString();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void postProcessModelProperty(CodegenModel model, CodegenProperty property) {
|
||||
// add regex information to property
|
||||
postProcessPattern(property.pattern, property.vendorExtensions);
|
||||
}
|
||||
|
||||
// override with any special post-processing for all models
|
||||
@SuppressWarnings({"static-method", "unchecked"})
|
||||
public Map<String, Object> postProcessAllModels(Map<String, Object> objs) {
|
||||
// loop through all models and delete ones where type!=object and the model has no validations and enums
|
||||
// we will remove them because they are not needed
|
||||
Map<String, Schema> modelSchemasToRemove = new HashMap<String, Schema>();
|
||||
for (Map.Entry<String, Object> entry : objs.entrySet()) {
|
||||
Map<String, Object> inner = (Map<String, Object>) entry.getValue();
|
||||
List<Map<String, Object>> models = (List<Map<String, Object>>) inner.get("models");
|
||||
for (Map<String, Object> mo : models) {
|
||||
CodegenModel cm = (CodegenModel) mo.get("model");
|
||||
Schema modelSchema = ModelUtils.getSchema(this.openAPI, cm.name);
|
||||
CodegenProperty modelProperty = fromProperty("value", modelSchema);
|
||||
if (cm.isEnum || cm.isAlias) {
|
||||
if (!modelProperty.isEnum && !modelProperty.hasValidation) {
|
||||
// remove these models because they are aliases and do not have any enums or validations
|
||||
modelSchemasToRemove.put(cm.name, modelSchema);
|
||||
}
|
||||
} else if (cm.isArrayModel && !modelProperty.isEnum && !modelProperty.hasValidation) {
|
||||
// remove any ArrayModels which lack validation and enums
|
||||
modelSchemasToRemove.put(cm.name, modelSchema);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Remove modelSchemasToRemove models from objs
|
||||
for (String modelName : modelSchemasToRemove.keySet()) {
|
||||
objs.remove(modelName);
|
||||
}
|
||||
return objs;
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert OAS Property object to Codegen Property object
|
||||
*
|
||||
* @param name name of the property
|
||||
* @param p OAS property object
|
||||
* @return Codegen Property object
|
||||
*/
|
||||
@Override
|
||||
public CodegenProperty fromProperty(String name, Schema p) {
|
||||
// we have a custom version of this function to always set allowableValues.enumVars on all enum variables
|
||||
CodegenProperty result = super.fromProperty(name, p);
|
||||
if (result.isEnum) {
|
||||
updateCodegenPropertyEnum(result);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Update codegen property's enum by adding "enumVars" (with name and value)
|
||||
*
|
||||
* @param var list of CodegenProperty
|
||||
*/
|
||||
@Override
|
||||
public void updateCodegenPropertyEnum(CodegenProperty var) {
|
||||
// we have a custom version of this method to omit overwriting the defaultValue
|
||||
Map<String, Object> allowableValues = var.allowableValues;
|
||||
|
||||
// handle array
|
||||
if (var.mostInnerItems != null) {
|
||||
allowableValues = var.mostInnerItems.allowableValues;
|
||||
}
|
||||
|
||||
if (allowableValues == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
List<Object> values = (List<Object>) allowableValues.get("values");
|
||||
if (values == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
String varDataType = var.mostInnerItems != null ? var.mostInnerItems.dataType : var.dataType;
|
||||
Optional<Schema> referencedSchema = ModelUtils.getSchemas(openAPI).entrySet().stream()
|
||||
.filter(entry -> Objects.equals(varDataType, toModelName(entry.getKey())))
|
||||
.map(Map.Entry::getValue)
|
||||
.findFirst();
|
||||
String dataType = (referencedSchema.isPresent()) ? getTypeDeclaration(referencedSchema.get()) : varDataType;
|
||||
|
||||
// put "enumVars" map into `allowableValues", including `name` and `value`
|
||||
List<Map<String, Object>> enumVars = new ArrayList<>();
|
||||
String commonPrefix = findCommonPrefixOfVars(values);
|
||||
int truncateIdx = commonPrefix.length();
|
||||
for (Object value : values) {
|
||||
Map<String, Object> enumVar = new HashMap<>();
|
||||
String enumName;
|
||||
if (truncateIdx == 0) {
|
||||
enumName = value.toString();
|
||||
} else {
|
||||
enumName = value.toString().substring(truncateIdx);
|
||||
if ("".equals(enumName)) {
|
||||
enumName = value.toString();
|
||||
}
|
||||
}
|
||||
|
||||
enumVar.put("name", toEnumVarName(enumName, dataType));
|
||||
enumVar.put("value", toEnumValue(value.toString(), dataType));
|
||||
enumVar.put("isString", isDataTypeString(dataType));
|
||||
enumVars.add(enumVar);
|
||||
}
|
||||
// if "x-enum-varnames" or "x-enum-descriptions" defined, update varnames
|
||||
Map<String, Object> extensions = var.mostInnerItems != null ? var.mostInnerItems.getVendorExtensions() : var.getVendorExtensions();
|
||||
if (referencedSchema.isPresent()) {
|
||||
extensions = referencedSchema.get().getExtensions();
|
||||
}
|
||||
updateEnumVarsWithExtensions(enumVars, extensions);
|
||||
allowableValues.put("enumVars", enumVars);
|
||||
// overwriting defaultValue omitted from here
|
||||
}
|
||||
|
||||
@Override
|
||||
public CodegenParameter fromRequestBody(RequestBody body, Set<String> imports, String bodyParameterName) {
|
||||
CodegenParameter result = super.fromRequestBody(body, imports, bodyParameterName);
|
||||
// if we generated a model with a non-object type because it has validations or enums,
|
||||
// make sure that the datatype of that body parameter refers to our model class
|
||||
Content content = body.getContent();
|
||||
Set<String> keySet = content.keySet();
|
||||
Object[] keyArray = (Object[]) keySet.toArray();
|
||||
MediaType mediaType = content.get(keyArray[0]);
|
||||
Schema schema = mediaType.getSchema();
|
||||
String ref = schema.get$ref();
|
||||
if (ref == null) {
|
||||
return result;
|
||||
}
|
||||
String modelName = ModelUtils.getSimpleRef(ref);
|
||||
// the result lacks validation info so we need to make a CodegenProperty from the schema to check
|
||||
// if we have validation and enum info exists
|
||||
Schema realSchema = ModelUtils.getSchema(this.openAPI, modelName);
|
||||
CodegenProperty modelProp = fromProperty("body", realSchema);
|
||||
if (modelProp.isPrimitiveType && (modelProp.hasValidation || modelProp.isEnum)) {
|
||||
String simpleDataType = result.dataType;
|
||||
result.isPrimitiveType = false;
|
||||
result.isModel = true;
|
||||
result.dataType = modelName;
|
||||
imports.add(modelName);
|
||||
// set the example value
|
||||
if (modelProp.isEnum) {
|
||||
String value = modelProp._enum.get(0).toString();
|
||||
result.example = modelName + "(" + toEnumValue(value, simpleDataType) + ")";
|
||||
} else {
|
||||
result.example = modelName + "(" + result.example + ")";
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert OAS Response object to Codegen Response object
|
||||
*
|
||||
* @param responseCode HTTP response code
|
||||
* @param response OAS Response object
|
||||
* @return Codegen Response object
|
||||
*/
|
||||
@Override
|
||||
public CodegenResponse fromResponse(String responseCode, ApiResponse response) {
|
||||
// if a response points at a model whose type != object and it has validations and/or enums, then we will
|
||||
// generate the model, and the response.isModel must be changed to true and response.baseType must be the name
|
||||
// of the model. Point responses at models if the model is python class type ModelSimple
|
||||
// When we serialize/deserialize ModelSimple models, validations and enums will be checked.
|
||||
Schema responseSchema;
|
||||
if (this.openAPI != null && this.openAPI.getComponents() != null) {
|
||||
responseSchema = ModelUtils.unaliasSchema(this.openAPI, ModelUtils.getSchemaFromResponse(response));
|
||||
} else { // no model/alias defined
|
||||
responseSchema = ModelUtils.getSchemaFromResponse(response);
|
||||
}
|
||||
|
||||
String newBaseType = null;
|
||||
if (responseSchema != null) {
|
||||
CodegenProperty cp = fromProperty("response", responseSchema);
|
||||
if (cp.complexType != null) {
|
||||
// check the referenced schema to see if it is an type=object model
|
||||
Schema modelSchema = ModelUtils.getSchema(this.openAPI, cp.complexType);
|
||||
if (modelSchema != null && !"object".equals(modelSchema.getType())) {
|
||||
CodegenProperty modelProp = fromProperty("response", modelSchema);
|
||||
if (modelProp.isEnum == true || modelProp.hasValidation == true) {
|
||||
// this model has validations and/or enums so we will generate it
|
||||
newBaseType = cp.complexType;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (cp.isEnum == true || cp.hasValidation == true) {
|
||||
// this model has validations and/or enums so we will generate it
|
||||
Schema sc = ModelUtils.getSchemaFromResponse(response);
|
||||
newBaseType = ModelUtils.getSimpleRef(sc.get$ref());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
CodegenResponse result = super.fromResponse(responseCode, response);
|
||||
if (newBaseType != null) {
|
||||
result.isModel = true;
|
||||
result.baseType = newBaseType;
|
||||
result.dataType = newBaseType;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set op's returnBaseType, returnType, examples etc.
|
||||
*
|
||||
* @param operation endpoint Operation
|
||||
* @param schemas a map of the schemas in the openapi spec
|
||||
* @param op endpoint CodegenOperation
|
||||
* @param methodResponse the default ApiResponse for the endpoint
|
||||
*/
|
||||
@Override
|
||||
public void handleMethodResponse(Operation operation,
|
||||
Map<String, Schema> schemas,
|
||||
CodegenOperation op,
|
||||
ApiResponse methodResponse) {
|
||||
// we have a custom version of this method to handle endpoints that return models where
|
||||
// type != object the model has validations and/or enums
|
||||
// we do this by invoking our custom fromResponse method to create defaultResponse
|
||||
// which we then use to set op.returnType and op.returnBaseType
|
||||
CodegenResponse defaultResponse = fromResponse("defaultResponse", methodResponse);
|
||||
Schema responseSchema = ModelUtils.unaliasSchema(this.openAPI, ModelUtils.getSchemaFromResponse(methodResponse));
|
||||
|
||||
if (responseSchema != null) {
|
||||
op.returnBaseType = defaultResponse.baseType;
|
||||
|
||||
// generate examples
|
||||
String exampleStatusCode = "200";
|
||||
for (String key : operation.getResponses().keySet()) {
|
||||
if (operation.getResponses().get(key) == methodResponse && !key.equals("default")) {
|
||||
exampleStatusCode = key;
|
||||
}
|
||||
}
|
||||
op.examples = new ExampleGenerator(schemas, this.openAPI).generateFromResponseSchema(exampleStatusCode, responseSchema, getProducesInfo(this.openAPI, operation));
|
||||
op.defaultResponse = toDefaultValue(responseSchema);
|
||||
op.returnType = defaultResponse.dataType;
|
||||
op.hasReference = schemas.containsKey(op.returnBaseType);
|
||||
|
||||
// lookup discriminator
|
||||
Schema schema = schemas.get(op.returnBaseType);
|
||||
if (schema != null) {
|
||||
CodegenModel cmod = fromModel(op.returnBaseType, schema);
|
||||
op.discriminator = cmod.discriminator;
|
||||
}
|
||||
|
||||
if (defaultResponse.isListContainer) {
|
||||
op.isListContainer = true;
|
||||
} else if (defaultResponse.isMapContainer) {
|
||||
op.isMapContainer = true;
|
||||
} else {
|
||||
op.returnSimpleType = true;
|
||||
}
|
||||
if (languageSpecificPrimitives().contains(op.returnBaseType) || op.returnBaseType == null) {
|
||||
op.returnTypeIsPrimitive = true;
|
||||
}
|
||||
}
|
||||
addHeaders(methodResponse, op.responseHeaders);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Return the sanitized variable name for enum
|
||||
*
|
||||
* @param value enum variable name
|
||||
* @param datatype data type
|
||||
* @return the sanitized variable name for enum
|
||||
*/
|
||||
public String toEnumVarName(String value, String datatype) {
|
||||
// our enum var names are keys in a python dict, so change spaces to underscores
|
||||
if (value.length() == 0) {
|
||||
return "EMPTY";
|
||||
}
|
||||
|
||||
String var = value.replaceAll("\\s+", "_").toUpperCase(Locale.ROOT);
|
||||
return var;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the enum value in the language specified format
|
||||
* e.g. status becomes "status"
|
||||
*
|
||||
* @param value enum variable name
|
||||
* @param datatype data type
|
||||
* @return the sanitized value for enum
|
||||
*/
|
||||
public String toEnumValue(String value, String datatype) {
|
||||
if (datatype.equals("int") || datatype.equals("float")) {
|
||||
return value;
|
||||
} else {
|
||||
return "\"" + escapeText(value) + "\"";
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void postProcessParameter(CodegenParameter parameter) {
|
||||
postProcessPattern(parameter.pattern, parameter.vendorExtensions);
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert OAS Model object to Codegen Model object
|
||||
*
|
||||
* @param name the name of the model
|
||||
* @param schema OAS Model object
|
||||
* @return Codegen Model object
|
||||
*/
|
||||
@Override
|
||||
public CodegenModel fromModel(String name, Schema schema) {
|
||||
// we have a custom version of this function so we can produce
|
||||
// models for components whose type != object and which have validations and enums
|
||||
// this ensures that endpoint (operation) responses with validations and enums
|
||||
// will generate models, and when those endpoint responses are received in python
|
||||
// the response is cast as a model, and the model will validate the response using the enums and validations
|
||||
Map<String, String> propertyToModelName = new HashMap<String, String>();
|
||||
Map<String, Schema> propertiesMap = schema.getProperties();
|
||||
if (propertiesMap != null) {
|
||||
for (Map.Entry<String, Schema> entry : propertiesMap.entrySet()) {
|
||||
String schemaPropertyName = entry.getKey();
|
||||
String pythonPropertyName = toVarName(schemaPropertyName);
|
||||
Schema propertySchema = entry.getValue();
|
||||
String ref = propertySchema.get$ref();
|
||||
if (ref == null) {
|
||||
continue;
|
||||
}
|
||||
Schema refSchema = ModelUtils.getReferencedSchema(this.openAPI, propertySchema);
|
||||
String refType = refSchema.getType();
|
||||
if (refType == null || refType.equals("object")) {
|
||||
continue;
|
||||
}
|
||||
CodegenProperty modelProperty = fromProperty("_fake_name", refSchema);
|
||||
if (modelProperty.isEnum == false && modelProperty.hasValidation == false) {
|
||||
continue;
|
||||
}
|
||||
String modelName = ModelUtils.getSimpleRef(ref);
|
||||
propertyToModelName.put(pythonPropertyName, modelName);
|
||||
}
|
||||
}
|
||||
CodegenModel result = super.fromModel(name, schema);
|
||||
|
||||
// make non-object type models have one property so we can use it to store enums and validations
|
||||
if (result.isAlias || result.isEnum) {
|
||||
Schema modelSchema = ModelUtils.getSchema(this.openAPI, result.name);
|
||||
CodegenProperty modelProperty = fromProperty("value", modelSchema);
|
||||
if (modelProperty.isEnum == true || modelProperty.hasValidation == true) {
|
||||
// these models are non-object models with enums and/or validations
|
||||
// add a single property to the model so we can have a way to access validations
|
||||
result.isAlias = true;
|
||||
modelProperty.required = true;
|
||||
List<CodegenProperty> theProperties = Arrays.asList(modelProperty);
|
||||
result.setAllVars(theProperties);
|
||||
result.setVars(theProperties);
|
||||
result.setRequiredVars(theProperties);
|
||||
// post process model properties
|
||||
if (result.vars != null) {
|
||||
for (CodegenProperty prop : result.vars) {
|
||||
postProcessModelProperty(result, prop);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
// return all models which don't need their properties connected to non-object models
|
||||
if (propertyToModelName.isEmpty()) {
|
||||
return result;
|
||||
}
|
||||
|
||||
// fix all property references to non-object models, make those properties non-primitive and
|
||||
// set their dataType and complexType to the model name, so documentation will refer to the correct model
|
||||
ArrayList<List<CodegenProperty>> listOfLists = new ArrayList<List<CodegenProperty>>();
|
||||
listOfLists.add(result.vars);
|
||||
listOfLists.add(result.allVars);
|
||||
listOfLists.add(result.requiredVars);
|
||||
listOfLists.add(result.optionalVars);
|
||||
listOfLists.add(result.readOnlyVars);
|
||||
listOfLists.add(result.readWriteVars);
|
||||
for (List<CodegenProperty> cpList : listOfLists) {
|
||||
for (CodegenProperty cp : cpList) {
|
||||
if (!propertyToModelName.containsKey(cp.name)) {
|
||||
continue;
|
||||
}
|
||||
cp.isPrimitiveType = false;
|
||||
String modelName = propertyToModelName.get(cp.name);
|
||||
cp.complexType = modelName;
|
||||
cp.dataType = modelName;
|
||||
cp.isEnum = false;
|
||||
cp.hasValidation = false;
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -387,7 +387,7 @@ public class RubyClientCodegen extends AbstractRubyCodegen {
|
||||
name = name.replaceAll("-", "_"); // FIXME: a parameter should not be assigned. Also declare the methods parameters as 'final'.
|
||||
|
||||
// e.g. PhoneNumberApi.rb => phone_number_api.rb
|
||||
return underscore(name) + "_api";
|
||||
return underscore(name + "_" + apiNameSuffix);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -407,11 +407,7 @@ public class RubyClientCodegen extends AbstractRubyCodegen {
|
||||
|
||||
@Override
|
||||
public String toApiName(String name) {
|
||||
if (name.length() == 0) {
|
||||
return "DefaultApi";
|
||||
}
|
||||
// e.g. phone_number_api => PhoneNumberApi
|
||||
return camelize(name) + "Api";
|
||||
return super.toApiName(name);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -909,6 +909,12 @@ public class RustServerCodegen extends DefaultCodegen implements CodegenConfig {
|
||||
additionalProperties.put("usesXmlNamespaces", true);
|
||||
}
|
||||
|
||||
Schema additionalProperties = ModelUtils.getAdditionalProperties(model);
|
||||
|
||||
if (additionalProperties != null) {
|
||||
mdl.additionalPropertiesType = getSchemaType(additionalProperties);
|
||||
}
|
||||
|
||||
return mdl;
|
||||
}
|
||||
|
||||
@@ -1123,20 +1129,34 @@ public class RustServerCodegen extends DefaultCodegen implements CodegenConfig {
|
||||
// 'null'. This ensures that we treat this model as a struct
|
||||
// with multiple parameters.
|
||||
cm.dataType = null;
|
||||
} else if (cm.dataType != null) {
|
||||
if (cm.dataType.equals("map")) {
|
||||
// We don't yet support `additionalProperties`. We ignore
|
||||
// the `additionalProperties` type ('map') and warn the
|
||||
// user. This will produce code that compiles, but won't
|
||||
// feature the `additionalProperties`.
|
||||
} else if (cm.dataType != null && cm.dataType.equals("map")) {
|
||||
if (!cm.allVars.isEmpty() || cm.additionalPropertiesType == null) {
|
||||
// We don't yet support `additionalProperties` that also have
|
||||
// properties. If we see variables, we ignore the
|
||||
// `additionalProperties` type ('map') and warn the user. This
|
||||
// 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;
|
||||
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));
|
||||
|
||||
@@ -41,7 +41,6 @@ public class Swift4Codegen extends DefaultCodegen implements CodegenConfig {
|
||||
|
||||
public static final String PROJECT_NAME = "projectName";
|
||||
public static final String RESPONSE_AS = "responseAs";
|
||||
public static final String UNWRAP_REQUIRED = "unwrapRequired";
|
||||
public static final String OBJC_COMPATIBLE = "objcCompatible";
|
||||
public static final String POD_SOURCE = "podSource";
|
||||
public static final String POD_AUTHORS = "podAuthors";
|
||||
@@ -101,7 +100,8 @@ public class Swift4Codegen extends DefaultCodegen implements CodegenConfig {
|
||||
"UUID",
|
||||
"URL",
|
||||
"AnyObject",
|
||||
"Any")
|
||||
"Any",
|
||||
"Decimal")
|
||||
);
|
||||
defaultIncludes = new HashSet<>(
|
||||
Arrays.asList(
|
||||
@@ -115,7 +115,8 @@ public class Swift4Codegen extends DefaultCodegen implements CodegenConfig {
|
||||
"Any",
|
||||
"Empty",
|
||||
"AnyObject",
|
||||
"Any")
|
||||
"Any",
|
||||
"Decimal")
|
||||
);
|
||||
|
||||
objcReservedWords = new HashSet<>(
|
||||
@@ -123,8 +124,8 @@ public class Swift4Codegen extends DefaultCodegen implements CodegenConfig {
|
||||
// Added for Objective-C compatibility
|
||||
"id", "description", "NSArray", "NSURL", "CGFloat", "NSSet", "NSString", "NSInteger", "NSUInteger",
|
||||
"NSError", "NSDictionary"
|
||||
)
|
||||
);
|
||||
)
|
||||
);
|
||||
|
||||
reservedWords = new HashSet<>(
|
||||
Arrays.asList(
|
||||
@@ -198,6 +199,7 @@ public class Swift4Codegen extends DefaultCodegen implements CodegenConfig {
|
||||
typeMapping.put("ByteArray", "Data");
|
||||
typeMapping.put("UUID", "UUID");
|
||||
typeMapping.put("URI", "String");
|
||||
typeMapping.put("BigDecimal", "Decimal");
|
||||
|
||||
importMapping = new HashMap<>();
|
||||
|
||||
@@ -206,10 +208,6 @@ public class Swift4Codegen extends DefaultCodegen implements CodegenConfig {
|
||||
"Optionally use libraries to manage response. Currently "
|
||||
+ StringUtils.join(RESPONSE_LIBRARIES, ", ")
|
||||
+ " are available."));
|
||||
cliOptions.add(new CliOption(UNWRAP_REQUIRED,
|
||||
"Treat 'required' properties in response as non-optional "
|
||||
+ "(which would crash the app if api returns null as opposed "
|
||||
+ "to required option specified in json schema"));
|
||||
cliOptions.add(new CliOption(OBJC_COMPATIBLE,
|
||||
"Add additional properties and methods for Objective-C "
|
||||
+ "compatibility (default: false)"));
|
||||
@@ -327,13 +325,6 @@ public class Swift4Codegen extends DefaultCodegen implements CodegenConfig {
|
||||
}
|
||||
sourceFolder = projectName + File.separator + sourceFolder;
|
||||
|
||||
// Setup unwrapRequired option, which makes all the
|
||||
// properties with "required" non-optional
|
||||
if (additionalProperties.containsKey(UNWRAP_REQUIRED)) {
|
||||
setUnwrapRequired(convertPropertyToBooleanAndWriteBack(UNWRAP_REQUIRED));
|
||||
}
|
||||
additionalProperties.put(UNWRAP_REQUIRED, unwrapRequired);
|
||||
|
||||
// Setup objcCompatible option, which adds additional properties
|
||||
// and methods for Objective-C compatibility
|
||||
if (additionalProperties.containsKey(OBJC_COMPATIBLE)) {
|
||||
@@ -709,10 +700,6 @@ public class Swift4Codegen extends DefaultCodegen implements CodegenConfig {
|
||||
this.projectName = projectName;
|
||||
}
|
||||
|
||||
public void setUnwrapRequired(boolean unwrapRequired) {
|
||||
this.unwrapRequired = unwrapRequired;
|
||||
}
|
||||
|
||||
public void setObjcCompatible(boolean objcCompatible) {
|
||||
this.objcCompatible = objcCompatible;
|
||||
}
|
||||
@@ -860,22 +847,9 @@ public class Swift4Codegen extends DefaultCodegen implements CodegenConfig {
|
||||
public void postProcessModelProperty(CodegenModel model, CodegenProperty property) {
|
||||
super.postProcessModelProperty(model, property);
|
||||
|
||||
// The default template code has the following logic for
|
||||
// assigning a type as Swift Optional:
|
||||
//
|
||||
// {{^unwrapRequired}}?{{/unwrapRequired}}
|
||||
// {{#unwrapRequired}}{{^required}}?{{/required}}{{/unwrapRequired}}
|
||||
//
|
||||
// which means:
|
||||
//
|
||||
// boolean isSwiftOptional = !unwrapRequired || (unwrapRequired && !property.required);
|
||||
//
|
||||
// We can drop the check for unwrapRequired in (unwrapRequired && !property.required)
|
||||
// due to short-circuit evaluation of the || operator.
|
||||
boolean isSwiftOptional = !unwrapRequired || !property.required;
|
||||
boolean isSwiftScalarType = property.isInteger || property.isLong || property.isFloat
|
||||
|| property.isDouble || property.isBoolean;
|
||||
if (isSwiftOptional && isSwiftScalarType) {
|
||||
if ((!property.required || property.isNullable) && isSwiftScalarType) {
|
||||
// Optional scalar types like Int?, Int64?, Float?, Double?, and Bool?
|
||||
// do not translate to Objective-C. So we want to flag those
|
||||
// properties in case we want to put special code in the templates
|
||||
|
||||
@@ -52,7 +52,7 @@ public class TypeScriptAngularClientCodegen extends AbstractTypeScriptClientCode
|
||||
public static final String STRING_ENUMS = "stringEnums";
|
||||
public static final String STRING_ENUMS_DESC = "Generate string enums instead of objects for enum values.";
|
||||
|
||||
protected String ngVersion = "7.0.0";
|
||||
protected String ngVersion = "8.0.0";
|
||||
protected String npmRepository = null;
|
||||
protected String serviceSuffix = "Service";
|
||||
protected String serviceFileSuffix = ".service";
|
||||
|
||||
@@ -17,7 +17,9 @@
|
||||
|
||||
package org.openapitools.codegen.languages;
|
||||
|
||||
import io.swagger.v3.oas.models.Operation;
|
||||
import io.swagger.v3.oas.models.media.Schema;
|
||||
import io.swagger.v3.oas.models.responses.ApiResponse;
|
||||
import org.openapitools.codegen.*;
|
||||
import org.openapitools.codegen.utils.ModelUtils;
|
||||
import org.slf4j.Logger;
|
||||
@@ -40,8 +42,12 @@ public class TypeScriptNodeClientCodegen extends AbstractTypeScriptClientCodegen
|
||||
public TypeScriptNodeClientCodegen() {
|
||||
super();
|
||||
|
||||
typeMapping.put("file", "Buffer");
|
||||
typeMapping.put("file", "RequestFile");
|
||||
// RequestFile is defined as: `type RequestFile = string | Buffer | ReadStream | RequestDetailedFile;`
|
||||
languageSpecificPrimitives.add("Buffer");
|
||||
languageSpecificPrimitives.add("ReadStream");
|
||||
languageSpecificPrimitives.add("RequestDetailedFile");
|
||||
languageSpecificPrimitives.add("RequestFile");
|
||||
|
||||
// clear import mapping (from default generator) as TS does not use it
|
||||
// at the moment
|
||||
@@ -70,19 +76,35 @@ public class TypeScriptNodeClientCodegen extends AbstractTypeScriptClientCodegen
|
||||
|
||||
@Override
|
||||
public boolean isDataTypeFile(final String dataType) {
|
||||
return "Buffer".equals(dataType);
|
||||
return dataType != null && dataType.equals("RequestFile");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTypeDeclaration(Schema p) {
|
||||
if (ModelUtils.isFileSchema(p)) {
|
||||
return "Buffer";
|
||||
// There are two file types:
|
||||
// 1) RequestFile: the parameter for the request lib when uploading a file
|
||||
// (https://github.com/request/request#multipartform-data-multipart-form-uploads)
|
||||
// 2) Buffer: for downloading files.
|
||||
// Use RequestFile as a default. The return type is fixed to Buffer in handleMethodResponse.
|
||||
return "RequestFile";
|
||||
} else if (ModelUtils.isBinarySchema(p)) {
|
||||
return "Buffer";
|
||||
}
|
||||
return super.getTypeDeclaration(p);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected void handleMethodResponse(Operation operation, Map<String, Schema> schemas, CodegenOperation op,
|
||||
ApiResponse methodResponse) {
|
||||
super.handleMethodResponse(operation, schemas, op, methodResponse);
|
||||
|
||||
// see comment in getTypeDeclaration
|
||||
if (op.isResponseFile) {
|
||||
op.returnType = "Buffer";
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toApiName(String name) {
|
||||
if (name.length() == 0) {
|
||||
@@ -239,13 +261,12 @@ public class TypeScriptNodeClientCodegen extends AbstractTypeScriptClientCodegen
|
||||
if (isLanguagePrimitive(openAPIType) || isLanguageGenericType(openAPIType)) {
|
||||
return openAPIType;
|
||||
}
|
||||
applyLocalTypeMapping(openAPIType);
|
||||
return openAPIType;
|
||||
return applyLocalTypeMapping(openAPIType);
|
||||
}
|
||||
|
||||
private String applyLocalTypeMapping(String type) {
|
||||
if (typeMapping.containsKey(type)) {
|
||||
type = typeMapping.get(type);
|
||||
return typeMapping.get(type);
|
||||
}
|
||||
return type;
|
||||
}
|
||||
|
||||
@@ -27,7 +27,7 @@ repositories {
|
||||
|
||||
ext {
|
||||
swagger_annotations_version = "1.5.22"
|
||||
jackson_version = "2.9.9"
|
||||
jackson_version = "2.9.10"
|
||||
}
|
||||
|
||||
dependencies {
|
||||
|
||||
@@ -136,8 +136,8 @@ if(hasProperty('target') && target == 'android') {
|
||||
|
||||
ext {
|
||||
swagger_annotations_version = "1.5.22"
|
||||
jackson_version = "{{^threetenbp}}2.9.9{{/threetenbp}}{{#threetenbp}}2.6.4{{/threetenbp}}"
|
||||
jackson_databind_version = "{{^threetenbp}}2.9.9{{/threetenbp}}{{#threetenbp}}2.6.4{{/threetenbp}}"
|
||||
jackson_version = "{{^threetenbp}}2.9.10{{/threetenbp}}{{#threetenbp}}2.6.4{{/threetenbp}}"
|
||||
jackson_databind_version = "{{^threetenbp}}2.9.10{{/threetenbp}}{{#threetenbp}}2.6.4{{/threetenbp}}"
|
||||
jackson-databind-nullable-version = "0.2.0"
|
||||
jersey_version = "1.19.4"
|
||||
jodatime_version = "2.9.9"
|
||||
|
||||
@@ -3,8 +3,11 @@ package {{invokerPackage}};
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.Map;
|
||||
|
||||
{{#hasOAuthMethods}}
|
||||
import org.apache.oltu.oauth2.client.request.OAuthClientRequest.AuthenticationRequestBuilder;
|
||||
import org.apache.oltu.oauth2.client.request.OAuthClientRequest.TokenRequestBuilder;
|
||||
{{/hasOAuthMethods}}
|
||||
|
||||
{{#threetenbp}}
|
||||
import org.threeten.bp.*;
|
||||
{{/threetenbp}}
|
||||
|
||||
@@ -77,7 +77,7 @@ public final class EncodingUtils {
|
||||
return null;
|
||||
}
|
||||
try {
|
||||
return URLEncoder.encode(parameter.toString(), "UTF-8");
|
||||
return URLEncoder.encode(parameter.toString(), "UTF-8").replaceAll("\\+", "%20");
|
||||
} catch (UnsupportedEncodingException e) {
|
||||
// Should never happen, UTF-8 is always supported
|
||||
throw new RuntimeException(e);
|
||||
|
||||
@@ -120,8 +120,8 @@ if(hasProperty('target') && target == 'android') {
|
||||
|
||||
ext {
|
||||
swagger_annotations_version = "1.5.22"
|
||||
jackson_version = "2.9.9"
|
||||
jackson_databind_version = "2.9.9"
|
||||
jackson_version = "2.9.10"
|
||||
jackson_databind_version = "2.9.10"
|
||||
jackson-databind-nullable-version = "0.2.0"
|
||||
{{#threetenbp}}
|
||||
threepane_version = "2.6.4"
|
||||
|
||||
@@ -14,9 +14,9 @@ lazy val root = (project in file(".")).
|
||||
"io.github.openfeign" % "feign-jackson" % "{{#useFeign10}}10.2.3{{/useFeign10}}{{^useFeign10}}9.7.0{{/useFeign10}}" % "compile",
|
||||
"io.github.openfeign" % "feign-slf4j" % "{{#useFeign10}}10.2.3{{/useFeign10}}{{^useFeign10}}9.7.0{{/useFeign10}}" % "compile",
|
||||
"io.github.openfeign.form" % "feign-form" % "2.1.0" % "compile",
|
||||
"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",
|
||||
"com.fasterxml.jackson.core" % "jackson-core" % "2.9.10" % "compile",
|
||||
"com.fasterxml.jackson.core" % "jackson-annotations" % "2.9.10" % "compile",
|
||||
"com.fasterxml.jackson.core" % "jackson-databind" % "2.9.10" % "compile",
|
||||
"com.fasterxml.jackson.datatype" % "jackson-datatype-{{^java8}}joda{{/java8}}{{#java8}}jsr310{{/java8}}" % "2.9.9" % "compile",
|
||||
"com.github.joschi.jackson" % "jackson-datatype-threetenbp" % "2.6.4" % "compile",
|
||||
"org.apache.oltu.oauth2" % "org.apache.oltu.oauth2.client" % "1.0.1" % "compile",
|
||||
|
||||
@@ -314,9 +314,9 @@
|
||||
<swagger-annotations-version>1.5.21</swagger-annotations-version>
|
||||
<feign-version>{{#useFeign10}}10.2.3{{/useFeign10}}{{^useFeign10}}9.7.0{{/useFeign10}}</feign-version>
|
||||
<feign-form-version>2.1.0</feign-form-version>
|
||||
<jackson-version>2.9.9</jackson-version>
|
||||
<jackson-version>2.9.10</jackson-version>
|
||||
<jackson-databind-nullable-version>0.2.0</jackson-databind-nullable-version>
|
||||
<jackson-databind-version>2.9.9</jackson-databind-version>
|
||||
<jackson-databind-version>2.9.10</jackson-databind-version>
|
||||
{{#threetenbp}}
|
||||
<jackson-threetenbp-version>2.6.4</jackson-threetenbp-version>
|
||||
{{/threetenbp}}
|
||||
|
||||
@@ -120,8 +120,8 @@ if(hasProperty('target') && target == 'android') {
|
||||
|
||||
ext {
|
||||
swagger_annotations_version = "1.5.22"
|
||||
jackson_version = "2.9.9"
|
||||
jackson_databind_version = "2.9.9"
|
||||
jackson_version = "2.9.10"
|
||||
jackson_databind_version = "2.9.10"
|
||||
jackson-databind-nullable-version = "0.2.0"
|
||||
google_api_client_version = "1.23.0"
|
||||
jersey_common_version = "2.25.1"
|
||||
|
||||
@@ -12,9 +12,9 @@ lazy val root = (project in file(".")).
|
||||
"io.swagger" % "swagger-annotations" % "1.5.22",
|
||||
"com.google.api-client" % "google-api-client" % "1.23.0",
|
||||
"org.glassfish.jersey.core" % "jersey-common" % "2.25.1",
|
||||
"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",
|
||||
"com.fasterxml.jackson.core" % "jackson-core" % "2.9.10" % "compile",
|
||||
"com.fasterxml.jackson.core" % "jackson-annotations" % "2.9.10" % "compile",
|
||||
"com.fasterxml.jackson.core" % "jackson-databind" % "2.9.10" % "compile",
|
||||
{{#withXml}}
|
||||
"com.fasterxml.jackson.dataformat" % "jackson-dataformat-xml" % "2.9.9" % "compile",
|
||||
{{/withXml}}
|
||||
|
||||
@@ -304,10 +304,10 @@
|
||||
<properties>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
<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>
|
||||
<jackson-version>2.9.9</jackson-version>
|
||||
<jackson-databind-version>2.9.9</jackson-databind-version>
|
||||
<jackson-version>2.9.10</jackson-version>
|
||||
<jackson-databind-version>2.9.10</jackson-databind-version>
|
||||
<jackson-databind-nullable-version>0.2.0</jackson-databind-nullable-version>
|
||||
{{#joda}}
|
||||
<jodatime-version>2.9.9</jodatime-version>
|
||||
|
||||
@@ -119,8 +119,8 @@ if(hasProperty('target') && target == 'android') {
|
||||
|
||||
ext {
|
||||
swagger_annotations_version = "1.5.22"
|
||||
jackson_version = "2.9.9"
|
||||
jackson_databind_version = "2.9.9"
|
||||
jackson_version = "2.9.10"
|
||||
jackson_databind_version = "2.9.10"
|
||||
jackson-databind-nullable-version = "0.2.0"
|
||||
{{#supportJava6}}
|
||||
jersey_version = "2.6"
|
||||
|
||||
@@ -13,9 +13,9 @@ lazy val root = (project in file(".")).
|
||||
"org.glassfish.jersey.core" % "jersey-client" % {{#supportJava6}}"2.6"{{/supportJava6}}{{^supportJava6}}"2.25.1"{{/supportJava6}},
|
||||
"org.glassfish.jersey.media" % "jersey-media-multipart" % {{#supportJava6}}"2.6"{{/supportJava6}}{{^supportJava6}}"2.25.1"{{/supportJava6}},
|
||||
"org.glassfish.jersey.media" % "jersey-media-json-jackson" % {{#supportJava6}}"2.6"{{/supportJava6}}{{^supportJava6}}"2.25.1"{{/supportJava6}},
|
||||
"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",
|
||||
"com.fasterxml.jackson.core" % "jackson-core" % "2.9.10" % "compile",
|
||||
"com.fasterxml.jackson.core" % "jackson-annotations" % "2.9.10" % "compile",
|
||||
"com.fasterxml.jackson.core" % "jackson-databind" % "2.9.10" % "compile",
|
||||
{{#joda}}
|
||||
"com.fasterxml.jackson.datatype" % "jackson-datatype-joda" % "2.9.9" % "compile",
|
||||
{{/joda}}
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user