mirror of
https://github.com/OpenAPITools/openapi-generator.git
synced 2025-12-04 11:56:13 +00:00
Compare commits
77 Commits
v4.1.0
...
update-swa
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f3c1c56741 | ||
|
|
96dd31a462 | ||
|
|
59360c86c6 | ||
|
|
30dcaf0e87 | ||
|
|
a039433182 | ||
|
|
14a39349d5 | ||
|
|
4898ffa4e9 | ||
|
|
62ca0c78ff | ||
|
|
a748e1ff9a | ||
|
|
8741a8ca35 | ||
|
|
870bb1c858 | ||
|
|
f6ead7b877 | ||
|
|
abfef86c8b | ||
|
|
b323b0a0af | ||
|
|
1a808dd644 | ||
|
|
d09e097e4e | ||
|
|
9de908a386 | ||
|
|
57236bc846 | ||
|
|
6924b3c710 | ||
|
|
bb5cd4c42d | ||
|
|
94eb6860aa | ||
|
|
10a310ef69 | ||
|
|
50253f2b15 | ||
|
|
99d7b4e70b | ||
|
|
2ee0c34347 | ||
|
|
4575b3074a | ||
|
|
7abd2e141a | ||
|
|
1adb0ba588 | ||
|
|
6addd76e11 | ||
|
|
8c498fb08a | ||
|
|
a5ab60bec8 | ||
|
|
e086ad1b6e | ||
|
|
1a6d3671d9 | ||
|
|
589e5c6312 | ||
|
|
024f46814c | ||
|
|
1ce09788a9 | ||
|
|
44fda895d2 | ||
|
|
aa4ead2a6d | ||
|
|
7e8c7db798 | ||
|
|
b83fe0c611 | ||
|
|
5182955cca | ||
|
|
cd9eea2fe5 | ||
|
|
ef88bd175f | ||
|
|
99fcfbc802 | ||
|
|
a4811c7850 | ||
|
|
2ada4d90b4 | ||
|
|
dac370b7f7 | ||
|
|
6f7d2792c7 | ||
|
|
2d7785ac63 | ||
|
|
eb6ca9199b | ||
|
|
c3535cf9ca | ||
|
|
286cdfdfa2 | ||
|
|
55786119e7 | ||
|
|
94d4e0cfac | ||
|
|
99d85a39a3 | ||
|
|
b936d72dfa | ||
|
|
93aedcf3d5 | ||
|
|
d04e16a255 | ||
|
|
fae0528cd5 | ||
|
|
ba65f675e2 | ||
|
|
5e27f11ef1 | ||
|
|
850c493c63 | ||
|
|
f5327b601e | ||
|
|
123efc5d65 | ||
|
|
36ccd87a80 | ||
|
|
20db89e277 | ||
|
|
a5349cfde5 | ||
|
|
4a92cd8dca | ||
|
|
c8a65a9942 | ||
|
|
4b6499c636 | ||
|
|
290550ef91 | ||
|
|
06533b977c | ||
|
|
07381e7275 | ||
|
|
22d022b2d5 | ||
|
|
42d6420400 | ||
|
|
ac85c8f901 | ||
|
|
5956569e7a |
@@ -2,6 +2,13 @@ kind: pipeline
|
||||
name: default
|
||||
|
||||
steps:
|
||||
# test Dart 2.x petstore client
|
||||
- name: dart2x-test
|
||||
image: google/dart
|
||||
commands:
|
||||
- (cd samples/client/petstore/dart-jaguar/openapi && pub get && pub run build_runner build --delete-conflicting-outputs)
|
||||
- (cd samples/client/petstore/dart-jaguar/flutter_petstore/openapi && pub get && pub run build_runner build --delete-conflicting-outputs)
|
||||
- (cd samples/client/petstore/dart2/openapi && pub get && pub run test)
|
||||
# test Java 11 HTTP client
|
||||
- name: java11-test
|
||||
image: hirokimatsumoto/alpine-openjdk-11
|
||||
|
||||
@@ -53,6 +53,7 @@ public class ArrayOfArrayOfNumberOnlyTest {
|
||||
List<BigDecimal> arrayArrayNumber = new ArrayList<BigDecimal>();
|
||||
arrayArrayNumber.add(b1);
|
||||
arrayArrayNumber.add(b2);
|
||||
model.setArrayArrayNumber(new ArrayList<List<BigDecimal>>());
|
||||
model.getArrayArrayNumber().add(arrayArrayNumber);
|
||||
|
||||
// create another instance for comparison
|
||||
@@ -62,6 +63,7 @@ public class ArrayOfArrayOfNumberOnlyTest {
|
||||
List<BigDecimal> arrayArrayNumber2 = new ArrayList<BigDecimal>();
|
||||
arrayArrayNumber2.add(b1);
|
||||
arrayArrayNumber2.add(b2);
|
||||
model2.setArrayArrayNumber(new ArrayList<List<BigDecimal>>());
|
||||
model2.getArrayArrayNumber().add(arrayArrayNumber2);
|
||||
|
||||
Assert.assertTrue(model2.equals(model));
|
||||
|
||||
@@ -0,0 +1,73 @@
|
||||
<project>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>org.openapitools</groupId>
|
||||
<artifactId>TypeScriptFetchBuildNamespaceParameterInterfacesPestoreClientTests</artifactId>
|
||||
<packaging>pom</packaging>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
<name>TS Fetch Petstore Client (with namespacing for parameter interfaces)</name>
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<artifactId>maven-dependency-plugin</artifactId>
|
||||
<executions>
|
||||
<execution>
|
||||
<phase>package</phase>
|
||||
<goals>
|
||||
<goal>copy-dependencies</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<outputDirectory>${project.build.directory}</outputDirectory>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.codehaus.mojo</groupId>
|
||||
<artifactId>exec-maven-plugin</artifactId>
|
||||
<version>1.2.1</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>npm-install</id>
|
||||
<phase>integration-test</phase>
|
||||
<goals>
|
||||
<goal>exec</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<executable>npm</executable>
|
||||
<arguments>
|
||||
<argument>install</argument>
|
||||
</arguments>
|
||||
</configuration>
|
||||
</execution>
|
||||
<execution>
|
||||
<id>npm-build</id>
|
||||
<phase>integration-test</phase>
|
||||
<goals>
|
||||
<goal>exec</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<executable>npm</executable>
|
||||
<arguments>
|
||||
<argument>run</argument>
|
||||
<argument>build</argument>
|
||||
</arguments>
|
||||
</configuration>
|
||||
</execution>
|
||||
<execution>
|
||||
<id>npm-test</id>
|
||||
<phase>integration-test</phase>
|
||||
<goals>
|
||||
<goal>exec</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<executable>npm</executable>
|
||||
<arguments>
|
||||
<argument>test</argument>
|
||||
</arguments>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</project>
|
||||
25
README.md
25
README.md
@@ -8,6 +8,12 @@
|
||||
[](https://ci.appveyor.com/project/WilliamCheng/openapi-generator-wh2wu)
|
||||
[](https://cloud.drone.io/OpenAPITools/openapi-generator)
|
||||
|
||||
[`4.2.x`](https://github.com/OpenAPITools/openapi-generator/tree/4.2.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)
|
||||
|
||||
[`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)
|
||||
@@ -59,8 +65,8 @@ OpenAPI Generator allows generation of API client libraries (SDK generation), se
|
||||
|
||||
| | Languages/Frameworks |
|
||||
|-|-|
|
||||
**API clients** | **ActionScript**, **Ada**, **Apex**, **Bash**, **C**, **C#** (.net 2.0, 3.5 or later), **C++** (cpp-restsdk, Qt5, Tizen), **Clojure**, **Dart (1.x, 2.x)**, **Elixir**, **Elm**, **Eiffel**, **Erlang**, **Go**, **Groovy**, **Haskell** (http-client, Servant), **Java** (Jersey1.x, Jersey2.x, OkHttp, Retrofit1.x, Retrofit2.x, Feign, RestTemplate, RESTEasy, Vertx, Google API Client Library for Java, Rest-assured, Spring 5 Web Client), **Kotlin**, **Lua**, **Node.js/JavaScript** (ES5, ES6, AngularJS with Google Closure Compiler annotations, Flow types), **Objective-C**, **OCaml**, **Perl**, **PHP**, **PowerShell**, **Python**, **R**, **Ruby**, **Rust** (rust, rust-server), **Scala** (akka, http4s, scalaz, swagger-async-httpclient), **Swift** (2.x, 3.x, 4.x), **Typescript** (AngularJS, Angular (2.x - 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 clients** | **ActionScript**, **Ada**, **Apex**, **Bash**, **C**, **C#** (.net 2.0, 3.5 or later), **C++** (cpp-restsdk, Qt5, Tizen), **Clojure**, **Dart (1.x, 2.x)**, **Elixir**, **Elm**, **Eiffel**, **Erlang**, **Go**, **Groovy**, **Haskell** (http-client, Servant), **Java** (Jersey1.x, Jersey2.x, OkHttp, Retrofit1.x, Retrofit2.x, Feign, RestTemplate, RESTEasy, Vertx, Google API Client Library for Java, Rest-assured, Spring 5 Web Client), **Kotlin**, **Lua**, **Node.js/JavaScript** (ES5, ES6, AngularJS with Google Closure Compiler annotations, Flow types), **Objective-C**, **OCaml**, **Perl**, **PHP**, **PowerShell**, **Python**, **R**, **Ruby**, **Rust** (rust, rust-server), **Scala** (akka, http4s, scalaz, swagger-async-httpclient), **Swift** (2.x, 3.x, 4.x), **Typescript** (AngularJS, Angular (2.x - 8.x), Aurelia, Axios, Fetch, Inversify, jQuery, Node, Rxjs)
|
||||
**Server stubs** | **Ada**, **C#** (ASP.NET Core, NancyFx), **C++** (Pistache, Restbed, Qt5 QHTTPEngine), **Erlang**, **F#** (Giraffe), **Go** (net/http, Gin), **Haskell** (Servant), **Java** (MSF4J, Spring, Undertow, JAX-RS: CDI, CXF, Inflector, Jersey, RestEasy, Play Framework, [PKMST](https://github.com/ProKarma-Inc/pkmst-getting-started-examples)), **Kotlin** (Spring Boot, Ktor), **PHP** (Laravel, Lumen, Slim, Silex, [Symfony](https://symfony.com/), [Zend Expressive](https://github.com/zendframework/zend-expressive)), **Python** (Flask), **NodeJS**, **Ruby** (Sinatra, Rails5), **Rust** (rust-server), **Scala** ([Finch](https://github.com/finagle/finch), [Lagom](https://github.com/lagom/lagom), [Play](https://www.playframework.com/), Scalatra)
|
||||
**API documentation generators** | **HTML**, **Confluence Wiki**
|
||||
**Configuration files** | [**Apache2**](https://httpd.apache.org/)
|
||||
**Others** | **GraphQL**, **JMeter**, **MySQL Schema**
|
||||
@@ -101,8 +107,9 @@ The OpenAPI Specification has undergone 3 revisions since initial creation in 20
|
||||
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.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)
|
||||
4.2.0 (upcoming minor release) [SNAPSHOT](https://oss.sonatype.org/content/repositories/snapshots/org/openapitools/openapi-generator-cli/4.2.0-SNAPSHOT/)| 09.10.2019 | Minor release (breaking changes with fallbacks)
|
||||
4.1.1 (upcoming minor release) [SNAPSHOT](https://oss.sonatype.org/content/repositories/snapshots/org/openapitools/openapi-generator-cli/4.1.1-SNAPSHOT/)| 23.08.2019 | Patch release (bug fixes, enhancements)
|
||||
[4.1.0](https://github.com/OpenAPITools/openapi-generator/releases/tag/v4.1.0) (latest stable release) | 09.08.2019 | Minor release (breaking changes with fallbacks)
|
||||
|
||||
OpenAPI Spec compatibility: 1.0, 1.1, 1.2, 2.0, 3.0
|
||||
|
||||
@@ -448,7 +455,6 @@ NAME
|
||||
SYNOPSIS
|
||||
openapi-generator-cli generate
|
||||
[(-a <authorization> | --auth <authorization>)]
|
||||
[--additional-properties <additional properties>...]
|
||||
[--api-package <api package>] [--artifact-id <artifact id>]
|
||||
[--artifact-version <artifact version>]
|
||||
[(-c <configuration file> | --config <configuration file>)]
|
||||
@@ -470,11 +476,12 @@ SYNOPSIS
|
||||
[--model-name-suffix <model name suffix>]
|
||||
[--model-package <model package>]
|
||||
[(-o <output directory> | --output <output directory>)]
|
||||
[(-p <additional properties> | --additional-properties <additional properties>)...]
|
||||
[--package-name <package name>] [--release-note <release note>]
|
||||
[--remove-operation-id-prefix]
|
||||
[--reserved-words-mappings <reserved word mappings>...]
|
||||
[(-s | --skip-overwrite)] [--skip-validate-spec]
|
||||
[--strict-spec <true/false strict behavior>]
|
||||
[(-s | --skip-overwrite)] [--server-variables <server variables>...]
|
||||
[--skip-validate-spec] [--strict-spec <true/false strict behavior>]
|
||||
[(-t <template directory> | --template-dir <template directory>)]
|
||||
[--type-mappings <type mappings>...] [(-v | --verbose)]
|
||||
|
||||
@@ -562,6 +569,7 @@ Here are some companies/projects (alphabetical order) using OpenAPI Generator in
|
||||
- [Klarna](https://www.klarna.com/)
|
||||
- [Metaswitch](https://www.metaswitch.com/)
|
||||
- [Myworkout](https://myworkout.com)
|
||||
- [Paxos](https://www.paxos.com)
|
||||
- [Prometheus/Alertmanager](https://github.com/prometheus/alertmanager)
|
||||
- [Raiffeisen Schweiz Genossenschaft](https://www.raiffeisen.ch)
|
||||
- [RepreZen API Studio](https://www.reprezen.com/swagger-openapi-code-generation-api-first-microservices-enterprise-development)
|
||||
@@ -748,6 +756,7 @@ Here is a list of template creators:
|
||||
* Configuration
|
||||
* Apache2: @stkrwork
|
||||
* Schema
|
||||
* Avro: @sgadouar
|
||||
* GraphQL: @wing328 [:heart:](https://www.patreon.com/wing328)
|
||||
* MySQL: @ybelenko
|
||||
|
||||
@@ -790,7 +799,7 @@ If you want to join the committee, please kindly apply by sending an email to te
|
||||
| Apex | |
|
||||
| Bash | @frol (2017/07) @bkryza (2017/08) @kenjones-cisco (2017/09) |
|
||||
| C | @zhemant (2018/11) |
|
||||
| C++ | @ravinikam (2017/07) @stkrwork (2017/07) @etherealjoy (2018/02) @martindelille (2018/03) |
|
||||
| C++ | @ravinikam (2017/07) @stkrwork (2017/07) @etherealjoy (2018/02) @martindelille (2018/03) @muttleyxd (2019/08) |
|
||||
| C# | @mandrean (2017/08), @jimschubert (2017/09) [:heart:](https://www.patreon.com/jimschubert) |
|
||||
| Clojure | |
|
||||
| Dart | @ircecho (2017/07) @swipesight (2018/09) @jaumard (2018/09) |
|
||||
|
||||
32
bin/openapi3/avro-petstore.sh
Executable file
32
bin/openapi3/avro-petstore.sh
Executable file
@@ -0,0 +1,32 @@
|
||||
#!/bin/sh
|
||||
|
||||
SCRIPT="$0"
|
||||
echo "# START SCRIPT: $SCRIPT"
|
||||
|
||||
while [ -h "$SCRIPT" ] ; do
|
||||
ls=`ls -ld "$SCRIPT"`
|
||||
link=`expr "$ls" : '.*-> \(.*\)$'`
|
||||
if expr "$link" : '/.*' > /dev/null; then
|
||||
SCRIPT="$link"
|
||||
else
|
||||
SCRIPT=`dirname "$SCRIPT"`/"$link"
|
||||
fi
|
||||
done
|
||||
|
||||
if [ ! -d "${APP_DIR}" ]; then
|
||||
APP_DIR=`dirname "$SCRIPT"`/..
|
||||
APP_DIR=`cd "${APP_DIR}"; pwd`
|
||||
fi
|
||||
|
||||
executable="./modules/openapi-generator-cli/target/openapi-generator-cli.jar"
|
||||
|
||||
if [ ! -f "$executable" ]
|
||||
then
|
||||
mvn clean package
|
||||
fi
|
||||
|
||||
# if you've executed sbt assembly previously it will use that instead.
|
||||
export JAVA_OPTS="${JAVA_OPTS} -Xmx1024M -DloggerPath=conf/log4j.properties"
|
||||
ags="generate -t modules/openapi-generator/src/main/resources/avro-schema -i modules/openapi-generator/src/test/resources/3_0/petstore.yaml -g avro-schema -o samples/openapi3/schema/petstore/avro-schema $@"
|
||||
|
||||
java $JAVA_OPTS -jar $executable $ags
|
||||
@@ -4,3 +4,4 @@
|
||||
./bin/openapi3/typescript-fetch-petstore-with-npm-version.sh
|
||||
./bin/openapi3/typescript-fetch-petstore-interfaces.sh
|
||||
./bin/openapi3/typescript-fetch-petstore.sh
|
||||
./bin/openapi3/typescript-fetch-petstore-namespace-parameter-interfaces.sh
|
||||
|
||||
32
bin/openapi3/typescript-fetch-petstore-namespace-parameter-interfaces.sh
Executable file
32
bin/openapi3/typescript-fetch-petstore-namespace-parameter-interfaces.sh
Executable file
@@ -0,0 +1,32 @@
|
||||
#!/bin/sh
|
||||
|
||||
SCRIPT="$0"
|
||||
echo "# START SCRIPT: $SCRIPT"
|
||||
|
||||
while [ -h "$SCRIPT" ] ; do
|
||||
ls=`ls -ld "$SCRIPT"`
|
||||
link=`expr "$ls" : '.*-> \(.*\)$'`
|
||||
if expr "$link" : '/.*' > /dev/null; then
|
||||
SCRIPT="$link"
|
||||
else
|
||||
SCRIPT=`dirname "$SCRIPT"`/"$link"
|
||||
fi
|
||||
done
|
||||
|
||||
if [ ! -d "${APP_DIR}" ]; then
|
||||
APP_DIR=`dirname "$SCRIPT"`/..
|
||||
APP_DIR=`cd "${APP_DIR}"; pwd`
|
||||
fi
|
||||
|
||||
executable="./modules/openapi-generator-cli/target/openapi-generator-cli.jar"
|
||||
|
||||
if [ ! -f "$executable" ]
|
||||
then
|
||||
mvn clean package
|
||||
fi
|
||||
|
||||
# if you've executed sbt assembly previously it will use that instead.
|
||||
export JAVA_OPTS="${JAVA_OPTS} -Xmx1024M -DloggerPath=conf/log4j.properties"
|
||||
ags="generate -i modules/openapi-generator/src/test/resources/3_0/petstore.yaml -g typescript-fetch -o samples/client/petstore/typescript-fetch/builds/namespace-parameter-interfaces --additional-properties namespaceParameterInterfaces=true $@"
|
||||
|
||||
java $JAVA_OPTS -jar $executable $ags
|
||||
@@ -38,4 +38,8 @@ for spec_path in modules/openapi-generator/src/test/resources/*/rust-server/* ;
|
||||
$@"
|
||||
|
||||
java $JAVA_OPTS -jar $executable $args
|
||||
|
||||
if [ $? -ne 0 ]; then
|
||||
exit $?
|
||||
fi
|
||||
done
|
||||
|
||||
@@ -13,3 +13,4 @@
|
||||
./bin/typescript-angular-v7-petstore-not-provided-in-root-with-npm.sh
|
||||
./bin/typescript-angular-v7-petstore-provided-in-root.sh
|
||||
./bin/typescript-angular-v7-petstore-provided-in-root-with-npm.sh
|
||||
./bin/typescript-angular-v8-petstore-provided-in-root-with-npm.sh
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
{
|
||||
"npmName": "@openapitools/typescript-angular-petstore",
|
||||
"npmVersion": "1.0.0",
|
||||
"npmRepository" : "https://skimdb.npmjs.com/registry",
|
||||
"snapshot" : false,
|
||||
"ngVersion": "8.0.0"
|
||||
}
|
||||
32
bin/typescript-angular-v8-petstore-provided-in-root-with-npm.sh
Executable file
32
bin/typescript-angular-v8-petstore-provided-in-root-with-npm.sh
Executable file
@@ -0,0 +1,32 @@
|
||||
#!/bin/sh
|
||||
|
||||
SCRIPT="$0"
|
||||
echo "# START SCRIPT: $SCRIPT"
|
||||
|
||||
while [ -h "$SCRIPT" ] ; do
|
||||
ls=`ls -ld "$SCRIPT"`
|
||||
link=`expr "$ls" : '.*-> \(.*\)$'`
|
||||
if expr "$link" : '/.*' > /dev/null; then
|
||||
SCRIPT="$link"
|
||||
else
|
||||
SCRIPT=`dirname "$SCRIPT"`/"$link"
|
||||
fi
|
||||
done
|
||||
|
||||
if [ ! -d "${APP_DIR}" ]; then
|
||||
APP_DIR=`dirname "$SCRIPT"`/..
|
||||
APP_DIR=`cd "${APP_DIR}"; pwd`
|
||||
fi
|
||||
|
||||
executable="./modules/openapi-generator-cli/target/openapi-generator-cli.jar"
|
||||
|
||||
if [ ! -f "$executable" ]
|
||||
then
|
||||
mvn -B clean package
|
||||
fi
|
||||
|
||||
# if you've executed sbt assembly previously it will use that instead.
|
||||
export JAVA_OPTS="${JAVA_OPTS} -Xmx1024M -DloggerPath=conf/log4j.properties"
|
||||
ags="generate -i modules/openapi-generator/src/test/resources/2_0/petstore.yaml -g typescript-angular -c bin/typescript-angular-v8-petstore-provided-in-root-with-npm.json -o samples/client/petstore/typescript-angular-v8-provided-in-root/builds/with-npm --additional-properties ngVersion=8.0.0 $@"
|
||||
|
||||
java $JAVA_OPTS -jar $executable $ags
|
||||
@@ -5,3 +5,4 @@
|
||||
./bin/typescript-fetch-petstore-interfaces.sh
|
||||
./bin/typescript-fetch-petstore.sh
|
||||
./bin/typescript-fetch-petstore-multiple-parameters.sh
|
||||
./bin/typescript-fetch-petstore-namespace-parameter-interfaces.sh
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
{
|
||||
"npmName": "@openapitools/typescript-fetch-petstore",
|
||||
"npmVersion": "1.0.0",
|
||||
"npmRepository" : "https://skimdb.npmjs.com/registry",
|
||||
"snapshot" : false,
|
||||
"namespaceParameterInterfaces": true
|
||||
}
|
||||
34
bin/typescript-fetch-petstore-namespace-parameter-interfaces.sh
Executable file
34
bin/typescript-fetch-petstore-namespace-parameter-interfaces.sh
Executable file
@@ -0,0 +1,34 @@
|
||||
#!/bin/sh
|
||||
|
||||
SCRIPT="$0"
|
||||
echo "# START SCRIPT: $SCRIPT"
|
||||
|
||||
while [ -h "$SCRIPT" ] ; do
|
||||
ls=`ls -ld "$SCRIPT"`
|
||||
link=`expr "$ls" : '.*-> \(.*\)$'`
|
||||
if expr "$link" : '/.*' > /dev/null; then
|
||||
SCRIPT="$link"
|
||||
else
|
||||
SCRIPT=`dirname "$SCRIPT"`/"$link"
|
||||
fi
|
||||
done
|
||||
|
||||
if [ ! -d "${APP_DIR}" ]; then
|
||||
APP_DIR=`dirname "$SCRIPT"`/..
|
||||
APP_DIR=`cd "${APP_DIR}"; pwd`
|
||||
fi
|
||||
|
||||
executable="./modules/openapi-generator-cli/target/openapi-generator-cli.jar"
|
||||
|
||||
if [ ! -f "$executable" ]
|
||||
then
|
||||
mvn -B clean package
|
||||
fi
|
||||
|
||||
# if you've executed sbt assembly previously it will use that instead.
|
||||
export JAVA_OPTS="${JAVA_OPTS} -Xmx1024M -DloggerPath=conf/log4j.properties"
|
||||
ags="generate -i modules/openapi-generator/src/test/resources/2_0/petstore.yaml -g typescript-fetch -c bin/typescript-fetch-petstore-namespace-parameter-interfaces.json -o samples/client/petstore/typescript-fetch/builds/namespace-parameter-interfaces $@"
|
||||
|
||||
java $JAVA_OPTS -jar $executable $ags
|
||||
|
||||
cp CI/samples.ci/client/petstore/typescript-fetch/builds/namespace-parameter-interfaces/pom.xml samples/client/petstore/typescript-fetch/builds/namespace-parameter-interfaces/pom.xml
|
||||
@@ -12,6 +12,7 @@ sleep 5
|
||||
# LIST OF SCRIPTS:
|
||||
declare -a scripts=(
|
||||
# SAMPLES
|
||||
"./bin/ruby-client-petstore.sh"
|
||||
"./bin/openapi3/ruby-client-petstore.sh"
|
||||
"./bin/openapi3/ruby-client-faraday-petstore.sh"
|
||||
"./bin/java-petstore-all.sh"
|
||||
@@ -57,11 +58,14 @@ declare -a scripts=(
|
||||
"./bin/groovy-petstore.sh"
|
||||
"./bin/apex-petstore.sh"
|
||||
"./bin/perl-petstore-all.sh"
|
||||
"./bin/dart-jaguar-petstore.sh"
|
||||
"./bin/dart-flutter-petstore.sh"
|
||||
"./bin/dart-petstore.sh"
|
||||
"./bin/dart2-petstore.sh"
|
||||
#"./bin/elm-petstore-all.sh"
|
||||
"./bin/meta-codegen.sh"
|
||||
# OTHERS
|
||||
"./bin/utils/export_docs_generators.sh"
|
||||
"./bin/utils/export_generators_docusaurus_index.sh"
|
||||
"./bin/utils/copy-to-website.sh"
|
||||
"./bin/utils/export_generators_readme.sh")
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@ echo "# START SCRIPT: ${SCRIPT}"
|
||||
|
||||
executable="./modules/openapi-generator-cli/target/openapi-generator-cli.jar"
|
||||
|
||||
for GENERATOR in $(java -jar ${executable} list --short | sed -e 's/,/\'$'\n''/g')
|
||||
for GENERATOR in $(java -jar ${executable} list --short --include all | sed -e 's/,/\'$'\n''/g')
|
||||
do
|
||||
./bin/utils/export_generator.sh ${GENERATOR}
|
||||
done
|
||||
|
||||
@@ -1,20 +0,0 @@
|
||||
#!/bin/sh
|
||||
|
||||
SCRIPT="$0"
|
||||
echo "# START SCRIPT: $SCRIPT"
|
||||
|
||||
executable="./modules/openapi-generator-cli/target/openapi-generator-cli.jar"
|
||||
|
||||
\rm -rf docs/generators.md
|
||||
|
||||
cat > docs/generators.md << EOF
|
||||
---
|
||||
id: generators
|
||||
title: Generators List
|
||||
---
|
||||
|
||||
EOF
|
||||
|
||||
java -jar $executable list --docsite >> docs/generators.md
|
||||
|
||||
echo "Wrote $(pwd)/docs/generators.md"
|
||||
@@ -15,6 +15,6 @@ title: Generators List
|
||||
|
||||
EOF
|
||||
|
||||
java -jar $executable list | sed -e 's/\([A-Z]*\) generators:/* \1 generators:/g' -e 's/- \([a-z0-9\-]*\)/- [\1]\(generators\/\1.md\)/g' >> docs/generators.md
|
||||
java -jar $executable list --docsite --include all >> docs/generators.md
|
||||
|
||||
echo "Wrote $(pwd)/docs/generators.md"
|
||||
|
||||
@@ -42,7 +42,7 @@ artifactid=openapi-generator-cli
|
||||
ver=${OPENAPI_GENERATOR_VERSION:-$(latest.tag $ghrepo)}
|
||||
|
||||
jar=${artifactid}-${ver}.jar
|
||||
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
||||
DIR=${OPENAPI_GENERATOR_DOWLOAD_CACHE_DIR:-"$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"}
|
||||
|
||||
if [ ! -f ${DIR}/${jar} ]; then
|
||||
repo="central::default::https://repo1.maven.org/maven2/"
|
||||
|
||||
@@ -11,4 +11,4 @@ call .\bin\windows\typescript-angular-v7-provided-in-root.bat
|
||||
call .\bin\windows\typescript-angular-v7-provided-in-root-with-npm.bat
|
||||
call .\bin\windows\typescript-angular-v7-not-provided-in-root.bat
|
||||
call .\bin\windows\typescript-angular-v7-not-provided-in-root-with-npm.bat
|
||||
|
||||
call .\bin\windows\typescript-angular-v8-provided-in-root-with-npm.bat
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
set executable=.\modules\openapi-generator-cli\target\openapi-generator-cli.jar
|
||||
|
||||
If Not Exist %executable% (
|
||||
mvn clean package
|
||||
)
|
||||
|
||||
set ags=generate -i modules\openapi-generator\src\test\resources\2_0\petstore.yaml -g typescript-angular -c bin/typescript-angular-v8-petstore-provided-in-root-with-npm.json -o samples\client\petstore\typescript-angular-v8-provided-in-root\builds\with-npm --additional-properties ngVersion=8.0.0
|
||||
|
||||
java %JAVA_OPTS% -jar %executable% %ags%
|
||||
@@ -5,3 +5,4 @@ call bin\windows\typescript-fetch-petstore-target-es6.bat
|
||||
call bin\windows\typescript-fetch-petstore-with-npm-version.bat
|
||||
call bin\windows\typescript-fetch-petstore-interfaces.bat
|
||||
call bin\windows\typescript-fetch-petstore-multiple-parameters.bat
|
||||
call bin\windows\typescript-fetch-petstore-namespace-parameter-interfaces.bat
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
@ECHO OFF
|
||||
|
||||
set executable=.\modules\openapi-generator-cli\target\openapi-generator-cli.jar
|
||||
|
||||
If Not Exist %executable% (
|
||||
mvn clean package
|
||||
)
|
||||
|
||||
REM set JAVA_OPTS=%JAVA_OPTS% -Xmx1024M
|
||||
set ags=generate -i modules\openapi-generator\src\test\resources\2_0\petstore.yaml -g typescript-fetch -o samples\client\petstore\typescript-fetch\builds\namespace-parameter-interfaces --additional-properties namespaceParameterInterfaces=true
|
||||
|
||||
java %JAVA_OPTS% -jar %executable% %ags%
|
||||
@@ -5,132 +5,133 @@ title: Generators List
|
||||
|
||||
The following generators are available:
|
||||
|
||||
* CLIENT generators:
|
||||
- [ada](generators/ada.md)
|
||||
- [android](generators/android.md)
|
||||
- [apex](generators/apex.md)
|
||||
- [bash](generators/bash.md)
|
||||
- [c](generators/c.md)
|
||||
- [clojure](generators/clojure.md)
|
||||
- [cpp-qt5-client](generators/cpp-qt5-client.md)
|
||||
- [cpp-restsdk](generators/cpp-restsdk.md)
|
||||
- [cpp-tizen](generators/cpp-tizen.md)
|
||||
- [csharp](generators/csharp.md)
|
||||
- [csharp-dotnet2](generators/csharp-dotnet2.md) (deprecated)
|
||||
- [csharp-netcore](generators/csharp-netcore.md)
|
||||
- [dart](generators/dart.md)
|
||||
- [dart-jaguar](generators/dart-jaguar.md)
|
||||
- [eiffel](generators/eiffel.md)
|
||||
- [elixir](generators/elixir.md)
|
||||
- [elm](generators/elm.md)
|
||||
- [erlang-client](generators/erlang-client.md)
|
||||
- [erlang-proper](generators/erlang-proper.md)
|
||||
- [flash](generators/flash.md)
|
||||
- [go](generators/go.md)
|
||||
- [go-experimental](generators/go-experimental.md)
|
||||
- [groovy](generators/groovy.md)
|
||||
- [haskell-http-client](generators/haskell-http-client.md)
|
||||
- [java](generators/java.md)
|
||||
- [javascript](generators/javascript.md)
|
||||
- [javascript-closure-angular](generators/javascript-closure-angular.md)
|
||||
- [javascript-flowtyped](generators/javascript-flowtyped.md)
|
||||
- [jaxrs-cxf-client](generators/jaxrs-cxf-client.md)
|
||||
- [jmeter](generators/jmeter.md)
|
||||
- [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)
|
||||
- [python](generators/python.md)
|
||||
- [python-experimental](generators/python-experimental.md)
|
||||
- [r](generators/r.md)
|
||||
- [ruby](generators/ruby.md)
|
||||
- [rust](generators/rust.md)
|
||||
- [scala-akka](generators/scala-akka.md)
|
||||
- [scala-gatling](generators/scala-gatling.md)
|
||||
- [scala-httpclient-deprecated](generators/scala-httpclient-deprecated.md) (deprecated)
|
||||
- [scalaz](generators/scalaz.md)
|
||||
- [swift2-deprecated](generators/swift2-deprecated.md) (deprecated)
|
||||
- [swift3-deprecated](generators/swift3-deprecated.md) (deprecated)
|
||||
- [swift4](generators/swift4.md)
|
||||
- [typescript-angular](generators/typescript-angular.md)
|
||||
- [typescript-angularjs](generators/typescript-angularjs.md)
|
||||
- [typescript-aurelia](generators/typescript-aurelia.md)
|
||||
- [typescript-axios](generators/typescript-axios.md)
|
||||
- [typescript-fetch](generators/typescript-fetch.md)
|
||||
- [typescript-inversify](generators/typescript-inversify.md)
|
||||
- [typescript-jquery](generators/typescript-jquery.md)
|
||||
- [typescript-node](generators/typescript-node.md)
|
||||
- [typescript-rxjs](generators/typescript-rxjs.md)
|
||||
## CLIENT generators
|
||||
* [ada](generators/ada)
|
||||
* [android](generators/android)
|
||||
* [apex](generators/apex)
|
||||
* [bash](generators/bash)
|
||||
* [c](generators/c)
|
||||
* [clojure](generators/clojure)
|
||||
* [cpp-qt5-client](generators/cpp-qt5-client)
|
||||
* [cpp-restsdk](generators/cpp-restsdk)
|
||||
* [cpp-tizen](generators/cpp-tizen)
|
||||
* [csharp](generators/csharp)
|
||||
* [csharp-dotnet2 (deprecated)](generators/csharp-dotnet2)
|
||||
* [csharp-netcore](generators/csharp-netcore)
|
||||
* [dart](generators/dart)
|
||||
* [dart-jaguar](generators/dart-jaguar)
|
||||
* [eiffel](generators/eiffel)
|
||||
* [elixir](generators/elixir)
|
||||
* [elm](generators/elm)
|
||||
* [erlang-client](generators/erlang-client)
|
||||
* [erlang-proper](generators/erlang-proper)
|
||||
* [flash](generators/flash)
|
||||
* [go](generators/go)
|
||||
* [go-experimental (experimental)](generators/go-experimental)
|
||||
* [groovy](generators/groovy)
|
||||
* [haskell-http-client](generators/haskell-http-client)
|
||||
* [java](generators/java)
|
||||
* [javascript](generators/javascript)
|
||||
* [javascript-closure-angular](generators/javascript-closure-angular)
|
||||
* [javascript-flowtyped](generators/javascript-flowtyped)
|
||||
* [jaxrs-cxf-client](generators/jaxrs-cxf-client)
|
||||
* [jmeter](generators/jmeter)
|
||||
* [kotlin](generators/kotlin)
|
||||
* [lua](generators/lua)
|
||||
* [objc](generators/objc)
|
||||
* [ocaml](generators/ocaml)
|
||||
* [perl](generators/perl)
|
||||
* [php](generators/php)
|
||||
* [powershell](generators/powershell)
|
||||
* [python](generators/python)
|
||||
* [python-experimental (experimental)](generators/python-experimental)
|
||||
* [r](generators/r)
|
||||
* [ruby](generators/ruby)
|
||||
* [rust](generators/rust)
|
||||
* [scala-akka](generators/scala-akka)
|
||||
* [scala-gatling](generators/scala-gatling)
|
||||
* [scala-httpclient-deprecated (deprecated)](generators/scala-httpclient-deprecated)
|
||||
* [scalaz](generators/scalaz)
|
||||
* [swift2-deprecated (deprecated)](generators/swift2-deprecated)
|
||||
* [swift3-deprecated (deprecated)](generators/swift3-deprecated)
|
||||
* [swift4](generators/swift4)
|
||||
* [typescript-angular](generators/typescript-angular)
|
||||
* [typescript-angularjs](generators/typescript-angularjs)
|
||||
* [typescript-aurelia](generators/typescript-aurelia)
|
||||
* [typescript-axios](generators/typescript-axios)
|
||||
* [typescript-fetch](generators/typescript-fetch)
|
||||
* [typescript-inversify](generators/typescript-inversify)
|
||||
* [typescript-jquery](generators/typescript-jquery)
|
||||
* [typescript-node](generators/typescript-node)
|
||||
* [typescript-rxjs](generators/typescript-rxjs)
|
||||
|
||||
|
||||
* SERVER generators:
|
||||
- [ada-server](generators/ada-server.md)
|
||||
- [aspnetcore](generators/aspnetcore.md)
|
||||
- [cpp-pistache-server](generators/cpp-pistache-server.md)
|
||||
- [cpp-qt5-qhttpengine-server](generators/cpp-qt5-qhttpengine-server.md)
|
||||
- [cpp-restbed-server](generators/cpp-restbed-server.md)
|
||||
- [csharp-nancyfx](generators/csharp-nancyfx.md)
|
||||
- [erlang-server](generators/erlang-server.md)
|
||||
- [fsharp-giraffe-server](generators/fsharp-giraffe-server.md)
|
||||
- [go-gin-server](generators/go-gin-server.md)
|
||||
- [go-server](generators/go-server.md)
|
||||
- [graphql-nodejs-express-server](generators/graphql-nodejs-express-server.md)
|
||||
- [haskell](generators/haskell.md)
|
||||
- [java-inflector](generators/java-inflector.md)
|
||||
- [java-msf4j](generators/java-msf4j.md)
|
||||
- [java-pkmst](generators/java-pkmst.md)
|
||||
- [java-play-framework](generators/java-play-framework.md)
|
||||
- [java-undertow-server](generators/java-undertow-server.md)
|
||||
- [java-vertx](generators/java-vertx.md)
|
||||
- [jaxrs-cxf](generators/jaxrs-cxf.md)
|
||||
- [jaxrs-cxf-cdi](generators/jaxrs-cxf-cdi.md)
|
||||
- [jaxrs-cxf-extended](generators/jaxrs-cxf-extended.md)
|
||||
- [jaxrs-jersey](generators/jaxrs-jersey.md)
|
||||
- [jaxrs-resteasy](generators/jaxrs-resteasy.md)
|
||||
- [jaxrs-resteasy-eap](generators/jaxrs-resteasy-eap.md)
|
||||
- [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)
|
||||
- [php-silex](generators/php-silex.md)
|
||||
- [php-slim](generators/php-slim.md)
|
||||
- [php-symfony](generators/php-symfony.md)
|
||||
- [php-ze-ph](generators/php-ze-ph.md)
|
||||
- [python-aiohttp](generators/python-aiohttp.md)
|
||||
- [python-blueplanet](generators/python-blueplanet.md)
|
||||
- [python-flask](generators/python-flask.md)
|
||||
- [ruby-on-rails](generators/ruby-on-rails.md)
|
||||
- [ruby-sinatra](generators/ruby-sinatra.md)
|
||||
- [rust-server](generators/rust-server.md)
|
||||
- [scala-finch](generators/scala-finch.md)
|
||||
- [scala-lagom-server](generators/scala-lagom-server.md)
|
||||
- [scala-play-server](generators/scala-play-server.md)
|
||||
- [scalatra](generators/scalatra.md)
|
||||
- [spring](generators/spring.md)
|
||||
## SERVER generators
|
||||
* [ada-server](generators/ada-server)
|
||||
* [aspnetcore](generators/aspnetcore)
|
||||
* [cpp-pistache-server](generators/cpp-pistache-server)
|
||||
* [cpp-qt5-qhttpengine-server](generators/cpp-qt5-qhttpengine-server)
|
||||
* [cpp-restbed-server](generators/cpp-restbed-server)
|
||||
* [csharp-nancyfx](generators/csharp-nancyfx)
|
||||
* [erlang-server](generators/erlang-server)
|
||||
* [fsharp-giraffe-server](generators/fsharp-giraffe-server)
|
||||
* [go-gin-server](generators/go-gin-server)
|
||||
* [go-server](generators/go-server)
|
||||
* [graphql-nodejs-express-server](generators/graphql-nodejs-express-server)
|
||||
* [haskell](generators/haskell)
|
||||
* [java-inflector](generators/java-inflector)
|
||||
* [java-msf4j](generators/java-msf4j)
|
||||
* [java-pkmst](generators/java-pkmst)
|
||||
* [java-play-framework](generators/java-play-framework)
|
||||
* [java-undertow-server](generators/java-undertow-server)
|
||||
* [java-vertx](generators/java-vertx)
|
||||
* [jaxrs-cxf](generators/jaxrs-cxf)
|
||||
* [jaxrs-cxf-cdi](generators/jaxrs-cxf-cdi)
|
||||
* [jaxrs-cxf-extended](generators/jaxrs-cxf-extended)
|
||||
* [jaxrs-jersey](generators/jaxrs-jersey)
|
||||
* [jaxrs-resteasy](generators/jaxrs-resteasy)
|
||||
* [jaxrs-resteasy-eap](generators/jaxrs-resteasy-eap)
|
||||
* [jaxrs-spec](generators/jaxrs-spec)
|
||||
* [kotlin-server](generators/kotlin-server)
|
||||
* [kotlin-spring](generators/kotlin-spring)
|
||||
* [nodejs-express-server (beta)](generators/nodejs-express-server)
|
||||
* [nodejs-server-deprecated (deprecated)](generators/nodejs-server-deprecated)
|
||||
* [php-laravel](generators/php-laravel)
|
||||
* [php-lumen](generators/php-lumen)
|
||||
* [php-silex](generators/php-silex)
|
||||
* [php-slim](generators/php-slim)
|
||||
* [php-symfony](generators/php-symfony)
|
||||
* [php-ze-ph](generators/php-ze-ph)
|
||||
* [python-aiohttp](generators/python-aiohttp)
|
||||
* [python-blueplanet](generators/python-blueplanet)
|
||||
* [python-flask](generators/python-flask)
|
||||
* [ruby-on-rails](generators/ruby-on-rails)
|
||||
* [ruby-sinatra](generators/ruby-sinatra)
|
||||
* [rust-server](generators/rust-server)
|
||||
* [scala-finch](generators/scala-finch)
|
||||
* [scala-lagom-server](generators/scala-lagom-server)
|
||||
* [scala-play-server](generators/scala-play-server)
|
||||
* [scalatra](generators/scalatra)
|
||||
* [spring](generators/spring)
|
||||
|
||||
|
||||
* DOCUMENTATION generators:
|
||||
- [cwiki](generators/cwiki.md)
|
||||
- [dynamic-html](generators/dynamic-html.md)
|
||||
- [html](generators/html.md)
|
||||
- [html2](generators/html2.md)
|
||||
- [openapi](generators/openapi.md)
|
||||
- [openapi-yaml](generators/openapi-yaml.md)
|
||||
## DOCUMENTATION generators
|
||||
* [cwiki](generators/cwiki)
|
||||
* [dynamic-html](generators/dynamic-html)
|
||||
* [html](generators/html)
|
||||
* [html2](generators/html2)
|
||||
* [openapi](generators/openapi)
|
||||
* [openapi-yaml](generators/openapi-yaml)
|
||||
|
||||
|
||||
* SCHEMA generators:
|
||||
- [mysql-schema](generators/mysql-schema.md)
|
||||
## SCHEMA generators
|
||||
* [avro-schema (beta)](generators/avro-schema)
|
||||
* [mysql-schema](generators/mysql-schema)
|
||||
|
||||
|
||||
* CONFIG generators:
|
||||
- [apache2](generators/apache2.md)
|
||||
- [graphql-schema](generators/graphql-schema.md)
|
||||
## CONFIG generators
|
||||
* [apache2](generators/apache2)
|
||||
* [graphql-schema](generators/graphql-schema)
|
||||
|
||||
|
||||
|
||||
|
||||
14
docs/generators/avro-schema.md
Normal file
14
docs/generators/avro-schema.md
Normal file
@@ -0,0 +1,14 @@
|
||||
|
||||
---
|
||||
id: generator-opts-schema-avro-schema
|
||||
title: Config Options for avro-schema
|
||||
sidebar_label: avro-schema
|
||||
---
|
||||
|
||||
| Option | Description | Values | Default |
|
||||
| ------ | ----------- | ------ | ------- |
|
||||
|sortParamsByRequiredFlag|Sort method arguments to place required parameters before optional parameters.| |true|
|
||||
|ensureUniqueParams|Whether to ensure parameter names are unique in an operation (rename parameters that are not).| |true|
|
||||
|allowUnicodeIdentifiers|boolean, toggles whether unicode identifiers are allowed in names or not, default is false| |false|
|
||||
|prependFormOrBodyParameters|Add form or body parameters to the beginning of the parameter list.| |false|
|
||||
|packageName|package for generated classes (where supported)| |null|
|
||||
@@ -12,7 +12,7 @@ sidebar_label: csharp-netcore
|
||||
|sourceFolder|source folder for generated code| |src|
|
||||
|packageGuid|The GUID that will be associated with the C# project| |null|
|
||||
|interfacePrefix|Prefix interfaces with a community standard or widely accepted prefix.| |I|
|
||||
|targetFramework|The target .NET framework version.|<dl><dt>**netstandard1.3**</dt><dd>.NET Standard 1.3 compatible</dd><dt>**netstandard1.4**</dt><dd>.NET Standard 1.4 compatible</dd><dt>**netstandard1.5**</dt><dd>.NET Standard 1.5 compatible</dd><dt>**netstandard1.6**</dt><dd>.NET Standard 1.6 compatible</dd><dt>**netstandard2.0**</dt><dd>.NET Standard 2.0 compatible</dd><dt>**netcoreapp2.0**</dt><dd>.NET Core 2.0 compatible</dd><dl>|v4.6.1|
|
||||
|targetFramework|The target .NET framework version.|<dl><dt>**netstandard1.3**</dt><dd>.NET Standard 1.3 compatible</dd><dt>**netstandard1.4**</dt><dd>.NET Standard 1.4 compatible</dd><dt>**netstandard1.5**</dt><dd>.NET Standard 1.5 compatible</dd><dt>**netstandard1.6**</dt><dd>.NET Standard 1.6 compatible</dd><dt>**netstandard2.0**</dt><dd>.NET Standard 2.0 compatible</dd><dt>**netcoreapp2.0**</dt><dd>.NET Core 2.0 compatible</dd><dl>|netstandard2.0|
|
||||
|modelPropertyNaming|Naming convention for the property: 'camelCase', 'PascalCase', 'snake_case' and 'original', which keeps the original name| |PascalCase|
|
||||
|hideGenerationTimestamp|Hides the generation timestamp when files are generated.| |true|
|
||||
|sortParamsByRequiredFlag|Sort method arguments to place required parameters before optional parameters.| |true|
|
||||
@@ -26,3 +26,4 @@ sidebar_label: csharp-netcore
|
||||
|allowUnicodeIdentifiers|boolean, toggles whether unicode identifiers are allowed in names or not, default is false| |false|
|
||||
|netCoreProjectFile|Use the new format (.NET Core) for .NET project files (.csproj).| |false|
|
||||
|validatable|Generates self-validatable models.| |true|
|
||||
|caseInsensitiveResponseHeaders|Make API response's headers case-insensitive| |false|
|
||||
|
||||
@@ -11,12 +11,12 @@ sidebar_label: dart-jaguar
|
||||
|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|
|
||||
|browserClient|Is the client browser based| |null|
|
||||
|browserClient|Is the client browser based (for Dart 1.x only)| |null|
|
||||
|pubName|Name in generated pubspec| |null|
|
||||
|pubVersion|Version in generated pubspec| |null|
|
||||
|pubDescription|Description in generated pubspec| |null|
|
||||
|useEnumExtension|Allow the 'x-enum-values' extension for enums| |null|
|
||||
|sourceFolder|source folder for generated code| |null|
|
||||
|supportDart2|support dart2| |true|
|
||||
|sourceFolder|Source folder for generated code| |null|
|
||||
|supportDart2|Support Dart 2.x| |true|
|
||||
|nullableFields|Is the null fields should be in the JSON payload| |null|
|
||||
|serialization|Choose serialization format JSON or PROTO is supported| |null|
|
||||
|
||||
@@ -11,10 +11,10 @@ sidebar_label: dart
|
||||
|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|
|
||||
|browserClient|Is the client browser based| |null|
|
||||
|browserClient|Is the client browser based (for Dart 1.x only)| |null|
|
||||
|pubName|Name in generated pubspec| |null|
|
||||
|pubVersion|Version in generated pubspec| |null|
|
||||
|pubDescription|Description in generated pubspec| |null|
|
||||
|useEnumExtension|Allow the 'x-enum-values' extension for enums| |null|
|
||||
|sourceFolder|source folder for generated code| |null|
|
||||
|supportDart2|support dart2| |true|
|
||||
|sourceFolder|Source folder for generated code| |null|
|
||||
|supportDart2|Support Dart 2.x| |true|
|
||||
|
||||
@@ -13,4 +13,5 @@ sidebar_label: go-experimental
|
||||
|isGoSubmodule|whether the generated Go module is a submodule| |false|
|
||||
|withGoCodegenComment|whether to include Go codegen comment to disable Go Lint and collapse by default GitHub in PRs and diffs| |false|
|
||||
|withXml|whether to include support for application/xml content type and include XML annotations in the model (works with libraries that provide support for JSON and XML)| |false|
|
||||
|enumClassPrefix|Prefix enum with class name| |false|
|
||||
|prependFormOrBodyParameters|Add form or body parameters to the beginning of the parameter list.| |false|
|
||||
|
||||
@@ -13,4 +13,5 @@ sidebar_label: go
|
||||
|isGoSubmodule|whether the generated Go module is a submodule| |false|
|
||||
|withGoCodegenComment|whether to include Go codegen comment to disable Go Lint and collapse by default GitHub in PRs and diffs| |false|
|
||||
|withXml|whether to include support for application/xml content type and include XML annotations in the model (works with libraries that provide support for JSON and XML)| |false|
|
||||
|enumClassPrefix|Prefix enum with class name| |false|
|
||||
|prependFormOrBodyParameters|Add form or body parameters to the beginning of the parameter list.| |false|
|
||||
|
||||
@@ -19,3 +19,4 @@ sidebar_label: typescript-fetch
|
||||
|npmRepository|Use this property to set an url your private npmRepo in the package.json| |null|
|
||||
|withInterfaces|Setting this property to true will generate interfaces next to the default class implementations.| |false|
|
||||
|useSingleRequestParameter|Setting this property to true will generate functions with a single argument containing all API endpoint parameters instead of one argument per parameter.| |true|
|
||||
|namespaceParameterInterfaces|Setting this property to true will generate parameter interface declarations within a dedicated namespace to avoid name conflicts.| |false|
|
||||
|
||||
@@ -3,7 +3,7 @@ id: swagger-codegen-migration
|
||||
title: Migrating from Swagger Codegen
|
||||
---
|
||||
|
||||
OpenAPI Generator is a fork of `swagger-codegen` between version `2.3.1` and `2.4.0`.
|
||||
OpenAPI Generator is a fork of `swagger-codegen` between version `2.3.1` and `2.4.0`. For the reasons behind the fork, please refer to the [Q&A](https://github.com/OpenAPITools/openapi-generator/blob/master/docs/qna.md).
|
||||
This community-driven version called "OpenAPI Generator" provides similar functionalities and can be used as drop-in replacement.
|
||||
This guide explains the major differences in order to help you with the migration.
|
||||
|
||||
@@ -22,6 +22,7 @@ This guide explains the major differences in order to help you with the migratio
|
||||
- [New fully qualified name for the classes](#new-fully-qualified-name-for-the-classes)
|
||||
- [Body parameter name](#body-parameter-name)
|
||||
- [Default basePath](#default-basepath)
|
||||
- [Nullable](#nullable)
|
||||
|
||||
## New docker images
|
||||
|
||||
@@ -250,3 +251,7 @@ If your API client is using named parameters in the function call (e.g. Perl req
|
||||
## Default basePath
|
||||
|
||||
The default `basePath` has been changed from `https://localhost` to `http://localhost` (http without s)
|
||||
|
||||
## Nullable
|
||||
|
||||
OpenAPI spec v3 has better support for `nullable`. If you're still using OpenAPI/Swagger spec v2, please use `x-nullable: true` instead.
|
||||
|
||||
@@ -38,9 +38,15 @@ NAME
|
||||
openapi-generator-cli list - Lists the available generators
|
||||
|
||||
SYNOPSIS
|
||||
openapi-generator-cli list [(-s | --short)]
|
||||
openapi-generator-cli list [(-i <include> | --include <include>)]
|
||||
[(-s | --short)]
|
||||
|
||||
OPTIONS
|
||||
-i <include>, --include <include>
|
||||
comma-separated list of stability indexes to include (value:
|
||||
all,beta,stable,experimental,deprecated). Excludes deprecated by
|
||||
default.
|
||||
|
||||
-s, --short
|
||||
shortened output (suitable for scripting)
|
||||
|
||||
@@ -210,13 +216,14 @@ This command takes one or more parameters representing the args list you would o
|
||||
|
||||
```bash
|
||||
openapi-generator completion config-help
|
||||
--named-header
|
||||
-o
|
||||
--output
|
||||
--named-header
|
||||
-g
|
||||
--generator-name
|
||||
-l
|
||||
--lang
|
||||
-f
|
||||
--format
|
||||
--markdown-header
|
||||
```
|
||||
|
||||
An example bash completion script can be found in the repo at [scripts/openapi-generator-cli-completion.bash](https://github.com/OpenAPITools/openapi-generator/blob/master/scripts/openapi-generator-cli-completion.bash).
|
||||
@@ -235,7 +242,6 @@ NAME
|
||||
SYNOPSIS
|
||||
openapi-generator-cli generate
|
||||
[(-a <authorization> | --auth <authorization>)]
|
||||
[--additional-properties <additional properties>...]
|
||||
[--api-package <api package>] [--artifact-id <artifact id>]
|
||||
[--artifact-version <artifact version>]
|
||||
[(-c <configuration file> | --config <configuration file>)]
|
||||
@@ -257,14 +263,14 @@ SYNOPSIS
|
||||
[--model-name-suffix <model name suffix>]
|
||||
[--model-package <model package>]
|
||||
[(-o <output directory> | --output <output directory>)]
|
||||
[(-p <additional properties> | --additional-properties <additional properties>)...]
|
||||
[--package-name <package name>] [--release-note <release note>]
|
||||
[--remove-operation-id-prefix]
|
||||
[--reserved-words-mappings <reserved word mappings>...]
|
||||
[(-s | --skip-overwrite)] [--skip-validate-spec]
|
||||
[--strict-spec <true/false strict behavior>]
|
||||
[(-s | --skip-overwrite)] [--server-variables <server variables>...]
|
||||
[--skip-validate-spec] [--strict-spec <true/false strict behavior>]
|
||||
[(-t <template directory> | --template-dir <template directory>)]
|
||||
[--type-mappings <type mappings>...] [(-v | --verbose)]
|
||||
|
||||
```
|
||||
|
||||
<details>
|
||||
@@ -277,19 +283,16 @@ OPTIONS
|
||||
remotely. Pass in a URL-encoded string of name:header with a comma
|
||||
separating multiple values
|
||||
|
||||
--additional-properties <additional properties>
|
||||
sets additional properties that can be referenced by the mustache
|
||||
templates in the format of name=value,name=value. You can also have
|
||||
multiple occurrences of this option.
|
||||
|
||||
--api-package <api package>
|
||||
package for generated api classes
|
||||
|
||||
--artifact-id <artifact id>
|
||||
artifactId in generated pom.xml
|
||||
artifactId in generated pom.xml. This also becomes part of the
|
||||
generated library's filename
|
||||
|
||||
--artifact-version <artifact version>
|
||||
artifact version in generated pom.xml
|
||||
artifact version in generated pom.xml. This also becomes part of the
|
||||
generated library's filename
|
||||
|
||||
-c <configuration file>, --config <configuration file>
|
||||
Path to configuration file configuration file. It can be json or
|
||||
@@ -382,6 +385,12 @@ OPTIONS
|
||||
-o <output directory>, --output <output directory>
|
||||
where to write the generated files (current dir by default)
|
||||
|
||||
-p <additional properties>, --additional-properties <additional
|
||||
properties>
|
||||
sets additional properties that can be referenced by the mustache
|
||||
templates in the format of name=value,name=value. You can also have
|
||||
multiple occurrences of this option.
|
||||
|
||||
--package-name <package name>
|
||||
package for generated classes (where supported)
|
||||
|
||||
@@ -400,6 +409,10 @@ OPTIONS
|
||||
specifies if the existing files should be overwritten during the
|
||||
generation.
|
||||
|
||||
--server-variables <server variables>
|
||||
sets server variables for spec documents which support variable
|
||||
templating of servers.
|
||||
|
||||
--skip-validate-spec
|
||||
Skips the default behavior of validating an input specification.
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
<groupId>org.openapitools</groupId>
|
||||
<artifactId>openapi-generator-project</artifactId>
|
||||
<!-- RELEASE_VERSION -->
|
||||
<version>4.1.0</version>
|
||||
<version>4.1.1-SNAPSHOT</version>
|
||||
<!-- /RELEASE_VERSION -->
|
||||
<relativePath>../..</relativePath>
|
||||
</parent>
|
||||
|
||||
@@ -18,13 +18,7 @@
|
||||
package org.openapitools.codegen.cmd;
|
||||
|
||||
import static org.apache.commons.lang3.StringUtils.isNotEmpty;
|
||||
import static org.openapitools.codegen.config.CodegenConfiguratorUtils.applyAdditionalPropertiesKvpList;
|
||||
import static org.openapitools.codegen.config.CodegenConfiguratorUtils.applyImportMappingsKvpList;
|
||||
import static org.openapitools.codegen.config.CodegenConfiguratorUtils.applyInstantiationTypesKvpList;
|
||||
import static org.openapitools.codegen.config.CodegenConfiguratorUtils.applyLanguageSpecificPrimitivesCsvList;
|
||||
import static org.openapitools.codegen.config.CodegenConfiguratorUtils.applyReservedWordsMappingsKvpList;
|
||||
import static org.openapitools.codegen.config.CodegenConfiguratorUtils.applySystemPropertiesKvpList;
|
||||
import static org.openapitools.codegen.config.CodegenConfiguratorUtils.applyTypeMappingsKvpList;
|
||||
import static org.openapitools.codegen.config.CodegenConfiguratorUtils.*;
|
||||
|
||||
import ch.qos.logback.classic.LoggerContext;
|
||||
import ch.qos.logback.core.spi.FilterAttachable;
|
||||
@@ -160,6 +154,12 @@ public class Generate implements Runnable {
|
||||
+ " You can also have multiple occurrences of this option.")
|
||||
private List<String> importMappings = new ArrayList<>();
|
||||
|
||||
@Option(
|
||||
name = {"--server-variables"},
|
||||
title = "server variables",
|
||||
description = "sets server variables overrides for spec documents which support variable templating of servers.")
|
||||
private List<String> serverVariableOverrides = new ArrayList<>();
|
||||
|
||||
@Option(name = {"--invoker-package"}, title = "invoker package",
|
||||
description = CodegenConstants.INVOKER_PACKAGE_DESC)
|
||||
private String invokerPackage;
|
||||
@@ -393,6 +393,7 @@ public class Generate implements Runnable {
|
||||
applyAdditionalPropertiesKvpList(additionalProperties, configurator);
|
||||
applyLanguageSpecificPrimitivesCsvList(languageSpecificPrimitives, configurator);
|
||||
applyReservedWordsMappingsKvpList(reservedWordsMappings, configurator);
|
||||
applyServerVariablesKvpList(serverVariableOverrides, configurator);
|
||||
|
||||
try {
|
||||
final ClientOptInput clientOptInput = configurator.toClientOptInput();
|
||||
|
||||
@@ -5,15 +5,14 @@ import com.google.common.base.Objects;
|
||||
import io.airlift.airline.Command;
|
||||
import io.airlift.airline.Option;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.openapitools.codegen.CodegenConfig;
|
||||
import org.openapitools.codegen.CodegenConfigLoader;
|
||||
import org.openapitools.codegen.CodegenType;
|
||||
import org.openapitools.codegen.meta.GeneratorMetadata;
|
||||
import org.openapitools.codegen.meta.Stability;
|
||||
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
// NOTE: List can later have subcommands such as list languages, list types, list frameworks, etc.
|
||||
@@ -26,9 +25,31 @@ public class ListGenerators implements Runnable {
|
||||
@Option(name = {"-d", "--docsite" }, description = "format for docusaurus site output", hidden = true)
|
||||
private Boolean docusaurus = false;
|
||||
|
||||
@Option(name = {"-i", "--include" },
|
||||
description = "comma-separated list of stability indexes to include (value: all,beta,stable,experimental,deprecated). Excludes deprecated by default.",
|
||||
allowedValues = { "all", "beta", "stable", "experimental", "deprecated" })
|
||||
private String include = "stable,beta,experimental";
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
List<CodegenConfig> generators = CodegenConfigLoader.getAll();
|
||||
List<CodegenConfig> generators = new ArrayList<>();
|
||||
List<Stability> stabilities = Arrays.asList(Stability.values());
|
||||
|
||||
if (!StringUtils.isEmpty(include)) {
|
||||
List<String> includes = Arrays.asList(include.split(","));
|
||||
if (includes.size() != 0 && !includes.contains("all")) {
|
||||
stabilities = includes.stream()
|
||||
.map(Stability::forDescription)
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
}
|
||||
|
||||
for (CodegenConfig codegenConfig : CodegenConfigLoader.getAll()) {
|
||||
GeneratorMetadata meta = codegenConfig.getGeneratorMetadata();
|
||||
if (meta != null && stabilities.contains(meta.getStability())) {
|
||||
generators.add(codegenConfig);
|
||||
}
|
||||
}
|
||||
|
||||
StringBuilder sb = new StringBuilder();
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
<artifactId>openapi-generator-project</artifactId>
|
||||
<groupId>org.openapitools</groupId>
|
||||
<!-- RELEASE_VERSION -->
|
||||
<version>4.1.0</version>
|
||||
<version>4.1.1-SNAPSHOT</version>
|
||||
<!-- /RELEASE_VERSION -->
|
||||
<relativePath>../..</relativePath>
|
||||
</parent>
|
||||
|
||||
@@ -52,6 +52,7 @@ public final class GeneratorSettings implements Serializable {
|
||||
private ImmutableMap<String, String> importMappings;
|
||||
private ImmutableSet<String> languageSpecificPrimitives;
|
||||
private ImmutableMap<String, String> reservedWordMappings;
|
||||
private ImmutableMap<String, String> serverVariables;
|
||||
|
||||
private String gitUserId;
|
||||
private String gitRepoId;
|
||||
@@ -245,6 +246,17 @@ public final class GeneratorSettings implements Serializable {
|
||||
return reservedWordMappings;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Gets server variable. Values defined here will be attempted to be replaced within a templated server object.
|
||||
*
|
||||
* @return the server variables
|
||||
*/
|
||||
public Map<String, String> getServerVariables() {
|
||||
return serverVariables;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Gets git user id. e.g. <strong>openapitools</strong>.
|
||||
* <p>
|
||||
@@ -311,6 +323,7 @@ public final class GeneratorSettings implements Serializable {
|
||||
importMappings = ImmutableMap.copyOf(builder.importMappings);
|
||||
languageSpecificPrimitives = ImmutableSet.copyOf(builder.languageSpecificPrimitives);
|
||||
reservedWordMappings = ImmutableMap.copyOf(builder.reservedWordMappings);
|
||||
serverVariables = ImmutableMap.copyOf(builder.serverVariables);
|
||||
gitUserId = builder.gitUserId;
|
||||
gitRepoId = builder.gitRepoId;
|
||||
releaseNote = builder.releaseNote;
|
||||
@@ -373,6 +386,7 @@ public final class GeneratorSettings implements Serializable {
|
||||
importMappings = ImmutableMap.of();
|
||||
languageSpecificPrimitives = ImmutableSet.of();
|
||||
reservedWordMappings = ImmutableMap.of();
|
||||
serverVariables = ImmutableMap.of();
|
||||
}
|
||||
|
||||
private void setDefaults() {
|
||||
@@ -394,12 +408,6 @@ public final class GeneratorSettings implements Serializable {
|
||||
return new Builder();
|
||||
}
|
||||
|
||||
/**
|
||||
* New builder builder.
|
||||
*
|
||||
* @param copy the copy
|
||||
* @return the builder
|
||||
*/
|
||||
public static Builder newBuilder(GeneratorSettings copy) {
|
||||
Builder builder = new Builder();
|
||||
builder.generatorName = copy.getGeneratorName();
|
||||
@@ -419,6 +427,7 @@ public final class GeneratorSettings implements Serializable {
|
||||
builder.importMappings = new HashMap<>(copy.getImportMappings());
|
||||
builder.languageSpecificPrimitives = new HashSet<>(copy.getLanguageSpecificPrimitives());
|
||||
builder.reservedWordMappings = new HashMap<>(copy.getReservedWordMappings());
|
||||
builder.serverVariables = new HashMap<>(copy.getServerVariables());
|
||||
builder.gitUserId = copy.getGitUserId();
|
||||
builder.gitRepoId = copy.getGitRepoId();
|
||||
builder.releaseNote = copy.getReleaseNote();
|
||||
@@ -449,6 +458,7 @@ public final class GeneratorSettings implements Serializable {
|
||||
private Map<String, String> importMappings;
|
||||
private Set<String> languageSpecificPrimitives;
|
||||
private Map<String, String> reservedWordMappings;
|
||||
private Map<String, String> serverVariables;
|
||||
private String gitUserId;
|
||||
private String gitRepoId;
|
||||
private String releaseNote;
|
||||
@@ -464,6 +474,7 @@ public final class GeneratorSettings implements Serializable {
|
||||
importMappings = new HashMap<>();
|
||||
languageSpecificPrimitives = new HashSet<>();
|
||||
reservedWordMappings = new HashMap<>();
|
||||
serverVariables = new HashMap<>();
|
||||
|
||||
gitUserId = DEFAULT_GIT_USER_ID;
|
||||
gitRepoId = DEFAULT_GIT_REPO_ID;
|
||||
@@ -617,6 +628,17 @@ public final class GeneratorSettings implements Serializable {
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the {@code serverVariables} and returns a reference to this Builder so that the methods can be chained together.
|
||||
*
|
||||
* @param serverVariables the {@code serverVariables} to set
|
||||
* @return a reference to this Builder
|
||||
*/
|
||||
public Builder withServerVariables(Map<String, String> serverVariables) {
|
||||
this.serverVariables = serverVariables;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the {@code typeMappings} and returns a reference to this Builder so that the methods can be chained together.
|
||||
*
|
||||
@@ -731,6 +753,22 @@ public final class GeneratorSettings implements Serializable {
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Sets a single {@code serverVariables} and returns a reference to this Builder so that the methods can be chained together.
|
||||
*
|
||||
* @param key A key for some server variable
|
||||
* @param value The value of some server variable to be replaced in a templated server object.
|
||||
* @return a reference to this Builder
|
||||
*/
|
||||
public Builder withServerVariable(String key, String value) {
|
||||
if (this.serverVariables == null) {
|
||||
this.serverVariables = new HashMap<>();
|
||||
}
|
||||
this.serverVariables.put(key, value);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the {@code gitUserId} and returns a reference to this Builder so that the methods can be chained together.
|
||||
*
|
||||
|
||||
@@ -50,4 +50,14 @@ public enum Stability {
|
||||
* @return The descriptive value of this enum.
|
||||
*/
|
||||
public String value() { return description; }
|
||||
|
||||
public static Stability forDescription(String description) {
|
||||
for (Stability value: values()) {
|
||||
if (value.description.equals(description)) {
|
||||
return value;
|
||||
}
|
||||
}
|
||||
|
||||
throw new IllegalArgumentException("description not found in the available values.");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -374,6 +374,18 @@ openApiGenerate {
|
||||
|
||||
|===
|
||||
|
||||
=== openApiGenerators
|
||||
|
||||
.Options
|
||||
|===
|
||||
|Key |Data Type |Default |Description
|
||||
|
||||
|include
|
||||
|String[]
|
||||
|None
|
||||
|A list of stability indexes to include (values: all,beta,stable,experimental,deprecated). Excludes deprecated by default.
|
||||
|
||||
|===
|
||||
|
||||
== Examples
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
buildscript {
|
||||
ext.kotlin_version = '1.2.61'
|
||||
repositories {
|
||||
mavenLocal()
|
||||
mavenCentral()
|
||||
maven {
|
||||
url "https://plugins.gradle.org/m2/"
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
# RELEASE_VERSION
|
||||
openApiGeneratorVersion=4.1.0
|
||||
openApiGeneratorVersion=4.1.1-SNAPSHOT
|
||||
# /RELEASE_VERSION
|
||||
|
||||
# BEGIN placeholders
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
<groupId>org.openapitools</groupId>
|
||||
<artifactId>openapi-generator-project</artifactId>
|
||||
<!-- RELEASE_VERSION -->
|
||||
<version>4.1.0</version>
|
||||
<version>4.1.1-SNAPSHOT</version>
|
||||
<!-- /RELEASE_VERSION -->
|
||||
<relativePath>../..</relativePath>
|
||||
</parent>
|
||||
|
||||
@@ -19,6 +19,7 @@ package org.openapitools.generator.gradle.plugin
|
||||
import org.gradle.api.Plugin
|
||||
import org.gradle.api.Project
|
||||
import org.openapitools.generator.gradle.plugin.extensions.OpenApiGeneratorGenerateExtension
|
||||
import org.openapitools.generator.gradle.plugin.extensions.OpenApiGeneratorGeneratorsExtension
|
||||
import org.openapitools.generator.gradle.plugin.extensions.OpenApiGeneratorMetaExtension
|
||||
import org.openapitools.generator.gradle.plugin.extensions.OpenApiGeneratorValidateExtension
|
||||
import org.openapitools.generator.gradle.plugin.tasks.GenerateTask
|
||||
@@ -53,12 +54,20 @@ class OpenApiGeneratorPlugin : Plugin<Project> {
|
||||
project
|
||||
)
|
||||
|
||||
val generators = extensions.create(
|
||||
"openApiGenerators",
|
||||
OpenApiGeneratorGeneratorsExtension::class.java,
|
||||
project
|
||||
)
|
||||
|
||||
generate.outputDir.set("$buildDir/generate-resources/main")
|
||||
|
||||
tasks.apply {
|
||||
create("openApiGenerators", GeneratorsTask::class.java) {
|
||||
group = pluginGroup
|
||||
description = "Lists generators available via Open API Generators."
|
||||
|
||||
include.set(generators.include)
|
||||
}
|
||||
|
||||
create("openApiMeta", MetaTask::class.java) {
|
||||
@@ -99,6 +108,7 @@ class OpenApiGeneratorPlugin : Plugin<Project> {
|
||||
instantiationTypes.set(generate.instantiationTypes)
|
||||
typeMappings.set(generate.typeMappings)
|
||||
additionalProperties.set(generate.additionalProperties)
|
||||
serverVariables.set(generate.serverVariables)
|
||||
languageSpecificPrimitives.set(generate.languageSpecificPrimitives)
|
||||
importMappings.set(generate.importMappings)
|
||||
invokerPackage.set(generate.invokerPackage)
|
||||
|
||||
@@ -120,6 +120,11 @@ open class OpenApiGeneratorGenerateExtension(project: Project) {
|
||||
*/
|
||||
val additionalProperties = project.objects.property<Map<String, String>>()
|
||||
|
||||
/**
|
||||
* Sets server variable for server URL template substitution, in the format of name=value,name=value.
|
||||
*/
|
||||
val serverVariables = project.objects.property<Map<String, String>>()
|
||||
|
||||
/**
|
||||
* Specifies additional language specific primitive types in the format of type1,type2,type3,type3. For example: String,boolean,Boolean,Double.
|
||||
*/
|
||||
|
||||
@@ -0,0 +1,43 @@
|
||||
/*
|
||||
* Copyright 2019 OpenAPI-Generator Contributors (https://openapi-generator.tech)
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.openapitools.generator.gradle.plugin.extensions
|
||||
|
||||
import org.gradle.api.Project
|
||||
import org.gradle.api.tasks.Internal
|
||||
import org.gradle.kotlin.dsl.listProperty
|
||||
import org.openapitools.codegen.meta.Stability
|
||||
|
||||
/**
|
||||
* Gradle project level extension object definition for the generators task
|
||||
*
|
||||
* @author Jim Schubert
|
||||
*/
|
||||
open class OpenApiGeneratorGeneratorsExtension(project: Project) {
|
||||
/**
|
||||
* A list of stability indexes to include (value: all,beta,stable,experimental,deprecated). Excludes deprecated by default.
|
||||
*/
|
||||
val include = project.objects.listProperty<String>()
|
||||
|
||||
init {
|
||||
applyDefaults()
|
||||
}
|
||||
|
||||
@Suppress("MemberVisibilityCanBePrivate")
|
||||
fun applyDefaults(){
|
||||
include.set(Stability.values().map { s -> s.value() }.filterNot { it == Stability.DEPRECATED.value() })
|
||||
}
|
||||
}
|
||||
@@ -155,6 +155,13 @@ open class GenerateTask : DefaultTask() {
|
||||
@get:Internal
|
||||
val additionalProperties = project.objects.property<Map<String, String>>()
|
||||
|
||||
/**
|
||||
* Sets server variable for server URL template substitution, in the format of name=value,name=value.
|
||||
* You can also have multiple occurrences of this option.
|
||||
*/
|
||||
@get:Internal
|
||||
val serverVariables = project.objects.property<Map<String, String>>()
|
||||
|
||||
/**
|
||||
* Specifies additional language specific primitive types in the format of type1,type2,type3,type3. For example: String,boolean,Boolean,Double.
|
||||
*/
|
||||
@@ -573,6 +580,12 @@ open class GenerateTask : DefaultTask() {
|
||||
}
|
||||
}
|
||||
|
||||
if (serverVariables.isPresent) {
|
||||
serverVariables.get().forEach { entry ->
|
||||
configurator.addServerVariable(entry.key, entry.value)
|
||||
}
|
||||
}
|
||||
|
||||
if (languageSpecificPrimitives.isPresent) {
|
||||
languageSpecificPrimitives.get().forEach {
|
||||
configurator.addLanguageSpecificPrimitive(it)
|
||||
|
||||
@@ -17,9 +17,11 @@
|
||||
package org.openapitools.generator.gradle.plugin.tasks
|
||||
|
||||
import org.gradle.api.DefaultTask
|
||||
import org.gradle.api.tasks.Internal
|
||||
import org.gradle.api.tasks.TaskAction
|
||||
import org.gradle.internal.logging.text.StyledTextOutput
|
||||
import org.gradle.internal.logging.text.StyledTextOutputFactory
|
||||
import org.gradle.kotlin.dsl.listProperty
|
||||
import org.openapitools.codegen.CodegenConfigLoader
|
||||
import org.openapitools.codegen.CodegenType
|
||||
import org.openapitools.codegen.meta.GeneratorMetadata
|
||||
@@ -35,6 +37,12 @@ import org.openapitools.codegen.meta.Stability
|
||||
* @author Jim Schubert
|
||||
*/
|
||||
open class GeneratorsTask : DefaultTask() {
|
||||
/**
|
||||
* A list of stability indexes to include (value: all,beta,stable,experimental,deprecated). Excludes deprecated by default.
|
||||
*/
|
||||
@get:Internal
|
||||
val include = project.objects.listProperty<String>()
|
||||
|
||||
@Suppress("unused")
|
||||
@TaskAction
|
||||
fun doWork() {
|
||||
@@ -45,6 +53,15 @@ open class GeneratorsTask : DefaultTask() {
|
||||
StringBuilder().apply {
|
||||
val types = CodegenType.values()
|
||||
|
||||
val stabilities = if (include.isPresent) {
|
||||
when {
|
||||
include.get().contains("all") -> Stability.values().toList()
|
||||
else -> include.get().map { Stability.forDescription(it) }
|
||||
}
|
||||
} else {
|
||||
Stability.values().filterNot { it == Stability.DEPRECATED }
|
||||
}
|
||||
|
||||
append("The following generators are available:")
|
||||
|
||||
append(System.lineSeparator())
|
||||
@@ -56,21 +73,23 @@ open class GeneratorsTask : DefaultTask() {
|
||||
|
||||
generators.filter { it.tag == type }
|
||||
.sortedBy { it.name }
|
||||
.forEach({ generator ->
|
||||
.forEach { generator ->
|
||||
|
||||
val meta: GeneratorMetadata? = generator.generatorMetadata
|
||||
val include = stabilities.contains(meta?.stability)
|
||||
if (include) {
|
||||
append(" - ")
|
||||
append(generator.name)
|
||||
|
||||
append(" - ")
|
||||
append(generator.name)
|
||||
|
||||
meta?.stability?.let {
|
||||
if (it != Stability.STABLE) {
|
||||
append(" (${it.value()})")
|
||||
meta?.stability?.let {
|
||||
if (it != Stability.STABLE) {
|
||||
append(" (${it.value()})")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
append(System.lineSeparator())
|
||||
})
|
||||
append(System.lineSeparator())
|
||||
}
|
||||
}
|
||||
|
||||
append(System.lineSeparator())
|
||||
append(System.lineSeparator())
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
<groupId>org.openapitools</groupId>
|
||||
<artifactId>openapi-generator-maven-plugin</artifactId>
|
||||
<!-- RELEASE_VERSION -->
|
||||
<version>4.1.0</version>
|
||||
<version>4.1.1-SNAPSHOT</version>
|
||||
<!-- /RELEASE_VERSION -->
|
||||
<executions>
|
||||
<execution>
|
||||
@@ -120,7 +120,12 @@
|
||||
<groupId>com.fasterxml.jackson.jaxrs</groupId>
|
||||
<artifactId>jackson-jaxrs-json-provider</artifactId>
|
||||
<version>${jackson-version}</version>
|
||||
</dependency>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.openapitools</groupId>
|
||||
<artifactId>jackson-databind-nullable</artifactId>
|
||||
<version>${jackson-databind-nullable-version}</version>
|
||||
</dependency>
|
||||
|
||||
<!-- Joda time: if you use it -->
|
||||
<dependency>
|
||||
@@ -146,6 +151,7 @@
|
||||
<swagger-annotations-version>1.5.8</swagger-annotations-version>
|
||||
<jersey-version>2.27</jersey-version>
|
||||
<jackson-version>2.8.9</jackson-version>
|
||||
<jackson-databind-nullable-version>0.2.0</jackson-databind-nullable-version>
|
||||
<jodatime-version>2.7</jodatime-version>
|
||||
<maven-plugin-version>1.0.0</maven-plugin-version>
|
||||
<junit-version>4.8.1</junit-version>
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
<groupId>org.openapitools</groupId>
|
||||
<artifactId>openapi-generator-maven-plugin</artifactId>
|
||||
<!-- RELEASE_VERSION -->
|
||||
<version>4.1.0</version>
|
||||
<version>4.1.1-SNAPSHOT</version>
|
||||
<!-- /RELEASE_VERSION -->
|
||||
<dependencies>
|
||||
<dependency>
|
||||
@@ -133,7 +133,12 @@
|
||||
<groupId>com.fasterxml.jackson.jaxrs</groupId>
|
||||
<artifactId>jackson-jaxrs-json-provider</artifactId>
|
||||
<version>${jackson-version}</version>
|
||||
</dependency>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.openapitools</groupId>
|
||||
<artifactId>jackson-databind-nullable</artifactId>
|
||||
<version>${jackson-databind-nullable-version}</version>
|
||||
</dependency>
|
||||
|
||||
<!-- Joda time: if you use it -->
|
||||
<dependency>
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
<swagger-annotations-version>1.5.8</swagger-annotations-version>
|
||||
<jersey-version>2.27</jersey-version>
|
||||
<jackson-version>2.8.9</jackson-version>
|
||||
<jackson-databind-nullable-version>0.2.0</jackson-databind-nullable-version>
|
||||
<jodatime-version>2.7</jodatime-version>
|
||||
<maven-plugin-version>1.0.0</maven-plugin-version>
|
||||
<junit-version>4.8.1</junit-version>
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
<groupId>org.openapitools</groupId>
|
||||
<artifactId>openapi-generator-project</artifactId>
|
||||
<!-- RELEASE_VERSION -->
|
||||
<version>4.1.0</version>
|
||||
<version>4.1.1-SNAPSHOT</version>
|
||||
<!-- /RELEASE_VERSION -->
|
||||
<relativePath>../..</relativePath>
|
||||
</parent>
|
||||
|
||||
@@ -17,19 +17,8 @@
|
||||
|
||||
package org.openapitools.codegen.plugin;
|
||||
|
||||
import static org.openapitools.codegen.config.CodegenConfiguratorUtils.applyAdditionalPropertiesKvp;
|
||||
import static org.openapitools.codegen.config.CodegenConfiguratorUtils.applyImportMappingsKvp;
|
||||
import static org.openapitools.codegen.config.CodegenConfiguratorUtils.applyInstantiationTypesKvp;
|
||||
import static org.openapitools.codegen.config.CodegenConfiguratorUtils.applyLanguageSpecificPrimitivesCsv;
|
||||
import static org.openapitools.codegen.config.CodegenConfiguratorUtils.applyTypeMappingsKvp;
|
||||
import static org.openapitools.codegen.config.CodegenConfiguratorUtils.applyReservedWordsMappingsKvp;
|
||||
import static org.openapitools.codegen.config.CodegenConfiguratorUtils.applyAdditionalPropertiesKvpList;
|
||||
import static org.openapitools.codegen.config.CodegenConfiguratorUtils.applyImportMappingsKvpList;
|
||||
import static org.openapitools.codegen.config.CodegenConfiguratorUtils.applyInstantiationTypesKvpList;
|
||||
import static org.openapitools.codegen.config.CodegenConfiguratorUtils.applyLanguageSpecificPrimitivesCsvList;
|
||||
import static org.openapitools.codegen.config.CodegenConfiguratorUtils.applyTypeMappingsKvpList;
|
||||
import static org.openapitools.codegen.config.CodegenConfiguratorUtils.applyReservedWordsMappingsKvpList;
|
||||
import static org.apache.commons.lang3.StringUtils.isNotEmpty;
|
||||
import static org.openapitools.codegen.config.CodegenConfiguratorUtils.*;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.HashMap;
|
||||
@@ -289,6 +278,12 @@ public class CodeGenMojo extends AbstractMojo {
|
||||
@Parameter(name = "additionalProperties", property = "openapi.generator.maven.plugin.additionalProperties")
|
||||
private List<String> additionalProperties;
|
||||
|
||||
/**
|
||||
* A map of server variable overrides for specs that support server URL templating
|
||||
*/
|
||||
@Parameter(name = "serverVariableOverrides", property = "openapi.generator.maven.plugin.serverVariableOverrides")
|
||||
private List<String> serverVariableOverrides;
|
||||
|
||||
/**
|
||||
* A map of reserved names and how they should be escaped
|
||||
*/
|
||||
@@ -615,6 +610,10 @@ public class CodeGenMojo extends AbstractMojo {
|
||||
configurator);
|
||||
}
|
||||
|
||||
if (serverVariableOverrides == null && configOptions.containsKey("server-variables")) {
|
||||
applyServerVariablesKvp(configOptions.get("server-variables").toString(), configurator);
|
||||
}
|
||||
|
||||
// Retained for backwards-compataibility with configOptions -> reserved-words-mappings
|
||||
if (reservedWordsMappings == null && configOptions.containsKey("reserved-words-mappings")) {
|
||||
applyReservedWordsMappingsKvp(configOptions.get("reserved-words-mappings")
|
||||
@@ -648,6 +647,10 @@ public class CodeGenMojo extends AbstractMojo {
|
||||
applyAdditionalPropertiesKvpList(additionalProperties, configurator);
|
||||
}
|
||||
|
||||
if (serverVariableOverrides != null && (configOptions == null || !configOptions.containsKey("server-variables"))) {
|
||||
applyServerVariablesKvpList(serverVariableOverrides, configurator);
|
||||
}
|
||||
|
||||
// Apply Reserved Words Mappings
|
||||
if (reservedWordsMappings != null && (configOptions == null || !configOptions.containsKey("reserved-words-mappings"))) {
|
||||
applyReservedWordsMappingsKvpList(reservedWordsMappings, configurator);
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
<groupId>org.openapitools</groupId>
|
||||
<artifactId>openapi-generator-project</artifactId>
|
||||
<!-- RELEASE_VERSION -->
|
||||
<version>4.1.0</version>
|
||||
<version>4.1.1-SNAPSHOT</version>
|
||||
<!-- /RELEASE_VERSION -->
|
||||
<relativePath>../..</relativePath>
|
||||
</parent>
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
<groupId>org.openapitools</groupId>
|
||||
<artifactId>openapi-generator-project</artifactId>
|
||||
<!-- RELEASE_VERSION -->
|
||||
<version>4.1.0</version>
|
||||
<version>4.1.1-SNAPSHOT</version>
|
||||
<!-- /RELEASE_VERSION -->
|
||||
<relativePath>../..</relativePath>
|
||||
</parent>
|
||||
@@ -268,6 +268,12 @@
|
||||
<!-- <version>${testng-version}</version> -->
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.github.javaparser</groupId>
|
||||
<artifactId>javaparser-core</artifactId>
|
||||
<version>3.14.11</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.reflections</groupId>
|
||||
<artifactId>reflections</artifactId>
|
||||
|
||||
@@ -43,6 +43,8 @@ public interface CodegenConfig {
|
||||
|
||||
Map<String, Object> additionalProperties();
|
||||
|
||||
Map<String, String> serverVariableOverrides();
|
||||
|
||||
Map<String, Object> vendorExtensions();
|
||||
|
||||
String testPackage();
|
||||
|
||||
@@ -308,4 +308,7 @@ public class CodegenConstants {
|
||||
|
||||
public static final String EXCEPTION_ON_FAILURE = "returnExceptionOnFailure";
|
||||
public static final String EXCEPTION_ON_FAILURE_DESC = "Throw an exception on non success response codes";
|
||||
|
||||
public static final String ENUM_CLASS_PREFIX = "enumClassPrefix";
|
||||
public static final String ENUM_CLASS_PREFIX_DESC = "Prefix enum with class name";
|
||||
}
|
||||
|
||||
@@ -7,4 +7,5 @@ public class CodegenServerVariable {
|
||||
public String defaultValue;
|
||||
public String description;
|
||||
public List<String> enumValues;
|
||||
public String value;
|
||||
}
|
||||
|
||||
@@ -97,6 +97,7 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
protected String embeddedTemplateDir;
|
||||
protected String commonTemplateDir = "_common";
|
||||
protected Map<String, Object> additionalProperties = new HashMap<String, Object>();
|
||||
protected Map<String, String> serverVariables = new HashMap<String, String>();
|
||||
protected Map<String, Object> vendorExtensions = new HashMap<String, Object>();
|
||||
protected List<SupportingFile> supportingFiles = new ArrayList<SupportingFile>();
|
||||
protected List<CliOption> cliOptions = new ArrayList<CliOption>();
|
||||
@@ -240,13 +241,10 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
}
|
||||
|
||||
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);
|
||||
LOGGER.error("A property called 'lambda' already exists in additionalProperties");
|
||||
throw new RuntimeException("A property called 'lambda' already exists in additionalProperties");
|
||||
}
|
||||
additionalProperties.put("lambda", lambdas);
|
||||
}
|
||||
|
||||
// override with any special post-processing for all models
|
||||
@@ -506,12 +504,12 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
public void postProcessParameter(CodegenParameter parameter) {
|
||||
}
|
||||
|
||||
//override with any special handling of the entire swagger spec
|
||||
//override with any special handling of the entire OpenAPI spec document
|
||||
@SuppressWarnings("unused")
|
||||
public void preprocessOpenAPI(OpenAPI openAPI) {
|
||||
}
|
||||
|
||||
// override with any special handling of the entire swagger spec
|
||||
// override with any special handling of the entire OpenAPI spec document
|
||||
@SuppressWarnings("unused")
|
||||
public void processOpenAPI(OpenAPI openAPI) {
|
||||
}
|
||||
@@ -725,6 +723,10 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
return additionalProperties;
|
||||
}
|
||||
|
||||
public Map<String, String> serverVariableOverrides() {
|
||||
return serverVariables;
|
||||
}
|
||||
|
||||
public Map<String, Object> vendorExtensions() {
|
||||
return vendorExtensions;
|
||||
}
|
||||
@@ -1825,6 +1827,7 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
} else {
|
||||
// composition
|
||||
addProperties(properties, required, refSchema);
|
||||
addProperties(allProperties, allRequired, refSchema);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4881,41 +4884,54 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
imports.add(codegenParameter.baseType);
|
||||
} else {
|
||||
CodegenProperty codegenProperty = fromProperty("property", schema);
|
||||
if (ModelUtils.getAdditionalProperties(schema) != null) {// http body is map
|
||||
LOGGER.error("Map should be supported. Please report to openapi-generator github repo about the issue.");
|
||||
} else if (codegenProperty != null) {
|
||||
String codegenModelName, codegenModelDescription;
|
||||
|
||||
if (codegenModel != null) {
|
||||
codegenModelName = codegenModel.classname;
|
||||
codegenModelDescription = codegenModel.description;
|
||||
} else {
|
||||
LOGGER.warn("The following schema has undefined (null) baseType. " +
|
||||
"It could be due to form parameter defined in OpenAPI v2 spec with incorrect consumes. " +
|
||||
"A correct 'consumes' for form parameters should be " +
|
||||
"'application/x-www-form-urlencoded' or 'multipart/form-data'");
|
||||
LOGGER.warn("schema: " + schema);
|
||||
LOGGER.warn("codegenModel is null. Default to UNKNOWN_BASE_TYPE");
|
||||
codegenModelName = "UNKNOWN_BASE_TYPE";
|
||||
codegenModelDescription = "UNKNOWN_DESCRIPTION";
|
||||
}
|
||||
|
||||
if (StringUtils.isEmpty(bodyParameterName)) {
|
||||
codegenParameter.baseName = codegenModelName;
|
||||
} else {
|
||||
codegenParameter.baseName = bodyParameterName;
|
||||
}
|
||||
|
||||
if (codegenProperty != null && codegenProperty.getComplexType() != null && codegenProperty.getComplexType().contains(" | ")) {
|
||||
List<String> parts = Arrays.asList(codegenProperty.getComplexType().split(" \\| "));
|
||||
imports.addAll(parts);
|
||||
String codegenModelName = codegenProperty.getComplexType();
|
||||
codegenParameter.baseName = codegenModelName;
|
||||
codegenParameter.paramName = toParamName(codegenParameter.baseName);
|
||||
codegenParameter.baseType = codegenModelName;
|
||||
codegenParameter.baseType = codegenParameter.baseName;
|
||||
codegenParameter.dataType = getTypeDeclaration(codegenModelName);
|
||||
codegenParameter.description = codegenModelDescription;
|
||||
imports.add(codegenParameter.baseType);
|
||||
codegenParameter.description = codegenProperty.getDescription();
|
||||
} else {
|
||||
if (ModelUtils.getAdditionalProperties(schema) != null) {// http body is map
|
||||
LOGGER.error("Map should be supported. Please report to openapi-generator github repo about the issue.");
|
||||
} else if (codegenProperty != null) {
|
||||
String codegenModelName, codegenModelDescription;
|
||||
|
||||
if (codegenProperty.complexType != null) {
|
||||
imports.add(codegenProperty.complexType);
|
||||
if (codegenModel != null) {
|
||||
codegenModelName = codegenModel.classname;
|
||||
codegenModelDescription = codegenModel.description;
|
||||
} else {
|
||||
LOGGER.warn("The following schema has undefined (null) baseType. " +
|
||||
"It could be due to form parameter defined in OpenAPI v2 spec with incorrect consumes. " +
|
||||
"A correct 'consumes' for form parameters should be " +
|
||||
"'application/x-www-form-urlencoded' or 'multipart/form-data'");
|
||||
LOGGER.warn("schema: " + schema);
|
||||
LOGGER.warn("codegenModel is null. Default to UNKNOWN_BASE_TYPE");
|
||||
codegenModelName = "UNKNOWN_BASE_TYPE";
|
||||
codegenModelDescription = "UNKNOWN_DESCRIPTION";
|
||||
}
|
||||
|
||||
if (StringUtils.isEmpty(bodyParameterName)) {
|
||||
codegenParameter.baseName = codegenModelName;
|
||||
} else {
|
||||
codegenParameter.baseName = bodyParameterName;
|
||||
}
|
||||
|
||||
codegenParameter.paramName = toParamName(codegenParameter.baseName);
|
||||
codegenParameter.baseType = codegenModelName;
|
||||
codegenParameter.dataType = getTypeDeclaration(codegenModelName);
|
||||
codegenParameter.description = codegenModelDescription;
|
||||
imports.add(codegenParameter.baseType);
|
||||
|
||||
if (codegenProperty.complexType != null) {
|
||||
imports.add(codegenProperty.complexType);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
setParameterBooleanFlagWithCodegenProperty(codegenParameter, codegenProperty);
|
||||
// set nullable
|
||||
setParameterNullable(codegenParameter, codegenProperty);
|
||||
@@ -5056,14 +5072,34 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
if (variables == null) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
Map<String, String> variableOverrides = serverVariableOverrides();
|
||||
|
||||
List<CodegenServerVariable> codegenServerVariables = new LinkedList<>();
|
||||
for (Entry<String, ServerVariable> variableEntry : variables.entrySet()) {
|
||||
CodegenServerVariable codegenServerVariable = new CodegenServerVariable();
|
||||
ServerVariable variable = variableEntry.getValue();
|
||||
List<String> enums = variable.getEnum();
|
||||
|
||||
codegenServerVariable.defaultValue = variable.getDefault();
|
||||
codegenServerVariable.description = escapeText(variable.getDescription());
|
||||
codegenServerVariable.enumValues = variable.getEnum();
|
||||
codegenServerVariable.enumValues = enums;
|
||||
codegenServerVariable.name = variableEntry.getKey();
|
||||
|
||||
// Sets the override value for a server variable pattern.
|
||||
// NOTE: OpenAPI Specification doesn't prevent multiple server URLs with variables. If multiple objects have the same
|
||||
// variables pattern, user overrides will apply to _all_ of these patterns. We may want to consider indexed overrides.
|
||||
if (variableOverrides != null && !variableOverrides.isEmpty()) {
|
||||
String value = variableOverrides.getOrDefault(variableEntry.getKey(), variable.getDefault());
|
||||
codegenServerVariable.value = value;
|
||||
|
||||
if (enums != null && !enums.isEmpty() && !enums.contains(value)) {
|
||||
LOGGER.warn("Variable override of '{}' is not listed in the enum of allowed values ({}).", value, StringUtils.join(enums, ","));
|
||||
}
|
||||
} else {
|
||||
codegenServerVariable.value = variable.getDefault();
|
||||
}
|
||||
|
||||
codegenServerVariables.add(codegenServerVariable);
|
||||
}
|
||||
return codegenServerVariables;
|
||||
|
||||
@@ -207,10 +207,12 @@ public class DefaultGenerator extends AbstractGenerator implements Generator {
|
||||
config.vendorExtensions().putAll(openAPI.getExtensions());
|
||||
}
|
||||
|
||||
URL url = URLPathUtils.getServerURL(openAPI);
|
||||
// TODO: Allow user to define _which_ servers object in the array to target.
|
||||
// Configures contextPath/basePath according to api document's servers
|
||||
URL url = URLPathUtils.getServerURL(openAPI, config.serverVariableOverrides());
|
||||
contextPath = config.escapeText(url.getPath()).replaceAll("/$", ""); // for backward compatibility
|
||||
basePathWithoutHost = contextPath;
|
||||
basePath = config.escapeText(URLPathUtils.getHost(openAPI)).replaceAll("/$", "");
|
||||
basePath = config.escapeText(URLPathUtils.getHost(openAPI, config.serverVariableOverrides())).replaceAll("/$", "");
|
||||
}
|
||||
|
||||
private void configureOpenAPIInfo() {
|
||||
@@ -548,7 +550,7 @@ public class DefaultGenerator extends AbstractGenerator implements Generator {
|
||||
}
|
||||
});
|
||||
Map<String, Object> operation = processOperations(config, tag, ops, allModels);
|
||||
URL url = URLPathUtils.getServerURL(openAPI);
|
||||
URL url = URLPathUtils.getServerURL(openAPI, config.serverVariableOverrides());
|
||||
operation.put("basePath", basePath);
|
||||
operation.put("basePathWithoutHost", config.encodePath(url.getPath()).replaceAll("/$", ""));
|
||||
operation.put("contextPath", contextPath);
|
||||
@@ -819,7 +821,7 @@ public class DefaultGenerator extends AbstractGenerator implements Generator {
|
||||
Map<String, Object> apis = new HashMap<String, Object>();
|
||||
apis.put("apis", allOperations);
|
||||
|
||||
URL url = URLPathUtils.getServerURL(openAPI);
|
||||
URL url = URLPathUtils.getServerURL(openAPI, config.serverVariableOverrides());
|
||||
|
||||
bundle.put("openAPI", openAPI);
|
||||
bundle.put("basePath", basePath);
|
||||
@@ -972,6 +974,7 @@ public class DefaultGenerator extends AbstractGenerator implements Generator {
|
||||
processOperation(resourcePath, "delete", path.getDelete(), ops, path);
|
||||
processOperation(resourcePath, "patch", path.getPatch(), ops, path);
|
||||
processOperation(resourcePath, "options", path.getOptions(), ops, path);
|
||||
processOperation(resourcePath, "trace", path.getTrace(), ops, path);
|
||||
}
|
||||
return ops;
|
||||
}
|
||||
@@ -1191,7 +1194,7 @@ public class DefaultGenerator extends AbstractGenerator implements Generator {
|
||||
for (String key : definitions.keySet()) {
|
||||
Schema schema = definitions.get(key);
|
||||
if (schema == null)
|
||||
throw new RuntimeException("schema cannot be null in processMoels");
|
||||
throw new RuntimeException("schema cannot be null in processModels");
|
||||
CodegenModel cm = config.fromModel(key, schema);
|
||||
Map<String, Object> mo = new HashMap<String, Object>();
|
||||
mo.put("model", cm);
|
||||
|
||||
@@ -19,6 +19,7 @@ package org.openapitools.codegen;
|
||||
|
||||
import io.swagger.v3.core.util.Json;
|
||||
import io.swagger.v3.oas.models.*;
|
||||
import io.swagger.v3.oas.models.callbacks.Callback;
|
||||
import io.swagger.v3.oas.models.media.*;
|
||||
import io.swagger.v3.oas.models.parameters.Parameter;
|
||||
import io.swagger.v3.oas.models.parameters.RequestBody;
|
||||
@@ -29,6 +30,7 @@ import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class InlineModelResolver {
|
||||
private OpenAPI openapi;
|
||||
@@ -64,7 +66,20 @@ public class InlineModelResolver {
|
||||
|
||||
for (String pathname : paths.keySet()) {
|
||||
PathItem path = paths.get(pathname);
|
||||
List<Operation> operations = new ArrayList<>(path.readOperations());
|
||||
|
||||
// Include callback operation as well
|
||||
for (Operation operation : path.readOperations()) {
|
||||
Map<String, Callback> callbacks = operation.getCallbacks();
|
||||
if (callbacks != null) {
|
||||
operations.addAll(callbacks.values().stream()
|
||||
.flatMap(callback -> callback.values().stream())
|
||||
.flatMap(pathItem -> pathItem.readOperations().stream())
|
||||
.collect(Collectors.toList()));
|
||||
}
|
||||
}
|
||||
|
||||
for (Operation operation : operations) {
|
||||
flattenRequestBody(openAPI, pathname, operation);
|
||||
flattenParameters(openAPI, pathname, operation);
|
||||
flattenResponses(openAPI, pathname, operation);
|
||||
|
||||
@@ -67,6 +67,7 @@ public class CodegenConfigurator {
|
||||
private Map<String, String> importMappings = new HashMap<>();
|
||||
private Set<String> languageSpecificPrimitives = new HashSet<>();
|
||||
private Map<String, String> reservedWordMappings = new HashMap<>();
|
||||
private Map<String, String> serverVariables = new HashMap<>();
|
||||
private String auth;
|
||||
|
||||
public CodegenConfigurator() {
|
||||
@@ -98,6 +99,12 @@ public class CodegenConfigurator {
|
||||
return null;
|
||||
}
|
||||
|
||||
public CodegenConfigurator addServerVariable(String key, String value) {
|
||||
this.serverVariables.put(key, value);
|
||||
generatorSettingsBuilder.withServerVariable(key, value);
|
||||
return this;
|
||||
}
|
||||
|
||||
public CodegenConfigurator addAdditionalProperty(String key, Object value) {
|
||||
this.additionalProperties.put(key, value);
|
||||
generatorSettingsBuilder.withAdditionalProperty(key, value);
|
||||
@@ -146,6 +153,18 @@ public class CodegenConfigurator {
|
||||
return this;
|
||||
}
|
||||
|
||||
public CodegenConfigurator setServerVariables(Map<String, String> serverVariables) {
|
||||
this.serverVariables = serverVariables;
|
||||
generatorSettingsBuilder.withServerVariables(serverVariables);
|
||||
return this;
|
||||
}
|
||||
|
||||
public CodegenConfigurator setReservedWordsMappings(Map<String, String> reservedWordMappings) {
|
||||
this.reservedWordMappings = reservedWordMappings;
|
||||
generatorSettingsBuilder.withReservedWordMappings(reservedWordMappings);
|
||||
return this;
|
||||
}
|
||||
|
||||
public CodegenConfigurator setApiPackage(String apiPackage) {
|
||||
generatorSettingsBuilder.withApiPackage(apiPackage);
|
||||
return this;
|
||||
@@ -247,6 +266,7 @@ public class CodegenConfigurator {
|
||||
|
||||
public CodegenConfigurator setLanguageSpecificPrimitives(
|
||||
Set<String> languageSpecificPrimitives) {
|
||||
this.languageSpecificPrimitives = languageSpecificPrimitives;
|
||||
generatorSettingsBuilder.withLanguageSpecificPrimitives(languageSpecificPrimitives);
|
||||
return this;
|
||||
}
|
||||
@@ -296,12 +316,6 @@ public class CodegenConfigurator {
|
||||
return this;
|
||||
}
|
||||
|
||||
public CodegenConfigurator setReservedWordsMappings(Map<String, String> reservedWordMappings) {
|
||||
this.reservedWordMappings = reservedWordMappings;
|
||||
generatorSettingsBuilder.withReservedWordMappings(reservedWordMappings);
|
||||
return this;
|
||||
}
|
||||
|
||||
public CodegenConfigurator setSkipOverwrite(boolean skipOverwrite) {
|
||||
workflowSettingsBuilder.withSkipOverwrite(skipOverwrite);
|
||||
return this;
|
||||
@@ -459,6 +473,13 @@ public class CodegenConfigurator {
|
||||
config.reservedWordsMappings().putAll(generatorSettings.getReservedWordMappings());
|
||||
config.additionalProperties().putAll(generatorSettings.getAdditionalProperties());
|
||||
|
||||
Map<String, String> serverVariables = generatorSettings.getServerVariables();
|
||||
if (!serverVariables.isEmpty()) {
|
||||
// This is currently experimental due to vagueness in the specification
|
||||
LOGGER.warn("user-defined server variable support is experimental.");
|
||||
config.serverVariableOverrides().putAll(serverVariables);
|
||||
}
|
||||
|
||||
// any other additional properties?
|
||||
String templateDir = workflowSettings.getTemplateDir();
|
||||
if (templateDir != null) {
|
||||
|
||||
@@ -107,6 +107,19 @@ public final class CodegenConfiguratorUtils {
|
||||
}
|
||||
}
|
||||
|
||||
public static void applyServerVariablesKvpList(List<String> values, CodegenConfigurator configurator) {
|
||||
for(String value : values) {
|
||||
applyServerVariablesKvp(value, configurator);
|
||||
}
|
||||
}
|
||||
|
||||
public static void applyServerVariablesKvp(String values, CodegenConfigurator configurator) {
|
||||
final Map<String, String> map = createMapFromKeyValuePairs(values);
|
||||
for (Map.Entry<String, String> entry : map.entrySet()) {
|
||||
configurator.addServerVariable(entry.getKey(), entry.getValue());
|
||||
}
|
||||
}
|
||||
|
||||
public static void applyLanguageSpecificPrimitivesCsvList(List<String> languageSpecificPrimitives, CodegenConfigurator configurator) {
|
||||
for(String propString : languageSpecificPrimitives) {
|
||||
applyLanguageSpecificPrimitivesCsv(propString, configurator);
|
||||
|
||||
@@ -296,7 +296,7 @@ abstract public class AbstractCppCodegen extends DefaultCodegen implements Codeg
|
||||
|
||||
@Override
|
||||
public void preprocessOpenAPI(OpenAPI openAPI) {
|
||||
URL url = URLPathUtils.getServerURL(openAPI);
|
||||
URL url = URLPathUtils.getServerURL(openAPI, serverVariableOverrides());
|
||||
String port = URLPathUtils.getPort(url, "");
|
||||
String host = url.getHost();
|
||||
if(!port.isEmpty()) {
|
||||
|
||||
@@ -38,6 +38,7 @@ public abstract class AbstractGoCodegen extends DefaultCodegen implements Codege
|
||||
|
||||
protected boolean withGoCodegenComment = false;
|
||||
protected boolean withXml = false;
|
||||
protected boolean enumClassPrefix = false;
|
||||
|
||||
protected String packageName = "openapi";
|
||||
|
||||
@@ -389,6 +390,11 @@ public abstract class AbstractGoCodegen extends DefaultCodegen implements Codege
|
||||
}
|
||||
}
|
||||
|
||||
// import "reflect" package if the parameter is collectionFormat=multi
|
||||
if (param.isCollectionFormatMulti) {
|
||||
imports.add(createMapping("import", "reflect"));
|
||||
}
|
||||
|
||||
// import "optionals" package if the parameter is optional
|
||||
if (!param.required) {
|
||||
if (!addedOptionalImport) {
|
||||
@@ -613,6 +619,10 @@ public abstract class AbstractGoCodegen extends DefaultCodegen implements Codege
|
||||
this.withXml = withXml;
|
||||
}
|
||||
|
||||
public void setEnumClassPrefix(boolean enumClassPrefix) {
|
||||
this.enumClassPrefix = enumClassPrefix;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toDefaultValue(Schema schema) {
|
||||
if (schema.getDefault() != null) {
|
||||
|
||||
@@ -417,6 +417,8 @@ public abstract class AbstractJavaCodegen extends DefaultCodegen implements Code
|
||||
importMapping.put("JsonTypeInfo", "com.fasterxml.jackson.annotation.JsonTypeInfo");
|
||||
importMapping.put("JsonCreator", "com.fasterxml.jackson.annotation.JsonCreator");
|
||||
importMapping.put("JsonValue", "com.fasterxml.jackson.annotation.JsonValue");
|
||||
importMapping.put("JsonIgnore", "com.fasterxml.jackson.annotation.JsonIgnore");
|
||||
importMapping.put("JsonInclude", "com.fasterxml.jackson.annotation.JsonInclude");
|
||||
importMapping.put("SerializedName", "com.google.gson.annotations.SerializedName");
|
||||
importMapping.put("TypeAdapter", "com.google.gson.TypeAdapter");
|
||||
importMapping.put("JsonAdapter", "com.google.gson.annotations.JsonAdapter");
|
||||
@@ -800,7 +802,13 @@ public abstract class AbstractJavaCodegen extends DefaultCodegen implements Code
|
||||
}
|
||||
}
|
||||
return null;
|
||||
} else if (ModelUtils.isObjectSchema(p)) {
|
||||
if (p.getDefault() != null) {
|
||||
return super.toDefaultValue(p);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
return super.toDefaultValue(p);
|
||||
}
|
||||
|
||||
|
||||
@@ -110,7 +110,7 @@ public abstract class AbstractJavaJAXRSServerCodegen extends AbstractJavaCodegen
|
||||
*/
|
||||
|
||||
if (!this.additionalProperties.containsKey(SERVER_PORT)) {
|
||||
URL url = URLPathUtils.getServerURL(openAPI);
|
||||
URL url = URLPathUtils.getServerURL(openAPI, serverVariableOverrides());
|
||||
// 8080 is the default value for a JEE Server:
|
||||
this.additionalProperties.put(SERVER_PORT, URLPathUtils.getPort(url, serverPort));
|
||||
}
|
||||
|
||||
@@ -612,6 +612,7 @@ public abstract class AbstractKotlinCodegen extends DefaultCodegen implements Co
|
||||
StringBuilder instantiationType = new StringBuilder(arrayType);
|
||||
Schema items = arr.getItems();
|
||||
String nestedType = getTypeDeclaration(items);
|
||||
additionalProperties.put("nestedType", nestedType);
|
||||
// TODO: We may want to differentiate here between generics and primitive arrays.
|
||||
instantiationType.append("<").append(nestedType).append(">");
|
||||
return instantiationType.toString();
|
||||
|
||||
@@ -268,7 +268,7 @@ public class AspNetCoreServerCodegen extends AbstractCSharpCodegen {
|
||||
@Override
|
||||
public void preprocessOpenAPI(OpenAPI openAPI) {
|
||||
super.preprocessOpenAPI(openAPI);
|
||||
URL url = URLPathUtils.getServerURL(openAPI);
|
||||
URL url = URLPathUtils.getServerURL(openAPI, serverVariableOverrides());
|
||||
additionalProperties.put("serverHost", url.getHost());
|
||||
additionalProperties.put("serverPort", URLPathUtils.getPort(url, 8080));
|
||||
}
|
||||
@@ -327,6 +327,7 @@ public class AspNetCoreServerCodegen extends AbstractCSharpCodegen {
|
||||
supportingFiles.add(new SupportingFile("Solution.mustache", "", packageName + ".sln"));
|
||||
supportingFiles.add(new SupportingFile("gitignore", packageFolder, ".gitignore"));
|
||||
supportingFiles.add(new SupportingFile("validateModel.mustache", packageFolder + File.separator + "Attributes", "ValidateModelStateAttribute.cs"));
|
||||
supportingFiles.add(new SupportingFile("typeConverter.mustache", packageFolder + File.separator + "Converters", "CustomEnumConverter.cs"));
|
||||
supportingFiles.add(new SupportingFile("Project.csproj.mustache", packageFolder, packageName + ".csproj"));
|
||||
if (!isLibrary) {
|
||||
supportingFiles.add(new SupportingFile("Dockerfile.mustache", packageFolder, "Dockerfile"));
|
||||
|
||||
@@ -0,0 +1,135 @@
|
||||
/*
|
||||
* Copyright 2019 OpenAPI-Generator Contributors (https://openapi-generator.tech)
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.openapitools.codegen.languages;
|
||||
|
||||
import org.openapitools.codegen.*;
|
||||
import org.openapitools.codegen.meta.GeneratorMetadata;
|
||||
import org.openapitools.codegen.meta.Stability;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashSet;
|
||||
import java.util.Map;
|
||||
|
||||
import static org.openapitools.codegen.utils.StringUtils.camelize;
|
||||
|
||||
public class AvroSchemaCodegen extends DefaultCodegen implements CodegenConfig {
|
||||
private static final String AVRO = "avro-schema";
|
||||
protected String packageName = "model";
|
||||
|
||||
public AvroSchemaCodegen() {
|
||||
super();
|
||||
|
||||
generatorMetadata = GeneratorMetadata.newBuilder(generatorMetadata)
|
||||
.stability(Stability.BETA)
|
||||
.build();
|
||||
|
||||
outputFolder = "generated-code/avro-schema";
|
||||
modelTemplateFiles.put("model.mustache", ".avsc");
|
||||
apiPackage = "api";
|
||||
modelPackage = "model";
|
||||
importMapping.clear();
|
||||
embeddedTemplateDir = templateDir = AVRO;
|
||||
|
||||
// default HIDE_GENERATION_TIMESTAMP to true
|
||||
hideGenerationTimestamp = Boolean.TRUE;
|
||||
|
||||
languageSpecificPrimitives = new HashSet<>(
|
||||
Arrays.asList("null", "boolean", "int", "integer", "long", "float", "double", "bytes", "string",
|
||||
"BigDecimal", "UUID", "number", "date", "DateTime")
|
||||
);
|
||||
defaultIncludes = new HashSet<>(languageSpecificPrimitives);
|
||||
|
||||
instantiationTypes.put("array", "Array");
|
||||
instantiationTypes.put("list", "Array");
|
||||
instantiationTypes.put("map", "Object");
|
||||
typeMapping.clear();
|
||||
typeMapping.put("number", "double");
|
||||
typeMapping.put("DateTime", "string");
|
||||
typeMapping.put("date", "string");
|
||||
typeMapping.put("short", "int");
|
||||
typeMapping.put("char", "string");
|
||||
typeMapping.put("integer", "int");
|
||||
typeMapping.put("ByteArray", "bytes");
|
||||
typeMapping.put("binary", "File");
|
||||
typeMapping.put("file", "File");
|
||||
typeMapping.put("UUID", "string");
|
||||
typeMapping.put("BigDecimal", "string");
|
||||
|
||||
cliOptions.add(new CliOption(CodegenConstants.PACKAGE_NAME, CodegenConstants.PACKAGE_NAME_DESC));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void processOpts() {
|
||||
super.processOpts();
|
||||
if (additionalProperties.containsKey(CodegenConstants.PACKAGE_NAME)) {
|
||||
packageName = (String) additionalProperties.get(CodegenConstants.PACKAGE_NAME);
|
||||
}
|
||||
|
||||
additionalProperties.put("packageName", packageName);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public CodegenType getTag() {
|
||||
return CodegenType.SCHEMA;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "avro-schema";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getHelp() {
|
||||
return "Generates a Avro model (beta).";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String modelFileFolder() {
|
||||
return outputFolder + File.separator;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Object> postProcessModels(Map<String, Object> objs) {
|
||||
return postProcessModelsEnum(objs);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void setNonArrayMapProperty(CodegenProperty property, String type) {
|
||||
super.setNonArrayMapProperty(property, type);
|
||||
if (property.isModel) {
|
||||
property.dataType = camelize(modelNamePrefix + property.dataType + modelNameSuffix);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String escapeUnsafeCharacters(String input) {
|
||||
// do nothing as it's a schema conversion
|
||||
return input;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String escapeQuotationMark(String input) {
|
||||
// do nothing as it's a schema conversion
|
||||
return input;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -359,7 +359,7 @@ public class CSharpNancyFXServerCodegen extends AbstractCSharpCodegen {
|
||||
|
||||
@Override
|
||||
public void preprocessOpenAPI(final OpenAPI openAPI) {
|
||||
URL url = URLPathUtils.getServerURL(openAPI);
|
||||
URL url = URLPathUtils.getServerURL(openAPI, serverVariableOverrides());
|
||||
String path = URLPathUtils.getPath(url, "/");
|
||||
final String packageContextOption = (String) additionalProperties.get(PACKAGE_CONTEXT);
|
||||
additionalProperties.put("packageContext", packageContextOption == null ? sanitizeName(path) : packageContextOption);
|
||||
|
||||
@@ -65,7 +65,7 @@ public class CSharpNetCoreClientCodegen extends AbstractCSharpCodegen {
|
||||
protected String modelDocPath = "docs/";
|
||||
|
||||
// Defines TargetFrameworkVersion in csproj files
|
||||
protected String targetFramework = defaultFramework.dotNetFrameworkVersion;
|
||||
protected String targetFramework = defaultFramework.name;
|
||||
|
||||
// Defines nuget identifiers for target framework
|
||||
protected String targetFrameworkNuget = targetFramework;
|
||||
@@ -78,6 +78,8 @@ public class CSharpNetCoreClientCodegen extends AbstractCSharpCodegen {
|
||||
// By default, generated code is considered public
|
||||
protected boolean nonPublicApi = Boolean.FALSE;
|
||||
|
||||
protected boolean caseInsensitiveResponseHeaders = Boolean.FALSE;
|
||||
|
||||
public CSharpNetCoreClientCodegen() {
|
||||
super();
|
||||
|
||||
@@ -206,6 +208,10 @@ public class CSharpNetCoreClientCodegen extends AbstractCSharpCodegen {
|
||||
CodegenConstants.VALIDATABLE_DESC,
|
||||
this.validatable);
|
||||
|
||||
addSwitch(CodegenConstants.CASE_INSENSITIVE_RESPONSE_HEADERS,
|
||||
CodegenConstants.CASE_INSENSITIVE_RESPONSE_HEADERS_DESC,
|
||||
this.caseInsensitiveResponseHeaders);
|
||||
|
||||
regexModifiers = new HashMap<>();
|
||||
regexModifiers.put('i', "IgnoreCase");
|
||||
regexModifiers.put('m', "Multiline");
|
||||
@@ -470,7 +476,7 @@ public class CSharpNetCoreClientCodegen extends AbstractCSharpCodegen {
|
||||
}
|
||||
clientPackage = "Client";
|
||||
|
||||
String framework = (String) additionalProperties.getOrDefault(CodegenConstants.DOTNET_FRAMEWORK, defaultFramework.dotNetFrameworkVersion);
|
||||
String framework = (String) additionalProperties.getOrDefault(CodegenConstants.DOTNET_FRAMEWORK, defaultFramework.name);
|
||||
FrameworkStrategy strategy = defaultFramework;
|
||||
for (FrameworkStrategy frameworkStrategy : frameworkStrategies) {
|
||||
if (framework.equals(frameworkStrategy.name)) {
|
||||
@@ -481,7 +487,7 @@ public class CSharpNetCoreClientCodegen extends AbstractCSharpCodegen {
|
||||
strategy.configureAdditionalProperties(additionalProperties);
|
||||
|
||||
setTargetFrameworkNuget(strategy.getNugetFrameworkIdentifier());
|
||||
setTargetFramework(strategy.dotNetFrameworkVersion);
|
||||
setTargetFramework(strategy.name);
|
||||
|
||||
if (strategy != FrameworkStrategy.NETSTANDARD_2_0) {
|
||||
LOGGER.warn("If using built-in templates-RestSharp only supports netstandard 2.0 or later.");
|
||||
@@ -640,6 +646,10 @@ public class CSharpNetCoreClientCodegen extends AbstractCSharpCodegen {
|
||||
this.validatable = validatable;
|
||||
}
|
||||
|
||||
public void setCaseInsensitiveResponseHeaders(final Boolean caseInsensitiveResponseHeaders) {
|
||||
this.caseInsensitiveResponseHeaders = caseInsensitiveResponseHeaders;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toEnumVarName(String value, String datatype) {
|
||||
if (value.length() == 0) {
|
||||
@@ -800,7 +810,7 @@ public class CSharpNetCoreClientCodegen extends AbstractCSharpCodegen {
|
||||
}
|
||||
|
||||
protected void configureAdditionalProperties(final Map<String, Object> properties) {
|
||||
properties.putIfAbsent(CodegenConstants.DOTNET_FRAMEWORK, this.dotNetFrameworkVersion);
|
||||
properties.putIfAbsent(CodegenConstants.DOTNET_FRAMEWORK, this.name);
|
||||
|
||||
// not intended to be user-settable
|
||||
properties.put(TARGET_FRAMEWORK_IDENTIFIER, this.getTargetFrameworkIdentifier());
|
||||
|
||||
@@ -118,13 +118,13 @@ public class DartClientCodegen extends DefaultCodegen implements CodegenConfig {
|
||||
typeMapping.put("URI", "String");
|
||||
typeMapping.put("ByteArray", "String");
|
||||
|
||||
cliOptions.add(new CliOption(BROWSER_CLIENT, "Is the client browser based"));
|
||||
cliOptions.add(new CliOption(BROWSER_CLIENT, "Is the client browser based (for Dart 1.x only)"));
|
||||
cliOptions.add(new CliOption(PUB_NAME, "Name in generated pubspec"));
|
||||
cliOptions.add(new CliOption(PUB_VERSION, "Version in generated pubspec"));
|
||||
cliOptions.add(new CliOption(PUB_DESCRIPTION, "Description in generated pubspec"));
|
||||
cliOptions.add(new CliOption(USE_ENUM_EXTENSION, "Allow the 'x-enum-values' extension for enums"));
|
||||
cliOptions.add(new CliOption(CodegenConstants.SOURCE_FOLDER, "source folder for generated code"));
|
||||
cliOptions.add(CliOption.newBoolean(SUPPORT_DART2, "support dart2").defaultValue(Boolean.TRUE.toString()));
|
||||
cliOptions.add(new CliOption(CodegenConstants.SOURCE_FOLDER, "Source folder for generated code"));
|
||||
cliOptions.add(CliOption.newBoolean(SUPPORT_DART2, "Support Dart 2.x").defaultValue(Boolean.TRUE.toString()));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -23,20 +23,14 @@ import org.openapitools.codegen.CodegenConstants;
|
||||
import org.openapitools.codegen.CodegenOperation;
|
||||
import org.openapitools.codegen.CodegenType;
|
||||
import org.openapitools.codegen.SupportingFile;
|
||||
import org.openapitools.codegen.CodegenModel;
|
||||
import org.openapitools.codegen.CodegenProperty;
|
||||
import org.openapitools.codegen.utils.URLPathUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.io.File;
|
||||
import java.net.URL;
|
||||
import java.util.Arrays;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.List;
|
||||
import java.util.ArrayList;
|
||||
|
||||
import static java.util.UUID.randomUUID;
|
||||
|
||||
@@ -165,7 +159,7 @@ public class FsharpGiraffeServerCodegen extends AbstractFSharpCodegen {
|
||||
@Override
|
||||
public void preprocessOpenAPI(OpenAPI openAPI) {
|
||||
super.preprocessOpenAPI(openAPI);
|
||||
URL url = URLPathUtils.getServerURL(openAPI);
|
||||
URL url = URLPathUtils.getServerURL(openAPI, serverVariableOverrides());
|
||||
additionalProperties.put("serverHost", url.getHost());
|
||||
additionalProperties.put("serverPort", URLPathUtils.getPort(url, 8080));
|
||||
}
|
||||
|
||||
@@ -55,7 +55,7 @@ public class GoClientCodegen extends AbstractGoCodegen {
|
||||
cliOptions.add(CliOption.newBoolean(CodegenConstants.IS_GO_SUBMODULE, CodegenConstants.IS_GO_SUBMODULE_DESC));
|
||||
cliOptions.add(CliOption.newBoolean(WITH_GO_CODEGEN_COMMENT, "whether to include Go codegen comment to disable Go Lint and collapse by default GitHub in PRs and diffs"));
|
||||
cliOptions.add(CliOption.newBoolean(WITH_XML, "whether to include support for application/xml content type and include XML annotations in the model (works with libraries that provide support for JSON and XML)"));
|
||||
|
||||
cliOptions.add(CliOption.newBoolean(CodegenConstants.ENUM_CLASS_PREFIX, CodegenConstants.ENUM_CLASS_PREFIX_DESC));
|
||||
|
||||
// option to change the order of form/body parameter
|
||||
cliOptions.add(CliOption.newBoolean(
|
||||
@@ -114,6 +114,13 @@ public class GoClientCodegen extends AbstractGoCodegen {
|
||||
}
|
||||
}
|
||||
|
||||
if (additionalProperties.containsKey(CodegenConstants.ENUM_CLASS_PREFIX)) {
|
||||
setEnumClassPrefix(Boolean.parseBoolean(additionalProperties.get(CodegenConstants.ENUM_CLASS_PREFIX).toString()));
|
||||
if (enumClassPrefix) {
|
||||
additionalProperties.put(CodegenConstants.ENUM_CLASS_PREFIX, "true");
|
||||
}
|
||||
}
|
||||
|
||||
if (additionalProperties.containsKey(CodegenConstants.IS_GO_SUBMODULE)) {
|
||||
setIsGoSubmodule(Boolean.parseBoolean(additionalProperties.get(CodegenConstants.IS_GO_SUBMODULE).toString()));
|
||||
if (isGoSubmodule) {
|
||||
|
||||
@@ -19,6 +19,8 @@ package org.openapitools.codegen.languages;
|
||||
import org.openapitools.codegen.CodegenModel;
|
||||
import org.openapitools.codegen.CodegenProperty;
|
||||
import org.openapitools.codegen.SupportingFile;
|
||||
import org.openapitools.codegen.meta.GeneratorMetadata;
|
||||
import org.openapitools.codegen.meta.Stability;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
@@ -33,6 +35,10 @@ public class GoClientExperimentalCodegen extends GoClientCodegen {
|
||||
super();
|
||||
outputFolder = "generated-code/go-experimental";
|
||||
embeddedTemplateDir = templateDir = "go-experimental";
|
||||
|
||||
generatorMetadata = GeneratorMetadata.newBuilder(generatorMetadata)
|
||||
.stability(Stability.EXPERIMENTAL)
|
||||
.build();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -1065,13 +1065,14 @@ public class HaskellHttpClientCodegen extends DefaultCodegen implements CodegenC
|
||||
case "tsv":
|
||||
return "TabSeparated";
|
||||
case "ssv":
|
||||
case "space":
|
||||
return "SpaceSeparated";
|
||||
case "pipes":
|
||||
return "PipeSeparated";
|
||||
case "multi":
|
||||
return "MultiParamArray";
|
||||
default:
|
||||
throw new UnsupportedOperationException();
|
||||
throw new UnsupportedOperationException(collectionFormat + " (collection format) not supported");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -549,6 +549,7 @@ public class HaskellServantCodegen extends DefaultCodegen implements CodegenConf
|
||||
return "(QueryList 'CommaSeparated (" + type + "))";
|
||||
case "tsv":
|
||||
return "(QueryList 'TabSeparated (" + type + "))";
|
||||
case "space":
|
||||
case "ssv":
|
||||
return "(QueryList 'SpaceSeparated (" + type + "))";
|
||||
case "pipes":
|
||||
@@ -556,7 +557,7 @@ public class HaskellServantCodegen extends DefaultCodegen implements CodegenConf
|
||||
case "multi":
|
||||
return "(QueryList 'MultiParamArray (" + type + "))";
|
||||
default:
|
||||
throw new UnsupportedOperationException();
|
||||
throw new UnsupportedOperationException(collectionFormat + " (collection format) not supported");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -24,6 +24,7 @@ import org.openapitools.codegen.languages.features.BeanValidationFeatures;
|
||||
import org.openapitools.codegen.languages.features.GzipFeatures;
|
||||
import org.openapitools.codegen.languages.features.PerformBeanValidationFeatures;
|
||||
import org.openapitools.codegen.templating.mustache.CaseFormatLambda;
|
||||
import org.openapitools.codegen.utils.ModelUtils;
|
||||
import org.openapitools.codegen.utils.ProcessUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
@@ -583,6 +584,7 @@ public class JavaClientCodegen extends AbstractJavaCodegen
|
||||
if (additionalProperties.containsKey("jackson")) {
|
||||
model.imports.add("JsonProperty");
|
||||
model.imports.add("JsonValue");
|
||||
model.imports.add("JsonInclude");
|
||||
}
|
||||
if (additionalProperties.containsKey("gson")) {
|
||||
model.imports.add("SerializedName");
|
||||
@@ -623,6 +625,39 @@ public class JavaClientCodegen extends AbstractJavaCodegen
|
||||
return objs;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Object> postProcessModels(Map<String, Object> objs) {
|
||||
objs = super.postProcessModels(objs);
|
||||
if (additionalProperties.containsKey("jackson") && !JERSEY1.equals(getLibrary())) {
|
||||
List<Map<String, String>> imports = (List<Map<String, String>>) objs.get("imports");
|
||||
List<Object> models = (List<Object>) objs.get("models");
|
||||
for (Object _mo : models) {
|
||||
Map<String, Object> mo = (Map<String, Object>) _mo;
|
||||
CodegenModel cm = (CodegenModel) mo.get("model");
|
||||
boolean addImports = false;
|
||||
for (CodegenProperty var : cm.vars) {
|
||||
boolean isOptionalNullable = Boolean.FALSE.equals(var.required) && Boolean.TRUE.equals(var.isNullable);
|
||||
// only add JsonNullable and related imports to optional and nullable values
|
||||
addImports |= isOptionalNullable;
|
||||
var.getVendorExtensions().put("isJacksonOptionalNullable", isOptionalNullable);
|
||||
}
|
||||
if (addImports) {
|
||||
cm.imports.add("JsonNullable");
|
||||
Map<String, String> itemJsonNullable = new HashMap<String, String>();
|
||||
itemJsonNullable.put("import", "org.openapitools.jackson.nullable.JsonNullable");
|
||||
imports.add(itemJsonNullable);
|
||||
|
||||
cm.imports.add("NoSuchElementException");
|
||||
Map<String, String> itemExc = new HashMap<String, String>();
|
||||
itemExc.put("import", "java.util.NoSuchElementException");
|
||||
imports.add(itemExc);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return objs;
|
||||
}
|
||||
|
||||
public void setUseRxJava(boolean useRxJava) {
|
||||
this.useRxJava = useRxJava;
|
||||
doNotUseRx = false;
|
||||
|
||||
@@ -538,7 +538,7 @@ public class JavaPKMSTServerCodegen extends AbstractJavaCodegen {
|
||||
additionalProperties.put(TITLE, this.title);
|
||||
}
|
||||
|
||||
URL url = URLPathUtils.getServerURL(openAPI);
|
||||
URL url = URLPathUtils.getServerURL(openAPI, serverVariableOverrides());
|
||||
this.additionalProperties.put("serverPort", URLPathUtils.getPort(url, 8080));
|
||||
|
||||
if (openAPI.getPaths() != null) {
|
||||
|
||||
@@ -221,7 +221,7 @@ public class JavaVertXServerCodegen extends AbstractJavaCodegen {
|
||||
super.preprocessOpenAPI(openAPI);
|
||||
|
||||
// add server port from the swagger file, 8080 by default
|
||||
URL url = URLPathUtils.getServerURL(openAPI);
|
||||
URL url = URLPathUtils.getServerURL(openAPI, serverVariableOverrides());
|
||||
this.additionalProperties.put("serverPort", URLPathUtils.getPort(url, 8080));
|
||||
|
||||
// retrieve api version from swagger file, 1.0.0-SNAPSHOT by default
|
||||
|
||||
@@ -149,6 +149,7 @@ public class KotlinClientCodegen extends AbstractKotlinCodegen {
|
||||
if (CollectionType.LIST.value.equals(collectionType)) {
|
||||
typeMapping.put("array", "kotlin.collections.List");
|
||||
typeMapping.put("list", "kotlin.collections.List");
|
||||
additionalProperties.put("isList", true);
|
||||
}
|
||||
|
||||
supportingFiles.add(new SupportingFile("README.mustache", "", "README.md"));
|
||||
|
||||
@@ -407,7 +407,7 @@ public class KotlinSpringServerCodegen extends AbstractKotlinCodegen
|
||||
}
|
||||
|
||||
if (!additionalProperties.containsKey(SERVER_PORT)) {
|
||||
URL url = URLPathUtils.getServerURL(openAPI);
|
||||
URL url = URLPathUtils.getServerURL(openAPI, serverVariableOverrides());
|
||||
this.additionalProperties.put(SERVER_PORT, URLPathUtils.getPort(url, 8080));
|
||||
}
|
||||
|
||||
|
||||
@@ -300,7 +300,7 @@ public class NodeJSExpressServerCodegen extends DefaultCodegen implements Codege
|
||||
|
||||
@Override
|
||||
public void preprocessOpenAPI(OpenAPI openAPI) {
|
||||
URL url = URLPathUtils.getServerURL(openAPI);
|
||||
URL url = URLPathUtils.getServerURL(openAPI, serverVariableOverrides());
|
||||
String host = URLPathUtils.getProtocolAndHost(url);
|
||||
String port = URLPathUtils.getPort(url, defaultServerPort) ;
|
||||
String basePath = url.getPath();
|
||||
|
||||
@@ -358,7 +358,7 @@ public class NodeJSServerCodegen extends DefaultCodegen implements CodegenConfig
|
||||
|
||||
@Override
|
||||
public void preprocessOpenAPI(OpenAPI openAPI) {
|
||||
URL url = URLPathUtils.getServerURL(openAPI);
|
||||
URL url = URLPathUtils.getServerURL(openAPI, serverVariableOverrides());
|
||||
String host = URLPathUtils.getProtocolAndHost(url);
|
||||
String port = URLPathUtils.getPort(url, defaultServerPort) ;
|
||||
String basePath = url.getPath();
|
||||
|
||||
@@ -18,6 +18,9 @@ package org.openapitools.codegen.languages;
|
||||
|
||||
import java.text.DateFormat;
|
||||
import java.text.SimpleDateFormat;
|
||||
|
||||
import org.openapitools.codegen.meta.GeneratorMetadata;
|
||||
import org.openapitools.codegen.meta.Stability;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
@@ -39,6 +42,10 @@ public class PythonClientExperimentalCodegen extends PythonClientCodegen {
|
||||
apiTemplateFiles.put("python-experimental/api.mustache", ".py");
|
||||
modelDocTemplateFiles.put("python-experimental/model_doc.mustache", ".md");
|
||||
modelTemplateFiles.put("python-experimental/model.mustache", ".py");
|
||||
|
||||
generatorMetadata = GeneratorMetadata.newBuilder(generatorMetadata)
|
||||
.stability(Stability.EXPERIMENTAL)
|
||||
.build();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -24,9 +24,7 @@ import io.swagger.v3.oas.models.info.Info;
|
||||
import io.swagger.v3.oas.models.media.ArraySchema;
|
||||
import io.swagger.v3.oas.models.media.FileSchema;
|
||||
import io.swagger.v3.oas.models.media.Schema;
|
||||
import io.swagger.v3.oas.models.media.StringSchema;
|
||||
import io.swagger.v3.oas.models.media.XML;
|
||||
import io.swagger.v3.oas.models.parameters.Parameter;
|
||||
import io.swagger.v3.oas.models.parameters.RequestBody;
|
||||
import io.swagger.v3.oas.models.servers.Server;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
@@ -291,7 +289,7 @@ public class RustServerCodegen extends DefaultCodegen implements CodegenConfig {
|
||||
}
|
||||
info.setVersion(StringUtils.join(versionComponents, "."));
|
||||
|
||||
URL url = URLPathUtils.getServerURL(openAPI);
|
||||
URL url = URLPathUtils.getServerURL(openAPI, serverVariableOverrides());
|
||||
additionalProperties.put("serverHost", url.getHost());
|
||||
additionalProperties.put("serverPort", URLPathUtils.getPort(url, 80));
|
||||
}
|
||||
@@ -617,10 +615,6 @@ public class RustServerCodegen extends DefaultCodegen implements CodegenConfig {
|
||||
}
|
||||
|
||||
for (CodegenParameter param : op.headerParams) {
|
||||
// If a header uses UUIDs, we need to import the UUID package.
|
||||
if (param.dataType.equals(uuidType)) {
|
||||
additionalProperties.put("apiUsesUuid", true);
|
||||
}
|
||||
processParam(param, op);
|
||||
|
||||
// Give header params a name in camel case. CodegenParameters don't have a nameInCamelCase property.
|
||||
@@ -756,10 +750,21 @@ public class RustServerCodegen extends DefaultCodegen implements CodegenConfig {
|
||||
}
|
||||
|
||||
if (op.authMethods != null) {
|
||||
boolean headerAuthMethods = false;
|
||||
|
||||
for (CodegenSecurity s : op.authMethods) {
|
||||
if (s.isApiKey && s.isKeyInHeader) {
|
||||
s.vendorExtensions.put("x-apiKeyName", toModelName(s.keyParamName));
|
||||
headerAuthMethods = true;
|
||||
}
|
||||
|
||||
if (s.isBasicBasic || s.isBasicBearer || s.isOAuth) {
|
||||
headerAuthMethods = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (headerAuthMethods) {
|
||||
op.vendorExtensions.put("hasHeaderAuthMethods", "true");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -927,7 +932,15 @@ public class RustServerCodegen extends DefaultCodegen implements CodegenConfig {
|
||||
String modelName = entry.getKey();
|
||||
CodegenModel model = entry.getValue();
|
||||
|
||||
if (uuidType.equals(model.dataType)) {
|
||||
additionalProperties.put("apiUsesUuid", true);
|
||||
}
|
||||
|
||||
for (CodegenProperty prop : model.vars) {
|
||||
if (prop.dataType.equals(uuidType)) {
|
||||
additionalProperties.put("apiUsesUuid", true);
|
||||
}
|
||||
|
||||
String xmlName = modelXmlNames.get(prop.dataType);
|
||||
if (xmlName != null) {
|
||||
prop.vendorExtensions.put("itemXmlName", xmlName);
|
||||
@@ -1134,6 +1147,11 @@ public class RustServerCodegen extends DefaultCodegen implements CodegenConfig {
|
||||
private void processParam(CodegenParameter param, CodegenOperation op) {
|
||||
String example = null;
|
||||
|
||||
// If a parameter uses UUIDs, we need to import the UUID package.
|
||||
if (param.dataType.equals(uuidType)) {
|
||||
additionalProperties.put("apiUsesUuid", true);
|
||||
}
|
||||
|
||||
if (param.isString) {
|
||||
param.vendorExtensions.put("formatString", "\\\"{}\\\"");
|
||||
example = "\"" + ((param.example != null) ? param.example : "") + "\".to_string()";
|
||||
|
||||
@@ -515,8 +515,8 @@ public class SpringCodegen extends AbstractJavaCodegen
|
||||
additionalProperties.put(TITLE, this.title);
|
||||
}
|
||||
|
||||
if (!additionalProperties.containsKey(SERVER_PORT)) {
|
||||
URL url = URLPathUtils.getServerURL(openAPI);
|
||||
if(!additionalProperties.containsKey(SERVER_PORT)) {
|
||||
URL url = URLPathUtils.getServerURL(openAPI, serverVariableOverrides());
|
||||
this.additionalProperties.put(SERVER_PORT, URLPathUtils.getPort(url, 8080));
|
||||
}
|
||||
|
||||
|
||||
@@ -209,8 +209,9 @@ public class TypeScriptAngularClientCodegen extends AbstractTypeScriptClientCode
|
||||
}
|
||||
|
||||
// Set the typescript version compatible to the Angular version
|
||||
if (ngVersion.atLeast("7.0.0")) {
|
||||
// Angular v7 requires typescript ">=3.1.1 <3.2.0"
|
||||
if (ngVersion.atLeast("8.0.0")) {
|
||||
additionalProperties.put("tsVersion", ">=3.4.0 <3.6.0");
|
||||
} else if (ngVersion.atLeast("7.0.0")) {
|
||||
additionalProperties.put("tsVersion", ">=3.1.1 <3.2.0");
|
||||
} else if (ngVersion.atLeast("6.0.0")) {
|
||||
additionalProperties.put("tsVersion", ">=2.7.2 and <2.10.0");
|
||||
@@ -222,7 +223,9 @@ public class TypeScriptAngularClientCodegen extends AbstractTypeScriptClientCode
|
||||
}
|
||||
|
||||
// Set the rxJS version compatible to the Angular version
|
||||
if (ngVersion.atLeast("7.0.0")) {
|
||||
if (ngVersion.atLeast("8.0.0")) {
|
||||
additionalProperties.put("rxjsVersion", "6.5.0");
|
||||
} else if (ngVersion.atLeast("7.0.0")) {
|
||||
additionalProperties.put("rxjsVersion", "6.3.0");
|
||||
} else if (ngVersion.atLeast("6.0.0")) {
|
||||
additionalProperties.put("rxjsVersion", "6.1.0");
|
||||
@@ -250,7 +253,10 @@ public class TypeScriptAngularClientCodegen extends AbstractTypeScriptClientCode
|
||||
additionalProperties.put("useOldNgPackagr", !ngVersion.atLeast("5.0.0"));
|
||||
|
||||
// Specific ng-packagr configuration
|
||||
if (ngVersion.atLeast("7.0.0")) {
|
||||
if (ngVersion.atLeast("8.0.0")) {
|
||||
additionalProperties.put("ngPackagrVersion", "5.4.0");
|
||||
additionalProperties.put("tsickleVersion", "0.35.0");
|
||||
} else if (ngVersion.atLeast("7.0.0")) {
|
||||
// compatible versions with typescript version
|
||||
additionalProperties.put("ngPackagrVersion", "5.1.0");
|
||||
additionalProperties.put("tsickleVersion", "0.34.0");
|
||||
@@ -268,7 +274,9 @@ public class TypeScriptAngularClientCodegen extends AbstractTypeScriptClientCode
|
||||
}
|
||||
|
||||
// set zone.js version
|
||||
if (ngVersion.atLeast("5.0.0")) {
|
||||
if (ngVersion.atLeast("8.0.0")) {
|
||||
additionalProperties.put("zonejsVersion", "0.9.1");
|
||||
} else if (ngVersion.atLeast("5.0.0")) {
|
||||
// compatible versions to Angular 5+
|
||||
additionalProperties.put("zonejsVersion", "0.8.26");
|
||||
} else {
|
||||
@@ -659,3 +667,4 @@ public class TypeScriptAngularClientCodegen extends AbstractTypeScriptClientCode
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -33,9 +33,11 @@ public class TypeScriptFetchClientCodegen extends AbstractTypeScriptClientCodege
|
||||
public static final String NPM_REPOSITORY = "npmRepository";
|
||||
public static final String WITH_INTERFACES = "withInterfaces";
|
||||
public static final String USE_SINGLE_REQUEST_PARAMETER = "useSingleRequestParameter";
|
||||
public static final String NAMESPACE_PARAMETER_INTERFACES = "namespaceParameterInterfaces";
|
||||
|
||||
protected String npmRepository = null;
|
||||
private boolean useSingleRequestParameter = true;
|
||||
private boolean namespaceParameterInterfaces = false;
|
||||
protected boolean addedApiIndex = false;
|
||||
protected boolean addedModelIndex = false;
|
||||
|
||||
@@ -59,6 +61,7 @@ public class TypeScriptFetchClientCodegen extends AbstractTypeScriptClientCodege
|
||||
this.cliOptions.add(new CliOption(NPM_REPOSITORY, "Use this property to set an url your private npmRepo in the package.json"));
|
||||
this.cliOptions.add(new CliOption(WITH_INTERFACES, "Setting this property to true will generate interfaces next to the default class implementations.", SchemaTypeUtil.BOOLEAN_TYPE).defaultValue(Boolean.FALSE.toString()));
|
||||
this.cliOptions.add(new CliOption(USE_SINGLE_REQUEST_PARAMETER, "Setting this property to true will generate functions with a single argument containing all API endpoint parameters instead of one argument per parameter.", SchemaTypeUtil.BOOLEAN_TYPE).defaultValue(Boolean.TRUE.toString()));
|
||||
this.cliOptions.add(new CliOption(NAMESPACE_PARAMETER_INTERFACES, "Setting this property to true will generate parameter interface declarations within a dedicated namespace to avoid name conflicts.", SchemaTypeUtil.BOOLEAN_TYPE).defaultValue(Boolean.FALSE.toString()));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -94,6 +97,11 @@ public class TypeScriptFetchClientCodegen extends AbstractTypeScriptClientCodege
|
||||
}
|
||||
writePropertyBack(USE_SINGLE_REQUEST_PARAMETER, getUseSingleRequestParameter());
|
||||
|
||||
if (additionalProperties.containsKey(NAMESPACE_PARAMETER_INTERFACES)) {
|
||||
this.setNamespaceParameterInterfaces(convertPropertyToBoolean(NAMESPACE_PARAMETER_INTERFACES));
|
||||
}
|
||||
writePropertyBack(NAMESPACE_PARAMETER_INTERFACES, getNamespaceParameterInterfaces());
|
||||
|
||||
if (additionalProperties.containsKey(NPM_NAME)) {
|
||||
addNpmPackageGeneration();
|
||||
}
|
||||
@@ -208,6 +216,7 @@ public class TypeScriptFetchClientCodegen extends AbstractTypeScriptClientCodege
|
||||
this.addOperationModelImportInfomation(operations);
|
||||
this.updateOperationParameterEnumInformation(operations);
|
||||
this.addOperationObjectResponseInformation(operations);
|
||||
this.addOperationNamespaceParameterInterfacesInformation(operations);
|
||||
return operations;
|
||||
}
|
||||
|
||||
@@ -254,6 +263,22 @@ public class TypeScriptFetchClientCodegen extends AbstractTypeScriptClientCodege
|
||||
}
|
||||
}
|
||||
|
||||
private void addOperationNamespaceParameterInterfacesInformation(Map<String, Object> operations) {
|
||||
Map<String, Object> _operations = (Map<String, Object>) operations.get("operations");
|
||||
List<CodegenOperation> operationList = (List<CodegenOperation>) _operations.get("operation");
|
||||
if (!operationList.isEmpty() && getNamespaceParameterInterfaces()) {
|
||||
operations.put("namespaceParameterInterfaces", true);
|
||||
operations.put("paramIfaceIndent", " ");
|
||||
operations.put("paramIfaceSuffix", "");
|
||||
operations.put("paramIfaceNsPrefix", operationList.get(0).baseName + "Requests.");
|
||||
} else {
|
||||
operations.put("namespaceParameterInterfaces", false);
|
||||
operations.put("paramIfaceIndent", "");
|
||||
operations.put("paramIfaceSuffix", "Request");
|
||||
operations.put("paramIfaceNsPrefix", "");
|
||||
}
|
||||
}
|
||||
|
||||
private void addExtraReservedWords() {
|
||||
this.reservedWords.add("BASE_PATH");
|
||||
this.reservedWords.add("BaseAPI");
|
||||
@@ -289,4 +314,12 @@ public class TypeScriptFetchClientCodegen extends AbstractTypeScriptClientCodege
|
||||
private void setUseSingleRequestParameter(boolean useSingleRequestParameter) {
|
||||
this.useSingleRequestParameter = useSingleRequestParameter;
|
||||
}
|
||||
|
||||
private boolean getNamespaceParameterInterfaces() {
|
||||
return namespaceParameterInterfaces;
|
||||
}
|
||||
|
||||
private void setNamespaceParameterInterfaces(boolean namespaceParameterInterfaces) {
|
||||
this.namespaceParameterInterfaces = namespaceParameterInterfaces;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
|
||||
package org.openapitools.codegen.utils;
|
||||
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import io.swagger.v3.oas.models.OpenAPI;
|
||||
import io.swagger.v3.oas.models.servers.Server;
|
||||
import io.swagger.v3.oas.models.servers.ServerVariable;
|
||||
@@ -28,9 +29,7 @@ import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.net.MalformedURLException;
|
||||
import java.net.URL;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.*;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
@@ -40,24 +39,28 @@ public class URLPathUtils {
|
||||
public static final String LOCAL_HOST = "http://localhost";
|
||||
public static final Pattern VARIABLE_PATTERN = Pattern.compile("\\{([^\\}]+)\\}");
|
||||
|
||||
public static URL getServerURL(OpenAPI openAPI) {
|
||||
// TODO: This should probably be moved into generator/workflow type rather than a static like this.
|
||||
public static URL getServerURL(OpenAPI openAPI, Map<String, String> userDefinedVariables) {
|
||||
final List<Server> servers = openAPI.getServers();
|
||||
if (servers == null || servers.isEmpty()) {
|
||||
LOGGER.warn("Server information seems not defined in the spec. Default to {}.", LOCAL_HOST);
|
||||
return getDefaultUrl();
|
||||
}
|
||||
// TODO need a way to obtain all server URLs
|
||||
return getServerURL(servers.get(0));
|
||||
return getServerURL(servers.get(0), userDefinedVariables);
|
||||
}
|
||||
|
||||
public static URL getServerURL(final Server server) {
|
||||
public static URL getServerURL(final Server server, final Map<String, String> userDefinedVariables) {
|
||||
String url = server.getUrl();
|
||||
ServerVariables variables = server.getVariables();
|
||||
if (variables == null) {
|
||||
variables = new ServerVariables();
|
||||
}
|
||||
|
||||
Map<String, String> userVariables = userDefinedVariables == null ? new HashMap<>() : ImmutableMap.copyOf(userDefinedVariables);
|
||||
|
||||
if (StringUtils.isNotBlank(url)) {
|
||||
url = extractUrl(server, url, variables);
|
||||
url = extractUrl(server, url, variables, userVariables);
|
||||
url = sanitizeUrl(url);
|
||||
|
||||
try {
|
||||
@@ -69,26 +72,37 @@ public class URLPathUtils {
|
||||
return getDefaultUrl();
|
||||
}
|
||||
|
||||
private static String extractUrl(Server server, String url, ServerVariables variables) {
|
||||
private static String extractUrl(Server server, String url, ServerVariables variables, Map<String, String> userVariables) {
|
||||
Set<String> replacedVariables = new HashSet<>();
|
||||
Matcher matcher = VARIABLE_PATTERN.matcher(url);
|
||||
while (matcher.find()) {
|
||||
if (!replacedVariables.contains(matcher.group())) {
|
||||
ServerVariable variable = variables.get(matcher.group(1));
|
||||
String variableName = matcher.group(1);
|
||||
ServerVariable variable = variables.get(variableName);
|
||||
String replacement;
|
||||
if (variable != null) {
|
||||
if (variable.getDefault() != null) {
|
||||
replacement = variable.getDefault();
|
||||
} else if (variable.getEnum() != null && !variable.getEnum().isEmpty()) {
|
||||
replacement = variable.getEnum().get(0);
|
||||
} else {
|
||||
LOGGER.warn("No value found for variable '{}' in server definition '{}', default to empty string.", matcher.group(1), server.getUrl());
|
||||
replacement = "";
|
||||
String defaultValue = variable.getDefault();
|
||||
List<String> enumValues = variable.getEnum() == null ? new ArrayList<>() : variable.getEnum();
|
||||
if (defaultValue == null && !enumValues.isEmpty()) {
|
||||
defaultValue = enumValues.get(0);
|
||||
} else if (defaultValue == null) {
|
||||
defaultValue = "";
|
||||
}
|
||||
|
||||
replacement = userVariables.getOrDefault(variableName, defaultValue);
|
||||
|
||||
if (!enumValues.isEmpty() && !enumValues.contains(replacement)) {
|
||||
LOGGER.warn("Variable override of '{}' is not listed in the enum of allowed values ({}).", replacement, StringUtils.join(enumValues, ","));
|
||||
}
|
||||
} else {
|
||||
LOGGER.warn("No variable '{}' found in server definition '{}', default to empty string.", matcher.group(1), server.getUrl());
|
||||
replacement = "";
|
||||
replacement = userVariables.getOrDefault(variableName, "");
|
||||
}
|
||||
|
||||
if (StringUtils.isEmpty(replacement)) {
|
||||
replacement = "";
|
||||
LOGGER.warn("No value found for variable '{}' in server definition '{}' and no user override specified, default to empty string.", variableName, server.getUrl());
|
||||
}
|
||||
|
||||
url = url.replace(matcher.group(), replacement);
|
||||
replacedVariables.add(matcher.group());
|
||||
matcher = VARIABLE_PATTERN.matcher(url);
|
||||
@@ -98,7 +112,7 @@ public class URLPathUtils {
|
||||
}
|
||||
|
||||
public static String getScheme(OpenAPI openAPI, CodegenConfig config) {
|
||||
URL url = getServerURL(openAPI);
|
||||
URL url = getServerURL(openAPI, config.serverVariableOverrides());
|
||||
return getScheme(url, config);
|
||||
}
|
||||
|
||||
@@ -176,11 +190,12 @@ public class URLPathUtils {
|
||||
* Return the first complete URL from the OpenAPI specification
|
||||
*
|
||||
* @param openAPI current OpenAPI specification
|
||||
* @param userDefinedVariables User overrides for server variable templating
|
||||
* @return host
|
||||
*/
|
||||
public static String getHost(OpenAPI openAPI) {
|
||||
public static String getHost(OpenAPI openAPI, final Map<String, String> userDefinedVariables) {
|
||||
if (openAPI.getServers() != null && openAPI.getServers().size() > 0) {
|
||||
return sanitizeUrl(getServerURL(openAPI.getServers().get(0)).toString());
|
||||
return sanitizeUrl(getServerURL(openAPI.getServers().get(0), userDefinedVariables).toString());
|
||||
}
|
||||
return LOCAL_HOST;
|
||||
}
|
||||
|
||||
19
modules/openapi-generator/src/main/resources/Java/jackson_annotations.mustache
vendored
Normal file
19
modules/openapi-generator/src/main/resources/Java/jackson_annotations.mustache
vendored
Normal file
@@ -0,0 +1,19 @@
|
||||
{{!
|
||||
If this is map and items are nullable, make sure that nulls are included.
|
||||
To determine what JsonInclude.Include method to use, consider the following:
|
||||
* If the field is required, always include it, even if it is null.
|
||||
* Else use custom behaviour, IOW use whatever is defined on the object mapper
|
||||
}}
|
||||
@JsonProperty(JSON_PROPERTY_{{nameInSnakeCase}})
|
||||
@JsonInclude({{#isMapContainer}}{{#items.isNullable}}content = JsonInclude.Include.ALWAYS, {{/items.isNullable}}{{/isMapContainer}}value = JsonInclude.Include.{{#required}}ALWAYS{{/required}}{{^required}}USE_DEFAULTS{{/required}})
|
||||
{{#withXml}}
|
||||
{{^isContainer}}
|
||||
@JacksonXmlProperty({{#isXmlAttribute}}isAttribute = true, {{/isXmlAttribute}}{{#xmlNamespace}}namespace="{{xmlNamespace}}", {{/xmlNamespace}}localName = "{{#xmlName}}{{xmlName}}{{/xmlName}}{{^xmlName}}{{baseName}}{{/xmlName}}")
|
||||
{{/isContainer}}
|
||||
{{#isContainer}}
|
||||
{{#isXmlWrapped}}
|
||||
// items.xmlName={{items.xmlName}}
|
||||
@JacksonXmlElementWrapper(useWrapping = {{isXmlWrapped}}, {{#xmlNamespace}}namespace="{{xmlNamespace}}", {{/xmlNamespace}}localName = "{{#items.xmlName}}{{items.xmlName}}{{/items.xmlName}}{{^items.xmlName}}{{items.baseName}}{{/items.xmlName}}")
|
||||
{{/isXmlWrapped}}
|
||||
{{/isContainer}}
|
||||
{{/withXml}}
|
||||
@@ -12,6 +12,7 @@ import org.threeten.bp.*;
|
||||
import com.fasterxml.jackson.databind.DeserializationFeature;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.fasterxml.jackson.databind.SerializationFeature;
|
||||
import org.openapitools.jackson.nullable.JsonNullableModule;
|
||||
{{#joda}}
|
||||
import com.fasterxml.jackson.datatype.joda.JodaModule;
|
||||
{{/joda}}
|
||||
@@ -177,6 +178,8 @@ public class ApiClient {
|
||||
module.addDeserializer(ZonedDateTime.class, CustomInstantDeserializer.ZONED_DATE_TIME);
|
||||
objectMapper.registerModule(module);
|
||||
{{/threetenbp}}
|
||||
JsonNullableModule jnm = new JsonNullableModule();
|
||||
objectMapper.registerModule(jnm);
|
||||
return objectMapper;
|
||||
}
|
||||
|
||||
|
||||
@@ -244,6 +244,11 @@
|
||||
<artifactId>jackson-databind</artifactId>
|
||||
<version>${jackson-databind-version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.openapitools</groupId>
|
||||
<artifactId>jackson-databind-nullable</artifactId>
|
||||
<version>${jackson-databind-nullable-version}</version>
|
||||
</dependency>
|
||||
{{#withXml}}
|
||||
|
||||
<!-- XML Support -->
|
||||
@@ -310,6 +315,7 @@
|
||||
<feign-version>{{#useFeign10}}10.2.3{{/useFeign10}}{{^useFeign10}}9.7.0{{/useFeign10}}</feign-version>
|
||||
<feign-form-version>2.1.0</feign-form-version>
|
||||
<jackson-version>2.9.9</jackson-version>
|
||||
<jackson-databind-nullable-version>0.2.0</jackson-databind-nullable-version>
|
||||
<jackson-databind-version>2.9.9</jackson-databind-version>
|
||||
{{#threetenbp}}
|
||||
<jackson-threetenbp-version>2.6.4</jackson-threetenbp-version>
|
||||
|
||||
@@ -4,6 +4,7 @@ import {{apiPackage}}.*;
|
||||
import com.fasterxml.jackson.databind.DeserializationFeature;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.fasterxml.jackson.databind.SerializationFeature;
|
||||
import org.openapitools.jackson.nullable.JsonNullableModule;
|
||||
{{#joda}}
|
||||
import com.fasterxml.jackson.datatype.joda.JodaModule;
|
||||
{{/joda}}
|
||||
@@ -53,6 +54,8 @@ public class ApiClient {
|
||||
module.addDeserializer(ZonedDateTime.class, CustomInstantDeserializer.ZONED_DATE_TIME);
|
||||
objectMapper.registerModule(module);
|
||||
{{/threetenbp}}
|
||||
JsonNullableModule jnm = new JsonNullableModule();
|
||||
objectMapper.registerModule(jnm);
|
||||
return objectMapper;
|
||||
}
|
||||
|
||||
|
||||
@@ -6,6 +6,7 @@ import {{invokerPackage}}.ApiClient;
|
||||
{{/imports}}
|
||||
|
||||
import com.fasterxml.jackson.core.type.TypeReference;
|
||||
import com.google.api.client.http.EmptyContent;
|
||||
import com.google.api.client.http.GenericUrl;
|
||||
import com.google.api.client.http.HttpContent;
|
||||
import com.google.api.client.http.InputStreamContent;
|
||||
@@ -104,10 +105,10 @@ public class {{classname}} {
|
||||
}
|
||||
}{{/queryParams}}{{/hasQueryParams}}
|
||||
|
||||
String url = uriBuilder{{#hasPathParams}}.buildFromMap(uriVariables).toString();{{/hasPathParams}}{{^hasPathParams}}.build().toString();{{/hasPathParams}}
|
||||
GenericUrl genericUrl = new GenericUrl(url);
|
||||
String localVarUrl = uriBuilder{{#hasPathParams}}.buildFromMap(uriVariables).toString();{{/hasPathParams}}{{^hasPathParams}}.build().toString();{{/hasPathParams}}
|
||||
GenericUrl genericUrl = new GenericUrl(localVarUrl);
|
||||
|
||||
HttpContent content = {{#isBodyAllowed}}apiClient.new JacksonJsonHttpContent({{#bodyParam}}{{paramName}}{{/bodyParam}}{{^bodyParam}}null{{/bodyParam}}){{/isBodyAllowed}}{{^isBodyAllowed}}null{{/isBodyAllowed}};
|
||||
HttpContent content = {{#isBodyAllowed}}{{#bodyParam}}apiClient.new JacksonJsonHttpContent({{paramName}}){{/bodyParam}}{{^bodyParam}}new EmptyContent(){{/bodyParam}}{{/isBodyAllowed}}{{^isBodyAllowed}}null{{/isBodyAllowed}};
|
||||
return apiClient.getHttpRequestFactory().buildRequest(HttpMethods.{{httpMethod}}, genericUrl, content).execute();
|
||||
}{{#bodyParam}}
|
||||
|
||||
@@ -135,8 +136,8 @@ public class {{classname}} {
|
||||
}
|
||||
}{{/queryParams}}{{/hasQueryParams}}
|
||||
|
||||
String url = uriBuilder{{#hasPathParams}}.buildFromMap(uriVariables).toString();{{/hasPathParams}}{{^hasPathParams}}.build().toString();{{/hasPathParams}}
|
||||
GenericUrl genericUrl = new GenericUrl(url);
|
||||
String localVarUrl = uriBuilder{{#hasPathParams}}.buildFromMap(uriVariables).toString();{{/hasPathParams}}{{^hasPathParams}}.build().toString();{{/hasPathParams}}
|
||||
GenericUrl genericUrl = new GenericUrl(localVarUrl);
|
||||
|
||||
HttpContent content = {{#bodyParam}}{{paramName}} == null ?
|
||||
apiClient.new JacksonJsonHttpContent(null) :
|
||||
@@ -176,10 +177,10 @@ public class {{classname}} {
|
||||
}
|
||||
}
|
||||
|
||||
String url = uriBuilder{{#hasPathParams}}.buildFromMap(uriVariables).toString();{{/hasPathParams}}{{^hasPathParams}}.build().toString();{{/hasPathParams}}
|
||||
GenericUrl genericUrl = new GenericUrl(url);
|
||||
String localVarUrl = uriBuilder{{#hasPathParams}}.buildFromMap(uriVariables).toString();{{/hasPathParams}}{{^hasPathParams}}.build().toString();{{/hasPathParams}}
|
||||
GenericUrl genericUrl = new GenericUrl(localVarUrl);
|
||||
|
||||
HttpContent content = {{#isBodyAllowed}}apiClient.new JacksonJsonHttpContent({{#bodyParam}}{{paramName}}{{/bodyParam}}{{^bodyParam}}null{{/bodyParam}}){{/isBodyAllowed}}{{^isBodyAllowed}}null{{/isBodyAllowed}};
|
||||
HttpContent content = {{#isBodyAllowed}}{{#bodyParam}}apiClient.new JacksonJsonHttpContent({{paramName}}){{/bodyParam}}{{^bodyParam}}new EmptyContent(){{/bodyParam}}{{/isBodyAllowed}}{{^isBodyAllowed}}null{{/isBodyAllowed}};
|
||||
return apiClient.getHttpRequestFactory().buildRequest(HttpMethods.{{httpMethod}}, genericUrl, content).execute();
|
||||
}
|
||||
|
||||
|
||||
@@ -253,6 +253,11 @@
|
||||
<artifactId>jackson-databind</artifactId>
|
||||
<version>${jackson-version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.openapitools</groupId>
|
||||
<artifactId>jackson-databind-nullable</artifactId>
|
||||
<version>${jackson-databind-nullable-version}</version>
|
||||
</dependency>
|
||||
{{#withXml}}
|
||||
<!-- XML processing: Jackson -->
|
||||
<dependency>
|
||||
@@ -303,6 +308,7 @@
|
||||
<jersey-common-version>2.25.1</jersey-common-version>
|
||||
<jackson-version>2.9.9</jackson-version>
|
||||
<jackson-databind-version>2.9.9</jackson-databind-version>
|
||||
<jackson-databind-nullable-version>0.2.0</jackson-databind-nullable-version>
|
||||
{{#joda}}
|
||||
<jodatime-version>2.9.9</jodatime-version>
|
||||
{{/joda}}
|
||||
|
||||
@@ -704,7 +704,7 @@ public class ApiClient {
|
||||
}
|
||||
}
|
||||
|
||||
Entity<?> entity = serialize(body, formParams, contentType);
|
||||
Entity<?> entity = (body == null) ? Entity.json("") : serialize(body, formParams, contentType);
|
||||
|
||||
Response response = null;
|
||||
|
||||
@@ -716,11 +716,15 @@ public class ApiClient {
|
||||
} else if ("PUT".equals(method)) {
|
||||
response = invocationBuilder.put(entity);
|
||||
} else if ("DELETE".equals(method)) {
|
||||
response = invocationBuilder.delete();
|
||||
response = invocationBuilder.method("DELETE", entity);
|
||||
} else if ("PATCH".equals(method)) {
|
||||
response = invocationBuilder.method("PATCH", entity);
|
||||
} else if ("HEAD".equals(method)) {
|
||||
response = invocationBuilder.head();
|
||||
} else if ("OPTIONS".equals(method)) {
|
||||
response = invocationBuilder.options();
|
||||
} else if ("TRACE".equals(method)) {
|
||||
response = invocationBuilder.trace();
|
||||
} else {
|
||||
throw new ApiException(500, "unknown method type " + method);
|
||||
}
|
||||
@@ -772,6 +776,8 @@ public class ApiClient {
|
||||
clientConfig.register(json);
|
||||
clientConfig.register(JacksonFeature.class);
|
||||
clientConfig.property(HttpUrlConnectorProvider.SET_METHOD_WORKAROUND, true);
|
||||
// turn off compliance validation to be able to send payloads with DELETE calls
|
||||
clientConfig.property(ClientProperties.SUPPRESS_HTTP_COMPLIANCE_VALIDATION, true);
|
||||
if (debugging) {
|
||||
{{^supportJava6}}
|
||||
clientConfig.register(new LoggingFeature(java.util.logging.Logger.getLogger(LoggingFeature.DEFAULT_LOGGER_NAME), java.util.logging.Level.INFO, LoggingFeature.Verbosity.PAYLOAD_ANY, 1024*50 /* Log payloads up to 50K */));
|
||||
@@ -782,6 +788,9 @@ public class ApiClient {
|
||||
{{#supportJava6}}
|
||||
clientConfig.register(new LoggingFilter(java.util.logging.Logger.getLogger(LoggingFilter.class.getName()), true));
|
||||
{{/supportJava6}}
|
||||
} else {
|
||||
// suppress warnings for payloads with DELETE calls:
|
||||
java.util.logging.Logger.getLogger("org.glassfish.jersey.client").setLevel(java.util.logging.Level.SEVERE);
|
||||
}
|
||||
performAdditionalClientConfiguration(clientConfig);
|
||||
return ClientBuilder.newClient(clientConfig);
|
||||
|
||||
@@ -5,6 +5,7 @@ import org.threeten.bp.*;
|
||||
{{/threetenbp}}
|
||||
import com.fasterxml.jackson.annotation.*;
|
||||
import com.fasterxml.jackson.databind.*;
|
||||
import org.openapitools.jackson.nullable.JsonNullableModule;
|
||||
{{#java8}}
|
||||
import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule;
|
||||
{{/java8}}
|
||||
@@ -45,6 +46,8 @@ public class JSON implements ContextResolver<ObjectMapper> {
|
||||
module.addDeserializer(ZonedDateTime.class, CustomInstantDeserializer.ZONED_DATE_TIME);
|
||||
mapper.registerModule(module);
|
||||
{{/threetenbp}}
|
||||
JsonNullableModule jnm = new JsonNullableModule();
|
||||
mapper.registerModule(jnm);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -107,7 +107,7 @@ public class {{classname}} {
|
||||
@Deprecated
|
||||
{{/isDeprecated}}
|
||||
public ApiResponse<{{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}Void{{/returnType}}> {{operationId}}WithHttpInfo({{#allParams}}{{{dataType}}} {{paramName}}{{#hasMore}}, {{/hasMore}}{{/allParams}}) throws ApiException {
|
||||
Object localVarPostBody = {{#bodyParam}}{{paramName}}{{/bodyParam}}{{^bodyParam}}new Object(){{/bodyParam}};
|
||||
Object localVarPostBody = {{#bodyParam}}{{paramName}}{{/bodyParam}}{{^bodyParam}}null{{/bodyParam}};
|
||||
{{#allParams}}{{#required}}
|
||||
// verify the required parameter '{{paramName}}' is set
|
||||
if ({{paramName}} == null) {
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user