mirror of
https://github.com/OpenAPITools/openapi-generator.git
synced 2025-12-19 02:47:05 +00:00
Compare commits
87 Commits
security-t
...
v4.0.0-bet
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b3146c9983 | ||
|
|
b7b68ce0bc | ||
|
|
d42b6d987a | ||
|
|
0889b8ec13 | ||
|
|
887b02c818 | ||
|
|
5a34f8428c | ||
|
|
128da8e84b | ||
|
|
ec42aca438 | ||
|
|
b55cdfbe53 | ||
|
|
182264cbdd | ||
|
|
ee69861a90 | ||
|
|
69ad9a9957 | ||
|
|
9c7d4073f4 | ||
|
|
f4fa941e2b | ||
|
|
c81c09b941 | ||
|
|
822234dd76 | ||
|
|
18b500218a | ||
|
|
977df6e232 | ||
|
|
976ab4fd0f | ||
|
|
8977d7b366 | ||
|
|
c4d982f775 | ||
|
|
f26d7bdea7 | ||
|
|
3bb4edf865 | ||
|
|
0bc06f8d4d | ||
|
|
d056df6250 | ||
|
|
cd6779584f | ||
|
|
09ba78b26a | ||
|
|
e58d7d09d5 | ||
|
|
9d10ffdb38 | ||
|
|
88cdbbc41f | ||
|
|
3a0d520c38 | ||
|
|
1313cff93a | ||
|
|
a079f70fb2 | ||
|
|
74fbd3454b | ||
|
|
46e8ccbd1e | ||
|
|
0f99cd0d37 | ||
|
|
7ab73ff587 | ||
|
|
1c1c1ef9c3 | ||
|
|
2ce3574868 | ||
|
|
81c57eefd5 | ||
|
|
6e7c621629 | ||
|
|
41b5d0e8fc | ||
|
|
09d27e82e7 | ||
|
|
393f5e499e | ||
|
|
d795c4e9d0 | ||
|
|
01e8c67da9 | ||
|
|
d4244be654 | ||
|
|
5a6f4cb4a9 | ||
|
|
5d05cc0e66 | ||
|
|
28ae33cb13 | ||
|
|
9e391efd1d | ||
|
|
173ae6f368 | ||
|
|
7af272a249 | ||
|
|
879d47ccd0 | ||
|
|
65e36e8369 | ||
|
|
f015363dbd | ||
|
|
3677bdcfc7 | ||
|
|
3810d12086 | ||
|
|
c918d7ad64 | ||
|
|
5346eb4c34 | ||
|
|
3e065db2c6 | ||
|
|
5074f4d9c5 | ||
|
|
df0d53795c | ||
|
|
3b017c59f1 | ||
|
|
e0caa6fd66 | ||
|
|
0935f5345d | ||
|
|
f7943257c5 | ||
|
|
033ab8a6f5 | ||
|
|
1adc962f2b | ||
|
|
94c267ee42 | ||
|
|
4a7dfecf24 | ||
|
|
db1b63780d | ||
|
|
e3716262e5 | ||
|
|
ee75366051 | ||
|
|
d839af5b1e | ||
|
|
2e777c04d4 | ||
|
|
b1955f3517 | ||
|
|
45ad72b032 | ||
|
|
2101780a09 | ||
|
|
1a19edb0e5 | ||
|
|
2f8e4fe32b | ||
|
|
77545df80d | ||
|
|
dc78405a68 | ||
|
|
fef2970dab | ||
|
|
522ccee7f3 | ||
|
|
d32564da51 | ||
|
|
49f3e9a355 |
@@ -1 +1 @@
|
|||||||
oracle64-1.8.0.152
|
oracle64-1.8.0.152
|
||||||
@@ -133,18 +133,16 @@ after_success:
|
|||||||
cd modules/openapi-generator-gradle-plugin;
|
cd modules/openapi-generator-gradle-plugin;
|
||||||
./gradlew -Psigning.keyId="$SIGNING_KEY" -Psigning.password="$SIGNING_PASSPHRASE" -Psigning.secretKeyRingFile="${TRAVIS_BUILD_DIR}/sec.gpg" -PossrhUsername="${SONATYPE_USERNAME}" -PossrhPassword="${SONATYPE_PASSWORD}" uploadArchives --no-daemon;
|
./gradlew -Psigning.keyId="$SIGNING_KEY" -Psigning.password="$SIGNING_PASSPHRASE" -Psigning.secretKeyRingFile="${TRAVIS_BUILD_DIR}/sec.gpg" -PossrhUsername="${SONATYPE_USERNAME}" -PossrhPassword="${SONATYPE_PASSWORD}" uploadArchives --no-daemon;
|
||||||
echo "Finished ./gradlew uploadArchives";
|
echo "Finished ./gradlew uploadArchives";
|
||||||
#./gradlew publishPlugins;
|
|
||||||
#echo "Finished ./gradlew publishPlugins (plugin portal)";
|
|
||||||
popd;
|
popd;
|
||||||
elif ([[ "$TRAVIS_BRANCH" =~ ^[0-9]+\.[0-9]+\.x$ ]]) ; then
|
elif ([[ "$TRAVIS_BRANCH" =~ ^[0-9]+\.[0-9]+\.x$ ]]) ; then
|
||||||
mvn clean deploy --settings CI/settings.xml;
|
mvn clean deploy --settings CI/settings.xml;
|
||||||
echo "Finished mvn clean deploy for $TRAVIS_BRANCH";
|
echo "Finished mvn clean deploy for $TRAVIS_BRANCH";
|
||||||
pushd .;
|
pushd .;
|
||||||
cd modules/openapi-generator-gradle-plugin;
|
cd modules/openapi-generator-gradle-plugin;
|
||||||
|
./gradlew -Psigning.keyId="$SIGNING_KEY" -Psigning.password="$SIGNING_PASSPHRASE" -Psigning.secretKeyRingFile="${TRAVIS_BUILD_DIR}/sec.gpg" publishPlugins -Dgradle.publish.key=$GRADLE_PUBLISH_KEY -Dgradle.publish.secret=$GRADLE_PUBLISH_SECRET --no-daemon;
|
||||||
|
echo "Finished ./gradlew publishPlugins (plugin portal)";
|
||||||
./gradlew -PossrhUsername="${SONATYPE_USERNAME}" -PossrhPassword="${SONATYPE_PASSWORD}" uploadArchives --no-daemon;
|
./gradlew -PossrhUsername="${SONATYPE_USERNAME}" -PossrhPassword="${SONATYPE_PASSWORD}" uploadArchives --no-daemon;
|
||||||
echo "Finished ./gradlew uploadArchives";
|
echo "Finished ./gradlew uploadArchives";
|
||||||
#./gradlew publishPlugins;
|
|
||||||
#echo "Finished ./gradlew publishPlugins (plugin portal)";
|
|
||||||
popd;
|
popd;
|
||||||
fi;
|
fi;
|
||||||
fi;
|
fi;
|
||||||
|
|||||||
12
README.md
12
README.md
@@ -39,7 +39,7 @@ OpenAPI Generator allows generation of API client libraries (SDK generation), se
|
|||||||
| | Languages/Frameworks |
|
| | Languages/Frameworks |
|
||||||
|-|-|
|
|-|-|
|
||||||
**API clients** | **ActionScript**, **Ada**, **Apex**, **Bash**, **C**, **C#** (.net 2.0, 3.5 or later), **C++** (cpprest, Qt5, Tizen), **Clojure**, **Dart (1.x, 2.x)**, **Elixir**, **Elm**, **Eiffel**, **Erlang**, **Go**, **Groovy**, **Haskell** (http-client, Servant), **Java** (Jersey1.x, Jersey2.x, OkHttp, Retrofit1.x, Retrofit2.x, Feign, RestTemplate, RESTEasy, Vertx, Google API Client Library for Java, Rest-assured, Spring 5 Web Client), **Kotlin**, **Lua**, **Node.js** (ES5, ES6, AngularJS with Google Closure Compiler annotations, Flow types) **Objective-C**, **Perl**, **PHP**, **PowerShell**, **Python**, **R**, **Ruby**, **Rust** (rust, rust-server), **Scala** (akka, http4s, scalaz, swagger-async-httpclient), **Swift** (2.x, 3.x, 4.x), **Typescript** (AngularJS, Angular (2.x - 7.x), Aurelia, Axios, Fetch, Inversify, jQuery, Node, Rxjs)
|
**API clients** | **ActionScript**, **Ada**, **Apex**, **Bash**, **C**, **C#** (.net 2.0, 3.5 or later), **C++** (cpprest, Qt5, Tizen), **Clojure**, **Dart (1.x, 2.x)**, **Elixir**, **Elm**, **Eiffel**, **Erlang**, **Go**, **Groovy**, **Haskell** (http-client, Servant), **Java** (Jersey1.x, Jersey2.x, OkHttp, Retrofit1.x, Retrofit2.x, Feign, RestTemplate, RESTEasy, Vertx, Google API Client Library for Java, Rest-assured, Spring 5 Web Client), **Kotlin**, **Lua**, **Node.js** (ES5, ES6, AngularJS with Google Closure Compiler annotations, Flow types) **Objective-C**, **Perl**, **PHP**, **PowerShell**, **Python**, **R**, **Ruby**, **Rust** (rust, rust-server), **Scala** (akka, http4s, scalaz, swagger-async-httpclient), **Swift** (2.x, 3.x, 4.x), **Typescript** (AngularJS, Angular (2.x - 7.x), Aurelia, Axios, Fetch, Inversify, jQuery, Node, Rxjs)
|
||||||
**Server stubs** | **Ada**, **C#** (ASP.NET Core, NancyFx), **C++** (Pistache, Restbed), **Erlang**, **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), Scalatra)
|
**Server stubs** | **Ada**, **C#** (ASP.NET Core, NancyFx), **C++** (Pistache, Restbed), **Erlang**, **Go** (net/http, Gin), **Haskell** (Servant), **Java** (MSF4J, Spring, Undertow, JAX-RS: CDI, CXF, Inflector, RestEasy, Play Framework, [PKMST](https://github.com/ProKarma-Inc/pkmst-getting-started-examples)), **Kotlin** (Spring Boot, Ktor), **PHP** (Laravel, Lumen, Slim, Silex, [Symfony](https://symfony.com/), [Zend Expressive](https://github.com/zendframework/zend-expressive)), **Python** (Flask), **NodeJS**, **Ruby** (Sinatra, Rails5), **Rust** (rust-server), **Scala** ([Finch](https://github.com/finagle/finch), [Lagom](https://github.com/lagom/lagom), [Play](https://www.playframework.com/), Scalatra)
|
||||||
**API documentation generators** | **HTML**, **Confluence Wiki**
|
**API documentation generators** | **HTML**, **Confluence Wiki**
|
||||||
**Configuration files** | [**Apache2**](https://httpd.apache.org/)
|
**Configuration files** | [**Apache2**](https://httpd.apache.org/)
|
||||||
**Others** | **GraphQL**, **JMeter**, **MySQL Schema**
|
**Others** | **GraphQL**, **JMeter**, **MySQL Schema**
|
||||||
@@ -511,6 +511,7 @@ Here are some companies/projects (alphabetical order) using OpenAPI Generator in
|
|||||||
- [FormAPI](https://formapi.io/)
|
- [FormAPI](https://formapi.io/)
|
||||||
- [GenFlow](https://github.com/RepreZen/GenFlow)
|
- [GenFlow](https://github.com/RepreZen/GenFlow)
|
||||||
- [GMO Pepabo](https://pepabo.com/en/)
|
- [GMO Pepabo](https://pepabo.com/en/)
|
||||||
|
- [GoDaddy](https://godaddy.com)
|
||||||
- [JustStar](https://www.juststarinfo.com)
|
- [JustStar](https://www.juststarinfo.com)
|
||||||
- [Klarna](https://www.klarna.com/)
|
- [Klarna](https://www.klarna.com/)
|
||||||
- [Metaswitch](https://www.metaswitch.com/)
|
- [Metaswitch](https://www.metaswitch.com/)
|
||||||
@@ -551,6 +552,10 @@ Here are some companies/projects (alphabetical order) using OpenAPI Generator in
|
|||||||
- 2019/02/20 - [An adventure in OpenAPI V3 code generation](https://mux.com/blog/an-adventure-in-openapi-v3-api-code-generation/) by [Phil Cluff](https://mux.com/blog/author/philc/)
|
- 2019/02/20 - [An adventure in OpenAPI V3 code generation](https://mux.com/blog/an-adventure-in-openapi-v3-api-code-generation/) by [Phil Cluff](https://mux.com/blog/author/philc/)
|
||||||
- 2019/02/26 - [Building API Services: A Beginner’s Guide](https://medium.com/google-cloud/building-api-services-a-beginners-guide-7274ae4c547f) by [Ratros Y.](https://medium.com/@ratrosy) in [Google Cloud Platofrm Blog](https://medium.com/google-cloud)
|
- 2019/02/26 - [Building API Services: A Beginner’s Guide](https://medium.com/google-cloud/building-api-services-a-beginners-guide-7274ae4c547f) by [Ratros Y.](https://medium.com/@ratrosy) in [Google Cloud Platofrm Blog](https://medium.com/google-cloud)
|
||||||
- 2019/02/26 - [Building APIs with OpenAPI: Continued](https://medium.com/@ratrosy/building-apis-with-openapi-continued-5d0faaed32eb) by [Ratros Y.](https://medium.com/@ratrosy) in [Google Cloud Platofrm Blog](https://medium.com/google-cloud)
|
- 2019/02/26 - [Building APIs with OpenAPI: Continued](https://medium.com/@ratrosy/building-apis-with-openapi-continued-5d0faaed32eb) by [Ratros Y.](https://medium.com/@ratrosy) in [Google Cloud Platofrm Blog](https://medium.com/google-cloud)
|
||||||
|
- 2019-03-07 - [OpenAPI Generator で Spring Boot と Angular をタイプセーフに繋ぐ](https://qiita.com/chibato/items/e4a748db12409b40c02f) by [Tomofumi Chiba](https://github.com/chibat)
|
||||||
|
- 2019-03-25 - [Access any REST service with the SAP S/4HANA Cloud SDK](https://blogs.sap.com/2019/03/25/integrate-sap-s4hana-cloud-sdk-with-open-api/) by [Alexander Duemont](https://people.sap.com/alexander.duemont)
|
||||||
|
- 2019-03-25 - [OpenAPI generatorを試してみる](https://qiita.com/amuyikam/items/e8a45daae59c68be0fc8) by [@amuyikam](https://twitter.com/amuyikam)
|
||||||
|
- 2019-03-27 - [OpenAPI3を使ってみよう!Go言語でクライアントとスタブの自動生成まで!](https://techblog.zozo.com/entry/openapi3/go) by [@gold_kou](https://twitter.com/gold_kou)
|
||||||
|
|
||||||
## [6 - About Us](#table-of-contents)
|
## [6 - About Us](#table-of-contents)
|
||||||
|
|
||||||
@@ -662,6 +667,7 @@ Here is a list of template creators:
|
|||||||
* Rust (rust-server): @metaswitch
|
* Rust (rust-server): @metaswitch
|
||||||
* Scala Finch: @jimschubert [:heart:](https://www.patreon.com/jimschubert)
|
* Scala Finch: @jimschubert [:heart:](https://www.patreon.com/jimschubert)
|
||||||
* Scala Lagom: @gmkumar2005
|
* Scala Lagom: @gmkumar2005
|
||||||
|
* Scala Play: @adigerber
|
||||||
* Documentation
|
* Documentation
|
||||||
* HTML Doc 2: @jhitchcock
|
* HTML Doc 2: @jhitchcock
|
||||||
* Confluence Wiki: @jhitchcock
|
* Confluence Wiki: @jhitchcock
|
||||||
@@ -722,8 +728,8 @@ If you want to join the committee, please kindly apply by sending an email to te
|
|||||||
| GraphQL | @renepardon (2018/12) |
|
| GraphQL | @renepardon (2018/12) |
|
||||||
| Groovy | |
|
| Groovy | |
|
||||||
| Haskell | |
|
| Haskell | |
|
||||||
| Java | @bbdouglas (2017/07) @sreeshas (2017/08) @jfiala (2017/08) @lukoyanov (2017/09) @cbornet (2017/09) @jeff9finger (2018/01) |
|
| Java | @bbdouglas (2017/07) @sreeshas (2017/08) @jfiala (2017/08) @lukoyanov (2017/09) @cbornet (2017/09) @jeff9finger (2018/01) @karismann (2019/03) |
|
||||||
| Kotlin | @jimschubert (2017/09) [:heart:](https://www.patreon.com/jimschubert), @dr4ke616 (2018/08) |
|
| Kotlin | @jimschubert (2017/09) [:heart:](https://www.patreon.com/jimschubert), @dr4ke616 (2018/08) @karismann (2019/03) |
|
||||||
| Lua | @daurnimator (2017/08) |
|
| Lua | @daurnimator (2017/08) |
|
||||||
| NodeJS/Javascript | @CodeNinjai (2017/07) @frol (2017/07) @cliffano (2017/07) |
|
| NodeJS/Javascript | @CodeNinjai (2017/07) @frol (2017/07) @cliffano (2017/07) |
|
||||||
| ObjC | |
|
| ObjC | |
|
||||||
|
|||||||
@@ -35,6 +35,14 @@ java $JAVA_OPTS -jar $executable $ags
|
|||||||
ags="$@ generate -t modules/openapi-generator/src/main/resources/dart-jaguar -i modules/openapi-generator/src/test/resources/2_0/petstore.yaml -g dart-jaguar -o samples/client/petstore/dart-jaguar/flutter_petstore/openapi -DhideGenerationTimestamp=true -DpubName=openapi"
|
ags="$@ generate -t modules/openapi-generator/src/main/resources/dart-jaguar -i modules/openapi-generator/src/test/resources/2_0/petstore.yaml -g dart-jaguar -o samples/client/petstore/dart-jaguar/flutter_petstore/openapi -DhideGenerationTimestamp=true -DpubName=openapi"
|
||||||
java $JAVA_OPTS -jar $executable $ags
|
java $JAVA_OPTS -jar $executable $ags
|
||||||
|
|
||||||
|
# Generate proto and put it to the flutter sample app
|
||||||
|
ags="$@ generate -t modules/openapi-generator/src/main/resources/dart-jaguar -i modules/openapi-generator/src/test/resources/2_0/petstore-proto.yaml -g dart-jaguar -o samples/client/petstore/dart-jaguar/flutter_proto_petstore/openapi -Dserialization=proto -DhideGenerationTimestamp=true -DpubName=openapi"
|
||||||
|
java $JAVA_OPTS -jar $executable $ags
|
||||||
|
|
||||||
|
# Generate proto and put it to the sample
|
||||||
|
ags="$@ generate -t modules/openapi-generator/src/main/resources/dart-jaguar -i modules/openapi-generator/src/test/resources/2_0/petstore-proto.yaml -g dart-jaguar -o samples/client/petstore/dart-jaguar/openapi_proto -Dserialization=proto -DhideGenerationTimestamp=true -DpubName=openapi"
|
||||||
|
java $JAVA_OPTS -jar $executable $ags
|
||||||
|
|
||||||
# There is a proposal to allow importing different libraries depending on the environment:
|
# There is a proposal to allow importing different libraries depending on the environment:
|
||||||
# https://github.com/munificent/dep-interface-libraries
|
# https://github.com/munificent/dep-interface-libraries
|
||||||
# When this is implemented there will only be one library.
|
# When this is implemented there will only be one library.
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
{
|
{
|
||||||
"library": "vertx",
|
"library": "vertx",
|
||||||
|
"dateLibrary": "java8",
|
||||||
"artifactId": "petstore-vertx"
|
"artifactId": "petstore-vertx"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -25,6 +25,11 @@ then
|
|||||||
mvn -B clean package
|
mvn -B clean package
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
echo "purge ruby petstore lib, docs, spec folder"
|
||||||
|
rm -Rf samples/client/petstore/ruby/lib
|
||||||
|
rm -Rf samples/client/petstore/ruby/docs
|
||||||
|
rm -Rf samples/client/petstore/ruby/spec
|
||||||
|
|
||||||
# if you've executed sbt assembly previously it will use that instead.
|
# if you've executed sbt assembly previously it will use that instead.
|
||||||
export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties"
|
export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties"
|
||||||
ags="generate -t modules/openapi-generator/src/main/resources/ruby-client -i modules/openapi-generator/src/test/resources/2_0/petstore-with-fake-endpoints-models-for-testing.yaml -g ruby -c bin/ruby-petstore.json -o samples/client/petstore/ruby $@"
|
ags="generate -t modules/openapi-generator/src/main/resources/ruby-client -i modules/openapi-generator/src/test/resources/2_0/petstore-with-fake-endpoints-models-for-testing.yaml -g ruby -c bin/ruby-petstore.json -o samples/client/petstore/ruby $@"
|
||||||
|
|||||||
@@ -22,11 +22,11 @@ executable="./modules/openapi-generator-cli/target/openapi-generator-cli.jar"
|
|||||||
|
|
||||||
if [ ! -f "$executable" ]
|
if [ ! -f "$executable" ]
|
||||||
then
|
then
|
||||||
mvn clean package
|
mvn -B clean package
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# if you've executed sbt assembly previously it will use that instead.
|
# if you've executed sbt assembly previously it will use that instead.
|
||||||
export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties"
|
export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties"
|
||||||
ags="generate -t modules/openapi-generator/src/main/resources/scala-httpclient -i modules/openapi-generator/src/test/resources/2_0/petstore-security-test.yaml -g scala-httpclient -o samples/client/petstore-security-test/scala-httpclient $@"
|
ags="generate -t modules/openapi-generator/src/main/resources/scala-play-server -i modules/openapi-generator/src/test/resources/2_0/petstore.yaml -g scala-play-server -o samples/server/petstore/scala-play-server $@"
|
||||||
|
|
||||||
java $JAVA_OPTS -jar $executable $ags
|
java $JAVA_OPTS -jar $executable $ags
|
||||||
@@ -1,32 +0,0 @@
|
|||||||
#!/bin/sh
|
|
||||||
|
|
||||||
SCRIPT="$0"
|
|
||||||
echo "# START SCRIPT: $SCRIPT"
|
|
||||||
|
|
||||||
while [ -h "$SCRIPT" ] ; do
|
|
||||||
ls=`ls -ld "$SCRIPT"`
|
|
||||||
link=`expr "$ls" : '.*-> \(.*\)$'`
|
|
||||||
if expr "$link" : '/.*' > /dev/null; then
|
|
||||||
SCRIPT="$link"
|
|
||||||
else
|
|
||||||
SCRIPT=`dirname "$SCRIPT"`/"$link"
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
|
|
||||||
if [ ! -d "${APP_DIR}" ]; then
|
|
||||||
APP_DIR=`dirname "$SCRIPT"`/..
|
|
||||||
APP_DIR=`cd "${APP_DIR}"; pwd`
|
|
||||||
fi
|
|
||||||
|
|
||||||
executable="./modules/openapi-generator-cli/target/openapi-generator-cli.jar"
|
|
||||||
|
|
||||||
if [ ! -f "$executable" ]
|
|
||||||
then
|
|
||||||
mvn clean package
|
|
||||||
fi
|
|
||||||
|
|
||||||
# if you've executed sbt assembly previously it will use that instead.
|
|
||||||
export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties"
|
|
||||||
ags="generate -t modules/openapi-generator/src/main/resources/cpp-qt5-client -i modules/openapi-generator/src/test/resources/2_0/petstore-security-test.yaml -g cpp-qt5-client -o samples/client/petstore-security-test/cpp-qt5 $@"
|
|
||||||
|
|
||||||
java $JAVA_OPTS -jar $executable $ags
|
|
||||||
@@ -1,32 +0,0 @@
|
|||||||
#!/bin/sh
|
|
||||||
|
|
||||||
SCRIPT="$0"
|
|
||||||
echo "# START SCRIPT: $SCRIPT"
|
|
||||||
|
|
||||||
while [ -h "$SCRIPT" ] ; do
|
|
||||||
ls=`ls -ld "$SCRIPT"`
|
|
||||||
link=`expr "$ls" : '.*-> \(.*\)$'`
|
|
||||||
if expr "$link" : '/.*' > /dev/null; then
|
|
||||||
SCRIPT="$link"
|
|
||||||
else
|
|
||||||
SCRIPT=`dirname "$SCRIPT"`/"$link"
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
|
|
||||||
if [ ! -d "${APP_DIR}" ]; then
|
|
||||||
APP_DIR=`dirname "$SCRIPT"`/..
|
|
||||||
APP_DIR=`cd "${APP_DIR}"; pwd`
|
|
||||||
fi
|
|
||||||
|
|
||||||
executable="./modules/openapi-generator-cli/target/openapi-generator-cli.jar"
|
|
||||||
|
|
||||||
if [ ! -f "$executable" ]
|
|
||||||
then
|
|
||||||
mvn clean package
|
|
||||||
fi
|
|
||||||
|
|
||||||
# if you've executed sbt assembly previously it will use that instead.
|
|
||||||
export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties"
|
|
||||||
ags="generate -i modules/openapi-generator/src/test/resources/2_0/petstore-security-test.yaml -g csharp -o samples/client/petstore-security-test/csharp/SwaggerClient --additional-properties packageGuid={8CE139DF-64BC-4591-85F8-8506C2B67514} $@"
|
|
||||||
|
|
||||||
java $JAVA_OPTS -jar $executable $ags
|
|
||||||
@@ -1,39 +0,0 @@
|
|||||||
#!/bin/sh
|
|
||||||
|
|
||||||
SCRIPT="$0"
|
|
||||||
echo "# START SCRIPT: $SCRIPT"
|
|
||||||
|
|
||||||
while [ -h "$SCRIPT" ] ; do
|
|
||||||
ls=`ls -ld "$SCRIPT"`
|
|
||||||
link=`expr "$ls" : '.*-> \(.*\)$'`
|
|
||||||
if expr "$link" : '/.*' > /dev/null; then
|
|
||||||
SCRIPT="$link"
|
|
||||||
else
|
|
||||||
SCRIPT=`dirname "$SCRIPT"`/"$link"
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
|
|
||||||
if [ ! -d "${APP_DIR}" ]; then
|
|
||||||
APP_DIR=`dirname "$SCRIPT"`/..
|
|
||||||
APP_DIR=`cd "${APP_DIR}"; pwd`
|
|
||||||
fi
|
|
||||||
|
|
||||||
executable="./modules/openapi-generator-cli/target/openapi-generator-cli.jar"
|
|
||||||
|
|
||||||
if [ ! -f "$executable" ]
|
|
||||||
then
|
|
||||||
mvn clean package
|
|
||||||
fi
|
|
||||||
|
|
||||||
SPEC="modules/openapi-generator/src/test/resources/2_0/petstore-security-test.yaml"
|
|
||||||
GENERATOR="go"
|
|
||||||
STUB_DIR="samples/client/petstore-security-test/go"
|
|
||||||
|
|
||||||
echo "Removing files and folders under $STUB_DIR"
|
|
||||||
rm -rf $STUB_DIR
|
|
||||||
|
|
||||||
# if you've executed sbt assembly previously it will use that instead.
|
|
||||||
export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties"
|
|
||||||
ags="generate -t modules/openapi-generator/src/main/resources/go -i $SPEC -g $GENERATOR -o $STUB_DIR $@"
|
|
||||||
|
|
||||||
java $JAVA_OPTS -jar $executable $ags
|
|
||||||
@@ -1,34 +0,0 @@
|
|||||||
#!/bin/sh
|
|
||||||
|
|
||||||
SCRIPT="$0"
|
|
||||||
echo "# START SCRIPT: $SCRIPT"
|
|
||||||
|
|
||||||
while [ -h "$SCRIPT" ] ; do
|
|
||||||
ls=`ls -ld "$SCRIPT"`
|
|
||||||
link=`expr "$ls" : '.*-> \(.*\)$'`
|
|
||||||
if expr "$link" : '/.*' > /dev/null; then
|
|
||||||
SCRIPT="$link"
|
|
||||||
else
|
|
||||||
SCRIPT=`dirname "$SCRIPT"`/"$link"
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
|
|
||||||
if [ ! -d "${APP_DIR}" ]; then
|
|
||||||
APP_DIR=`dirname "$SCRIPT"`/..
|
|
||||||
APP_DIR=`cd "${APP_DIR}"; pwd`
|
|
||||||
fi
|
|
||||||
|
|
||||||
executable="./modules/openapi-generator-cli/target/openapi-generator-cli.jar"
|
|
||||||
|
|
||||||
if [ ! -f "$executable" ]
|
|
||||||
then
|
|
||||||
mvn clean package
|
|
||||||
fi
|
|
||||||
|
|
||||||
# if you've executed sbt assembly previously it will use that instead.
|
|
||||||
export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties"
|
|
||||||
ags="generate -t modules/openapi-generator/src/main/resources/Java/libraries/okhttp-gson -i modules/openapi-generator/src/test/resources/2_0/petstore-security-test.yaml -g java -c bin/java-petstore-okhttp-gson.json -o samples/client/petstore-security-test/java/okhttp-gson -DhideGenerationTimestamp=true $@"
|
|
||||||
|
|
||||||
rm -rf samples/client/petstore-security-test/java/okhttp-gson/src/main
|
|
||||||
find samples/client/petstore-security-test/java/okhttp-gson -maxdepth 1 -type f ! -name "README.md" -exec rm {} +
|
|
||||||
java $JAVA_OPTS -jar $executable $ags
|
|
||||||
@@ -1,32 +0,0 @@
|
|||||||
#!/bin/sh
|
|
||||||
|
|
||||||
SCRIPT="$0"
|
|
||||||
echo "# START SCRIPT: $SCRIPT"
|
|
||||||
|
|
||||||
while [ -h "$SCRIPT" ] ; do
|
|
||||||
ls=`ls -ld "$SCRIPT"`
|
|
||||||
link=`expr "$ls" : '.*-> \(.*\)$'`
|
|
||||||
if expr "$link" : '/.*' > /dev/null; then
|
|
||||||
SCRIPT="$link"
|
|
||||||
else
|
|
||||||
SCRIPT=`dirname "$SCRIPT"`/"$link"
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
|
|
||||||
if [ ! -d "${APP_DIR}" ]; then
|
|
||||||
APP_DIR=`dirname "$SCRIPT"`/..
|
|
||||||
APP_DIR=`cd "${APP_DIR}"; pwd`
|
|
||||||
fi
|
|
||||||
|
|
||||||
executable="./modules/openapi-generator-cli/target/openapi-generator-cli.jar"
|
|
||||||
|
|
||||||
if [ ! -f "$executable" ]
|
|
||||||
then
|
|
||||||
mvn clean package
|
|
||||||
fi
|
|
||||||
|
|
||||||
# if you've executed sbt assembly previously it will use that instead.
|
|
||||||
export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties"
|
|
||||||
ags="generate -i modules/openapi-generator/src/test/resources/2_0/petstore-security-test.yaml -g javascript-closure-angular -o samples/client/petstore-security-test/javascript-closure-angular $@"
|
|
||||||
|
|
||||||
java $JAVA_OPTS -jar $executable $ags
|
|
||||||
@@ -1,32 +0,0 @@
|
|||||||
#!/bin/sh
|
|
||||||
|
|
||||||
SCRIPT="$0"
|
|
||||||
echo "# START SCRIPT: $SCRIPT"
|
|
||||||
|
|
||||||
while [ -h "$SCRIPT" ] ; do
|
|
||||||
ls=`ls -ld "$SCRIPT"`
|
|
||||||
link=`expr "$ls" : '.*-> \(.*\)$'`
|
|
||||||
if expr "$link" : '/.*' > /dev/null; then
|
|
||||||
SCRIPT="$link"
|
|
||||||
else
|
|
||||||
SCRIPT=`dirname "$SCRIPT"`/"$link"
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
|
|
||||||
if [ ! -d "${APP_DIR}" ]; then
|
|
||||||
APP_DIR=`dirname "$SCRIPT"`/..
|
|
||||||
APP_DIR=`cd "${APP_DIR}"; pwd`
|
|
||||||
fi
|
|
||||||
|
|
||||||
executable="./modules/openapi-generator-cli/target/openapi-generator-cli.jar"
|
|
||||||
|
|
||||||
if [ ! -f "$executable" ]
|
|
||||||
then
|
|
||||||
mvn clean package
|
|
||||||
fi
|
|
||||||
|
|
||||||
# if you've executed sbt assembly previously it will use that instead.
|
|
||||||
export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties"
|
|
||||||
ags="generate -t modules/openapi-generator/src/main/resources/Javascript -i modules/openapi-generator/src/test/resources/2_0/petstore-security-test.yaml -g javascript -o samples/client/petstore-security-test/javascript -DappName=PetstoreClient $@"
|
|
||||||
|
|
||||||
java $JAVA_OPTS -jar $executable $ags
|
|
||||||
@@ -1,32 +0,0 @@
|
|||||||
#!/bin/sh
|
|
||||||
|
|
||||||
SCRIPT="$0"
|
|
||||||
echo "# START SCRIPT: $SCRIPT"
|
|
||||||
|
|
||||||
while [ -h "$SCRIPT" ] ; do
|
|
||||||
ls=`ls -ld "$SCRIPT"`
|
|
||||||
link=`expr "$ls" : '.*-> \(.*\)$'`
|
|
||||||
if expr "$link" : '/.*' > /dev/null; then
|
|
||||||
SCRIPT="$link"
|
|
||||||
else
|
|
||||||
SCRIPT=`dirname "$SCRIPT"`/"$link"
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
|
|
||||||
if [ ! -d "${APP_DIR}" ]; then
|
|
||||||
APP_DIR=`dirname "$SCRIPT"`/..
|
|
||||||
APP_DIR=`cd "${APP_DIR}"; pwd`
|
|
||||||
fi
|
|
||||||
|
|
||||||
executable="./modules/openapi-generator-cli/target/openapi-generator-cli.jar"
|
|
||||||
|
|
||||||
if [ ! -f "$executable" ]
|
|
||||||
then
|
|
||||||
mvn clean package
|
|
||||||
fi
|
|
||||||
|
|
||||||
# if you've executed sbt assembly previously it will use that instead.
|
|
||||||
export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties"
|
|
||||||
ags="generate -t modules/openapi-generator/src/main/resources/lumen -i modules/openapi-generator/src/test/resources/2_0/petstore-security-test.yaml -g php-lumen -o samples/server/petstore-security-test/lumen $@"
|
|
||||||
|
|
||||||
java $JAVA_OPTS -jar $executable $ags
|
|
||||||
@@ -1,32 +0,0 @@
|
|||||||
#!/bin/sh
|
|
||||||
|
|
||||||
SCRIPT="$0"
|
|
||||||
echo "# START SCRIPT: $SCRIPT"
|
|
||||||
|
|
||||||
while [ -h "$SCRIPT" ] ; do
|
|
||||||
ls=`ls -ld "$SCRIPT"`
|
|
||||||
link=`expr "$ls" : '.*-> \(.*\)$'`
|
|
||||||
if expr "$link" : '/.*' > /dev/null; then
|
|
||||||
SCRIPT="$link"
|
|
||||||
else
|
|
||||||
SCRIPT=`dirname "$SCRIPT"`/"$link"
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
|
|
||||||
if [ ! -d "${APP_DIR}" ]; then
|
|
||||||
APP_DIR=`dirname "$SCRIPT"`/..
|
|
||||||
APP_DIR=`cd "${APP_DIR}"; pwd`
|
|
||||||
fi
|
|
||||||
|
|
||||||
executable="./modules/openapi-generator-cli/target/openapi-generator-cli.jar"
|
|
||||||
|
|
||||||
if [ ! -f "$executable" ]
|
|
||||||
then
|
|
||||||
mvn clean package
|
|
||||||
fi
|
|
||||||
|
|
||||||
# if you've executed sbt assembly previously it will use that instead.
|
|
||||||
export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties"
|
|
||||||
ags="generate -t modules/openapi-generator/src/main/resources/mysql-schema -i modules/openapi-generator/src/test/resources/2_0/petstore-security-test.yaml -g mysql-schema -o samples/schema/petstore-security-test/mysql $@"
|
|
||||||
|
|
||||||
java $JAVA_OPTS -jar $executable $ags
|
|
||||||
@@ -1,32 +0,0 @@
|
|||||||
#!/bin/sh
|
|
||||||
|
|
||||||
SCRIPT="$0"
|
|
||||||
echo "# START SCRIPT: $SCRIPT"
|
|
||||||
|
|
||||||
while [ -h "$SCRIPT" ] ; do
|
|
||||||
ls=`ls -ld "$SCRIPT"`
|
|
||||||
link=`expr "$ls" : '.*-> \(.*\)$'`
|
|
||||||
if expr "$link" : '/.*' > /dev/null; then
|
|
||||||
SCRIPT="$link"
|
|
||||||
else
|
|
||||||
SCRIPT=`dirname "$SCRIPT"`/"$link"
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
|
|
||||||
if [ ! -d "${APP_DIR}" ]; then
|
|
||||||
APP_DIR=`dirname "$SCRIPT"`/..
|
|
||||||
APP_DIR=`cd "${APP_DIR}"; pwd`
|
|
||||||
fi
|
|
||||||
|
|
||||||
executable="./modules/openapi-generator-cli/target/openapi-generator-cli.jar"
|
|
||||||
|
|
||||||
if [ ! -f "$executable" ]
|
|
||||||
then
|
|
||||||
mvn clean package
|
|
||||||
fi
|
|
||||||
|
|
||||||
# if you've executed sbt assembly previously it will use that instead.
|
|
||||||
export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties"
|
|
||||||
ags="generate -t modules/openapi-generator/src/main/resources/objc -i modules/openapi-generator/src/test/resources/2_0/petstore-security-test.yaml -g objc -o samples/client/petstore-security-test/objc $@"
|
|
||||||
|
|
||||||
java $JAVA_OPTS -jar $executable $ags
|
|
||||||
@@ -1,38 +0,0 @@
|
|||||||
#!/bin/sh
|
|
||||||
|
|
||||||
SCRIPT="$0"
|
|
||||||
echo "# START SCRIPT: $SCRIPT"
|
|
||||||
|
|
||||||
while [ -h "$SCRIPT" ] ; do
|
|
||||||
ls=`ls -ld "$SCRIPT"`
|
|
||||||
link=`expr "$ls" : '.*-> \(.*\)$'`
|
|
||||||
if expr "$link" : '/.*' > /dev/null; then
|
|
||||||
SCRIPT="$link"
|
|
||||||
else
|
|
||||||
SCRIPT=`dirname "$SCRIPT"`/"$link"
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
|
|
||||||
if [ ! -d "${APP_DIR}" ]; then
|
|
||||||
APP_DIR=`dirname "$SCRIPT"`/..
|
|
||||||
APP_DIR=`cd "${APP_DIR}"; pwd`
|
|
||||||
fi
|
|
||||||
|
|
||||||
executable="./modules/openapi-generator-cli/target/openapi-generator-cli.jar"
|
|
||||||
|
|
||||||
if [ ! -f "$executable" ]
|
|
||||||
then
|
|
||||||
mvn clean package
|
|
||||||
fi
|
|
||||||
|
|
||||||
# cleanup tests
|
|
||||||
TEST_DIR="./samples/client/petstore-security-test/php/OpenAPIToolsClient-php/test"
|
|
||||||
if [ -d $TEST_DIR ]; then
|
|
||||||
rm -rf $TEST_DIR
|
|
||||||
fi
|
|
||||||
|
|
||||||
# if you've executed sbt assembly previously it will use that instead.
|
|
||||||
export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties"
|
|
||||||
ags="generate -t modules/openapi-generator/src/main/resources/php -i modules/openapi-generator/src/test/resources/3_0/petstore-security-test.yaml -g php -o samples/openapi3/client/petstore-security-test/php/OpenAPIClient-php $@"
|
|
||||||
|
|
||||||
java $JAVA_OPTS -jar $executable $ags
|
|
||||||
@@ -1,10 +0,0 @@
|
|||||||
set executable=.\modules\openapi-generator-cli\target\openapi-generator-cli.jar
|
|
||||||
|
|
||||||
If Not Exist %executable% (
|
|
||||||
mvn clean package
|
|
||||||
)
|
|
||||||
|
|
||||||
REM set JAVA_OPTS=%JAVA_OPTS% -Xmx1024M
|
|
||||||
set ags=generate -i modules\openapi-generator\src\test\resources\3_0\petstore-security-test.yaml -g php -o samples\openapi3\client\petstore-security-test\php\OpenAPIClient-php
|
|
||||||
|
|
||||||
java %JAVA_OPTS% -jar %executable% %ags%
|
|
||||||
@@ -1,35 +0,0 @@
|
|||||||
#!/bin/sh
|
|
||||||
|
|
||||||
SCRIPT="$0"
|
|
||||||
echo "# START SCRIPT: $SCRIPT"
|
|
||||||
|
|
||||||
while [ -h "$SCRIPT" ] ; do
|
|
||||||
ls=`ls -ld "$SCRIPT"`
|
|
||||||
link=`expr "$ls" : '.*-> \(.*\)$'`
|
|
||||||
if expr "$link" : '/.*' > /dev/null; then
|
|
||||||
SCRIPT="$link"
|
|
||||||
else
|
|
||||||
SCRIPT=`dirname "$SCRIPT"`/"$link"
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
|
|
||||||
if [ ! -d "${APP_DIR}" ]; then
|
|
||||||
APP_DIR=`dirname "$SCRIPT"`/..
|
|
||||||
APP_DIR=`cd "${APP_DIR}"; pwd`
|
|
||||||
fi
|
|
||||||
|
|
||||||
executable="./modules/openapi-generator-cli/target/openapi-generator-cli.jar"
|
|
||||||
|
|
||||||
if [ ! -f "$executable" ]
|
|
||||||
then
|
|
||||||
mvn clean package
|
|
||||||
fi
|
|
||||||
|
|
||||||
# if you've executed sbt assembly previously it will use that instead.
|
|
||||||
export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties"
|
|
||||||
# complex module name used for testing
|
|
||||||
ags="generate -i modules/openapi-generator/src/test/resources/2_0/petstore-security-test.yaml -g perl -o samples/client/petstore-security-test/perl $@"
|
|
||||||
|
|
||||||
java $JAVA_OPTS -jar $executable $ags
|
|
||||||
|
|
||||||
java $JAVA_OPTS -jar $executable $ags --additional-properties moduleName=Something::Deep -o samples/client/petstore-security-test/perl/deep_module_test
|
|
||||||
@@ -1,38 +0,0 @@
|
|||||||
#!/bin/sh
|
|
||||||
|
|
||||||
SCRIPT="$0"
|
|
||||||
echo "# START SCRIPT: $SCRIPT"
|
|
||||||
|
|
||||||
while [ -h "$SCRIPT" ] ; do
|
|
||||||
ls=`ls -ld "$SCRIPT"`
|
|
||||||
link=`expr "$ls" : '.*-> \(.*\)$'`
|
|
||||||
if expr "$link" : '/.*' > /dev/null; then
|
|
||||||
SCRIPT="$link"
|
|
||||||
else
|
|
||||||
SCRIPT=`dirname "$SCRIPT"`/"$link"
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
|
|
||||||
if [ ! -d "${APP_DIR}" ]; then
|
|
||||||
APP_DIR=`dirname "$SCRIPT"`/..
|
|
||||||
APP_DIR=`cd "${APP_DIR}"; pwd`
|
|
||||||
fi
|
|
||||||
|
|
||||||
executable="./modules/openapi-generator-cli/target/openapi-generator-cli.jar"
|
|
||||||
|
|
||||||
if [ ! -f "$executable" ]
|
|
||||||
then
|
|
||||||
mvn clean package
|
|
||||||
fi
|
|
||||||
|
|
||||||
# cleanup tests
|
|
||||||
TEST_DIR="./samples/client/petstore-security-test/php/OpenAPIToolsClient-php/test"
|
|
||||||
if [ -d $TEST_DIR ]; then
|
|
||||||
rm -rf $TEST_DIR
|
|
||||||
fi
|
|
||||||
|
|
||||||
# if you've executed sbt assembly previously it will use that instead.
|
|
||||||
export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties"
|
|
||||||
ags="generate -t modules/openapi-generator/src/main/resources/php -i modules/openapi-generator/src/test/resources/2_0/petstore-security-test.yaml -g php -o samples/client/petstore-security-test/php/OpenAPIClient-php $@"
|
|
||||||
|
|
||||||
java $JAVA_OPTS -jar $executable $ags
|
|
||||||
@@ -1,32 +0,0 @@
|
|||||||
#!/bin/sh
|
|
||||||
|
|
||||||
SCRIPT="$0"
|
|
||||||
echo "# START SCRIPT: $SCRIPT"
|
|
||||||
|
|
||||||
while [ -h "$SCRIPT" ] ; do
|
|
||||||
ls=`ls -ld "$SCRIPT"`
|
|
||||||
link=`expr "$ls" : '.*-> \(.*\)$'`
|
|
||||||
if expr "$link" : '/.*' > /dev/null; then
|
|
||||||
SCRIPT="$link"
|
|
||||||
else
|
|
||||||
SCRIPT=`dirname "$SCRIPT"`/"$link"
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
|
|
||||||
if [ ! -d "${APP_DIR}" ]; then
|
|
||||||
APP_DIR=`dirname "$SCRIPT"`/..
|
|
||||||
APP_DIR=`cd "${APP_DIR}"; pwd`
|
|
||||||
fi
|
|
||||||
|
|
||||||
executable="./modules/openapi-generator-cli/target/openapi-generator-cli.jar"
|
|
||||||
|
|
||||||
if [ ! -f "$executable" ]
|
|
||||||
then
|
|
||||||
mvn clean package
|
|
||||||
fi
|
|
||||||
|
|
||||||
# if you've executed sbt assembly previously it will use that instead.
|
|
||||||
export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties"
|
|
||||||
ags="generate -t modules/openapi-generator/src/main/resources/php-slim-server -i modules/openapi-generator/src/test/resources/2_0/petstore-security-test.yaml -g php-slim -o samples/server/petstore-security-test/php-slim $@"
|
|
||||||
|
|
||||||
java $JAVA_OPTS -jar $executable $ags
|
|
||||||
@@ -1,32 +0,0 @@
|
|||||||
#!/bin/sh
|
|
||||||
|
|
||||||
SCRIPT="$0"
|
|
||||||
echo "# START SCRIPT: $SCRIPT"
|
|
||||||
|
|
||||||
while [ -h "$SCRIPT" ] ; do
|
|
||||||
ls=`ls -ld "$SCRIPT"`
|
|
||||||
link=`expr "$ls" : '.*-> \(.*\)$'`
|
|
||||||
if expr "$link" : '/.*' > /dev/null; then
|
|
||||||
SCRIPT="$link"
|
|
||||||
else
|
|
||||||
SCRIPT=`dirname "$SCRIPT"`/"$link"
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
|
|
||||||
if [ ! -d "${APP_DIR}" ]; then
|
|
||||||
APP_DIR=`dirname "$SCRIPT"`/..
|
|
||||||
APP_DIR=`cd "${APP_DIR}"; pwd`
|
|
||||||
fi
|
|
||||||
|
|
||||||
executable="./modules/openapi-generator-cli/target/openapi-generator-cli.jar"
|
|
||||||
|
|
||||||
if [ ! -f "$executable" ]
|
|
||||||
then
|
|
||||||
mvn clean package
|
|
||||||
fi
|
|
||||||
|
|
||||||
# if you've executed sbt assembly previously it will use that instead.
|
|
||||||
export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties"
|
|
||||||
ags="generate -t modules/openapi-generator/src/main/resources/python -i modules/openapi-generator/src/test/resources/2_0/petstore-security-test.yaml -g python -o samples/client/petstore-security-test/python -DpackageName=petstore_api $@"
|
|
||||||
|
|
||||||
java $JAVA_OPTS -jar $executable $ags
|
|
||||||
@@ -1,32 +0,0 @@
|
|||||||
#!/bin/sh
|
|
||||||
|
|
||||||
SCRIPT="$0"
|
|
||||||
echo "# START SCRIPT: $SCRIPT"
|
|
||||||
|
|
||||||
while [ -h "$SCRIPT" ] ; do
|
|
||||||
ls=`ls -ld "$SCRIPT"`
|
|
||||||
link=`expr "$ls" : '.*-> \(.*\)$'`
|
|
||||||
if expr "$link" : '/.*' > /dev/null; then
|
|
||||||
SCRIPT="$link"
|
|
||||||
else
|
|
||||||
SCRIPT=`dirname "$SCRIPT"`/"$link"
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
|
|
||||||
if [ ! -d "${APP_DIR}" ]; then
|
|
||||||
APP_DIR=`dirname "$SCRIPT"`/..
|
|
||||||
APP_DIR=`cd "${APP_DIR}"; pwd`
|
|
||||||
fi
|
|
||||||
|
|
||||||
executable="./modules/openapi-generator-cli/target/openapi-generator-cli.jar"
|
|
||||||
|
|
||||||
if [ ! -f "$executable" ]
|
|
||||||
then
|
|
||||||
mvn clean package
|
|
||||||
fi
|
|
||||||
|
|
||||||
# if you've executed sbt assembly previously it will use that instead.
|
|
||||||
export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties"
|
|
||||||
ags="generate -t modules/openapi-generator/src/main/resources/ruby-client -i modules/openapi-generator/src/test/resources/2_0/petstore-security-test.yaml -g ruby -c bin/ruby-petstore.json -o samples/client/petstore-security-test/ruby $@"
|
|
||||||
|
|
||||||
java $JAVA_OPTS -jar $executable $ags
|
|
||||||
@@ -1,15 +0,0 @@
|
|||||||
#!/bin/bash -e
|
|
||||||
|
|
||||||
for SCRIPT in ./bin/security/*.sh
|
|
||||||
do
|
|
||||||
if [ -f $SCRIPT -a -x $SCRIPT ]
|
|
||||||
then
|
|
||||||
$SCRIPT
|
|
||||||
rc=$?
|
|
||||||
if [[ $rc != 0 ]]
|
|
||||||
then
|
|
||||||
echo "ERROR!! FAILED TO RUN $SCRIPT"
|
|
||||||
exit $rc;
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
@@ -1,32 +0,0 @@
|
|||||||
#!/bin/sh
|
|
||||||
|
|
||||||
SCRIPT="$0"
|
|
||||||
echo "# START SCRIPT: $SCRIPT"
|
|
||||||
|
|
||||||
while [ -h "$SCRIPT" ] ; do
|
|
||||||
ls=`ls -ld "$SCRIPT"`
|
|
||||||
link=`expr "$ls" : '.*-> \(.*\)$'`
|
|
||||||
if expr "$link" : '/.*' > /dev/null; then
|
|
||||||
SCRIPT="$link"
|
|
||||||
else
|
|
||||||
SCRIPT=`dirname "$SCRIPT"`/"$link"
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
|
|
||||||
if [ ! -d "${APP_DIR}" ]; then
|
|
||||||
APP_DIR=`dirname "$SCRIPT"`/..
|
|
||||||
APP_DIR=`cd "${APP_DIR}"; pwd`
|
|
||||||
fi
|
|
||||||
|
|
||||||
executable="./modules/openapi-generator-cli/target/openapi-generator-cli.jar"
|
|
||||||
|
|
||||||
if [ ! -f "$executable" ]
|
|
||||||
then
|
|
||||||
mvn clean package
|
|
||||||
fi
|
|
||||||
|
|
||||||
# if you've executed sbt assembly previously it will use that instead.
|
|
||||||
export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties"
|
|
||||||
ags="generate -t modules/openapi-generator/src/main/resources/php-silex -i modules/openapi-generator/src/test/resources/2_0/petstore-security-test.yaml -g php-silex -o samples/server/petstore-security-test/silex/SwaggerServer $@"
|
|
||||||
|
|
||||||
java $JAVA_OPTS -jar $executable $ags
|
|
||||||
@@ -1,32 +0,0 @@
|
|||||||
#!/bin/sh
|
|
||||||
|
|
||||||
SCRIPT="$0"
|
|
||||||
echo "# START SCRIPT: $SCRIPT"
|
|
||||||
|
|
||||||
while [ -h "$SCRIPT" ] ; do
|
|
||||||
ls=`ls -ld "$SCRIPT"`
|
|
||||||
link=`expr "$ls" : '.*-> \(.*\)$'`
|
|
||||||
if expr "$link" : '/.*' > /dev/null; then
|
|
||||||
SCRIPT="$link"
|
|
||||||
else
|
|
||||||
SCRIPT=`dirname "$SCRIPT"`/"$link"
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
|
|
||||||
if [ ! -d "${APP_DIR}" ]; then
|
|
||||||
APP_DIR=`dirname "$SCRIPT"`/..
|
|
||||||
APP_DIR=`cd "${APP_DIR}"; pwd`
|
|
||||||
fi
|
|
||||||
|
|
||||||
executable="./modules/openapi-generator-cli/target/openapi-generator-cli.jar"
|
|
||||||
|
|
||||||
if [ ! -f "$executable" ]
|
|
||||||
then
|
|
||||||
mvn clean package
|
|
||||||
fi
|
|
||||||
|
|
||||||
# if you've executed sbt assembly previously it will use that instead.
|
|
||||||
export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties"
|
|
||||||
ags="generate -t modules/openapi-generator/src/main/resources/swift -i modules/openapi-generator/src/test/resources/2_0/petstore-security-test.yaml -g swift2-deprecated -o samples/client/petstore-security-test/swift $@"
|
|
||||||
|
|
||||||
java $JAVA_OPTS -jar $executable $ags
|
|
||||||
@@ -1,32 +0,0 @@
|
|||||||
#!/bin/sh
|
|
||||||
|
|
||||||
SCRIPT="$0"
|
|
||||||
echo "# START SCRIPT: $SCRIPT"
|
|
||||||
|
|
||||||
while [ -h "$SCRIPT" ] ; do
|
|
||||||
ls=`ls -ld "$SCRIPT"`
|
|
||||||
link=`expr "$ls" : '.*-> \(.*\)$'`
|
|
||||||
if expr "$link" : '/.*' > /dev/null; then
|
|
||||||
SCRIPT="$link"
|
|
||||||
else
|
|
||||||
SCRIPT=`dirname "$SCRIPT"`/"$link"
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
|
|
||||||
if [ ! -d "${APP_DIR}" ]; then
|
|
||||||
APP_DIR=`dirname "$SCRIPT"`/..
|
|
||||||
APP_DIR=`cd "${APP_DIR}"; pwd`
|
|
||||||
fi
|
|
||||||
|
|
||||||
executable="./modules/openapi-generator-cli/target/openapi-generator-cli.jar"
|
|
||||||
|
|
||||||
if [ ! -f "$executable" ]
|
|
||||||
then
|
|
||||||
mvn clean package
|
|
||||||
fi
|
|
||||||
|
|
||||||
# if you've executed sbt assembly previously it will use that instead.
|
|
||||||
export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties"
|
|
||||||
ags="generate -t modules/openapi-generator/src/main/resources/typescript-angular -i modules/openapi-generator/src/test/resources/2_0/petstore-security-test.yaml -g typescript-angular -o samples/client/petstore-security-test/typescript-angular $@"
|
|
||||||
|
|
||||||
java $JAVA_OPTS -jar $executable $ags
|
|
||||||
@@ -1,32 +0,0 @@
|
|||||||
#!/bin/sh
|
|
||||||
|
|
||||||
SCRIPT="$0"
|
|
||||||
echo "# START SCRIPT: $SCRIPT"
|
|
||||||
|
|
||||||
while [ -h "$SCRIPT" ] ; do
|
|
||||||
ls=`ls -ld "$SCRIPT"`
|
|
||||||
link=`expr "$ls" : '.*-> \(.*\)$'`
|
|
||||||
if expr "$link" : '/.*' > /dev/null; then
|
|
||||||
SCRIPT="$link"
|
|
||||||
else
|
|
||||||
SCRIPT=`dirname "$SCRIPT"`/"$link"
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
|
|
||||||
if [ ! -d "${APP_DIR}" ]; then
|
|
||||||
APP_DIR=`dirname "$SCRIPT"`/..
|
|
||||||
APP_DIR=`cd "${APP_DIR}"; pwd`
|
|
||||||
fi
|
|
||||||
|
|
||||||
executable="./modules/openapi-generator-cli/target/openapi-generator-cli.jar"
|
|
||||||
|
|
||||||
if [ ! -f "$executable" ]
|
|
||||||
then
|
|
||||||
mvn clean package
|
|
||||||
fi
|
|
||||||
|
|
||||||
# if you've executed sbt assembly previously it will use that instead.
|
|
||||||
export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties"
|
|
||||||
ags="generate -i modules/openapi-generator/src/test/resources/2_0/petstore-security-test.yaml -g typescript-angular -o samples/client/petstore-security-test/typescript-angular2 $@"
|
|
||||||
|
|
||||||
java $JAVA_OPTS -jar $executable $ags
|
|
||||||
@@ -1,32 +0,0 @@
|
|||||||
#!/bin/sh
|
|
||||||
|
|
||||||
SCRIPT="$0"
|
|
||||||
echo "# START SCRIPT: $SCRIPT"
|
|
||||||
|
|
||||||
while [ -h "$SCRIPT" ] ; do
|
|
||||||
ls=`ls -ld "$SCRIPT"`
|
|
||||||
link=`expr "$ls" : '.*-> \(.*\)$'`
|
|
||||||
if expr "$link" : '/.*' > /dev/null; then
|
|
||||||
SCRIPT="$link"
|
|
||||||
else
|
|
||||||
SCRIPT=`dirname "$SCRIPT"`/"$link"
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
|
|
||||||
if [ ! -d "${APP_DIR}" ]; then
|
|
||||||
APP_DIR=`dirname "$SCRIPT"`/..
|
|
||||||
APP_DIR=`cd "${APP_DIR}"; pwd`
|
|
||||||
fi
|
|
||||||
|
|
||||||
executable="./modules/openapi-generator-cli/target/openapi-generator-cli.jar"
|
|
||||||
|
|
||||||
if [ ! -f "$executable" ]
|
|
||||||
then
|
|
||||||
mvn clean package
|
|
||||||
fi
|
|
||||||
|
|
||||||
# if you've executed sbt assembly previously it will use that instead.
|
|
||||||
export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties"
|
|
||||||
ags="generate -t modules/openapi-generator/src/main/resources/typescript-fetch -i modules/openapi-generator/src/test/resources/2_0/petstore-security-test.yaml -g typescript-fetch -o samples/client/petstore-security-test/typescript-fetch $@"
|
|
||||||
|
|
||||||
java $JAVA_OPTS -jar $executable $ags
|
|
||||||
@@ -1,32 +0,0 @@
|
|||||||
#!/bin/sh
|
|
||||||
|
|
||||||
SCRIPT="$0"
|
|
||||||
echo "# START SCRIPT: $SCRIPT"
|
|
||||||
|
|
||||||
while [ -h "$SCRIPT" ] ; do
|
|
||||||
ls=`ls -ld "$SCRIPT"`
|
|
||||||
link=`expr "$ls" : '.*-> \(.*\)$'`
|
|
||||||
if expr "$link" : '/.*' > /dev/null; then
|
|
||||||
SCRIPT="$link"
|
|
||||||
else
|
|
||||||
SCRIPT=`dirname "$SCRIPT"`/"$link"
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
|
|
||||||
if [ ! -d "${APP_DIR}" ]; then
|
|
||||||
APP_DIR=`dirname "$SCRIPT"`/..
|
|
||||||
APP_DIR=`cd "${APP_DIR}"; pwd`
|
|
||||||
fi
|
|
||||||
|
|
||||||
executable="./modules/openapi-generator-cli/target/openapi-generator-cli.jar"
|
|
||||||
|
|
||||||
if [ ! -f "$executable" ]
|
|
||||||
then
|
|
||||||
mvn clean package
|
|
||||||
fi
|
|
||||||
|
|
||||||
# if you've executed sbt assembly previously it will use that instead.
|
|
||||||
export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties"
|
|
||||||
ags="generate -t modules/openapi-generator/src/main/resources/typescript-inversify -i modules/openapi-generator/src/test/resources/2_0/petstore-security-test.yaml -g typescript-inversify -o samples/client/petstore-security-test/typescript-inversify $@"
|
|
||||||
|
|
||||||
java $JAVA_OPTS -jar $executable $ags
|
|
||||||
@@ -1,37 +0,0 @@
|
|||||||
#!/bin/sh
|
|
||||||
|
|
||||||
SCRIPT="$0"
|
|
||||||
echo "# START SCRIPT: $SCRIPT"
|
|
||||||
|
|
||||||
while [ -h "$SCRIPT" ] ; do
|
|
||||||
ls=`ls -ld "$SCRIPT"`
|
|
||||||
link=`expr "$ls" : '.*-> \(.*\)$'`
|
|
||||||
if expr "$link" : '/.*' > /dev/null; then
|
|
||||||
SCRIPT="$link"
|
|
||||||
else
|
|
||||||
SCRIPT=`dirname "$SCRIPT"`/"$link"
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
|
|
||||||
if [ ! -d "${APP_DIR}" ]; then
|
|
||||||
APP_DIR=`dirname "$SCRIPT"`/..
|
|
||||||
APP_DIR=`cd "${APP_DIR}"; pwd`
|
|
||||||
fi
|
|
||||||
|
|
||||||
executable="./modules/openapi-generator-cli/target/openapi-generator-cli.jar"
|
|
||||||
|
|
||||||
if [ ! -f "$executable" ]
|
|
||||||
then
|
|
||||||
mvn clean package
|
|
||||||
fi
|
|
||||||
|
|
||||||
# if you've executed sbt assembly previously it will use that instead.
|
|
||||||
export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties"
|
|
||||||
|
|
||||||
echo "Typescript jquery Petstore API client (default setting)"
|
|
||||||
ags="generate -i modules/openapi-generator/src/test/resources/2_0/petstore-security-test.yaml -g typescript-jquery -o samples/client/petstore-security-test/typescript-jquery/default $@"
|
|
||||||
java $JAVA_OPTS -jar $executable $ags
|
|
||||||
|
|
||||||
echo "Typescript jquery Petstore API client with npm setting"
|
|
||||||
ags="generate -i modules/openapi-generator/src/test/resources/2_0/petstore-security-test.yaml -g typescript-jquery -c bin/typescript-petstore-npm.json -o samples/client/petstore-security-test/typescript-jquery/npm $@"
|
|
||||||
java $JAVA_OPTS -jar $executable $ags
|
|
||||||
@@ -1,32 +0,0 @@
|
|||||||
#!/bin/sh
|
|
||||||
|
|
||||||
SCRIPT="$0"
|
|
||||||
echo "# START SCRIPT: $SCRIPT"
|
|
||||||
|
|
||||||
while [ -h "$SCRIPT" ] ; do
|
|
||||||
ls=`ls -ld "$SCRIPT"`
|
|
||||||
link=`expr "$ls" : '.*-> \(.*\)$'`
|
|
||||||
if expr "$link" : '/.*' > /dev/null; then
|
|
||||||
SCRIPT="$link"
|
|
||||||
else
|
|
||||||
SCRIPT=`dirname "$SCRIPT"`/"$link"
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
|
|
||||||
if [ ! -d "${APP_DIR}" ]; then
|
|
||||||
APP_DIR=`dirname "$SCRIPT"`/..
|
|
||||||
APP_DIR=`cd "${APP_DIR}"; pwd`
|
|
||||||
fi
|
|
||||||
|
|
||||||
executable="./modules/openapi-generator-cli/target/openapi-generator-cli.jar"
|
|
||||||
|
|
||||||
if [ ! -f "$executable" ]
|
|
||||||
then
|
|
||||||
mvn clean package
|
|
||||||
fi
|
|
||||||
|
|
||||||
# if you've executed sbt assembly previously it will use that instead.
|
|
||||||
export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties"
|
|
||||||
ags="generate -t modules/openapi-generator/src/main/resources/typescript-node -i modules/openapi-generator/src/test/resources/2_0/petstore-security-test.yaml -g typescript-node -o samples/client/petstore-security-test/typescript-node $@"
|
|
||||||
|
|
||||||
java $JAVA_OPTS -jar $executable $ags
|
|
||||||
@@ -1,10 +0,0 @@
|
|||||||
set executable=.\modules\openapi-generator-cli\target\openapi-generator-cli.jar
|
|
||||||
|
|
||||||
If Not Exist %executable% (
|
|
||||||
mvn clean package
|
|
||||||
)
|
|
||||||
|
|
||||||
REM set JAVA_OPTS=%JAVA_OPTS% -Xmx1024M
|
|
||||||
set ags=generate -i modules/openapi-generator/src/test/resources/2_0/petstore-security-test.yaml -g csharp -o samples/client/petstore-security-test/csharp/SwaggerClient --additional-properties packageGuid={8CE139DF-64BC-4591-85F8-8506C2B67514}
|
|
||||||
|
|
||||||
java %JAVA_OPTS% -jar %executable% %ags%
|
|
||||||
@@ -1,10 +0,0 @@
|
|||||||
set executable=.\modules\openapi-generator-cli\target\openapi-generator-cli.jar
|
|
||||||
|
|
||||||
If Not Exist %executable% (
|
|
||||||
mvn clean package
|
|
||||||
)
|
|
||||||
|
|
||||||
REM set JAVA_OPTS=%JAVA_OPTS% -Xmx1024M
|
|
||||||
set ags=generate -t modules/openapi-generator/src/main/resources/cpp-qt5-client -i modules\openapi-generator\src\test\resources\2_0\petstore-security-test.yaml -g qt5cpp -o samples\client\petstore-security-test\qt5cpp
|
|
||||||
|
|
||||||
java %JAVA_OPTS% -jar %executable% %ags%
|
|
||||||
@@ -24,6 +24,7 @@ declare -a scripts=(
|
|||||||
"./bin/kotlin-client-string.sh"
|
"./bin/kotlin-client-string.sh"
|
||||||
"./bin/kotlin-client-threetenbp.sh"
|
"./bin/kotlin-client-threetenbp.sh"
|
||||||
"./bin/kotlin-server-petstore.sh"
|
"./bin/kotlin-server-petstore.sh"
|
||||||
|
"./bin/kotlin-springboot-petstore-server.sh"
|
||||||
"./bin/mysql-schema-petstore.sh"
|
"./bin/mysql-schema-petstore.sh"
|
||||||
"./bin/python-petstore-all.sh"
|
"./bin/python-petstore-all.sh"
|
||||||
"./bin/openapi3/python-petstore.sh"
|
"./bin/openapi3/python-petstore.sh"
|
||||||
@@ -34,7 +35,9 @@ declare -a scripts=(
|
|||||||
"./bin/php-slim-server-petstore.sh"
|
"./bin/php-slim-server-petstore.sh"
|
||||||
"./bin/php-ze-ph-petstore-server.sh"
|
"./bin/php-ze-ph-petstore-server.sh"
|
||||||
"./bin/openapi3/php-petstore.sh"
|
"./bin/openapi3/php-petstore.sh"
|
||||||
|
"./bin/typescript-angularjs-petstore.sh"
|
||||||
"./bin/typescript-angular-petstore-all.sh"
|
"./bin/typescript-angular-petstore-all.sh"
|
||||||
|
"./bin/typescript-aurelia-petstore.sh"
|
||||||
"./bin/typescript-axios-petstore-all.sh"
|
"./bin/typescript-axios-petstore-all.sh"
|
||||||
"./bin/typescript-fetch-petstore-all.sh"
|
"./bin/typescript-fetch-petstore-all.sh"
|
||||||
"./bin/typescript-node-petstore-all.sh"
|
"./bin/typescript-node-petstore-all.sh"
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
set executable=.\modules\openapi-generator-cli\target\openapi-generator-cli.jar
|
set executable=.\modules\openapi-generator-cli\target\openapi-generator-cli.jar
|
||||||
|
|
||||||
If Not Exist %executable% (
|
If Not Exist %executable% (
|
||||||
mvn clean package
|
mvn clean package
|
||||||
)
|
)
|
||||||
|
|
||||||
REM set JAVA_OPTS=%JAVA_OPTS% -Xmx1024M
|
REM set JAVA_OPTS=%JAVA_OPTS% -Xmx1024M
|
||||||
set ags=generate -i modules\openapi-generator\src\test\resources\2_0\petstore.yaml -g kotlin-spring -o samples\server\petstore\kotlin-springboot --additional-properties=library=spring-boot
|
set ags=generate -i modules\openapi-generator\src\test\resources\2_0\petstore.yaml -g kotlin-spring -o samples\server\petstore\kotlin-springboot --additional-properties=library=spring-boot,beanValidations=true,swaggerAnnotations=true,serviceImplementation=true
|
||||||
|
|
||||||
java %JAVA_OPTS% -jar %executable% %ags%
|
java %JAVA_OPTS% -jar %executable% %ags%
|
||||||
|
|||||||
2
bin/security/windows/php-petstore.bat → bin/windows/scala-play-framework-petstore.bat
Normal file → Executable file
2
bin/security/windows/php-petstore.bat → bin/windows/scala-play-framework-petstore.bat
Normal file → Executable file
@@ -5,6 +5,6 @@ If Not Exist %executable% (
|
|||||||
)
|
)
|
||||||
|
|
||||||
REM set JAVA_OPTS=%JAVA_OPTS% -Xmx1024M
|
REM set JAVA_OPTS=%JAVA_OPTS% -Xmx1024M
|
||||||
set ags=generate -i modules\openapi-generator\src\test\resources\2_0\petstore-security-test.yaml -g php -o samples\client\petstore-security-test\php\OpenAPIClient-php
|
set ags=generate -i modules\openapi-generator\src\test\resources\2_0\petstore.yaml -g scala-play-server -o samples\server\petstore\scala-play-server
|
||||||
|
|
||||||
java %JAVA_OPTS% -jar %executable% %ags%
|
java %JAVA_OPTS% -jar %executable% %ags%
|
||||||
@@ -105,6 +105,7 @@ The following generators are available:
|
|||||||
- [rust-server](generators/rust-server.md)
|
- [rust-server](generators/rust-server.md)
|
||||||
- [scala-finch](generators/scala-finch.md)
|
- [scala-finch](generators/scala-finch.md)
|
||||||
- [scala-lagom-server](generators/scala-lagom-server.md)
|
- [scala-lagom-server](generators/scala-lagom-server.md)
|
||||||
|
- [scala-play-server](generators/scala-play-server.md)
|
||||||
- [scalatra](generators/scalatra.md)
|
- [scalatra](generators/scalatra.md)
|
||||||
- [spring](generators/spring.md)
|
- [spring](generators/spring.md)
|
||||||
|
|
||||||
|
|||||||
@@ -16,13 +16,14 @@ sidebar_label: aspnetcore
|
|||||||
|packageVersion|C# package version.| |1.0.0|
|
|packageVersion|C# package version.| |1.0.0|
|
||||||
|packageGuid|The GUID that will be associated with the C# project| |null|
|
|packageGuid|The GUID that will be associated with the C# project| |null|
|
||||||
|sourceFolder|source folder for generated code| |src|
|
|sourceFolder|source folder for generated code| |src|
|
||||||
|aspnetCoreVersion|ASP.NET Core version: 2.1 (default), 2.0 (deprecated)| |2.1|
|
|compatibilityVersion|ASP.Net Core CompatibilityVersion| |Version_2_1|
|
||||||
|
|aspnetCoreVersion|ASP.NET Core version: 2.2 (default), 2.1, 2.0 (deprecated)| |2.2|
|
||||||
|sortParamsByRequiredFlag|Sort method arguments to place required parameters before optional parameters.| |true|
|
|sortParamsByRequiredFlag|Sort method arguments to place required parameters before optional parameters.| |true|
|
||||||
|useDateTimeOffset|Use DateTimeOffset to model date-time properties| |false|
|
|useDateTimeOffset|Use DateTimeOffset to model date-time properties| |false|
|
||||||
|useCollection|Deserialize array types to Collection<T> instead of List<T>.| |false|
|
|useCollection|Deserialize array types to Collection<T> instead of List<T>.| |false|
|
||||||
|returnICollection|Return ICollection<T> instead of the concrete type.| |false|
|
|returnICollection|Return ICollection<T> instead of the concrete type.| |false|
|
||||||
|useSwashbuckle|Uses the Swashbuckle.AspNetCore NuGet package for documentation.| |true|
|
|useSwashbuckle|Uses the Swashbuckle.AspNetCore NuGet package for documentation.| |true|
|
||||||
|classModifier|Class modifiers such as abstract or partial| ||
|
|classModifier|Class Modifier can be empty, abstract| ||
|
||||||
|operationModifier|Operation modifiers such as virtual or abstract.| |virtual|
|
|operationModifier|Operation Modifier can be virtual, abstract or partial| |virtual|
|
||||||
|
|buildTarget|Target to build an application or library| |program|
|
||||||
|generateBody|Generates method body.| |true|
|
|generateBody|Generates method body.| |true|
|
||||||
|buildTarget|Target the build for a program or library.| |program|
|
|
||||||
|
|||||||
@@ -22,7 +22,6 @@ sidebar_label: csharp-netcore
|
|||||||
|optionalMethodArgument|C# Optional method argument, e.g. void square(int x=10) (.net 4.0+ only).| |true|
|
|optionalMethodArgument|C# Optional method argument, e.g. void square(int x=10) (.net 4.0+ only).| |true|
|
||||||
|optionalAssemblyInfo|Generate AssemblyInfo.cs.| |true|
|
|optionalAssemblyInfo|Generate AssemblyInfo.cs.| |true|
|
||||||
|optionalProjectFile|Generate {PackageName}.csproj.| |true|
|
|optionalProjectFile|Generate {PackageName}.csproj.| |true|
|
||||||
|optionalEmitDefaultValues|Set DataMember's EmitDefaultValue.| |false|
|
|
||||||
|nonPublicApi|Generates code with reduced access modifiers; allows embedding elsewhere without exposing non-public API calls to consumers.| |false|
|
|nonPublicApi|Generates code with reduced access modifiers; allows embedding elsewhere without exposing non-public API calls to consumers.| |false|
|
||||||
|allowUnicodeIdentifiers|boolean, toggles whether unicode identifiers are allowed in names or not, default is false| |false|
|
|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|
|
|netCoreProjectFile|Use the new format (.NET Core) for .NET project files (.csproj).| |false|
|
||||||
|
|||||||
@@ -22,7 +22,6 @@ sidebar_label: csharp
|
|||||||
|optionalMethodArgument|C# Optional method argument, e.g. void square(int x=10) (.net 4.0+ only).| |true|
|
|optionalMethodArgument|C# Optional method argument, e.g. void square(int x=10) (.net 4.0+ only).| |true|
|
||||||
|optionalAssemblyInfo|Generate AssemblyInfo.cs.| |true|
|
|optionalAssemblyInfo|Generate AssemblyInfo.cs.| |true|
|
||||||
|optionalProjectFile|Generate {PackageName}.csproj.| |true|
|
|optionalProjectFile|Generate {PackageName}.csproj.| |true|
|
||||||
|optionalEmitDefaultValues|Set DataMember's EmitDefaultValue.| |false|
|
|
||||||
|generatePropertyChanged|Specifies a AssemblyDescription for the .NET Framework global assembly attributes stored in the AssemblyInfo file.| |false|
|
|generatePropertyChanged|Specifies a AssemblyDescription for the .NET Framework global assembly attributes stored in the AssemblyInfo file.| |false|
|
||||||
|nonPublicApi|Generates code with reduced access modifiers; allows embedding elsewhere without exposing non-public API calls to consumers.| |false|
|
|nonPublicApi|Generates code with reduced access modifiers; allows embedding elsewhere without exposing non-public API calls to consumers.| |false|
|
||||||
|allowUnicodeIdentifiers|boolean, toggles whether unicode identifiers are allowed in names or not, default is false| |false|
|
|allowUnicodeIdentifiers|boolean, toggles whether unicode identifiers are allowed in names or not, default is false| |false|
|
||||||
|
|||||||
@@ -19,3 +19,4 @@ sidebar_label: dart-jaguar
|
|||||||
|sourceFolder|source folder for generated code| |null|
|
|sourceFolder|source folder for generated code| |null|
|
||||||
|supportDart2|support dart2| |true|
|
|supportDart2|support dart2| |true|
|
||||||
|nullableFields|Is the null fields should be in the JSON payload| |null|
|
|nullableFields|Is the null fields should be in the JSON payload| |null|
|
||||||
|
|serialization|Choose serialization format JSON or PROTO is supported| |null|
|
||||||
|
|||||||
@@ -8,4 +8,5 @@ sidebar_label: go-gin-server
|
|||||||
| Option | Description | Values | Default |
|
| Option | Description | Values | Default |
|
||||||
| ------ | ----------- | ------ | ------- |
|
| ------ | ----------- | ------ | ------- |
|
||||||
|packageName|Go package name (convention: lowercase).| |openapi|
|
|packageName|Go package name (convention: lowercase).| |openapi|
|
||||||
|
|packageVersion|Go package version.| |1.0.0|
|
||||||
|hideGenerationTimestamp|Hides the generation timestamp when files are generated.| |true|
|
|hideGenerationTimestamp|Hides the generation timestamp when files are generated.| |true|
|
||||||
|
|||||||
@@ -8,4 +8,7 @@ sidebar_label: go-server
|
|||||||
| Option | Description | Values | Default |
|
| Option | Description | Values | Default |
|
||||||
| ------ | ----------- | ------ | ------- |
|
| ------ | ----------- | ------ | ------- |
|
||||||
|packageName|Go package name (convention: lowercase).| |openapi|
|
|packageName|Go package name (convention: lowercase).| |openapi|
|
||||||
|
|packageVersion|Go package version.| |1.0.0|
|
||||||
|hideGenerationTimestamp|Hides the generation timestamp when files are generated.| |true|
|
|hideGenerationTimestamp|Hides the generation timestamp when files are generated.| |true|
|
||||||
|
|sourceFolder|source folder for generated code| |go|
|
||||||
|
|serverPort|The network port the generated server binds to| |8080|
|
||||||
|
|||||||
@@ -8,8 +8,8 @@ sidebar_label: go
|
|||||||
| Option | Description | Values | Default |
|
| Option | Description | Values | Default |
|
||||||
| ------ | ----------- | ------ | ------- |
|
| ------ | ----------- | ------ | ------- |
|
||||||
|packageName|Go package name (convention: lowercase).| |openapi|
|
|packageName|Go package name (convention: lowercase).| |openapi|
|
||||||
|hideGenerationTimestamp|Hides the generation timestamp when files are generated.| |true|
|
|
||||||
|packageVersion|Go package version.| |1.0.0|
|
|packageVersion|Go package version.| |1.0.0|
|
||||||
|
|hideGenerationTimestamp|Hides the generation timestamp when files are generated.| |true|
|
||||||
|withGoCodegenComment|whether to include Go codegen comment to disable Go Lint and collapse by default GitHub in PRs and diffs| |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|
|
|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|
|
||||||
|prependFormOrBodyParameters|Add form or body parameters to the beginning of the parameter list.| |false|
|
|prependFormOrBodyParameters|Add form or body parameters to the beginning of the parameter list.| |false|
|
||||||
|
|||||||
@@ -54,4 +54,4 @@ sidebar_label: java
|
|||||||
|useRuntimeException|Use RuntimeException instead of Exception| |false|
|
|useRuntimeException|Use RuntimeException instead of Exception| |false|
|
||||||
|feignVersion|Version of OpenFeign: '10.x', '9.x' (default)| |false|
|
|feignVersion|Version of OpenFeign: '10.x', '9.x' (default)| |false|
|
||||||
|useReflectionEqualsHashCode|Use org.apache.commons.lang3.builder for equals and hashCode in the models. WARNING: This will fail under a security manager, unless the appropriate permissions are set up correctly and also there's potential performance impact.| |false|
|
|useReflectionEqualsHashCode|Use org.apache.commons.lang3.builder for equals and hashCode in the models. WARNING: This will fail under a security manager, unless the appropriate permissions are set up correctly and also there's potential performance impact.| |false|
|
||||||
|library|library template (sub-template) to use|<dl><dt>**jersey1**</dt><dd>HTTP client: Jersey client 1.19.4. JSON processing: Jackson 2.8.9. Enable Java6 support using '-DsupportJava6=true'. Enable gzip request encoding using '-DuseGzipFeature=true'.</dd><dt>**feign**</dt><dd>HTTP client: OpenFeign 9.4.0. JSON processing: Jackson 2.8.9. To enable OpenFeign 10.x, set the 'feignVersion' option to '10.x'</dd><dt>**jersey2**</dt><dd>HTTP client: Jersey client 2.25.1. JSON processing: Jackson 2.8.9</dd><dt>**okhttp-gson**</dt><dd>HTTP client: OkHttp 2.7.5. JSON processing: Gson 2.8.1. Enable Parcelable models on Android using '-DparcelableModel=true'. Enable gzip request encoding using '-DuseGzipFeature=true'.</dd><dt>**retrofit**</dt><dd>HTTP client: OkHttp 2.7.5. JSON processing: Gson 2.3.1 (Retrofit 1.9.0). IMPORTANT NOTE: retrofit1.x is no longer actively maintained so please upgrade to 'retrofit2' instead.</dd><dt>**retrofit2**</dt><dd>HTTP client: OkHttp 3.8.0. JSON processing: Gson 2.6.1 (Retrofit 2.3.0). Enable the RxJava adapter using '-DuseRxJava[2]=true'. (RxJava 1.x or 2.x)</dd><dt>**resttemplate**</dt><dd>HTTP client: Spring RestTemplate 4.3.9-RELEASE. JSON processing: Jackson 2.8.9</dd><dt>**webclient**</dt><dd>HTTP client: Spring WebClient 5.0.7-RELEASE. JSON processing: Jackson 2.9.5</dd><dt>**resteasy**</dt><dd>HTTP client: Resteasy client 3.1.3.Final. JSON processing: Jackson 2.8.9</dd><dt>**vertx**</dt><dd>HTTP client: VertX client 3.2.4. JSON processing: Jackson 2.8.9</dd><dt>**google-api-client**</dt><dd>HTTP client: Google API client 1.23.0. JSON processing: Jackson 2.8.9</dd><dt>**rest-assured**</dt><dd>HTTP client: rest-assured : 3.1.0. JSON processing: Gson 2.6.1. Only for Java8</dd><dl>|okhttp-gson|
|
|library|library template (sub-template) to use|<dl><dt>**jersey1**</dt><dd>HTTP client: Jersey client 1.19.x. JSON processing: Jackson 2.8.x. Enable Java6 support using '-DsupportJava6=true'. Enable gzip request encoding using '-DuseGzipFeature=true'.</dd><dt>**feign**</dt><dd>HTTP client: OpenFeign 9.x or 10.x. JSON processing: Jackson 2.8.x. To enable OpenFeign 10.x, set the 'feignVersion' option to '10.x'</dd><dt>**jersey2**</dt><dd>HTTP client: Jersey client 2.25.1. JSON processing: Jackson 2.8.x</dd><dt>**okhttp-gson**</dt><dd>HTTP client: OkHttp 3.x. JSON processing: Gson 2.8.x. Enable Parcelable models on Android using '-DparcelableModel=true'. Enable gzip request encoding using '-DuseGzipFeature=true'.</dd><dt>**retrofit**</dt><dd>HTTP client: OkHttp 2.x. JSON processing: Gson 2.x (Retrofit 1.9.0). IMPORTANT NOTE: retrofit1.x is no longer actively maintained so please upgrade to 'retrofit2' instead.</dd><dt>**retrofit2**</dt><dd>HTTP client: OkHttp 3.x. JSON processing: Gson 2.x (Retrofit 2.3.0). Enable the RxJava adapter using '-DuseRxJava[2]=true'. (RxJava 1.x or 2.x)</dd><dt>**resttemplate**</dt><dd>HTTP client: Spring RestTemplate 4.x. JSON processing: Jackson 2.8.x</dd><dt>**webclient**</dt><dd>HTTP client: Spring WebClient 5.x. JSON processing: Jackson 2.9.x</dd><dt>**resteasy**</dt><dd>HTTP client: Resteasy client 3.x. JSON processing: Jackson 2.8.x</dd><dt>**vertx**</dt><dd>HTTP client: VertX client 3.x. JSON processing: Jackson 2.8.x</dd><dt>**google-api-client**</dt><dd>HTTP client: Google API client 1.x. JSON processing: Jackson 2.8.x</dd><dt>**rest-assured**</dt><dd>HTTP client: rest-assured : 3.x. JSON processing: Gson 2.x. Only for Java8</dd><dl>|okhttp-gson|
|
||||||
|
|||||||
22
docs/generators/scala-play-framework.md
Normal file
22
docs/generators/scala-play-framework.md
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
|
||||||
|
---
|
||||||
|
id: generator-opts-server-scala-play-framework
|
||||||
|
title: Config Options for scala-play-framework
|
||||||
|
sidebar_label: scala-play-framework
|
||||||
|
---
|
||||||
|
|
||||||
|
| 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|
|
||||||
|
|modelPackage|package for generated models| |null|
|
||||||
|
|apiPackage|package for generated api classes| |null|
|
||||||
|
|sourceFolder|source folder for generated code| |null|
|
||||||
|
|routesFileName|Name of the routes file to generate.| |routes|
|
||||||
|
|routesFileName|Base package in which supporting classes are generated.| |org.openapitools|
|
||||||
|
|skipStubs|If set, skips generation of stub classes.| |false|
|
||||||
|
|supportAsync|If set, wraps API return types with Futures and generates async actions.| |false|
|
||||||
|
|generateCustomExceptions|If set, generates custom exception types.| |true|
|
||||||
|
|useSwaggerUI|Add a route to /api which show your documentation in swagger-ui. Will also import needed dependencies| |true|
|
||||||
22
docs/generators/scala-play-server.md
Normal file
22
docs/generators/scala-play-server.md
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
|
||||||
|
---
|
||||||
|
id: generator-opts-server-scala-play-server
|
||||||
|
title: Config Options for scala-play-server
|
||||||
|
sidebar_label: scala-play-server
|
||||||
|
---
|
||||||
|
|
||||||
|
| Option | Description | Values | Default |
|
||||||
|
| ------ | ----------- | ------ | ------- |
|
||||||
|
|sortParamsByRequiredFlag|Sort method arguments to place required parameters before optional parameters.| |true|
|
||||||
|
|ensureUniqueParams|Whether to ensure parameter names are unique in an operation (rename parameters that are not).| |true|
|
||||||
|
|allowUnicodeIdentifiers|boolean, toggles whether unicode identifiers are allowed in names or not, default is false| |false|
|
||||||
|
|prependFormOrBodyParameters|Add form or body parameters to the beginning of the parameter list.| |false|
|
||||||
|
|modelPackage|package for generated models| |null|
|
||||||
|
|apiPackage|package for generated api classes| |null|
|
||||||
|
|sourceFolder|source folder for generated code| |null|
|
||||||
|
|routesFileName|Name of the routes file to generate.| |routes|
|
||||||
|
|routesFileName|Base package in which supporting classes are generated.| |org.openapitools|
|
||||||
|
|skipStubs|If set, skips generation of stub classes.| |false|
|
||||||
|
|supportAsync|If set, wraps API return types with Futures and generates async actions.| |false|
|
||||||
|
|generateCustomExceptions|If set, generates custom exception types.| |true|
|
||||||
|
|useSwaggerUI|Add a route to /api which show your documentation in swagger-ui. Will also import needed dependencies| |true|
|
||||||
@@ -249,4 +249,4 @@ If your API client is using named parameters in the function call (e.g. Perl req
|
|||||||
|
|
||||||
## Default basePath
|
## Default basePath
|
||||||
|
|
||||||
The default `basePath` has been changed from `https://localhost` to `http://locallhost` (http without s)
|
The default `basePath` has been changed from `https://localhost` to `http://localhost` (http without s)
|
||||||
|
|||||||
@@ -72,8 +72,8 @@ SYNOPSIS
|
|||||||
|
|
||||||
OPTIONS
|
OPTIONS
|
||||||
-f <output format>, --format <output format>
|
-f <output format>, --format <output format>
|
||||||
Write output files in the desired format. Options are 'text' and
|
Write output files in the desired format. Options are 'text',
|
||||||
'markdown'. Default is 'text'.
|
'markdown' or 'yamlsample'. Default is 'text'.
|
||||||
|
|
||||||
-g <generator name>, --generator-name <generator name>
|
-g <generator name>, --generator-name <generator name>
|
||||||
generator to get config help for
|
generator to get config help for
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>org.openapitools</groupId>
|
<groupId>org.openapitools</groupId>
|
||||||
<artifactId>openapi-generator-project</artifactId>
|
<artifactId>openapi-generator-project</artifactId>
|
||||||
<version>4.0.0-SNAPSHOT</version>
|
<version>4.0.0-beta3</version>
|
||||||
<relativePath>../..</relativePath>
|
<relativePath>../..</relativePath>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|||||||
@@ -29,8 +29,8 @@ import org.slf4j.LoggerFactory;
|
|||||||
|
|
||||||
import java.io.*;
|
import java.io.*;
|
||||||
import java.nio.charset.StandardCharsets;
|
import java.nio.charset.StandardCharsets;
|
||||||
import java.util.Map;
|
|
||||||
import java.nio.file.Paths;
|
import java.nio.file.Paths;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
import static org.apache.commons.lang3.StringEscapeUtils.escapeHtml4;
|
import static org.apache.commons.lang3.StringEscapeUtils.escapeHtml4;
|
||||||
import static org.apache.commons.lang3.StringUtils.isEmpty;
|
import static org.apache.commons.lang3.StringUtils.isEmpty;
|
||||||
@@ -40,30 +40,34 @@ public class ConfigHelp implements Runnable {
|
|||||||
|
|
||||||
private static final Logger LOGGER = LoggerFactory.getLogger(Generate.class);
|
private static final Logger LOGGER = LoggerFactory.getLogger(Generate.class);
|
||||||
|
|
||||||
@Option(name = {"-g", "--generator-name"}, title = "generator name",
|
public static final String FORMAT_TEXT = "text";
|
||||||
description = "generator to get config help for")
|
public static final String FORMAT_MARKDOWN = "markdown";
|
||||||
|
public static final String FORMAT_YAMLSAMPLE = "yamlsample";
|
||||||
|
|
||||||
|
@Option(name = {"-g",
|
||||||
|
"--generator-name"}, title = "generator name", description = "generator to get config help for")
|
||||||
private String generatorName;
|
private String generatorName;
|
||||||
|
|
||||||
@Option(name = {"--named-header"}, title = "named header",
|
@Option(name = {
|
||||||
description = "Header includes the generator name, for clarity in output")
|
"--named-header"}, title = "named header", description = "Header includes the generator name, for clarity in output")
|
||||||
private Boolean namedHeader;
|
private Boolean namedHeader;
|
||||||
|
|
||||||
@Option(name = {"-o", "--output"}, title = "output location",
|
@Option(name = {"-o",
|
||||||
description = "Optionally write help to this location, otherwise default is standard output")
|
"--output"}, title = "output location", description = "Optionally write help to this location, otherwise default is standard output")
|
||||||
private String outputFile;
|
private String outputFile;
|
||||||
|
|
||||||
@Option(name = {"-f", "--format"}, title = "output format",
|
@Option(name = {"-f",
|
||||||
description = "Write output files in the desired format. Options are 'text' and 'markdown'. Default is 'text'.")
|
"--format"}, title = "output format", description = "Write output files in the desired format. Options are 'text', 'markdown' or 'yamlsample'. Default is 'text'.", allowedValues = {
|
||||||
|
FORMAT_TEXT, FORMAT_MARKDOWN, FORMAT_YAMLSAMPLE})
|
||||||
private String format;
|
private String format;
|
||||||
|
|
||||||
@Option(name = {"--markdown-header"}, title = "markdown header",
|
@Option(name = {
|
||||||
description = "When format=markdown, include this option to write out markdown headers (e.g. for docusaurus).")
|
"--markdown-header"}, title = "markdown header", description = "When format=markdown, include this option to write out markdown headers (e.g. for docusaurus).")
|
||||||
private Boolean markdownHeader;
|
private Boolean markdownHeader;
|
||||||
|
|
||||||
private String newline = System.lineSeparator();
|
private String newline = System.lineSeparator();
|
||||||
|
|
||||||
@Override
|
@Override public void run() {
|
||||||
public void run() {
|
|
||||||
if (isEmpty(generatorName)) {
|
if (isEmpty(generatorName)) {
|
||||||
LOGGER.error("[error] A generator name (--generator-name / -g) is required.");
|
LOGGER.error("[error] A generator name (--generator-name / -g) is required.");
|
||||||
System.exit(1);
|
System.exit(1);
|
||||||
@@ -73,20 +77,34 @@ public class ConfigHelp implements Runnable {
|
|||||||
StringBuilder sb = new StringBuilder();
|
StringBuilder sb = new StringBuilder();
|
||||||
CodegenConfig config = CodegenConfigLoader.forName(generatorName);
|
CodegenConfig config = CodegenConfigLoader.forName(generatorName);
|
||||||
|
|
||||||
if (StringUtils.isEmpty(format) || "text".equalsIgnoreCase(format)) {
|
String desiredFormat = StringUtils.defaultIfBlank(format, FORMAT_TEXT);
|
||||||
generatePlainTextHelp(sb, config);
|
|
||||||
} else if ("markdown".equalsIgnoreCase(format)) {
|
switch (desiredFormat) {
|
||||||
generateMarkdownHelp(sb, config);
|
case FORMAT_MARKDOWN:
|
||||||
} else {
|
generateMarkdownHelp(sb, config);
|
||||||
LOGGER.warn("[warning] Unrecognized format option: %s.%n", format);
|
break;
|
||||||
|
case FORMAT_YAMLSAMPLE:
|
||||||
|
generateYamlSample(sb, config);
|
||||||
|
break;
|
||||||
|
case FORMAT_TEXT:
|
||||||
|
generatePlainTextHelp(sb, config);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
LOGGER.warn("[warning] Unrecognized format option: {}", format);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (!isEmpty(outputFile)) {
|
if (!isEmpty(outputFile)) {
|
||||||
File out = Paths.get(outputFile).toFile();
|
File out = Paths.get(outputFile).toFile();
|
||||||
//noinspection ResultOfMethodCallIgnored
|
//noinspection ResultOfMethodCallIgnored
|
||||||
out.getParentFile().mkdirs();
|
File parentFolder = out.getParentFile();
|
||||||
|
if (parentFolder != null && parentFolder.isDirectory()) {
|
||||||
|
parentFolder.mkdirs();
|
||||||
|
}
|
||||||
|
|
||||||
try (Writer writer = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(out), StandardCharsets.UTF_8))) {
|
try (Writer writer = new BufferedWriter(
|
||||||
|
new OutputStreamWriter(new FileOutputStream(out), StandardCharsets.UTF_8))) {
|
||||||
writer.write(sb.toString());
|
writer.write(sb.toString());
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@@ -101,12 +119,41 @@ public class ConfigHelp implements Runnable {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void generateYamlSample(StringBuilder sb, CodegenConfig config) {
|
||||||
|
|
||||||
|
for (CliOption langCliOption : config.cliOptions()) {
|
||||||
|
|
||||||
|
sb.append("# Description: ").append(langCliOption.getDescription()).append(newline);
|
||||||
|
|
||||||
|
Map<String, String> enums = langCliOption.getEnum();
|
||||||
|
if (enums != null) {
|
||||||
|
sb.append("# Available Values:").append(newline);
|
||||||
|
|
||||||
|
for (Map.Entry<String, String> entry : enums.entrySet()) {
|
||||||
|
sb.append("# ").append(entry.getKey()).append(newline);
|
||||||
|
sb.append("# ").append(entry.getValue()).append(newline);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
String defaultValue = langCliOption.getDefault();
|
||||||
|
|
||||||
|
if (defaultValue != null) {
|
||||||
|
sb.append(langCliOption.getOpt()).append(": ").append(defaultValue).append(newline);
|
||||||
|
} else {
|
||||||
|
sb.append("# ").append(langCliOption.getOpt()).append(": ").append(newline);
|
||||||
|
}
|
||||||
|
|
||||||
|
sb.append(newline);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void generateMarkdownHelp(StringBuilder sb, CodegenConfig config) {
|
private void generateMarkdownHelp(StringBuilder sb, CodegenConfig config) {
|
||||||
sb.append(newline);
|
sb.append(newline);
|
||||||
|
|
||||||
if (Boolean.TRUE.equals(markdownHeader)) {
|
if (Boolean.TRUE.equals(markdownHeader)) {
|
||||||
sb.append("---").append(newline);
|
sb.append("---").append(newline);
|
||||||
sb.append("id: generator-opts-").append(config.getTag().toValue()).append("-").append(config.getName()).append(newline);
|
sb.append("id: generator-opts-").append(config.getTag().toValue()).append("-")
|
||||||
|
.append(config.getName()).append(newline);
|
||||||
sb.append("title: Config Options for ").append(generatorName).append(newline);
|
sb.append("title: Config Options for ").append(generatorName).append(newline);
|
||||||
sb.append("sidebar_label: ").append(generatorName).append(newline);
|
sb.append("sidebar_label: ").append(generatorName).append(newline);
|
||||||
sb.append("---").append(newline);
|
sb.append("---").append(newline);
|
||||||
@@ -167,7 +214,8 @@ public class ConfigHelp implements Runnable {
|
|||||||
for (CliOption langCliOption : config.cliOptions()) {
|
for (CliOption langCliOption : config.cliOptions()) {
|
||||||
sb.append("\t").append(langCliOption.getOpt());
|
sb.append("\t").append(langCliOption.getOpt());
|
||||||
sb.append(newline);
|
sb.append(newline);
|
||||||
sb.append("\t ").append(langCliOption.getOptionHelp().replaceAll("\n", System.lineSeparator() + "\t "));
|
sb.append("\t ").append(langCliOption.getOptionHelp()
|
||||||
|
.replaceAll("\n", System.lineSeparator() + "\t "));
|
||||||
sb.append(newline);
|
sb.append(newline);
|
||||||
sb.append(newline);
|
sb.append(newline);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -217,6 +217,11 @@ public class Generate implements Runnable {
|
|||||||
@Option(name = {"--generate-alias-as-model"}, title = "generate alias (array, map) as model", description = CodegenConstants.GENERATE_ALIAS_AS_MODEL_DESC)
|
@Option(name = {"--generate-alias-as-model"}, title = "generate alias (array, map) as model", description = CodegenConstants.GENERATE_ALIAS_AS_MODEL_DESC)
|
||||||
private Boolean generateAliasAsModel;
|
private Boolean generateAliasAsModel;
|
||||||
|
|
||||||
|
@Option(name = {"--minimal-update"},
|
||||||
|
title = "Minimal update",
|
||||||
|
description = "Only write output files that have changed.")
|
||||||
|
private Boolean minimalUpdate;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
if (logToStderr != null) {
|
if (logToStderr != null) {
|
||||||
@@ -346,6 +351,9 @@ public class Generate implements Runnable {
|
|||||||
if (generateAliasAsModel != null) {
|
if (generateAliasAsModel != null) {
|
||||||
configurator.setGenerateAliasAsModel(generateAliasAsModel);
|
configurator.setGenerateAliasAsModel(generateAliasAsModel);
|
||||||
}
|
}
|
||||||
|
if (minimalUpdate != null) {
|
||||||
|
configurator.setEnableMinimalUpdate(minimalUpdate);
|
||||||
|
}
|
||||||
|
|
||||||
applySystemPropertiesKvpList(systemProperties, configurator);
|
applySystemPropertiesKvpList(systemProperties, configurator);
|
||||||
applyInstantiationTypesKvpList(instantiationTypes, configurator);
|
applyInstantiationTypesKvpList(instantiationTypes, configurator);
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
openApiGeneratorVersion=4.0.0-SNAPSHOT
|
openApiGeneratorVersion=4.0.0-beta3
|
||||||
|
|
||||||
# BEGIN placeholders
|
# BEGIN placeholders
|
||||||
# these are just placeholders to allow contributors to build directly
|
# these are just placeholders to allow contributors to build directly
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>org.openapitools</groupId>
|
<groupId>org.openapitools</groupId>
|
||||||
<artifactId>openapi-generator-project</artifactId>
|
<artifactId>openapi-generator-project</artifactId>
|
||||||
<version>4.0.0-SNAPSHOT</version>
|
<version>4.0.0-beta3</version>
|
||||||
<relativePath>../..</relativePath>
|
<relativePath>../..</relativePath>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|||||||
@@ -0,0 +1,142 @@
|
|||||||
|
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
|
||||||
|
<parent>
|
||||||
|
<groupId>org.openapitools</groupId>
|
||||||
|
<artifactId>multi-parent</artifactId>
|
||||||
|
<version>1.0-SNAPSHOT</version>
|
||||||
|
<relativePath>../</relativePath>
|
||||||
|
</parent>
|
||||||
|
|
||||||
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
<artifactId>java-client</artifactId>
|
||||||
|
<packaging>jar</packaging>
|
||||||
|
<version>1.0-SNAPSHOT</version>
|
||||||
|
<name>java-client</name>
|
||||||
|
<url>http://maven.apache.org</url>
|
||||||
|
<build>
|
||||||
|
<plugins>
|
||||||
|
<!-- activate the plugin -->
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.openapitools</groupId>
|
||||||
|
<artifactId>openapi-generator-maven-plugin</artifactId>
|
||||||
|
<version>4.0.0-SNAPSHOT</version>
|
||||||
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>${project.groupId}</groupId>
|
||||||
|
<artifactId>sample-schema</artifactId>
|
||||||
|
<version>${project.parent.version}</version>
|
||||||
|
</dependency>
|
||||||
|
</dependencies>
|
||||||
|
<executions>
|
||||||
|
<execution>
|
||||||
|
<goals>
|
||||||
|
<goal>generate</goal>
|
||||||
|
</goals>
|
||||||
|
<configuration>
|
||||||
|
<!-- specify the OpenAPI spec -->
|
||||||
|
<inputSpec>openapi.yaml</inputSpec>
|
||||||
|
|
||||||
|
<!-- target to generate java client code -->
|
||||||
|
<generatorName>java</generatorName>
|
||||||
|
|
||||||
|
<!-- hint: if you want to generate java server code, e.g. based on Spring Boot,
|
||||||
|
you can use the following target: <generatorName>spring</generatorName> -->
|
||||||
|
|
||||||
|
<!-- pass any necessary config options -->
|
||||||
|
<configOptions>
|
||||||
|
<dateLibrary>joda</dateLibrary>
|
||||||
|
</configOptions>
|
||||||
|
|
||||||
|
<!-- override the default library to jersey2 -->
|
||||||
|
<library>jersey2</library>
|
||||||
|
</configuration>
|
||||||
|
</execution>
|
||||||
|
</executions>
|
||||||
|
</plugin>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
|
<artifactId>maven-compiler-plugin</artifactId>
|
||||||
|
<version>3.6.1</version>
|
||||||
|
<configuration>
|
||||||
|
<source>1.7</source>
|
||||||
|
<target>1.7</target>
|
||||||
|
</configuration>
|
||||||
|
</plugin>
|
||||||
|
</plugins>
|
||||||
|
</build>
|
||||||
|
<dependencies>
|
||||||
|
<!-- dependencies are needed for the client being generated -->
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>io.swagger</groupId>
|
||||||
|
<artifactId>swagger-annotations</artifactId>
|
||||||
|
<version>${swagger-annotations-version}</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!-- You can find the dependencies for the library configuation you chose by looking in JavaClientCodegen.
|
||||||
|
Then find the corresponding dependency on Maven Central, and set the versions in the property section below -->
|
||||||
|
|
||||||
|
<!-- HTTP client: jersey-client -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.glassfish.jersey.core</groupId>
|
||||||
|
<artifactId>jersey-client</artifactId>
|
||||||
|
<version>${jersey-version}</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.glassfish.jersey.media</groupId>
|
||||||
|
<artifactId>jersey-media-multipart</artifactId>
|
||||||
|
<version>${jersey-version}</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.glassfish.jersey.media</groupId>
|
||||||
|
<artifactId>jersey-media-json-jackson</artifactId>
|
||||||
|
<version>${jersey-version}</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!-- JSON processing: jackson -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.fasterxml.jackson.jaxrs</groupId>
|
||||||
|
<artifactId>jackson-jaxrs-base</artifactId>
|
||||||
|
<version>${jackson-version}</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.fasterxml.jackson.core</groupId>
|
||||||
|
<artifactId>jackson-core</artifactId>
|
||||||
|
<version>${jackson-version}</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.fasterxml.jackson.core</groupId>
|
||||||
|
<artifactId>jackson-annotations</artifactId>
|
||||||
|
<version>${jackson-version}</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.fasterxml.jackson.core</groupId>
|
||||||
|
<artifactId>jackson-databind</artifactId>
|
||||||
|
<version>${jackson-version}</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.fasterxml.jackson.jaxrs</groupId>
|
||||||
|
<artifactId>jackson-jaxrs-json-provider</artifactId>
|
||||||
|
<version>${jackson-version}</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!-- Joda time: if you use it -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.fasterxml.jackson.datatype</groupId>
|
||||||
|
<artifactId>jackson-datatype-joda</artifactId>
|
||||||
|
<version>${jackson-version}</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>joda-time</groupId>
|
||||||
|
<artifactId>joda-time</artifactId>
|
||||||
|
<version>${jodatime-version}</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!-- Base64 encoding that works in both JVM and Android -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.brsanthu</groupId>
|
||||||
|
<artifactId>migbase64</artifactId>
|
||||||
|
<version>2.2</version>
|
||||||
|
</dependency>
|
||||||
|
</dependencies>
|
||||||
|
|
||||||
|
</project>
|
||||||
@@ -0,0 +1,23 @@
|
|||||||
|
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
|
||||||
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
<groupId>org.openapitools</groupId>
|
||||||
|
<artifactId>multi-parent</artifactId>
|
||||||
|
<packaging>pom</packaging>
|
||||||
|
<version>1.0-SNAPSHOT</version>
|
||||||
|
<name>parent-project</name>
|
||||||
|
<url>http://maven.apache.org</url>
|
||||||
|
|
||||||
|
<modules>
|
||||||
|
<module>sample-schema</module>
|
||||||
|
<module>java-client</module>
|
||||||
|
</modules>
|
||||||
|
|
||||||
|
<properties>
|
||||||
|
<swagger-annotations-version>1.5.8</swagger-annotations-version>
|
||||||
|
<jersey-version>2.27</jersey-version>
|
||||||
|
<jackson-version>2.8.9</jackson-version>
|
||||||
|
<jodatime-version>2.7</jodatime-version>
|
||||||
|
<maven-plugin-version>1.0.0</maven-plugin-version>
|
||||||
|
<junit-version>4.8.1</junit-version>
|
||||||
|
</properties>
|
||||||
|
</project>
|
||||||
@@ -0,0 +1,18 @@
|
|||||||
|
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
|
||||||
|
<parent>
|
||||||
|
<groupId>org.openapitools</groupId>
|
||||||
|
<artifactId>multi-parent</artifactId>
|
||||||
|
<version>1.0-SNAPSHOT</version>
|
||||||
|
<relativePath>../</relativePath>
|
||||||
|
</parent>
|
||||||
|
|
||||||
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
<groupId>org.openapitools</groupId>
|
||||||
|
<artifactId>sample-schema</artifactId>
|
||||||
|
<packaging>jar</packaging>
|
||||||
|
<version>1.0-SNAPSHOT</version>
|
||||||
|
<name>sample-schema</name>
|
||||||
|
<url>http://maven.apache.org</url>
|
||||||
|
|
||||||
|
|
||||||
|
</project>
|
||||||
@@ -0,0 +1,702 @@
|
|||||||
|
---
|
||||||
|
swagger: "2.0"
|
||||||
|
info:
|
||||||
|
description: "This is a sample server Petstore server. You can find out more about\
|
||||||
|
\ Swagger at [http://swagger.io](http://swagger.io) or on [irc.freenode.net, #swagger](http://swagger.io/irc/).\
|
||||||
|
\ For this sample, you can use the api key `special-key` to test the authorization\
|
||||||
|
\ filters."
|
||||||
|
version: "1.0.0"
|
||||||
|
title: "Swagger Petstore"
|
||||||
|
termsOfService: "http://swagger.io/terms/"
|
||||||
|
contact:
|
||||||
|
email: "apiteam@swagger.io"
|
||||||
|
license:
|
||||||
|
name: "Apache 2.0"
|
||||||
|
url: "http://www.apache.org/licenses/LICENSE-2.0.html"
|
||||||
|
host: "petstore.swagger.io"
|
||||||
|
basePath: "/v2"
|
||||||
|
tags:
|
||||||
|
- name: "pet"
|
||||||
|
description: "Everything about your Pets"
|
||||||
|
externalDocs:
|
||||||
|
description: "Find out more"
|
||||||
|
url: "http://swagger.io"
|
||||||
|
- name: "store"
|
||||||
|
description: "Access to Petstore orders"
|
||||||
|
- name: "user"
|
||||||
|
description: "Operations about user"
|
||||||
|
externalDocs:
|
||||||
|
description: "Find out more about our store"
|
||||||
|
url: "http://swagger.io"
|
||||||
|
schemes:
|
||||||
|
- "http"
|
||||||
|
paths:
|
||||||
|
/pet:
|
||||||
|
post:
|
||||||
|
tags:
|
||||||
|
- "pet"
|
||||||
|
summary: "Add a new pet to the store"
|
||||||
|
description: ""
|
||||||
|
operationId: "addPet"
|
||||||
|
consumes:
|
||||||
|
- "application/json"
|
||||||
|
- "application/xml"
|
||||||
|
produces:
|
||||||
|
- "application/xml"
|
||||||
|
- "application/json"
|
||||||
|
parameters:
|
||||||
|
- in: "body"
|
||||||
|
name: "body"
|
||||||
|
description: "Pet object that needs to be added to the store"
|
||||||
|
required: true
|
||||||
|
schema:
|
||||||
|
$ref: "#/definitions/Pet"
|
||||||
|
responses:
|
||||||
|
405:
|
||||||
|
description: "Invalid input"
|
||||||
|
security:
|
||||||
|
- petstore_auth:
|
||||||
|
- "write:pets"
|
||||||
|
- "read:pets"
|
||||||
|
put:
|
||||||
|
tags:
|
||||||
|
- "pet"
|
||||||
|
summary: "Update an existing pet"
|
||||||
|
description: ""
|
||||||
|
operationId: "updatePet"
|
||||||
|
consumes:
|
||||||
|
- "application/json"
|
||||||
|
- "application/xml"
|
||||||
|
produces:
|
||||||
|
- "application/xml"
|
||||||
|
- "application/json"
|
||||||
|
parameters:
|
||||||
|
- in: "body"
|
||||||
|
name: "body"
|
||||||
|
description: "Pet object that needs to be added to the store"
|
||||||
|
required: true
|
||||||
|
schema:
|
||||||
|
$ref: "#/definitions/Pet"
|
||||||
|
responses:
|
||||||
|
400:
|
||||||
|
description: "Invalid ID supplied"
|
||||||
|
404:
|
||||||
|
description: "Pet not found"
|
||||||
|
405:
|
||||||
|
description: "Validation exception"
|
||||||
|
security:
|
||||||
|
- petstore_auth:
|
||||||
|
- "write:pets"
|
||||||
|
- "read:pets"
|
||||||
|
/pet/findByStatus:
|
||||||
|
get:
|
||||||
|
tags:
|
||||||
|
- "pet"
|
||||||
|
summary: "Finds Pets by status"
|
||||||
|
description: "Multiple status values can be provided with comma separated strings"
|
||||||
|
operationId: "findPetsByStatus"
|
||||||
|
produces:
|
||||||
|
- "application/xml"
|
||||||
|
- "application/json"
|
||||||
|
parameters:
|
||||||
|
- name: "status"
|
||||||
|
in: "query"
|
||||||
|
description: "Status values that need to be considered for filter"
|
||||||
|
required: true
|
||||||
|
type: "array"
|
||||||
|
items:
|
||||||
|
type: "string"
|
||||||
|
enum:
|
||||||
|
- "available"
|
||||||
|
- "pending"
|
||||||
|
- "sold"
|
||||||
|
default: "available"
|
||||||
|
collectionFormat: "csv"
|
||||||
|
responses:
|
||||||
|
200:
|
||||||
|
description: "successful operation"
|
||||||
|
schema:
|
||||||
|
type: "array"
|
||||||
|
items:
|
||||||
|
$ref: "#/definitions/Pet"
|
||||||
|
400:
|
||||||
|
description: "Invalid status value"
|
||||||
|
security:
|
||||||
|
- petstore_auth:
|
||||||
|
- "write:pets"
|
||||||
|
- "read:pets"
|
||||||
|
/pet/findByTags:
|
||||||
|
get:
|
||||||
|
tags:
|
||||||
|
- "pet"
|
||||||
|
summary: "Finds Pets by tags"
|
||||||
|
description: "Multiple tags can be provided with comma separated strings. Use\
|
||||||
|
\ tag1, tag2, tag3 for testing."
|
||||||
|
operationId: "findPetsByTags"
|
||||||
|
produces:
|
||||||
|
- "application/xml"
|
||||||
|
- "application/json"
|
||||||
|
parameters:
|
||||||
|
- name: "tags"
|
||||||
|
in: "query"
|
||||||
|
description: "Tags to filter by"
|
||||||
|
required: true
|
||||||
|
type: "array"
|
||||||
|
items:
|
||||||
|
type: "string"
|
||||||
|
collectionFormat: "csv"
|
||||||
|
responses:
|
||||||
|
200:
|
||||||
|
description: "successful operation"
|
||||||
|
schema:
|
||||||
|
type: "array"
|
||||||
|
items:
|
||||||
|
$ref: "#/definitions/Pet"
|
||||||
|
400:
|
||||||
|
description: "Invalid tag value"
|
||||||
|
security:
|
||||||
|
- petstore_auth:
|
||||||
|
- "write:pets"
|
||||||
|
- "read:pets"
|
||||||
|
/pet/{petId}:
|
||||||
|
get:
|
||||||
|
tags:
|
||||||
|
- "pet"
|
||||||
|
summary: "Find pet by ID"
|
||||||
|
description: "Returns a single pet"
|
||||||
|
operationId: "getPetById"
|
||||||
|
produces:
|
||||||
|
- "application/xml"
|
||||||
|
- "application/json"
|
||||||
|
parameters:
|
||||||
|
- name: "petId"
|
||||||
|
in: "path"
|
||||||
|
description: "ID of pet to return"
|
||||||
|
required: true
|
||||||
|
type: "integer"
|
||||||
|
format: "int64"
|
||||||
|
responses:
|
||||||
|
200:
|
||||||
|
description: "successful operation"
|
||||||
|
schema:
|
||||||
|
$ref: "#/definitions/Pet"
|
||||||
|
400:
|
||||||
|
description: "Invalid ID supplied"
|
||||||
|
404:
|
||||||
|
description: "Pet not found"
|
||||||
|
security:
|
||||||
|
- api_key: []
|
||||||
|
post:
|
||||||
|
tags:
|
||||||
|
- "pet"
|
||||||
|
summary: "Updates a pet in the store with form data"
|
||||||
|
description: ""
|
||||||
|
operationId: "updatePetWithForm"
|
||||||
|
consumes:
|
||||||
|
- "application/x-www-form-urlencoded"
|
||||||
|
produces:
|
||||||
|
- "application/xml"
|
||||||
|
- "application/json"
|
||||||
|
parameters:
|
||||||
|
- name: "petId"
|
||||||
|
in: "path"
|
||||||
|
description: "ID of pet that needs to be updated"
|
||||||
|
required: true
|
||||||
|
type: "integer"
|
||||||
|
format: "int64"
|
||||||
|
- name: "name"
|
||||||
|
in: "formData"
|
||||||
|
description: "Updated name of the pet"
|
||||||
|
required: false
|
||||||
|
type: "string"
|
||||||
|
- name: "status"
|
||||||
|
in: "formData"
|
||||||
|
description: "Updated status of the pet"
|
||||||
|
required: false
|
||||||
|
type: "string"
|
||||||
|
responses:
|
||||||
|
405:
|
||||||
|
description: "Invalid input"
|
||||||
|
security:
|
||||||
|
- petstore_auth:
|
||||||
|
- "write:pets"
|
||||||
|
- "read:pets"
|
||||||
|
delete:
|
||||||
|
tags:
|
||||||
|
- "pet"
|
||||||
|
summary: "Deletes a pet"
|
||||||
|
description: ""
|
||||||
|
operationId: "deletePet"
|
||||||
|
produces:
|
||||||
|
- "application/xml"
|
||||||
|
- "application/json"
|
||||||
|
parameters:
|
||||||
|
- name: "api_key"
|
||||||
|
in: "header"
|
||||||
|
required: false
|
||||||
|
type: "string"
|
||||||
|
- name: "petId"
|
||||||
|
in: "path"
|
||||||
|
description: "Pet id to delete"
|
||||||
|
required: true
|
||||||
|
type: "integer"
|
||||||
|
format: "int64"
|
||||||
|
responses:
|
||||||
|
400:
|
||||||
|
description: "Invalid pet value"
|
||||||
|
security:
|
||||||
|
- petstore_auth:
|
||||||
|
- "write:pets"
|
||||||
|
- "read:pets"
|
||||||
|
/pet/{petId}/uploadImage:
|
||||||
|
post:
|
||||||
|
tags:
|
||||||
|
- "pet"
|
||||||
|
summary: "uploads an image"
|
||||||
|
description: ""
|
||||||
|
operationId: "uploadFile"
|
||||||
|
consumes:
|
||||||
|
- "multipart/form-data"
|
||||||
|
produces:
|
||||||
|
- "application/json"
|
||||||
|
parameters:
|
||||||
|
- name: "petId"
|
||||||
|
in: "path"
|
||||||
|
description: "ID of pet to update"
|
||||||
|
required: true
|
||||||
|
type: "integer"
|
||||||
|
format: "int64"
|
||||||
|
- name: "additionalMetadata"
|
||||||
|
in: "formData"
|
||||||
|
description: "Additional data to pass to server"
|
||||||
|
required: false
|
||||||
|
type: "string"
|
||||||
|
- name: "file"
|
||||||
|
in: "formData"
|
||||||
|
description: "file to upload"
|
||||||
|
required: false
|
||||||
|
type: "file"
|
||||||
|
responses:
|
||||||
|
200:
|
||||||
|
description: "successful operation"
|
||||||
|
schema:
|
||||||
|
$ref: "#/definitions/ApiResponse"
|
||||||
|
security:
|
||||||
|
- petstore_auth:
|
||||||
|
- "write:pets"
|
||||||
|
- "read:pets"
|
||||||
|
/store/inventory:
|
||||||
|
get:
|
||||||
|
tags:
|
||||||
|
- "store"
|
||||||
|
summary: "Returns pet inventories by status"
|
||||||
|
description: "Returns a map of status codes to quantities"
|
||||||
|
operationId: "getInventory"
|
||||||
|
produces:
|
||||||
|
- "application/json"
|
||||||
|
parameters: []
|
||||||
|
responses:
|
||||||
|
200:
|
||||||
|
description: "successful operation"
|
||||||
|
schema:
|
||||||
|
type: "object"
|
||||||
|
additionalProperties:
|
||||||
|
type: "integer"
|
||||||
|
format: "int32"
|
||||||
|
security:
|
||||||
|
- api_key: []
|
||||||
|
/store/order:
|
||||||
|
post:
|
||||||
|
tags:
|
||||||
|
- "store"
|
||||||
|
summary: "Place an order for a pet"
|
||||||
|
description: ""
|
||||||
|
operationId: "placeOrder"
|
||||||
|
produces:
|
||||||
|
- "application/xml"
|
||||||
|
- "application/json"
|
||||||
|
parameters:
|
||||||
|
- in: "body"
|
||||||
|
name: "body"
|
||||||
|
description: "order placed for purchasing the pet"
|
||||||
|
required: true
|
||||||
|
schema:
|
||||||
|
$ref: "#/definitions/Order"
|
||||||
|
responses:
|
||||||
|
200:
|
||||||
|
description: "successful operation"
|
||||||
|
schema:
|
||||||
|
$ref: "#/definitions/Order"
|
||||||
|
400:
|
||||||
|
description: "Invalid Order"
|
||||||
|
/store/order/{orderId}:
|
||||||
|
get:
|
||||||
|
tags:
|
||||||
|
- "store"
|
||||||
|
summary: "Find purchase order by ID"
|
||||||
|
description: "For valid response try integer IDs with value <= 5 or > 10. Other\
|
||||||
|
\ values will generated exceptions"
|
||||||
|
operationId: "getOrderById"
|
||||||
|
produces:
|
||||||
|
- "application/xml"
|
||||||
|
- "application/json"
|
||||||
|
parameters:
|
||||||
|
- name: "orderId"
|
||||||
|
in: "path"
|
||||||
|
description: "ID of pet that needs to be fetched"
|
||||||
|
required: true
|
||||||
|
type: "integer"
|
||||||
|
maximum: 5.0
|
||||||
|
minimum: 1.0
|
||||||
|
format: "int64"
|
||||||
|
responses:
|
||||||
|
200:
|
||||||
|
description: "successful operation"
|
||||||
|
schema:
|
||||||
|
$ref: "#/definitions/Order"
|
||||||
|
400:
|
||||||
|
description: "Invalid ID supplied"
|
||||||
|
404:
|
||||||
|
description: "Order not found"
|
||||||
|
delete:
|
||||||
|
tags:
|
||||||
|
- "store"
|
||||||
|
summary: "Delete purchase order by ID"
|
||||||
|
description: "For valid response try integer IDs with value < 1000. Anything\
|
||||||
|
\ above 1000 or nonintegers will generate API errors"
|
||||||
|
operationId: "deleteOrder"
|
||||||
|
produces:
|
||||||
|
- "application/xml"
|
||||||
|
- "application/json"
|
||||||
|
parameters:
|
||||||
|
- name: "orderId"
|
||||||
|
in: "path"
|
||||||
|
description: "ID of the order that needs to be deleted"
|
||||||
|
required: true
|
||||||
|
type: "string"
|
||||||
|
minimum: 1.0
|
||||||
|
responses:
|
||||||
|
400:
|
||||||
|
description: "Invalid ID supplied"
|
||||||
|
404:
|
||||||
|
description: "Order not found"
|
||||||
|
/user:
|
||||||
|
post:
|
||||||
|
tags:
|
||||||
|
- "user"
|
||||||
|
summary: "Create user"
|
||||||
|
description: "This can only be done by the logged in user."
|
||||||
|
operationId: "createUser"
|
||||||
|
produces:
|
||||||
|
- "application/xml"
|
||||||
|
- "application/json"
|
||||||
|
parameters:
|
||||||
|
- in: "body"
|
||||||
|
name: "body"
|
||||||
|
description: "Created user object"
|
||||||
|
required: true
|
||||||
|
schema:
|
||||||
|
$ref: "#/definitions/User"
|
||||||
|
responses:
|
||||||
|
default:
|
||||||
|
description: "successful operation"
|
||||||
|
/user/createWithArray:
|
||||||
|
post:
|
||||||
|
tags:
|
||||||
|
- "user"
|
||||||
|
summary: "Creates list of users with given input array"
|
||||||
|
description: ""
|
||||||
|
operationId: "createUsersWithArrayInput"
|
||||||
|
produces:
|
||||||
|
- "application/xml"
|
||||||
|
- "application/json"
|
||||||
|
parameters:
|
||||||
|
- in: "body"
|
||||||
|
name: "body"
|
||||||
|
description: "List of user object"
|
||||||
|
required: true
|
||||||
|
schema:
|
||||||
|
type: "array"
|
||||||
|
items:
|
||||||
|
$ref: "#/definitions/User"
|
||||||
|
responses:
|
||||||
|
default:
|
||||||
|
description: "successful operation"
|
||||||
|
/user/createWithList:
|
||||||
|
post:
|
||||||
|
tags:
|
||||||
|
- "user"
|
||||||
|
summary: "Creates list of users with given input array"
|
||||||
|
description: ""
|
||||||
|
operationId: "createUsersWithListInput"
|
||||||
|
produces:
|
||||||
|
- "application/xml"
|
||||||
|
- "application/json"
|
||||||
|
parameters:
|
||||||
|
- in: "body"
|
||||||
|
name: "body"
|
||||||
|
description: "List of user object"
|
||||||
|
required: true
|
||||||
|
schema:
|
||||||
|
type: "array"
|
||||||
|
items:
|
||||||
|
$ref: "#/definitions/User"
|
||||||
|
responses:
|
||||||
|
default:
|
||||||
|
description: "successful operation"
|
||||||
|
/user/login:
|
||||||
|
get:
|
||||||
|
tags:
|
||||||
|
- "user"
|
||||||
|
summary: "Logs user into the system"
|
||||||
|
description: ""
|
||||||
|
operationId: "loginUser"
|
||||||
|
produces:
|
||||||
|
- "application/xml"
|
||||||
|
- "application/json"
|
||||||
|
parameters:
|
||||||
|
- name: "username"
|
||||||
|
in: "query"
|
||||||
|
description: "The user name for login"
|
||||||
|
required: true
|
||||||
|
type: "string"
|
||||||
|
- name: "password"
|
||||||
|
in: "query"
|
||||||
|
description: "The password for login in clear text"
|
||||||
|
required: true
|
||||||
|
type: "string"
|
||||||
|
responses:
|
||||||
|
200:
|
||||||
|
description: "successful operation"
|
||||||
|
schema:
|
||||||
|
type: "string"
|
||||||
|
headers:
|
||||||
|
X-Rate-Limit:
|
||||||
|
type: "integer"
|
||||||
|
format: "int32"
|
||||||
|
description: "calls per hour allowed by the user"
|
||||||
|
X-Expires-After:
|
||||||
|
type: "string"
|
||||||
|
format: "date-time"
|
||||||
|
description: "date in UTC when toekn expires"
|
||||||
|
400:
|
||||||
|
description: "Invalid username/password supplied"
|
||||||
|
/user/logout:
|
||||||
|
get:
|
||||||
|
tags:
|
||||||
|
- "user"
|
||||||
|
summary: "Logs out current logged in user session"
|
||||||
|
description: ""
|
||||||
|
operationId: "logoutUser"
|
||||||
|
produces:
|
||||||
|
- "application/xml"
|
||||||
|
- "application/json"
|
||||||
|
parameters: []
|
||||||
|
responses:
|
||||||
|
default:
|
||||||
|
description: "successful operation"
|
||||||
|
/user/{username}:
|
||||||
|
get:
|
||||||
|
tags:
|
||||||
|
- "user"
|
||||||
|
summary: "Get user by user name"
|
||||||
|
description: ""
|
||||||
|
operationId: "getUserByName"
|
||||||
|
produces:
|
||||||
|
- "application/xml"
|
||||||
|
- "application/json"
|
||||||
|
parameters:
|
||||||
|
- name: "username"
|
||||||
|
in: "path"
|
||||||
|
description: "The name that needs to be fetched. Use user1 for testing. "
|
||||||
|
required: true
|
||||||
|
type: "string"
|
||||||
|
responses:
|
||||||
|
200:
|
||||||
|
description: "successful operation"
|
||||||
|
schema:
|
||||||
|
$ref: "#/definitions/User"
|
||||||
|
400:
|
||||||
|
description: "Invalid username supplied"
|
||||||
|
404:
|
||||||
|
description: "User not found"
|
||||||
|
put:
|
||||||
|
tags:
|
||||||
|
- "user"
|
||||||
|
summary: "Updated user"
|
||||||
|
description: "This can only be done by the logged in user."
|
||||||
|
operationId: "updateUser"
|
||||||
|
produces:
|
||||||
|
- "application/xml"
|
||||||
|
- "application/json"
|
||||||
|
parameters:
|
||||||
|
- name: "username"
|
||||||
|
in: "path"
|
||||||
|
description: "name that need to be deleted"
|
||||||
|
required: true
|
||||||
|
type: "string"
|
||||||
|
- in: "body"
|
||||||
|
name: "body"
|
||||||
|
description: "Updated user object"
|
||||||
|
required: true
|
||||||
|
schema:
|
||||||
|
$ref: "#/definitions/User"
|
||||||
|
responses:
|
||||||
|
400:
|
||||||
|
description: "Invalid user supplied"
|
||||||
|
404:
|
||||||
|
description: "User not found"
|
||||||
|
delete:
|
||||||
|
tags:
|
||||||
|
- "user"
|
||||||
|
summary: "Delete user"
|
||||||
|
description: "This can only be done by the logged in user."
|
||||||
|
operationId: "deleteUser"
|
||||||
|
produces:
|
||||||
|
- "application/xml"
|
||||||
|
- "application/json"
|
||||||
|
parameters:
|
||||||
|
- name: "username"
|
||||||
|
in: "path"
|
||||||
|
description: "The name that needs to be deleted"
|
||||||
|
required: true
|
||||||
|
type: "string"
|
||||||
|
responses:
|
||||||
|
400:
|
||||||
|
description: "Invalid username supplied"
|
||||||
|
404:
|
||||||
|
description: "User not found"
|
||||||
|
securityDefinitions:
|
||||||
|
petstore_auth:
|
||||||
|
type: "oauth2"
|
||||||
|
authorizationUrl: "http://petstore.swagger.io/api/oauth/dialog"
|
||||||
|
flow: "implicit"
|
||||||
|
scopes:
|
||||||
|
write:pets: "modify pets in your account"
|
||||||
|
read:pets: "read your pets"
|
||||||
|
api_key:
|
||||||
|
type: "apiKey"
|
||||||
|
name: "api_key"
|
||||||
|
in: "header"
|
||||||
|
definitions:
|
||||||
|
Order:
|
||||||
|
type: "object"
|
||||||
|
properties:
|
||||||
|
id:
|
||||||
|
type: "integer"
|
||||||
|
format: "int64"
|
||||||
|
petId:
|
||||||
|
type: "integer"
|
||||||
|
format: "int64"
|
||||||
|
quantity:
|
||||||
|
type: "integer"
|
||||||
|
format: "int32"
|
||||||
|
shipDate:
|
||||||
|
type: "string"
|
||||||
|
format: "date-time"
|
||||||
|
status:
|
||||||
|
type: "string"
|
||||||
|
description: "Order Status"
|
||||||
|
enum:
|
||||||
|
- "placed"
|
||||||
|
- "approved"
|
||||||
|
- "delivered"
|
||||||
|
complete:
|
||||||
|
type: "boolean"
|
||||||
|
default: false
|
||||||
|
xml:
|
||||||
|
name: "Order"
|
||||||
|
Category:
|
||||||
|
type: "object"
|
||||||
|
properties:
|
||||||
|
id:
|
||||||
|
type: "integer"
|
||||||
|
format: "int64"
|
||||||
|
name:
|
||||||
|
type: "string"
|
||||||
|
xml:
|
||||||
|
name: "Category"
|
||||||
|
User:
|
||||||
|
type: "object"
|
||||||
|
properties:
|
||||||
|
id:
|
||||||
|
type: "integer"
|
||||||
|
format: "int64"
|
||||||
|
username:
|
||||||
|
type: "string"
|
||||||
|
firstName:
|
||||||
|
type: "string"
|
||||||
|
lastName:
|
||||||
|
type: "string"
|
||||||
|
email:
|
||||||
|
type: "string"
|
||||||
|
password:
|
||||||
|
type: "string"
|
||||||
|
phone:
|
||||||
|
type: "string"
|
||||||
|
userStatus:
|
||||||
|
type: "integer"
|
||||||
|
format: "int32"
|
||||||
|
description: "User Status"
|
||||||
|
xml:
|
||||||
|
name: "User"
|
||||||
|
Tag:
|
||||||
|
type: "object"
|
||||||
|
properties:
|
||||||
|
id:
|
||||||
|
type: "integer"
|
||||||
|
format: "int64"
|
||||||
|
name:
|
||||||
|
type: "string"
|
||||||
|
xml:
|
||||||
|
name: "Tag"
|
||||||
|
Pet:
|
||||||
|
type: "object"
|
||||||
|
required:
|
||||||
|
- "name"
|
||||||
|
- "photoUrls"
|
||||||
|
properties:
|
||||||
|
id:
|
||||||
|
type: "integer"
|
||||||
|
format: "int64"
|
||||||
|
category:
|
||||||
|
$ref: "#/definitions/Category"
|
||||||
|
name:
|
||||||
|
type: "string"
|
||||||
|
example: "doggie"
|
||||||
|
photoUrls:
|
||||||
|
type: "array"
|
||||||
|
xml:
|
||||||
|
name: "photoUrl"
|
||||||
|
wrapped: true
|
||||||
|
items:
|
||||||
|
type: "string"
|
||||||
|
tags:
|
||||||
|
type: "array"
|
||||||
|
xml:
|
||||||
|
name: "tag"
|
||||||
|
wrapped: true
|
||||||
|
items:
|
||||||
|
$ref: "#/definitions/Tag"
|
||||||
|
status:
|
||||||
|
type: "string"
|
||||||
|
description: "pet status in the store"
|
||||||
|
enum:
|
||||||
|
- "available"
|
||||||
|
- "pending"
|
||||||
|
- "sold"
|
||||||
|
xml:
|
||||||
|
name: "Pet"
|
||||||
|
ApiResponse:
|
||||||
|
type: "object"
|
||||||
|
properties:
|
||||||
|
code:
|
||||||
|
type: "integer"
|
||||||
|
format: "int32"
|
||||||
|
type:
|
||||||
|
type: "string"
|
||||||
|
message:
|
||||||
|
type: "string"
|
||||||
|
externalDocs:
|
||||||
|
description: "Find out more about Swagger"
|
||||||
|
url: "http://swagger.io"
|
||||||
@@ -4,7 +4,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>org.openapitools</groupId>
|
<groupId>org.openapitools</groupId>
|
||||||
<artifactId>openapi-generator-project</artifactId>
|
<artifactId>openapi-generator-project</artifactId>
|
||||||
<version>4.0.0-SNAPSHOT</version>
|
<version>4.0.0-beta3</version>
|
||||||
<relativePath>../..</relativePath>
|
<relativePath>../..</relativePath>
|
||||||
</parent>
|
</parent>
|
||||||
<artifactId>openapi-generator-maven-plugin</artifactId>
|
<artifactId>openapi-generator-maven-plugin</artifactId>
|
||||||
|
|||||||
@@ -37,6 +37,9 @@ import java.util.List;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
|
import com.google.common.io.ByteSource;
|
||||||
|
import com.google.common.io.CharSource;
|
||||||
|
import io.swagger.v3.parser.util.ClasspathHelper;
|
||||||
import org.apache.maven.plugin.AbstractMojo;
|
import org.apache.maven.plugin.AbstractMojo;
|
||||||
import org.apache.maven.plugin.MojoExecutionException;
|
import org.apache.maven.plugin.MojoExecutionException;
|
||||||
import org.apache.maven.plugins.annotations.LifecyclePhase;
|
import org.apache.maven.plugins.annotations.LifecyclePhase;
|
||||||
@@ -163,6 +166,12 @@ public class CodeGenMojo extends AbstractMojo {
|
|||||||
@Parameter(name = "invokerPackage")
|
@Parameter(name = "invokerPackage")
|
||||||
private String invokerPackage;
|
private String invokerPackage;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The default package to use for the generated objects
|
||||||
|
*/
|
||||||
|
@Parameter(name = "packageName")
|
||||||
|
private String packageName;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* groupId in generated pom.xml
|
* groupId in generated pom.xml
|
||||||
*/
|
*/
|
||||||
@@ -507,6 +516,10 @@ public class CodeGenMojo extends AbstractMojo {
|
|||||||
configurator.setInvokerPackage(invokerPackage);
|
configurator.setInvokerPackage(invokerPackage);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (isNotEmpty(packageName)) {
|
||||||
|
configurator.setPackageName(packageName);
|
||||||
|
}
|
||||||
|
|
||||||
if (isNotEmpty(groupId)) {
|
if (isNotEmpty(groupId)) {
|
||||||
configurator.setGroupId(groupId);
|
configurator.setGroupId(groupId);
|
||||||
}
|
}
|
||||||
@@ -672,7 +685,12 @@ public class CodeGenMojo extends AbstractMojo {
|
|||||||
|
|
||||||
// Store a checksum of the input spec
|
// Store a checksum of the input spec
|
||||||
File storedInputSpecHashFile = getHashFile(inputSpecFile);
|
File storedInputSpecHashFile = getHashFile(inputSpecFile);
|
||||||
String inputSpecHash = Files.asByteSource(inputSpecFile).hash(Hashing.sha256()).toString();
|
ByteSource inputSpecByteSource =
|
||||||
|
inputSpecFile.exists()
|
||||||
|
? Files.asByteSource(inputSpecFile)
|
||||||
|
: CharSource.wrap(ClasspathHelper.loadFileFromClasspath(inputSpecFile.toString().replaceAll("\\\\","/")))
|
||||||
|
.asByteSource(Charsets.UTF_8);
|
||||||
|
String inputSpecHash =inputSpecByteSource.hash(Hashing.sha256()).toString();
|
||||||
|
|
||||||
if (storedInputSpecHashFile.getParent() != null && !new File(storedInputSpecHashFile.getParent()).exists()) {
|
if (storedInputSpecHashFile.getParent() != null && !new File(storedInputSpecHashFile.getParent()).exists()) {
|
||||||
File parent = new File(storedInputSpecHashFile.getParent());
|
File parent = new File(storedInputSpecHashFile.getParent());
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>org.openapitools</groupId>
|
<groupId>org.openapitools</groupId>
|
||||||
<artifactId>openapi-generator-project</artifactId>
|
<artifactId>openapi-generator-project</artifactId>
|
||||||
<version>4.0.0-SNAPSHOT</version>
|
<version>4.0.0-beta3</version>
|
||||||
<relativePath>../..</relativePath>
|
<relativePath>../..</relativePath>
|
||||||
</parent>
|
</parent>
|
||||||
<artifactId>openapi-generator-online</artifactId>
|
<artifactId>openapi-generator-online</artifactId>
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>org.openapitools</groupId>
|
<groupId>org.openapitools</groupId>
|
||||||
<artifactId>openapi-generator-project</artifactId>
|
<artifactId>openapi-generator-project</artifactId>
|
||||||
<version>4.0.0-SNAPSHOT</version>
|
<version>4.0.0-beta3</version>
|
||||||
<relativePath>../..</relativePath>
|
<relativePath>../..</relativePath>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|||||||
@@ -17,6 +17,10 @@
|
|||||||
|
|
||||||
package org.openapitools.codegen;
|
package org.openapitools.codegen;
|
||||||
|
|
||||||
|
import java.nio.charset.Charset;
|
||||||
|
import java.nio.file.Files;
|
||||||
|
import java.nio.file.StandardCopyOption;
|
||||||
|
import java.util.Arrays;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
@@ -28,23 +32,78 @@ import java.util.regex.Pattern;
|
|||||||
|
|
||||||
public abstract class AbstractGenerator {
|
public abstract class AbstractGenerator {
|
||||||
private static final Logger LOGGER = LoggerFactory.getLogger(AbstractGenerator.class);
|
private static final Logger LOGGER = LoggerFactory.getLogger(AbstractGenerator.class);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Is the minimal-file-update option enabled?
|
||||||
|
*
|
||||||
|
* @return Option value
|
||||||
|
*/
|
||||||
|
public abstract boolean getEnableMinimalUpdate();
|
||||||
|
|
||||||
@SuppressWarnings("static-method")
|
/**
|
||||||
|
* Write String to a file, formatting as UTF-8
|
||||||
|
*
|
||||||
|
* @param filename The name of file to write
|
||||||
|
* @param contents The contents string.
|
||||||
|
* @return File representing the written file.
|
||||||
|
* @throws IOException If file cannot be written.
|
||||||
|
*/
|
||||||
public File writeToFile(String filename, String contents) throws IOException {
|
public File writeToFile(String filename, String contents) throws IOException {
|
||||||
LOGGER.info("writing file " + filename);
|
return writeToFile(filename, contents.getBytes(Charset.forName("UTF-8")));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Write bytes to a file
|
||||||
|
*
|
||||||
|
* @param filename The name of file to write
|
||||||
|
* @param contents The contents bytes. Typically this is a UTF-8 formatted string.
|
||||||
|
* @return File representing the written file.
|
||||||
|
* @throws IOException If file cannot be written.
|
||||||
|
*/
|
||||||
|
@SuppressWarnings("static-method")
|
||||||
|
public File writeToFile(String filename, byte contents[]) throws IOException {
|
||||||
|
if (getEnableMinimalUpdate()) {
|
||||||
|
String tempFilename = filename + ".tmp";
|
||||||
|
// Use Paths.get here to normalize path (for Windows file separator, space escaping on Linux/Mac, etc)
|
||||||
|
File outputFile = Paths.get(filename).toFile();
|
||||||
|
File tempFile = null;
|
||||||
|
try {
|
||||||
|
tempFile = writeToFileRaw(tempFilename, contents);
|
||||||
|
if (!filesEqual(tempFile, outputFile)) {
|
||||||
|
LOGGER.info("writing file " + filename);
|
||||||
|
Files.move(tempFile.toPath(), outputFile.toPath(), StandardCopyOption.REPLACE_EXISTING);
|
||||||
|
tempFile = null;
|
||||||
|
} else {
|
||||||
|
LOGGER.info("skipping unchanged file " + filename);
|
||||||
|
}
|
||||||
|
} finally {
|
||||||
|
if (tempFile != null && tempFile.exists()) {
|
||||||
|
try {
|
||||||
|
tempFile.delete();
|
||||||
|
} catch (Exception ex) {
|
||||||
|
LOGGER.error("Error removing temporary file " + tempFile, ex);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return outputFile;
|
||||||
|
} else {
|
||||||
|
LOGGER.info("writing file " + filename);
|
||||||
|
return writeToFileRaw(filename, contents);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean filesEqual(File file1, File file2) throws IOException {
|
||||||
|
return file1.exists() && file2.exists() && Arrays.equals(Files.readAllBytes(file1.toPath()), Files.readAllBytes(file2.toPath()));
|
||||||
|
}
|
||||||
|
|
||||||
|
private File writeToFileRaw(String filename, byte[] contents) throws IOException {
|
||||||
// Use Paths.get here to normalize path (for Windows file separator, space escaping on Linux/Mac, etc)
|
// Use Paths.get here to normalize path (for Windows file separator, space escaping on Linux/Mac, etc)
|
||||||
File output = Paths.get(filename).toFile();
|
File output = Paths.get(filename).toFile();
|
||||||
|
|
||||||
if (output.getParent() != null && !new File(output.getParent()).exists()) {
|
if (output.getParent() != null && !new File(output.getParent()).exists()) {
|
||||||
File parent = new File(output.getParent());
|
File parent = Paths.get(output.getParent()).toFile();
|
||||||
parent.mkdirs();
|
parent.mkdirs();
|
||||||
}
|
}
|
||||||
|
Files.write(output.toPath(), contents);
|
||||||
try (Writer out = new BufferedWriter(new OutputStreamWriter(
|
|
||||||
new FileOutputStream(output), "UTF-8"))) {
|
|
||||||
out.write(contents);
|
|
||||||
}
|
|
||||||
return output;
|
return output;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -28,6 +28,7 @@ public class CliOption {
|
|||||||
private String description;
|
private String description;
|
||||||
private String type;
|
private String type;
|
||||||
private String defaultValue;
|
private String defaultValue;
|
||||||
|
private String optValue;
|
||||||
private Map<String, String> enumValues;
|
private Map<String, String> enumValues;
|
||||||
|
|
||||||
public CliOption(String opt, String description) {
|
public CliOption(String opt, String description) {
|
||||||
@@ -73,6 +74,18 @@ public class CliOption {
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getOptValue() {
|
||||||
|
return this.optValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setOptValue(String optValue) {
|
||||||
|
if (this.enumValues!=null && this.enumValues.containsKey(optValue)) {
|
||||||
|
this.optValue = optValue;
|
||||||
|
} else {
|
||||||
|
this.optValue = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public CliOption addEnum(String value, String description) {
|
public CliOption addEnum(String value, String description) {
|
||||||
if (this.enumValues == null) {
|
if (this.enumValues == null) {
|
||||||
this.enumValues = new LinkedHashMap<String, String>();
|
this.enumValues = new LinkedHashMap<String, String>();
|
||||||
|
|||||||
@@ -260,4 +260,8 @@ public interface CodegenConfig {
|
|||||||
*/
|
*/
|
||||||
void setOpenAPI(OpenAPI openAPI);
|
void setOpenAPI(OpenAPI openAPI);
|
||||||
|
|
||||||
|
public boolean isEnableMinimalUpdate();
|
||||||
|
|
||||||
|
public void setEnableMinimalUpdate(boolean isEnableMinimalUpdate);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -191,9 +191,6 @@ public class CodegenConstants {
|
|||||||
public static final String MODEL_NAME_SUFFIX = "modelNameSuffix";
|
public static final String MODEL_NAME_SUFFIX = "modelNameSuffix";
|
||||||
public static final String MODEL_NAME_SUFFIX_DESC = "Suffix that will be appended to all model names. Default is the empty string.";
|
public static final String MODEL_NAME_SUFFIX_DESC = "Suffix that will be appended to all model names. Default is the empty string.";
|
||||||
|
|
||||||
public static final String OPTIONAL_EMIT_DEFAULT_VALUES = "optionalEmitDefaultValues";
|
|
||||||
public static final String OPTIONAL_EMIT_DEFAULT_VALUES_DESC = "Set DataMember's EmitDefaultValue.";
|
|
||||||
|
|
||||||
public static final String GIT_USER_ID = "gitUserId";
|
public static final String GIT_USER_ID = "gitUserId";
|
||||||
public static final String GIT_USER_ID_DESC = "Git user ID, e.g. openapitools.";
|
public static final String GIT_USER_ID_DESC = "Git user ID, e.g. openapitools.";
|
||||||
|
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ package org.openapitools.codegen;
|
|||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
||||||
public class CodegenProperty implements Cloneable {
|
public class CodegenProperty implements Cloneable {
|
||||||
public String baseName, complexType, getter, setter, description, dataType,
|
public String openApiType, baseName, complexType, getter, setter, description, dataType,
|
||||||
datatypeWithEnum, dataFormat, name, min, max, defaultValue, defaultValueWithParam,
|
datatypeWithEnum, dataFormat, name, min, max, defaultValue, defaultValueWithParam,
|
||||||
baseType, containerType, title;
|
baseType, containerType, title;
|
||||||
|
|
||||||
@@ -415,6 +415,7 @@ public class CodegenProperty implements Cloneable {
|
|||||||
return Objects.hash(
|
return Objects.hash(
|
||||||
_enum,
|
_enum,
|
||||||
allowableValues,
|
allowableValues,
|
||||||
|
openApiType,
|
||||||
baseName,
|
baseName,
|
||||||
baseType,
|
baseType,
|
||||||
complexType,
|
complexType,
|
||||||
@@ -501,6 +502,7 @@ public class CodegenProperty implements Cloneable {
|
|||||||
final CodegenProperty other = (CodegenProperty) obj;
|
final CodegenProperty other = (CodegenProperty) obj;
|
||||||
|
|
||||||
return Objects.equals(baseName, other.baseName) &&
|
return Objects.equals(baseName, other.baseName) &&
|
||||||
|
Objects.equals(openApiType, other.openApiType) &&
|
||||||
Objects.equals(complexType, other.complexType) &&
|
Objects.equals(complexType, other.complexType) &&
|
||||||
Objects.equals(getter, other.getter) &&
|
Objects.equals(getter, other.getter) &&
|
||||||
Objects.equals(setter, other.setter) &&
|
Objects.equals(setter, other.setter) &&
|
||||||
@@ -600,6 +602,7 @@ public class CodegenProperty implements Cloneable {
|
|||||||
public java.lang.String toString() {
|
public java.lang.String toString() {
|
||||||
return "CodegenProperty{" +
|
return "CodegenProperty{" +
|
||||||
"baseName='" + baseName + '\'' +
|
"baseName='" + baseName + '\'' +
|
||||||
|
", openApiType='" + openApiType + '\'' +
|
||||||
", complexType='" + complexType + '\'' +
|
", complexType='" + complexType + '\'' +
|
||||||
", getter='" + getter + '\'' +
|
", getter='" + getter + '\'' +
|
||||||
", setter='" + setter + '\'' +
|
", setter='" + setter + '\'' +
|
||||||
|
|||||||
@@ -111,6 +111,8 @@ public class DefaultCodegen implements CodegenConfig {
|
|||||||
protected String ignoreFilePathOverride;
|
protected String ignoreFilePathOverride;
|
||||||
// flag to indicate whether to use environment variable to post process file
|
// flag to indicate whether to use environment variable to post process file
|
||||||
protected boolean enablePostProcessFile = false;
|
protected boolean enablePostProcessFile = false;
|
||||||
|
// flag to indicate whether to only update files whose contents have changed
|
||||||
|
protected boolean enableMinimalUpdate = false;
|
||||||
|
|
||||||
// make openapi available to all methods
|
// make openapi available to all methods
|
||||||
protected OpenAPI openAPI;
|
protected OpenAPI openAPI;
|
||||||
@@ -778,7 +780,7 @@ public class DefaultCodegen implements CodegenConfig {
|
|||||||
* @return the file name of the model
|
* @return the file name of the model
|
||||||
*/
|
*/
|
||||||
public String toModelFilename(String name) {
|
public String toModelFilename(String name) {
|
||||||
return initialCaps(name);
|
return camelize(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -788,7 +790,7 @@ public class DefaultCodegen implements CodegenConfig {
|
|||||||
* @return the file name of the model
|
* @return the file name of the model
|
||||||
*/
|
*/
|
||||||
public String toModelTestFilename(String name) {
|
public String toModelTestFilename(String name) {
|
||||||
return initialCaps(name) + "Test";
|
return camelize(name) + "Test";
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -798,7 +800,7 @@ public class DefaultCodegen implements CodegenConfig {
|
|||||||
* @return the file name of the model
|
* @return the file name of the model
|
||||||
*/
|
*/
|
||||||
public String toModelDocFilename(String name) {
|
public String toModelDocFilename(String name) {
|
||||||
return initialCaps(name);
|
return camelize(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -1474,17 +1476,6 @@ public class DefaultCodegen implements CodegenConfig {
|
|||||||
return (name.length() > 0) ? (Character.toLowerCase(name.charAt(0)) + name.substring(1)) : "";
|
return (name.length() > 0) ? (Character.toLowerCase(name.charAt(0)) + name.substring(1)) : "";
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Capitalize the string. Please use org.openapitools.codegen.utils.StringUtils.camelize instead as this method will be deprecated.
|
|
||||||
*
|
|
||||||
* @param name string to be capitalized
|
|
||||||
* @return capitalized string
|
|
||||||
* @deprecated use {@link org.openapitools.codegen.utils.StringUtils#camelize(String)} instead
|
|
||||||
*/
|
|
||||||
@SuppressWarnings("static-method")
|
|
||||||
public String initialCaps(String name) {
|
|
||||||
return camelize(name);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Output the type declaration of a given name
|
* Output the type declaration of a given name
|
||||||
@@ -1574,7 +1565,7 @@ public class DefaultCodegen implements CodegenConfig {
|
|||||||
if (name.length() == 0) {
|
if (name.length() == 0) {
|
||||||
return "DefaultApi";
|
return "DefaultApi";
|
||||||
}
|
}
|
||||||
return initialCaps(name) + "Api";
|
return camelize(name) + "Api";
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -1585,7 +1576,7 @@ public class DefaultCodegen implements CodegenConfig {
|
|||||||
* @return capitalized model name
|
* @return capitalized model name
|
||||||
*/
|
*/
|
||||||
public String toModelName(final String name) {
|
public String toModelName(final String name) {
|
||||||
return initialCaps(modelNamePrefix + "_" + name + "_" + modelNameSuffix);
|
return camelize(modelNamePrefix + "_" + name + "_" + modelNameSuffix);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -1898,6 +1889,11 @@ public class DefaultCodegen implements CodegenConfig {
|
|||||||
CodegenProperty property = CodegenModelFactory.newInstance(CodegenModelType.PROPERTY);
|
CodegenProperty property = CodegenModelFactory.newInstance(CodegenModelType.PROPERTY);
|
||||||
property.name = toVarName(name);
|
property.name = toVarName(name);
|
||||||
property.baseName = name;
|
property.baseName = name;
|
||||||
|
if (p.getType() == null) {
|
||||||
|
property.openApiType = getSchemaType(p);
|
||||||
|
} else {
|
||||||
|
property.openApiType = p.getType();
|
||||||
|
}
|
||||||
property.nameInCamelCase = camelize(property.name, false);
|
property.nameInCamelCase = camelize(property.name, false);
|
||||||
property.nameInSnakeCase = CaseFormat.UPPER_CAMEL.to(CaseFormat.UPPER_UNDERSCORE, property.nameInCamelCase);
|
property.nameInSnakeCase = CaseFormat.UPPER_CAMEL.to(CaseFormat.UPPER_UNDERSCORE, property.nameInCamelCase);
|
||||||
property.description = escapeText(p.getDescription());
|
property.description = escapeText(p.getDescription());
|
||||||
@@ -3257,7 +3253,7 @@ public class DefaultCodegen implements CodegenConfig {
|
|||||||
if (builder.toString().length() == 0) {
|
if (builder.toString().length() == 0) {
|
||||||
part = Character.toLowerCase(part.charAt(0)) + part.substring(1);
|
part = Character.toLowerCase(part.charAt(0)) + part.substring(1);
|
||||||
} else {
|
} else {
|
||||||
part = initialCaps(part);
|
part = camelize(part);
|
||||||
}
|
}
|
||||||
builder.append(part);
|
builder.append(part);
|
||||||
}
|
}
|
||||||
@@ -3854,6 +3850,11 @@ public class DefaultCodegen implements CodegenConfig {
|
|||||||
// input name and age => input_name_and_age
|
// input name and age => input_name_and_age
|
||||||
name = name.replaceAll(" ", "_");
|
name = name.replaceAll(" ", "_");
|
||||||
|
|
||||||
|
// /api/films/get => _api_films_get
|
||||||
|
// \api\films\get => _api_films_get
|
||||||
|
name = name.replaceAll("/", "_");
|
||||||
|
name = name.replaceAll("\\\\", "_");
|
||||||
|
|
||||||
// remove everything else other than word, number and _
|
// remove everything else other than word, number and _
|
||||||
// $php_variable => php_variable
|
// $php_variable => php_variable
|
||||||
if (allowUnicodeIdentifiers) { //could be converted to a single line with ?: operator
|
if (allowUnicodeIdentifiers) { //could be converted to a single line with ?: operator
|
||||||
@@ -4834,4 +4835,22 @@ public class DefaultCodegen implements CodegenConfig {
|
|||||||
this.enablePostProcessFile = enablePostProcessFile;
|
this.enablePostProcessFile = enablePostProcessFile;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the boolean value indicating the state of the option for updating only changed files
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public boolean isEnableMinimalUpdate() {
|
||||||
|
return enableMinimalUpdate;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the boolean value indicating the state of the option for updating only changed files
|
||||||
|
*
|
||||||
|
* @param enableMinimalUpdate true to enable minimal update
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void setEnableMinimalUpdate(boolean enableMinimalUpdate) {
|
||||||
|
this.enableMinimalUpdate = enableMinimalUpdate;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -67,6 +67,11 @@ public class DefaultGenerator extends AbstractGenerator implements Generator {
|
|||||||
private String contextPath;
|
private String contextPath;
|
||||||
private Map<String, String> generatorPropertyDefaults = new HashMap<>();
|
private Map<String, String> generatorPropertyDefaults = new HashMap<>();
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean getEnableMinimalUpdate() {
|
||||||
|
return config.isEnableMinimalUpdate();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Generator opts(ClientOptInput opts) {
|
public Generator opts(ClientOptInput opts) {
|
||||||
this.opts = opts;
|
this.opts = opts;
|
||||||
@@ -797,16 +802,13 @@ public class DefaultGenerator extends AbstractGenerator implements Generator {
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected File writeInputStreamToFile(String filename, InputStream in, String templateFile) throws FileNotFoundException, IOException {
|
protected File writeInputStreamToFile(String filename, InputStream in, String templateFile) throws FileNotFoundException, IOException {
|
||||||
File outputFile = java.nio.file.Paths.get(filename).toFile();
|
|
||||||
if (in != null) {
|
if (in != null) {
|
||||||
OutputStream out = new FileOutputStream(outputFile, false);
|
byte bytes[] = IOUtils.toByteArray(in);
|
||||||
LOGGER.info("writing file " + outputFile);
|
return writeToFile(filename, bytes);
|
||||||
IOUtils.copy(in, out);
|
|
||||||
out.close();
|
|
||||||
} else {
|
} else {
|
||||||
LOGGER.error("can't open '" + templateFile + "' for input; cannot write '" + filename + "'");
|
LOGGER.error("can't open '" + templateFile + "' for input; cannot write '" + filename + "'");
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
return outputFile;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private Map<String, Object> buildSupportFileBundle(List<Object> allOperations, List<Object> allModels) {
|
private Map<String, Object> buildSupportFileBundle(List<Object> allOperations, List<Object> allModels) {
|
||||||
|
|||||||
@@ -408,8 +408,8 @@ public class InlineModelResolver {
|
|||||||
|
|
||||||
private String uniqueName(String key) {
|
private String uniqueName(String key) {
|
||||||
if (key == null) {
|
if (key == null) {
|
||||||
key = "NULL_UNIQUE_NAME";
|
key = "InlineObject";
|
||||||
LOGGER.warn("null key found. Default to NULL_UNIQUE_NAME");
|
LOGGER.warn("Found an inline schema without the `title` attribute. Default the model name to InlineObject instead. To have better control of the model naming, define the model separately so that it can be reused throughout the spec.");
|
||||||
}
|
}
|
||||||
int count = 0;
|
int count = 0;
|
||||||
boolean done = false;
|
boolean done = false;
|
||||||
|
|||||||
@@ -101,11 +101,13 @@ public class CodegenConfigurator implements Serializable {
|
|||||||
private boolean logToStderr;
|
private boolean logToStderr;
|
||||||
private boolean validateSpec;
|
private boolean validateSpec;
|
||||||
private boolean enablePostProcessFile;
|
private boolean enablePostProcessFile;
|
||||||
|
private boolean enableMinimalUpdate;
|
||||||
private String templateDir;
|
private String templateDir;
|
||||||
private String auth;
|
private String auth;
|
||||||
private String apiPackage;
|
private String apiPackage;
|
||||||
private String modelPackage;
|
private String modelPackage;
|
||||||
private String invokerPackage;
|
private String invokerPackage;
|
||||||
|
private String packageName;
|
||||||
private String modelNamePrefix;
|
private String modelNamePrefix;
|
||||||
private String modelNameSuffix;
|
private String modelNameSuffix;
|
||||||
private String groupId;
|
private String groupId;
|
||||||
@@ -239,6 +241,15 @@ public class CodegenConfigurator implements Serializable {
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean getEnableMinimalUpdate() {
|
||||||
|
return enableMinimalUpdate;
|
||||||
|
}
|
||||||
|
|
||||||
|
public CodegenConfigurator setEnableMinimalUpdate(boolean enableMinimalUpdate) {
|
||||||
|
this.enableMinimalUpdate = enableMinimalUpdate;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
public boolean isGenerateAliasAsModel() {
|
public boolean isGenerateAliasAsModel() {
|
||||||
return ModelUtils.isGenerateAliasAsModel();
|
return ModelUtils.isGenerateAliasAsModel();
|
||||||
}
|
}
|
||||||
@@ -349,6 +360,15 @@ public class CodegenConfigurator implements Serializable {
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getPackageName() {
|
||||||
|
return packageName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public CodegenConfigurator setPackageName(String packageName) {
|
||||||
|
this.packageName = packageName;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
public String getGroupId() {
|
public String getGroupId() {
|
||||||
return groupId;
|
return groupId;
|
||||||
}
|
}
|
||||||
@@ -545,6 +565,7 @@ public class CodegenConfigurator implements Serializable {
|
|||||||
config.setIgnoreFilePathOverride(ignoreFileOverride);
|
config.setIgnoreFilePathOverride(ignoreFileOverride);
|
||||||
config.setRemoveOperationIdPrefix(removeOperationIdPrefix);
|
config.setRemoveOperationIdPrefix(removeOperationIdPrefix);
|
||||||
config.setEnablePostProcessFile(enablePostProcessFile);
|
config.setEnablePostProcessFile(enablePostProcessFile);
|
||||||
|
config.setEnableMinimalUpdate(enableMinimalUpdate);
|
||||||
|
|
||||||
config.instantiationTypes().putAll(instantiationTypes);
|
config.instantiationTypes().putAll(instantiationTypes);
|
||||||
config.typeMapping().putAll(typeMappings);
|
config.typeMapping().putAll(typeMappings);
|
||||||
@@ -555,6 +576,7 @@ public class CodegenConfigurator implements Serializable {
|
|||||||
checkAndSetAdditionalProperty(apiPackage, CodegenConstants.API_PACKAGE);
|
checkAndSetAdditionalProperty(apiPackage, CodegenConstants.API_PACKAGE);
|
||||||
checkAndSetAdditionalProperty(modelPackage, CodegenConstants.MODEL_PACKAGE);
|
checkAndSetAdditionalProperty(modelPackage, CodegenConstants.MODEL_PACKAGE);
|
||||||
checkAndSetAdditionalProperty(invokerPackage, CodegenConstants.INVOKER_PACKAGE);
|
checkAndSetAdditionalProperty(invokerPackage, CodegenConstants.INVOKER_PACKAGE);
|
||||||
|
checkAndSetAdditionalProperty(packageName, CodegenConstants.PACKAGE_NAME);
|
||||||
checkAndSetAdditionalProperty(groupId, CodegenConstants.GROUP_ID);
|
checkAndSetAdditionalProperty(groupId, CodegenConstants.GROUP_ID);
|
||||||
checkAndSetAdditionalProperty(artifactId, CodegenConstants.ARTIFACT_ID);
|
checkAndSetAdditionalProperty(artifactId, CodegenConstants.ARTIFACT_ID);
|
||||||
checkAndSetAdditionalProperty(artifactVersion, CodegenConstants.ARTIFACT_VERSION);
|
checkAndSetAdditionalProperty(artifactVersion, CodegenConstants.ARTIFACT_VERSION);
|
||||||
|
|||||||
@@ -232,16 +232,8 @@ public class ExampleGenerator {
|
|||||||
Schema innerType = ((ArraySchema) property).getItems();
|
Schema innerType = ((ArraySchema) property).getItems();
|
||||||
if (innerType != null) {
|
if (innerType != null) {
|
||||||
int arrayLength = null == ((ArraySchema) property).getMaxItems() ? 2 : ((ArraySchema) property).getMaxItems();
|
int arrayLength = null == ((ArraySchema) property).getMaxItems() ? 2 : ((ArraySchema) property).getMaxItems();
|
||||||
if (arrayLength == Integer.MAX_VALUE) {
|
// avoid memory issues by limiting to max. 5 items
|
||||||
// swagger-jersey2-jaxrs generated spec may contain maxItem = 2147483647
|
arrayLength = Math.min(arrayLength, 5);
|
||||||
// semantically this means there is no upper limit
|
|
||||||
// treating this as if the property was not present at all
|
|
||||||
LOGGER.warn("The max items allowed in property {} of {} equals Integer.MAX_VALUE. Treating this as if no max items has been specified.", property, arrayLength);
|
|
||||||
arrayLength = 2;
|
|
||||||
} else if (arrayLength > 1024) {
|
|
||||||
LOGGER.warn("The max items allowed in property {} is too large ({} items), restricting it to 1024 items", property, arrayLength);
|
|
||||||
arrayLength = 1024;
|
|
||||||
}
|
|
||||||
Object[] objectProperties = new Object[arrayLength];
|
Object[] objectProperties = new Object[arrayLength];
|
||||||
Object objProperty = resolvePropertyToExample(propertyName, mediaType, innerType, processedModels);
|
Object objProperty = resolvePropertyToExample(propertyName, mediaType, innerType, processedModels);
|
||||||
for (int i = 0; i < arrayLength; i++) {
|
for (int i = 0; i < arrayLength; i++) {
|
||||||
|
|||||||
@@ -39,7 +39,6 @@ public abstract class AbstractCSharpCodegen extends DefaultCodegen implements Co
|
|||||||
|
|
||||||
protected boolean optionalAssemblyInfoFlag = true;
|
protected boolean optionalAssemblyInfoFlag = true;
|
||||||
protected boolean optionalProjectFileFlag = true;
|
protected boolean optionalProjectFileFlag = true;
|
||||||
protected boolean optionalEmitDefaultValue = false;
|
|
||||||
protected boolean optionalMethodArgumentFlag = true;
|
protected boolean optionalMethodArgumentFlag = true;
|
||||||
protected boolean useDateTimeOffsetFlag = false;
|
protected boolean useDateTimeOffsetFlag = false;
|
||||||
protected boolean useCollection = false;
|
protected boolean useCollection = false;
|
||||||
@@ -197,10 +196,6 @@ public abstract class AbstractCSharpCodegen extends DefaultCodegen implements Co
|
|||||||
this.returnICollection = returnICollection;
|
this.returnICollection = returnICollection;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setOptionalEmitDefaultValue(boolean optionalEmitDefaultValue) {
|
|
||||||
this.optionalEmitDefaultValue = optionalEmitDefaultValue;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setUseCollection(boolean useCollection) {
|
public void setUseCollection(boolean useCollection) {
|
||||||
this.useCollection = useCollection;
|
this.useCollection = useCollection;
|
||||||
if (useCollection) {
|
if (useCollection) {
|
||||||
@@ -339,12 +334,6 @@ public abstract class AbstractCSharpCodegen extends DefaultCodegen implements Co
|
|||||||
additionalProperties.put(CodegenConstants.RETURN_ICOLLECTION, returnICollection);
|
additionalProperties.put(CodegenConstants.RETURN_ICOLLECTION, returnICollection);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (additionalProperties.containsKey(CodegenConstants.OPTIONAL_EMIT_DEFAULT_VALUES)) {
|
|
||||||
setOptionalEmitDefaultValue(convertPropertyToBooleanAndWriteBack(CodegenConstants.OPTIONAL_EMIT_DEFAULT_VALUES));
|
|
||||||
} else {
|
|
||||||
additionalProperties.put(CodegenConstants.OPTIONAL_EMIT_DEFAULT_VALUES, optionalEmitDefaultValue);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (additionalProperties.containsKey(CodegenConstants.NETCORE_PROJECT_FILE)) {
|
if (additionalProperties.containsKey(CodegenConstants.NETCORE_PROJECT_FILE)) {
|
||||||
setNetCoreProjectFileFlag(convertPropertyToBooleanAndWriteBack(CodegenConstants.NETCORE_PROJECT_FILE));
|
setNetCoreProjectFileFlag(convertPropertyToBooleanAndWriteBack(CodegenConstants.NETCORE_PROJECT_FILE));
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -112,7 +112,8 @@ public abstract class AbstractGoCodegen extends DefaultCodegen implements Codege
|
|||||||
cliOptions.clear();
|
cliOptions.clear();
|
||||||
cliOptions.add(new CliOption(CodegenConstants.PACKAGE_NAME, "Go package name (convention: lowercase).")
|
cliOptions.add(new CliOption(CodegenConstants.PACKAGE_NAME, "Go package name (convention: lowercase).")
|
||||||
.defaultValue("openapi"));
|
.defaultValue("openapi"));
|
||||||
|
cliOptions.add(new CliOption(CodegenConstants.PACKAGE_VERSION, "Go package version.")
|
||||||
|
.defaultValue("1.0.0"));
|
||||||
cliOptions.add(new CliOption(CodegenConstants.HIDE_GENERATION_TIMESTAMP, CodegenConstants.HIDE_GENERATION_TIMESTAMP_DESC)
|
cliOptions.add(new CliOption(CodegenConstants.HIDE_GENERATION_TIMESTAMP, CodegenConstants.HIDE_GENERATION_TIMESTAMP_DESC)
|
||||||
.defaultValue(Boolean.TRUE.toString()));
|
.defaultValue(Boolean.TRUE.toString()));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -360,7 +360,7 @@ public abstract class AbstractKotlinCodegen extends DefaultCodegen implements Co
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (additionalProperties.containsKey(CodegenConstants.PARCELIZE_MODELS)) {
|
if (additionalProperties.containsKey(CodegenConstants.PARCELIZE_MODELS)) {
|
||||||
this.setParcelizeModels(Boolean.valueOf((String)additionalProperties.get(CodegenConstants.PARCELIZE_MODELS)));
|
this.setParcelizeModels(Boolean.valueOf((String) additionalProperties.get(CodegenConstants.PARCELIZE_MODELS)));
|
||||||
LOGGER.info(CodegenConstants.PARCELIZE_MODELS + " depends on the android framework and " +
|
LOGGER.info(CodegenConstants.PARCELIZE_MODELS + " depends on the android framework and " +
|
||||||
"experimental parcelize feature. Make sure your build applies the android plugin:\n" +
|
"experimental parcelize feature. Make sure your build applies the android plugin:\n" +
|
||||||
"apply plugin: 'com.android.library' OR apply plugin: 'com.android.application'.\n" +
|
"apply plugin: 'com.android.library' OR apply plugin: 'com.android.application'.\n" +
|
||||||
@@ -597,10 +597,7 @@ public abstract class AbstractKotlinCodegen extends DefaultCodegen implements Co
|
|||||||
private String sanitizeKotlinSpecificNames(final String name) {
|
private String sanitizeKotlinSpecificNames(final String name) {
|
||||||
String word = name;
|
String word = name;
|
||||||
for (Map.Entry<String, String> specialCharacters : specialCharReplacements.entrySet()) {
|
for (Map.Entry<String, String> specialCharacters : specialCharReplacements.entrySet()) {
|
||||||
// Underscore is the only special character we'll allow
|
word = replaceSpecialCharacters(word, specialCharacters);
|
||||||
if (!specialCharacters.getKey().equals("_")) {
|
|
||||||
word = word.replaceAll("\\Q" + specialCharacters.getKey() + "\\E", specialCharacters.getValue());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Fallback, replace unknowns with underscore.
|
// Fallback, replace unknowns with underscore.
|
||||||
@@ -617,6 +614,38 @@ public abstract class AbstractKotlinCodegen extends DefaultCodegen implements Co
|
|||||||
return word;
|
return word;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private String replaceSpecialCharacters(String word, Map.Entry<String, String> specialCharacters) {
|
||||||
|
String specialChar = specialCharacters.getKey();
|
||||||
|
String replacementChar = specialCharacters.getValue();
|
||||||
|
// Underscore is the only special character we'll allow
|
||||||
|
if (!specialChar.equals("_") && word.contains(specialChar)) {
|
||||||
|
return replaceCharacters(word, specialChar, replacementChar);
|
||||||
|
}
|
||||||
|
return word;
|
||||||
|
}
|
||||||
|
|
||||||
|
private String replaceCharacters(String word, String oldValue, String newValue) {
|
||||||
|
if (!word.contains(oldValue)) {
|
||||||
|
return word;
|
||||||
|
}
|
||||||
|
if (word.equals(oldValue)) {
|
||||||
|
return newValue;
|
||||||
|
}
|
||||||
|
int i = word.indexOf(oldValue);
|
||||||
|
String start = word.substring(0, i);
|
||||||
|
String end = recurseOnEndOfWord(word, oldValue, newValue, i);
|
||||||
|
return start + newValue + end;
|
||||||
|
}
|
||||||
|
|
||||||
|
private String recurseOnEndOfWord(String word, String oldValue, String newValue, int lastReplacedValue) {
|
||||||
|
String end = word.substring(lastReplacedValue + 1);
|
||||||
|
if (!end.isEmpty()) {
|
||||||
|
end = titleCase(end);
|
||||||
|
end = replaceCharacters(end, oldValue, newValue);
|
||||||
|
}
|
||||||
|
return end;
|
||||||
|
}
|
||||||
|
|
||||||
private String titleCase(final String input) {
|
private String titleCase(final String input) {
|
||||||
return input.substring(0, 1).toUpperCase(Locale.ROOT) + input.substring(1);
|
return input.substring(0, 1).toUpperCase(Locale.ROOT) + input.substring(1);
|
||||||
}
|
}
|
||||||
@@ -676,6 +705,7 @@ public abstract class AbstractKotlinCodegen extends DefaultCodegen implements Co
|
|||||||
@Override
|
@Override
|
||||||
public String toVarName(String name) {
|
public String toVarName(String name) {
|
||||||
// sanitize name
|
// sanitize name
|
||||||
|
name = sanitizeKotlinSpecificNames(name);
|
||||||
name = sanitizeName(name, "\\W-[\\$]");
|
name = sanitizeName(name, "\\W-[\\$]");
|
||||||
|
|
||||||
if (name.toLowerCase(Locale.ROOT).matches("^_*class$")) {
|
if (name.toLowerCase(Locale.ROOT).matches("^_*class$")) {
|
||||||
@@ -756,4 +786,31 @@ public abstract class AbstractKotlinCodegen extends DefaultCodegen implements Co
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toDefaultValue(Schema p) {
|
||||||
|
if (ModelUtils.isBooleanSchema(p)) {
|
||||||
|
if (p.getDefault() != null) {
|
||||||
|
return p.getDefault().toString();
|
||||||
|
}
|
||||||
|
} else if (ModelUtils.isDateSchema(p)) {
|
||||||
|
// TODO
|
||||||
|
} else if (ModelUtils.isDateTimeSchema(p)) {
|
||||||
|
// TODO
|
||||||
|
} else if (ModelUtils.isNumberSchema(p)) {
|
||||||
|
if (p.getDefault() != null) {
|
||||||
|
return p.getDefault().toString();
|
||||||
|
}
|
||||||
|
} else if (ModelUtils.isIntegerSchema(p)) {
|
||||||
|
if (p.getDefault() != null) {
|
||||||
|
return p.getDefault().toString();
|
||||||
|
}
|
||||||
|
} else if (ModelUtils.isStringSchema(p)) {
|
||||||
|
if (p.getDefault() != null) {
|
||||||
|
return "'" + p.getDefault() + "'";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -333,4 +333,29 @@ public abstract class AbstractScalaCodegen extends DefaultCodegen {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toOperationId(String operationId) {
|
||||||
|
// throw exception if method name is empty
|
||||||
|
if (StringUtils.isEmpty(operationId)) {
|
||||||
|
throw new RuntimeException("Empty method/operation name (operationId) not allowed");
|
||||||
|
}
|
||||||
|
|
||||||
|
operationId = camelize(sanitizeName(operationId), true);
|
||||||
|
|
||||||
|
// method name cannot use reserved keyword, e.g. return
|
||||||
|
if (isReservedWord(operationId)) {
|
||||||
|
String newOperationId = camelize("call_" + operationId, true);
|
||||||
|
LOGGER.warn(operationId + " (reserved word) cannot be used as method name. Renamed to " + newOperationId);
|
||||||
|
return newOperationId;
|
||||||
|
}
|
||||||
|
|
||||||
|
// operationId starts with a number
|
||||||
|
if (operationId.matches("^\\d.*")) {
|
||||||
|
LOGGER.warn(operationId + " (starting with a number) cannot be used as method sname. Renamed to " + camelize("call_" + operationId), true);
|
||||||
|
operationId = camelize("call_" + operationId, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
return operationId;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,10 +19,8 @@ package org.openapitools.codegen.languages;
|
|||||||
|
|
||||||
import com.samskivert.mustache.Mustache;
|
import com.samskivert.mustache.Mustache;
|
||||||
import io.swagger.v3.oas.models.OpenAPI;
|
import io.swagger.v3.oas.models.OpenAPI;
|
||||||
import org.openapitools.codegen.CodegenConstants;
|
import io.swagger.v3.oas.models.media.Schema;
|
||||||
import org.openapitools.codegen.CodegenOperation;
|
import org.openapitools.codegen.*;
|
||||||
import org.openapitools.codegen.CodegenType;
|
|
||||||
import org.openapitools.codegen.SupportingFile;
|
|
||||||
import org.openapitools.codegen.utils.URLPathUtils;
|
import org.openapitools.codegen.utils.URLPathUtils;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
@@ -47,6 +45,7 @@ public class AspNetCoreServerCodegen extends AbstractCSharpCodegen {
|
|||||||
public static final String PROJECT_SDK = "projectSdk";
|
public static final String PROJECT_SDK = "projectSdk";
|
||||||
public static final String SDK_WEB = "Microsoft.NET.Sdk.Web";
|
public static final String SDK_WEB = "Microsoft.NET.Sdk.Web";
|
||||||
public static final String SDK_LIB = "Microsoft.NET.Sdk";
|
public static final String SDK_LIB = "Microsoft.NET.Sdk";
|
||||||
|
public static final String COMPATIBILITY_VERSION = "compatibilityVersion";
|
||||||
|
|
||||||
private String packageGuid = "{" + randomUUID().toString().toUpperCase(Locale.ROOT) + "}";
|
private String packageGuid = "{" + randomUUID().toString().toUpperCase(Locale.ROOT) + "}";
|
||||||
|
|
||||||
@@ -56,13 +55,13 @@ public class AspNetCoreServerCodegen extends AbstractCSharpCodegen {
|
|||||||
private boolean useSwashbuckle = true;
|
private boolean useSwashbuckle = true;
|
||||||
protected int serverPort = 8080;
|
protected int serverPort = 8080;
|
||||||
protected String serverHost = "0.0.0.0";
|
protected String serverHost = "0.0.0.0";
|
||||||
protected String aspnetCoreVersion= "2.1"; // default to 2.1
|
private CliOption aspnetCoreVersion = new CliOption(ASPNET_CORE_VERSION, "ASP.NET Core version: 2.2 (default), 2.1, 2.0 (deprecated)");
|
||||||
// TODO Make next two enums toensure fixed list.
|
private CliOption classModifier = new CliOption(CLASS_MODIFIER, "Class Modifier can be empty, abstract");
|
||||||
private String classModifier = "";
|
private CliOption operationModifier = new CliOption(OPERATION_MODIFIER, "Operation Modifier can be virtual, abstract or partial");
|
||||||
private String operationModifier = "virtual";
|
|
||||||
private boolean generateBody = true;
|
private boolean generateBody = true;
|
||||||
private String buildTarget = "program";
|
private CliOption buildTarget = new CliOption("buildTarget", "Target to build an application or library");
|
||||||
private String projectSdk = SDK_WEB;
|
private String projectSdk = SDK_WEB;
|
||||||
|
private String compatibilityVersion = "Version_2_1";
|
||||||
|
|
||||||
public AspNetCoreServerCodegen() {
|
public AspNetCoreServerCodegen() {
|
||||||
super();
|
super();
|
||||||
@@ -82,6 +81,18 @@ public class AspNetCoreServerCodegen extends AbstractCSharpCodegen {
|
|||||||
|
|
||||||
cliOptions.clear();
|
cliOptions.clear();
|
||||||
|
|
||||||
|
typeMapping.put("boolean", "bool");
|
||||||
|
typeMapping.put("integer", "int");
|
||||||
|
typeMapping.put("float", "float");
|
||||||
|
typeMapping.put("long", "long");
|
||||||
|
typeMapping.put("double", "double");
|
||||||
|
typeMapping.put("number", "decimal");
|
||||||
|
typeMapping.put("DateTime", "DateTime");
|
||||||
|
typeMapping.put("date", "DateTime");
|
||||||
|
typeMapping.put("UUID", "Guid");
|
||||||
|
|
||||||
|
setSupportNullable(Boolean.TRUE);
|
||||||
|
|
||||||
// CLI options
|
// CLI options
|
||||||
addOption(CodegenConstants.LICENSE_URL,
|
addOption(CodegenConstants.LICENSE_URL,
|
||||||
CodegenConstants.LICENSE_URL_DESC,
|
CodegenConstants.LICENSE_URL_DESC,
|
||||||
@@ -119,9 +130,14 @@ public class AspNetCoreServerCodegen extends AbstractCSharpCodegen {
|
|||||||
CodegenConstants.SOURCE_FOLDER_DESC,
|
CodegenConstants.SOURCE_FOLDER_DESC,
|
||||||
sourceFolder);
|
sourceFolder);
|
||||||
|
|
||||||
addOption(ASPNET_CORE_VERSION,
|
addOption(COMPATIBILITY_VERSION, "ASP.Net Core CompatibilityVersion", compatibilityVersion);
|
||||||
"ASP.NET Core version: 2.1 (default), 2.0 (deprecated)",
|
|
||||||
aspnetCoreVersion);
|
aspnetCoreVersion.addEnum("2.0", "ASP.NET COre V2.0");
|
||||||
|
aspnetCoreVersion.addEnum("2.1", "ASP.NET COre V2.1");
|
||||||
|
aspnetCoreVersion.addEnum("2.2", "ASP.NET COre V2.2");
|
||||||
|
aspnetCoreVersion.setDefault("2.2");
|
||||||
|
aspnetCoreVersion.setOptValue(aspnetCoreVersion.getDefault());
|
||||||
|
addOption(aspnetCoreVersion.getOpt(), aspnetCoreVersion.getDescription(), aspnetCoreVersion.getOptValue());
|
||||||
|
|
||||||
// CLI Switches
|
// CLI Switches
|
||||||
addSwitch(CodegenConstants.SORT_PARAMS_BY_REQUIRED_FLAG,
|
addSwitch(CodegenConstants.SORT_PARAMS_BY_REQUIRED_FLAG,
|
||||||
@@ -144,22 +160,28 @@ public class AspNetCoreServerCodegen extends AbstractCSharpCodegen {
|
|||||||
"Uses the Swashbuckle.AspNetCore NuGet package for documentation.",
|
"Uses the Swashbuckle.AspNetCore NuGet package for documentation.",
|
||||||
useSwashbuckle);
|
useSwashbuckle);
|
||||||
|
|
||||||
addOption(CLASS_MODIFIER,
|
classModifier.addEnum("", "Keep class default with no modifier");
|
||||||
"Class modifiers such as abstract or partial",
|
classModifier.addEnum("abstract", "Make class abstract");
|
||||||
classModifier);
|
classModifier.setDefault("");
|
||||||
|
classModifier.setOptValue(classModifier.getDefault());
|
||||||
|
addOption(classModifier.getOpt(), classModifier.getDescription(), classModifier.getOptValue());
|
||||||
|
|
||||||
addOption(OPERATION_MODIFIER,
|
operationModifier.addEnum("virtual", "Keep method virtual ");
|
||||||
"Operation modifiers such as virtual or abstract.",
|
operationModifier.addEnum("abstract", "Make method abstract");
|
||||||
operationModifier);
|
operationModifier.setDefault("virtual");
|
||||||
|
operationModifier.setOptValue(operationModifier.getDefault());
|
||||||
|
addOption(operationModifier.getOpt(), operationModifier.getDescription(), operationModifier.getOptValue());
|
||||||
|
|
||||||
|
buildTarget.addEnum("program", "Generate code for standalone server");
|
||||||
|
buildTarget.addEnum("library", "Generate code for a server abstract class lbrary");
|
||||||
|
buildTarget.setDefault("program");
|
||||||
|
buildTarget.setOptValue(buildTarget.getDefault());
|
||||||
|
addOption(buildTarget.getOpt(), buildTarget.getDescription(), buildTarget.getOptValue());
|
||||||
|
|
||||||
addSwitch(GENERATE_BODY,
|
addSwitch(GENERATE_BODY,
|
||||||
"Generates method body.",
|
"Generates method body.",
|
||||||
generateBody);
|
generateBody);
|
||||||
|
|
||||||
addOption(BUILD_TARGET,
|
|
||||||
"Target the build for a program or library.",
|
|
||||||
buildTarget);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -201,53 +223,15 @@ public class AspNetCoreServerCodegen extends AbstractCSharpCodegen {
|
|||||||
additionalProperties.put(USE_SWASHBUCKLE, useSwashbuckle);
|
additionalProperties.put(USE_SWASHBUCKLE, useSwashbuckle);
|
||||||
}
|
}
|
||||||
|
|
||||||
// determine the ASP.NET core version setting
|
|
||||||
if (additionalProperties.containsKey(ASPNET_CORE_VERSION)) {
|
// CHeck for the modifiers etc.
|
||||||
setAspnetCoreVersion((String) additionalProperties.get(ASPNET_CORE_VERSION));
|
// The order of the checks is important.
|
||||||
}
|
isLibrary = setBuildTarget();
|
||||||
|
setClassModifier();
|
||||||
|
setOperationModifier();
|
||||||
|
|
||||||
|
|
||||||
// CHeck for class modifier if not present set the default value.
|
// CHeck for class modifier if not present set the default value.
|
||||||
if (additionalProperties.containsKey(CLASS_MODIFIER)) {
|
|
||||||
classModifier = additionalProperties.get(CLASS_MODIFIER).toString();
|
|
||||||
} else {
|
|
||||||
additionalProperties.put(CLASS_MODIFIER, classModifier);
|
|
||||||
}
|
|
||||||
|
|
||||||
// TODO Validate modifier values
|
|
||||||
// If class modifierier is abstract then the methods need to be abstrat too.
|
|
||||||
if ("abstract".equals(classModifier)) {
|
|
||||||
operationModifier = classModifier;
|
|
||||||
additionalProperties.put(OPERATION_MODIFIER, operationModifier);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (additionalProperties.containsKey(OPERATION_MODIFIER)) {
|
|
||||||
operationModifier = additionalProperties.get(OPERATION_MODIFIER).toString();
|
|
||||||
} else {
|
|
||||||
additionalProperties.put(OPERATION_MODIFIER, operationModifier);
|
|
||||||
}
|
|
||||||
|
|
||||||
// TODO Validate modifier values
|
|
||||||
// If operation modifier is abstract then dont generate any body
|
|
||||||
if ("abstract".equals(operationModifier)) {
|
|
||||||
generateBody = false;
|
|
||||||
additionalProperties.put(GENERATE_BODY, generateBody);
|
|
||||||
}
|
|
||||||
if (additionalProperties.containsKey(GENERATE_BODY)) {
|
|
||||||
generateBody = convertPropertyToBooleanAndWriteBack(GENERATE_BODY);
|
|
||||||
} else {
|
|
||||||
additionalProperties.put(GENERATE_BODY, generateBody);
|
|
||||||
}
|
|
||||||
|
|
||||||
// CHeck for class modifier if not present set the default value.
|
|
||||||
if (additionalProperties.containsKey(BUILD_TARGET)) {
|
|
||||||
buildTarget = additionalProperties.get(BUILD_TARGET).toString();
|
|
||||||
} else {
|
|
||||||
additionalProperties.put(BUILD_TARGET, buildTarget);
|
|
||||||
}
|
|
||||||
if ("library".equals(buildTarget)) {
|
|
||||||
isLibrary = true;
|
|
||||||
projectSdk = SDK_LIB;
|
|
||||||
}
|
|
||||||
additionalProperties.put(PROJECT_SDK, projectSdk);
|
additionalProperties.put(PROJECT_SDK, projectSdk);
|
||||||
|
|
||||||
additionalProperties.put("dockerTag", packageName.toLowerCase(Locale.ROOT));
|
additionalProperties.put("dockerTag", packageName.toLowerCase(Locale.ROOT));
|
||||||
@@ -257,17 +241,8 @@ public class AspNetCoreServerCodegen extends AbstractCSharpCodegen {
|
|||||||
|
|
||||||
String packageFolder = sourceFolder + File.separator + packageName;
|
String packageFolder = sourceFolder + File.separator + packageName;
|
||||||
|
|
||||||
if ("2.0".equals(aspnetCoreVersion)) {
|
// determine the ASP.NET core version setting
|
||||||
embeddedTemplateDir = templateDir = "aspnetcore/2.0";
|
setAspnetCoreVersion(packageFolder);
|
||||||
supportingFiles.add(new SupportingFile("web.config", packageFolder, "web.config"));
|
|
||||||
LOGGER.info("ASP.NET core version: 2.0");
|
|
||||||
} else if ("2.1".equals(aspnetCoreVersion)) {
|
|
||||||
// default, do nothing
|
|
||||||
LOGGER.info("ASP.NET core version: 2.1");
|
|
||||||
} else {
|
|
||||||
throw new IllegalArgumentException("aspnetCoreVersion must be '2.1', '2.0' but found " + aspnetCoreVersion);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
supportingFiles.add(new SupportingFile("build.sh.mustache", "", "build.sh"));
|
supportingFiles.add(new SupportingFile("build.sh.mustache", "", "build.sh"));
|
||||||
supportingFiles.add(new SupportingFile("build.bat.mustache", "", "build.bat"));
|
supportingFiles.add(new SupportingFile("build.bat.mustache", "", "build.bat"));
|
||||||
@@ -294,26 +269,6 @@ public class AspNetCoreServerCodegen extends AbstractCSharpCodegen {
|
|||||||
supportingFiles.add(new SupportingFile("wwwroot" + File.separator + "openapi-original.mustache",
|
supportingFiles.add(new SupportingFile("wwwroot" + File.separator + "openapi-original.mustache",
|
||||||
packageFolder + File.separator + "wwwroot", "openapi-original.json"));
|
packageFolder + File.separator + "wwwroot", "openapi-original.json"));
|
||||||
}
|
}
|
||||||
supportingFiles.add(new SupportingFile("validateModel.mustache", packageFolder + File.separator + "Attributes", "ValidateModelStateAttribute.cs"));
|
|
||||||
supportingFiles.add(new SupportingFile("Project.csproj.mustache", packageFolder, packageName + ".csproj"));
|
|
||||||
if (!isLibrary) {
|
|
||||||
supportingFiles.add(new SupportingFile("Dockerfile.mustache", packageFolder, "Dockerfile"));
|
|
||||||
supportingFiles.add(new SupportingFile("appsettings.json", packageFolder, "appsettings.json"));
|
|
||||||
|
|
||||||
supportingFiles.add(new SupportingFile("Startup.mustache", packageFolder, "Startup.cs"));
|
|
||||||
supportingFiles.add(new SupportingFile("Program.mustache", packageFolder, "Program.cs"));
|
|
||||||
supportingFiles.add(new SupportingFile("Properties" + File.separator + "launchSettings.json",
|
|
||||||
packageFolder + File.separator + "Properties", "launchSettings.json"));
|
|
||||||
} else {
|
|
||||||
supportingFiles.add(new SupportingFile("Project.nuspec.mustache", packageFolder, packageName + ".nuspec"));
|
|
||||||
// wwwroot files.
|
|
||||||
supportingFiles.add(new SupportingFile("wwwroot" + File.separator + "README.md", packageFolder + File.separator + "wwwroot", "README.md"));
|
|
||||||
supportingFiles.add(new SupportingFile("wwwroot" + File.separator + "index.html", packageFolder + File.separator + "wwwroot", "index.html"));
|
|
||||||
supportingFiles.add(new SupportingFile("wwwroot" + File.separator + "web.config", packageFolder + File.separator + "wwwroot", "web.config"));
|
|
||||||
|
|
||||||
supportingFiles.add(new SupportingFile("wwwroot" + File.separator + "openapi-original.mustache",
|
|
||||||
packageFolder + File.separator + "wwwroot", "openapi-original.json"));
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
if (useSwashbuckle) {
|
if (useSwashbuckle) {
|
||||||
@@ -328,10 +283,6 @@ public class AspNetCoreServerCodegen extends AbstractCSharpCodegen {
|
|||||||
this.packageGuid = packageGuid;
|
this.packageGuid = packageGuid;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setAspnetCoreVersion(String aspnetCoreVersion) {
|
|
||||||
this.aspnetCoreVersion= aspnetCoreVersion;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String apiFileFolder() {
|
public String apiFileFolder() {
|
||||||
return outputFolder + File.separator + sourceFolder + File.separator + packageName + File.separator + "Controllers";
|
return outputFolder + File.separator + sourceFolder + File.separator + packageName + File.separator + "Controllers";
|
||||||
@@ -375,4 +326,85 @@ public class AspNetCoreServerCodegen extends AbstractCSharpCodegen {
|
|||||||
public String toRegularExpression(String pattern) {
|
public String toRegularExpression(String pattern) {
|
||||||
return escapeText(pattern);
|
return escapeText(pattern);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getNullableType(Schema p, String type) {
|
||||||
|
boolean isNullableExpected = p.getNullable() == null || (p.getNullable() != null && p.getNullable());
|
||||||
|
|
||||||
|
if (isNullableExpected && languageSpecificPrimitives.contains(type + "?")) {
|
||||||
|
return type + "?";
|
||||||
|
} else if (languageSpecificPrimitives.contains(type)) {
|
||||||
|
return type;
|
||||||
|
} else {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void setCliOption(CliOption cliOption) throws IllegalArgumentException {
|
||||||
|
if (additionalProperties.containsKey(cliOption.getOpt())) {
|
||||||
|
cliOption.setOptValue(additionalProperties.get(cliOption.getOpt()).toString());
|
||||||
|
if (cliOption.getOptValue() == null) {
|
||||||
|
cliOption.setOptValue(cliOption.getDefault());
|
||||||
|
throw new IllegalArgumentException(cliOption.getOpt() + ": Invalid value '" + additionalProperties.get(cliOption.getOpt()).toString() + "'" +
|
||||||
|
". " + cliOption.getDescription());
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
additionalProperties.put(cliOption.getOpt(), cliOption.getOptValue());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void setClassModifier() {
|
||||||
|
// CHeck for class modifier if not present set the default value.
|
||||||
|
setCliOption(classModifier);
|
||||||
|
|
||||||
|
// If class modifier is abstract then the methods need to be abstract too.
|
||||||
|
if ("abstract".equals(classModifier.getOptValue())) {
|
||||||
|
operationModifier.setOptValue(classModifier.getOptValue());
|
||||||
|
additionalProperties.put(OPERATION_MODIFIER, operationModifier.getOptValue());
|
||||||
|
LOGGER.warn("classModifier is " + classModifier.getOptValue() + " so forcing operatonModifier to " + operationModifier.getOptValue());
|
||||||
|
} else {
|
||||||
|
setCliOption(operationModifier);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void setOperationModifier() {
|
||||||
|
setCliOption(operationModifier);
|
||||||
|
|
||||||
|
// If operation modifier is abstract then dont generate any body
|
||||||
|
if ("abstract".equals(operationModifier.getOptValue())) {
|
||||||
|
generateBody = false;
|
||||||
|
additionalProperties.put(GENERATE_BODY, generateBody);
|
||||||
|
LOGGER.warn("operationModifier is " + operationModifier.getOptValue() + " so forcing generateBody to " + generateBody);
|
||||||
|
} else if (additionalProperties.containsKey(GENERATE_BODY)) {
|
||||||
|
generateBody = convertPropertyToBooleanAndWriteBack(GENERATE_BODY);
|
||||||
|
} else {
|
||||||
|
additionalProperties.put(GENERATE_BODY, generateBody);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean setBuildTarget() {
|
||||||
|
boolean isLibrary = false;
|
||||||
|
setCliOption(buildTarget);
|
||||||
|
if ("library".equals(buildTarget.getOptValue())) {
|
||||||
|
isLibrary = true;
|
||||||
|
projectSdk = SDK_LIB;
|
||||||
|
additionalProperties.put(CLASS_MODIFIER, "abstract");
|
||||||
|
}
|
||||||
|
return isLibrary;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void setAspnetCoreVersion(String packageFolder) {
|
||||||
|
setCliOption(aspnetCoreVersion);
|
||||||
|
if ("2.0".equals(aspnetCoreVersion.getOptValue())) {
|
||||||
|
embeddedTemplateDir = templateDir = "aspnetcore/2.0";
|
||||||
|
supportingFiles.add(new SupportingFile("web.config", packageFolder, "web.config"));
|
||||||
|
LOGGER.info("ASP.NET core version: 2.0");
|
||||||
|
compatibilityVersion = null;
|
||||||
|
} else {
|
||||||
|
// default, do nothing
|
||||||
|
LOGGER.info("ASP.NET core version: " + aspnetCoreVersion.getOptValue());
|
||||||
|
compatibilityVersion = "Version_" + aspnetCoreVersion.getOptValue().replace(".", "_");
|
||||||
|
}
|
||||||
|
additionalProperties.put(COMPATIBILITY_VERSION, compatibilityVersion);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -35,6 +35,8 @@ import org.slf4j.LoggerFactory;
|
|||||||
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
||||||
|
import static org.openapitools.codegen.utils.StringUtils.*;
|
||||||
|
|
||||||
public class BashClientCodegen extends DefaultCodegen implements CodegenConfig {
|
public class BashClientCodegen extends DefaultCodegen implements CodegenConfig {
|
||||||
private static final Logger LOGGER = LoggerFactory.getLogger(BashClientCodegen.class);
|
private static final Logger LOGGER = LoggerFactory.getLogger(BashClientCodegen.class);
|
||||||
|
|
||||||
@@ -743,7 +745,7 @@ public class BashClientCodegen extends DefaultCodegen implements CodegenConfig {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toModelFilename(String name) {
|
public String toModelFilename(String name) {
|
||||||
return initialCaps(name);
|
return camelize(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -86,6 +86,18 @@ public class CSharpClientCodegen extends AbstractCSharpCodegen {
|
|||||||
|
|
||||||
cliOptions.clear();
|
cliOptions.clear();
|
||||||
|
|
||||||
|
typeMapping.put("boolean", "bool");
|
||||||
|
typeMapping.put("integer", "int");
|
||||||
|
typeMapping.put("float", "float");
|
||||||
|
typeMapping.put("long", "long");
|
||||||
|
typeMapping.put("double", "double");
|
||||||
|
typeMapping.put("number", "decimal");
|
||||||
|
typeMapping.put("DateTime", "DateTime");
|
||||||
|
typeMapping.put("date", "DateTime");
|
||||||
|
typeMapping.put("UUID", "Guid");
|
||||||
|
|
||||||
|
setSupportNullable(Boolean.TRUE);
|
||||||
|
|
||||||
// CLI options
|
// CLI options
|
||||||
addOption(CodegenConstants.PACKAGE_NAME,
|
addOption(CodegenConstants.PACKAGE_NAME,
|
||||||
"C# package name (convention: Title.Case).",
|
"C# package name (convention: Title.Case).",
|
||||||
@@ -158,10 +170,6 @@ public class CSharpClientCodegen extends AbstractCSharpCodegen {
|
|||||||
CodegenConstants.OPTIONAL_PROJECT_FILE_DESC,
|
CodegenConstants.OPTIONAL_PROJECT_FILE_DESC,
|
||||||
this.optionalProjectFileFlag);
|
this.optionalProjectFileFlag);
|
||||||
|
|
||||||
addSwitch(CodegenConstants.OPTIONAL_EMIT_DEFAULT_VALUES,
|
|
||||||
CodegenConstants.OPTIONAL_EMIT_DEFAULT_VALUES_DESC,
|
|
||||||
this.optionalEmitDefaultValue);
|
|
||||||
|
|
||||||
addSwitch(CodegenConstants.GENERATE_PROPERTY_CHANGED,
|
addSwitch(CodegenConstants.GENERATE_PROPERTY_CHANGED,
|
||||||
CodegenConstants.PACKAGE_DESCRIPTION_DESC,
|
CodegenConstants.PACKAGE_DESCRIPTION_DESC,
|
||||||
this.generatePropertyChanged);
|
this.generatePropertyChanged);
|
||||||
@@ -318,9 +326,6 @@ public class CSharpClientCodegen extends AbstractCSharpCodegen {
|
|||||||
additionalProperties.put("netStandard", this.netStandard);
|
additionalProperties.put("netStandard", this.netStandard);
|
||||||
additionalProperties.put("targetFrameworkNuget", this.targetFrameworkNuget);
|
additionalProperties.put("targetFrameworkNuget", this.targetFrameworkNuget);
|
||||||
|
|
||||||
// TODO: either remove this and update templates to match the "optionalEmitDefaultValues" property, or rename that property.
|
|
||||||
additionalProperties.put("emitDefaultValue", optionalEmitDefaultValue);
|
|
||||||
|
|
||||||
if (additionalProperties.containsKey(CodegenConstants.OPTIONAL_PROJECT_FILE)) {
|
if (additionalProperties.containsKey(CodegenConstants.OPTIONAL_PROJECT_FILE)) {
|
||||||
setOptionalProjectFileFlag(convertPropertyToBooleanAndWriteBack(CodegenConstants.OPTIONAL_PROJECT_FILE));
|
setOptionalProjectFileFlag(convertPropertyToBooleanAndWriteBack(CodegenConstants.OPTIONAL_PROJECT_FILE));
|
||||||
} else {
|
} else {
|
||||||
@@ -862,4 +867,18 @@ public class CSharpClientCodegen extends AbstractCSharpCodegen {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getNullableType(Schema p, String type) {
|
||||||
|
boolean isNullableExpected = p.getNullable() == null || (p.getNullable() != null && p.getNullable());
|
||||||
|
|
||||||
|
if (isNullableExpected && languageSpecificPrimitives.contains(type + "?")) {
|
||||||
|
return type + "?";
|
||||||
|
} else if (languageSpecificPrimitives.contains(type)) {
|
||||||
|
return type;
|
||||||
|
} else {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -184,10 +184,6 @@ public class CSharpNetCoreClientCodegen extends AbstractCSharpCodegen {
|
|||||||
CodegenConstants.OPTIONAL_PROJECT_FILE_DESC,
|
CodegenConstants.OPTIONAL_PROJECT_FILE_DESC,
|
||||||
this.optionalProjectFileFlag);
|
this.optionalProjectFileFlag);
|
||||||
|
|
||||||
addSwitch(CodegenConstants.OPTIONAL_EMIT_DEFAULT_VALUES,
|
|
||||||
CodegenConstants.OPTIONAL_EMIT_DEFAULT_VALUES_DESC,
|
|
||||||
this.optionalEmitDefaultValue);
|
|
||||||
|
|
||||||
// NOTE: This will reduce visibility of all public members in templates. Users can use InternalsVisibleTo
|
// NOTE: This will reduce visibility of all public members in templates. Users can use InternalsVisibleTo
|
||||||
// https://msdn.microsoft.com/en-us/library/system.runtime.compilerservices.internalsvisibletoattribute(v=vs.110).aspx
|
// https://msdn.microsoft.com/en-us/library/system.runtime.compilerservices.internalsvisibletoattribute(v=vs.110).aspx
|
||||||
// to expose to shared code if the generated code is not embedded into another project. Otherwise, users of codegen
|
// to expose to shared code if the generated code is not embedded into another project. Otherwise, users of codegen
|
||||||
@@ -510,8 +506,6 @@ public class CSharpNetCoreClientCodegen extends AbstractCSharpCodegen {
|
|||||||
|
|
||||||
syncBooleanProperty(additionalProperties, "netStandard", this::setNetStandard, this.netStandard);
|
syncBooleanProperty(additionalProperties, "netStandard", this::setNetStandard, this.netStandard);
|
||||||
|
|
||||||
// TODO: either remove this and update templates to match the "optionalEmitDefaultValues" property, or rename that property.
|
|
||||||
syncBooleanProperty(additionalProperties, "emitDefaultValue", this::setOptionalEmitDefaultValue, optionalEmitDefaultValue);
|
|
||||||
syncBooleanProperty(additionalProperties, CodegenConstants.VALIDATABLE, this::setValidatable, this.validatable);
|
syncBooleanProperty(additionalProperties, CodegenConstants.VALIDATABLE, this::setValidatable, this.validatable);
|
||||||
syncBooleanProperty(additionalProperties, CodegenConstants.SUPPORTS_ASYNC, this::setSupportsAsync, this.supportsAsync);
|
syncBooleanProperty(additionalProperties, CodegenConstants.SUPPORTS_ASYNC, this::setSupportsAsync, this.supportsAsync);
|
||||||
syncBooleanProperty(additionalProperties, CodegenConstants.OPTIONAL_PROJECT_FILE, this::setOptionalProjectFileFlag, optionalProjectFileFlag);
|
syncBooleanProperty(additionalProperties, CodegenConstants.OPTIONAL_PROJECT_FILE, this::setOptionalProjectFileFlag, optionalProjectFileFlag);
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ import org.openapitools.codegen.utils.ModelUtils;
|
|||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
||||||
import static org.openapitools.codegen.utils.StringUtils.underscore;
|
import static org.openapitools.codegen.utils.StringUtils.*;
|
||||||
|
|
||||||
public class CppPistacheServerCodegen extends AbstractCppCodegen {
|
public class CppPistacheServerCodegen extends AbstractCppCodegen {
|
||||||
protected String implFolder = "impl";
|
protected String implFolder = "impl";
|
||||||
@@ -265,7 +265,7 @@ public class CppPistacheServerCodegen extends AbstractCppCodegen {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toModelFilename(String name) {
|
public String toModelFilename(String name) {
|
||||||
return initialCaps(toModelName(name));
|
return camelize(toModelName(name));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -286,7 +286,7 @@ public class CppPistacheServerCodegen extends AbstractCppCodegen {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toApiFilename(String name) {
|
public String toApiFilename(String name) {
|
||||||
return modelNamePrefix + initialCaps(name) + "Api";
|
return modelNamePrefix + camelize(name) + "Api";
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import io.swagger.v3.oas.models.media.Schema;
|
|||||||
import io.swagger.v3.parser.util.SchemaTypeUtil;
|
import io.swagger.v3.parser.util.SchemaTypeUtil;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.openapitools.codegen.CodegenConfig;
|
import org.openapitools.codegen.CodegenConfig;
|
||||||
|
import org.openapitools.codegen.CodegenModel;
|
||||||
import org.openapitools.codegen.CodegenOperation;
|
import org.openapitools.codegen.CodegenOperation;
|
||||||
import org.openapitools.codegen.CodegenParameter;
|
import org.openapitools.codegen.CodegenParameter;
|
||||||
import org.openapitools.codegen.utils.ModelUtils;
|
import org.openapitools.codegen.utils.ModelUtils;
|
||||||
@@ -280,7 +281,19 @@ public class CppQt5AbstractCodegen extends AbstractCppCodegen implements Codegen
|
|||||||
List<CodegenOperation> operations = (List<CodegenOperation>) objectMap.get("operation");
|
List<CodegenOperation> operations = (List<CodegenOperation>) objectMap.get("operation");
|
||||||
|
|
||||||
List<Map<String, String>> imports = (List<Map<String, String>>) objs.get("imports");
|
List<Map<String, String>> imports = (List<Map<String, String>>) objs.get("imports");
|
||||||
|
Map<String, CodegenModel> codegenModels = new HashMap<String, CodegenModel> ();
|
||||||
|
for(Object moObj : allModels) {
|
||||||
|
CodegenModel mo = ((Map<String, CodegenModel>) moObj).get("model");
|
||||||
|
if(mo.isEnum) {
|
||||||
|
codegenModels.put(mo.classname, mo);
|
||||||
|
}
|
||||||
|
}
|
||||||
for (CodegenOperation operation : operations) {
|
for (CodegenOperation operation : operations) {
|
||||||
|
if(operation.returnType != null) {
|
||||||
|
if(codegenModels.containsKey(operation.returnType)){
|
||||||
|
operation.vendorExtensions.put("returnsEnum", true);
|
||||||
|
}
|
||||||
|
}
|
||||||
// Check all return parameter baseType if there is a necessity to include, include it if not
|
// Check all return parameter baseType if there is a necessity to include, include it if not
|
||||||
// already done
|
// already done
|
||||||
if (operation.returnBaseType != null && needToImport(operation.returnBaseType)) {
|
if (operation.returnBaseType != null && needToImport(operation.returnBaseType)) {
|
||||||
@@ -316,6 +329,21 @@ public class CppQt5AbstractCodegen extends AbstractCppCodegen implements Codegen
|
|||||||
return objs;
|
return objs;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Map<String, Object> postProcessModels(Map<String, Object> objs) {
|
||||||
|
return postProcessModelsEnum(objs);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toEnumValue(String value, String datatype) {
|
||||||
|
return escapeText(value);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isDataTypeString(String dataType) {
|
||||||
|
return "QString".equals(dataType);
|
||||||
|
}
|
||||||
|
|
||||||
private Map<String, String> createMapping(String key, String value) {
|
private Map<String, String> createMapping(String key, String value) {
|
||||||
Map<String, String> customImport = new HashMap<String, String>();
|
Map<String, String> customImport = new HashMap<String, String>();
|
||||||
customImport.put(key, toModelImport(value));
|
customImport.put(key, toModelImport(value));
|
||||||
|
|||||||
@@ -24,6 +24,8 @@ import org.openapitools.codegen.SupportingFile;
|
|||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
|
||||||
|
import static org.openapitools.codegen.utils.StringUtils.*;
|
||||||
|
|
||||||
public class CppQt5ClientCodegen extends CppQt5AbstractCodegen implements CodegenConfig {
|
public class CppQt5ClientCodegen extends CppQt5AbstractCodegen implements CodegenConfig {
|
||||||
public static final String OPTIONAL_PROJECT_FILE_DESC = "Generate client.pri.";
|
public static final String OPTIONAL_PROJECT_FILE_DESC = "Generate client.pri.";
|
||||||
// source folder where to write the files
|
// source folder where to write the files
|
||||||
@@ -75,6 +77,7 @@ public class CppQt5ClientCodegen extends CppQt5AbstractCodegen implements Codege
|
|||||||
supportingFiles.add(new SupportingFile("HttpRequest.h.mustache", sourceFolder, PREFIX + "HttpRequest.h"));
|
supportingFiles.add(new SupportingFile("HttpRequest.h.mustache", sourceFolder, PREFIX + "HttpRequest.h"));
|
||||||
supportingFiles.add(new SupportingFile("HttpRequest.cpp.mustache", sourceFolder, PREFIX + "HttpRequest.cpp"));
|
supportingFiles.add(new SupportingFile("HttpRequest.cpp.mustache", sourceFolder, PREFIX + "HttpRequest.cpp"));
|
||||||
supportingFiles.add(new SupportingFile("object.mustache", sourceFolder, PREFIX + "Object.h"));
|
supportingFiles.add(new SupportingFile("object.mustache", sourceFolder, PREFIX + "Object.h"));
|
||||||
|
supportingFiles.add(new SupportingFile("enum.mustache", sourceFolder, PREFIX + "Enum.h"));
|
||||||
if (optionalProjectFileFlag) {
|
if (optionalProjectFileFlag) {
|
||||||
supportingFiles.add(new SupportingFile("Project.mustache", sourceFolder, "client.pri"));
|
supportingFiles.add(new SupportingFile("Project.mustache", sourceFolder, "client.pri"));
|
||||||
}
|
}
|
||||||
@@ -100,6 +103,7 @@ public class CppQt5ClientCodegen extends CppQt5AbstractCodegen implements Codege
|
|||||||
supportingFiles.add(new SupportingFile("HttpRequest.h.mustache", sourceFolder, modelNamePrefix + "HttpRequest.h"));
|
supportingFiles.add(new SupportingFile("HttpRequest.h.mustache", sourceFolder, modelNamePrefix + "HttpRequest.h"));
|
||||||
supportingFiles.add(new SupportingFile("HttpRequest.cpp.mustache", sourceFolder, modelNamePrefix + "HttpRequest.cpp"));
|
supportingFiles.add(new SupportingFile("HttpRequest.cpp.mustache", sourceFolder, modelNamePrefix + "HttpRequest.cpp"));
|
||||||
supportingFiles.add(new SupportingFile("object.mustache", sourceFolder, modelNamePrefix + "Object.h"));
|
supportingFiles.add(new SupportingFile("object.mustache", sourceFolder, modelNamePrefix + "Object.h"));
|
||||||
|
supportingFiles.add(new SupportingFile("enum.mustache", sourceFolder, modelNamePrefix + "Enum.h"));
|
||||||
|
|
||||||
typeMapping.put("file", modelNamePrefix + "HttpRequestInputFileElement");
|
typeMapping.put("file", modelNamePrefix + "HttpRequestInputFileElement");
|
||||||
typeMapping.put("binary", modelNamePrefix + "HttpRequestInputFileElement");
|
typeMapping.put("binary", modelNamePrefix + "HttpRequestInputFileElement");
|
||||||
@@ -163,7 +167,7 @@ public class CppQt5ClientCodegen extends CppQt5AbstractCodegen implements Codege
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toApiFilename(String name) {
|
public String toApiFilename(String name) {
|
||||||
return modelNamePrefix + sanitizeName(initialCaps(name)) + "Api";
|
return modelNamePrefix + sanitizeName(camelize(name)) + "Api";
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setOptionalProjectFileFlag(boolean flag) {
|
public void setOptionalProjectFileFlag(boolean flag) {
|
||||||
|
|||||||
@@ -23,6 +23,8 @@ import org.openapitools.codegen.SupportingFile;
|
|||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
|
||||||
|
import static org.openapitools.codegen.utils.StringUtils.*;
|
||||||
|
|
||||||
public class CppQt5QHttpEngineServerCodegen extends CppQt5AbstractCodegen implements CodegenConfig {
|
public class CppQt5QHttpEngineServerCodegen extends CppQt5AbstractCodegen implements CodegenConfig {
|
||||||
|
|
||||||
protected final String SRC_DIR = "/src";
|
protected final String SRC_DIR = "/src";
|
||||||
@@ -83,6 +85,7 @@ public class CppQt5QHttpEngineServerCodegen extends CppQt5AbstractCodegen implem
|
|||||||
supportingFiles.add(new SupportingFile("helpers-header.mustache", sourceFolder + MODEL_DIR, PREFIX + "Helpers.h"));
|
supportingFiles.add(new SupportingFile("helpers-header.mustache", sourceFolder + MODEL_DIR, PREFIX + "Helpers.h"));
|
||||||
supportingFiles.add(new SupportingFile("helpers-body.mustache", sourceFolder + MODEL_DIR, PREFIX + "Helpers.cpp"));
|
supportingFiles.add(new SupportingFile("helpers-body.mustache", sourceFolder + MODEL_DIR, PREFIX + "Helpers.cpp"));
|
||||||
supportingFiles.add(new SupportingFile("object.mustache", sourceFolder + MODEL_DIR, PREFIX + "Object.h"));
|
supportingFiles.add(new SupportingFile("object.mustache", sourceFolder + MODEL_DIR, PREFIX + "Object.h"));
|
||||||
|
supportingFiles.add(new SupportingFile("enum.mustache", sourceFolder + MODEL_DIR, PREFIX + "Enum.h"));
|
||||||
supportingFiles.add(new SupportingFile("apirouter.h.mustache", sourceFolder + APIHANDLER_DIR, PREFIX + "ApiRouter.h"));
|
supportingFiles.add(new SupportingFile("apirouter.h.mustache", sourceFolder + APIHANDLER_DIR, PREFIX + "ApiRouter.h"));
|
||||||
supportingFiles.add(new SupportingFile("apirouter.cpp.mustache", sourceFolder + APIHANDLER_DIR, PREFIX + "ApiRouter.cpp"));
|
supportingFiles.add(new SupportingFile("apirouter.cpp.mustache", sourceFolder + APIHANDLER_DIR, PREFIX + "ApiRouter.cpp"));
|
||||||
|
|
||||||
@@ -106,6 +109,7 @@ public class CppQt5QHttpEngineServerCodegen extends CppQt5AbstractCodegen implem
|
|||||||
supportingFiles.add(new SupportingFile("helpers-header.mustache", sourceFolder + MODEL_DIR, modelNamePrefix + "Helpers.h"));
|
supportingFiles.add(new SupportingFile("helpers-header.mustache", sourceFolder + MODEL_DIR, modelNamePrefix + "Helpers.h"));
|
||||||
supportingFiles.add(new SupportingFile("helpers-body.mustache", sourceFolder + MODEL_DIR, modelNamePrefix + "Helpers.cpp"));
|
supportingFiles.add(new SupportingFile("helpers-body.mustache", sourceFolder + MODEL_DIR, modelNamePrefix + "Helpers.cpp"));
|
||||||
supportingFiles.add(new SupportingFile("object.mustache", sourceFolder + MODEL_DIR, modelNamePrefix + "Object.h"));
|
supportingFiles.add(new SupportingFile("object.mustache", sourceFolder + MODEL_DIR, modelNamePrefix + "Object.h"));
|
||||||
|
supportingFiles.add(new SupportingFile("enum.mustache", sourceFolder + MODEL_DIR, modelNamePrefix + "Enum.h"));
|
||||||
supportingFiles.add(new SupportingFile("apirouter.h.mustache", sourceFolder + APIHANDLER_DIR, modelNamePrefix + "ApiRouter.h"));
|
supportingFiles.add(new SupportingFile("apirouter.h.mustache", sourceFolder + APIHANDLER_DIR, modelNamePrefix + "ApiRouter.h"));
|
||||||
supportingFiles.add(new SupportingFile("apirouter.cpp.mustache", sourceFolder + APIHANDLER_DIR, modelNamePrefix + "ApiRouter.cpp"));
|
supportingFiles.add(new SupportingFile("apirouter.cpp.mustache", sourceFolder + APIHANDLER_DIR, modelNamePrefix + "ApiRouter.cpp"));
|
||||||
|
|
||||||
@@ -187,7 +191,7 @@ public class CppQt5QHttpEngineServerCodegen extends CppQt5AbstractCodegen implem
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toApiFilename(String name) {
|
public String toApiFilename(String name) {
|
||||||
return modelNamePrefix + sanitizeName(initialCaps(name)) + "ApiHandler";
|
return modelNamePrefix + sanitizeName(camelize(name)) + "ApiHandler";
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -31,6 +31,7 @@ import org.openapitools.codegen.utils.ModelUtils;
|
|||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
||||||
import static com.google.common.base.Strings.isNullOrEmpty;
|
import static com.google.common.base.Strings.isNullOrEmpty;
|
||||||
|
import static org.openapitools.codegen.utils.StringUtils.*;
|
||||||
|
|
||||||
public class CppRestSdkClientCodegen extends AbstractCppCodegen {
|
public class CppRestSdkClientCodegen extends AbstractCppCodegen {
|
||||||
|
|
||||||
@@ -288,12 +289,12 @@ public class CppRestSdkClientCodegen extends AbstractCppCodegen {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toModelFilename(String name) {
|
public String toModelFilename(String name) {
|
||||||
return sanitizeName(initialCaps(name));
|
return sanitizeName(camelize(name));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toApiFilename(String name) {
|
public String toApiFilename(String name) {
|
||||||
return sanitizeName(initialCaps(name) + "Api");
|
return sanitizeName(camelize(name) + "Api");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -27,6 +27,8 @@ import org.slf4j.LoggerFactory;
|
|||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
||||||
|
import static org.openapitools.codegen.utils.StringUtils.*;
|
||||||
|
|
||||||
public class CppRestbedServerCodegen extends AbstractCppCodegen {
|
public class CppRestbedServerCodegen extends AbstractCppCodegen {
|
||||||
|
|
||||||
private static final org.slf4j.Logger LOGGER = LoggerFactory.getLogger(CppRestbedServerCodegen.class);
|
private static final org.slf4j.Logger LOGGER = LoggerFactory.getLogger(CppRestbedServerCodegen.class);
|
||||||
@@ -191,12 +193,12 @@ public class CppRestbedServerCodegen extends AbstractCppCodegen {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toModelFilename(String name) {
|
public String toModelFilename(String name) {
|
||||||
return initialCaps(name);
|
return camelize(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toApiFilename(String name) {
|
public String toApiFilename(String name) {
|
||||||
return initialCaps(name) + "Api";
|
return camelize(name) + "Api";
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
|
|||||||
@@ -247,17 +247,17 @@ public class CppTizenClientCodegen extends AbstractCppCodegen implements Codegen
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toModelFilename(String name) {
|
public String toModelFilename(String name) {
|
||||||
return initialCaps(name);
|
return camelize(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toApiName(String name) {
|
public String toApiName(String name) {
|
||||||
return initialCaps(name) + "Manager";
|
return camelize(name) + "Manager";
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toApiFilename(String name) {
|
public String toApiFilename(String name) {
|
||||||
return initialCaps(name) + "Manager";
|
return camelize(name) + "Manager";
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -16,10 +16,16 @@
|
|||||||
|
|
||||||
package org.openapitools.codegen.languages;
|
package org.openapitools.codegen.languages;
|
||||||
|
|
||||||
import io.swagger.v3.oas.models.media.Schema;
|
import org.apache.commons.io.FilenameUtils;
|
||||||
|
import org.openapitools.codegen.*;
|
||||||
|
import org.openapitools.codegen.utils.ModelUtils;
|
||||||
|
|
||||||
|
import io.swagger.v3.oas.models.media.*;
|
||||||
|
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.openapitools.codegen.*;
|
import org.openapitools.codegen.*;
|
||||||
import org.openapitools.codegen.utils.ModelUtils;
|
import org.openapitools.codegen.utils.ModelUtils;
|
||||||
|
import org.openapitools.codegen.utils.ProcessUtils;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
@@ -28,16 +34,25 @@ import static org.openapitools.codegen.utils.StringUtils.underscore;
|
|||||||
|
|
||||||
public class DartJaguarClientCodegen extends DartClientCodegen {
|
public class DartJaguarClientCodegen extends DartClientCodegen {
|
||||||
private static final String NULLABLE_FIELDS = "nullableFields";
|
private static final String NULLABLE_FIELDS = "nullableFields";
|
||||||
|
private static final String SERIALIZATION_FORMAT = "serialization";
|
||||||
|
private static final String IS_FORMAT_JSON = "jsonFormat";
|
||||||
|
private static final String IS_FORMAT_PROTO = "protoFormat";
|
||||||
private static Set<String> modelToIgnore = new HashSet<>();
|
private static Set<String> modelToIgnore = new HashSet<>();
|
||||||
|
private HashMap<String, String> protoTypeMapping = new HashMap<>();
|
||||||
|
|
||||||
static {
|
static {
|
||||||
modelToIgnore.add("datetime");
|
modelToIgnore.add("datetime");
|
||||||
modelToIgnore.add("map");
|
modelToIgnore.add("map");
|
||||||
modelToIgnore.add("list");
|
modelToIgnore.add("list");
|
||||||
modelToIgnore.add("file");
|
modelToIgnore.add("file");
|
||||||
|
modelToIgnore.add("uint8list");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static final String SERIALIZATION_JSON = "json";
|
||||||
|
private static final String SERIALIZATION_PROTO = "proto";
|
||||||
|
|
||||||
private boolean nullableFields = true;
|
private boolean nullableFields = true;
|
||||||
|
private String serialization = SERIALIZATION_JSON;
|
||||||
|
|
||||||
public DartJaguarClientCodegen() {
|
public DartJaguarClientCodegen() {
|
||||||
super();
|
super();
|
||||||
@@ -46,6 +61,33 @@ public class DartJaguarClientCodegen extends DartClientCodegen {
|
|||||||
embeddedTemplateDir = templateDir = "dart-jaguar";
|
embeddedTemplateDir = templateDir = "dart-jaguar";
|
||||||
|
|
||||||
cliOptions.add(new CliOption(NULLABLE_FIELDS, "Is the null fields should be in the JSON payload"));
|
cliOptions.add(new CliOption(NULLABLE_FIELDS, "Is the null fields should be in the JSON payload"));
|
||||||
|
cliOptions.add(new CliOption(SERIALIZATION_FORMAT, "Choose serialization format JSON or PROTO is supported"));
|
||||||
|
|
||||||
|
typeMapping.put("file", "Uint8List");
|
||||||
|
typeMapping.put("binary", "Uint8List");
|
||||||
|
|
||||||
|
protoTypeMapping.put("Array", "repeated");
|
||||||
|
protoTypeMapping.put("array", "repeated");
|
||||||
|
protoTypeMapping.put("List", "repeated");
|
||||||
|
protoTypeMapping.put("boolean", "bool");
|
||||||
|
protoTypeMapping.put("string", "string");
|
||||||
|
protoTypeMapping.put("char", "string");
|
||||||
|
protoTypeMapping.put("int", "int32");
|
||||||
|
protoTypeMapping.put("long", "int64");
|
||||||
|
protoTypeMapping.put("short", "int32");
|
||||||
|
protoTypeMapping.put("number", "double");
|
||||||
|
protoTypeMapping.put("float", "float");
|
||||||
|
protoTypeMapping.put("double", "double");
|
||||||
|
protoTypeMapping.put("object", "google.protobuf.Any");
|
||||||
|
protoTypeMapping.put("integer", "int32");
|
||||||
|
protoTypeMapping.put("Date", "google.protobuf.Timestamp");
|
||||||
|
protoTypeMapping.put("date", "google.protobuf.Timestamp");
|
||||||
|
protoTypeMapping.put("File", "bytes");
|
||||||
|
protoTypeMapping.put("file", "bytes");
|
||||||
|
protoTypeMapping.put("binary", "bytes");
|
||||||
|
protoTypeMapping.put("UUID", "string");
|
||||||
|
protoTypeMapping.put("ByteArray", "bytes");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -77,6 +119,20 @@ public class DartJaguarClientCodegen extends DartClientCodegen {
|
|||||||
additionalProperties.put(NULLABLE_FIELDS, nullableFields);
|
additionalProperties.put(NULLABLE_FIELDS, nullableFields);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (additionalProperties.containsKey(SERIALIZATION_FORMAT)) {
|
||||||
|
serialization = ((String) additionalProperties.get(SERIALIZATION_FORMAT));
|
||||||
|
boolean isProto = serialization.equalsIgnoreCase(SERIALIZATION_PROTO);
|
||||||
|
additionalProperties.put(IS_FORMAT_JSON, serialization.equalsIgnoreCase(SERIALIZATION_JSON));
|
||||||
|
additionalProperties.put(IS_FORMAT_PROTO, isProto);
|
||||||
|
|
||||||
|
modelTemplateFiles.put("model.mustache", isProto ? ".proto" : ".dart");
|
||||||
|
|
||||||
|
} else {
|
||||||
|
//not set, use to be passed to template
|
||||||
|
additionalProperties.put(IS_FORMAT_JSON, true);
|
||||||
|
additionalProperties.put(IS_FORMAT_PROTO, false);
|
||||||
|
}
|
||||||
|
|
||||||
if (additionalProperties.containsKey(PUB_NAME)) {
|
if (additionalProperties.containsKey(PUB_NAME)) {
|
||||||
this.setPubName((String) additionalProperties.get(PUB_NAME));
|
this.setPubName((String) additionalProperties.get(PUB_NAME));
|
||||||
} else {
|
} else {
|
||||||
@@ -133,6 +189,7 @@ public class DartJaguarClientCodegen extends DartClientCodegen {
|
|||||||
public Map<String, Object> postProcessModels(Map<String, Object> objs) {
|
public Map<String, Object> postProcessModels(Map<String, Object> objs) {
|
||||||
objs = super.postProcessModels(objs);
|
objs = super.postProcessModels(objs);
|
||||||
List<Object> models = (List<Object>) objs.get("models");
|
List<Object> models = (List<Object>) objs.get("models");
|
||||||
|
ProcessUtils.addIndexToProperties(models, 1);
|
||||||
for (Object _mo : models) {
|
for (Object _mo : models) {
|
||||||
Map<String, Object> mo = (Map<String, Object>) _mo;
|
Map<String, Object> mo = (Map<String, Object>) _mo;
|
||||||
Set<String> modelImports = new HashSet<>();
|
Set<String> modelImports = new HashSet<>();
|
||||||
@@ -142,6 +199,16 @@ public class DartJaguarClientCodegen extends DartClientCodegen {
|
|||||||
modelImports.add(underscore(modelImport));
|
modelImports.add(underscore(modelImport));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for (CodegenProperty p : cm.vars) {
|
||||||
|
String protoType = protoTypeMapping.get(p.openApiType);
|
||||||
|
if (p.isListContainer) {
|
||||||
|
String innerType = protoTypeMapping.get(p.mostInnerItems.openApiType);
|
||||||
|
protoType = protoType + " " + (innerType == null ? p.mostInnerItems.openApiType : innerType);
|
||||||
|
}
|
||||||
|
p.vendorExtensions.put("x-proto-type", protoType == null ? p.openApiType : protoType);
|
||||||
|
}
|
||||||
|
|
||||||
cm.imports = modelImports;
|
cm.imports = modelImports;
|
||||||
cm.vendorExtensions.put("hasVars", cm.vars.size() > 0);
|
cm.vendorExtensions.put("hasVars", cm.vars.size() > 0);
|
||||||
}
|
}
|
||||||
@@ -155,17 +222,20 @@ public class DartJaguarClientCodegen extends DartClientCodegen {
|
|||||||
List<CodegenOperation> operationList = (List<CodegenOperation>) operations.get("operation");
|
List<CodegenOperation> operationList = (List<CodegenOperation>) operations.get("operation");
|
||||||
|
|
||||||
Set<String> modelImports = new HashSet<>();
|
Set<String> modelImports = new HashSet<>();
|
||||||
|
Set<String> fullImports = new HashSet<>();
|
||||||
|
|
||||||
for (CodegenOperation op : operationList) {
|
for (CodegenOperation op : operationList) {
|
||||||
op.httpMethod = StringUtils.capitalize(op.httpMethod.toLowerCase(Locale.ROOT));
|
op.httpMethod = StringUtils.capitalize(op.httpMethod.toLowerCase(Locale.ROOT));
|
||||||
boolean isJson = true; //default to JSON
|
boolean isJson = true; //default to JSON
|
||||||
boolean isForm = false;
|
boolean isForm = false;
|
||||||
|
boolean isProto = false;
|
||||||
boolean isMultipart = false;
|
boolean isMultipart = false;
|
||||||
if (op.consumes != null) {
|
if (op.consumes != null) {
|
||||||
for (Map<String, String> consume : op.consumes) {
|
for (Map<String, String> consume : op.consumes) {
|
||||||
if (consume.containsKey("mediaType")) {
|
if (consume.containsKey("mediaType")) {
|
||||||
String type = consume.get("mediaType");
|
String type = consume.get("mediaType");
|
||||||
isJson = type.equalsIgnoreCase("application/json");
|
isJson = type.equalsIgnoreCase("application/json");
|
||||||
|
isProto = type.equalsIgnoreCase("application/octet-stream");
|
||||||
isForm = type.equalsIgnoreCase("application/x-www-form-urlencoded");
|
isForm = type.equalsIgnoreCase("application/x-www-form-urlencoded");
|
||||||
isMultipart = type.equalsIgnoreCase("multipart/form-data");
|
isMultipart = type.equalsIgnoreCase("multipart/form-data");
|
||||||
break;
|
break;
|
||||||
@@ -173,7 +243,27 @@ public class DartJaguarClientCodegen extends DartClientCodegen {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for (CodegenParameter param : op.allParams) {
|
||||||
|
if (param.baseType != null && param.baseType.equalsIgnoreCase("Uint8List") && isMultipart) {
|
||||||
|
param.baseType = "MultipartFile";
|
||||||
|
param.dataType = "MultipartFile";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for (CodegenParameter param : op.formParams) {
|
||||||
|
if (param.baseType != null && param.baseType.equalsIgnoreCase("Uint8List") && isMultipart) {
|
||||||
|
param.baseType = "MultipartFile";
|
||||||
|
param.dataType = "MultipartFile";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for (CodegenParameter param : op.bodyParams) {
|
||||||
|
if (param.baseType != null && param.baseType.equalsIgnoreCase("Uint8List") && isMultipart) {
|
||||||
|
param.baseType = "MultipartFile";
|
||||||
|
param.dataType = "MultipartFile";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
op.vendorExtensions.put("isJson", isJson);
|
op.vendorExtensions.put("isJson", isJson);
|
||||||
|
op.vendorExtensions.put("isProto", isProto);
|
||||||
op.vendorExtensions.put("isForm", isForm);
|
op.vendorExtensions.put("isForm", isForm);
|
||||||
op.vendorExtensions.put("isMultipart", isMultipart);
|
op.vendorExtensions.put("isMultipart", isMultipart);
|
||||||
|
|
||||||
@@ -181,6 +271,8 @@ public class DartJaguarClientCodegen extends DartClientCodegen {
|
|||||||
for (String item : op.imports) {
|
for (String item : op.imports) {
|
||||||
if (!modelToIgnore.contains(item.toLowerCase(Locale.ROOT))) {
|
if (!modelToIgnore.contains(item.toLowerCase(Locale.ROOT))) {
|
||||||
imports.add(underscore(item));
|
imports.add(underscore(item));
|
||||||
|
} else if (item.equalsIgnoreCase("Uint8List")) {
|
||||||
|
fullImports.add("dart:typed_data");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
modelImports.addAll(imports);
|
modelImports.addAll(imports);
|
||||||
@@ -205,6 +297,7 @@ public class DartJaguarClientCodegen extends DartClientCodegen {
|
|||||||
}
|
}
|
||||||
|
|
||||||
objs.put("modelImports", modelImports);
|
objs.put("modelImports", modelImports);
|
||||||
|
objs.put("fullImports", fullImports);
|
||||||
|
|
||||||
return objs;
|
return objs;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -23,6 +23,7 @@ import io.swagger.v3.oas.models.OpenAPI;
|
|||||||
import io.swagger.v3.oas.models.info.Info;
|
import io.swagger.v3.oas.models.info.Info;
|
||||||
import io.swagger.v3.oas.models.media.ArraySchema;
|
import io.swagger.v3.oas.models.media.ArraySchema;
|
||||||
import io.swagger.v3.oas.models.media.Schema;
|
import io.swagger.v3.oas.models.media.Schema;
|
||||||
|
import io.swagger.v3.oas.models.responses.ApiResponse;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.openapitools.codegen.*;
|
import org.openapitools.codegen.*;
|
||||||
import org.openapitools.codegen.utils.ModelUtils;
|
import org.openapitools.codegen.utils.ModelUtils;
|
||||||
@@ -53,7 +54,7 @@ public class ElixirClientCodegen extends DefaultCodegen implements CodegenConfig
|
|||||||
List<String> extraApplications = Arrays.asList(":logger");
|
List<String> extraApplications = Arrays.asList(":logger");
|
||||||
List<String> deps = Arrays.asList(
|
List<String> deps = Arrays.asList(
|
||||||
"{:tesla, \"~> 1.0.0\"}",
|
"{:tesla, \"~> 1.0.0\"}",
|
||||||
"{:poison, \">= 1.0.0\"}"
|
"{:poison, \"~> 3.0.0\"}"
|
||||||
);
|
);
|
||||||
|
|
||||||
public ElixirClientCodegen() {
|
public ElixirClientCodegen() {
|
||||||
@@ -310,6 +311,11 @@ public class ElixirClientCodegen extends DefaultCodegen implements CodegenConfig
|
|||||||
return new ExtendedCodegenModel(cm);
|
return new ExtendedCodegenModel(cm);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public CodegenResponse fromResponse(String responseCode, ApiResponse resp) {
|
||||||
|
return new ExtendedCodegenResponse(super.fromResponse(responseCode, resp));
|
||||||
|
}
|
||||||
|
|
||||||
// We should use String.join if we can use Java8
|
// We should use String.join if we can use Java8
|
||||||
String join(CharSequence charSequence, Iterable<String> iterable) {
|
String join(CharSequence charSequence, Iterable<String> iterable) {
|
||||||
StringBuilder buf = new StringBuilder();
|
StringBuilder buf = new StringBuilder();
|
||||||
@@ -515,6 +521,91 @@ public class ElixirClientCodegen extends DefaultCodegen implements CodegenConfig
|
|||||||
return toModelName(type);
|
return toModelName(type);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class ExtendedCodegenResponse extends CodegenResponse {
|
||||||
|
public boolean isDefinedDefault;
|
||||||
|
|
||||||
|
public ExtendedCodegenResponse(CodegenResponse o) {
|
||||||
|
super();
|
||||||
|
|
||||||
|
this.headers.addAll(o.headers);
|
||||||
|
this.code = o.code;
|
||||||
|
this.message = o.message;
|
||||||
|
this.hasMore = o.hasMore;
|
||||||
|
this.examples = o.examples;
|
||||||
|
this.dataType = o.dataType;
|
||||||
|
this.baseType = o.baseType;
|
||||||
|
this.containerType = o.containerType;
|
||||||
|
this.hasHeaders = o.hasHeaders;
|
||||||
|
this.isString = o.isString;
|
||||||
|
this.isNumeric = o.isNumeric;
|
||||||
|
this.isInteger = o.isInteger;
|
||||||
|
this.isLong = o.isLong;
|
||||||
|
this.isNumber = o.isNumber;
|
||||||
|
this.isFloat = o.isFloat;
|
||||||
|
this.isDouble = o.isDouble;
|
||||||
|
this.isByteArray = o.isByteArray;
|
||||||
|
this.isBoolean = o.isBoolean;
|
||||||
|
this.isDate = o.isDate;
|
||||||
|
this.isDateTime = o.isDateTime;
|
||||||
|
this.isUuid = o.isUuid;
|
||||||
|
this.isEmail = o.isEmail;
|
||||||
|
this.isModel = o.isModel;
|
||||||
|
this.isFreeFormObject = o.isFreeFormObject;
|
||||||
|
this.isDefault = o.isDefault;
|
||||||
|
this.simpleType = o.simpleType;
|
||||||
|
this.primitiveType = o.primitiveType;
|
||||||
|
this.isMapContainer = o.isMapContainer;
|
||||||
|
this.isListContainer = o.isListContainer;
|
||||||
|
this.isBinary = o.isBinary;
|
||||||
|
this.isFile = o.isFile;
|
||||||
|
this.schema = o.schema;
|
||||||
|
this.jsonSchema = o.jsonSchema;
|
||||||
|
this.vendorExtensions = o.vendorExtensions;
|
||||||
|
|
||||||
|
this.isDefinedDefault = (this.code.equals("0") || this.code.equals("default"));
|
||||||
|
}
|
||||||
|
|
||||||
|
public String codeMappingKey(){
|
||||||
|
if(this.isDefinedDefault) {
|
||||||
|
return ":default";
|
||||||
|
}
|
||||||
|
|
||||||
|
if(code.matches("^\\d{3}$")){
|
||||||
|
return code;
|
||||||
|
}
|
||||||
|
|
||||||
|
LOGGER.warn("Unknown HTTP status code: " + this.code);
|
||||||
|
return "\"" + code + "\"";
|
||||||
|
}
|
||||||
|
|
||||||
|
public String decodedStruct() {
|
||||||
|
// Let Poison decode the entire response into a generic blob
|
||||||
|
if (isMapContainer) {
|
||||||
|
return "%{}";
|
||||||
|
}
|
||||||
|
// Primitive return type, don't even try to decode
|
||||||
|
if (baseType == null || (simpleType && primitiveType)) {
|
||||||
|
return "false";
|
||||||
|
} else if (isListContainer && languageSpecificPrimitives().contains(baseType)) {
|
||||||
|
return "[]";
|
||||||
|
}
|
||||||
|
StringBuilder sb = new StringBuilder();
|
||||||
|
if (isListContainer) {
|
||||||
|
sb.append("[");
|
||||||
|
}
|
||||||
|
sb.append("%");
|
||||||
|
sb.append(moduleName);
|
||||||
|
sb.append(".Model.");
|
||||||
|
sb.append(baseType);
|
||||||
|
sb.append("{}");
|
||||||
|
if (isListContainer) {
|
||||||
|
sb.append("]");
|
||||||
|
}
|
||||||
|
return sb.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
class ExtendedCodegenOperation extends CodegenOperation {
|
class ExtendedCodegenOperation extends CodegenOperation {
|
||||||
private List<String> pathTemplateNames = new ArrayList<String>();
|
private List<String> pathTemplateNames = new ArrayList<String>();
|
||||||
private String replacedPathName;
|
private String replacedPathName;
|
||||||
@@ -688,32 +779,6 @@ public class ElixirClientCodegen extends DefaultCodegen implements CodegenConfig
|
|||||||
sb.append(".t");
|
sb.append(".t");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public String decodedStruct() {
|
|
||||||
// Let Poison decode the entire response into a generic blob
|
|
||||||
if (isMapContainer) {
|
|
||||||
return "";
|
|
||||||
}
|
|
||||||
// Primitive return type, don't even try to decode
|
|
||||||
if (returnBaseType == null || (returnSimpleType && returnTypeIsPrimitive)) {
|
|
||||||
return "false";
|
|
||||||
} else if (isListContainer && languageSpecificPrimitives().contains(returnBaseType)) {
|
|
||||||
return "[]";
|
|
||||||
}
|
|
||||||
StringBuilder sb = new StringBuilder();
|
|
||||||
if (isListContainer) {
|
|
||||||
sb.append("[");
|
|
||||||
}
|
|
||||||
sb.append("%");
|
|
||||||
sb.append(moduleName);
|
|
||||||
sb.append(".Model.");
|
|
||||||
sb.append(returnBaseType);
|
|
||||||
sb.append("{}");
|
|
||||||
if (isListContainer) {
|
|
||||||
sb.append("]");
|
|
||||||
}
|
|
||||||
return sb.toString();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
class ExtendedCodegenModel extends CodegenModel {
|
class ExtendedCodegenModel extends CodegenModel {
|
||||||
|
|||||||
@@ -30,7 +30,9 @@ import org.slf4j.LoggerFactory;
|
|||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.text.Collator;
|
import java.text.Collator;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
import java.util.function.Predicate;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
import java.util.stream.Stream;
|
||||||
|
|
||||||
import static org.openapitools.codegen.utils.StringUtils.camelize;
|
import static org.openapitools.codegen.utils.StringUtils.camelize;
|
||||||
|
|
||||||
@@ -234,7 +236,7 @@ public class ElmClientCodegen extends DefaultCodegen implements CodegenConfig {
|
|||||||
if (name.length() == 0) {
|
if (name.length() == 0) {
|
||||||
return "Default";
|
return "Default";
|
||||||
}
|
}
|
||||||
return initialCaps(name);
|
return camelize(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -411,14 +413,26 @@ public class ElmClientCodegen extends DefaultCodegen implements CodegenConfig {
|
|||||||
return postProcessModelsEnum(objs);
|
return postProcessModelsEnum(objs);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static boolean anyOperationParam(final List<CodegenOperation> operations, final Predicate<CodegenParameter> predicate) {
|
||||||
|
return operations.stream()
|
||||||
|
.flatMap(operation -> Stream.of(
|
||||||
|
operation.bodyParams.stream(),
|
||||||
|
operation.queryParams.stream(),
|
||||||
|
operation.pathParams.stream(),
|
||||||
|
operation.headerParams.stream()
|
||||||
|
))
|
||||||
|
.flatMap(a -> a)
|
||||||
|
.filter(predicate)
|
||||||
|
.findAny()
|
||||||
|
.isPresent();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@SuppressWarnings({"static-method", "unchecked"})
|
@SuppressWarnings({"static-method", "unchecked"})
|
||||||
public Map<String, Object> postProcessOperationsWithModels(Map<String, Object> operations, List<Object> allModels) {
|
public Map<String, Object> postProcessOperationsWithModels(Map<String, Object> operations, List<Object> allModels) {
|
||||||
Map<String, Object> objs = (Map<String, Object>) operations.get("operations");
|
Map<String, Object> objs = (Map<String, Object>) operations.get("operations");
|
||||||
List<CodegenOperation> ops = (List<CodegenOperation>) objs.get("operation");
|
List<CodegenOperation> ops = (List<CodegenOperation>) objs.get("operation");
|
||||||
|
|
||||||
boolean hasDateTime = false;
|
|
||||||
boolean hasDate = false;
|
|
||||||
final Map<String, Set<String>> dependencies = new HashMap<>();
|
final Map<String, Set<String>> dependencies = new HashMap<>();
|
||||||
|
|
||||||
for (CodegenOperation op : ops) {
|
for (CodegenOperation op : ops) {
|
||||||
@@ -427,8 +441,6 @@ public class ElmClientCodegen extends DefaultCodegen implements CodegenConfig {
|
|||||||
for (CodegenParameter param : op.pathParams) {
|
for (CodegenParameter param : op.pathParams) {
|
||||||
final String var = paramToString("params", param, false, null);
|
final String var = paramToString("params", param, false, null);
|
||||||
path = path.replace("{" + param.paramName + "}", "\" ++ " + var + " ++ \"");
|
path = path.replace("{" + param.paramName + "}", "\" ++ " + var + " ++ \"");
|
||||||
hasDateTime = hasDateTime || param.isDateTime;
|
|
||||||
hasDate = hasDate || param.isDate;
|
|
||||||
}
|
}
|
||||||
op.path = ("\"" + path + "\"").replaceAll(" \\+\\+ \"\"", "");
|
op.path = ("\"" + path + "\"").replaceAll(" \\+\\+ \"\"", "");
|
||||||
} else {
|
} else {
|
||||||
@@ -437,8 +449,6 @@ public class ElmClientCodegen extends DefaultCodegen implements CodegenConfig {
|
|||||||
for (CodegenParameter param : op.pathParams) {
|
for (CodegenParameter param : op.pathParams) {
|
||||||
String str = paramToString("params", param, false, null);
|
String str = paramToString("params", param, false, null);
|
||||||
path = path.replace("{" + param.paramName + "}", str);
|
path = path.replace("{" + param.paramName + "}", str);
|
||||||
hasDateTime = hasDateTime || param.isDateTime;
|
|
||||||
hasDate = hasDate || param.isDate;
|
|
||||||
}
|
}
|
||||||
op.path = path;
|
op.path = path;
|
||||||
|
|
||||||
@@ -487,6 +497,7 @@ public class ElmClientCodegen extends DefaultCodegen implements CodegenConfig {
|
|||||||
elmImport.hasExposures = true;
|
elmImport.hasExposures = true;
|
||||||
elmImports.add(elmImport);
|
elmImports.add(elmImport);
|
||||||
}
|
}
|
||||||
|
final boolean hasDate = anyOperationParam(ops, param -> param.isDate);
|
||||||
if (hasDate) {
|
if (hasDate) {
|
||||||
final ElmImport elmImport = new ElmImport();
|
final ElmImport elmImport = new ElmImport();
|
||||||
elmImport.moduleName = "DateOnly";
|
elmImport.moduleName = "DateOnly";
|
||||||
@@ -495,6 +506,7 @@ public class ElmClientCodegen extends DefaultCodegen implements CodegenConfig {
|
|||||||
elmImport.hasExposures = true;
|
elmImport.hasExposures = true;
|
||||||
elmImports.add(elmImport);
|
elmImports.add(elmImport);
|
||||||
}
|
}
|
||||||
|
final boolean hasDateTime = anyOperationParam(ops, param -> param.isDateTime);
|
||||||
if (hasDateTime) {
|
if (hasDateTime) {
|
||||||
final ElmImport elmImport = new ElmImport();
|
final ElmImport elmImport = new ElmImport();
|
||||||
elmImport.moduleName = "DateTime";
|
elmImport.moduleName = "DateTime";
|
||||||
@@ -503,6 +515,15 @@ public class ElmClientCodegen extends DefaultCodegen implements CodegenConfig {
|
|||||||
elmImport.hasExposures = true;
|
elmImport.hasExposures = true;
|
||||||
elmImports.add(elmImport);
|
elmImports.add(elmImport);
|
||||||
}
|
}
|
||||||
|
final boolean hasUuid = anyOperationParam(ops, param -> param.isUuid);
|
||||||
|
if (hasUuid) {
|
||||||
|
final ElmImport elmImport = new ElmImport();
|
||||||
|
elmImport.moduleName = "Uuid";
|
||||||
|
elmImport.exposures = new TreeSet<>();
|
||||||
|
elmImport.exposures.add("Uuid");
|
||||||
|
elmImport.hasExposures = true;
|
||||||
|
elmImports.add(elmImport);
|
||||||
|
}
|
||||||
operations.put("elmImports", elmImports);
|
operations.put("elmImports", elmImports);
|
||||||
|
|
||||||
return operations;
|
return operations;
|
||||||
@@ -553,7 +574,7 @@ public class ElmClientCodegen extends DefaultCodegen implements CodegenConfig {
|
|||||||
}
|
}
|
||||||
|
|
||||||
String mapFn = null;
|
String mapFn = null;
|
||||||
if (param.isString || param.isUuid || param.isBinary || param.isByteArray) {
|
if (param.isString || param.isBinary || param.isByteArray) {
|
||||||
mapFn = "";
|
mapFn = "";
|
||||||
} else if (param.isBoolean) {
|
} else if (param.isBoolean) {
|
||||||
mapFn = "(\\val -> if val then \"true\" else \"false\")";
|
mapFn = "(\\val -> if val then \"true\" else \"false\")";
|
||||||
@@ -561,6 +582,8 @@ public class ElmClientCodegen extends DefaultCodegen implements CodegenConfig {
|
|||||||
mapFn = "DateTime.toString";
|
mapFn = "DateTime.toString";
|
||||||
} else if (param.isDate) {
|
} else if (param.isDate) {
|
||||||
mapFn = "DateOnly.toString";
|
mapFn = "DateOnly.toString";
|
||||||
|
} else if (param.isUuid) {
|
||||||
|
mapFn = "Uuid.toString";
|
||||||
} else if (ElmVersion.ELM_018.equals(elmVersion)) {
|
} else if (ElmVersion.ELM_018.equals(elmVersion)) {
|
||||||
mapFn = "toString";
|
mapFn = "toString";
|
||||||
} else if (param.isInteger || param.isLong) {
|
} else if (param.isInteger || param.isLong) {
|
||||||
|
|||||||
@@ -51,8 +51,6 @@ public class GoClientCodegen extends AbstractGoCodegen {
|
|||||||
// default HIDE_GENERATION_TIMESTAMP to true
|
// default HIDE_GENERATION_TIMESTAMP to true
|
||||||
hideGenerationTimestamp = Boolean.TRUE;
|
hideGenerationTimestamp = Boolean.TRUE;
|
||||||
|
|
||||||
cliOptions.add(new CliOption(CodegenConstants.PACKAGE_VERSION, "Go package version.")
|
|
||||||
.defaultValue("1.0.0"));
|
|
||||||
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_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(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)"));
|
||||||
|
|
||||||
|
|||||||
@@ -17,6 +17,7 @@
|
|||||||
|
|
||||||
package org.openapitools.codegen.languages;
|
package org.openapitools.codegen.languages;
|
||||||
|
|
||||||
|
import org.openapitools.codegen.CliOption;
|
||||||
import org.openapitools.codegen.CodegenConstants;
|
import org.openapitools.codegen.CodegenConstants;
|
||||||
import org.openapitools.codegen.CodegenType;
|
import org.openapitools.codegen.CodegenType;
|
||||||
import org.openapitools.codegen.SupportingFile;
|
import org.openapitools.codegen.SupportingFile;
|
||||||
@@ -30,16 +31,25 @@ public class GoServerCodegen extends AbstractGoCodegen {
|
|||||||
|
|
||||||
private static final Logger LOGGER = LoggerFactory.getLogger(GoServerCodegen.class);
|
private static final Logger LOGGER = LoggerFactory.getLogger(GoServerCodegen.class);
|
||||||
|
|
||||||
protected String apiVersion = "1.0.0";
|
protected String packageVersion = "1.0.0";
|
||||||
protected int serverPort = 8080;
|
protected int serverPort = 8080;
|
||||||
protected String projectName = "openapi-server";
|
protected String projectName = "openapi-server";
|
||||||
protected String apiPath = "go";
|
protected String sourceFolder = "go";
|
||||||
|
|
||||||
|
|
||||||
public GoServerCodegen() {
|
public GoServerCodegen() {
|
||||||
super();
|
super();
|
||||||
|
|
||||||
// set the output folder here
|
// set the output folder here
|
||||||
outputFolder = "generated-code/go";
|
outputFolder = "generated-code/go";
|
||||||
|
|
||||||
|
cliOptions.add(new CliOption(CodegenConstants.SOURCE_FOLDER, CodegenConstants.SOURCE_FOLDER_DESC)
|
||||||
|
.defaultValue(sourceFolder));
|
||||||
|
|
||||||
|
CliOption optServerPort = new CliOption("serverPort", "The network port the generated server binds to");
|
||||||
|
optServerPort.setType("int");
|
||||||
|
optServerPort.defaultValue(Integer.toString(serverPort));
|
||||||
|
cliOptions.add(optServerPort);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Models. You can write model files using the modelTemplateFiles map.
|
* Models. You can write model files using the modelTemplateFiles map.
|
||||||
@@ -88,21 +98,35 @@ public class GoServerCodegen extends AbstractGoCodegen {
|
|||||||
@Override
|
@Override
|
||||||
public void processOpts() {
|
public void processOpts() {
|
||||||
super.processOpts();
|
super.processOpts();
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Additional Properties. These values can be passed to the templates and
|
||||||
|
* are available in models, apis, and supporting files
|
||||||
|
*/
|
||||||
if (additionalProperties.containsKey(CodegenConstants.PACKAGE_NAME)) {
|
if (additionalProperties.containsKey(CodegenConstants.PACKAGE_NAME)) {
|
||||||
setPackageName((String) additionalProperties.get(CodegenConstants.PACKAGE_NAME));
|
setPackageName((String) additionalProperties.get(CodegenConstants.PACKAGE_NAME));
|
||||||
} else {
|
} else {
|
||||||
setPackageName("openapi");
|
setPackageName("openapi");
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
if (additionalProperties.containsKey(CodegenConstants.PACKAGE_VERSION)) {
|
||||||
* Additional Properties. These values can be passed to the templates and
|
this.setPackageVersion((String) additionalProperties.get(CodegenConstants.PACKAGE_VERSION));
|
||||||
* are available in models, apis, and supporting files
|
} else {
|
||||||
*/
|
additionalProperties.put(CodegenConstants.PACKAGE_VERSION, packageVersion);
|
||||||
additionalProperties.put("apiVersion", apiVersion);
|
}
|
||||||
additionalProperties.put("serverPort", serverPort);
|
|
||||||
additionalProperties.put("apiPath", apiPath);
|
if (additionalProperties.containsKey(CodegenConstants.SOURCE_FOLDER)) {
|
||||||
additionalProperties.put(CodegenConstants.PACKAGE_NAME, packageName);
|
this.setSourceFolder((String) additionalProperties.get(CodegenConstants.SOURCE_FOLDER));
|
||||||
|
} else {
|
||||||
|
additionalProperties.put(CodegenConstants.SOURCE_FOLDER, sourceFolder);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (additionalProperties.containsKey("serverPort") && additionalProperties.get("serverPort") instanceof Integer) {
|
||||||
|
this.setServerPort((int) additionalProperties.get("serverPort"));
|
||||||
|
} else {
|
||||||
|
additionalProperties.put("serverPort", serverPort);
|
||||||
|
}
|
||||||
|
|
||||||
modelPackage = packageName;
|
modelPackage = packageName;
|
||||||
apiPackage = packageName;
|
apiPackage = packageName;
|
||||||
@@ -115,14 +139,14 @@ public class GoServerCodegen extends AbstractGoCodegen {
|
|||||||
supportingFiles.add(new SupportingFile("openapi.mustache", "api", "openapi.yaml"));
|
supportingFiles.add(new SupportingFile("openapi.mustache", "api", "openapi.yaml"));
|
||||||
supportingFiles.add(new SupportingFile("main.mustache", "", "main.go"));
|
supportingFiles.add(new SupportingFile("main.mustache", "", "main.go"));
|
||||||
supportingFiles.add(new SupportingFile("Dockerfile.mustache", "", "Dockerfile"));
|
supportingFiles.add(new SupportingFile("Dockerfile.mustache", "", "Dockerfile"));
|
||||||
supportingFiles.add(new SupportingFile("routers.mustache", apiPath, "routers.go"));
|
supportingFiles.add(new SupportingFile("routers.mustache", sourceFolder, "routers.go"));
|
||||||
supportingFiles.add(new SupportingFile("logger.mustache", apiPath, "logger.go"));
|
supportingFiles.add(new SupportingFile("logger.mustache", sourceFolder, "logger.go"));
|
||||||
writeOptional(outputFolder, new SupportingFile("README.mustache", apiPath, "README.md"));
|
writeOptional(outputFolder, new SupportingFile("README.mustache", "", "README.md"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String apiPackage() {
|
public String apiPackage() {
|
||||||
return apiPath;
|
return sourceFolder;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -172,5 +196,16 @@ public class GoServerCodegen extends AbstractGoCodegen {
|
|||||||
public String modelFileFolder() {
|
public String modelFileFolder() {
|
||||||
return outputFolder + File.separator + apiPackage().replace('.', File.separatorChar);
|
return outputFolder + File.separator + apiPackage().replace('.', File.separatorChar);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setSourceFolder(String sourceFolder) {
|
||||||
|
this.sourceFolder = sourceFolder;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPackageVersion(String packageVersion) {
|
||||||
|
this.packageVersion = packageVersion;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setServerPort(int serverPort) {
|
||||||
|
this.serverPort = serverPort;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -116,18 +116,18 @@ public class JavaClientCodegen extends AbstractJavaCodegen
|
|||||||
cliOptions.add(CliOption.newBoolean(FEIGN_VERSION, "Version of OpenFeign: '10.x', '9.x' (default)"));
|
cliOptions.add(CliOption.newBoolean(FEIGN_VERSION, "Version of OpenFeign: '10.x', '9.x' (default)"));
|
||||||
cliOptions.add(CliOption.newBoolean(USE_REFLECTION_EQUALS_HASHCODE, "Use org.apache.commons.lang3.builder for equals and hashCode in the models. WARNING: This will fail under a security manager, unless the appropriate permissions are set up correctly and also there's potential performance impact."));
|
cliOptions.add(CliOption.newBoolean(USE_REFLECTION_EQUALS_HASHCODE, "Use org.apache.commons.lang3.builder for equals and hashCode in the models. WARNING: This will fail under a security manager, unless the appropriate permissions are set up correctly and also there's potential performance impact."));
|
||||||
|
|
||||||
supportedLibraries.put(JERSEY1, "HTTP client: Jersey client 1.19.4. JSON processing: Jackson 2.8.9. Enable Java6 support using '-DsupportJava6=true'. Enable gzip request encoding using '-DuseGzipFeature=true'.");
|
supportedLibraries.put(JERSEY1, "HTTP client: Jersey client 1.19.x. JSON processing: Jackson 2.8.x. Enable Java6 support using '-DsupportJava6=true'. Enable gzip request encoding using '-DuseGzipFeature=true'.");
|
||||||
supportedLibraries.put(FEIGN, "HTTP client: OpenFeign 9.4.0. JSON processing: Jackson 2.8.9. To enable OpenFeign 10.x, set the 'feignVersion' option to '10.x'");
|
supportedLibraries.put(FEIGN, "HTTP client: OpenFeign 9.x or 10.x. JSON processing: Jackson 2.8.x. To enable OpenFeign 10.x, set the 'feignVersion' option to '10.x'");
|
||||||
supportedLibraries.put(JERSEY2, "HTTP client: Jersey client 2.25.1. JSON processing: Jackson 2.8.9");
|
supportedLibraries.put(JERSEY2, "HTTP client: Jersey client 2.25.1. JSON processing: Jackson 2.8.x");
|
||||||
supportedLibraries.put(OKHTTP_GSON, "HTTP client: OkHttp 2.7.5. JSON processing: Gson 2.8.1. Enable Parcelable models on Android using '-DparcelableModel=true'. Enable gzip request encoding using '-DuseGzipFeature=true'.");
|
supportedLibraries.put(OKHTTP_GSON, "HTTP client: OkHttp 3.x. JSON processing: Gson 2.8.x. Enable Parcelable models on Android using '-DparcelableModel=true'. Enable gzip request encoding using '-DuseGzipFeature=true'.");
|
||||||
supportedLibraries.put(RETROFIT_1, "HTTP client: OkHttp 2.7.5. JSON processing: Gson 2.3.1 (Retrofit 1.9.0). IMPORTANT NOTE: retrofit1.x is no longer actively maintained so please upgrade to 'retrofit2' instead.");
|
supportedLibraries.put(RETROFIT_1, "HTTP client: OkHttp 2.x. JSON processing: Gson 2.x (Retrofit 1.9.0). IMPORTANT NOTE: retrofit1.x is no longer actively maintained so please upgrade to 'retrofit2' instead.");
|
||||||
supportedLibraries.put(RETROFIT_2, "HTTP client: OkHttp 3.8.0. JSON processing: Gson 2.6.1 (Retrofit 2.3.0). Enable the RxJava adapter using '-DuseRxJava[2]=true'. (RxJava 1.x or 2.x)");
|
supportedLibraries.put(RETROFIT_2, "HTTP client: OkHttp 3.x. JSON processing: Gson 2.x (Retrofit 2.3.0). Enable the RxJava adapter using '-DuseRxJava[2]=true'. (RxJava 1.x or 2.x)");
|
||||||
supportedLibraries.put(RESTTEMPLATE, "HTTP client: Spring RestTemplate 4.3.9-RELEASE. JSON processing: Jackson 2.8.9");
|
supportedLibraries.put(RESTTEMPLATE, "HTTP client: Spring RestTemplate 4.x. JSON processing: Jackson 2.8.x");
|
||||||
supportedLibraries.put(WEBCLIENT, "HTTP client: Spring WebClient 5.0.7-RELEASE. JSON processing: Jackson 2.9.5");
|
supportedLibraries.put(WEBCLIENT, "HTTP client: Spring WebClient 5.x. JSON processing: Jackson 2.9.x");
|
||||||
supportedLibraries.put(RESTEASY, "HTTP client: Resteasy client 3.1.3.Final. JSON processing: Jackson 2.8.9");
|
supportedLibraries.put(RESTEASY, "HTTP client: Resteasy client 3.x. JSON processing: Jackson 2.8.x");
|
||||||
supportedLibraries.put(VERTX, "HTTP client: VertX client 3.2.4. JSON processing: Jackson 2.8.9");
|
supportedLibraries.put(VERTX, "HTTP client: VertX client 3.x. JSON processing: Jackson 2.8.x");
|
||||||
supportedLibraries.put(GOOGLE_API_CLIENT, "HTTP client: Google API client 1.23.0. JSON processing: Jackson 2.8.9");
|
supportedLibraries.put(GOOGLE_API_CLIENT, "HTTP client: Google API client 1.x. JSON processing: Jackson 2.8.x");
|
||||||
supportedLibraries.put(REST_ASSURED, "HTTP client: rest-assured : 3.1.0. JSON processing: Gson 2.6.1. Only for Java8");
|
supportedLibraries.put(REST_ASSURED, "HTTP client: rest-assured : 3.x. JSON processing: Gson 2.x. Only for Java8");
|
||||||
|
|
||||||
CliOption libraryOption = new CliOption(CodegenConstants.LIBRARY, "library template (sub-template) to use");
|
CliOption libraryOption = new CliOption(CodegenConstants.LIBRARY, "library template (sub-template) to use");
|
||||||
libraryOption.setEnum(supportedLibraries);
|
libraryOption.setEnum(supportedLibraries);
|
||||||
|
|||||||
@@ -51,8 +51,8 @@ public class JavascriptClientCodegen extends DefaultCodegen implements CodegenCo
|
|||||||
|
|
||||||
final String[][] JAVASCRIPT_SUPPORTING_FILES = new String[][]{
|
final String[][] JAVASCRIPT_SUPPORTING_FILES = new String[][]{
|
||||||
new String[]{"package.mustache", "package.json"},
|
new String[]{"package.mustache", "package.json"},
|
||||||
new String[]{"index.mustache", "src/index.js"},
|
// new String[]{"index.mustache", "src/index.js", },
|
||||||
new String[]{"ApiClient.mustache", "src/ApiClient.js"},
|
// new String[]{"ApiClient.mustache", "src/ApiClient.js"},
|
||||||
new String[]{"git_push.sh.mustache", "git_push.sh"},
|
new String[]{"git_push.sh.mustache", "git_push.sh"},
|
||||||
new String[]{"README.mustache", "README.md"},
|
new String[]{"README.mustache", "README.md"},
|
||||||
new String[]{"mocha.opts", "mocha.opts"},
|
new String[]{"mocha.opts", "mocha.opts"},
|
||||||
@@ -61,8 +61,8 @@ public class JavascriptClientCodegen extends DefaultCodegen implements CodegenCo
|
|||||||
|
|
||||||
final String[][] JAVASCRIPT_ES6_SUPPORTING_FILES = new String[][]{
|
final String[][] JAVASCRIPT_ES6_SUPPORTING_FILES = new String[][]{
|
||||||
new String[]{"package.mustache", "package.json"},
|
new String[]{"package.mustache", "package.json"},
|
||||||
new String[]{"index.mustache", "src/index.js"},
|
// new String[]{"index.mustache", "src/index.js"},
|
||||||
new String[]{"ApiClient.mustache", "src/ApiClient.js"},
|
// new String[]{"ApiClient.mustache", "src/ApiClient.js"},
|
||||||
new String[]{"git_push.sh.mustache", "git_push.sh"},
|
new String[]{"git_push.sh.mustache", "git_push.sh"},
|
||||||
new String[]{"README.mustache", "README.md"},
|
new String[]{"README.mustache", "README.md"},
|
||||||
new String[]{"mocha.opts", "mocha.opts"},
|
new String[]{"mocha.opts", "mocha.opts"},
|
||||||
@@ -85,7 +85,7 @@ public class JavascriptClientCodegen extends DefaultCodegen implements CodegenCo
|
|||||||
protected String modelDocPath = "docs/";
|
protected String modelDocPath = "docs/";
|
||||||
protected String apiTestPath = "api/";
|
protected String apiTestPath = "api/";
|
||||||
protected String modelTestPath = "model/";
|
protected String modelTestPath = "model/";
|
||||||
protected boolean useES6 = true; // default is ES5
|
protected boolean useES6 = true; // default is ES6
|
||||||
private String modelPropertyNaming = "camelCase";
|
private String modelPropertyNaming = "camelCase";
|
||||||
|
|
||||||
public JavascriptClientCodegen() {
|
public JavascriptClientCodegen() {
|
||||||
@@ -205,7 +205,7 @@ public class JavascriptClientCodegen extends DefaultCodegen implements CodegenCo
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getHelp() {
|
public String getHelp() {
|
||||||
return "Generates a Javascript client library.";
|
return "Generates a JavaScript client library.";
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -337,6 +337,10 @@ public class JavascriptClientCodegen extends DefaultCodegen implements CodegenCo
|
|||||||
for (String[] supportingTemplateFile : supportingTemplateFiles) {
|
for (String[] supportingTemplateFile : supportingTemplateFiles) {
|
||||||
supportingFiles.add(new SupportingFile(supportingTemplateFile[0], "", supportingTemplateFile[1]));
|
supportingFiles.add(new SupportingFile(supportingTemplateFile[0], "", supportingTemplateFile[1]));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
supportingFiles.add(new SupportingFile("index.mustache", createPath(sourceFolder, invokerPackage), "index.js"));
|
||||||
|
supportingFiles.add(new SupportingFile("ApiClient.mustache", createPath(sourceFolder, invokerPackage), "ApiClient.js"));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -373,12 +377,12 @@ public class JavascriptClientCodegen extends DefaultCodegen implements CodegenCo
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String apiTestFileFolder() {
|
public String apiTestFileFolder() {
|
||||||
return (outputFolder + "/test/" + apiTestPath).replace('/', File.separatorChar);
|
return createPath(outputFolder, "test", invokerPackage, apiTestPath);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String modelTestFileFolder() {
|
public String modelTestFileFolder() {
|
||||||
return (outputFolder + "/test/" + modelTestPath).replace('/', File.separatorChar);
|
return createPath(outputFolder, "test", invokerPackage, modelTestPath);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -788,7 +792,7 @@ public class JavascriptClientCodegen extends DefaultCodegen implements CodegenCo
|
|||||||
* @param type Primitive type
|
* @param type Primitive type
|
||||||
* @return Normalized type
|
* @return Normalized type
|
||||||
*/
|
*/
|
||||||
public String normalizeType(String type) {
|
private String normalizeType(String type) {
|
||||||
return type.replaceAll("\\b(Boolean|Integer|Number|String|Date|Blob)\\b", "'$1'");
|
return type.replaceAll("\\b(Boolean|Integer|Number|String|Date|Blob)\\b", "'$1'");
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -867,10 +871,11 @@ public class JavascriptClientCodegen extends DefaultCodegen implements CodegenCo
|
|||||||
return codegenModel;
|
return codegenModel;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
private String sanitizePath(String p) {
|
private String sanitizePath(String p) {
|
||||||
//prefer replace a ', instead of a fuLL URL encode for readability
|
//prefer replace a ', instead of a fuLL URL encode for readability
|
||||||
return p.replaceAll("'", "%27");
|
return p.replaceAll("'", "%27");
|
||||||
}
|
}*/
|
||||||
|
|
||||||
private String trimBrackets(String s) {
|
private String trimBrackets(String s) {
|
||||||
if (s != null) {
|
if (s != null) {
|
||||||
@@ -959,7 +964,7 @@ public class JavascriptClientCodegen extends DefaultCodegen implements CodegenCo
|
|||||||
if (operations != null) {
|
if (operations != null) {
|
||||||
List<CodegenOperation> ops = (List<CodegenOperation>) operations.get("operation");
|
List<CodegenOperation> ops = (List<CodegenOperation>) operations.get("operation");
|
||||||
for (CodegenOperation operation : ops) {
|
for (CodegenOperation operation : ops) {
|
||||||
List<String> argList = new ArrayList<String>();
|
List<String> argList = new ArrayList<>();
|
||||||
boolean hasOptionalParams = false;
|
boolean hasOptionalParams = false;
|
||||||
for (CodegenParameter p : operation.allParams) {
|
for (CodegenParameter p : operation.allParams) {
|
||||||
if (p.required) {
|
if (p.required) {
|
||||||
@@ -976,7 +981,7 @@ public class JavascriptClientCodegen extends DefaultCodegen implements CodegenCo
|
|||||||
|
|
||||||
if (hasOptionalParams) {
|
if (hasOptionalParams) {
|
||||||
argList.add("opts");
|
argList.add("opts");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!usePromises) {
|
if (!usePromises) {
|
||||||
argList.add("callback");
|
argList.add("callback");
|
||||||
@@ -1014,7 +1019,7 @@ public class JavascriptClientCodegen extends DefaultCodegen implements CodegenCo
|
|||||||
// NOTE: can't use 'mandatory' as it is built from ModelImpl.getRequired(), which sorts names
|
// NOTE: can't use 'mandatory' as it is built from ModelImpl.getRequired(), which sorts names
|
||||||
// alphabetically and in any case the document order of 'required' and 'properties' can differ.
|
// alphabetically and in any case the document order of 'required' and 'properties' can differ.
|
||||||
List<CodegenProperty> required = new ArrayList<>();
|
List<CodegenProperty> required = new ArrayList<>();
|
||||||
List<CodegenProperty> allRequired = supportsInheritance || supportsMixins ? new ArrayList<CodegenProperty>() : required;
|
List<CodegenProperty> allRequired = supportsInheritance || supportsMixins ? new ArrayList<>() : required;
|
||||||
cm.vendorExtensions.put("x-required", required);
|
cm.vendorExtensions.put("x-required", required);
|
||||||
cm.vendorExtensions.put("x-all-required", allRequired);
|
cm.vendorExtensions.put("x-all-required", allRequired);
|
||||||
|
|
||||||
@@ -1120,15 +1125,6 @@ public class JavascriptClientCodegen extends DefaultCodegen implements CodegenCo
|
|||||||
return codegenModel;
|
return codegenModel;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static String sanitizePackageName(String packageName) { // FIXME parameter should not be assigned. Also declare it as "final"
|
|
||||||
packageName = packageName.trim();
|
|
||||||
packageName = packageName.replaceAll("[^a-zA-Z0-9_\\.]", "_");
|
|
||||||
if (Strings.isNullOrEmpty(packageName)) {
|
|
||||||
return "invalidPackageName";
|
|
||||||
}
|
|
||||||
return packageName;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toEnumName(CodegenProperty property) {
|
public String toEnumName(CodegenProperty property) {
|
||||||
return sanitizeName(camelize(property.name)) + "Enum";
|
return sanitizeName(camelize(property.name)) + "Enum";
|
||||||
@@ -1160,12 +1156,18 @@ public class JavascriptClientCodegen extends DefaultCodegen implements CodegenCo
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String escapeQuotationMark(String input) {
|
public String escapeQuotationMark(String input) {
|
||||||
|
if (input == null) {
|
||||||
|
return "";
|
||||||
|
}
|
||||||
// remove ', " to avoid code injection
|
// remove ', " to avoid code injection
|
||||||
return input.replace("\"", "").replace("'", "");
|
return input.replace("\"", "").replace("'", "");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String escapeUnsafeCharacters(String input) {
|
public String escapeUnsafeCharacters(String input) {
|
||||||
|
if (input == null) {
|
||||||
|
return "";
|
||||||
|
}
|
||||||
return input.replace("*/", "*_/").replace("/*", "/_*");
|
return input.replace("*/", "*_/").replace("/*", "/_*");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -164,7 +164,12 @@ public class JavascriptFlowtypedClientCodegen extends AbstractTypeScriptClientCo
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (additionalProperties.containsKey(SNAPSHOT) && Boolean.valueOf(additionalProperties.get(SNAPSHOT).toString())) {
|
if (additionalProperties.containsKey(SNAPSHOT) && Boolean.valueOf(additionalProperties.get(SNAPSHOT).toString())) {
|
||||||
this.setNpmVersion(npmVersion + "-SNAPSHOT." + SNAPSHOT_SUFFIX_FORMAT.format(new Date()));
|
if (npmVersion.toUpperCase(Locale.ROOT).matches("^.*-SNAPSHOT$")) {
|
||||||
|
this.setNpmVersion(npmVersion + "." + SNAPSHOT_SUFFIX_FORMAT.format(new Date()));
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
this.setNpmVersion(npmVersion + "-SNAPSHOT." + SNAPSHOT_SUFFIX_FORMAT.format(new Date()));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
additionalProperties.put(NPM_VERSION, npmVersion);
|
additionalProperties.put(NPM_VERSION, npmVersion);
|
||||||
|
|
||||||
|
|||||||
@@ -44,7 +44,7 @@ public class KotlinSpringServerCodegen extends AbstractKotlinCodegen
|
|||||||
LoggerFactory.getLogger(KotlinSpringServerCodegen.class);
|
LoggerFactory.getLogger(KotlinSpringServerCodegen.class);
|
||||||
|
|
||||||
private static final HashSet<String> VARIABLE_RESERVED_WORDS =
|
private static final HashSet<String> VARIABLE_RESERVED_WORDS =
|
||||||
new HashSet<String>(Arrays.asList(
|
new HashSet<>(Arrays.asList(
|
||||||
"ApiClient",
|
"ApiClient",
|
||||||
"ApiException",
|
"ApiException",
|
||||||
"ApiResponse"
|
"ApiResponse"
|
||||||
@@ -109,6 +109,10 @@ public class KotlinSpringServerCodegen extends AbstractKotlinCodegen
|
|||||||
importMapping.put("Date", "java.time.LocalDate");
|
importMapping.put("Date", "java.time.LocalDate");
|
||||||
importMapping.put("DateTime", "java.time.OffsetDateTime");
|
importMapping.put("DateTime", "java.time.OffsetDateTime");
|
||||||
|
|
||||||
|
// use resource for file handling
|
||||||
|
typeMapping.put("file", "org.springframework.core.io.Resource");
|
||||||
|
|
||||||
|
|
||||||
languageSpecificPrimitives.addAll(Arrays.asList(
|
languageSpecificPrimitives.addAll(Arrays.asList(
|
||||||
"Any",
|
"Any",
|
||||||
"Byte",
|
"Byte",
|
||||||
@@ -562,4 +566,33 @@ public class KotlinSpringServerCodegen extends AbstractKotlinCodegen
|
|||||||
|
|
||||||
return m;
|
return m;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Output the proper model name (capitalized).
|
||||||
|
* In case the name belongs to the TypeSystem it won't be renamed.
|
||||||
|
*
|
||||||
|
* @param name the name of the model
|
||||||
|
* @return capitalized model name
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public String toModelName(final String name) {
|
||||||
|
// Allow for explicitly configured spring.*
|
||||||
|
if (name.startsWith("org.springframework.") ) {
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
return super.toModelName(name);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check the type to see if it needs import the library/module/package
|
||||||
|
*
|
||||||
|
* @param type name of the type
|
||||||
|
* @return true if the library/module/package of the corresponding type needs to be imported
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
protected boolean needToImport(String type) {
|
||||||
|
// provides extra protection against improperly trying to import language primitives and java types
|
||||||
|
boolean imports = !type.startsWith("org.springframework.") && super.needToImport(type);
|
||||||
|
return imports;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -38,6 +38,8 @@ import java.util.*;
|
|||||||
import java.util.Map.Entry;
|
import java.util.Map.Entry;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
|
import static org.openapitools.codegen.utils.StringUtils.*;
|
||||||
|
|
||||||
public class NodeJSServerCodegen extends DefaultCodegen implements CodegenConfig {
|
public class NodeJSServerCodegen extends DefaultCodegen implements CodegenConfig {
|
||||||
|
|
||||||
private static final Logger LOGGER = LoggerFactory.getLogger(NodeJSServerCodegen.class);
|
private static final Logger LOGGER = LoggerFactory.getLogger(NodeJSServerCodegen.class);
|
||||||
@@ -160,7 +162,7 @@ public class NodeJSServerCodegen extends DefaultCodegen implements CodegenConfig
|
|||||||
if (name.length() == 0) {
|
if (name.length() == 0) {
|
||||||
return "DefaultController";
|
return "DefaultController";
|
||||||
}
|
}
|
||||||
return initialCaps(name);
|
return camelize(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -30,6 +30,8 @@ import java.io.UnsupportedEncodingException;
|
|||||||
import java.net.URLEncoder;
|
import java.net.URLEncoder;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
||||||
|
import static org.openapitools.codegen.utils.StringUtils.*;
|
||||||
|
|
||||||
public class PhpSlimServerCodegen extends AbstractPhpCodegen {
|
public class PhpSlimServerCodegen extends AbstractPhpCodegen {
|
||||||
private static final Logger LOGGER = LoggerFactory.getLogger(PhpSlimServerCodegen.class);
|
private static final Logger LOGGER = LoggerFactory.getLogger(PhpSlimServerCodegen.class);
|
||||||
|
|
||||||
@@ -175,7 +177,7 @@ public class PhpSlimServerCodegen extends AbstractPhpCodegen {
|
|||||||
if (name.length() == 0) {
|
if (name.length() == 0) {
|
||||||
return toAbstractName("DefaultApi");
|
return toAbstractName("DefaultApi");
|
||||||
}
|
}
|
||||||
return toAbstractName(initialCaps(name) + "Api");
|
return toAbstractName(camelize(name) + "Api");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -183,7 +185,7 @@ public class PhpSlimServerCodegen extends AbstractPhpCodegen {
|
|||||||
if (name.length() == 0) {
|
if (name.length() == 0) {
|
||||||
return "DefaultApiTest";
|
return "DefaultApiTest";
|
||||||
}
|
}
|
||||||
return initialCaps(name) + "ApiTest";
|
return camelize(name) + "ApiTest";
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -324,10 +324,10 @@ public class PythonAbstractConnexionServerCodegen extends DefaultCodegen impleme
|
|||||||
// Fix path parameters to be in snake_case
|
// Fix path parameters to be in snake_case
|
||||||
if (pathname.contains("{")) {
|
if (pathname.contains("{")) {
|
||||||
String fixedPath = new String();
|
String fixedPath = new String();
|
||||||
for (String token: pathname.substring(1).split("/")) {
|
for (String token : pathname.substring(1).split("/")) {
|
||||||
if (token.startsWith("{")) {
|
if (token.startsWith("{")) {
|
||||||
String snake_case_token = "{" + this.toParamName(token.substring(1, token.length()-1)) + "}";
|
String snake_case_token = "{" + this.toParamName(token.substring(1, token.length() - 1)) + "}";
|
||||||
if(!token.equals(snake_case_token)) {
|
if (!token.equals(snake_case_token)) {
|
||||||
token = snake_case_token;
|
token = snake_case_token;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -336,6 +336,7 @@ public class PythonAbstractConnexionServerCodegen extends DefaultCodegen impleme
|
|||||||
if (!fixedPath.equals(pathname)) {
|
if (!fixedPath.equals(pathname)) {
|
||||||
LOGGER.warn("Path '" + pathname + "' is not consistant with Python variable names. It will be replaced by '" + fixedPath + "'");
|
LOGGER.warn("Path '" + pathname + "' is not consistant with Python variable names. It will be replaced by '" + fixedPath + "'");
|
||||||
paths.remove(pathname);
|
paths.remove(pathname);
|
||||||
|
path.addExtension("x-python-connexion-openapi-name", pathname);
|
||||||
paths.put(fixedPath, path);
|
paths.put(fixedPath, path);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -359,11 +360,12 @@ public class PythonAbstractConnexionServerCodegen extends DefaultCodegen impleme
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
if (operation.getParameters() != null) {
|
if (operation.getParameters() != null) {
|
||||||
for (Parameter parameter: operation.getParameters()) {
|
for (Parameter parameter : operation.getParameters()) {
|
||||||
String swaggerParameterName = parameter.getName();
|
String swaggerParameterName = parameter.getName();
|
||||||
String pythonParameterName = this.toParamName(swaggerParameterName);
|
String pythonParameterName = this.toParamName(swaggerParameterName);
|
||||||
if (!swaggerParameterName.equals(pythonParameterName)) {
|
if (!swaggerParameterName.equals(pythonParameterName)) {
|
||||||
LOGGER.warn("Parameter name '" + swaggerParameterName + "' is not consistant with Python variable names. It will be replaced by '" + pythonParameterName + "'");
|
LOGGER.warn("Parameter name '" + swaggerParameterName + "' is not consistant with Python variable names. It will be replaced by '" + pythonParameterName + "'");
|
||||||
|
parameter.addExtension("x-python-connexion-openapi-name", swaggerParameterName);
|
||||||
parameter.setName(pythonParameterName);
|
parameter.setName(pythonParameterName);
|
||||||
}
|
}
|
||||||
if (swaggerParameterName.isEmpty()) {
|
if (swaggerParameterName.isEmpty()) {
|
||||||
@@ -377,8 +379,7 @@ public class PythonAbstractConnexionServerCodegen extends DefaultCodegen impleme
|
|||||||
String bodyParameterName = "body";
|
String bodyParameterName = "body";
|
||||||
if (operation.getExtensions() != null && operation.getExtensions().containsKey("x-codegen-request-body-name")) {
|
if (operation.getExtensions() != null && operation.getExtensions().containsKey("x-codegen-request-body-name")) {
|
||||||
bodyParameterName = (String) operation.getExtensions().get("x-codegen-request-body-name");
|
bodyParameterName = (String) operation.getExtensions().get("x-codegen-request-body-name");
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
// Used by code generator
|
// Used by code generator
|
||||||
operation.addExtension("x-codegen-request-body-name", bodyParameterName);
|
operation.addExtension("x-codegen-request-body-name", bodyParameterName);
|
||||||
}
|
}
|
||||||
@@ -392,7 +393,7 @@ public class PythonAbstractConnexionServerCodegen extends DefaultCodegen impleme
|
|||||||
// Sort path names after variable name fix
|
// Sort path names after variable name fix
|
||||||
List<String> fixedPathnames = new ArrayList(paths.keySet());
|
List<String> fixedPathnames = new ArrayList(paths.keySet());
|
||||||
Collections.sort(fixedPathnames);
|
Collections.sort(fixedPathnames);
|
||||||
for (String pathname: fixedPathnames) {
|
for (String pathname : fixedPathnames) {
|
||||||
PathItem pathItem = paths.remove(pathname);
|
PathItem pathItem = paths.remove(pathname);
|
||||||
paths.put(pathname, pathItem);
|
paths.put(pathname, pathItem);
|
||||||
}
|
}
|
||||||
@@ -401,7 +402,7 @@ public class PythonAbstractConnexionServerCodegen extends DefaultCodegen impleme
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void addSecurityExtension(SecurityScheme securityScheme, String extensionName, String functionName) {
|
private void addSecurityExtension(SecurityScheme securityScheme, String extensionName, String functionName) {
|
||||||
if (securityScheme.getExtensions() == null || ! securityScheme.getExtensions().containsKey(extensionName)) {
|
if (securityScheme.getExtensions() == null || !securityScheme.getExtensions().containsKey(extensionName)) {
|
||||||
securityScheme.addExtension(extensionName, functionName);
|
securityScheme.addExtension(extensionName, functionName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -410,18 +411,17 @@ public class PythonAbstractConnexionServerCodegen extends DefaultCodegen impleme
|
|||||||
Components components = openAPI.getComponents();
|
Components components = openAPI.getComponents();
|
||||||
if (components != null && components.getSecuritySchemes() != null) {
|
if (components != null && components.getSecuritySchemes() != null) {
|
||||||
Map<String, SecurityScheme> securitySchemes = components.getSecuritySchemes();
|
Map<String, SecurityScheme> securitySchemes = components.getSecuritySchemes();
|
||||||
for(String securityName: securitySchemes.keySet()) {
|
for (String securityName : securitySchemes.keySet()) {
|
||||||
SecurityScheme securityScheme = securitySchemes.get(securityName);
|
SecurityScheme securityScheme = securitySchemes.get(securityName);
|
||||||
String baseFunctionName = controllerPackage + ".security_controller_.";
|
String baseFunctionName = controllerPackage + ".security_controller_.";
|
||||||
switch(securityScheme.getType()) {
|
switch (securityScheme.getType()) {
|
||||||
case APIKEY:
|
case APIKEY:
|
||||||
addSecurityExtension(securityScheme, "x-apikeyInfoFunc", baseFunctionName + "info_from_" + securityName);
|
addSecurityExtension(securityScheme, "x-apikeyInfoFunc", baseFunctionName + "info_from_" + securityName);
|
||||||
break;
|
break;
|
||||||
case HTTP:
|
case HTTP:
|
||||||
if ("basic".equals(securityScheme.getScheme())) {
|
if ("basic".equals(securityScheme.getScheme())) {
|
||||||
addSecurityExtension(securityScheme, "x-basicInfoFunc", baseFunctionName + "info_from_" + securityName);
|
addSecurityExtension(securityScheme, "x-basicInfoFunc", baseFunctionName + "info_from_" + securityName);
|
||||||
}
|
} else if ("bearer".equals(securityScheme.getScheme())) {
|
||||||
else if ("bearer".equals(securityScheme.getScheme())) {
|
|
||||||
addSecurityExtension(securityScheme, "x-bearerInfoFunc", baseFunctionName + "info_from_" + securityName);
|
addSecurityExtension(securityScheme, "x-bearerInfoFunc", baseFunctionName + "info_from_" + securityName);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@@ -474,6 +474,68 @@ public class PythonAbstractConnexionServerCodegen extends DefaultCodegen impleme
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Map<String, Object> postProcessSupportingFileData(Map<String, Object> objs) {
|
public Map<String, Object> postProcessSupportingFileData(Map<String, Object> objs) {
|
||||||
|
// XXX - Revert the original parameter (and path) names to make sure we have
|
||||||
|
// a consistent REST interface across other server/client languages:
|
||||||
|
//
|
||||||
|
// XXX - Reverts `x-python-connexion-openapi-name` back to the original (query/path) parameter name.
|
||||||
|
// We do not want to have our REST API itself being converted to pythonic params.
|
||||||
|
// This would be incompatible with other server implementations.
|
||||||
|
OpenAPI openAPI = (OpenAPI) objs.get("openAPI");
|
||||||
|
Map<String, PathItem> paths = openAPI.getPaths();
|
||||||
|
if (paths != null) {
|
||||||
|
List<String> pathnames = new ArrayList(paths.keySet());
|
||||||
|
for (String pythonPathname : pathnames) {
|
||||||
|
PathItem path = paths.get(pythonPathname);
|
||||||
|
|
||||||
|
// Fix path parameters back to original casing
|
||||||
|
Map<String, Object> pathExtensions = path.getExtensions();
|
||||||
|
if (pathExtensions != null) {
|
||||||
|
// Get and remove the (temporary) vendor extension
|
||||||
|
String openapiPathname = (String) pathExtensions.remove("x-python-connexion-openapi-name");
|
||||||
|
if (openapiPathname != null && openapiPathname != pythonPathname) {
|
||||||
|
LOGGER.info("Path '" + pythonPathname + "' is not consistant with the original OpenAPI definition. It will be replaced back by '" + openapiPathname + "'");
|
||||||
|
paths.remove(pythonPathname);
|
||||||
|
paths.put(openapiPathname, path);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Map<HttpMethod, Operation> operationMap = path.readOperationsMap();
|
||||||
|
if (operationMap != null) {
|
||||||
|
for (HttpMethod method : operationMap.keySet()) {
|
||||||
|
Operation operation = operationMap.get(method);
|
||||||
|
if (operation.getParameters() != null) {
|
||||||
|
for (Parameter parameter : operation.getParameters()) {
|
||||||
|
Map<String, Object> parameterExtensions = parameter.getExtensions();
|
||||||
|
if (parameterExtensions != null) {
|
||||||
|
// Get and remove the (temporary) vendor extension
|
||||||
|
String swaggerParameterName = (String) parameterExtensions.remove("x-python-connexion-openapi-name");
|
||||||
|
if (swaggerParameterName != null) {
|
||||||
|
String pythonParameterName = parameter.getName();
|
||||||
|
if (swaggerParameterName != pythonParameterName) {
|
||||||
|
LOGGER.info("Reverting name of parameter '" + pythonParameterName + "' of operation '" + operation.getOperationId() + "' back to '" + swaggerParameterName + "'");
|
||||||
|
parameter.setName(swaggerParameterName);
|
||||||
|
} else {
|
||||||
|
LOGGER.debug("Name of parameter '" + pythonParameterName + "' of operation '" + operation.getOperationId() + "' was unchanged.");
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
LOGGER.debug("x-python-connexion-openapi-name was not set on parameter '" + parameter.getName() + "' of operation '" + operation.getOperationId() + "'");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Sort path names after variable name fix
|
||||||
|
List<String> recoveredPathnames = new ArrayList(paths.keySet());
|
||||||
|
Collections.sort(recoveredPathnames);
|
||||||
|
for (String pathname : recoveredPathnames) {
|
||||||
|
PathItem pathItem = paths.remove(pathname);
|
||||||
|
paths.put(pathname, pathItem);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
generateYAMLSpecFile(objs);
|
generateYAMLSpecFile(objs);
|
||||||
|
|
||||||
for (Map<String, Object> operations : getOperations(objs)) {
|
for (Map<String, Object> operations : getOperations(objs)) {
|
||||||
@@ -581,6 +643,7 @@ public class PythonAbstractConnexionServerCodegen extends DefaultCodegen impleme
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the default value of the property
|
* Return the default value of the property
|
||||||
|
*
|
||||||
* @param p OpenAPI property object
|
* @param p OpenAPI property object
|
||||||
* @return string presentation of the default value of the property
|
* @return string presentation of the default value of the property
|
||||||
*/
|
*/
|
||||||
@@ -691,8 +754,7 @@ public class PythonAbstractConnexionServerCodegen extends DefaultCodegen impleme
|
|||||||
if (example == null) {
|
if (example == null) {
|
||||||
if (Boolean.TRUE.equals(p.isListContainer)) {
|
if (Boolean.TRUE.equals(p.isListContainer)) {
|
||||||
example = "[]";
|
example = "[]";
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
example = "None";
|
example = "None";
|
||||||
}
|
}
|
||||||
} else if (Boolean.TRUE.equals(p.isListContainer)) {
|
} else if (Boolean.TRUE.equals(p.isListContainer)) {
|
||||||
@@ -799,7 +861,7 @@ public class PythonAbstractConnexionServerCodegen extends DefaultCodegen impleme
|
|||||||
for (CodegenOperation operation : operationList) {
|
for (CodegenOperation operation : operationList) {
|
||||||
Map<String, String> skipTests = new HashMap<>();
|
Map<String, String> skipTests = new HashMap<>();
|
||||||
// Set flag to deactivate tests due to connexion issue.
|
// Set flag to deactivate tests due to connexion issue.
|
||||||
if (operation.consumes != null ) {
|
if (operation.consumes != null) {
|
||||||
if (operation.consumes.size() == 1) {
|
if (operation.consumes.size() == 1) {
|
||||||
Map<String, String> consume = operation.consumes.get(0);
|
Map<String, String> consume = operation.consumes.get(0);
|
||||||
if (!("application/json".equals(consume.get(MEDIA_TYPE))
|
if (!("application/json".equals(consume.get(MEDIA_TYPE))
|
||||||
@@ -810,8 +872,7 @@ public class PythonAbstractConnexionServerCodegen extends DefaultCodegen impleme
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
operation.vendorExtensions.put("x-prefered-consume", consume);
|
operation.vendorExtensions.put("x-prefered-consume", consume);
|
||||||
}
|
} else if (operation.consumes.size() > 1) {
|
||||||
else if (operation.consumes.size() > 1) {
|
|
||||||
Map<String, String> consume = operation.consumes.get(0);
|
Map<String, String> consume = operation.consumes.get(0);
|
||||||
skipTests.put("reason", "Connexion does not support multiple consummes. See https://github.com/zalando/connexion/pull/760");
|
skipTests.put("reason", "Connexion does not support multiple consummes. See https://github.com/zalando/connexion/pull/760");
|
||||||
operation.vendorExtensions.put("x-prefered-consume", consume);
|
operation.vendorExtensions.put("x-prefered-consume", consume);
|
||||||
@@ -819,8 +880,7 @@ public class PythonAbstractConnexionServerCodegen extends DefaultCodegen impleme
|
|||||||
operation.isMultipart = Boolean.TRUE;
|
operation.isMultipart = Boolean.TRUE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
// A body without consumes means '*/*' has been used instead of application/json
|
// A body without consumes means '*/*' has been used instead of application/json
|
||||||
if (operation.bodyParam != null) {
|
if (operation.bodyParam != null) {
|
||||||
Map<String, String> consume = new HashMap<>();
|
Map<String, String> consume = new HashMap<>();
|
||||||
@@ -830,19 +890,19 @@ public class PythonAbstractConnexionServerCodegen extends DefaultCodegen impleme
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Choose to consume 'application/json' if available, else choose the last one.
|
// Choose to consume 'application/json' if available, else choose the last one.
|
||||||
if (operation.produces != null ) {
|
if (operation.produces != null) {
|
||||||
for (Map<String, String> produce: operation.produces) {
|
for (Map<String, String> produce : operation.produces) {
|
||||||
operation.vendorExtensions.put("x-prefered-produce", produce);
|
operation.vendorExtensions.put("x-prefered-produce", produce);
|
||||||
if (produce.get(MEDIA_TYPE).equals("application/json")) {
|
if (produce.get(MEDIA_TYPE).equals("application/json")) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (! skipTests.isEmpty()) {
|
if (!skipTests.isEmpty()) {
|
||||||
operation.vendorExtensions.put("x-skip-test", skipTests);
|
operation.vendorExtensions.put("x-skip-test", skipTests);
|
||||||
}
|
}
|
||||||
if (operation.requestBodyExamples != null) {
|
if (operation.requestBodyExamples != null) {
|
||||||
for (Map<String, String> example: operation.requestBodyExamples) {
|
for (Map<String, String> example : operation.requestBodyExamples) {
|
||||||
if (example.get("contentType") != null && example.get("contentType").equals("application/json")) {
|
if (example.get("contentType") != null && example.get("contentType").equals("application/json")) {
|
||||||
operation.bodyParam.example = example.get("example");
|
operation.bodyParam.example = example.get("example");
|
||||||
}
|
}
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user