forked from loafle/openapi-generator-original
Compare commits
114 Commits
swift5-cod
...
v4.1.0
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
59c4e381d1 | ||
|
|
1ab7b9ceb6 | ||
|
|
65c7c1b39b | ||
|
|
2d7cc778db | ||
|
|
fbb2f1e05a | ||
|
|
752030890f | ||
|
|
36dd848440 | ||
|
|
4b0fc3013f | ||
|
|
1152af4d02 | ||
|
|
b28ef78145 | ||
|
|
7f36f26422 | ||
|
|
411199bc99 | ||
|
|
4478f42927 | ||
|
|
9e659d13ed | ||
|
|
b8295afa27 | ||
|
|
3538c08a8b | ||
|
|
5ab1c9c75b | ||
|
|
2bbebf9752 | ||
|
|
f756bd5e11 | ||
|
|
fae073874b | ||
|
|
00f7134eb3 | ||
|
|
b20118b87c | ||
|
|
a48df102d6 | ||
|
|
3f7653a5c9 | ||
|
|
4df1e1928c | ||
|
|
83f17941b9 | ||
|
|
6963e5eeb0 | ||
|
|
86228e9964 | ||
|
|
480d6baf3b | ||
|
|
8b44c9dff1 | ||
|
|
ba63aa55a5 | ||
|
|
d45e306480 | ||
|
|
1c36fa9fe3 | ||
|
|
d0f0e17542 | ||
|
|
ffaeb11a61 | ||
|
|
4c1133be3f | ||
|
|
dff3386594 | ||
|
|
ca85ecb283 | ||
|
|
93ddf6e2ef | ||
|
|
ed82aaae97 | ||
|
|
581131e0fe | ||
|
|
08415d1d83 | ||
|
|
4d285939a6 | ||
|
|
eca8ec3cf8 | ||
|
|
0a7527b03e | ||
|
|
bcc3a9ecf7 | ||
|
|
f90f214121 | ||
|
|
0e621dcc29 | ||
|
|
8b054e6f8e | ||
|
|
88af8964fd | ||
|
|
199447a398 | ||
|
|
4c9d023468 | ||
|
|
d46cabcd4f | ||
|
|
6824bd8b24 | ||
|
|
f90507b527 | ||
|
|
3b584c2138 | ||
|
|
37cdc8e493 | ||
|
|
c684505cba | ||
|
|
1bf8c15206 | ||
|
|
b4f1581941 | ||
|
|
cf01bf4ae7 | ||
|
|
74eeb07b22 | ||
|
|
981b3a53ef | ||
|
|
9cb3ae1048 | ||
|
|
cbd78d7fca | ||
|
|
6e3176557c | ||
|
|
1713c7610d | ||
|
|
049f69c55b | ||
|
|
b9e863a9ca | ||
|
|
6358b11516 | ||
|
|
652b14c28f | ||
|
|
93cb215531 | ||
|
|
d5d8b7a118 | ||
|
|
45fcf3792a | ||
|
|
43590582c5 | ||
|
|
8253c28d6e | ||
|
|
fabe021fb0 | ||
|
|
8231cbfe81 | ||
|
|
a3cf964ce9 | ||
|
|
d0b728794d | ||
|
|
da62116c9d | ||
|
|
2c9bfdf29a | ||
|
|
64c2069256 | ||
|
|
3f3ecb6879 | ||
|
|
2f479f493f | ||
|
|
ee538be964 | ||
|
|
a0dd7394ac | ||
|
|
3f7725c9e2 | ||
|
|
ab644f9912 | ||
|
|
28a16bea24 | ||
|
|
2e81e612fc | ||
|
|
a4b1c269d8 | ||
|
|
2c4fdd0792 | ||
|
|
00c7d6f46b | ||
|
|
40f1f920df | ||
|
|
5775813031 | ||
|
|
d2576f411e | ||
|
|
76fecf744b | ||
|
|
f436904359 | ||
|
|
5cba55f8fb | ||
|
|
1413775e0e | ||
|
|
21e29d7177 | ||
|
|
5c7d902c4c | ||
|
|
e58cc2a282 | ||
|
|
84e2f60d6b | ||
|
|
944e1c3468 | ||
|
|
26b8d1f4c2 | ||
|
|
0fec25e92e | ||
|
|
1aa8a2bec4 | ||
|
|
1e735c69fa | ||
|
|
4223743ee0 | ||
|
|
29a85d54a2 | ||
|
|
a85bd0f8f9 | ||
|
|
610ca28681 |
30
.github/.test/samples.json
vendored
30
.github/.test/samples.json
vendored
@@ -1094,36 +1094,6 @@
|
||||
"Client: Swift"
|
||||
]
|
||||
},
|
||||
{
|
||||
"input": "swift5-petstore-promisekit.sh",
|
||||
"matches": [
|
||||
"Client: Swift"
|
||||
]
|
||||
},
|
||||
{
|
||||
"input": "swift5-petstore-rxswift.sh",
|
||||
"matches": [
|
||||
"Client: Swift"
|
||||
]
|
||||
},
|
||||
{
|
||||
"input": "swift5-petstore-unwrapRequired.sh",
|
||||
"matches": [
|
||||
"Client: Swift"
|
||||
]
|
||||
},
|
||||
{
|
||||
"input": "swift5-petstore.sh",
|
||||
"matches": [
|
||||
"Client: Swift"
|
||||
]
|
||||
},
|
||||
{
|
||||
"input": "swift5-test.sh",
|
||||
"matches": [
|
||||
"Client: Swift"
|
||||
]
|
||||
},
|
||||
{
|
||||
"input": "typescript-angular-v2-petstore-interfaces.sh",
|
||||
"matches": [
|
||||
|
||||
4
.gitignore
vendored
4
.gitignore
vendored
@@ -232,3 +232,7 @@ samples/client/petstore/elm/index.html
|
||||
# C
|
||||
samples/client/petstore/c/build
|
||||
samples/client/petstore/c/*.so
|
||||
|
||||
# Ruby
|
||||
samples/openapi3/client/petstore/ruby/Gemfile.lock
|
||||
samples/openapi3/client/petstore/ruby-faraday/Gemfile.lock
|
||||
|
||||
@@ -94,6 +94,12 @@ before_install:
|
||||
# - Rely on `kerl` for [pre-compiled versions available](https://docs.travis-ci.com/user/languages/erlang#Choosing-OTP-releases-to-test-against). Rely on installation path chosen by [`travis-erlang-builder`](https://github.com/travis-ci/travis-erlang-builder/blob/e6d016b1a91ca7ecac5a5a46395bde917ea13d36/bin/compile#L18).
|
||||
# - . ~/otp/18.2.1/activate && erl -version
|
||||
#- curl -f -L -o ./rebar3 https://s3.amazonaws.com/rebar3/rebar3 && chmod +x ./rebar3 && ./rebar3 version && export PATH="${TRAVIS_BUILD_DIR}:$PATH"
|
||||
# install Qt 5.10
|
||||
- sudo add-apt-repository --yes ppa:beineri/opt-qt-5.10.1-trusty
|
||||
- sudo apt-get update -qq
|
||||
- sudo apt-get install qt510-meta-minimal
|
||||
- source /opt/qt510/bin/qt510-env.sh
|
||||
- qmake -v
|
||||
|
||||
# show host table to confirm petstore.swagger.io is mapped to localhost
|
||||
- cat /etc/hosts
|
||||
|
||||
20
CI/.drone.yml
Normal file
20
CI/.drone.yml
Normal file
@@ -0,0 +1,20 @@
|
||||
kind: pipeline
|
||||
name: default
|
||||
|
||||
steps:
|
||||
# test Java 11 HTTP client
|
||||
- name: java11-test
|
||||
image: hirokimatsumoto/alpine-openjdk-11
|
||||
commands:
|
||||
- ./mvnw clean install
|
||||
- ./mvnw --quiet verify -Psamples.droneio
|
||||
# test ocaml petstore client
|
||||
- name: ocaml-test
|
||||
image: ocaml/opam2:4.07
|
||||
commands:
|
||||
- sudo apt-get -y install m4
|
||||
- cd samples/client/petstore/ocaml
|
||||
- opam install ppx_deriving_yojson cohttp ppx_deriving cohttp-lwt-unix
|
||||
- eval $(opam env)
|
||||
- sudo chmod -R 777 .
|
||||
- dune build --build-dir=./_build
|
||||
@@ -10,6 +10,7 @@ import java.util.TimeZone;
|
||||
|
||||
import org.junit.*;
|
||||
import static org.junit.Assert.*;
|
||||
import static org.hamcrest.CoreMatchers.*;
|
||||
|
||||
|
||||
public class ApiClientTest {
|
||||
@@ -329,24 +330,18 @@ public class ApiClientTest {
|
||||
assertEquals("sun.gif", apiClient.sanitizeFilename(".\\sun.gif"));
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testInterceptorCleanupWithNewClient() {
|
||||
public void testNewHttpClient() {
|
||||
OkHttpClient oldClient = apiClient.getHttpClient();
|
||||
assertEquals(1, oldClient.networkInterceptors().size());
|
||||
|
||||
OkHttpClient newClient = new OkHttpClient();
|
||||
apiClient.setHttpClient(newClient);
|
||||
assertEquals(1, apiClient.getHttpClient().networkInterceptors().size());
|
||||
apiClient.setHttpClient(newClient);
|
||||
assertEquals(1, apiClient.getHttpClient().networkInterceptors().size());
|
||||
apiClient.setHttpClient(oldClient.newBuilder().build());
|
||||
assertThat(apiClient.getHttpClient(), is(not(oldClient)));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testInterceptorCleanupWithSameClient() {
|
||||
OkHttpClient oldClient = apiClient.getHttpClient();
|
||||
assertEquals(1, oldClient.networkInterceptors().size());
|
||||
apiClient.setHttpClient(oldClient);
|
||||
assertEquals(1, apiClient.getHttpClient().networkInterceptors().size());
|
||||
/**
|
||||
* Tests the invariant that the HttpClient for the ApiClient must never be null
|
||||
*/
|
||||
@Test(expected = NullPointerException.class)
|
||||
public void testNullHttpClient() {
|
||||
apiClient.setHttpClient(null);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
<project>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>org.openapitools</groupId>
|
||||
<artifactId>TypeScriptAngularBuildPestoreClientTests</artifactId>
|
||||
<packaging>pom</packaging>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
<name>TS Fetch Multiple Parameters Petstore Client</name>
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<artifactId>maven-dependency-plugin</artifactId>
|
||||
<executions>
|
||||
<execution>
|
||||
<phase>package</phase>
|
||||
<goals>
|
||||
<goal>copy-dependencies</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<outputDirectory>${project.build.directory}</outputDirectory>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</project>
|
||||
61
README.md
61
README.md
@@ -6,16 +6,18 @@
|
||||
[](https://circleci.com/gh/OpenAPITools/openapi-generator)
|
||||
[](https://app.shippable.com/github/OpenAPITools/openapi-generator)
|
||||
[](https://ci.appveyor.com/project/WilliamCheng/openapi-generator-wh2wu)
|
||||
[](https://cloud.drone.io/OpenAPITools/openapi-generator)
|
||||
|
||||
[`5.0.x`](https://github.com/OpenAPITools/openapi-generator/tree/5.0.x) branch: [](https://travis-ci.org/OpenAPITools/openapi-generator)
|
||||
[](https://circleci.com/gh/OpenAPITools/openapi-generator)
|
||||
[](https://app.shippable.com/github/OpenAPITools/openapi-generator)
|
||||
[](https://ci.appveyor.com/project/WilliamCheng/openapi-generator-wh2wu)
|
||||
[](https://cloud.drone.io/OpenAPITools/openapi-generator)
|
||||
</div>
|
||||
|
||||
<div align="center">
|
||||
|
||||
[](https://gitter.im/OpenAPITools/openapi-generator?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
|
||||
[](https://join.slack.com/t/openapi-generator/shared_invite/enQtNzAyNDMyOTU0OTE1LTY5ZDBiNDI5NzI5ZjQ1Y2E5OWVjMjZkYzY1ZGM2MWQ4YWFjMzcyNDY5MGI4NjQxNDBiMTlmZTc5NjY2ZTQ5MGM)
|
||||
[](http://search.maven.org/#search%7Cgav%7C1%7Cg%3A%22org.openapitools%22%20AND%20a%3A%22openapi-generator%22)
|
||||
[](https://twitter.com/oas_generator)
|
||||
|
||||
@@ -46,12 +48,18 @@ If you find OpenAPI Generator useful for work, please consider asking your compa
|
||||
[](https://www.namsor.com/?utm_source=openapi_generator&utm_medium=github_webpage&utm_campaign=sponsor)
|
||||
[](https://www.lightbow.net/?utm_source=openapi_generator&utm_medium=github_webpage&utm_campaign=sponsor)
|
||||
|
||||
#### Thank you GoDaddy for sponsoring the domain names and Linode for sponsoring the VPS
|
||||
|
||||
[<img src="https://openapi-generator.tech/img/companies/godaddy.png" width="150">](https://www.godaddy.com/?utm_source=openapi_generator&utm_medium=github_webpage&utm_campaign=sponsor)
|
||||
[](https://www.linode.com/?utm_source=openapi_generator&utm_medium=github_webpage&utm_campaign=sponsor)
|
||||
|
||||
|
||||
## Overview
|
||||
OpenAPI Generator allows generation of API client libraries (SDK generation), server stubs, documentation and configuration automatically given an [OpenAPI Spec](https://github.com/OAI/OpenAPI-Specification) (both 2.0 and 3.0 are supported). Currently, the following languages/frameworks are supported:
|
||||
|
||||
| | Languages/Frameworks |
|
||||
|-|-|
|
||||
**API clients** | **ActionScript**, **Ada**, **Apex**, **Bash**, **C**, **C#** (.net 2.0, 3.5 or later), **C++** (cpp-restsdk, Qt5, Tizen), **Clojure**, **Dart (1.x, 2.x)**, **Elixir**, **Elm**, **Eiffel**, **Erlang**, **Go**, **Groovy**, **Haskell** (http-client, Servant), **Java** (Jersey1.x, Jersey2.x, OkHttp, Retrofit1.x, Retrofit2.x, Feign, RestTemplate, RESTEasy, Vertx, Google API Client Library for Java, Rest-assured, Spring 5 Web Client), **Kotlin**, **Lua**, **Node.js** (ES5, ES6, AngularJS with Google Closure Compiler annotations, Flow types) **Objective-C**, **Perl**, **PHP**, **PowerShell**, **Python**, **R**, **Ruby**, **Rust** (rust, rust-server), **Scala** (akka, http4s, scalaz, swagger-async-httpclient), **Swift** (2.x, 3.x, 4.x), **Typescript** (AngularJS, Angular (2.x - 7.x), Aurelia, Axios, Fetch, Inversify, jQuery, Node, Rxjs)
|
||||
**API clients** | **ActionScript**, **Ada**, **Apex**, **Bash**, **C**, **C#** (.net 2.0, 3.5 or later), **C++** (cpp-restsdk, Qt5, Tizen), **Clojure**, **Dart (1.x, 2.x)**, **Elixir**, **Elm**, **Eiffel**, **Erlang**, **Go**, **Groovy**, **Haskell** (http-client, Servant), **Java** (Jersey1.x, Jersey2.x, OkHttp, Retrofit1.x, Retrofit2.x, Feign, RestTemplate, RESTEasy, Vertx, Google API Client Library for Java, Rest-assured, Spring 5 Web Client), **Kotlin**, **Lua**, **Node.js/JavaScript** (ES5, ES6, AngularJS with Google Closure Compiler annotations, Flow types), **Objective-C**, **OCaml**, **Perl**, **PHP**, **PowerShell**, **Python**, **R**, **Ruby**, **Rust** (rust, rust-server), **Scala** (akka, http4s, scalaz, swagger-async-httpclient), **Swift** (2.x, 3.x, 4.x), **Typescript** (AngularJS, Angular (2.x - 7.x), Aurelia, Axios, Fetch, Inversify, jQuery, Node, Rxjs)
|
||||
**Server stubs** | **Ada**, **C#** (ASP.NET Core, NancyFx), **C++** (Pistache, Restbed, Qt5 QHTTPEngine), **Erlang**, **F#** (Giraffe), **Go** (net/http, Gin), **Haskell** (Servant), **Java** (MSF4J, Spring, Undertow, JAX-RS: CDI, CXF, Inflector, RestEasy, Play Framework, [PKMST](https://github.com/ProKarma-Inc/pkmst-getting-started-examples)), **Kotlin** (Spring Boot, Ktor), **PHP** (Laravel, Lumen, Slim, Silex, [Symfony](https://symfony.com/), [Zend Expressive](https://github.com/zendframework/zend-expressive)), **Python** (Flask), **NodeJS**, **Ruby** (Sinatra, Rails5), **Rust** (rust-server), **Scala** ([Finch](https://github.com/finagle/finch), [Lagom](https://github.com/lagom/lagom), [Play](https://www.playframework.com/), Scalatra)
|
||||
**API documentation generators** | **HTML**, **Confluence Wiki**
|
||||
**Configuration files** | [**Apache2**](https://httpd.apache.org/)
|
||||
@@ -94,7 +102,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.1.0 (upcoming minor release) [SNAPSHOT](https://oss.sonatype.org/content/repositories/snapshots/org/openapitools/openapi-generator-cli/4.1.0-SNAPSHOT/)| 31.07.2019 | Minor release (breaking changes with fallbacks)
|
||||
[4.0.3](https://github.com/OpenAPITools/openapi-generator/releases/tag/v4.0.3) (latest stable release) | 09.07.2019 | Patch release (bug fixes, minor enhancements, etc)
|
||||
[4.1.0](https://github.com/OpenAPITools/openapi-generator/releases/tag/v4.1.0) (latest stable release) | 09.07.2019 | Patch release (bug fixes, minor enhancements, etc)
|
||||
|
||||
OpenAPI Spec compatibility: 1.0, 1.1, 1.2, 2.0, 3.0
|
||||
|
||||
@@ -150,16 +158,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.0.3/openapi-generator-cli-4.0.3.jar`
|
||||
JAR location: `http://central.maven.org/maven2/org/openapitools/openapi-generator-cli/4.1.0/openapi-generator-cli-4.1.0.jar`
|
||||
|
||||
For **Mac/Linux** users:
|
||||
```sh
|
||||
wget http://central.maven.org/maven2/org/openapitools/openapi-generator-cli/4.0.3/openapi-generator-cli-4.0.3.jar -O openapi-generator-cli.jar
|
||||
wget http://central.maven.org/maven2/org/openapitools/openapi-generator-cli/4.1.0/openapi-generator-cli-4.1.0.jar -O openapi-generator-cli.jar
|
||||
```
|
||||
|
||||
For **Windows** users, you will need to install [wget](http://gnuwin32.sourceforge.net/packages/wget.htm) or you can use Invoke-WebRequest in PowerShell (3.0+), e.g.
|
||||
```
|
||||
Invoke-WebRequest -OutFile openapi-generator-cli.jar http://central.maven.org/maven2/org/openapitools/openapi-generator-cli/4.0.3/openapi-generator-cli-4.0.3.jar
|
||||
Invoke-WebRequest -OutFile openapi-generator-cli.jar http://central.maven.org/maven2/org/openapitools/openapi-generator-cli/4.1.0/openapi-generator-cli-4.1.0.jar
|
||||
```
|
||||
|
||||
After downloading the JAR, run `java -jar openapi-generator-cli.jar help` to show the usage.
|
||||
@@ -217,9 +225,9 @@ openapi-generator-cli version # is always 3.0.2, unless any of the above overrid
|
||||
|
||||
To build from source, you need the following installed and available in your `$PATH:`
|
||||
|
||||
* [Java 8](http://java.oracle.com)
|
||||
* [Java 8](https://www.oracle.com/technetwork/java/index.html)
|
||||
|
||||
* [Apache Maven 3.3.4 or greater](http://maven.apache.org/)
|
||||
* [Apache Maven 3.3.4 or greater](https://maven.apache.org/)
|
||||
|
||||
After cloning the project, you can build it from source with this command:
|
||||
```sh
|
||||
@@ -242,6 +250,17 @@ openapi-generator generate -i https://raw.githubusercontent.com/openapitools/ope
|
||||
|
||||
To reinstall with the latest master, run `brew uninstall openapi-generator && brew install --HEAD openapi-generator`
|
||||
|
||||
To install OpenJDK (pre-requisites), please run
|
||||
```sh
|
||||
brew cask install adoptopenjdk12
|
||||
export JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk-12.0.2.jdk/Contents/Home/
|
||||
```
|
||||
|
||||
To install Maven, please run
|
||||
```sh
|
||||
brew install maven
|
||||
```
|
||||
|
||||
### [1.6 - Docker](#table-of-contents)
|
||||
|
||||
#### Public Pre-built Docker images
|
||||
@@ -342,7 +361,7 @@ Right now: no solution for this one :|
|
||||
#### Run Docker in Vagrant
|
||||
Prerequisite: install [Vagrant](https://www.vagrantup.com/downloads.html) and [VirtualBox](https://www.virtualbox.org/wiki/Downloads).
|
||||
```sh
|
||||
git clone http://github.com/openapitools/openapi-generator.git
|
||||
git clone https://github.com/openapitools/openapi-generator.git
|
||||
cd openapi-generator
|
||||
vagrant up
|
||||
vagrant ssh
|
||||
@@ -363,10 +382,10 @@ openapi-generator version
|
||||
```
|
||||
|
||||
<!-- RELEASE_VERSION -->
|
||||
Or install a particular OpenAPI Generator version (e.g. v4.0.3):
|
||||
Or install a particular OpenAPI Generator version (e.g. v4.1.0):
|
||||
|
||||
```sh
|
||||
npm install @openapitools/openapi-generator-cli@cli-4.0.3 -g
|
||||
npm install @openapitools/openapi-generator-cli@cli-4.1.0 -g
|
||||
```
|
||||
|
||||
Or install it as dev-dependency:
|
||||
@@ -390,7 +409,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.0.3/openapi-generator-cli-4.0.3.jar)
|
||||
You can also download the JAR (latest release) directly from [maven.org](http://central.maven.org/maven2/org/openapitools/openapi-generator-cli/4.1.0/openapi-generator-cli-4.1.0.jar)
|
||||
<!-- /RELEASE_VERSION -->
|
||||
|
||||
To get a list of **general** options available, please run `java -jar modules/openapi-generator-cli/target/openapi-generator-cli.jar help generate`
|
||||
@@ -500,8 +519,8 @@ Please refer to [integration.md](docs/integration.md) on how to integrate OpenAP
|
||||
|
||||
Here are the public online services:
|
||||
|
||||
- latest stable version: http://api.openapi-generator.tech
|
||||
- latest master: http://api-latest-master.openapi-generator.tech (updated with latest master every hour)
|
||||
- latest stable version: https://api.openapi-generator.tech
|
||||
- latest master: https://api-latest-master.openapi-generator.tech (updated with latest master every hour)
|
||||
|
||||
The server is sponsored by [Linode](https://www.linode.com/) [](https://www.linode.com/)
|
||||
|
||||
@@ -531,6 +550,7 @@ Here are some companies/projects (alphabetical order) using OpenAPI Generator in
|
||||
- [CAM](https://www.cam-inc.co.jp/)
|
||||
- [Camptocamp](https://www.camptocamp.com/en)
|
||||
- [codecentric AG](https://www.codecentric.de/)
|
||||
- [Commencis](https://www.commencis.com/)
|
||||
- [Cupix](https://www.cupix.com/)
|
||||
- [DB Systel](https://www.dbsystel.de)
|
||||
- [FormAPI](https://formapi.io/)
|
||||
@@ -575,6 +595,7 @@ Here are some companies/projects (alphabetical order) using OpenAPI Generator in
|
||||
- 2018/12/09 - [openapi-generator をカスタマイズする方法](https://qiita.com/watiko/items/0961287c02eac9211572) by [@watiko](https://qiita.com/watiko)
|
||||
- 2019/01/03 - [Calling a Swagger service from Apex using openapi-generator](https://lekkimworld.com/2019/01/03/calling-a-swagger-service-from-apex-using-openapi-generator/) by [Mikkel Flindt Heisterberg](https://lekkimworld.com)
|
||||
- 2019/01/13 - [OpenAPI GeneratorでRESTful APIの定義書から色々自動生成する](https://ky-yk-d.hatenablog.com/entry/2019/01/13/234108) by [@ky_yk_d](https://twitter.com/ky_yk_d)
|
||||
- 2019/01/20 - [Contract-First API Development with OpenAPI Generator and Connexion](https://medium.com/commencis/contract-first-api-development-with-openapi-generator-and-connexion-b21bbf2f9244) by [Anil Can Aydin](https://github.com/anlcnydn)
|
||||
- 2019/01/30 - [Rapid Application Development With API First Approach Using Open-API Generator](https://dzone.com/articles/rapid-api-development-using-open-api-generator) by [Milan Sonkar](https://dzone.com/users/828329/milan_sonkar.html)
|
||||
- 2019/02/02 - [平静を保ち、コードを生成せよ 〜 OpenAPI Generator誕生の背景と軌跡 〜](https://speakerdeck.com/akihito_nakano/gunmaweb34) by [中野暁人](https://github.com/ackintosh) at [Gunma.web #34 スキーマ駆動開発](https://gunmaweb.connpass.com/event/113974/)
|
||||
- 2019/02/20 - [An adventure in OpenAPI V3 code generation](https://mux.com/blog/an-adventure-in-openapi-v3-api-code-generation/) by [Phil Cluff](https://mux.com/blog/author/philc/)
|
||||
@@ -597,6 +618,7 @@ Here are some companies/projects (alphabetical order) using OpenAPI Generator in
|
||||
- 2019-07-04 - [REST API のためのコード生成入門 (OpenAPI Generator)](https://gum.co/openapi_generator_ebook_big5) by [William Cheng](https://twitter.com/wing328), [中野暁人](https://github.com/ackintosh), [和田拓朗](https://github.com/taxpon)
|
||||
- 2019-07-08 - [OpenAPI Generator にコントリビュートしたら社名が載った話。(CAM) - CAM TECH BLOG](https://tech.cam-inc.co.jp/entry/2019/07/08/140000) by [CAM, Inc.](https://www.cam-inc.co.jp/)
|
||||
- 2019-07-14 - [OpenAPI GeneratorでPythonのクライアントライブラリを作成した](https://qiita.com/yuji38kwmt/items/dfb929316a1335a161c0) by [yuji38kwmt](https://qiita.com/yuji38kwmt)
|
||||
- 2019-07-19 - [Developer Experience (DX) for Open-Source Projects: How to Engage Developers and Build a Growing Developer Community](https://speakerdeck.com/wing328/developer-experience-dx-for-open-source-projects-english-japanese) by [William Cheng](https://twitter.com/wing328), [中野暁人](https://github.com/ackintosh) at [Open Source Summit Japan 2019](https://events.linuxfoundation.org/events/open-source-summit-japan-2019/)
|
||||
|
||||
## [6 - About Us](#table-of-contents)
|
||||
|
||||
@@ -653,16 +675,19 @@ Here is a list of template creators:
|
||||
* Java (Vertx): @lopesmcc
|
||||
* Java (Google APIs Client Library): @charlescapps
|
||||
* Java (Rest-assured): @viclovsky
|
||||
* Java (Java 11 Native HTTP client): @bbdouglas
|
||||
* Javascript/NodeJS: @jfiala
|
||||
* Javascript (Closure-annotated Angular) @achew22
|
||||
* Javascript (Flow types) @jaypea
|
||||
* JMeter: @davidkiss
|
||||
* Kotlin: @jimschubert [:heart:](https://www.patreon.com/jimschubert)
|
||||
* Lua: @daurnimator
|
||||
* OCaml: @cgensoul
|
||||
* Perl: @wing328 [:heart:](https://www.patreon.com/wing328)
|
||||
* PHP (Guzzle): @baartosz
|
||||
* PowerShell: @beatcracker
|
||||
* R: @ramnov
|
||||
* Ruby (Faraday): @meganemura @dkliban
|
||||
* Rust: @farcaller
|
||||
* Rust (rust-server): @metaswitch
|
||||
* Scala (scalaz & http4s): @tbrown1979
|
||||
@@ -705,6 +730,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
|
||||
* NodeJS Express: @YishTish
|
||||
* PHP Laravel: @renepardon
|
||||
* PHP Lumen: @abcsun
|
||||
* PHP Slim: @jfastnacht
|
||||
@@ -773,7 +799,7 @@ If you want to join the committee, please kindly apply by sending an email to te
|
||||
| Elm | @eriktim (2018/09) |
|
||||
| Erlang | @tsloughter (2017/11) @jfacorro (2018/10) @robertoaloi (2018/10) |
|
||||
| F# | @nmfisher (2019/05) |
|
||||
| Go | @antihax (2017/11) @bvwells (2017/12) @grokify (2018/07) @kemokemo (2018/09 |
|
||||
| Go | @antihax (2017/11) @bvwells (2017/12) @grokify (2018/07) @kemokemo (2018/09) @bkabrda (2019/07) |
|
||||
| GraphQL | @renepardon (2018/12) |
|
||||
| Groovy | |
|
||||
| Haskell | |
|
||||
@@ -782,13 +808,14 @@ If you want to join the committee, please kindly apply by sending an email to te
|
||||
| Lua | @daurnimator (2017/08) |
|
||||
| NodeJS/Javascript | @CodeNinjai (2017/07) @frol (2017/07) @cliffano (2017/07) |
|
||||
| ObjC | |
|
||||
| OCaml | @cgensoul (2019/08) |
|
||||
| Perl | @wing328 (2017/07) [:heart:](https://www.patreon.com/wing328) @yue9944882 (2019/06) |
|
||||
| PHP | @jebentier (2017/07), @dkarlovi (2017/07), @mandrean (2017/08), @jfastnacht (2017/09), @ackintosh (2017/09) [:heart:](https://www.patreon.com/ackintosh/overview), @ybelenko (2018/07), @renepardon (2018/12) |
|
||||
| PowerShell | |
|
||||
| Python | @taxpon (2017/07) @frol (2017/07) @mbohlool (2017/07) @cbornet (2017/09) @kenjones-cisco (2017/11) @tomplus (2018/10) @Jyhess (2019/01) |
|
||||
| R | @Ramanth (2019/07) @saigiridhar21 (2019/07) |
|
||||
| Ruby | @cliffano (2017/07) @zlx (2017/09) @autopp (2019/02) |
|
||||
| Rust | @frol (2017/07) @farcaller (2017/08) @bjgill (2017/12) |
|
||||
| Rust | @frol (2017/07) @farcaller (2017/08) @bjgill (2017/12) @richardwhiuk (2019/07) |
|
||||
| Scala | @clasnake (2017/07), @jimschubert (2017/09) [:heart:](https://www.patreon.com/jimschubert), @shijinkui (2018/01), @ramzimaalej (2018/03) |
|
||||
| Swift | @jgavris (2017/07) @ehyche (2017/08) @Edubits (2017/09) @jaz-ah (2017/09) @d-date (2018/03) |
|
||||
| TypeScript | @TiFu (2017/07) @taxpon (2017/07) @sebastianhaas (2017/07) @kenisteward (2017/07) @Vrolijkx (2017/09) @macjohnny (2018/01) @nicokoenig (2018/09) @topce (2018/10) @akehir (2019/07) |
|
||||
@@ -861,7 +888,7 @@ Copyright 2018 SmartBear Software
|
||||
|
||||
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 [apache.org/licenses/LICENSE-2.0](http://www.apache.org/licenses/LICENSE-2.0)
|
||||
You may obtain a copy of the License at [apache.org/licenses/LICENSE-2.0](https://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,
|
||||
|
||||
@@ -34,6 +34,6 @@ rm -rf $STUB_DIR
|
||||
|
||||
# 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/$GENERATOR -i $SPEC -g $GENERATOR -o $STUB_DIR -DpackageName=petstore $@"
|
||||
ags="generate -t modules/openapi-generator/src/main/resources/$GENERATOR -i $SPEC -g $GENERATOR -o $STUB_DIR --additional-properties packageName=petstore $@"
|
||||
|
||||
java $JAVA_OPTS -jar $executable $ags
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
./bin/java-petstore-feign-10x.sh
|
||||
./bin/java-petstore-okhttp-gson.sh
|
||||
./bin/java-petstore-okhttp-gson-parcelable.sh
|
||||
./bin/java-petstore-native.sh
|
||||
./bin/java-petstore-retrofit.sh
|
||||
./bin/java-petstore-retrofit2.sh
|
||||
./bin/java-petstore-retrofit2rx.sh
|
||||
|
||||
@@ -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 --artifact-id petstore-java-client-jersey1 -t modules/openapi-generator/src/main/resources/Java -i modules/openapi-generator/src/test/resources/2_0/petstore-with-fake-endpoints-models-for-testing.yaml -g java -o samples/client/petstore/java/jersey1 --additional-properties hideGenerationTimestamp=true --library=jersey1 --additional-properties useNullForUnknownEnumValue=true $@"
|
||||
ags="generate --artifact-id petstore-java-client-jersey1 -t modules/openapi-generator/src/main/resources/Java -i modules/openapi-generator/src/test/resources/2_0/petstore-with-fake-endpoints-models-for-testing.yaml -g java -o samples/client/petstore/java/jersey1 --additional-properties hideGenerationTimestamp=true --library=jersey1 $@"
|
||||
|
||||
echo "Removing files and folders under samples/client/petstore/java/jersey1/src/main"
|
||||
rm -rf samples/client/petstore/java/jersey1/src/main
|
||||
|
||||
@@ -1,7 +1,4 @@
|
||||
{
|
||||
"library": "jersey2",
|
||||
"artifactId": "petstore-jersey2",
|
||||
"additionalProperties" : {
|
||||
"useNullForUnknownEnumValue" : true
|
||||
}
|
||||
"artifactId": "petstore-jersey2"
|
||||
}
|
||||
|
||||
4
bin/java-petstore-native.json
Normal file
4
bin/java-petstore-native.json
Normal file
@@ -0,0 +1,4 @@
|
||||
{
|
||||
"library": "native",
|
||||
"artifactId": "petstore-native"
|
||||
}
|
||||
@@ -27,20 +27,9 @@ 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/swift5 -i modules/openapi-generator/src/test/resources/2_0/swift/petstore-with-fake-endpoints-models-for-testing.yaml -g swift5 -c ./bin/swift5-petstore.json -o samples/client/petstore/swift5/default --generate-alias-as-model $@"
|
||||
ags="generate -t modules/openapi-generator/src/main/resources/Java/libraries/native -i modules/openapi-generator/src/test/resources/2_0/petstore-with-fake-endpoints-models-for-testing.yaml -g java -c bin/java-petstore-native.json -o samples/client/petstore/java/native --additional-properties hideGenerationTimestamp=true $@"
|
||||
|
||||
echo "Removing files and folders under samples/client/petstore/java/httpclient/src/main"
|
||||
rm -rf samples/client/petstore/java/native/src/main
|
||||
find samples/client/petstore/java/native -maxdepth 1 -type f ! -name "README.md" -exec rm {} +
|
||||
java $JAVA_OPTS -jar $executable $ags
|
||||
|
||||
cd samples/client/petstore/swift5/default
|
||||
|
||||
if type "xcodegen" > /dev/null 2>&1; then
|
||||
xcodegen generate
|
||||
|
||||
if type "carthage" > /dev/null 2>&1; then
|
||||
carthage update --no-use-binaries --platform ios --cache-builds
|
||||
fi
|
||||
fi
|
||||
|
||||
if type "swiftlint" > /dev/null 2>&1; then
|
||||
swiftlint autocorrect --quiet
|
||||
fi
|
||||
@@ -27,20 +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/swift5 -i modules/openapi-generator/src/test/resources/2_0/swift4Test.json -g swift5 -c ./bin/swift5-test.json -o samples/client/test/swift5default $@"
|
||||
ags="generate -t modules/openapi-generator/src/main/resources/nodejs-express-server -i modules/openapi-generator/src/test/resources/2_0/petstore.yaml -g nodejs-express-server -o samples/server/petstore/nodejs-express-server -Dservice $@"
|
||||
|
||||
java $JAVA_OPTS -jar $executable $ags
|
||||
|
||||
cd samples/client/test/swift5default
|
||||
|
||||
if type "xcodegen" > /dev/null 2>&1; then
|
||||
xcodegen generate
|
||||
|
||||
if type "carthage" > /dev/null 2>&1; then
|
||||
carthage update --no-use-binaries --platform ios --cache-builds
|
||||
fi
|
||||
fi
|
||||
|
||||
if type "swiftlint" > /dev/null 2>&1; then
|
||||
swiftlint autocorrect --quiet
|
||||
fi
|
||||
34
bin/ocaml-petstore.sh
Executable file
34
bin/ocaml-petstore.sh
Executable file
@@ -0,0 +1,34 @@
|
||||
#!/bin/sh
|
||||
|
||||
SCRIPT="$0"
|
||||
echo "# START SCRIPT: $SCRIPT"
|
||||
|
||||
while [ -h "$SCRIPT" ] ; do
|
||||
ls=`ls -ld "$SCRIPT"`
|
||||
link=`expr "$ls" : '.*-> \(.*\)$'`
|
||||
if expr "$link" : '/.*' > /dev/null; then
|
||||
SCRIPT="$link"
|
||||
else
|
||||
SCRIPT=`dirname "$SCRIPT"`/"$link"
|
||||
fi
|
||||
done
|
||||
|
||||
if [ ! -d "${APP_DIR}" ]; then
|
||||
APP_DIR=`dirname "$SCRIPT"`/..
|
||||
APP_DIR=`cd "${APP_DIR}"; pwd`
|
||||
fi
|
||||
|
||||
executable="./modules/openapi-generator-cli/target/openapi-generator-cli.jar"
|
||||
|
||||
if [ ! -f "$executable" ]
|
||||
then
|
||||
mvn -B clean package
|
||||
fi
|
||||
|
||||
# if you've executed sbt assembly previously it will use that instead.
|
||||
export JAVA_OPTS="${JAVA_OPTS} -Xmx1024M -DloggerPath=conf/log4j.properties"
|
||||
|
||||
args="generate -t modules/openapi-generator/src/main/resources/ocaml -i modules/openapi-generator/src/test/resources/2_0/petstore.yaml -g ocaml -o samples/client/petstore/ocaml --additional-properties packageName=petstore_client $@"
|
||||
|
||||
echo "java ${JAVA_OPTS} -jar ${executable} ${args}"
|
||||
java $JAVA_OPTS -jar $executable $args
|
||||
34
bin/openapi3/ocaml-client-petstore.sh
Executable file
34
bin/openapi3/ocaml-client-petstore.sh
Executable file
@@ -0,0 +1,34 @@
|
||||
#!/bin/sh
|
||||
|
||||
SCRIPT="$0"
|
||||
echo "# START SCRIPT: $SCRIPT"
|
||||
|
||||
while [ -h "$SCRIPT" ] ; do
|
||||
ls=`ls -ld "$SCRIPT"`
|
||||
link=`expr "$ls" : '.*-> \(.*\)$'`
|
||||
if expr "$link" : '/.*' > /dev/null; then
|
||||
SCRIPT="$link"
|
||||
else
|
||||
SCRIPT=`dirname "$SCRIPT"`/"$link"
|
||||
fi
|
||||
done
|
||||
|
||||
if [ ! -d "${APP_DIR}" ]; then
|
||||
APP_DIR=`dirname "$SCRIPT"`/..
|
||||
APP_DIR=`cd "${APP_DIR}"; pwd`
|
||||
fi
|
||||
|
||||
executable="./modules/openapi-generator-cli/target/openapi-generator-cli.jar"
|
||||
|
||||
if [ ! -f "$executable" ]
|
||||
then
|
||||
mvn -B clean package
|
||||
fi
|
||||
|
||||
# if you've executed sbt assembly previously it will use that instead.
|
||||
export JAVA_OPTS="${JAVA_OPTS} -Xmx1024M -DdebugOperations -DloggerPath=conf/log4j.properties"
|
||||
|
||||
args="generate -t modules/openapi-generator/src/main/resources/ocaml -i modules/openapi-generator/src/test/resources/3_0/petstore-with-fake-endpoints-models-for-testing.yaml -g ocaml -o samples/openapi3/client/petstore/ocaml/ --additional-properties packageName=petstore_client $@"
|
||||
|
||||
echo "java ${JAVA_OPTS} -jar ${executable} ${args}"
|
||||
java $JAVA_OPTS -jar $executable $args
|
||||
@@ -23,7 +23,7 @@ if [ ! -d "${APP_DIR}" ]; then
|
||||
fi
|
||||
|
||||
# Make sure that we are regenerating the sample by removing any existing target directory
|
||||
TARGET_DIR="$SCRIPT_DIR/../../samples/server/petstore/php-symfony/SymfonyBundle-php"
|
||||
TARGET_DIR="$SCRIPT_DIR/../../samples/openapi3/server/petstore/php-symfony/SymfonyBundle-php"
|
||||
if [ -d "$TARGET_DIR" ]; then
|
||||
rm -rf $TARGET_DIR
|
||||
fi
|
||||
|
||||
43
bin/openapi3/ruby-client-faraday-petstore.sh
Executable file
43
bin/openapi3/ruby-client-faraday-petstore.sh
Executable file
@@ -0,0 +1,43 @@
|
||||
#!/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
|
||||
|
||||
# purge lib/doc folder
|
||||
echo "purge ruby petstore lib, docs folder"
|
||||
rm -Rf samples/openapi3/client/petstore/ruby-faraday/lib
|
||||
rm -Rf samples/openapi3/client/petstore/ruby-faraday/docs
|
||||
|
||||
# purge test files other than integration test
|
||||
# NOTE: spec/custom/*.rb and spec/petstore_helper.rb are not generated files
|
||||
echo "purge ruby petstore spec"
|
||||
find samples/openapi3/client/petstore/ruby-faraday/spec -type d -not -name spec -not -name custom | xargs rm -Rf
|
||||
find samples/openapi3/client/petstore/ruby-faraday/spec -type f -not -name petstore_helper.rb -not -iwholename '*/spec/custom/*' | xargs rm -Rf
|
||||
|
||||
# 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/ruby-client -i modules/openapi-generator/src/test/resources/3_0/petstore-with-fake-endpoints-models-for-testing.yaml -g ruby -c bin/openapi3/ruby-petstore-faraday.json -o samples/openapi3/client/petstore/ruby-faraday --additional-properties skipFormModel=true $@"
|
||||
|
||||
java $JAVA_OPTS -jar $executable $ags
|
||||
6
bin/openapi3/ruby-petstore-faraday.json
Normal file
6
bin/openapi3/ruby-petstore-faraday.json
Normal file
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"gemName": "petstore",
|
||||
"moduleName": "Petstore",
|
||||
"library": "faraday",
|
||||
"gemVersion": "1.0.0"
|
||||
}
|
||||
32
bin/ruby-client-petstore-faraday.sh
Executable file
32
bin/ruby-client-petstore-faraday.sh
Executable file
@@ -0,0 +1,32 @@
|
||||
#!/bin/sh
|
||||
|
||||
SCRIPT="$0"
|
||||
echo "# START SCRIPT: $SCRIPT"
|
||||
|
||||
while [ -h "$SCRIPT" ] ; do
|
||||
ls=`ls -ld "$SCRIPT"`
|
||||
link=`expr "$ls" : '.*-> \(.*\)$'`
|
||||
if expr "$link" : '/.*' > /dev/null; then
|
||||
SCRIPT="$link"
|
||||
else
|
||||
SCRIPT=`dirname "$SCRIPT"`/"$link"
|
||||
fi
|
||||
done
|
||||
|
||||
if [ ! -d "${APP_DIR}" ]; then
|
||||
APP_DIR=`dirname "$SCRIPT"`/..
|
||||
APP_DIR=`cd "${APP_DIR}"; pwd`
|
||||
fi
|
||||
|
||||
executable="./modules/openapi-generator-cli/target/openapi-generator-cli.jar"
|
||||
|
||||
if [ ! -f "$executable" ]
|
||||
then
|
||||
mvn -B clean package
|
||||
fi
|
||||
|
||||
# if you've executed sbt assembly previously it will use that instead.
|
||||
export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties"
|
||||
ags="generate -t modules/openapi-generator/src/main/resources/ruby-client -i modules/openapi-generator/src/test/resources/2_0/petstore-with-fake-endpoints-models-for-testing.yaml -g ruby -c bin/ruby-petstore-faraday.json -o samples/client/petstore/ruby-faraday $@"
|
||||
|
||||
java $JAVA_OPTS -jar $executable $ags
|
||||
6
bin/ruby-petstore-faraday.json
Normal file
6
bin/ruby-petstore-faraday.json
Normal file
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"gemName": "petstore",
|
||||
"moduleName": "Petstore",
|
||||
"library": "faraday",
|
||||
"gemVersion": "1.0.0"
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
{
|
||||
"gemName": "petstore",
|
||||
"library": "typhoeus",
|
||||
"moduleName": "Petstore",
|
||||
"gemVersion": "1.0.0"
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
# Generate clients:
|
||||
./bin/spring-cloud-feign-petstore.sh
|
||||
./bin/spring-cloud-feign-async-petstore.sh
|
||||
./bin/spring-stubs.sh
|
||||
|
||||
# Generate spring-mvc servers:
|
||||
|
||||
@@ -27,20 +27,9 @@ 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/swift5 -i modules/openapi-generator/src/test/resources/2_0/swift/petstore-with-fake-endpoints-models-for-testing.yaml -g swift5 -c ./bin/swift5-petstore-rxswift.json -o samples/client/petstore/swift5/rxswift --generate-alias-as-model $@"
|
||||
ags="generate -t modules/openapi-generator/src/main/resources/JavaSpring/libraries/spring-cloud -i modules/openapi-generator/src/test/resources/2_0/petstore.yaml -g spring -c bin/spring-cloud-feign-petstore.json -o samples/client/petstore/spring-cloud-async --additional-properties hideGenerationTimestamp=true,java8=true,async=true $@"
|
||||
|
||||
echo "Removing files and folders under samples/client/petstore/spring-cloud-async/src/main"
|
||||
rm -rf samples/client/petstore/spring-cloud-async/src/main
|
||||
find samples/client/petstore/spring-cloud-async -maxdepth 1 -type f ! -name "README.md" -exec rm {} +
|
||||
java $JAVA_OPTS -jar $executable $ags
|
||||
|
||||
cd samples/client/petstore/swift5/rxswift
|
||||
|
||||
if type "xcodegen" > /dev/null 2>&1; then
|
||||
xcodegen generate
|
||||
|
||||
if type "carthage" > /dev/null 2>&1; then
|
||||
carthage update --no-use-binaries --platform ios --cache-builds
|
||||
fi
|
||||
fi
|
||||
|
||||
if type "swiftlint" > /dev/null 2>&1; then
|
||||
swiftlint autocorrect --quiet
|
||||
fi
|
||||
@@ -30,3 +30,13 @@ export JAVA_OPTS="${JAVA_OPTS} -Xmx1024M -DloggerPath=conf/log4j.properties"
|
||||
ags="generate -t modules/openapi-generator/src/main/resources/swift4 -i modules/openapi-generator/src/test/resources/2_0/petstore-with-fake-endpoints-models-for-testing.yaml -g swift4 -c ./bin/swift4-petstore-objcCompatible.json -o samples/client/petstore/swift4/objcCompatible $@"
|
||||
|
||||
java $JAVA_OPTS -jar $executable $ags
|
||||
|
||||
if type "xcodegen" > /dev/null 2>&1; then
|
||||
cd samples/client/petstore/swift4/objcCompatible
|
||||
xcodegen generate
|
||||
fi
|
||||
|
||||
if type "swiftlint" > /dev/null 2>&1; then
|
||||
cd samples/client/petstore/swift4/objcCompatible
|
||||
swiftlint autocorrect
|
||||
fi
|
||||
@@ -30,3 +30,13 @@ export JAVA_OPTS="${JAVA_OPTS} -Xmx1024M -DloggerPath=conf/log4j.properties"
|
||||
ags="generate -t modules/openapi-generator/src/main/resources/swift4 -i modules/openapi-generator/src/test/resources/2_0/swift/petstore-with-fake-endpoints-models-for-testing.yaml -g swift4 -c ./bin/swift4-petstore-promisekit.json -o samples/client/petstore/swift4/promisekit --generate-alias-as-model $@"
|
||||
|
||||
java $JAVA_OPTS -jar $executable $ags
|
||||
|
||||
if type "xcodegen" > /dev/null 2>&1; then
|
||||
cd samples/client/petstore/swift4/promisekit
|
||||
xcodegen generate
|
||||
fi
|
||||
|
||||
if type "swiftlint" > /dev/null 2>&1; then
|
||||
cd samples/client/petstore/swift4/promisekit
|
||||
swiftlint autocorrect
|
||||
fi
|
||||
@@ -30,3 +30,13 @@ export JAVA_OPTS="${JAVA_OPTS} -Xmx1024M -DloggerPath=conf/log4j.properties"
|
||||
ags="generate -t modules/openapi-generator/src/main/resources/swift4 -i modules/openapi-generator/src/test/resources/2_0/swift/petstore-with-fake-endpoints-models-for-testing.yaml -g swift4 -c ./bin/swift4-petstore-rxswift.json -o samples/client/petstore/swift4/rxswift --generate-alias-as-model $@"
|
||||
|
||||
java $JAVA_OPTS -jar $executable $ags
|
||||
|
||||
if type "xcodegen" > /dev/null 2>&1; then
|
||||
cd samples/client/petstore/swift4/rxswift
|
||||
xcodegen generate
|
||||
fi
|
||||
|
||||
if type "swiftlint" > /dev/null 2>&1; then
|
||||
cd samples/client/petstore/swift4/rxswift
|
||||
swiftlint autocorrect
|
||||
fi
|
||||
@@ -30,3 +30,13 @@ export JAVA_OPTS="${JAVA_OPTS} -Xmx1024M -DloggerPath=conf/log4j.properties"
|
||||
ags="generate -t modules/openapi-generator/src/main/resources/swift4 -i modules/openapi-generator/src/test/resources/2_0/swift/petstore-with-fake-endpoints-models-for-testing.yaml -g swift4 -c ./bin/swift4-petstore-unwrapRequired.json -o samples/client/petstore/swift4/unwrapRequired --generate-alias-as-model $@"
|
||||
|
||||
java $JAVA_OPTS -jar $executable $ags
|
||||
|
||||
if type "xcodegen" > /dev/null 2>&1; then
|
||||
cd samples/client/petstore/swift4/unwrapRequired
|
||||
xcodegen generate
|
||||
fi
|
||||
|
||||
if type "swiftlint" > /dev/null 2>&1; then
|
||||
cd samples/client/petstore/swift4/unwrapRequired
|
||||
swiftlint autocorrect
|
||||
fi
|
||||
@@ -30,3 +30,13 @@ export JAVA_OPTS="${JAVA_OPTS} -Xmx1024M -DloggerPath=conf/log4j.properties"
|
||||
ags="generate -t modules/openapi-generator/src/main/resources/swift4 -i modules/openapi-generator/src/test/resources/2_0/swift/petstore-with-fake-endpoints-models-for-testing.yaml -g swift4 -c ./bin/swift4-petstore.json -o samples/client/petstore/swift4/default --generate-alias-as-model $@"
|
||||
|
||||
java $JAVA_OPTS -jar $executable $ags
|
||||
|
||||
if type "xcodegen" > /dev/null 2>&1; then
|
||||
cd samples/client/petstore/swift4/default
|
||||
xcodegen generate
|
||||
fi
|
||||
|
||||
if type "swiftlint" > /dev/null 2>&1; then
|
||||
cd samples/client/petstore/swift4/default
|
||||
swiftlint autocorrect
|
||||
fi
|
||||
|
||||
@@ -30,3 +30,13 @@ export JAVA_OPTS="${JAVA_OPTS} -Xmx1024M -DloggerPath=conf/log4j.properties"
|
||||
ags="generate -t modules/openapi-generator/src/main/resources/swift4 -i modules/openapi-generator/src/test/resources/2_0/swift4Test.json -g swift4 -c ./bin/swift4-test.json -o samples/client/test/swift4/default $@"
|
||||
|
||||
java $JAVA_OPTS -jar $executable $ags
|
||||
|
||||
if type "xcodegen" > /dev/null 2>&1; then
|
||||
cd samples/client/test/swift4/default
|
||||
xcodegen generate
|
||||
fi
|
||||
|
||||
if type "swiftlint" > /dev/null 2>&1; then
|
||||
cd samples/client/test/swift4/default
|
||||
swiftlint autocorrect
|
||||
fi
|
||||
|
||||
@@ -1,4 +0,0 @@
|
||||
#!/bin/sh
|
||||
|
||||
./bin/swift5-petstore-all.sh
|
||||
./bin/swift5-test.sh
|
||||
@@ -1,6 +0,0 @@
|
||||
#!/bin/sh
|
||||
|
||||
./bin/swift5-petstore.sh
|
||||
./bin/swift5-petstore-promisekit.sh
|
||||
./bin/swift5-petstore-rxswift.sh
|
||||
./bin/swift5-petstore-unwrapRequired.sh
|
||||
@@ -1,8 +0,0 @@
|
||||
{
|
||||
"podSummary": "PetstoreClient",
|
||||
"podHomepage": "https://github.com/openapitools/openapi-generator",
|
||||
"podAuthors": "",
|
||||
"projectName": "PetstoreClient",
|
||||
"onlyPlainInterface": false,
|
||||
"responseAs": "PromiseKit"
|
||||
}
|
||||
@@ -1,8 +0,0 @@
|
||||
{
|
||||
"podSummary": "PetstoreClient",
|
||||
"podHomepage": "https://github.com/openapitools/openapi-generator",
|
||||
"podAuthors": "",
|
||||
"projectName": "PetstoreClient",
|
||||
"onlyPlainInterface": false,
|
||||
"responseAs": "RxSwift"
|
||||
}
|
||||
@@ -1,7 +0,0 @@
|
||||
{
|
||||
"podSummary": "PetstoreClient",
|
||||
"podHomepage": "https://github.com/openapitools/openapi-generator",
|
||||
"podAuthors": "",
|
||||
"projectName": "PetstoreClient",
|
||||
"unwrapRequired": true
|
||||
}
|
||||
@@ -1,46 +0,0 @@
|
||||
#!/bin/sh
|
||||
|
||||
SCRIPT="$0"
|
||||
echo "# START SCRIPT: $SCRIPT"
|
||||
|
||||
while [ -h "$SCRIPT" ] ; do
|
||||
ls=`ls -ld "$SCRIPT"`
|
||||
link=`expr "$ls" : '.*-> \(.*\)$'`
|
||||
if expr "$link" : '/.*' > /dev/null; then
|
||||
SCRIPT="$link"
|
||||
else
|
||||
SCRIPT=`dirname "$SCRIPT"`/"$link"
|
||||
fi
|
||||
done
|
||||
|
||||
if [ ! -d "${APP_DIR}" ]; then
|
||||
APP_DIR=`dirname "$SCRIPT"`/..
|
||||
APP_DIR=`cd "${APP_DIR}"; pwd`
|
||||
fi
|
||||
|
||||
executable="./modules/openapi-generator-cli/target/openapi-generator-cli.jar"
|
||||
|
||||
if [ ! -f "$executable" ]
|
||||
then
|
||||
mvn -B clean package
|
||||
fi
|
||||
|
||||
# if you've executed sbt assembly previously it will use that instead.
|
||||
export JAVA_OPTS="${JAVA_OPTS} -Xmx1024M -DloggerPath=conf/log4j.properties"
|
||||
ags="generate -t modules/openapi-generator/src/main/resources/swift5 -i modules/openapi-generator/src/test/resources/2_0/swift/petstore-with-fake-endpoints-models-for-testing.yaml -g swift5 -c ./bin/swift5-petstore-unwrapRequired.json -o samples/client/petstore/swift5/unwrapRequired --generate-alias-as-model $@"
|
||||
|
||||
java $JAVA_OPTS -jar $executable $ags
|
||||
|
||||
cd samples/client/petstore/swift5/unwrapRequired
|
||||
|
||||
if type "xcodegen" > /dev/null 2>&1; then
|
||||
xcodegen generate
|
||||
|
||||
if type "carthage" > /dev/null 2>&1; then
|
||||
carthage update --no-use-binaries --platform ios --cache-builds
|
||||
fi
|
||||
fi
|
||||
|
||||
if type "swiftlint" > /dev/null 2>&1; then
|
||||
swiftlint autocorrect --quiet
|
||||
fi
|
||||
@@ -1,6 +0,0 @@
|
||||
{
|
||||
"podSummary": "PetstoreClient",
|
||||
"podHomepage": "https://github.com/openapitools/openapi-generator",
|
||||
"podAuthors": "",
|
||||
"projectName": "PetstoreClient"
|
||||
}
|
||||
@@ -1,6 +0,0 @@
|
||||
{
|
||||
"podSummary": "TestClient",
|
||||
"podHomepage": "https://github.com/openapitools/openapi-generator",
|
||||
"podAuthors": "",
|
||||
"projectName": "TestClient"
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
{
|
||||
"npmName": "@openapitools/typescript-angular-petstore",
|
||||
"npmVersion": "1.0.0",
|
||||
"npmRepository" : "https://skimdb.npmjs.com/registry",
|
||||
"snapshot" : false
|
||||
"stringEnums": true,
|
||||
"npmRepository": "https://skimdb.npmjs.com/registry",
|
||||
"snapshot": false
|
||||
}
|
||||
|
||||
@@ -3,5 +3,6 @@
|
||||
./bin/typescript-axios-petstore-target-es6.sh
|
||||
./bin/typescript-axios-petstore-with-npm-version.sh
|
||||
./bin/typescript-axios-petstore-with-npm-version-and-separate-models-and-api.sh
|
||||
./bin/typescript-axios-petstore-with-complex-headers.sh
|
||||
./bin/typescript-axios-petstore-interfaces.sh
|
||||
./bin/typescript-axios-petstore.sh
|
||||
|
||||
32
bin/typescript-axios-petstore-with-complex-headers.sh
Executable file
32
bin/typescript-axios-petstore-with-complex-headers.sh
Executable file
@@ -0,0 +1,32 @@
|
||||
#!/bin/sh
|
||||
|
||||
SCRIPT="$0"
|
||||
echo "# START SCRIPT: $SCRIPT"
|
||||
|
||||
while [ -h "$SCRIPT" ] ; do
|
||||
ls=`ls -ld "$SCRIPT"`
|
||||
link=`expr "$ls" : '.*-> \(.*\)$'`
|
||||
if expr "$link" : '/.*' > /dev/null; then
|
||||
SCRIPT="$link"
|
||||
else
|
||||
SCRIPT=`dirname "$SCRIPT"`/"$link"
|
||||
fi
|
||||
done
|
||||
|
||||
if [ ! -d "${APP_DIR}" ]; then
|
||||
APP_DIR=`dirname "$SCRIPT"`/..
|
||||
APP_DIR=`cd "${APP_DIR}"; pwd`
|
||||
fi
|
||||
|
||||
executable="./modules/openapi-generator-cli/target/openapi-generator-cli.jar"
|
||||
|
||||
if [ ! -f "$executable" ]
|
||||
then
|
||||
mvn -B clean package
|
||||
fi
|
||||
|
||||
# if you've executed sbt assembly previously it will use that instead.
|
||||
export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties"
|
||||
ags="generate -i modules/openapi-generator/src/test/resources/3_0/petstore-with-complex-headers.yaml -g typescript-axios -o samples/client/petstore/typescript-axios/builds/with-complex-headers $@"
|
||||
|
||||
java $JAVA_OPTS -jar $executable $ags
|
||||
@@ -4,3 +4,4 @@
|
||||
./bin/typescript-fetch-petstore-with-npm-version.sh
|
||||
./bin/typescript-fetch-petstore-interfaces.sh
|
||||
./bin/typescript-fetch-petstore.sh
|
||||
./bin/typescript-fetch-petstore-multiple-parameters.sh
|
||||
4
bin/typescript-fetch-petstore-multiple-parameters.json
Normal file
4
bin/typescript-fetch-petstore-multiple-parameters.json
Normal file
@@ -0,0 +1,4 @@
|
||||
{
|
||||
"snapshot" : false,
|
||||
"useSingleRequestParameter": false
|
||||
}
|
||||
@@ -27,20 +27,8 @@ 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/swift5 -i modules/openapi-generator/src/test/resources/2_0/swift/petstore-with-fake-endpoints-models-for-testing.yaml -g swift5 -c ./bin/swift5-petstore-promisekit.json -o samples/client/petstore/swift5/promisekit --generate-alias-as-model $@"
|
||||
ags="generate -i modules/openapi-generator/src/test/resources/2_0/petstore.yaml -g typescript-fetch -c bin/typescript-fetch-petstore-multiple-parameters.json -o samples/client/petstore/typescript-fetch/builds/multiple-parameters $@"
|
||||
|
||||
java $JAVA_OPTS -jar $executable $ags
|
||||
|
||||
cd samples/client/petstore/swift5/promisekit
|
||||
|
||||
if type "xcodegen" > /dev/null 2>&1; then
|
||||
xcodegen generate
|
||||
|
||||
if type "carthage" > /dev/null 2>&1; then
|
||||
carthage update --no-use-binaries --platform ios --cache-builds
|
||||
fi
|
||||
fi
|
||||
|
||||
if type "swiftlint" > /dev/null 2>&1; then
|
||||
swiftlint autocorrect --quiet
|
||||
fi
|
||||
cp CI/samples.ci/client/petstore/typescript-fetch/builds/multiple-parameters/pom.xml samples/client/petstore/typescript-fetch/builds/multiple-parameters/pom.xml
|
||||
cp CI/samples.ci/client/petstore/typescript-fetch/tests/default/pom.xml samples/client/petstore/typescript-fetch/tests/default/pom.xml
|
||||
@@ -13,7 +13,7 @@ sleep 5
|
||||
declare -a scripts=(
|
||||
# SAMPLES
|
||||
"./bin/openapi3/ruby-client-petstore.sh"
|
||||
"./bin/ruby-client-petstore.sh"
|
||||
"./bin/openapi3/ruby-client-faraday-petstore.sh"
|
||||
"./bin/java-petstore-all.sh"
|
||||
"./bin/java-jaxrs-petstore-server-all.sh"
|
||||
"./bin/java-msf4j-petstore-server.sh"
|
||||
|
||||
@@ -2,6 +2,7 @@ call .\bin\windows\java-petstore-jersey1.bat
|
||||
call .\bin\windows\java-petstore-jersey2.bat
|
||||
call .\bin\windows\java-petstore-feign.bat
|
||||
call .\bin\windows\java-petstore-feign-10x.bat
|
||||
call .\bin\windows\java-petstore-native.bat
|
||||
call .\bin\windows\java-petstore-okhttp-gson.bat
|
||||
call .\bin\windows\java-petstore-okhttp-gson-parcelable.bat
|
||||
call .\bin\windows\java-petstore-retrofit.bat
|
||||
|
||||
10
bin/windows/java-petstore-native.bat
Normal file
10
bin/windows/java-petstore-native.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
|
||||
set ags=generate -t modules\openapi-generator\src\main\resources\Java\libraries\native -i modules\openapi-generator\src\test\resources\2_0\petstore-with-fake-endpoints-models-for-testing.yaml -g java -c bin\java-petstore-native.json -o samples\client\petstore\java\native --additional-properties hideGenerationTimestamp=true
|
||||
|
||||
java %JAVA_OPTS% -jar %executable% %ags%
|
||||
10
bin/windows/ocaml-petstore.bat
Executable file
10
bin/windows/ocaml-petstore.bat
Executable file
@@ -0,0 +1,10 @@
|
||||
set executable=.\modules\openapi-generator-cli\target\openapi-generator-cli.jar
|
||||
|
||||
If Not Exist %executable% (
|
||||
mvn clean package
|
||||
)
|
||||
|
||||
REM set JAVA_OPTS=%JAVA_OPTS% -Xmx1024M -DloggerPath=conf/log4j.properties
|
||||
set ags=generate -i modules\openapi-generator\src\test\resources\2_0\petstore.yaml -g ocaml -o samples\client\petstore\ocaml
|
||||
|
||||
java %JAVA_OPTS% -jar %executable% %ags%
|
||||
10
bin/windows/python-experimental-petstore.bat
Normal file
10
bin/windows/python-experimental-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
|
||||
set ags=generate -i modules\openapi-generator\src\test\resources\2_0\petstore-with-fake-endpoints-models-for-testing.yaml -g python-experimental -o samples\client\petstore\python-experimental -DpackageName=petstore_api
|
||||
|
||||
java %JAVA_OPTS% -jar %executable% %ags%
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
call bin\windows\typescript-axios-petstore.bat
|
||||
call bin\windows\typescript-axios-petstore-target-es6.bat
|
||||
call bin\windows\typescript-axios-petstore-with-complex-headers.bat
|
||||
call bin\windows\typescript-axios-petstore-with-npm-version.bat
|
||||
call bin\windows\typescript-axios-petstore-interfaces.bat
|
||||
call bin\windows\typescript-axios-petstore-with-npm-version-and-separate-models-and-api.bat
|
||||
12
bin/windows/typescript-axios-petstore-with-complex-headers.bat
Executable file
12
bin/windows/typescript-axios-petstore-with-complex-headers.bat
Executable file
@@ -0,0 +1,12 @@
|
||||
@ECHO OFF
|
||||
|
||||
set executable=.\modules\openapi-generator-cli\target\openapi-generator-cli.jar
|
||||
|
||||
If Not Exist %executable% (
|
||||
mvn clean package
|
||||
)
|
||||
|
||||
REM set JAVA_OPTS=%JAVA_OPTS% -Xmx1024M
|
||||
set ags=generate -i modules\openapi-generator\src\test\resources\3_0\petstore-with-complex-headers.yaml -g typescript-axios -o samples\client\petstore\typescript-axios\builds\with-complex-headers
|
||||
|
||||
java %JAVA_OPTS% -jar %executable% %ags%
|
||||
@@ -4,3 +4,4 @@ call bin\windows\typescript-fetch-petstore.bat
|
||||
call bin\windows\typescript-fetch-petstore-target-es6.bat
|
||||
call bin\windows\typescript-fetch-petstore-with-npm-version.bat
|
||||
call bin\windows\typescript-fetch-petstore-interfaces.bat
|
||||
call bin\windows\typescript-fetch-petstore-multiple-parameters.bat
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
@ECHO OFF
|
||||
|
||||
set executable=.\modules\openapi-generator-cli\target\openapi-generator-cli.jar
|
||||
|
||||
If Not Exist %executable% (
|
||||
mvn clean package
|
||||
)
|
||||
|
||||
REM set JAVA_OPTS=%JAVA_OPTS% -Xmx1024M
|
||||
set ags=generate -i modules\openapi-generator\src\test\resources\2_0\petstore.yaml -g typescript-fetch -c bin\typescript-fetch-petstore-multiple-parameters.json -o samples\client\petstore\typescript-fetch\builds\multiple-parameters
|
||||
|
||||
java %JAVA_OPTS% -jar %executable% %ags%
|
||||
@@ -19,7 +19,7 @@ if [[ -f "${codegen}" && -n "$(java ${JAVA_OPTS} -jar "${codegen}" completion |
|
||||
command=$1
|
||||
shift
|
||||
exec java ${JAVA_OPTS} -jar "${codegen}" "${command}" "$@"
|
||||
elif [[ -n "$(echo commands | tr ',' '\n' | grep "^$1\$" )" ]]; then
|
||||
elif [[ -n "$(echo $commands | tr ',' '\n' | grep "^$1\$" )" ]]; then
|
||||
# If CLI jar does not exist, and $1 is a known CLI command, build the CLI jar and run that command.
|
||||
if [[ ! -f "${codegen}" ]]; then
|
||||
(cd "${GEN_DIR}" && exec mvn -am -pl "modules/openapi-generator-cli" -Duser.home=$(dirname $MAVEN_CONFIG) package)
|
||||
|
||||
@@ -62,3 +62,26 @@ The steps are shown here for a specific version of the generator, but apply the
|
||||
Listening for transport dt_socket at address: 5005
|
||||
```
|
||||
* Set breakpoints in code, and then attach your remote debugger from your IDE (see above). The generator will automatically unblock once the remote debugger is attached. You can now step through the code.
|
||||
|
||||
## Logs
|
||||
|
||||
You can try to enable debugging log with `-Dlog.level=debug` option to the `JAVA_OPTS` environment variable to see more information:
|
||||
|
||||
```bash
|
||||
export JAVA_OPTS="${JAVA_OPTS} -Dlog.level=debug"
|
||||
```
|
||||
|
||||
Set the option then DEBUG logs are printed out:
|
||||
|
||||
```bash
|
||||
openapi-generator generate -g go ...
|
||||
|
||||
...
|
||||
...
|
||||
[main] DEBUG o.o.codegen.DefaultCodegen - debugging fromProperty for files : class Schema {
|
||||
type: null
|
||||
format: null
|
||||
$ref: #/components/schemas/File
|
||||
...
|
||||
...
|
||||
```
|
||||
|
||||
@@ -39,6 +39,7 @@ The following generators are available:
|
||||
- [kotlin](generators/kotlin.md)
|
||||
- [lua](generators/lua.md)
|
||||
- [objc](generators/objc.md)
|
||||
- [ocaml](generators/ocaml.md)
|
||||
- [perl](generators/perl.md)
|
||||
- [php](generators/php.md)
|
||||
- [powershell](generators/powershell.md)
|
||||
@@ -54,7 +55,6 @@ The following generators are available:
|
||||
- [swift2-deprecated](generators/swift2-deprecated.md) (deprecated)
|
||||
- [swift3-deprecated](generators/swift3-deprecated.md) (deprecated)
|
||||
- [swift4](generators/swift4.md)
|
||||
- [swift5](generators/swift5.md)
|
||||
- [typescript-angular](generators/typescript-angular.md)
|
||||
- [typescript-angularjs](generators/typescript-angularjs.md)
|
||||
- [typescript-aurelia](generators/typescript-aurelia.md)
|
||||
@@ -94,6 +94,7 @@ The following generators are available:
|
||||
- [jaxrs-spec](generators/jaxrs-spec.md)
|
||||
- [kotlin-server](generators/kotlin-server.md)
|
||||
- [kotlin-spring](generators/kotlin-spring.md)
|
||||
- [nodejs-express-server](generators/nodejs-express-server.md) (beta)
|
||||
- [nodejs-server-deprecated](generators/nodejs-server-deprecated.md) (deprecated)
|
||||
- [php-laravel](generators/php-laravel.md)
|
||||
- [php-lumen](generators/php-lumen.md)
|
||||
|
||||
@@ -47,7 +47,6 @@ The following generators are available:
|
||||
- [swift2-deprecated](swift2-deprecated.md)
|
||||
- [swift3-deprecated](swift3-deprecated.md)
|
||||
- [swift4](swift4.md)
|
||||
- [swift5](swift5.md)
|
||||
- [typescript-angular](typescript-angular.md)
|
||||
- [typescript-angularjs](typescript-angularjs.md)
|
||||
- [typescript-aurelia](typescript-aurelia.md)
|
||||
|
||||
@@ -12,5 +12,5 @@ sidebar_label: cpp-qt5-client
|
||||
|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|
|
||||
|cppNamespace|C++ namespace (convention: name::space::for::api).| |OpenAPI|
|
||||
|cppNamespace|C++ namespace (convention: name::space::for::api).| |OpenAPI|
|
||||
|modelNamePrefix|Prefix that will be prepended to all model names.| |OAI|
|
||||
|optionalProjectFile|Generate client.pri.| |true|
|
||||
|
||||
@@ -12,4 +12,4 @@ sidebar_label: cpp-qt5-qhttpengine-server
|
||||
|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|
|
||||
|cppNamespace|C++ namespace (convention: name::space::for::api).| |OpenAPI|
|
||||
|cppNamespace|C++ namespace (convention: name::space::for::api).| |OpenAPI|
|
||||
|modelNamePrefix|Prefix that will be prepended to all model names.| |OAI|
|
||||
|
||||
@@ -55,4 +55,4 @@ sidebar_label: java
|
||||
|feignVersion|Version of OpenFeign: '10.x', '9.x' (default)| |false|
|
||||
|useReflectionEqualsHashCode|Use org.apache.commons.lang3.builder for equals and hashCode in the models. WARNING: This will fail under a security manager, unless the appropriate permissions are set up correctly and also there's potential performance impact.| |false|
|
||||
|caseInsensitiveResponseHeaders|Make API response's headers case-insensitive. Available on okhttp-gson, jersey2 libraries| |false|
|
||||
|library|library template (sub-template) to use|<dl><dt>**jersey1**</dt><dd>HTTP client: Jersey client 1.19.x. JSON processing: Jackson 2.8.x. Enable Java6 support using '-DsupportJava6=true'. Enable gzip request encoding using '-DuseGzipFeature=true'. IMPORTANT NOTE: jersey 1.x is no longer actively maintained so please upgrade to 'jersey2' or other HTTP libaries instead.</dd><dt>**jersey2**</dt><dd>HTTP client: Jersey client 2.25.1. JSON processing: Jackson 2.8.x</dd><dt>**feign**</dt><dd>HTTP client: OpenFeign 9.x or 10.x. JSON processing: Jackson 2.8.x. To enable OpenFeign 10.x, set the 'feignVersion' option to '10.x'</dd><dt>**okhttp-gson**</dt><dd>[DEFAULT] HTTP client: OkHttp 3.x. JSON processing: Gson 2.8.x. Enable Parcelable models on Android using '-DparcelableModel=true'. Enable gzip request encoding using '-DuseGzipFeature=true'.</dd><dt>**retrofit**</dt><dd>HTTP client: OkHttp 2.x. JSON processing: Gson 2.x (Retrofit 1.9.0). IMPORTANT NOTE: retrofit1.x is no longer actively maintained so please upgrade to 'retrofit2' instead.</dd><dt>**retrofit2**</dt><dd>HTTP client: OkHttp 3.x. JSON processing: Gson 2.x (Retrofit 2.3.0). Enable the RxJava adapter using '-DuseRxJava[2]=true'. (RxJava 1.x or 2.x)</dd><dt>**resttemplate**</dt><dd>HTTP client: Spring RestTemplate 4.x. JSON processing: Jackson 2.8.x</dd><dt>**webclient**</dt><dd>HTTP client: Spring WebClient 5.x. JSON processing: Jackson 2.9.x</dd><dt>**resteasy**</dt><dd>HTTP client: Resteasy client 3.x. JSON processing: Jackson 2.8.x</dd><dt>**vertx**</dt><dd>HTTP client: VertX client 3.x. JSON processing: Jackson 2.8.x</dd><dt>**google-api-client**</dt><dd>HTTP client: Google API client 1.x. JSON processing: Jackson 2.8.x</dd><dt>**rest-assured**</dt><dd>HTTP client: rest-assured : 4.x. JSON processing: Gson 2.x. Only for Java8</dd><dl>|okhttp-gson|
|
||||
|library|library template (sub-template) to use|<dl><dt>**jersey1**</dt><dd>HTTP client: Jersey client 1.19.x. JSON processing: Jackson 2.8.x. Enable Java6 support using '-DsupportJava6=true'. Enable gzip request encoding using '-DuseGzipFeature=true'. IMPORTANT NOTE: jersey 1.x is no longer actively maintained so please upgrade to 'jersey2' or other HTTP libaries instead.</dd><dt>**jersey2**</dt><dd>HTTP client: Jersey client 2.25.1. JSON processing: Jackson 2.8.x</dd><dt>**feign**</dt><dd>HTTP client: OpenFeign 9.x or 10.x. JSON processing: Jackson 2.8.x. To enable OpenFeign 10.x, set the 'feignVersion' option to '10.x'</dd><dt>**okhttp-gson**</dt><dd>[DEFAULT] HTTP client: OkHttp 3.x. JSON processing: Gson 2.8.x. Enable Parcelable models on Android using '-DparcelableModel=true'. Enable gzip request encoding using '-DuseGzipFeature=true'.</dd><dt>**retrofit**</dt><dd>HTTP client: OkHttp 2.x. JSON processing: Gson 2.x (Retrofit 1.9.0). IMPORTANT NOTE: retrofit1.x is no longer actively maintained so please upgrade to 'retrofit2' instead.</dd><dt>**retrofit2**</dt><dd>HTTP client: OkHttp 3.x. JSON processing: Gson 2.x (Retrofit 2.3.0). Enable the RxJava adapter using '-DuseRxJava[2]=true'. (RxJava 1.x or 2.x)</dd><dt>**resttemplate**</dt><dd>HTTP client: Spring RestTemplate 4.x. JSON processing: Jackson 2.8.x</dd><dt>**webclient**</dt><dd>HTTP client: Spring WebClient 5.x. JSON processing: Jackson 2.9.x</dd><dt>**resteasy**</dt><dd>HTTP client: Resteasy client 3.x. JSON processing: Jackson 2.8.x</dd><dt>**vertx**</dt><dd>HTTP client: VertX client 3.x. JSON processing: Jackson 2.8.x</dd><dt>**google-api-client**</dt><dd>HTTP client: Google API client 1.x. JSON processing: Jackson 2.8.x</dd><dt>**rest-assured**</dt><dd>HTTP client: rest-assured : 4.x. JSON processing: Gson 2.x. Only for Java8</dd><dt>**native**</dt><dd>HTTP client: Java native HttpClient. JSON processing: Jackson 2.9.x. Only for Java11+</dd><dl>|okhttp-gson|
|
||||
|
||||
14
docs/generators/nodejs-express-server.md
Normal file
14
docs/generators/nodejs-express-server.md
Normal file
@@ -0,0 +1,14 @@
|
||||
|
||||
---
|
||||
id: generator-opts-server-nodejs-express-server
|
||||
title: Config Options for nodejs-express-server
|
||||
sidebar_label: nodejs-express-server
|
||||
---
|
||||
|
||||
| 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|
|
||||
|serverPort|TCP port to listen on.| |null|
|
||||
13
docs/generators/ocaml-client.md
Normal file
13
docs/generators/ocaml-client.md
Normal file
@@ -0,0 +1,13 @@
|
||||
|
||||
---
|
||||
id: generator-opts-client-ocaml-client
|
||||
title: Config Options for ocaml-client
|
||||
sidebar_label: ocaml-client
|
||||
---
|
||||
|
||||
| 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
docs/generators/ocaml.md
Normal file
13
docs/generators/ocaml.md
Normal file
@@ -0,0 +1,13 @@
|
||||
|
||||
---
|
||||
id: generator-opts-client-ocaml
|
||||
title: Config Options for ocaml
|
||||
sidebar_label: ocaml
|
||||
---
|
||||
|
||||
| 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|
|
||||
@@ -11,4 +11,4 @@ sidebar_label: openapi-yaml
|
||||
|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|
|
||||
|outputFile|output filename| |null|
|
||||
|outputFile|Output filename| |openapi/openapi.yaml|
|
||||
|
||||
@@ -22,3 +22,4 @@ sidebar_label: ruby
|
||||
|gemAuthor|gem author (only one is supported).| |null|
|
||||
|gemAuthorEmail|gem author email (only one is supported).| |null|
|
||||
|hideGenerationTimestamp|Hides the generation timestamp when files are generated.| |true|
|
||||
|library|HTTP library template (sub-template) to use|<dl><dt>**faraday**</dt><dd>Faraday (https://github.com/lostisland/faraday) (Beta support)</dd><dt>**typhoeus**</dt><dd>Typhoeus >= 1.0.1 (https://github.com/typhoeus/typhoeus)</dd><dl>|typhoeus|
|
||||
|
||||
@@ -26,3 +26,4 @@ sidebar_label: typescript-angular
|
||||
|modelSuffix|The suffix of the generated model.| |null|
|
||||
|modelFileSuffix|The suffix of the file of the generated model (model<suffix>.ts).| |null|
|
||||
|fileNaming|Naming convention for the output files: 'camelCase', 'kebab-case'.| |camelCase|
|
||||
|stringEnums|Generate string enums instead of objects for enum values.| |false|
|
||||
|
||||
@@ -18,3 +18,4 @@ sidebar_label: typescript-fetch
|
||||
|snapshot|When setting this property to true, the version will be suffixed with -SNAPSHOT.yyyyMMddHHmm| |false|
|
||||
|npmRepository|Use this property to set an url your private npmRepo in the package.json| |null|
|
||||
|withInterfaces|Setting this property to true will generate interfaces next to the default class implementations.| |false|
|
||||
|useSingleRequestParameter|Setting this property to true will generate functions with a single argument containing all API endpoint parameters instead of one argument per parameter.| |true|
|
||||
|
||||
@@ -16,7 +16,7 @@ The transform logic needs to implement [CodegenConfig.java](https://github.com/o
|
||||
> OpenAPI Generator applies user-defined templates via options:
|
||||
> * CLI: `-t/--template` CLI options
|
||||
> * Maven Plugin: `templateDirectory`
|
||||
> * Gradle Plugin: `templateDir`
|
||||
> * Gradle Plugin: `templateDir`
|
||||
|
||||
Built-in templates are written in Mustache and processed by [jmustache](https://github.com/samskivert/jmustache). Beginning with version 4.0.0, we support experimental Handlebars and user-defined template engines via plugins.
|
||||
|
||||
@@ -26,7 +26,7 @@ OpenAPI Generator supports user-defined templates. This approach is often the ea
|
||||
|
||||
### Custom Logic
|
||||
|
||||
For this example, let's modify a Java client to use AOP via [jcabi/jcabi-aspects](https://github.com/jcabi/jcabi-aspects). We'll log API method execution at the `INFO` level. The jcabi-aspects project could also be used to implement method retries on failures; this would be a great exercise to further play around with templating.
|
||||
For this example, let's modify a Java client to use AOP via [jcabi/jcabi-aspects](https://github.com/jcabi/jcabi-aspects). We'll log API method execution at the `INFO` level. The jcabi-aspects project could also be used to implement method retries on failures; this would be a great exercise to further play around with templating.
|
||||
|
||||
The Java generator supports a `library` option. This option works by defining base templates, then applying library-specific template overrides. This allows for template reuse for libraries sharing the same programming language. Templates defined as a library need only modify or extend the templates concerning the library, and generation falls back to the root templates (the "defaults") when not extended by the library. Generators which support the `library` option will only support the libraries known by the generator at compile time, and will throw a runtime error if you try to provide a custom library name.
|
||||
|
||||
@@ -77,7 +77,7 @@ index 3b40702..a6d12e0 100644
|
||||
+++ b/libraries/resteasy/build.gradle.mustache
|
||||
@@ -134,6 +134,7 @@ ext {
|
||||
}
|
||||
|
||||
|
||||
dependencies {
|
||||
+ compile "com.jcabi:jcabi-aspects:0.22.6"
|
||||
compile "io.swagger:swagger-annotations:$swagger_annotations_version"
|
||||
@@ -95,7 +95,7 @@ index a4d0f9f..49b17c7 100644
|
||||
+++ b/libraries/resteasy/api.mustache
|
||||
@@ -1,5 +1,6 @@
|
||||
package {{package}};
|
||||
|
||||
|
||||
+import com.jcabi.aspects.Loggable;
|
||||
import {{invokerPackage}}.ApiException;
|
||||
import {{invokerPackage}}.ApiClient;
|
||||
@@ -134,7 +134,7 @@ index 04a9d55..7a93c50 100644
|
||||
apply plugin: 'idea'
|
||||
apply plugin: 'eclipse'
|
||||
+apply plugin: 'aspectj'
|
||||
|
||||
|
||||
group = '{{groupId}}'
|
||||
version = '{{artifactVersion}}'
|
||||
@@ -12,6 +13,7 @@ buildscript {
|
||||
@@ -144,14 +144,14 @@ index 04a9d55..7a93c50 100644
|
||||
+ classpath "net.uberfoo.gradle:gradle-aspectj:2.2"
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -140,9 +142,18 @@ ext {
|
||||
jersey_version = "1.19.4"
|
||||
jodatime_version = "2.9.9"
|
||||
junit_version = "4.12"
|
||||
+ aspectjVersion = '1.9.0'
|
||||
}
|
||||
|
||||
|
||||
+sourceCompatibility = '1.8'
|
||||
+targetCompatibility = '1.8'
|
||||
+
|
||||
@@ -199,7 +199,7 @@ Make sure your custom template compiles:
|
||||
```bash
|
||||
cd ~/.openapi-generator/example
|
||||
gradle assemble
|
||||
# or, regenerate the wrapper
|
||||
# or, regenerate the wrapper
|
||||
gradle wrapper --gradle-version 4.8 --distribution-type all
|
||||
./gradlew assemble
|
||||
```
|
||||
@@ -291,7 +291,7 @@ Modifications to the new project's `build.gradle` should be made in the `plugins
|
||||
id 'org.jetbrains.kotlin.jvm' version '1.3.11'
|
||||
id "com.github.johnrengelman.shadow" version "5.0.0"
|
||||
}
|
||||
|
||||
|
||||
dependencies {
|
||||
compile "org.jetbrains.kotlin:kotlin-stdlib-jdk8"
|
||||
compile "org.openapitools:openapi-generator-core:4.0.0-SNAPSHOT"
|
||||
@@ -301,7 +301,7 @@ Modifications to the new project's `build.gradle` should be made in the `plugins
|
||||
|
||||
The above configuration for the `shadow` plugin is strictly optional. It is not needed, for instance, if you plan to publish your adapter and consume it via the Maven or Gradle plugins.
|
||||
|
||||
Next, create a new class file called `PebbleTemplateEngineAdapter` under `src/kotlin`. We'll define the template adapter's name as `pebble` and we'll also list this as the only supported file extension. We'll implement the adapter by extending `AbstractTemplatingEngineAdapter`, which includes reusable logic, such as retrieving a list of all possible template names for our provided template extensions(s).
|
||||
Next, create a new class file called `PebbleTemplateEngineAdapter` under `src/kotlin`. We'll define the template adapter's name as `pebble` and we'll also list this as the only supported file extension. We'll implement the adapter by extending `AbstractTemplatingEngineAdapter`, which includes reusable logic, such as retrieving a list of all possible template names for our provided template extensions(s).
|
||||
|
||||
The class in its simplest form looks like this (with inline comments):
|
||||
|
||||
@@ -374,7 +374,7 @@ import (
|
||||
{% endfor %}
|
||||
)
|
||||
|
||||
type Generated{{classname}}Servicer
|
||||
type Generated{{classname}}Servicer
|
||||
|
||||
// etc
|
||||
```
|
||||
@@ -402,7 +402,7 @@ type {{item.classname}} struct {
|
||||
|
||||
> Find object structures passed to templates later in this document's **Structures** section.
|
||||
|
||||
Finally, we can compile some code by explicitly defining our classpath and jar entrypoint for CLI (be sure to modify `/your/path` below)
|
||||
Finally, we can compile some code by explicitly defining our classpath and jar entrypoint for CLI (be sure to modify `/your/path` below)
|
||||
|
||||
```bash
|
||||
java $JAVA_OPTS -cp /your/path/build/libs/pebble-template-adapter-1.0-SNAPSHOT-all.jar:modules/openapi-generator-cli/target/openapi-generator-cli.jar \
|
||||
@@ -428,49 +428,49 @@ Examples for the following structures will be presented using the following spec
|
||||
|
||||
```yaml
|
||||
swagger: "2.0"
|
||||
info:
|
||||
info:
|
||||
version: "1.0.0"
|
||||
title: "Swagger Petstore"
|
||||
description: "A sample API that uses a petstore as an example to demonstrate features in the swagger-2.0 specification"
|
||||
termsOfService: "http://swagger.io/terms/"
|
||||
contact:
|
||||
contact:
|
||||
name: "Swagger API Team"
|
||||
license:
|
||||
license:
|
||||
name: "MIT"
|
||||
host: "petstore.swagger.io"
|
||||
basePath: "/api"
|
||||
schemes:
|
||||
schemes:
|
||||
- "http"
|
||||
consumes:
|
||||
consumes:
|
||||
- "application/json"
|
||||
produces:
|
||||
produces:
|
||||
- "application/json"
|
||||
paths:
|
||||
/pets:
|
||||
get:
|
||||
paths:
|
||||
/pets:
|
||||
get:
|
||||
description: "Returns all pets from the system that the user has access to"
|
||||
produces:
|
||||
produces:
|
||||
- "application/json"
|
||||
responses:
|
||||
responses:
|
||||
"200":
|
||||
description: "A list of pets."
|
||||
schema:
|
||||
schema:
|
||||
type: "array"
|
||||
items:
|
||||
items:
|
||||
$ref: "#/definitions/Pet"
|
||||
definitions:
|
||||
Pet:
|
||||
definitions:
|
||||
Pet:
|
||||
type: "object"
|
||||
required:
|
||||
required:
|
||||
- "id"
|
||||
- "name"
|
||||
properties:
|
||||
id:
|
||||
properties:
|
||||
id:
|
||||
type: "integer"
|
||||
format: "int64"
|
||||
name:
|
||||
name:
|
||||
type: "string"
|
||||
tag:
|
||||
tag:
|
||||
type: "string"
|
||||
|
||||
```
|
||||
@@ -478,9 +478,9 @@ Examples for the following structures will be presented using the following spec
|
||||
### Operations
|
||||
|
||||
> Inspect operation structures passed to templates with system property `-DdebugOpenAPI`
|
||||
>
|
||||
>
|
||||
> Example:
|
||||
>
|
||||
>
|
||||
> ```bash
|
||||
> openapi-generator generate -g go \
|
||||
> -o out \
|
||||
@@ -510,9 +510,9 @@ Here, an Operation with tag `Pet` will generate two files: `SWGPetApi.h` and `SW
|
||||
### Models
|
||||
|
||||
> Inspect models passed to templates with system property `-DdebugModels`
|
||||
>
|
||||
>
|
||||
> Execute:
|
||||
>
|
||||
>
|
||||
> ```bash
|
||||
> openapi-generator generate -g go \
|
||||
> -o out \
|
||||
@@ -730,14 +730,14 @@ Templates are passed redundant properties, depending on the semantics of the arr
|
||||
* `readOnlyVars` lists all model properties marked with `readonly` in the spec document
|
||||
* `allVars` lists all model properties. This may include the same set as `vars`, but may also include generator-defined properties
|
||||
|
||||
We expose the same properties in multiple sets because this allows us to conditionally iterate over properties based on some condition ("is it required" or "is it readonly"). This is driven by the use of the logic-less Mustache templates. It is possible that models passed to the templating engine may be cleaned up as we support more template engines, but such an effort will go through a deprecation phase and would be communicated at runtime through log messages.
|
||||
We expose the same properties in multiple sets because this allows us to conditionally iterate over properties based on some condition ("is it required" or "is it readonly"). This is driven by the use of the logic-less Mustache templates. It is possible that models passed to the templating engine may be cleaned up as we support more template engines, but such an effort will go through a deprecation phase and would be communicated at runtime through log messages.
|
||||
|
||||
### supportingFiles
|
||||
|
||||
> Inspect supportingFiles passed to templates with system property `-DdebugSupportingFiles`
|
||||
>
|
||||
>
|
||||
> Execute:
|
||||
>
|
||||
>
|
||||
> ```bash
|
||||
> openapi-generator generate -g go \
|
||||
> -o out \
|
||||
@@ -755,10 +755,25 @@ Supporting files can either be processed through the templating engine or copied
|
||||
|
||||
> This is a very limited list of variable name explanations. Feel free to [open a pull request](https://github.com/OpenAPITools/openapi-generator/pull/new/master) to add to this documentation!
|
||||
|
||||
- **complexType**: stores the name of the model (e.g. Pet)
|
||||
- **complexType**: stores the name of the model (e.g. Pet)
|
||||
- **isContainer**: true if the parameter or property is an array or a map.
|
||||
- **isPrimitiveType**: true if the parameter or property type is a primitive type (e.g. string, integer, etc) as defined in the spec.
|
||||
|
||||
## Mustache Lambdas
|
||||
|
||||
Many generators (*those extending DefaultCodegen*) come with a small set of lambda functions available under the key `lambda`:
|
||||
|
||||
- `lowercase` - Converts all of the characters in this fragment to lower case using the rules of the `ROOT` locale.
|
||||
- `uppercase` - Converts all of the characters in this fragment to upper case using the rules of the `ROOT` locale.
|
||||
- `titlecase` - Converts text in a fragment to title case. For example `once upon a time` to `Once Upon A Time`.
|
||||
- `camelcase` - Converts text in a fragment to camelCase. For example `Input-text` to `inputText`.
|
||||
- `indented` - Prepends 4 spaces indention from second line of a fragment on. First line will be indented by Mustache.
|
||||
- `indented_8` - Prepends 8 spaces indention from second line of a fragment on. First line will be indented by Mustache.
|
||||
- `indented_12` - Prepends 12 spaces indention from second line of a fragment on. First line will be indented by Mustache.
|
||||
- `indented_16` -Prepends 16 spaces indention from second line of a fragment on. First line will be indented by Mustache.
|
||||
|
||||
Lambda is invoked by `lambda.[lambda name]` expression. For example: `{{#lambda.lowercase}}FRAGMENT TO LOWERCASE{{/lambda.lowercase}}` to lower case text between `lambda.lowercase`.
|
||||
|
||||
## Extensions
|
||||
|
||||
OpenAPI supports a concept called "Extensions". These are called "Specification Extensions" [in 3.x](https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.2.md#specificationExtensions) and "Vendor Extensions" [in 2.0](https://github.com/OAI/OpenAPI-Specification/blob/master/versions/2.0.md#vendorExtensions).
|
||||
@@ -861,7 +876,7 @@ paths:
|
||||
|
||||
#### x-mysqlSchema
|
||||
|
||||
MySQL schema generator creates vendor extensions based on openapi `dataType` and `dataFormat`. When user defined extensions with same key already exists codegen accepts those as is. It means it won't validate properties or correct it for you. Every model in `definitions` can contain table related and column related extensions like in example below:
|
||||
MySQL schema generator creates vendor extensions based on openapi `dataType` and `dataFormat`. When user defined extensions with same key already exists codegen accepts those as is. It means it won't validate properties or correct it for you. Every model in `definitions` can contain table related and column related extensions like in example below:
|
||||
|
||||
```yaml
|
||||
definitions:
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
<groupId>org.openapitools</groupId>
|
||||
<artifactId>openapi-generator-project</artifactId>
|
||||
<!-- RELEASE_VERSION -->
|
||||
<version>4.1.0-SNAPSHOT</version>
|
||||
<version>4.1.0</version>
|
||||
<!-- /RELEASE_VERSION -->
|
||||
<relativePath>../..</relativePath>
|
||||
</parent>
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
<artifactId>openapi-generator-project</artifactId>
|
||||
<groupId>org.openapitools</groupId>
|
||||
<!-- RELEASE_VERSION -->
|
||||
<version>4.1.0-SNAPSHOT</version>
|
||||
<version>4.1.0</version>
|
||||
<!-- /RELEASE_VERSION -->
|
||||
<relativePath>../..</relativePath>
|
||||
</parent>
|
||||
|
||||
@@ -45,7 +45,7 @@ compileJava.dependsOn tasks.openApiGenerate
|
||||
[source,group]
|
||||
----
|
||||
plugins {
|
||||
id "org.openapi.generator" version "4.0.3"
|
||||
id "org.openapi.generator" version "4.1.0"
|
||||
}
|
||||
----
|
||||
|
||||
@@ -61,7 +61,7 @@ buildscript {
|
||||
// url "https://plugins.gradle.org/m2/"
|
||||
}
|
||||
dependencies {
|
||||
classpath "org.openapitools:openapi-generator-gradle-plugin:4.0.3"
|
||||
classpath "org.openapitools:openapi-generator-gradle-plugin:4.1.0"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -609,7 +609,7 @@ buildscript {
|
||||
}
|
||||
dependencies {
|
||||
classpath 'com.android.tools.build:gradle:3.2.1'
|
||||
classpath('org.openapitools:openapi-generator-gradle-plugin:4.0.3') {
|
||||
classpath('org.openapitools:openapi-generator-gradle-plugin:4.1.0') {
|
||||
exclude group: 'com.google.guava'
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
# RELEASE_VERSION
|
||||
openApiGeneratorVersion=4.1.0-SNAPSHOT
|
||||
openApiGeneratorVersion=4.1.0
|
||||
# /RELEASE_VERSION
|
||||
|
||||
# BEGIN placeholders
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
<groupId>org.openapitools</groupId>
|
||||
<artifactId>openapi-generator-project</artifactId>
|
||||
<!-- RELEASE_VERSION -->
|
||||
<version>4.1.0-SNAPSHOT</version>
|
||||
<version>4.1.0</version>
|
||||
<!-- /RELEASE_VERSION -->
|
||||
<relativePath>../..</relativePath>
|
||||
</parent>
|
||||
|
||||
@@ -17,5 +17,5 @@ gradle generateGoWithInvalidSpec
|
||||
The samples can be tested against other versions of the plugin using the `openApiGeneratorVersion` property. For example:
|
||||
|
||||
```bash
|
||||
gradle -PopenApiGeneratorVersion=4.0.3 openApiValidate
|
||||
gradle -PopenApiGeneratorVersion=4.1.0 openApiValidate
|
||||
```
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
# RELEASE_VERSION
|
||||
openApiGeneratorVersion=4.0.3
|
||||
openApiGeneratorVersion=4.1.0
|
||||
# /RELEASE_VERSION
|
||||
|
||||
@@ -12,7 +12,7 @@ Add to your `build->plugins` section (default phase is `generate-sources` phase)
|
||||
<groupId>org.openapitools</groupId>
|
||||
<artifactId>openapi-generator-maven-plugin</artifactId>
|
||||
<!-- RELEASE_VERSION -->
|
||||
<version>4.0.3</version>
|
||||
<version>4.1.0</version>
|
||||
<!-- /RELEASE_VERSION -->
|
||||
<executions>
|
||||
<execution>
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
<groupId>org.openapitools</groupId>
|
||||
<artifactId>openapi-generator-maven-plugin</artifactId>
|
||||
<!-- RELEASE_VERSION -->
|
||||
<version>4.0.3</version>
|
||||
<version>4.1.0</version>
|
||||
<!-- /RELEASE_VERSION -->
|
||||
<executions>
|
||||
<execution>
|
||||
@@ -88,6 +88,13 @@
|
||||
<version>${jersey-version}</version>
|
||||
</dependency>
|
||||
|
||||
<!-- @Nullable annotation -->
|
||||
<dependency>
|
||||
<groupId>com.google.code.findbugs</groupId>
|
||||
<artifactId>jsr305</artifactId>
|
||||
<version>3.0.2</version>
|
||||
</dependency>
|
||||
|
||||
<!-- JSON processing: jackson -->
|
||||
<dependency>
|
||||
<groupId>com.fasterxml.jackson.jaxrs</groupId>
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
<groupId>org.openapitools</groupId>
|
||||
<artifactId>openapi-generator-maven-plugin</artifactId>
|
||||
<!-- RELEASE_VERSION -->
|
||||
<version>4.0.3</version>
|
||||
<version>4.1.0</version>
|
||||
<!-- /RELEASE_VERSION -->
|
||||
<dependencies>
|
||||
<dependency>
|
||||
@@ -101,6 +101,13 @@
|
||||
<version>${jersey-version}</version>
|
||||
</dependency>
|
||||
|
||||
<!-- @Nullable annotation -->
|
||||
<dependency>
|
||||
<groupId>com.google.code.findbugs</groupId>
|
||||
<artifactId>jsr305</artifactId>
|
||||
<version>3.0.2</version>
|
||||
</dependency>
|
||||
|
||||
<!-- JSON processing: jackson -->
|
||||
<dependency>
|
||||
<groupId>com.fasterxml.jackson.jaxrs</groupId>
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
<groupId>org.openapitools</groupId>
|
||||
<artifactId>openapi-generator-maven-plugin</artifactId>
|
||||
<!-- RELEASE_VERSION -->
|
||||
<version>4.0.3</version>
|
||||
<version>4.1.0</version>
|
||||
<!-- /RELEASE_VERSION -->
|
||||
<executions>
|
||||
<execution>
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
<groupId>org.openapitools</groupId>
|
||||
<artifactId>openapi-generator-maven-plugin</artifactId>
|
||||
<!-- RELEASE_VERSION -->
|
||||
<version>4.0.3</version>
|
||||
<version>4.1.0</version>
|
||||
<!-- /RELEASE_VERSION -->
|
||||
<executions>
|
||||
<execution>
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
<groupId>org.openapitools</groupId>
|
||||
<artifactId>openapi-generator-project</artifactId>
|
||||
<!-- RELEASE_VERSION -->
|
||||
<version>4.1.0-SNAPSHOT</version>
|
||||
<version>4.1.0</version>
|
||||
<!-- /RELEASE_VERSION -->
|
||||
<relativePath>../..</relativePath>
|
||||
</parent>
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
<groupId>org.openapitools</groupId>
|
||||
<artifactId>openapi-generator-project</artifactId>
|
||||
<!-- RELEASE_VERSION -->
|
||||
<version>4.1.0-SNAPSHOT</version>
|
||||
<version>4.1.0</version>
|
||||
<!-- /RELEASE_VERSION -->
|
||||
<relativePath>../..</relativePath>
|
||||
</parent>
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
<groupId>org.openapitools</groupId>
|
||||
<artifactId>openapi-generator-project</artifactId>
|
||||
<!-- RELEASE_VERSION -->
|
||||
<version>4.1.0-SNAPSHOT</version>
|
||||
<version>4.1.0</version>
|
||||
<!-- /RELEASE_VERSION -->
|
||||
<relativePath>../..</relativePath>
|
||||
</parent>
|
||||
|
||||
@@ -203,10 +203,10 @@ public class CodegenConstants {
|
||||
public static final String ENUM_PROPERTY_NAMING_DESC = "Naming convention for enum properties: 'camelCase', 'PascalCase', 'snake_case', 'UPPERCASE', and 'original'";
|
||||
|
||||
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. Default is the empty string.";
|
||||
public static final String MODEL_NAME_PREFIX_DESC = "Prefix that will be prepended to all model names.";
|
||||
|
||||
public static final String MODEL_NAME_SUFFIX = "modelNameSuffix";
|
||||
public static final String MODEL_NAME_SUFFIX_DESC = "Suffix that will be appended to all model names. Default is the empty string.";
|
||||
public static final String MODEL_NAME_SUFFIX_DESC = "Suffix that will be appended to all model names.";
|
||||
|
||||
public static final String GIT_USER_ID = "gitUserId";
|
||||
public static final String GIT_USER_ID_DESC = "Git user ID, e.g. openapitools.";
|
||||
|
||||
@@ -46,7 +46,7 @@ public class CodegenModel {
|
||||
public String defaultValue;
|
||||
public String arrayModelType;
|
||||
public boolean isAlias; // Is this effectively an alias of another simple type
|
||||
public boolean isString, isInteger;
|
||||
public boolean isString, isInteger, isLong, isNumber, isNumeric, isFloat, isDouble;
|
||||
public List<CodegenProperty> vars = new ArrayList<CodegenProperty>(); // all properties (without parent's properties)
|
||||
public List<CodegenProperty> allVars = new ArrayList<CodegenProperty>(); // all properties (with parent's properties)
|
||||
public List<CodegenProperty> requiredVars = new ArrayList<CodegenProperty>(); // a list of required properties
|
||||
@@ -61,7 +61,7 @@ public class CodegenModel {
|
||||
public Set<String> allMandatory = new TreeSet<String>(); // with parent's required properties
|
||||
|
||||
public Set<String> imports = new TreeSet<String>();
|
||||
public boolean hasVars, emptyVars, hasMoreModels, hasEnums, isEnum, hasRequired, hasOptional, isArrayModel, hasChildren, isMapModel;
|
||||
public boolean hasVars, emptyVars, hasMoreModels, hasEnums, isEnum, isNullable, hasRequired, hasOptional, isArrayModel, hasChildren, isMapModel;
|
||||
public boolean hasOnlyReadOnly = true; // true if all properties are read-only
|
||||
public ExternalDocumentation externalDocumentation;
|
||||
|
||||
@@ -96,7 +96,12 @@ public class CodegenModel {
|
||||
.append("arrayModelType", arrayModelType)
|
||||
.append("isAlias", isAlias)
|
||||
.append("isString", isString)
|
||||
.append("isNumeric", isNumeric)
|
||||
.append("isInteger", isInteger)
|
||||
.append("isLong", isLong)
|
||||
.append("isNumber", isNumber)
|
||||
.append("isFloat", isFloat)
|
||||
.append("isDouble", isDouble)
|
||||
.append("vars", vars)
|
||||
.append("requiredVars", requiredVars)
|
||||
.append("optionalVars", optionalVars)
|
||||
@@ -113,6 +118,7 @@ public class CodegenModel {
|
||||
.append("hasMoreModels", hasMoreModels)
|
||||
.append("hasEnums", hasEnums)
|
||||
.append("isEnum", isEnum)
|
||||
.append("isNullable", isEnum)
|
||||
.append("hasRequired", hasRequired)
|
||||
.append("hasOptional", hasOptional)
|
||||
.append("isArrayModel", isArrayModel)
|
||||
@@ -133,86 +139,86 @@ public class CodegenModel {
|
||||
CodegenModel that = (CodegenModel) o;
|
||||
|
||||
return Objects.equals(parent, that.parent) &&
|
||||
Objects.equals(parentSchema, that.parentSchema) &&
|
||||
Objects.equals(interfaces, that.interfaces) &&
|
||||
Objects.equals(allParents, that.allParents) &&
|
||||
Objects.equals(parentModel, that.parentModel) &&
|
||||
Objects.equals(interfaceModels, that.interfaceModels) &&
|
||||
Objects.equals(name, that.name) &&
|
||||
Objects.equals(classname, that.classname) &&
|
||||
Objects.equals(title, that.title) &&
|
||||
Objects.equals(description, that.description) &&
|
||||
Objects.equals(classVarName, that.classVarName) &&
|
||||
Objects.equals(modelJson, that.modelJson) &&
|
||||
Objects.equals(dataType, that.dataType) &&
|
||||
Objects.equals(xmlPrefix, that.xmlPrefix) &&
|
||||
Objects.equals(xmlNamespace, that.xmlNamespace) &&
|
||||
Objects.equals(xmlName, that.xmlName) &&
|
||||
Objects.equals(classFilename, that.classFilename) &&
|
||||
Objects.equals(unescapedDescription, that.unescapedDescription) &&
|
||||
Objects.equals(discriminator, that.discriminator) &&
|
||||
Objects.equals(defaultValue, that.defaultValue) &&
|
||||
Objects.equals(vars, that.vars) &&
|
||||
Objects.equals(requiredVars, that.requiredVars) &&
|
||||
Objects.equals(optionalVars, that.optionalVars) &&
|
||||
Objects.equals(allVars, that.allVars) &&
|
||||
Objects.equals(allowableValues, that.allowableValues) &&
|
||||
Objects.equals(mandatory, that.mandatory) &&
|
||||
Objects.equals(allMandatory, that.allMandatory) &&
|
||||
Objects.equals(imports, that.imports) &&
|
||||
Objects.equals(hasVars, that.hasVars) &&
|
||||
Objects.equals(emptyVars, that.emptyVars) &&
|
||||
Objects.equals(hasMoreModels, that.hasMoreModels) &&
|
||||
Objects.equals(hasEnums, that.hasEnums) &&
|
||||
Objects.equals(isEnum, that.isEnum) &&
|
||||
Objects.equals(externalDocumentation, that.externalDocumentation) &&
|
||||
Objects.equals(hasOnlyReadOnly, that.hasOnlyReadOnly) &&
|
||||
Objects.equals(hasChildren, that.hasChildren) &&
|
||||
Objects.equals(parentVars, that.parentVars) &&
|
||||
Objects.equals(vendorExtensions, that.vendorExtensions);
|
||||
Objects.equals(parentSchema, that.parentSchema) &&
|
||||
Objects.equals(interfaces, that.interfaces) &&
|
||||
Objects.equals(allParents, that.allParents) &&
|
||||
Objects.equals(parentModel, that.parentModel) &&
|
||||
Objects.equals(interfaceModels, that.interfaceModels) &&
|
||||
Objects.equals(name, that.name) &&
|
||||
Objects.equals(classname, that.classname) &&
|
||||
Objects.equals(title, that.title) &&
|
||||
Objects.equals(description, that.description) &&
|
||||
Objects.equals(classVarName, that.classVarName) &&
|
||||
Objects.equals(modelJson, that.modelJson) &&
|
||||
Objects.equals(dataType, that.dataType) &&
|
||||
Objects.equals(xmlPrefix, that.xmlPrefix) &&
|
||||
Objects.equals(xmlNamespace, that.xmlNamespace) &&
|
||||
Objects.equals(xmlName, that.xmlName) &&
|
||||
Objects.equals(classFilename, that.classFilename) &&
|
||||
Objects.equals(unescapedDescription, that.unescapedDescription) &&
|
||||
Objects.equals(discriminator, that.discriminator) &&
|
||||
Objects.equals(defaultValue, that.defaultValue) &&
|
||||
Objects.equals(vars, that.vars) &&
|
||||
Objects.equals(requiredVars, that.requiredVars) &&
|
||||
Objects.equals(optionalVars, that.optionalVars) &&
|
||||
Objects.equals(allVars, that.allVars) &&
|
||||
Objects.equals(allowableValues, that.allowableValues) &&
|
||||
Objects.equals(mandatory, that.mandatory) &&
|
||||
Objects.equals(allMandatory, that.allMandatory) &&
|
||||
Objects.equals(imports, that.imports) &&
|
||||
Objects.equals(hasVars, that.hasVars) &&
|
||||
Objects.equals(emptyVars, that.emptyVars) &&
|
||||
Objects.equals(hasMoreModels, that.hasMoreModels) &&
|
||||
Objects.equals(hasEnums, that.hasEnums) &&
|
||||
Objects.equals(isEnum, that.isEnum) &&
|
||||
Objects.equals(externalDocumentation, that.externalDocumentation) &&
|
||||
Objects.equals(hasOnlyReadOnly, that.hasOnlyReadOnly) &&
|
||||
Objects.equals(hasChildren, that.hasChildren) &&
|
||||
Objects.equals(parentVars, that.parentVars) &&
|
||||
Objects.equals(vendorExtensions, that.vendorExtensions);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(
|
||||
parent,
|
||||
parentSchema,
|
||||
interfaces,
|
||||
allParents,
|
||||
parentModel,
|
||||
interfaceModels,
|
||||
name,
|
||||
classname,
|
||||
title,
|
||||
description,
|
||||
classVarName,
|
||||
modelJson,
|
||||
dataType,
|
||||
xmlPrefix,
|
||||
xmlNamespace,
|
||||
xmlName,
|
||||
classFilename,
|
||||
unescapedDescription,
|
||||
discriminator,
|
||||
defaultValue,
|
||||
vars,
|
||||
requiredVars,
|
||||
optionalVars,
|
||||
allVars,
|
||||
allowableValues,
|
||||
mandatory,
|
||||
allMandatory,
|
||||
imports,
|
||||
hasVars,
|
||||
emptyVars,
|
||||
hasMoreModels,
|
||||
hasEnums,
|
||||
isEnum,
|
||||
externalDocumentation,
|
||||
vendorExtensions,
|
||||
hasOnlyReadOnly,
|
||||
hasChildren,
|
||||
parentVars);
|
||||
parent,
|
||||
parentSchema,
|
||||
interfaces,
|
||||
allParents,
|
||||
parentModel,
|
||||
interfaceModels,
|
||||
name,
|
||||
classname,
|
||||
title,
|
||||
description,
|
||||
classVarName,
|
||||
modelJson,
|
||||
dataType,
|
||||
xmlPrefix,
|
||||
xmlNamespace,
|
||||
xmlName,
|
||||
classFilename,
|
||||
unescapedDescription,
|
||||
discriminator,
|
||||
defaultValue,
|
||||
vars,
|
||||
requiredVars,
|
||||
optionalVars,
|
||||
allVars,
|
||||
allowableValues,
|
||||
mandatory,
|
||||
allMandatory,
|
||||
imports,
|
||||
hasVars,
|
||||
emptyVars,
|
||||
hasMoreModels,
|
||||
hasEnums,
|
||||
isEnum,
|
||||
externalDocumentation,
|
||||
vendorExtensions,
|
||||
hasOnlyReadOnly,
|
||||
hasChildren,
|
||||
parentVars);
|
||||
}
|
||||
|
||||
public String getParent() {
|
||||
|
||||
@@ -19,7 +19,11 @@ package org.openapitools.codegen;
|
||||
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
import com.google.common.base.CaseFormat;
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import com.samskivert.mustache.Mustache;
|
||||
import com.samskivert.mustache.Mustache.Compiler;
|
||||
import com.samskivert.mustache.Mustache.Lambda;
|
||||
|
||||
import io.swagger.v3.core.util.Json;
|
||||
import io.swagger.v3.oas.models.OpenAPI;
|
||||
import io.swagger.v3.oas.models.Operation;
|
||||
@@ -48,6 +52,11 @@ import org.openapitools.codegen.meta.GeneratorMetadata;
|
||||
import org.openapitools.codegen.meta.Stability;
|
||||
import org.openapitools.codegen.serializer.SerializerUtils;
|
||||
import org.openapitools.codegen.templating.MustacheEngineAdapter;
|
||||
import org.openapitools.codegen.templating.mustache.CamelCaseLambda;
|
||||
import org.openapitools.codegen.templating.mustache.IndentedLambda;
|
||||
import org.openapitools.codegen.templating.mustache.LowercaseLambda;
|
||||
import org.openapitools.codegen.templating.mustache.TitlecaseLambda;
|
||||
import org.openapitools.codegen.templating.mustache.UppercaseLambda;
|
||||
import org.openapitools.codegen.utils.ModelUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
@@ -199,6 +208,47 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
}
|
||||
}
|
||||
|
||||
/***
|
||||
* Preset map builder with commonly used Mustache lambdas.
|
||||
*
|
||||
* To extend the map, override addMustacheLambdas(), call parent method
|
||||
* first and then add additional lambdas to the returned builder.
|
||||
*
|
||||
* If common lambdas are not desired, override addMustacheLambdas() method
|
||||
* and return empty builder.
|
||||
*
|
||||
* @return preinitialized map builder with common lambdas
|
||||
*/
|
||||
protected ImmutableMap.Builder<String, Lambda> addMustacheLambdas() {
|
||||
|
||||
return new ImmutableMap.Builder<String, Mustache.Lambda>()
|
||||
.put("lowercase", new LowercaseLambda().generator(this))
|
||||
.put("uppercase", new UppercaseLambda())
|
||||
.put("titlecase", new TitlecaseLambda())
|
||||
.put("camelcase", new CamelCaseLambda().generator(this))
|
||||
.put("indented", new IndentedLambda())
|
||||
.put("indented_8", new IndentedLambda(8, " "))
|
||||
.put("indented_12", new IndentedLambda(12, " "))
|
||||
.put("indented_16", new IndentedLambda(16, " "));
|
||||
}
|
||||
|
||||
private void registerMustacheLambdas() {
|
||||
ImmutableMap<String, Lambda> lambdas = addMustacheLambdas().build();
|
||||
|
||||
if (lambdas.size() == 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (additionalProperties.containsKey("lambda")) {
|
||||
LOGGER.warn("A property named 'lambda' already exists. Mustache lambdas renamed from 'lambda' to '_lambda'. " +
|
||||
"You'll likely need to use a custom template, " +
|
||||
"see https://github.com/OpenAPITools/openapi-generator/blob/master/docs/templating.md. ");
|
||||
additionalProperties.put("_lambda", lambdas);
|
||||
} else {
|
||||
additionalProperties.put("lambda", lambdas);
|
||||
}
|
||||
}
|
||||
|
||||
// override with any special post-processing for all models
|
||||
@SuppressWarnings({"static-method", "unchecked"})
|
||||
public Map<String, Object> postProcessAllModels(Map<String, Object> objs) {
|
||||
@@ -1060,6 +1110,9 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
|
||||
// initialize special character mapping
|
||||
initalizeSpecialCharacterMapping();
|
||||
|
||||
// Register common Mustache lambdas.
|
||||
registerMustacheLambdas();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1519,11 +1572,11 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
} else if (ModelUtils.isURISchema(schema)) {
|
||||
return "URI";
|
||||
} else if (ModelUtils.isStringSchema(schema)) {
|
||||
if(typeMapping.containsKey(schema.getFormat())) {
|
||||
if (typeMapping.containsKey(schema.getFormat())) {
|
||||
// If the format matches a typeMapping (supplied with the --typeMappings flag)
|
||||
// then treat the format as a primitive type.
|
||||
// This allows the typeMapping flag to add a new custom type which can then
|
||||
// be used in the format field.
|
||||
// be used in the format field.
|
||||
return schema.getFormat();
|
||||
}
|
||||
return "string";
|
||||
@@ -1817,6 +1870,9 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
}
|
||||
}
|
||||
|
||||
if(composed.getRequired() != null) {
|
||||
required.addAll(composed.getRequired());
|
||||
}
|
||||
addVars(m, unaliasPropertySchema(properties), required, unaliasPropertySchema(allProperties), allRequired);
|
||||
|
||||
// end of code block for composed schema
|
||||
@@ -1831,14 +1887,28 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
if (ModelUtils.isMapSchema(schema)) {
|
||||
addAdditionPropertiesToCodeGenModel(m, schema);
|
||||
m.isMapModel = true;
|
||||
}
|
||||
if (ModelUtils.isIntegerSchema(schema)) { // integer type
|
||||
if (!ModelUtils.isLongSchema(schema)) { // long type is not integer
|
||||
} else if (ModelUtils.isIntegerSchema(schema)) { // integer type
|
||||
m.isNumeric = Boolean.TRUE;
|
||||
if (ModelUtils.isLongSchema(schema)) { // int64/long format
|
||||
m.isLong = Boolean.TRUE;
|
||||
} else { // int32 format
|
||||
m.isInteger = Boolean.TRUE;
|
||||
}
|
||||
}
|
||||
if (ModelUtils.isStringSchema(schema)) {
|
||||
} else if (ModelUtils.isStringSchema(schema)) {
|
||||
m.isString = Boolean.TRUE;
|
||||
} else if (ModelUtils.isNumberSchema(schema)) {
|
||||
m.isNumeric = Boolean.TRUE;
|
||||
if (ModelUtils.isFloatSchema(schema)) { // float
|
||||
m.isFloat = Boolean.TRUE;
|
||||
} else if (ModelUtils.isDoubleSchema(schema)) { // double
|
||||
m.isDouble = Boolean.TRUE;
|
||||
} else { // type is number and without format
|
||||
m.isNumber = Boolean.TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
if (Boolean.TRUE.equals(schema.getNullable())) {
|
||||
m.isNullable = Boolean.TRUE;
|
||||
}
|
||||
|
||||
// passing null to allProperties and allRequired as there's no parent
|
||||
@@ -1908,6 +1978,10 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
addProperties(properties, required, component);
|
||||
}
|
||||
|
||||
if(schema.getRequired() != null) {
|
||||
required.addAll(schema.getRequired());
|
||||
}
|
||||
|
||||
if (composedSchema.getOneOf() != null) {
|
||||
throw new RuntimeException("Please report the issue: Cannot process oneOf (Composed Scheme) in addProperties: " + schema);
|
||||
}
|
||||
@@ -2006,7 +2080,7 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
String type = getSchemaType(p);
|
||||
if (ModelUtils.isIntegerSchema(p)) { // integer type
|
||||
property.isNumeric = Boolean.TRUE;
|
||||
if (SchemaTypeUtil.INTEGER64_FORMAT.equals(p.getFormat())) { // int64/long format
|
||||
if (ModelUtils.isLongSchema(p)) { // int64/long format
|
||||
property.isLong = Boolean.TRUE;
|
||||
} else { // int32 format
|
||||
property.isInteger = Boolean.TRUE;
|
||||
@@ -2584,7 +2658,7 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
if (requestBody != null) {
|
||||
if (getContentType(requestBody) != null &&
|
||||
(getContentType(requestBody).toLowerCase(Locale.ROOT).startsWith("application/x-www-form-urlencoded") ||
|
||||
getContentType(requestBody).toLowerCase(Locale.ROOT).startsWith("multipart/form-data"))) {
|
||||
getContentType(requestBody).toLowerCase(Locale.ROOT).startsWith("multipart/form-data"))) {
|
||||
// process form parameters
|
||||
formParams = fromRequestBodyToFormParameters(requestBody, imports);
|
||||
for (CodegenParameter cp : formParams) {
|
||||
@@ -2952,7 +3026,7 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
}
|
||||
|
||||
Schema s;
|
||||
if(parameter.getSchema() != null) {
|
||||
if (parameter.getSchema() != null) {
|
||||
s = parameter.getSchema();
|
||||
} else if (parameter.getContent() != null) {
|
||||
Content content = parameter.getContent();
|
||||
@@ -3950,6 +4024,19 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
* @return sanitized string
|
||||
*/
|
||||
public String sanitizeName(String name, String removeCharRegEx) {
|
||||
return sanitizeName(name, removeCharRegEx, new ArrayList<String>());
|
||||
}
|
||||
|
||||
/**
|
||||
* Sanitize name (parameter, property, method, etc)
|
||||
*
|
||||
* @param name string to be sanitize
|
||||
* @param removeCharRegEx a regex containing all char that will be removed
|
||||
* @param exceptionList a list of matches which should not be sanitized (i.e expections)
|
||||
* @return sanitized string
|
||||
*/
|
||||
@SuppressWarnings("static-method")
|
||||
public String sanitizeName(String name, String removeCharRegEx, ArrayList<String> exceptionList) {
|
||||
// NOTE: performance wise, we should have written with 2 replaceAll to replace desired
|
||||
// character with _ or empty character. Below aims to spell out different cases we've
|
||||
// encountered so far and hopefully make it easier for others to add more special
|
||||
@@ -3967,27 +4054,27 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
}
|
||||
|
||||
// input[] => input
|
||||
name = name.replaceAll("\\[\\]", ""); // FIXME: a parameter should not be assigned. Also declare the methods parameters as 'final'.
|
||||
name = this.sanitizeValue(name, "\\[\\]", "", exceptionList);
|
||||
|
||||
// input[a][b] => input_a_b
|
||||
name = name.replaceAll("\\[", "_");
|
||||
name = name.replaceAll("\\]", "");
|
||||
name = this.sanitizeValue(name, "\\[", "_", exceptionList);
|
||||
name = this.sanitizeValue(name, "\\]", "", exceptionList);
|
||||
|
||||
// input(a)(b) => input_a_b
|
||||
name = name.replaceAll("\\(", "_");
|
||||
name = name.replaceAll("\\)", "");
|
||||
name = this.sanitizeValue(name, "\\(", "_", exceptionList);
|
||||
name = this.sanitizeValue(name, "\\)", "", exceptionList);
|
||||
|
||||
// input.name => input_name
|
||||
name = name.replaceAll("\\.", "_");
|
||||
name = this.sanitizeValue(name, "\\.", "_", exceptionList);
|
||||
|
||||
// input-name => input_name
|
||||
name = name.replaceAll("-", "_");
|
||||
name = this.sanitizeValue(name, "-", "_", exceptionList);
|
||||
|
||||
// a|b => a_b
|
||||
name = name.replace("|", "_");
|
||||
name = this.sanitizeValue(name, "\\|", "_", exceptionList);
|
||||
|
||||
// input name and age => input_name_and_age
|
||||
name = name.replaceAll(" ", "_");
|
||||
name = this.sanitizeValue(name, " ", "_", exceptionList);
|
||||
|
||||
// /api/films/get => _api_films_get
|
||||
// \api\films\get => _api_films_get
|
||||
@@ -4005,6 +4092,13 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
return name;
|
||||
}
|
||||
|
||||
private String sanitizeValue(String value, String replaceMatch, String replaceValue, ArrayList<String> exceptionList) {
|
||||
if (exceptionList.size() == 0 || !exceptionList.contains(replaceMatch)) {
|
||||
return value.replaceAll(replaceMatch, replaceValue);
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sanitize tag
|
||||
*
|
||||
@@ -4841,6 +4935,15 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
codegenParameter.dataType = codegenProperty.dataType;
|
||||
codegenParameter.description = codegenProperty.description;
|
||||
codegenParameter.paramName = toParamName(codegenParameter.baseName);
|
||||
codegenParameter.minimum = codegenProperty.minimum;
|
||||
codegenParameter.maximum = codegenProperty.maximum;
|
||||
codegenParameter.exclusiveMinimum = codegenProperty.exclusiveMinimum;
|
||||
codegenParameter.exclusiveMaximum = codegenProperty.exclusiveMaximum;
|
||||
codegenParameter.minLength = codegenProperty.minLength;
|
||||
codegenParameter.maxLength = codegenProperty.maxLength;
|
||||
codegenParameter.pattern = codegenProperty.pattern;
|
||||
|
||||
|
||||
|
||||
if (codegenProperty.complexType != null) {
|
||||
imports.add(codegenProperty.complexType);
|
||||
@@ -4876,7 +4979,7 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
}
|
||||
|
||||
protected void removeOption(String key) {
|
||||
for(int i = 0; i < cliOptions.size(); i++) {
|
||||
for (int i = 0; i < cliOptions.size(); i++) {
|
||||
if (key.equals(cliOptions.get(i).getOpt())) {
|
||||
cliOptions.remove(i);
|
||||
break;
|
||||
|
||||
@@ -407,9 +407,19 @@ public class InlineModelResolver {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Generates a unique model name. Non-alphanumeric characters will be replaced
|
||||
* with underscores
|
||||
*
|
||||
* @param title String title field in the schema if present
|
||||
* @param key String model name
|
||||
*/
|
||||
private String resolveModelName(String title, String key) {
|
||||
if (title == null) {
|
||||
return uniqueName(key);
|
||||
// for auto-generated schema name, replace non-alphanumeric characters with underscore
|
||||
// to avoid bugs with schema look up with inline schema created on the fly
|
||||
// e.g. io.schema.User_name => io_schema_User_name
|
||||
return uniqueName(key).replaceAll("[^A-Za-z0-9]", "_");
|
||||
} else {
|
||||
return uniqueName(title);
|
||||
}
|
||||
@@ -589,4 +599,4 @@ public class InlineModelResolver {
|
||||
target.addExtension(extName, vendorExtensions.get(extName));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -223,6 +223,7 @@ public class CodegenConfigurator {
|
||||
}
|
||||
|
||||
public CodegenConfigurator setImportMappings(Map<String, String> importMappings) {
|
||||
this.importMappings = importMappings;
|
||||
generatorSettingsBuilder.withImportMappings(importMappings);
|
||||
return this;
|
||||
}
|
||||
@@ -234,6 +235,7 @@ public class CodegenConfigurator {
|
||||
}
|
||||
|
||||
public CodegenConfigurator setInstantiationTypes(Map<String, String> instantiationTypes) {
|
||||
this.instantiationTypes = instantiationTypes;
|
||||
generatorSettingsBuilder.withInstantiationTypes(instantiationTypes);
|
||||
return this;
|
||||
}
|
||||
@@ -295,6 +297,7 @@ public class CodegenConfigurator {
|
||||
}
|
||||
|
||||
public CodegenConfigurator setReservedWordsMappings(Map<String, String> reservedWordMappings) {
|
||||
this.reservedWordMappings = reservedWordMappings;
|
||||
generatorSettingsBuilder.withReservedWordMappings(reservedWordMappings);
|
||||
return this;
|
||||
}
|
||||
@@ -310,6 +313,7 @@ public class CodegenConfigurator {
|
||||
}
|
||||
|
||||
public CodegenConfigurator setSystemProperties(Map<String, String> systemProperties) {
|
||||
this.systemProperties = systemProperties;
|
||||
workflowSettingsBuilder.withSystemProperties(systemProperties);
|
||||
return this;
|
||||
}
|
||||
@@ -326,6 +330,7 @@ public class CodegenConfigurator {
|
||||
}
|
||||
|
||||
public CodegenConfigurator setTypeMappings(Map<String, String> typeMappings) {
|
||||
this.typeMappings = typeMappings;
|
||||
generatorSettingsBuilder.withTypeMappings(typeMappings);
|
||||
return this;
|
||||
}
|
||||
@@ -454,6 +459,12 @@ public class CodegenConfigurator {
|
||||
config.reservedWordsMappings().putAll(generatorSettings.getReservedWordMappings());
|
||||
config.additionalProperties().putAll(generatorSettings.getAdditionalProperties());
|
||||
|
||||
// any other additional properties?
|
||||
String templateDir = workflowSettings.getTemplateDir();
|
||||
if (templateDir != null) {
|
||||
config.additionalProperties().put(CodegenConstants.TEMPLATE_DIR, workflowSettings.getTemplateDir());
|
||||
}
|
||||
|
||||
ClientOptInput input = new ClientOptInput()
|
||||
.config(config);
|
||||
|
||||
|
||||
@@ -17,8 +17,9 @@
|
||||
|
||||
package org.openapitools.codegen.languages;
|
||||
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import com.samskivert.mustache.Mustache;
|
||||
import com.google.common.collect.ImmutableMap.Builder;
|
||||
import com.samskivert.mustache.Mustache.Lambda;
|
||||
|
||||
import io.swagger.v3.core.util.Json;
|
||||
import io.swagger.v3.oas.models.media.ArraySchema;
|
||||
import io.swagger.v3.oas.models.media.Schema;
|
||||
@@ -152,13 +153,14 @@ public abstract class AbstractCSharpCodegen extends DefaultCodegen implements Co
|
||||
"DateTime?",
|
||||
"DateTime",
|
||||
"DateTimeOffset?",
|
||||
"DataTimeOffset",
|
||||
"DateTimeOffset",
|
||||
"Boolean",
|
||||
"Double",
|
||||
"Int32",
|
||||
"Int64",
|
||||
"Float",
|
||||
"Guid?",
|
||||
"Guid",
|
||||
"System.IO.Stream", // not really a primitive, we include it to avoid model import
|
||||
"Object")
|
||||
);
|
||||
@@ -191,7 +193,7 @@ public abstract class AbstractCSharpCodegen extends DefaultCodegen implements Co
|
||||
|
||||
// nullable type
|
||||
nullableType = new HashSet<String>(
|
||||
Arrays.asList("decimal", "bool", "int", "float", "long", "double", "DateTime", "Guid")
|
||||
Arrays.asList("decimal", "bool", "int", "float", "long", "double", "DateTime", "DateTimeOffset", "Guid")
|
||||
);
|
||||
// value Types
|
||||
valueTypes = new HashSet<String>(
|
||||
@@ -225,9 +227,9 @@ public abstract class AbstractCSharpCodegen extends DefaultCodegen implements Co
|
||||
public void useDateTimeOffset(boolean flag) {
|
||||
this.useDateTimeOffsetFlag = flag;
|
||||
if (flag) {
|
||||
typeMapping.put("DateTime", "DateTimeOffset?");
|
||||
typeMapping.put("DateTime", "DateTimeOffset");
|
||||
} else {
|
||||
typeMapping.put("DateTime", "DateTime?");
|
||||
typeMapping.put("DateTime", "DateTime");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -359,32 +361,12 @@ public abstract class AbstractCSharpCodegen extends DefaultCodegen implements Co
|
||||
|
||||
// This either updates additionalProperties with the above fixes, or sets the default if the option was not specified.
|
||||
additionalProperties.put(CodegenConstants.INTERFACE_PREFIX, interfacePrefix);
|
||||
|
||||
addMustacheLambdas(additionalProperties);
|
||||
}
|
||||
|
||||
private void addMustacheLambdas(Map<String, Object> objs) {
|
||||
|
||||
Map<String, Mustache.Lambda> lambdas = new ImmutableMap.Builder<String, Mustache.Lambda>()
|
||||
.put("lowercase", new LowercaseLambda().generator(this))
|
||||
.put("uppercase", new UppercaseLambda())
|
||||
.put("titlecase", new TitlecaseLambda())
|
||||
.put("camelcase", new CamelCaseLambda().generator(this))
|
||||
.put("camelcase_param", new CamelCaseLambda().generator(this).escapeAsParamName(true))
|
||||
.put("indented", new IndentedLambda())
|
||||
.put("indented_8", new IndentedLambda(8, " "))
|
||||
.put("indented_12", new IndentedLambda(12, " "))
|
||||
.put("indented_16", new IndentedLambda(16, " "))
|
||||
.build();
|
||||
|
||||
if (objs.containsKey("lambda")) {
|
||||
LOGGER.warn("A property named 'lambda' already exists. Mustache lambdas renamed from 'lambda' to '_lambda'. " +
|
||||
"You'll likely need to use a custom template, " +
|
||||
"see https://github.com/swagger-api/swagger-codegen#modifying-the-client-library-format. ");
|
||||
objs.put("_lambda", lambdas);
|
||||
} else {
|
||||
objs.put("lambda", lambdas);
|
||||
}
|
||||
@Override
|
||||
protected Builder<String, Lambda> addMustacheLambdas() {
|
||||
return super.addMustacheLambdas()
|
||||
.put("camelcase_param", new CamelCaseLambda().generator(this).escapeAsParamName(true));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -17,8 +17,8 @@
|
||||
|
||||
package org.openapitools.codegen.languages;
|
||||
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import com.samskivert.mustache.Mustache;
|
||||
import com.google.common.collect.ImmutableMap.Builder;
|
||||
import com.samskivert.mustache.Mustache.Lambda;
|
||||
|
||||
import io.swagger.v3.oas.models.OpenAPI;
|
||||
import io.swagger.v3.oas.models.media.Schema;
|
||||
@@ -35,7 +35,6 @@ 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);
|
||||
@@ -260,22 +259,12 @@ abstract public class AbstractCppCodegen extends DefaultCodegen implements Codeg
|
||||
LOGGER.info("Environment variable CPP_POST_PROCESS_FILE not defined so the C++ code may not be properly formatted. To define it, try 'export CPP_POST_PROCESS_FILE=\"/usr/local/bin/clang-format -i\"' (Linux/Mac)");
|
||||
LOGGER.info("NOTE: To enable file post-processing, 'enablePostProcessFile' must be set to `true` (--enable-post-process-file for CLI).");
|
||||
}
|
||||
|
||||
addMustacheLambdas(additionalProperties);
|
||||
}
|
||||
|
||||
private void addMustacheLambdas(Map<String, Object> objs) {
|
||||
|
||||
Map<String, Mustache.Lambda> lambdas = new ImmutableMap.Builder<String, Mustache.Lambda>()
|
||||
.put("multiline_comment_4", new IndentedLambda(4, " ", "///"))
|
||||
.build();
|
||||
|
||||
if (objs.containsKey("lambda")) {
|
||||
LOGGER.warn("A property named 'lambda' already exists. Mustache lambdas renamed from 'lambda' to '_lambda'.");
|
||||
objs.put("_lambda", lambdas);
|
||||
} else {
|
||||
objs.put("lambda", lambdas);
|
||||
}
|
||||
@Override
|
||||
protected Builder<String, Lambda> addMustacheLambdas() {
|
||||
return super.addMustacheLambdas()
|
||||
.put("multiline_comment_4", new IndentedLambda(4, " ", "///"));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -304,17 +293,17 @@ abstract public class AbstractCppCodegen extends DefaultCodegen implements Codeg
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void preprocessOpenAPI(OpenAPI openAPI) {
|
||||
URL url = URLPathUtils.getServerURL(openAPI);
|
||||
String port = URLPathUtils.getPort(url, "");
|
||||
String host = url.getHost();
|
||||
if(!port.isEmpty()) {
|
||||
this.additionalProperties.put("serverPort", port);
|
||||
this.additionalProperties.put("serverPort", port);
|
||||
}
|
||||
if(!host.isEmpty()) {
|
||||
this.additionalProperties.put("serverHost", host);
|
||||
}
|
||||
this.additionalProperties.put("serverHost", host);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,8 +16,9 @@
|
||||
|
||||
package org.openapitools.codegen.languages;
|
||||
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import com.samskivert.mustache.Mustache;
|
||||
import com.google.common.collect.ImmutableMap.Builder;
|
||||
import com.samskivert.mustache.Mustache.Lambda;
|
||||
|
||||
import io.swagger.v3.core.util.Json;
|
||||
import io.swagger.v3.oas.models.media.ArraySchema;
|
||||
import io.swagger.v3.oas.models.media.Schema;
|
||||
@@ -67,7 +68,7 @@ public abstract class AbstractFSharpCodegen extends DefaultCodegen implements Co
|
||||
protected Set<String> collectionTypes;
|
||||
protected Set<String> mapTypes;
|
||||
|
||||
// true if nullable types will be supported (as option)
|
||||
// true if nullable types will be supported (as option)
|
||||
protected boolean supportNullable = Boolean.TRUE;
|
||||
|
||||
protected Set<String> nullableType = new HashSet<String>();
|
||||
@@ -329,32 +330,12 @@ public abstract class AbstractFSharpCodegen extends DefaultCodegen implements Co
|
||||
|
||||
// This either updates additionalProperties with the above fixes, or sets the default if the option was not specified.
|
||||
additionalProperties.put(CodegenConstants.INTERFACE_PREFIX, interfacePrefix);
|
||||
|
||||
addMustacheLambdas(additionalProperties);
|
||||
}
|
||||
|
||||
private void addMustacheLambdas(Map<String, Object> objs) {
|
||||
|
||||
Map<String, Mustache.Lambda> lambdas = new ImmutableMap.Builder<String, Mustache.Lambda>()
|
||||
.put("lowercase", new LowercaseLambda().generator(this))
|
||||
.put("uppercase", new UppercaseLambda())
|
||||
.put("titlecase", new TitlecaseLambda())
|
||||
.put("camelcase", new CamelCaseLambda().generator(this))
|
||||
.put("camelcase_param", new CamelCaseLambda().generator(this).escapeAsParamName(true))
|
||||
.put("indented", new IndentedLambda())
|
||||
.put("indented_8", new IndentedLambda(8, " "))
|
||||
.put("indented_12", new IndentedLambda(12, " "))
|
||||
.put("indented_16", new IndentedLambda(16, " "))
|
||||
.build();
|
||||
|
||||
if (objs.containsKey("lambda")) {
|
||||
LOGGER.warn("A property named 'lambda' already exists. Mustache lambdas renamed from 'lambda' to '_lambda'. " +
|
||||
"You'll likely need to use a custom template, " +
|
||||
"see https://github.com/swagger-api/swagger-codegen#modifying-the-client-library-format. ");
|
||||
objs.put("_lambda", lambdas);
|
||||
} else {
|
||||
objs.put("lambda", lambdas);
|
||||
}
|
||||
@Override
|
||||
protected Builder<String, Lambda> addMustacheLambdas() {
|
||||
return super.addMustacheLambdas()
|
||||
.put("camelcase_param", new CamelCaseLambda().generator(this).escapeAsParamName(true));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -52,7 +52,6 @@ public abstract class AbstractJavaCodegen extends DefaultCodegen implements Code
|
||||
public static final String SUPPORT_JAVA6 = "supportJava6";
|
||||
public static final String DISABLE_HTML_ESCAPING = "disableHtmlEscaping";
|
||||
public static final String BOOLEAN_GETTER_PREFIX = "booleanGetterPrefix";
|
||||
public static final String USE_NULL_FOR_UNKNOWN_ENUM_VALUE = "useNullForUnknownEnumValue";
|
||||
|
||||
protected String dateLibrary = "threetenbp";
|
||||
protected boolean supportAsync = false;
|
||||
@@ -86,7 +85,6 @@ public abstract class AbstractJavaCodegen extends DefaultCodegen implements Code
|
||||
protected boolean supportJava6 = false;
|
||||
protected boolean disableHtmlEscaping = false;
|
||||
protected String booleanGetterPrefix = "get";
|
||||
protected boolean useNullForUnknownEnumValue = false;
|
||||
protected String parentGroupId = "";
|
||||
protected String parentArtifactId = "";
|
||||
protected String parentVersion = "";
|
||||
@@ -220,10 +218,6 @@ public abstract class AbstractJavaCodegen extends DefaultCodegen implements Code
|
||||
this.setBooleanGetterPrefix(additionalProperties.get(BOOLEAN_GETTER_PREFIX).toString());
|
||||
}
|
||||
additionalProperties.put(BOOLEAN_GETTER_PREFIX, booleanGetterPrefix);
|
||||
if (additionalProperties.containsKey(USE_NULL_FOR_UNKNOWN_ENUM_VALUE)) {
|
||||
this.setUseNullForUnknownEnumValue(Boolean.valueOf(additionalProperties.get(USE_NULL_FOR_UNKNOWN_ENUM_VALUE).toString()));
|
||||
}
|
||||
additionalProperties.put(USE_NULL_FOR_UNKNOWN_ENUM_VALUE, useNullForUnknownEnumValue);
|
||||
|
||||
if (additionalProperties.containsKey(CodegenConstants.INVOKER_PACKAGE)) {
|
||||
this.setInvokerPackage((String) additionalProperties.get(CodegenConstants.INVOKER_PACKAGE));
|
||||
@@ -417,6 +411,7 @@ public abstract class AbstractJavaCodegen extends DefaultCodegen implements Code
|
||||
// imports for pojos
|
||||
importMapping.put("ApiModelProperty", "io.swagger.annotations.ApiModelProperty");
|
||||
importMapping.put("ApiModel", "io.swagger.annotations.ApiModel");
|
||||
importMapping.put("BigDecimal", "java.math.BigDecimal");
|
||||
importMapping.put("JsonProperty", "com.fasterxml.jackson.annotation.JsonProperty");
|
||||
importMapping.put("JsonSubTypes", "com.fasterxml.jackson.annotation.JsonSubTypes");
|
||||
importMapping.put("JsonTypeInfo", "com.fasterxml.jackson.annotation.JsonTypeInfo");
|
||||
@@ -585,6 +580,11 @@ public abstract class AbstractJavaCodegen extends DefaultCodegen implements Code
|
||||
name = "_u";
|
||||
}
|
||||
|
||||
// numbers are not allowed at the beginning
|
||||
if (name.matches("^\\d.*")) {
|
||||
name = "_" + name;
|
||||
}
|
||||
|
||||
// if it's all uppper case, do nothing
|
||||
if (name.matches("^[A-Z0-9_]*$")) {
|
||||
return name;
|
||||
@@ -944,6 +944,9 @@ public abstract class AbstractJavaCodegen extends DefaultCodegen implements Code
|
||||
final CodegenModel parentCodegenModel = super.fromModel(codegenModel.parent, parentModel);
|
||||
codegenModel = AbstractJavaCodegen.reconcileInlineEnums(codegenModel, parentCodegenModel);
|
||||
}
|
||||
if ("BigDecimal".equals(codegenModel.dataType)) {
|
||||
codegenModel.imports.add("BigDecimal");
|
||||
}
|
||||
return codegenModel;
|
||||
}
|
||||
|
||||
@@ -1107,7 +1110,7 @@ public abstract class AbstractJavaCodegen extends DefaultCodegen implements Code
|
||||
|
||||
// number
|
||||
if ("Integer".equals(datatype) || "Long".equals(datatype) ||
|
||||
"Float".equals(datatype) || "Double".equals(datatype)) {
|
||||
"Float".equals(datatype) || "Double".equals(datatype) || "BigDecimal".equals(datatype)) {
|
||||
String varName = "NUMBER_" + value;
|
||||
varName = varName.replaceAll("-", "MINUS_");
|
||||
varName = varName.replaceAll("\\+", "PLUS_");
|
||||
@@ -1134,6 +1137,9 @@ public abstract class AbstractJavaCodegen extends DefaultCodegen implements Code
|
||||
} else if ("Float".equals(datatype)) {
|
||||
// add f to number, e.g. 3.14 => 3.14f
|
||||
return value + "f";
|
||||
} else if ("BigDecimal".equals(datatype)) {
|
||||
// use BigDecimal String constructor
|
||||
return "new BigDecimal(\"" + value + "\")";
|
||||
} else {
|
||||
return "\"" + escapeText(value) + "\"";
|
||||
}
|
||||
@@ -1393,10 +1399,6 @@ public abstract class AbstractJavaCodegen extends DefaultCodegen implements Code
|
||||
this.booleanGetterPrefix = booleanGetterPrefix;
|
||||
}
|
||||
|
||||
public void setUseNullForUnknownEnumValue(boolean useNullForUnknownEnumValue) {
|
||||
this.useNullForUnknownEnumValue = useNullForUnknownEnumValue;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String escapeQuotationMark(String input) {
|
||||
// remove " to avoid code injection
|
||||
|
||||
@@ -19,6 +19,7 @@ package org.openapitools.codegen.languages;
|
||||
|
||||
import io.swagger.v3.oas.models.OpenAPI;
|
||||
import io.swagger.v3.oas.models.media.ArraySchema;
|
||||
import io.swagger.v3.oas.models.media.ComposedSchema;
|
||||
import io.swagger.v3.oas.models.media.Schema;
|
||||
import io.swagger.v3.oas.models.parameters.Parameter;
|
||||
import org.apache.commons.io.FilenameUtils;
|
||||
@@ -54,6 +55,9 @@ public abstract class AbstractTypeScriptClientCodegen extends DefaultCodegen imp
|
||||
protected String npmName = null;
|
||||
protected String npmVersion = "1.0.0";
|
||||
|
||||
protected String enumSuffix = "Enum";
|
||||
protected String classEnumSeparator = ".";
|
||||
|
||||
public AbstractTypeScriptClientCodegen() {
|
||||
super();
|
||||
|
||||
@@ -94,7 +98,7 @@ public abstract class AbstractTypeScriptClientCodegen extends DefaultCodegen imp
|
||||
"object"
|
||||
));
|
||||
|
||||
languageGenericTypes = new HashSet<>(Arrays.asList(
|
||||
languageGenericTypes = new HashSet<>(Collections.singletonList(
|
||||
"Array"
|
||||
));
|
||||
|
||||
@@ -144,8 +148,7 @@ public abstract class AbstractTypeScriptClientCodegen extends DefaultCodegen imp
|
||||
if (StringUtils.isEmpty(System.getenv("TS_POST_PROCESS_FILE"))) {
|
||||
LOGGER.info("Hint: Environment variable 'TS_POST_PROCESS_FILE' (optional) not defined. E.g. to format the source code, please try 'export TS_POST_PROCESS_FILE=\"/usr/local/bin/prettier --write\"' (Linux/Mac)");
|
||||
LOGGER.info("Note: To enable file post-processing, 'enablePostProcessFile' must be set to `true` (--enable-post-process-file for CLI).");
|
||||
}
|
||||
else if (!this.isEnablePostProcessFile()) {
|
||||
} else if (!this.isEnablePostProcessFile()) {
|
||||
LOGGER.info("Warning: Environment variable 'TS_POST_PROCESS_FILE' is set but file post-processing is not enabled. To enable file post-processing, 'enablePostProcessFile' must be set to `true` (--enable-post-process-file for CLI).");
|
||||
}
|
||||
|
||||
@@ -177,7 +180,7 @@ public abstract class AbstractTypeScriptClientCodegen extends DefaultCodegen imp
|
||||
this.setNpmVersion(openAPI.getInfo().getVersion());
|
||||
}
|
||||
|
||||
if (additionalProperties.containsKey(SNAPSHOT) && Boolean.valueOf(additionalProperties.get(SNAPSHOT).toString())) {
|
||||
if (additionalProperties.containsKey(SNAPSHOT) && Boolean.parseBoolean(additionalProperties.get(SNAPSHOT).toString())) {
|
||||
if (npmVersion.toUpperCase(Locale.ROOT).matches("^.*-SNAPSHOT$")) {
|
||||
this.setNpmVersion(npmVersion + "." + SNAPSHOT_SUFFIX_FORMAT.format(new Date()));
|
||||
} else {
|
||||
@@ -260,45 +263,45 @@ public abstract class AbstractTypeScriptClientCodegen extends DefaultCodegen imp
|
||||
final String regex = "^.*[+*:;,.()-]+.*$";
|
||||
final Pattern pattern = Pattern.compile(regex);
|
||||
final Matcher matcher = pattern.matcher(str);
|
||||
boolean matches = matcher.matches();
|
||||
return matches;
|
||||
return matcher.matches();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toModelName(String name) {
|
||||
name = sanitizeName(name); // FIXME: a parameter should not be assigned. Also declare the methods parameters as 'final'.
|
||||
public String toModelName(final String name) {
|
||||
ArrayList<String> exceptions = new ArrayList<String>(Arrays.asList("\\|", " "));
|
||||
String sanName = sanitizeName(name, "(?![| ])\\W", exceptions);
|
||||
|
||||
if (!StringUtils.isEmpty(modelNamePrefix)) {
|
||||
name = modelNamePrefix + "_" + name;
|
||||
sanName = modelNamePrefix + "_" + sanName;
|
||||
}
|
||||
|
||||
if (!StringUtils.isEmpty(modelNameSuffix)) {
|
||||
name = name + "_" + modelNameSuffix;
|
||||
sanName = sanName + "_" + modelNameSuffix;
|
||||
}
|
||||
|
||||
// model name cannot use reserved keyword, e.g. return
|
||||
if (isReservedWord(name)) {
|
||||
String modelName = camelize("model_" + name);
|
||||
LOGGER.warn(name + " (reserved word) cannot be used as model name. Renamed to " + modelName);
|
||||
if (isReservedWord(sanName)) {
|
||||
String modelName = camelize("model_" + sanName);
|
||||
LOGGER.warn(sanName + " (reserved word) cannot be used as model name. Renamed to " + modelName);
|
||||
return modelName;
|
||||
}
|
||||
|
||||
// model name starts with number
|
||||
if (name.matches("^\\d.*")) {
|
||||
String modelName = camelize("model_" + name); // e.g. 200Response => Model200Response (after camelize)
|
||||
LOGGER.warn(name + " (model name starts with number) cannot be used as model name. Renamed to " + modelName);
|
||||
if (sanName.matches("^\\d.*")) {
|
||||
String modelName = camelize("model_" + sanName); // e.g. 200Response => Model200Response (after camelize)
|
||||
LOGGER.warn(sanName + " (model name starts with number) cannot be used as model name. Renamed to " + modelName);
|
||||
return modelName;
|
||||
}
|
||||
|
||||
if (languageSpecificPrimitives.contains(name)) {
|
||||
String modelName = camelize("model_" + name);
|
||||
LOGGER.warn(name + " (model name matches existing language type) cannot be used as a model name. Renamed to " + modelName);
|
||||
if (languageSpecificPrimitives.contains(sanName)) {
|
||||
String modelName = camelize("model_" + sanName);
|
||||
LOGGER.warn(sanName + " (model name matches existing language type) cannot be used as a model name. Renamed to " + modelName);
|
||||
return modelName;
|
||||
}
|
||||
|
||||
// camelize the model name
|
||||
// phone_number => PhoneNumber
|
||||
return camelize(name);
|
||||
return camelize(sanName);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -549,8 +552,7 @@ public abstract class AbstractTypeScriptClientCodegen extends DefaultCodegen imp
|
||||
|
||||
@Override
|
||||
public String toEnumName(CodegenProperty property) {
|
||||
String enumName = toModelName(property.name) + "Enum";
|
||||
|
||||
String enumName = toModelName(property.name) + enumSuffix;
|
||||
if (enumName.matches("\\d.*")) { // starts with number
|
||||
return "_" + enumName;
|
||||
} else {
|
||||
@@ -569,14 +571,14 @@ public abstract class AbstractTypeScriptClientCodegen extends DefaultCodegen imp
|
||||
// name enum with model name, e.g. StatusEnum => Pet.StatusEnum
|
||||
for (CodegenProperty var : cm.vars) {
|
||||
if (Boolean.TRUE.equals(var.isEnum)) {
|
||||
var.datatypeWithEnum = var.datatypeWithEnum.replace(var.enumName, cm.classname + "." + var.enumName);
|
||||
var.datatypeWithEnum = var.datatypeWithEnum.replace(var.enumName, cm.classname + classEnumSeparator + var.enumName);
|
||||
}
|
||||
}
|
||||
if (cm.parent != null) {
|
||||
for (CodegenProperty var : cm.allVars) {
|
||||
if (Boolean.TRUE.equals(var.isEnum)) {
|
||||
var.datatypeWithEnum = var.datatypeWithEnum
|
||||
.replace(var.enumName, cm.classname + "." + var.enumName);
|
||||
.replace(var.enumName, cm.classname + classEnumSeparator + var.enumName);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -696,4 +698,14 @@ public abstract class AbstractTypeScriptClientCodegen extends DefaultCodegen imp
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toAnyOfName(List<String> names, ComposedSchema composedSchema) {
|
||||
return String.join(" | ", names);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toOneOfName(List<String> names, ComposedSchema composedSchema) {
|
||||
return String.join(" | ", names);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,6 +22,7 @@ import io.swagger.v3.oas.models.OpenAPI;
|
||||
import io.swagger.v3.oas.models.media.Schema;
|
||||
import io.swagger.v3.parser.util.SchemaTypeUtil;
|
||||
import org.openapitools.codegen.*;
|
||||
import org.openapitools.codegen.utils.ModelUtils;
|
||||
import org.openapitools.codegen.utils.URLPathUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
@@ -353,7 +354,7 @@ public class AspNetCoreServerCodegen extends AbstractCSharpCodegen {
|
||||
supportingFiles.add(new SupportingFile("Filters" + File.separator + "GeneratePathParamsValidationFilter.mustache",
|
||||
packageFolder + File.separator + "Filters", "GeneratePathParamsValidationFilter.cs"));
|
||||
}
|
||||
|
||||
|
||||
supportingFiles.add(new SupportingFile("Authentication" + File.separator + "ApiAuthentication.mustache",packageFolder + File.separator + "Authentication", "ApiAuthentication.cs"));
|
||||
}
|
||||
|
||||
@@ -407,12 +408,12 @@ public class AspNetCoreServerCodegen extends AbstractCSharpCodegen {
|
||||
|
||||
@Override
|
||||
public String getNullableType(Schema p, String type) {
|
||||
boolean isNullableExpected = p.getNullable() == null || (p.getNullable() != null && p.getNullable());
|
||||
|
||||
if (isNullableExpected && languageSpecificPrimitives.contains(type + "?")) {
|
||||
return type + "?";
|
||||
} else if (languageSpecificPrimitives.contains(type)) {
|
||||
return type;
|
||||
if (languageSpecificPrimitives.contains(type)) {
|
||||
if (isSupportNullable() && ModelUtils.isNullable(p) && nullableType.contains(type)) {
|
||||
return type + "?";
|
||||
} else {
|
||||
return type;
|
||||
}
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -879,15 +879,15 @@ public class CSharpClientCodegen extends AbstractCSharpCodegen {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String getNullableType(Schema p, String type) {
|
||||
boolean isNullableExpected = p.getNullable() == null || (p.getNullable() != null && p.getNullable());
|
||||
|
||||
if (isNullableExpected && languageSpecificPrimitives.contains(type + "?")) {
|
||||
return type + "?";
|
||||
} else if (languageSpecificPrimitives.contains(type)) {
|
||||
return type;
|
||||
if (languageSpecificPrimitives.contains(type)) {
|
||||
if (isSupportNullable() && ModelUtils.isNullable(p) && nullableType.contains(type)) {
|
||||
return type + "?";
|
||||
} else {
|
||||
return type;
|
||||
}
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -5,6 +5,7 @@ import io.swagger.v3.oas.models.media.Schema;
|
||||
import io.swagger.v3.parser.util.SchemaTypeUtil;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.openapitools.codegen.CodegenConfig;
|
||||
import org.openapitools.codegen.CodegenConstants;
|
||||
import org.openapitools.codegen.CodegenModel;
|
||||
import org.openapitools.codegen.CodegenOperation;
|
||||
import org.openapitools.codegen.CodegenParameter;
|
||||
@@ -34,6 +35,7 @@ public class CppQt5AbstractCodegen extends AbstractCppCodegen implements Codegen
|
||||
}
|
||||
// CLI options
|
||||
addOption(CPP_NAMESPACE, CPP_NAMESPACE_DESC, this.cppNamespace);
|
||||
addOption(CodegenConstants.MODEL_NAME_PREFIX, CodegenConstants.MODEL_NAME_PREFIX_DESC, this.modelNamePrefix);
|
||||
|
||||
/*
|
||||
* Additional Properties. These values can be passed to the templates and
|
||||
@@ -45,9 +47,7 @@ public class CppQt5AbstractCodegen extends AbstractCppCodegen implements Codegen
|
||||
// Write defaults namespace in properties so that it can be accessible in templates.
|
||||
// At this point command line has not been parsed so if value is given
|
||||
// in command line it will supersede this content
|
||||
additionalProperties.put("cppNamespace", cppNamespace);
|
||||
// CLI options
|
||||
addOption(CPP_NAMESPACE, CPP_NAMESPACE_DESC, this.cppNamespace);
|
||||
additionalProperties.put("cppNamespace", cppNamespace);
|
||||
/*
|
||||
* Language Specific Primitives. These types will not trigger imports by
|
||||
* the client generator
|
||||
@@ -112,7 +112,9 @@ public class CppQt5AbstractCodegen extends AbstractCppCodegen implements Codegen
|
||||
}
|
||||
|
||||
additionalProperties.put("cppNamespaceDeclarations", cppNamespace.split("\\::"));
|
||||
|
||||
if (additionalProperties.containsKey("modelNamePrefix")) {
|
||||
modelNamePrefix = (String) additionalProperties.get("modelNamePrefix");
|
||||
typeMapping.put("object", modelNamePrefix + "Object");
|
||||
additionalProperties().put("prefix", modelNamePrefix);
|
||||
}
|
||||
|
||||
@@ -359,7 +359,10 @@ public class CppRestSdkClientCodegen extends AbstractCppCodegen {
|
||||
return "new " + toModelName(ModelUtils.getSimpleRef(p.get$ref())) + "()";
|
||||
} else if (ModelUtils.isStringSchema(p)) {
|
||||
return "utility::conversions::to_string_t(\"\")";
|
||||
} else if (ModelUtils.isFreeFormObject(p)) {
|
||||
return "new Object()";
|
||||
}
|
||||
|
||||
return "nullptr";
|
||||
}
|
||||
|
||||
|
||||
@@ -16,15 +16,23 @@
|
||||
|
||||
package org.openapitools.codegen.languages;
|
||||
|
||||
import org.openapitools.codegen.CodegenModel;
|
||||
import org.openapitools.codegen.CodegenProperty;
|
||||
import org.openapitools.codegen.SupportingFile;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class GoClientExperimentalCodegen extends GoClientCodegen {
|
||||
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(GoClientExperimentalCodegen.class);
|
||||
|
||||
public GoClientExperimentalCodegen() {
|
||||
super();
|
||||
outputFolder = "generated-code/go-experimental";
|
||||
embeddedTemplateDir = templateDir = "go-experimental";
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -49,4 +57,35 @@ public class GoClientExperimentalCodegen extends GoClientCodegen {
|
||||
return "Generates a Go client library (experimental and may subject to breaking changes without further notice).";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void processOpts() {
|
||||
super.processOpts();
|
||||
supportingFiles.add(new SupportingFile("utils.mustache", "", "utils.go"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Object> postProcessModels(Map<String, Object> objs) {
|
||||
objs = super.postProcessModels(objs);
|
||||
List<Map<String, String>> imports = (List<Map<String, String>>) objs.get("imports");
|
||||
|
||||
boolean addedErrorsImport = false;
|
||||
List<Map<String, Object>> models = (List<Map<String, Object>>) objs.get("models");
|
||||
for (Map<String, Object> m : models) {
|
||||
Object v = m.get("model");
|
||||
if (v instanceof CodegenModel) {
|
||||
CodegenModel model = (CodegenModel) v;
|
||||
if (!model.isEnum) {
|
||||
imports.add(createMapping("import", "encoding/json"));
|
||||
}
|
||||
for (CodegenProperty param : model.vars) {
|
||||
if (!addedErrorsImport && param.required) {
|
||||
imports.add(createMapping("import", "errors"));
|
||||
addedErrorsImport = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return objs;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -67,6 +67,7 @@ public class JavaClientCodegen extends AbstractJavaCodegen
|
||||
public static final String GOOGLE_API_CLIENT = "google-api-client";
|
||||
public static final String JERSEY1 = "jersey1";
|
||||
public static final String JERSEY2 = "jersey2";
|
||||
public static final String NATIVE = "native";
|
||||
public static final String OKHTTP_GSON = "okhttp-gson";
|
||||
public static final String RESTEASY = "resteasy";
|
||||
public static final String RESTTEMPLATE = "resttemplate";
|
||||
@@ -139,6 +140,7 @@ public class JavaClientCodegen extends AbstractJavaCodegen
|
||||
supportedLibraries.put(VERTX, "HTTP client: VertX client 3.x. JSON processing: Jackson 2.8.x");
|
||||
supportedLibraries.put(GOOGLE_API_CLIENT, "HTTP client: Google API client 1.x. JSON processing: Jackson 2.8.x");
|
||||
supportedLibraries.put(REST_ASSURED, "HTTP client: rest-assured : 4.x. JSON processing: Gson 2.x. Only for Java8");
|
||||
supportedLibraries.put(NATIVE, "HTTP client: Java native HttpClient. JSON processing: Jackson 2.9.x. Only for Java11+");
|
||||
|
||||
CliOption libraryOption = new CliOption(CodegenConstants.LIBRARY, "library template (sub-template) to use");
|
||||
libraryOption.setEnum(supportedLibraries);
|
||||
@@ -166,7 +168,7 @@ public class JavaClientCodegen extends AbstractJavaCodegen
|
||||
|
||||
@Override
|
||||
public void processOpts() {
|
||||
if (WEBCLIENT.equals(getLibrary()) && "threetenbp".equals(dateLibrary)) {
|
||||
if ((WEBCLIENT.equals(getLibrary()) && "threetenbp".equals(dateLibrary)) || NATIVE.equals(getLibrary())) {
|
||||
dateLibrary = "java8";
|
||||
}
|
||||
|
||||
@@ -254,12 +256,12 @@ public class JavaClientCodegen extends AbstractJavaCodegen
|
||||
writeOptional(outputFolder, new SupportingFile("manifest.mustache", projectFolder, "AndroidManifest.xml"));
|
||||
supportingFiles.add(new SupportingFile("travis.mustache", "", ".travis.yml"));
|
||||
supportingFiles.add(new SupportingFile("ApiClient.mustache", invokerFolder, "ApiClient.java"));
|
||||
if (!(RESTTEMPLATE.equals(getLibrary()) || REST_ASSURED.equals(getLibrary()))) {
|
||||
if (!(RESTTEMPLATE.equals(getLibrary()) || REST_ASSURED.equals(getLibrary()) || NATIVE.equals(getLibrary()))) {
|
||||
supportingFiles.add(new SupportingFile("StringUtil.mustache", invokerFolder, "StringUtil.java"));
|
||||
}
|
||||
|
||||
// google-api-client doesn't use the OpenAPI auth, because it uses Google Credential directly (HttpRequestInitializer)
|
||||
if (!(GOOGLE_API_CLIENT.equals(getLibrary()) || REST_ASSURED.equals(getLibrary()))) {
|
||||
if (!(GOOGLE_API_CLIENT.equals(getLibrary()) || REST_ASSURED.equals(getLibrary()) || NATIVE.equals(getLibrary()))) {
|
||||
supportingFiles.add(new SupportingFile("auth/HttpBasicAuth.mustache", authFolder, "HttpBasicAuth.java"));
|
||||
supportingFiles.add(new SupportingFile("auth/HttpBearerAuth.mustache", authFolder, "HttpBearerAuth.java"));
|
||||
supportingFiles.add(new SupportingFile("auth/ApiKeyAuth.mustache", authFolder, "ApiKeyAuth.java"));
|
||||
@@ -293,7 +295,7 @@ public class JavaClientCodegen extends AbstractJavaCodegen
|
||||
supportingFiles.add(new SupportingFile("Pair.mustache", invokerFolder, "Pair.java"));
|
||||
}
|
||||
|
||||
if (!(FEIGN.equals(getLibrary()) || RESTTEMPLATE.equals(getLibrary()) || usesAnyRetrofitLibrary() || GOOGLE_API_CLIENT.equals(getLibrary()) || REST_ASSURED.equals(getLibrary()))) {
|
||||
if (!(FEIGN.equals(getLibrary()) || RESTTEMPLATE.equals(getLibrary()) || usesAnyRetrofitLibrary() || GOOGLE_API_CLIENT.equals(getLibrary()) || REST_ASSURED.equals(getLibrary()) || NATIVE.equals(getLibrary()))) {
|
||||
supportingFiles.add(new SupportingFile("auth/Authentication.mustache", authFolder, "Authentication.java"));
|
||||
}
|
||||
|
||||
@@ -325,6 +327,10 @@ public class JavaClientCodegen extends AbstractJavaCodegen
|
||||
supportingFiles.add(new SupportingFile("JSON.mustache", invokerFolder, "JSON.java"));
|
||||
supportingFiles.add(new SupportingFile("ApiResponse.mustache", invokerFolder, "ApiResponse.java"));
|
||||
additionalProperties.put("jackson", "true");
|
||||
} else if (NATIVE.equals(getLibrary())) {
|
||||
setJava8Mode(true);
|
||||
additionalProperties.put("java8", "true");
|
||||
additionalProperties.put("jackson", "true");
|
||||
} else if (RESTEASY.equals(getLibrary())) {
|
||||
supportingFiles.add(new SupportingFile("JSON.mustache", invokerFolder, "JSON.java"));
|
||||
additionalProperties.put("jackson", "true");
|
||||
@@ -412,7 +418,7 @@ public class JavaClientCodegen extends AbstractJavaCodegen
|
||||
additionalProperties.remove("gson");
|
||||
}
|
||||
|
||||
if (additionalProperties.containsKey("jackson")) {
|
||||
if (additionalProperties.containsKey("jackson") && !NATIVE.equals(getLibrary())) {
|
||||
supportingFiles.add(new SupportingFile("RFC3339DateFormat.mustache", invokerFolder, "RFC3339DateFormat.java"));
|
||||
if ("threetenbp".equals(dateLibrary) && !usePlayWS) {
|
||||
supportingFiles.add(new SupportingFile("CustomInstantDeserializer.mustache", invokerFolder, "CustomInstantDeserializer.java"));
|
||||
@@ -500,7 +506,7 @@ public class JavaClientCodegen extends AbstractJavaCodegen
|
||||
}
|
||||
|
||||
// google-api-client doesn't use the OpenAPI auth, because it uses Google Credential directly (HttpRequestInitializer)
|
||||
if ((!(GOOGLE_API_CLIENT.equals(getLibrary()) || REST_ASSURED.equals(getLibrary()) || usePlayWS)) && ProcessUtils.hasOAuthMethods(objs)) {
|
||||
if ((!(GOOGLE_API_CLIENT.equals(getLibrary()) || REST_ASSURED.equals(getLibrary()) || usePlayWS || NATIVE.equals(getLibrary()))) && ProcessUtils.hasOAuthMethods(objs)) {
|
||||
supportingFiles.add(new SupportingFile("auth/OAuth.mustache", authFolder, "OAuth.java"));
|
||||
supportingFiles.add(new SupportingFile("auth/OAuthFlow.mustache", authFolder, "OAuthFlow.java"));
|
||||
}
|
||||
|
||||
@@ -18,13 +18,11 @@
|
||||
package org.openapitools.codegen.languages;
|
||||
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import com.samskivert.mustache.Mustache;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.openapitools.codegen.CliOption;
|
||||
import org.openapitools.codegen.CodegenConstants;
|
||||
import org.openapitools.codegen.CodegenType;
|
||||
import org.openapitools.codegen.SupportingFile;
|
||||
import org.openapitools.codegen.templating.mustache.*;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
@@ -211,31 +209,6 @@ public class KotlinServerCodegen extends AbstractKotlinCodegen {
|
||||
final String infrastructureFolder = (sourceFolder + File.separator + packageName + File.separator + "infrastructure").replace(".", File.separator);
|
||||
|
||||
supportingFiles.add(new SupportingFile("ApiKeyAuth.kt.mustache", infrastructureFolder, "ApiKeyAuth.kt"));
|
||||
|
||||
addMustacheLambdas(additionalProperties);
|
||||
}
|
||||
|
||||
private void addMustacheLambdas(Map<String, Object> objs) {
|
||||
|
||||
Map<String, Mustache.Lambda> lambdas = new ImmutableMap.Builder<String, Mustache.Lambda>()
|
||||
.put("lowercase", new LowercaseLambda().generator(this))
|
||||
.put("uppercase", new UppercaseLambda())
|
||||
.put("titlecase", new TitlecaseLambda())
|
||||
.put("camelcase", new CamelCaseLambda().generator(this))
|
||||
.put("indented", new IndentedLambda())
|
||||
.put("indented_8", new IndentedLambda(8, " "))
|
||||
.put("indented_12", new IndentedLambda(12, " "))
|
||||
.put("indented_16", new IndentedLambda(16, " "))
|
||||
.build();
|
||||
|
||||
if (objs.containsKey("lambda")) {
|
||||
LOGGER.warn("A property named 'lambda' already exists. Mustache lambdas renamed from 'lambda' to '_lambda'. " +
|
||||
"You'll likely need to use a custom template, " +
|
||||
"see https://github.com/OpenAPITools/openapi-generator/blob/master/docs/templating.md. ");
|
||||
objs.put("_lambda", lambdas);
|
||||
} else {
|
||||
objs.put("lambda", lambdas);
|
||||
}
|
||||
}
|
||||
|
||||
public static class Constants {
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user