Compare commits

..

2 Commits

Author SHA1 Message Date
William Cheng
745868e925 Add petstore samples 2019-03-20 22:29:29 +08:00
William Cheng
b74d25d414 add back scripts for security tests 2019-03-20 19:04:28 +08:00
3496 changed files with 48669 additions and 50058 deletions

View File

@@ -1 +1 @@
oracle64-1.8.0.152
oracle64-1.8.0.152

View File

@@ -133,16 +133,18 @@ after_success:
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;
echo "Finished ./gradlew uploadArchives";
#./gradlew publishPlugins;
#echo "Finished ./gradlew publishPlugins (plugin portal)";
popd;
elif ([[ "$TRAVIS_BRANCH" =~ ^[0-9]+\.[0-9]+\.x$ ]]) ; then
mvn clean deploy --settings CI/settings.xml;
echo "Finished mvn clean deploy for $TRAVIS_BRANCH";
pushd .;
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;
echo "Finished ./gradlew uploadArchives";
#./gradlew publishPlugins;
#echo "Finished ./gradlew publishPlugins (plugin portal)";
popd;
fi;
fi;

View File

@@ -39,7 +39,7 @@ OpenAPI Generator allows generation of API client libraries (SDK generation), se
| | Languages/Frameworks |
|-|-|
**API clients** | **ActionScript**, **Ada**, **Apex**, **Bash**, **C**, **C#** (.net 2.0, 3.5 or later), **C++** (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), [Play](https://www.playframework.com/), 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), Scalatra)
**API documentation generators** | **HTML**, **Confluence Wiki**
**Configuration files** | [**Apache2**](https://httpd.apache.org/)
**Others** | **GraphQL**, **JMeter**, **MySQL Schema**
@@ -511,7 +511,6 @@ Here are some companies/projects (alphabetical order) using OpenAPI Generator in
- [FormAPI](https://formapi.io/)
- [GenFlow](https://github.com/RepreZen/GenFlow)
- [GMO Pepabo](https://pepabo.com/en/)
- [GoDaddy](https://godaddy.com)
- [JustStar](https://www.juststarinfo.com)
- [Klarna](https://www.klarna.com/)
- [Metaswitch](https://www.metaswitch.com/)
@@ -552,10 +551,6 @@ 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/26 - [Building API Services: A Beginners 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-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)
@@ -667,7 +662,6 @@ Here is a list of template creators:
* Rust (rust-server): @metaswitch
* Scala Finch: @jimschubert [:heart:](https://www.patreon.com/jimschubert)
* Scala Lagom: @gmkumar2005
* Scala Play: @adigerber
* Documentation
* HTML Doc 2: @jhitchcock
* Confluence Wiki: @jhitchcock
@@ -728,8 +722,8 @@ If you want to join the committee, please kindly apply by sending an email to te
| GraphQL | @renepardon (2018/12) |
| Groovy | |
| Haskell | |
| 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) @karismann (2019/03) |
| Java | @bbdouglas (2017/07) @sreeshas (2017/08) @jfiala (2017/08) @lukoyanov (2017/09) @cbornet (2017/09) @jeff9finger (2018/01) |
| Kotlin | @jimschubert (2017/09) [:heart:](https://www.patreon.com/jimschubert), @dr4ke616 (2018/08) |
| Lua | @daurnimator (2017/08) |
| NodeJS/Javascript | @CodeNinjai (2017/07) @frol (2017/07) @cliffano (2017/07) |
| ObjC | |

View File

@@ -35,14 +35,6 @@ 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"
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:
# https://github.com/munificent/dep-interface-libraries
# When this is implemented there will only be one library.

View File

@@ -1,5 +1,4 @@
{
"library": "vertx",
"dateLibrary": "java8",
"artifactId": "petstore-vertx"
}

View File

@@ -25,11 +25,6 @@ then
mvn -B clean package
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.
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 $@"

View File

@@ -0,0 +1,32 @@
#!/bin/sh
SCRIPT="$0"
echo "# START SCRIPT: $SCRIPT"
while [ -h "$SCRIPT" ] ; do
ls=`ls -ld "$SCRIPT"`
link=`expr "$ls" : '.*-> \(.*\)$'`
if expr "$link" : '/.*' > /dev/null; then
SCRIPT="$link"
else
SCRIPT=`dirname "$SCRIPT"`/"$link"
fi
done
if [ ! -d "${APP_DIR}" ]; then
APP_DIR=`dirname "$SCRIPT"`/..
APP_DIR=`cd "${APP_DIR}"; pwd`
fi
executable="./modules/openapi-generator-cli/target/openapi-generator-cli.jar"
if [ ! -f "$executable" ]
then
mvn clean package
fi
# if you've executed sbt assembly previously it will use that instead.
export JAVA_OPTS="${JAVA_OPTS} -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

32
bin/security/csharp-petstore.sh Executable file
View File

@@ -0,0 +1,32 @@
#!/bin/sh
SCRIPT="$0"
echo "# START SCRIPT: $SCRIPT"
while [ -h "$SCRIPT" ] ; do
ls=`ls -ld "$SCRIPT"`
link=`expr "$ls" : '.*-> \(.*\)$'`
if expr "$link" : '/.*' > /dev/null; then
SCRIPT="$link"
else
SCRIPT=`dirname "$SCRIPT"`/"$link"
fi
done
if [ ! -d "${APP_DIR}" ]; then
APP_DIR=`dirname "$SCRIPT"`/..
APP_DIR=`cd "${APP_DIR}"; pwd`
fi
executable="./modules/openapi-generator-cli/target/openapi-generator-cli.jar"
if [ ! -f "$executable" ]
then
mvn clean package
fi
# if you've executed sbt assembly previously it will use that instead.
export JAVA_OPTS="${JAVA_OPTS} -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

39
bin/security/go-petstore.sh Executable file
View File

@@ -0,0 +1,39 @@
#!/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

View File

@@ -0,0 +1,34 @@
#!/bin/sh
SCRIPT="$0"
echo "# START SCRIPT: $SCRIPT"
while [ -h "$SCRIPT" ] ; do
ls=`ls -ld "$SCRIPT"`
link=`expr "$ls" : '.*-> \(.*\)$'`
if expr "$link" : '/.*' > /dev/null; then
SCRIPT="$link"
else
SCRIPT=`dirname "$SCRIPT"`/"$link"
fi
done
if [ ! -d "${APP_DIR}" ]; then
APP_DIR=`dirname "$SCRIPT"`/..
APP_DIR=`cd "${APP_DIR}"; pwd`
fi
executable="./modules/openapi-generator-cli/target/openapi-generator-cli.jar"
if [ ! -f "$executable" ]
then
mvn 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

View File

@@ -0,0 +1,32 @@
#!/bin/sh
SCRIPT="$0"
echo "# START SCRIPT: $SCRIPT"
while [ -h "$SCRIPT" ] ; do
ls=`ls -ld "$SCRIPT"`
link=`expr "$ls" : '.*-> \(.*\)$'`
if expr "$link" : '/.*' > /dev/null; then
SCRIPT="$link"
else
SCRIPT=`dirname "$SCRIPT"`/"$link"
fi
done
if [ ! -d "${APP_DIR}" ]; then
APP_DIR=`dirname "$SCRIPT"`/..
APP_DIR=`cd "${APP_DIR}"; pwd`
fi
executable="./modules/openapi-generator-cli/target/openapi-generator-cli.jar"
if [ ! -f "$executable" ]
then
mvn clean package
fi
# if you've executed sbt assembly previously it will use that instead.
export JAVA_OPTS="${JAVA_OPTS} -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

View File

@@ -0,0 +1,32 @@
#!/bin/sh
SCRIPT="$0"
echo "# START SCRIPT: $SCRIPT"
while [ -h "$SCRIPT" ] ; do
ls=`ls -ld "$SCRIPT"`
link=`expr "$ls" : '.*-> \(.*\)$'`
if expr "$link" : '/.*' > /dev/null; then
SCRIPT="$link"
else
SCRIPT=`dirname "$SCRIPT"`/"$link"
fi
done
if [ ! -d "${APP_DIR}" ]; then
APP_DIR=`dirname "$SCRIPT"`/..
APP_DIR=`cd "${APP_DIR}"; pwd`
fi
executable="./modules/openapi-generator-cli/target/openapi-generator-cli.jar"
if [ ! -f "$executable" ]
then
mvn clean package
fi
# if you've executed sbt assembly previously it will use that instead.
export JAVA_OPTS="${JAVA_OPTS} -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

View File

@@ -0,0 +1,32 @@
#!/bin/sh
SCRIPT="$0"
echo "# START SCRIPT: $SCRIPT"
while [ -h "$SCRIPT" ] ; do
ls=`ls -ld "$SCRIPT"`
link=`expr "$ls" : '.*-> \(.*\)$'`
if expr "$link" : '/.*' > /dev/null; then
SCRIPT="$link"
else
SCRIPT=`dirname "$SCRIPT"`/"$link"
fi
done
if [ ! -d "${APP_DIR}" ]; then
APP_DIR=`dirname "$SCRIPT"`/..
APP_DIR=`cd "${APP_DIR}"; pwd`
fi
executable="./modules/openapi-generator-cli/target/openapi-generator-cli.jar"
if [ ! -f "$executable" ]
then
mvn clean package
fi
# if you've executed sbt assembly previously it will use that instead.
export JAVA_OPTS="${JAVA_OPTS} -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

View File

@@ -0,0 +1,32 @@
#!/bin/sh
SCRIPT="$0"
echo "# START SCRIPT: $SCRIPT"
while [ -h "$SCRIPT" ] ; do
ls=`ls -ld "$SCRIPT"`
link=`expr "$ls" : '.*-> \(.*\)$'`
if expr "$link" : '/.*' > /dev/null; then
SCRIPT="$link"
else
SCRIPT=`dirname "$SCRIPT"`/"$link"
fi
done
if [ ! -d "${APP_DIR}" ]; then
APP_DIR=`dirname "$SCRIPT"`/..
APP_DIR=`cd "${APP_DIR}"; pwd`
fi
executable="./modules/openapi-generator-cli/target/openapi-generator-cli.jar"
if [ ! -f "$executable" ]
then
mvn clean package
fi
# if you've executed sbt assembly previously it will use that instead.
export JAVA_OPTS="${JAVA_OPTS} -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

32
bin/security/objc-petstore.sh Executable file
View File

@@ -0,0 +1,32 @@
#!/bin/sh
SCRIPT="$0"
echo "# START SCRIPT: $SCRIPT"
while [ -h "$SCRIPT" ] ; do
ls=`ls -ld "$SCRIPT"`
link=`expr "$ls" : '.*-> \(.*\)$'`
if expr "$link" : '/.*' > /dev/null; then
SCRIPT="$link"
else
SCRIPT=`dirname "$SCRIPT"`/"$link"
fi
done
if [ ! -d "${APP_DIR}" ]; then
APP_DIR=`dirname "$SCRIPT"`/..
APP_DIR=`cd "${APP_DIR}"; pwd`
fi
executable="./modules/openapi-generator-cli/target/openapi-generator-cli.jar"
if [ ! -f "$executable" ]
then
mvn clean package
fi
# if you've executed sbt assembly previously it will use that instead.
export JAVA_OPTS="${JAVA_OPTS} -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

View File

@@ -0,0 +1,38 @@
#!/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

View File

@@ -0,0 +1,10 @@
set executable=.\modules\openapi-generator-cli\target\openapi-generator-cli.jar
If Not Exist %executable% (
mvn clean package
)
REM set JAVA_OPTS=%JAVA_OPTS% -Xmx1024M
set ags=generate -i modules\openapi-generator\src\test\resources\3_0\petstore-security-test.yaml -g php -o samples\openapi3\client\petstore-security-test\php\OpenAPIClient-php
java %JAVA_OPTS% -jar %executable% %ags%

35
bin/security/perl-petstore.sh Executable file
View File

@@ -0,0 +1,35 @@
#!/bin/sh
SCRIPT="$0"
echo "# START SCRIPT: $SCRIPT"
while [ -h "$SCRIPT" ] ; do
ls=`ls -ld "$SCRIPT"`
link=`expr "$ls" : '.*-> \(.*\)$'`
if expr "$link" : '/.*' > /dev/null; then
SCRIPT="$link"
else
SCRIPT=`dirname "$SCRIPT"`/"$link"
fi
done
if [ ! -d "${APP_DIR}" ]; then
APP_DIR=`dirname "$SCRIPT"`/..
APP_DIR=`cd "${APP_DIR}"; pwd`
fi
executable="./modules/openapi-generator-cli/target/openapi-generator-cli.jar"
if [ ! -f "$executable" ]
then
mvn clean package
fi
# 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

38
bin/security/php-petstore.sh Executable file
View File

@@ -0,0 +1,38 @@
#!/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

View File

@@ -0,0 +1,32 @@
#!/bin/sh
SCRIPT="$0"
echo "# START SCRIPT: $SCRIPT"
while [ -h "$SCRIPT" ] ; do
ls=`ls -ld "$SCRIPT"`
link=`expr "$ls" : '.*-> \(.*\)$'`
if expr "$link" : '/.*' > /dev/null; then
SCRIPT="$link"
else
SCRIPT=`dirname "$SCRIPT"`/"$link"
fi
done
if [ ! -d "${APP_DIR}" ]; then
APP_DIR=`dirname "$SCRIPT"`/..
APP_DIR=`cd "${APP_DIR}"; pwd`
fi
executable="./modules/openapi-generator-cli/target/openapi-generator-cli.jar"
if [ ! -f "$executable" ]
then
mvn clean package
fi
# if you've executed sbt assembly previously it will use that instead.
export JAVA_OPTS="${JAVA_OPTS} -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

32
bin/security/python-petstore.sh Executable file
View File

@@ -0,0 +1,32 @@
#!/bin/sh
SCRIPT="$0"
echo "# START SCRIPT: $SCRIPT"
while [ -h "$SCRIPT" ] ; do
ls=`ls -ld "$SCRIPT"`
link=`expr "$ls" : '.*-> \(.*\)$'`
if expr "$link" : '/.*' > /dev/null; then
SCRIPT="$link"
else
SCRIPT=`dirname "$SCRIPT"`/"$link"
fi
done
if [ ! -d "${APP_DIR}" ]; then
APP_DIR=`dirname "$SCRIPT"`/..
APP_DIR=`cd "${APP_DIR}"; pwd`
fi
executable="./modules/openapi-generator-cli/target/openapi-generator-cli.jar"
if [ ! -f "$executable" ]
then
mvn clean package
fi
# if you've executed sbt assembly previously it will use that instead.
export JAVA_OPTS="${JAVA_OPTS} -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

View File

@@ -0,0 +1,32 @@
#!/bin/sh
SCRIPT="$0"
echo "# START SCRIPT: $SCRIPT"
while [ -h "$SCRIPT" ] ; do
ls=`ls -ld "$SCRIPT"`
link=`expr "$ls" : '.*-> \(.*\)$'`
if expr "$link" : '/.*' > /dev/null; then
SCRIPT="$link"
else
SCRIPT=`dirname "$SCRIPT"`/"$link"
fi
done
if [ ! -d "${APP_DIR}" ]; then
APP_DIR=`dirname "$SCRIPT"`/..
APP_DIR=`cd "${APP_DIR}"; pwd`
fi
executable="./modules/openapi-generator-cli/target/openapi-generator-cli.jar"
if [ ! -f "$executable" ]
then
mvn clean package
fi
# if you've executed sbt assembly previously it will use that instead.
export JAVA_OPTS="${JAVA_OPTS} -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

View File

@@ -0,0 +1,15 @@
#!/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

View File

@@ -22,11 +22,11 @@ executable="./modules/openapi-generator-cli/target/openapi-generator-cli.jar"
if [ ! -f "$executable" ]
then
mvn -B clean package
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/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 $@"
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 $@"
java $JAVA_OPTS -jar $executable $ags

View File

@@ -0,0 +1,32 @@
#!/bin/sh
SCRIPT="$0"
echo "# START SCRIPT: $SCRIPT"
while [ -h "$SCRIPT" ] ; do
ls=`ls -ld "$SCRIPT"`
link=`expr "$ls" : '.*-> \(.*\)$'`
if expr "$link" : '/.*' > /dev/null; then
SCRIPT="$link"
else
SCRIPT=`dirname "$SCRIPT"`/"$link"
fi
done
if [ ! -d "${APP_DIR}" ]; then
APP_DIR=`dirname "$SCRIPT"`/..
APP_DIR=`cd "${APP_DIR}"; pwd`
fi
executable="./modules/openapi-generator-cli/target/openapi-generator-cli.jar"
if [ ! -f "$executable" ]
then
mvn clean package
fi
# if you've executed sbt assembly previously it will use that instead.
export JAVA_OPTS="${JAVA_OPTS} -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

32
bin/security/swift-petstore.sh Executable file
View File

@@ -0,0 +1,32 @@
#!/bin/sh
SCRIPT="$0"
echo "# START SCRIPT: $SCRIPT"
while [ -h "$SCRIPT" ] ; do
ls=`ls -ld "$SCRIPT"`
link=`expr "$ls" : '.*-> \(.*\)$'`
if expr "$link" : '/.*' > /dev/null; then
SCRIPT="$link"
else
SCRIPT=`dirname "$SCRIPT"`/"$link"
fi
done
if [ ! -d "${APP_DIR}" ]; then
APP_DIR=`dirname "$SCRIPT"`/..
APP_DIR=`cd "${APP_DIR}"; pwd`
fi
executable="./modules/openapi-generator-cli/target/openapi-generator-cli.jar"
if [ ! -f "$executable" ]
then
mvn clean package
fi
# if you've executed sbt assembly previously it will use that instead.
export JAVA_OPTS="${JAVA_OPTS} -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

View File

@@ -0,0 +1,32 @@
#!/bin/sh
SCRIPT="$0"
echo "# START SCRIPT: $SCRIPT"
while [ -h "$SCRIPT" ] ; do
ls=`ls -ld "$SCRIPT"`
link=`expr "$ls" : '.*-> \(.*\)$'`
if expr "$link" : '/.*' > /dev/null; then
SCRIPT="$link"
else
SCRIPT=`dirname "$SCRIPT"`/"$link"
fi
done
if [ ! -d "${APP_DIR}" ]; then
APP_DIR=`dirname "$SCRIPT"`/..
APP_DIR=`cd "${APP_DIR}"; pwd`
fi
executable="./modules/openapi-generator-cli/target/openapi-generator-cli.jar"
if [ ! -f "$executable" ]
then
mvn clean package
fi
# if you've executed sbt assembly previously it will use that instead.
export JAVA_OPTS="${JAVA_OPTS} -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

View File

@@ -0,0 +1,32 @@
#!/bin/sh
SCRIPT="$0"
echo "# START SCRIPT: $SCRIPT"
while [ -h "$SCRIPT" ] ; do
ls=`ls -ld "$SCRIPT"`
link=`expr "$ls" : '.*-> \(.*\)$'`
if expr "$link" : '/.*' > /dev/null; then
SCRIPT="$link"
else
SCRIPT=`dirname "$SCRIPT"`/"$link"
fi
done
if [ ! -d "${APP_DIR}" ]; then
APP_DIR=`dirname "$SCRIPT"`/..
APP_DIR=`cd "${APP_DIR}"; pwd`
fi
executable="./modules/openapi-generator-cli/target/openapi-generator-cli.jar"
if [ ! -f "$executable" ]
then
mvn clean package
fi
# if you've executed sbt assembly previously it will use that instead.
export JAVA_OPTS="${JAVA_OPTS} -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

View File

@@ -0,0 +1,32 @@
#!/bin/sh
SCRIPT="$0"
echo "# START SCRIPT: $SCRIPT"
while [ -h "$SCRIPT" ] ; do
ls=`ls -ld "$SCRIPT"`
link=`expr "$ls" : '.*-> \(.*\)$'`
if expr "$link" : '/.*' > /dev/null; then
SCRIPT="$link"
else
SCRIPT=`dirname "$SCRIPT"`/"$link"
fi
done
if [ ! -d "${APP_DIR}" ]; then
APP_DIR=`dirname "$SCRIPT"`/..
APP_DIR=`cd "${APP_DIR}"; pwd`
fi
executable="./modules/openapi-generator-cli/target/openapi-generator-cli.jar"
if [ ! -f "$executable" ]
then
mvn clean package
fi
# if you've executed sbt assembly previously it will use that instead.
export JAVA_OPTS="${JAVA_OPTS} -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

View File

@@ -0,0 +1,32 @@
#!/bin/sh
SCRIPT="$0"
echo "# START SCRIPT: $SCRIPT"
while [ -h "$SCRIPT" ] ; do
ls=`ls -ld "$SCRIPT"`
link=`expr "$ls" : '.*-> \(.*\)$'`
if expr "$link" : '/.*' > /dev/null; then
SCRIPT="$link"
else
SCRIPT=`dirname "$SCRIPT"`/"$link"
fi
done
if [ ! -d "${APP_DIR}" ]; then
APP_DIR=`dirname "$SCRIPT"`/..
APP_DIR=`cd "${APP_DIR}"; pwd`
fi
executable="./modules/openapi-generator-cli/target/openapi-generator-cli.jar"
if [ ! -f "$executable" ]
then
mvn clean package
fi
# if you've executed sbt assembly previously it will use that instead.
export JAVA_OPTS="${JAVA_OPTS} -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

View File

@@ -0,0 +1,37 @@
#!/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

32
bin/security/typescript-node.sh Executable file
View File

@@ -0,0 +1,32 @@
#!/bin/sh
SCRIPT="$0"
echo "# START SCRIPT: $SCRIPT"
while [ -h "$SCRIPT" ] ; do
ls=`ls -ld "$SCRIPT"`
link=`expr "$ls" : '.*-> \(.*\)$'`
if expr "$link" : '/.*' > /dev/null; then
SCRIPT="$link"
else
SCRIPT=`dirname "$SCRIPT"`/"$link"
fi
done
if [ ! -d "${APP_DIR}" ]; then
APP_DIR=`dirname "$SCRIPT"`/..
APP_DIR=`cd "${APP_DIR}"; pwd`
fi
executable="./modules/openapi-generator-cli/target/openapi-generator-cli.jar"
if [ ! -f "$executable" ]
then
mvn clean package
fi
# if you've executed sbt assembly previously it will use that instead.
export JAVA_OPTS="${JAVA_OPTS} -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

View File

@@ -0,0 +1,10 @@
set executable=.\modules\openapi-generator-cli\target\openapi-generator-cli.jar
If Not Exist %executable% (
mvn clean package
)
REM set JAVA_OPTS=%JAVA_OPTS% -Xmx1024M
set ags=generate -i modules/openapi-generator/src/test/resources/2_0/petstore-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%

View File

@@ -5,6 +5,6 @@ If Not Exist %executable% (
)
REM set JAVA_OPTS=%JAVA_OPTS% -Xmx1024M
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
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
java %JAVA_OPTS% -jar %executable% %ags%

View File

@@ -0,0 +1,10 @@
set executable=.\modules\openapi-generator-cli\target\openapi-generator-cli.jar
If Not Exist %executable% (
mvn clean package
)
REM set JAVA_OPTS=%JAVA_OPTS% -Xmx1024M
set ags=generate -t modules/openapi-generator/src/main/resources/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%

View File

@@ -24,7 +24,6 @@ declare -a scripts=(
"./bin/kotlin-client-string.sh"
"./bin/kotlin-client-threetenbp.sh"
"./bin/kotlin-server-petstore.sh"
"./bin/kotlin-springboot-petstore-server.sh"
"./bin/mysql-schema-petstore.sh"
"./bin/python-petstore-all.sh"
"./bin/openapi3/python-petstore.sh"
@@ -35,9 +34,7 @@ declare -a scripts=(
"./bin/php-slim-server-petstore.sh"
"./bin/php-ze-ph-petstore-server.sh"
"./bin/openapi3/php-petstore.sh"
"./bin/typescript-angularjs-petstore.sh"
"./bin/typescript-angular-petstore-all.sh"
"./bin/typescript-aurelia-petstore.sh"
"./bin/typescript-axios-petstore-all.sh"
"./bin/typescript-fetch-petstore-all.sh"
"./bin/typescript-node-petstore-all.sh"

View File

@@ -1,10 +1,10 @@
set executable=.\modules\openapi-generator-cli\target\openapi-generator-cli.jar
If Not Exist %executable% (
mvn clean package
)
REM set JAVA_OPTS=%JAVA_OPTS% -Xmx1024M
set ags=generate -i modules\openapi-generator\src\test\resources\2_0\petstore.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%
set executable=.\modules\openapi-generator-cli\target\openapi-generator-cli.jar
If Not Exist %executable% (
mvn clean package
)
REM set JAVA_OPTS=%JAVA_OPTS% -Xmx1024M
set ags=generate -i modules\openapi-generator\src\test\resources\2_0\petstore.yaml -g kotlin-spring -o samples\server\petstore\kotlin-springboot --additional-properties=library=spring-boot
java %JAVA_OPTS% -jar %executable% %ags%

View File

@@ -105,7 +105,6 @@ The following generators are available:
- [rust-server](generators/rust-server.md)
- [scala-finch](generators/scala-finch.md)
- [scala-lagom-server](generators/scala-lagom-server.md)
- [scala-play-server](generators/scala-play-server.md)
- [scalatra](generators/scalatra.md)
- [spring](generators/spring.md)

View File

@@ -16,14 +16,13 @@ sidebar_label: aspnetcore
|packageVersion|C# package version.| |1.0.0|
|packageGuid|The GUID that will be associated with the C# project| |null|
|sourceFolder|source folder for generated code| |src|
|compatibilityVersion|ASP.Net Core CompatibilityVersion| |Version_2_1|
|aspnetCoreVersion|ASP.NET Core version: 2.2 (default), 2.1, 2.0 (deprecated)| |2.2|
|aspnetCoreVersion|ASP.NET Core version: 2.1 (default), 2.0 (deprecated)| |2.1|
|sortParamsByRequiredFlag|Sort method arguments to place required parameters before optional parameters.| |true|
|useDateTimeOffset|Use DateTimeOffset to model date-time properties| |false|
|useCollection|Deserialize array types to Collection<T> instead of List<T>.| |false|
|returnICollection|Return ICollection<T> instead of the concrete type.| |false|
|useSwashbuckle|Uses the Swashbuckle.AspNetCore NuGet package for documentation.| |true|
|classModifier|Class Modifier can be empty, abstract| ||
|operationModifier|Operation Modifier can be virtual, abstract or partial| |virtual|
|buildTarget|Target to build an application or library| |program|
|classModifier|Class modifiers such as abstract or partial| ||
|operationModifier|Operation modifiers such as virtual or abstract.| |virtual|
|generateBody|Generates method body.| |true|
|buildTarget|Target the build for a program or library.| |program|

View File

@@ -22,6 +22,7 @@ sidebar_label: csharp-netcore
|optionalMethodArgument|C# Optional method argument, e.g. void square(int x=10) (.net 4.0+ only).| |true|
|optionalAssemblyInfo|Generate AssemblyInfo.cs.| |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|
|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|

View File

@@ -22,6 +22,7 @@ sidebar_label: csharp
|optionalMethodArgument|C# Optional method argument, e.g. void square(int x=10) (.net 4.0+ only).| |true|
|optionalAssemblyInfo|Generate AssemblyInfo.cs.| |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|
|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|

View File

@@ -19,4 +19,3 @@ sidebar_label: dart-jaguar
|sourceFolder|source folder for generated code| |null|
|supportDart2|support dart2| |true|
|nullableFields|Is the null fields should be in the JSON payload| |null|
|serialization|Choose serialization format JSON or PROTO is supported| |null|

View File

@@ -8,5 +8,4 @@ sidebar_label: go-gin-server
| Option | Description | Values | Default |
| ------ | ----------- | ------ | ------- |
|packageName|Go package name (convention: lowercase).| |openapi|
|packageVersion|Go package version.| |1.0.0|
|hideGenerationTimestamp|Hides the generation timestamp when files are generated.| |true|

View File

@@ -8,7 +8,4 @@ sidebar_label: go-server
| Option | Description | Values | Default |
| ------ | ----------- | ------ | ------- |
|packageName|Go package name (convention: lowercase).| |openapi|
|packageVersion|Go package version.| |1.0.0|
|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|

View File

@@ -8,8 +8,8 @@ sidebar_label: go
| Option | Description | Values | Default |
| ------ | ----------- | ------ | ------- |
|packageName|Go package name (convention: lowercase).| |openapi|
|packageVersion|Go package version.| |1.0.0|
|hideGenerationTimestamp|Hides the generation timestamp when files are generated.| |true|
|packageVersion|Go package version.| |1.0.0|
|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|
|prependFormOrBodyParameters|Add form or body parameters to the beginning of the parameter list.| |false|

View File

@@ -54,4 +54,4 @@ sidebar_label: java
|useRuntimeException|Use RuntimeException instead of Exception| |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|
|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|
|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|

View File

@@ -1,22 +0,0 @@
---
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|

View File

@@ -1,22 +0,0 @@
---
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|

View File

@@ -249,4 +249,4 @@ If your API client is using named parameters in the function call (e.g. Perl req
## Default basePath
The default `basePath` has been changed from `https://localhost` to `http://localhost` (http without s)
The default `basePath` has been changed from `https://localhost` to `http://locallhost` (http without s)

View File

@@ -72,8 +72,8 @@ SYNOPSIS
OPTIONS
-f <output format>, --format <output format>
Write output files in the desired format. Options are 'text',
'markdown' or 'yamlsample'. Default is 'text'.
Write output files in the desired format. Options are 'text' and
'markdown'. Default is 'text'.
-g <generator name>, --generator-name <generator name>
generator to get config help for

View File

@@ -3,7 +3,7 @@
<parent>
<groupId>org.openapitools</groupId>
<artifactId>openapi-generator-project</artifactId>
<version>4.0.0-beta3</version>
<version>4.0.0-SNAPSHOT</version>
<relativePath>../..</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>

View File

@@ -29,8 +29,8 @@ import org.slf4j.LoggerFactory;
import java.io.*;
import java.nio.charset.StandardCharsets;
import java.nio.file.Paths;
import java.util.Map;
import java.nio.file.Paths;
import static org.apache.commons.lang3.StringEscapeUtils.escapeHtml4;
import static org.apache.commons.lang3.StringUtils.isEmpty;
@@ -40,34 +40,30 @@ public class ConfigHelp implements Runnable {
private static final Logger LOGGER = LoggerFactory.getLogger(Generate.class);
public static final String FORMAT_TEXT = "text";
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")
@Option(name = {"-g", "--generator-name"}, title = "generator name",
description = "generator to get config help for")
private String generatorName;
@Option(name = {
"--named-header"}, title = "named header", description = "Header includes the generator name, for clarity in output")
@Option(name = {"--named-header"}, title = "named header",
description = "Header includes the generator name, for clarity in output")
private Boolean namedHeader;
@Option(name = {"-o",
"--output"}, title = "output location", description = "Optionally write help to this location, otherwise default is standard output")
@Option(name = {"-o", "--output"}, title = "output location",
description = "Optionally write help to this location, otherwise default is standard output")
private String outputFile;
@Option(name = {"-f",
"--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})
@Option(name = {"-f", "--format"}, title = "output format",
description = "Write output files in the desired format. Options are 'text' and 'markdown'. Default is 'text'.")
private String format;
@Option(name = {
"--markdown-header"}, title = "markdown header", description = "When format=markdown, include this option to write out markdown headers (e.g. for docusaurus).")
@Option(name = {"--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 String newline = System.lineSeparator();
@Override public void run() {
@Override
public void run() {
if (isEmpty(generatorName)) {
LOGGER.error("[error] A generator name (--generator-name / -g) is required.");
System.exit(1);
@@ -77,34 +73,20 @@ public class ConfigHelp implements Runnable {
StringBuilder sb = new StringBuilder();
CodegenConfig config = CodegenConfigLoader.forName(generatorName);
String desiredFormat = StringUtils.defaultIfBlank(format, FORMAT_TEXT);
switch (desiredFormat) {
case FORMAT_MARKDOWN:
generateMarkdownHelp(sb, config);
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 (StringUtils.isEmpty(format) || "text".equalsIgnoreCase(format)) {
generatePlainTextHelp(sb, config);
} else if ("markdown".equalsIgnoreCase(format)) {
generateMarkdownHelp(sb, config);
} else {
LOGGER.warn("[warning] Unrecognized format option: %s.%n", format);
}
if (!isEmpty(outputFile)) {
File out = Paths.get(outputFile).toFile();
//noinspection ResultOfMethodCallIgnored
File parentFolder = out.getParentFile();
if (parentFolder != null && parentFolder.isDirectory()) {
parentFolder.mkdirs();
}
out.getParentFile().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());
}
} else {
@@ -119,41 +101,12 @@ 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) {
sb.append(newline);
if (Boolean.TRUE.equals(markdownHeader)) {
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("sidebar_label: ").append(generatorName).append(newline);
sb.append("---").append(newline);
@@ -214,8 +167,7 @@ public class ConfigHelp implements Runnable {
for (CliOption langCliOption : config.cliOptions()) {
sb.append("\t").append(langCliOption.getOpt());
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);
}

View File

@@ -217,11 +217,6 @@ 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)
private Boolean generateAliasAsModel;
@Option(name = {"--minimal-update"},
title = "Minimal update",
description = "Only write output files that have changed.")
private Boolean minimalUpdate;
@Override
public void run() {
if (logToStderr != null) {
@@ -351,9 +346,6 @@ public class Generate implements Runnable {
if (generateAliasAsModel != null) {
configurator.setGenerateAliasAsModel(generateAliasAsModel);
}
if (minimalUpdate != null) {
configurator.setEnableMinimalUpdate(minimalUpdate);
}
applySystemPropertiesKvpList(systemProperties, configurator);
applyInstantiationTypesKvpList(instantiationTypes, configurator);

View File

@@ -1,4 +1,4 @@
openApiGeneratorVersion=4.0.0-beta3
openApiGeneratorVersion=4.0.0-SNAPSHOT
# BEGIN placeholders
# these are just placeholders to allow contributors to build directly

View File

@@ -3,7 +3,7 @@
<parent>
<groupId>org.openapitools</groupId>
<artifactId>openapi-generator-project</artifactId>
<version>4.0.0-beta3</version>
<version>4.0.0-SNAPSHOT</version>
<relativePath>../..</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>

View File

@@ -1,142 +0,0 @@
<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>

View File

@@ -1,23 +0,0 @@
<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>

View File

@@ -1,18 +0,0 @@
<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>

View File

@@ -1,702 +0,0 @@
---
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"

View File

@@ -4,7 +4,7 @@
<parent>
<groupId>org.openapitools</groupId>
<artifactId>openapi-generator-project</artifactId>
<version>4.0.0-beta3</version>
<version>4.0.0-SNAPSHOT</version>
<relativePath>../..</relativePath>
</parent>
<artifactId>openapi-generator-maven-plugin</artifactId>

View File

@@ -37,9 +37,6 @@ import java.util.List;
import java.util.Map;
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.MojoExecutionException;
import org.apache.maven.plugins.annotations.LifecyclePhase;
@@ -166,12 +163,6 @@ public class CodeGenMojo extends AbstractMojo {
@Parameter(name = "invokerPackage")
private String invokerPackage;
/**
* The default package to use for the generated objects
*/
@Parameter(name = "packageName")
private String packageName;
/**
* groupId in generated pom.xml
*/
@@ -516,10 +507,6 @@ public class CodeGenMojo extends AbstractMojo {
configurator.setInvokerPackage(invokerPackage);
}
if (isNotEmpty(packageName)) {
configurator.setPackageName(packageName);
}
if (isNotEmpty(groupId)) {
configurator.setGroupId(groupId);
}
@@ -685,12 +672,7 @@ public class CodeGenMojo extends AbstractMojo {
// Store a checksum of the input spec
File storedInputSpecHashFile = getHashFile(inputSpecFile);
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();
String inputSpecHash = Files.asByteSource(inputSpecFile).hash(Hashing.sha256()).toString();
if (storedInputSpecHashFile.getParent() != null && !new File(storedInputSpecHashFile.getParent()).exists()) {
File parent = new File(storedInputSpecHashFile.getParent());

View File

@@ -3,7 +3,7 @@
<parent>
<groupId>org.openapitools</groupId>
<artifactId>openapi-generator-project</artifactId>
<version>4.0.0-beta3</version>
<version>4.0.0-SNAPSHOT</version>
<relativePath>../..</relativePath>
</parent>
<artifactId>openapi-generator-online</artifactId>

View File

@@ -3,7 +3,7 @@
<parent>
<groupId>org.openapitools</groupId>
<artifactId>openapi-generator-project</artifactId>
<version>4.0.0-beta3</version>
<version>4.0.0-SNAPSHOT</version>
<relativePath>../..</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>

View File

@@ -17,10 +17,6 @@
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.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -32,78 +28,23 @@ import java.util.regex.Pattern;
public abstract class AbstractGenerator {
private static final Logger LOGGER = LoggerFactory.getLogger(AbstractGenerator.class);
/**
* Is the minimal-file-update option enabled?
*
* @return Option value
*/
public abstract boolean getEnableMinimalUpdate();
/**
* 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 {
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);
}
}
public File writeToFile(String filename, String contents) throws IOException {
LOGGER.info("writing file " + filename);
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)
File output = Paths.get(filename).toFile();
if (output.getParent() != null && !new File(output.getParent()).exists()) {
File parent = Paths.get(output.getParent()).toFile();
File parent = new File(output.getParent());
parent.mkdirs();
}
Files.write(output.toPath(), contents);
try (Writer out = new BufferedWriter(new OutputStreamWriter(
new FileOutputStream(output), "UTF-8"))) {
out.write(contents);
}
return output;
}

View File

@@ -28,7 +28,6 @@ public class CliOption {
private String description;
private String type;
private String defaultValue;
private String optValue;
private Map<String, String> enumValues;
public CliOption(String opt, String description) {
@@ -74,18 +73,6 @@ public class CliOption {
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) {
if (this.enumValues == null) {
this.enumValues = new LinkedHashMap<String, String>();

View File

@@ -260,8 +260,4 @@ public interface CodegenConfig {
*/
void setOpenAPI(OpenAPI openAPI);
public boolean isEnableMinimalUpdate();
public void setEnableMinimalUpdate(boolean isEnableMinimalUpdate);
}

View File

@@ -191,6 +191,9 @@ public class CodegenConstants {
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 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_DESC = "Git user ID, e.g. openapitools.";

View File

@@ -20,7 +20,7 @@ package org.openapitools.codegen;
import java.util.*;
public class CodegenProperty implements Cloneable {
public String openApiType, baseName, complexType, getter, setter, description, dataType,
public String baseName, complexType, getter, setter, description, dataType,
datatypeWithEnum, dataFormat, name, min, max, defaultValue, defaultValueWithParam,
baseType, containerType, title;
@@ -415,7 +415,6 @@ public class CodegenProperty implements Cloneable {
return Objects.hash(
_enum,
allowableValues,
openApiType,
baseName,
baseType,
complexType,
@@ -502,7 +501,6 @@ public class CodegenProperty implements Cloneable {
final CodegenProperty other = (CodegenProperty) obj;
return Objects.equals(baseName, other.baseName) &&
Objects.equals(openApiType, other.openApiType) &&
Objects.equals(complexType, other.complexType) &&
Objects.equals(getter, other.getter) &&
Objects.equals(setter, other.setter) &&
@@ -602,7 +600,6 @@ public class CodegenProperty implements Cloneable {
public java.lang.String toString() {
return "CodegenProperty{" +
"baseName='" + baseName + '\'' +
", openApiType='" + openApiType + '\'' +
", complexType='" + complexType + '\'' +
", getter='" + getter + '\'' +
", setter='" + setter + '\'' +

View File

@@ -111,8 +111,6 @@ public class DefaultCodegen implements CodegenConfig {
protected String ignoreFilePathOverride;
// flag to indicate whether to use environment variable to post process file
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
protected OpenAPI openAPI;
@@ -780,7 +778,7 @@ public class DefaultCodegen implements CodegenConfig {
* @return the file name of the model
*/
public String toModelFilename(String name) {
return camelize(name);
return initialCaps(name);
}
/**
@@ -790,7 +788,7 @@ public class DefaultCodegen implements CodegenConfig {
* @return the file name of the model
*/
public String toModelTestFilename(String name) {
return camelize(name) + "Test";
return initialCaps(name) + "Test";
}
/**
@@ -800,7 +798,7 @@ public class DefaultCodegen implements CodegenConfig {
* @return the file name of the model
*/
public String toModelDocFilename(String name) {
return camelize(name);
return initialCaps(name);
}
/**
@@ -1476,6 +1474,17 @@ public class DefaultCodegen implements CodegenConfig {
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
@@ -1565,7 +1574,7 @@ public class DefaultCodegen implements CodegenConfig {
if (name.length() == 0) {
return "DefaultApi";
}
return camelize(name) + "Api";
return initialCaps(name) + "Api";
}
/**
@@ -1576,7 +1585,7 @@ public class DefaultCodegen implements CodegenConfig {
* @return capitalized model name
*/
public String toModelName(final String name) {
return camelize(modelNamePrefix + "_" + name + "_" + modelNameSuffix);
return initialCaps(modelNamePrefix + "_" + name + "_" + modelNameSuffix);
}
/**
@@ -1889,11 +1898,6 @@ public class DefaultCodegen implements CodegenConfig {
CodegenProperty property = CodegenModelFactory.newInstance(CodegenModelType.PROPERTY);
property.name = toVarName(name);
property.baseName = name;
if (p.getType() == null) {
property.openApiType = getSchemaType(p);
} else {
property.openApiType = p.getType();
}
property.nameInCamelCase = camelize(property.name, false);
property.nameInSnakeCase = CaseFormat.UPPER_CAMEL.to(CaseFormat.UPPER_UNDERSCORE, property.nameInCamelCase);
property.description = escapeText(p.getDescription());
@@ -3253,7 +3257,7 @@ public class DefaultCodegen implements CodegenConfig {
if (builder.toString().length() == 0) {
part = Character.toLowerCase(part.charAt(0)) + part.substring(1);
} else {
part = camelize(part);
part = initialCaps(part);
}
builder.append(part);
}
@@ -3850,11 +3854,6 @@ public class DefaultCodegen implements CodegenConfig {
// input name and age => input_name_and_age
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 _
// $php_variable => php_variable
if (allowUnicodeIdentifiers) { //could be converted to a single line with ?: operator
@@ -4835,22 +4834,4 @@ public class DefaultCodegen implements CodegenConfig {
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;
}
}

View File

@@ -67,11 +67,6 @@ public class DefaultGenerator extends AbstractGenerator implements Generator {
private String contextPath;
private Map<String, String> generatorPropertyDefaults = new HashMap<>();
@Override
public boolean getEnableMinimalUpdate() {
return config.isEnableMinimalUpdate();
}
@Override
public Generator opts(ClientOptInput opts) {
this.opts = opts;
@@ -802,13 +797,16 @@ public class DefaultGenerator extends AbstractGenerator implements Generator {
}
protected File writeInputStreamToFile(String filename, InputStream in, String templateFile) throws FileNotFoundException, IOException {
File outputFile = java.nio.file.Paths.get(filename).toFile();
if (in != null) {
byte bytes[] = IOUtils.toByteArray(in);
return writeToFile(filename, bytes);
OutputStream out = new FileOutputStream(outputFile, false);
LOGGER.info("writing file " + outputFile);
IOUtils.copy(in, out);
out.close();
} else {
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) {

View File

@@ -408,8 +408,8 @@ public class InlineModelResolver {
private String uniqueName(String key) {
if (key == null) {
key = "InlineObject";
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.");
key = "NULL_UNIQUE_NAME";
LOGGER.warn("null key found. Default to NULL_UNIQUE_NAME");
}
int count = 0;
boolean done = false;

View File

@@ -101,13 +101,11 @@ public class CodegenConfigurator implements Serializable {
private boolean logToStderr;
private boolean validateSpec;
private boolean enablePostProcessFile;
private boolean enableMinimalUpdate;
private String templateDir;
private String auth;
private String apiPackage;
private String modelPackage;
private String invokerPackage;
private String packageName;
private String modelNamePrefix;
private String modelNameSuffix;
private String groupId;
@@ -241,15 +239,6 @@ public class CodegenConfigurator implements Serializable {
return this;
}
public boolean getEnableMinimalUpdate() {
return enableMinimalUpdate;
}
public CodegenConfigurator setEnableMinimalUpdate(boolean enableMinimalUpdate) {
this.enableMinimalUpdate = enableMinimalUpdate;
return this;
}
public boolean isGenerateAliasAsModel() {
return ModelUtils.isGenerateAliasAsModel();
}
@@ -360,15 +349,6 @@ public class CodegenConfigurator implements Serializable {
return this;
}
public String getPackageName() {
return packageName;
}
public CodegenConfigurator setPackageName(String packageName) {
this.packageName = packageName;
return this;
}
public String getGroupId() {
return groupId;
}
@@ -565,7 +545,6 @@ public class CodegenConfigurator implements Serializable {
config.setIgnoreFilePathOverride(ignoreFileOverride);
config.setRemoveOperationIdPrefix(removeOperationIdPrefix);
config.setEnablePostProcessFile(enablePostProcessFile);
config.setEnableMinimalUpdate(enableMinimalUpdate);
config.instantiationTypes().putAll(instantiationTypes);
config.typeMapping().putAll(typeMappings);
@@ -576,7 +555,6 @@ public class CodegenConfigurator implements Serializable {
checkAndSetAdditionalProperty(apiPackage, CodegenConstants.API_PACKAGE);
checkAndSetAdditionalProperty(modelPackage, CodegenConstants.MODEL_PACKAGE);
checkAndSetAdditionalProperty(invokerPackage, CodegenConstants.INVOKER_PACKAGE);
checkAndSetAdditionalProperty(packageName, CodegenConstants.PACKAGE_NAME);
checkAndSetAdditionalProperty(groupId, CodegenConstants.GROUP_ID);
checkAndSetAdditionalProperty(artifactId, CodegenConstants.ARTIFACT_ID);
checkAndSetAdditionalProperty(artifactVersion, CodegenConstants.ARTIFACT_VERSION);

View File

@@ -232,8 +232,16 @@ public class ExampleGenerator {
Schema innerType = ((ArraySchema) property).getItems();
if (innerType != null) {
int arrayLength = null == ((ArraySchema) property).getMaxItems() ? 2 : ((ArraySchema) property).getMaxItems();
// avoid memory issues by limiting to max. 5 items
arrayLength = Math.min(arrayLength, 5);
if (arrayLength == Integer.MAX_VALUE) {
// swagger-jersey2-jaxrs generated spec may contain maxItem = 2147483647
// 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 objProperty = resolvePropertyToExample(propertyName, mediaType, innerType, processedModels);
for (int i = 0; i < arrayLength; i++) {

View File

@@ -39,6 +39,7 @@ public abstract class AbstractCSharpCodegen extends DefaultCodegen implements Co
protected boolean optionalAssemblyInfoFlag = true;
protected boolean optionalProjectFileFlag = true;
protected boolean optionalEmitDefaultValue = false;
protected boolean optionalMethodArgumentFlag = true;
protected boolean useDateTimeOffsetFlag = false;
protected boolean useCollection = false;
@@ -196,6 +197,10 @@ public abstract class AbstractCSharpCodegen extends DefaultCodegen implements Co
this.returnICollection = returnICollection;
}
public void setOptionalEmitDefaultValue(boolean optionalEmitDefaultValue) {
this.optionalEmitDefaultValue = optionalEmitDefaultValue;
}
public void setUseCollection(boolean useCollection) {
this.useCollection = useCollection;
if (useCollection) {
@@ -334,6 +339,12 @@ public abstract class AbstractCSharpCodegen extends DefaultCodegen implements Co
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)) {
setNetCoreProjectFileFlag(convertPropertyToBooleanAndWriteBack(CodegenConstants.NETCORE_PROJECT_FILE));
} else {

View File

@@ -112,8 +112,7 @@ public abstract class AbstractGoCodegen extends DefaultCodegen implements Codege
cliOptions.clear();
cliOptions.add(new CliOption(CodegenConstants.PACKAGE_NAME, "Go package name (convention: lowercase).")
.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)
.defaultValue(Boolean.TRUE.toString()));
}

View File

@@ -360,7 +360,7 @@ public abstract class AbstractKotlinCodegen extends DefaultCodegen implements Co
}
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 " +
"experimental parcelize feature. Make sure your build applies the android plugin:\n" +
"apply plugin: 'com.android.library' OR apply plugin: 'com.android.application'.\n" +
@@ -597,7 +597,10 @@ public abstract class AbstractKotlinCodegen extends DefaultCodegen implements Co
private String sanitizeKotlinSpecificNames(final String name) {
String word = name;
for (Map.Entry<String, String> specialCharacters : specialCharReplacements.entrySet()) {
word = replaceSpecialCharacters(word, specialCharacters);
// Underscore is the only special character we'll allow
if (!specialCharacters.getKey().equals("_")) {
word = word.replaceAll("\\Q" + specialCharacters.getKey() + "\\E", specialCharacters.getValue());
}
}
// Fallback, replace unknowns with underscore.
@@ -614,38 +617,6 @@ public abstract class AbstractKotlinCodegen extends DefaultCodegen implements Co
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) {
return input.substring(0, 1).toUpperCase(Locale.ROOT) + input.substring(1);
}
@@ -705,7 +676,6 @@ public abstract class AbstractKotlinCodegen extends DefaultCodegen implements Co
@Override
public String toVarName(String name) {
// sanitize name
name = sanitizeKotlinSpecificNames(name);
name = sanitizeName(name, "\\W-[\\$]");
if (name.toLowerCase(Locale.ROOT).matches("^_*class$")) {
@@ -786,31 +756,4 @@ 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;
}
}

View File

@@ -333,29 +333,4 @@ 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;
}
}

View File

@@ -19,8 +19,10 @@ package org.openapitools.codegen.languages;
import com.samskivert.mustache.Mustache;
import io.swagger.v3.oas.models.OpenAPI;
import io.swagger.v3.oas.models.media.Schema;
import org.openapitools.codegen.*;
import org.openapitools.codegen.CodegenConstants;
import org.openapitools.codegen.CodegenOperation;
import org.openapitools.codegen.CodegenType;
import org.openapitools.codegen.SupportingFile;
import org.openapitools.codegen.utils.URLPathUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -45,7 +47,6 @@ public class AspNetCoreServerCodegen extends AbstractCSharpCodegen {
public static final String PROJECT_SDK = "projectSdk";
public static final String SDK_WEB = "Microsoft.NET.Sdk.Web";
public static final String SDK_LIB = "Microsoft.NET.Sdk";
public static final String COMPATIBILITY_VERSION = "compatibilityVersion";
private String packageGuid = "{" + randomUUID().toString().toUpperCase(Locale.ROOT) + "}";
@@ -55,13 +56,13 @@ public class AspNetCoreServerCodegen extends AbstractCSharpCodegen {
private boolean useSwashbuckle = true;
protected int serverPort = 8080;
protected String serverHost = "0.0.0.0";
private CliOption aspnetCoreVersion = new CliOption(ASPNET_CORE_VERSION, "ASP.NET Core version: 2.2 (default), 2.1, 2.0 (deprecated)");
private CliOption classModifier = new CliOption(CLASS_MODIFIER, "Class Modifier can be empty, abstract");
private CliOption operationModifier = new CliOption(OPERATION_MODIFIER, "Operation Modifier can be virtual, abstract or partial");
protected String aspnetCoreVersion= "2.1"; // default to 2.1
// TODO Make next two enums toensure fixed list.
private String classModifier = "";
private String operationModifier = "virtual";
private boolean generateBody = true;
private CliOption buildTarget = new CliOption("buildTarget", "Target to build an application or library");
private String buildTarget = "program";
private String projectSdk = SDK_WEB;
private String compatibilityVersion = "Version_2_1";
public AspNetCoreServerCodegen() {
super();
@@ -81,18 +82,6 @@ public class AspNetCoreServerCodegen extends AbstractCSharpCodegen {
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
addOption(CodegenConstants.LICENSE_URL,
CodegenConstants.LICENSE_URL_DESC,
@@ -130,14 +119,9 @@ public class AspNetCoreServerCodegen extends AbstractCSharpCodegen {
CodegenConstants.SOURCE_FOLDER_DESC,
sourceFolder);
addOption(COMPATIBILITY_VERSION, "ASP.Net Core CompatibilityVersion", compatibilityVersion);
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());
addOption(ASPNET_CORE_VERSION,
"ASP.NET Core version: 2.1 (default), 2.0 (deprecated)",
aspnetCoreVersion);
// CLI Switches
addSwitch(CodegenConstants.SORT_PARAMS_BY_REQUIRED_FLAG,
@@ -160,28 +144,22 @@ public class AspNetCoreServerCodegen extends AbstractCSharpCodegen {
"Uses the Swashbuckle.AspNetCore NuGet package for documentation.",
useSwashbuckle);
classModifier.addEnum("", "Keep class default with no modifier");
classModifier.addEnum("abstract", "Make class abstract");
classModifier.setDefault("");
classModifier.setOptValue(classModifier.getDefault());
addOption(classModifier.getOpt(), classModifier.getDescription(), classModifier.getOptValue());
addOption(CLASS_MODIFIER,
"Class modifiers such as abstract or partial",
classModifier);
operationModifier.addEnum("virtual", "Keep method virtual ");
operationModifier.addEnum("abstract", "Make method abstract");
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());
addOption(OPERATION_MODIFIER,
"Operation modifiers such as virtual or abstract.",
operationModifier);
addSwitch(GENERATE_BODY,
"Generates method body.",
generateBody);
addOption(BUILD_TARGET,
"Target the build for a program or library.",
buildTarget);
}
@Override
@@ -223,15 +201,53 @@ public class AspNetCoreServerCodegen extends AbstractCSharpCodegen {
additionalProperties.put(USE_SWASHBUCKLE, useSwashbuckle);
}
// CHeck for the modifiers etc.
// The order of the checks is important.
isLibrary = setBuildTarget();
setClassModifier();
setOperationModifier();
// determine the ASP.NET core version setting
if (additionalProperties.containsKey(ASPNET_CORE_VERSION)) {
setAspnetCoreVersion((String) additionalProperties.get(ASPNET_CORE_VERSION));
}
// 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("dockerTag", packageName.toLowerCase(Locale.ROOT));
@@ -241,8 +257,17 @@ public class AspNetCoreServerCodegen extends AbstractCSharpCodegen {
String packageFolder = sourceFolder + File.separator + packageName;
// determine the ASP.NET core version setting
setAspnetCoreVersion(packageFolder);
if ("2.0".equals(aspnetCoreVersion)) {
embeddedTemplateDir = templateDir = "aspnetcore/2.0";
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.bat.mustache", "", "build.bat"));
@@ -269,6 +294,26 @@ public class AspNetCoreServerCodegen extends AbstractCSharpCodegen {
supportingFiles.add(new SupportingFile("wwwroot" + File.separator + "openapi-original.mustache",
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) {
@@ -283,6 +328,10 @@ public class AspNetCoreServerCodegen extends AbstractCSharpCodegen {
this.packageGuid = packageGuid;
}
public void setAspnetCoreVersion(String aspnetCoreVersion) {
this.aspnetCoreVersion= aspnetCoreVersion;
}
@Override
public String apiFileFolder() {
return outputFolder + File.separator + sourceFolder + File.separator + packageName + File.separator + "Controllers";
@@ -326,85 +375,4 @@ public class AspNetCoreServerCodegen extends AbstractCSharpCodegen {
public String toRegularExpression(String 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);
}
}

View File

@@ -35,8 +35,6 @@ import org.slf4j.LoggerFactory;
import java.util.*;
import static org.openapitools.codegen.utils.StringUtils.*;
public class BashClientCodegen extends DefaultCodegen implements CodegenConfig {
private static final Logger LOGGER = LoggerFactory.getLogger(BashClientCodegen.class);
@@ -745,7 +743,7 @@ public class BashClientCodegen extends DefaultCodegen implements CodegenConfig {
@Override
public String toModelFilename(String name) {
return camelize(name);
return initialCaps(name);
}

View File

@@ -86,18 +86,6 @@ public class CSharpClientCodegen extends AbstractCSharpCodegen {
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
addOption(CodegenConstants.PACKAGE_NAME,
"C# package name (convention: Title.Case).",
@@ -170,6 +158,10 @@ public class CSharpClientCodegen extends AbstractCSharpCodegen {
CodegenConstants.OPTIONAL_PROJECT_FILE_DESC,
this.optionalProjectFileFlag);
addSwitch(CodegenConstants.OPTIONAL_EMIT_DEFAULT_VALUES,
CodegenConstants.OPTIONAL_EMIT_DEFAULT_VALUES_DESC,
this.optionalEmitDefaultValue);
addSwitch(CodegenConstants.GENERATE_PROPERTY_CHANGED,
CodegenConstants.PACKAGE_DESCRIPTION_DESC,
this.generatePropertyChanged);
@@ -326,6 +318,9 @@ public class CSharpClientCodegen extends AbstractCSharpCodegen {
additionalProperties.put("netStandard", this.netStandard);
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)) {
setOptionalProjectFileFlag(convertPropertyToBooleanAndWriteBack(CodegenConstants.OPTIONAL_PROJECT_FILE));
} else {
@@ -867,18 +862,4 @@ public class CSharpClientCodegen extends AbstractCSharpCodegen {
return null;
}
}
@Override
public String getNullableType(Schema p, String type) {
boolean isNullableExpected = p.getNullable() == null || (p.getNullable() != null && p.getNullable());
if (isNullableExpected && languageSpecificPrimitives.contains(type + "?")) {
return type + "?";
} else if (languageSpecificPrimitives.contains(type)) {
return type;
} else {
return null;
}
}
}

View File

@@ -184,6 +184,10 @@ public class CSharpNetCoreClientCodegen extends AbstractCSharpCodegen {
CodegenConstants.OPTIONAL_PROJECT_FILE_DESC,
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
// 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
@@ -506,6 +510,8 @@ public class CSharpNetCoreClientCodegen extends AbstractCSharpCodegen {
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.SUPPORTS_ASYNC, this::setSupportsAsync, this.supportsAsync);
syncBooleanProperty(additionalProperties, CodegenConstants.OPTIONAL_PROJECT_FILE, this::setOptionalProjectFileFlag, optionalProjectFileFlag);

View File

@@ -29,7 +29,7 @@ import org.openapitools.codegen.utils.ModelUtils;
import java.io.File;
import java.util.*;
import static org.openapitools.codegen.utils.StringUtils.*;
import static org.openapitools.codegen.utils.StringUtils.underscore;
public class CppPistacheServerCodegen extends AbstractCppCodegen {
protected String implFolder = "impl";
@@ -265,7 +265,7 @@ public class CppPistacheServerCodegen extends AbstractCppCodegen {
@Override
public String toModelFilename(String name) {
return camelize(toModelName(name));
return initialCaps(toModelName(name));
}
@Override
@@ -286,7 +286,7 @@ public class CppPistacheServerCodegen extends AbstractCppCodegen {
@Override
public String toApiFilename(String name) {
return modelNamePrefix + camelize(name) + "Api";
return modelNamePrefix + initialCaps(name) + "Api";
}
/**

View File

@@ -5,7 +5,6 @@ import io.swagger.v3.oas.models.media.Schema;
import io.swagger.v3.parser.util.SchemaTypeUtil;
import org.apache.commons.lang3.StringUtils;
import org.openapitools.codegen.CodegenConfig;
import org.openapitools.codegen.CodegenModel;
import org.openapitools.codegen.CodegenOperation;
import org.openapitools.codegen.CodegenParameter;
import org.openapitools.codegen.utils.ModelUtils;
@@ -281,19 +280,7 @@ public class CppQt5AbstractCodegen extends AbstractCppCodegen implements Codegen
List<CodegenOperation> operations = (List<CodegenOperation>) objectMap.get("operation");
List<Map<String, String>> imports = (List<Map<String, String>>) objs.get("imports");
Map<String, CodegenModel> codegenModels = new HashMap<String, CodegenModel> ();
for(Object moObj : allModels) {
CodegenModel mo = ((Map<String, CodegenModel>) moObj).get("model");
if(mo.isEnum) {
codegenModels.put(mo.classname, mo);
}
}
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
// already done
if (operation.returnBaseType != null && needToImport(operation.returnBaseType)) {
@@ -329,21 +316,6 @@ public class CppQt5AbstractCodegen extends AbstractCppCodegen implements Codegen
return objs;
}
@Override
public Map<String, Object> postProcessModels(Map<String, Object> objs) {
return postProcessModelsEnum(objs);
}
@Override
public String toEnumValue(String value, String datatype) {
return escapeText(value);
}
@Override
public boolean isDataTypeString(String dataType) {
return "QString".equals(dataType);
}
private Map<String, String> createMapping(String key, String value) {
Map<String, String> customImport = new HashMap<String, String>();
customImport.put(key, toModelImport(value));

View File

@@ -24,8 +24,6 @@ import org.openapitools.codegen.SupportingFile;
import java.io.File;
import static org.openapitools.codegen.utils.StringUtils.*;
public class CppQt5ClientCodegen extends CppQt5AbstractCodegen implements CodegenConfig {
public static final String OPTIONAL_PROJECT_FILE_DESC = "Generate client.pri.";
// source folder where to write the files
@@ -77,7 +75,6 @@ public class CppQt5ClientCodegen extends CppQt5AbstractCodegen implements Codege
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("object.mustache", sourceFolder, PREFIX + "Object.h"));
supportingFiles.add(new SupportingFile("enum.mustache", sourceFolder, PREFIX + "Enum.h"));
if (optionalProjectFileFlag) {
supportingFiles.add(new SupportingFile("Project.mustache", sourceFolder, "client.pri"));
}
@@ -103,7 +100,6 @@ public class CppQt5ClientCodegen extends CppQt5AbstractCodegen implements Codege
supportingFiles.add(new SupportingFile("HttpRequest.h.mustache", sourceFolder, modelNamePrefix + "HttpRequest.h"));
supportingFiles.add(new SupportingFile("HttpRequest.cpp.mustache", sourceFolder, modelNamePrefix + "HttpRequest.cpp"));
supportingFiles.add(new SupportingFile("object.mustache", sourceFolder, modelNamePrefix + "Object.h"));
supportingFiles.add(new SupportingFile("enum.mustache", sourceFolder, modelNamePrefix + "Enum.h"));
typeMapping.put("file", modelNamePrefix + "HttpRequestInputFileElement");
typeMapping.put("binary", modelNamePrefix + "HttpRequestInputFileElement");
@@ -167,7 +163,7 @@ public class CppQt5ClientCodegen extends CppQt5AbstractCodegen implements Codege
@Override
public String toApiFilename(String name) {
return modelNamePrefix + sanitizeName(camelize(name)) + "Api";
return modelNamePrefix + sanitizeName(initialCaps(name)) + "Api";
}
public void setOptionalProjectFileFlag(boolean flag) {

View File

@@ -23,8 +23,6 @@ import org.openapitools.codegen.SupportingFile;
import java.io.File;
import static org.openapitools.codegen.utils.StringUtils.*;
public class CppQt5QHttpEngineServerCodegen extends CppQt5AbstractCodegen implements CodegenConfig {
protected final String SRC_DIR = "/src";
@@ -85,7 +83,6 @@ public class CppQt5QHttpEngineServerCodegen extends CppQt5AbstractCodegen implem
supportingFiles.add(new SupportingFile("helpers-header.mustache", sourceFolder + MODEL_DIR, PREFIX + "Helpers.h"));
supportingFiles.add(new SupportingFile("helpers-body.mustache", sourceFolder + MODEL_DIR, PREFIX + "Helpers.cpp"));
supportingFiles.add(new SupportingFile("object.mustache", sourceFolder + MODEL_DIR, PREFIX + "Object.h"));
supportingFiles.add(new SupportingFile("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.cpp.mustache", sourceFolder + APIHANDLER_DIR, PREFIX + "ApiRouter.cpp"));
@@ -109,7 +106,6 @@ public class CppQt5QHttpEngineServerCodegen extends CppQt5AbstractCodegen implem
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("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.cpp.mustache", sourceFolder + APIHANDLER_DIR, modelNamePrefix + "ApiRouter.cpp"));
@@ -191,7 +187,7 @@ public class CppQt5QHttpEngineServerCodegen extends CppQt5AbstractCodegen implem
@Override
public String toApiFilename(String name) {
return modelNamePrefix + sanitizeName(camelize(name)) + "ApiHandler";
return modelNamePrefix + sanitizeName(initialCaps(name)) + "ApiHandler";
}
}

View File

@@ -31,7 +31,6 @@ import org.openapitools.codegen.utils.ModelUtils;
import java.util.*;
import static com.google.common.base.Strings.isNullOrEmpty;
import static org.openapitools.codegen.utils.StringUtils.*;
public class CppRestSdkClientCodegen extends AbstractCppCodegen {
@@ -289,12 +288,12 @@ public class CppRestSdkClientCodegen extends AbstractCppCodegen {
@Override
public String toModelFilename(String name) {
return sanitizeName(camelize(name));
return sanitizeName(initialCaps(name));
}
@Override
public String toApiFilename(String name) {
return sanitizeName(camelize(name) + "Api");
return sanitizeName(initialCaps(name) + "Api");
}
/**

View File

@@ -27,8 +27,6 @@ import org.slf4j.LoggerFactory;
import java.io.File;
import java.util.*;
import static org.openapitools.codegen.utils.StringUtils.*;
public class CppRestbedServerCodegen extends AbstractCppCodegen {
private static final org.slf4j.Logger LOGGER = LoggerFactory.getLogger(CppRestbedServerCodegen.class);
@@ -193,12 +191,12 @@ public class CppRestbedServerCodegen extends AbstractCppCodegen {
@Override
public String toModelFilename(String name) {
return camelize(name);
return initialCaps(name);
}
@Override
public String toApiFilename(String name) {
return camelize(name) + "Api";
return initialCaps(name) + "Api";
}
@SuppressWarnings("unchecked")

View File

@@ -247,17 +247,17 @@ public class CppTizenClientCodegen extends AbstractCppCodegen implements Codegen
@Override
public String toModelFilename(String name) {
return camelize(name);
return initialCaps(name);
}
@Override
public String toApiName(String name) {
return camelize(name) + "Manager";
return initialCaps(name) + "Manager";
}
@Override
public String toApiFilename(String name) {
return camelize(name) + "Manager";
return initialCaps(name) + "Manager";
}
@Override

View File

@@ -16,16 +16,10 @@
package org.openapitools.codegen.languages;
import org.apache.commons.io.FilenameUtils;
import org.openapitools.codegen.*;
import org.openapitools.codegen.utils.ModelUtils;
import io.swagger.v3.oas.models.media.*;
import io.swagger.v3.oas.models.media.Schema;
import org.apache.commons.lang3.StringUtils;
import org.openapitools.codegen.*;
import org.openapitools.codegen.utils.ModelUtils;
import org.openapitools.codegen.utils.ProcessUtils;
import java.io.File;
import java.util.*;
@@ -34,25 +28,16 @@ import static org.openapitools.codegen.utils.StringUtils.underscore;
public class DartJaguarClientCodegen extends DartClientCodegen {
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 HashMap<String, String> protoTypeMapping = new HashMap<>();
static {
modelToIgnore.add("datetime");
modelToIgnore.add("map");
modelToIgnore.add("list");
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 String serialization = SERIALIZATION_JSON;
public DartJaguarClientCodegen() {
super();
@@ -61,33 +46,6 @@ public class DartJaguarClientCodegen extends DartClientCodegen {
embeddedTemplateDir = templateDir = "dart-jaguar";
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
@@ -119,20 +77,6 @@ public class DartJaguarClientCodegen extends DartClientCodegen {
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)) {
this.setPubName((String) additionalProperties.get(PUB_NAME));
} else {
@@ -189,7 +133,6 @@ public class DartJaguarClientCodegen extends DartClientCodegen {
public Map<String, Object> postProcessModels(Map<String, Object> objs) {
objs = super.postProcessModels(objs);
List<Object> models = (List<Object>) objs.get("models");
ProcessUtils.addIndexToProperties(models, 1);
for (Object _mo : models) {
Map<String, Object> mo = (Map<String, Object>) _mo;
Set<String> modelImports = new HashSet<>();
@@ -199,16 +142,6 @@ public class DartJaguarClientCodegen extends DartClientCodegen {
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.vendorExtensions.put("hasVars", cm.vars.size() > 0);
}
@@ -222,20 +155,17 @@ public class DartJaguarClientCodegen extends DartClientCodegen {
List<CodegenOperation> operationList = (List<CodegenOperation>) operations.get("operation");
Set<String> modelImports = new HashSet<>();
Set<String> fullImports = new HashSet<>();
for (CodegenOperation op : operationList) {
op.httpMethod = StringUtils.capitalize(op.httpMethod.toLowerCase(Locale.ROOT));
boolean isJson = true; //default to JSON
boolean isForm = false;
boolean isProto = false;
boolean isMultipart = false;
if (op.consumes != null) {
for (Map<String, String> consume : op.consumes) {
if (consume.containsKey("mediaType")) {
String type = consume.get("mediaType");
isJson = type.equalsIgnoreCase("application/json");
isProto = type.equalsIgnoreCase("application/octet-stream");
isForm = type.equalsIgnoreCase("application/x-www-form-urlencoded");
isMultipart = type.equalsIgnoreCase("multipart/form-data");
break;
@@ -243,27 +173,7 @@ 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("isProto", isProto);
op.vendorExtensions.put("isForm", isForm);
op.vendorExtensions.put("isMultipart", isMultipart);
@@ -271,8 +181,6 @@ public class DartJaguarClientCodegen extends DartClientCodegen {
for (String item : op.imports) {
if (!modelToIgnore.contains(item.toLowerCase(Locale.ROOT))) {
imports.add(underscore(item));
} else if (item.equalsIgnoreCase("Uint8List")) {
fullImports.add("dart:typed_data");
}
}
modelImports.addAll(imports);
@@ -297,7 +205,6 @@ public class DartJaguarClientCodegen extends DartClientCodegen {
}
objs.put("modelImports", modelImports);
objs.put("fullImports", fullImports);
return objs;
}

View File

@@ -23,7 +23,6 @@ import io.swagger.v3.oas.models.OpenAPI;
import io.swagger.v3.oas.models.info.Info;
import io.swagger.v3.oas.models.media.ArraySchema;
import io.swagger.v3.oas.models.media.Schema;
import io.swagger.v3.oas.models.responses.ApiResponse;
import org.apache.commons.lang3.StringUtils;
import org.openapitools.codegen.*;
import org.openapitools.codegen.utils.ModelUtils;
@@ -54,7 +53,7 @@ public class ElixirClientCodegen extends DefaultCodegen implements CodegenConfig
List<String> extraApplications = Arrays.asList(":logger");
List<String> deps = Arrays.asList(
"{:tesla, \"~> 1.0.0\"}",
"{:poison, \"~> 3.0.0\"}"
"{:poison, \">= 1.0.0\"}"
);
public ElixirClientCodegen() {
@@ -311,11 +310,6 @@ public class ElixirClientCodegen extends DefaultCodegen implements CodegenConfig
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
String join(CharSequence charSequence, Iterable<String> iterable) {
StringBuilder buf = new StringBuilder();
@@ -521,91 +515,6 @@ public class ElixirClientCodegen extends DefaultCodegen implements CodegenConfig
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 {
private List<String> pathTemplateNames = new ArrayList<String>();
private String replacedPathName;
@@ -779,6 +688,32 @@ public class ElixirClientCodegen extends DefaultCodegen implements CodegenConfig
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 {

View File

@@ -30,9 +30,7 @@ import org.slf4j.LoggerFactory;
import java.io.File;
import java.text.Collator;
import java.util.*;
import java.util.function.Predicate;
import java.util.stream.Collectors;
import java.util.stream.Stream;
import static org.openapitools.codegen.utils.StringUtils.camelize;
@@ -236,7 +234,7 @@ public class ElmClientCodegen extends DefaultCodegen implements CodegenConfig {
if (name.length() == 0) {
return "Default";
}
return camelize(name);
return initialCaps(name);
}
@Override
@@ -413,26 +411,14 @@ public class ElmClientCodegen extends DefaultCodegen implements CodegenConfig {
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
@SuppressWarnings({"static-method", "unchecked"})
public Map<String, Object> postProcessOperationsWithModels(Map<String, Object> operations, List<Object> allModels) {
Map<String, Object> objs = (Map<String, Object>) operations.get("operations");
List<CodegenOperation> ops = (List<CodegenOperation>) objs.get("operation");
boolean hasDateTime = false;
boolean hasDate = false;
final Map<String, Set<String>> dependencies = new HashMap<>();
for (CodegenOperation op : ops) {
@@ -441,6 +427,8 @@ public class ElmClientCodegen extends DefaultCodegen implements CodegenConfig {
for (CodegenParameter param : op.pathParams) {
final String var = paramToString("params", param, false, null);
path = path.replace("{" + param.paramName + "}", "\" ++ " + var + " ++ \"");
hasDateTime = hasDateTime || param.isDateTime;
hasDate = hasDate || param.isDate;
}
op.path = ("\"" + path + "\"").replaceAll(" \\+\\+ \"\"", "");
} else {
@@ -449,6 +437,8 @@ public class ElmClientCodegen extends DefaultCodegen implements CodegenConfig {
for (CodegenParameter param : op.pathParams) {
String str = paramToString("params", param, false, null);
path = path.replace("{" + param.paramName + "}", str);
hasDateTime = hasDateTime || param.isDateTime;
hasDate = hasDate || param.isDate;
}
op.path = path;
@@ -497,7 +487,6 @@ public class ElmClientCodegen extends DefaultCodegen implements CodegenConfig {
elmImport.hasExposures = true;
elmImports.add(elmImport);
}
final boolean hasDate = anyOperationParam(ops, param -> param.isDate);
if (hasDate) {
final ElmImport elmImport = new ElmImport();
elmImport.moduleName = "DateOnly";
@@ -506,7 +495,6 @@ public class ElmClientCodegen extends DefaultCodegen implements CodegenConfig {
elmImport.hasExposures = true;
elmImports.add(elmImport);
}
final boolean hasDateTime = anyOperationParam(ops, param -> param.isDateTime);
if (hasDateTime) {
final ElmImport elmImport = new ElmImport();
elmImport.moduleName = "DateTime";
@@ -515,15 +503,6 @@ public class ElmClientCodegen extends DefaultCodegen implements CodegenConfig {
elmImport.hasExposures = true;
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);
return operations;
@@ -574,7 +553,7 @@ public class ElmClientCodegen extends DefaultCodegen implements CodegenConfig {
}
String mapFn = null;
if (param.isString || param.isBinary || param.isByteArray) {
if (param.isString || param.isUuid || param.isBinary || param.isByteArray) {
mapFn = "";
} else if (param.isBoolean) {
mapFn = "(\\val -> if val then \"true\" else \"false\")";
@@ -582,8 +561,6 @@ public class ElmClientCodegen extends DefaultCodegen implements CodegenConfig {
mapFn = "DateTime.toString";
} else if (param.isDate) {
mapFn = "DateOnly.toString";
} else if (param.isUuid) {
mapFn = "Uuid.toString";
} else if (ElmVersion.ELM_018.equals(elmVersion)) {
mapFn = "toString";
} else if (param.isInteger || param.isLong) {

View File

@@ -51,6 +51,8 @@ public class GoClientCodegen extends AbstractGoCodegen {
// default HIDE_GENERATION_TIMESTAMP to 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_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)"));

View File

@@ -17,7 +17,6 @@
package org.openapitools.codegen.languages;
import org.openapitools.codegen.CliOption;
import org.openapitools.codegen.CodegenConstants;
import org.openapitools.codegen.CodegenType;
import org.openapitools.codegen.SupportingFile;
@@ -31,25 +30,16 @@ public class GoServerCodegen extends AbstractGoCodegen {
private static final Logger LOGGER = LoggerFactory.getLogger(GoServerCodegen.class);
protected String packageVersion = "1.0.0";
protected String apiVersion = "1.0.0";
protected int serverPort = 8080;
protected String projectName = "openapi-server";
protected String sourceFolder = "go";
protected String apiPath = "go";
public GoServerCodegen() {
super();
// set the output folder here
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.
@@ -98,35 +88,21 @@ public class GoServerCodegen extends AbstractGoCodegen {
@Override
public void 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)) {
setPackageName((String) additionalProperties.get(CodegenConstants.PACKAGE_NAME));
} else {
setPackageName("openapi");
}
if (additionalProperties.containsKey(CodegenConstants.PACKAGE_VERSION)) {
this.setPackageVersion((String) additionalProperties.get(CodegenConstants.PACKAGE_VERSION));
} else {
additionalProperties.put(CodegenConstants.PACKAGE_VERSION, packageVersion);
}
if (additionalProperties.containsKey(CodegenConstants.SOURCE_FOLDER)) {
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);
}
/*
* Additional Properties. These values can be passed to the templates and
* are available in models, apis, and supporting files
*/
additionalProperties.put("apiVersion", apiVersion);
additionalProperties.put("serverPort", serverPort);
additionalProperties.put("apiPath", apiPath);
additionalProperties.put(CodegenConstants.PACKAGE_NAME, packageName);
modelPackage = packageName;
apiPackage = packageName;
@@ -139,14 +115,14 @@ public class GoServerCodegen extends AbstractGoCodegen {
supportingFiles.add(new SupportingFile("openapi.mustache", "api", "openapi.yaml"));
supportingFiles.add(new SupportingFile("main.mustache", "", "main.go"));
supportingFiles.add(new SupportingFile("Dockerfile.mustache", "", "Dockerfile"));
supportingFiles.add(new SupportingFile("routers.mustache", sourceFolder, "routers.go"));
supportingFiles.add(new SupportingFile("logger.mustache", sourceFolder, "logger.go"));
writeOptional(outputFolder, new SupportingFile("README.mustache", "", "README.md"));
supportingFiles.add(new SupportingFile("routers.mustache", apiPath, "routers.go"));
supportingFiles.add(new SupportingFile("logger.mustache", apiPath, "logger.go"));
writeOptional(outputFolder, new SupportingFile("README.mustache", apiPath, "README.md"));
}
@Override
public String apiPackage() {
return sourceFolder;
return apiPath;
}
/**
@@ -196,16 +172,5 @@ public class GoServerCodegen extends AbstractGoCodegen {
public String modelFileFolder() {
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;
}
}

View File

@@ -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(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.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.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.x");
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.x. JSON processing: Gson 2.x (Retrofit 1.9.0). IMPORTANT NOTE: retrofit1.x is no longer actively maintained so please upgrade to 'retrofit2' instead.");
supportedLibraries.put(RETROFIT_2, "HTTP client: OkHttp 3.x. JSON processing: Gson 2.x (Retrofit 2.3.0). Enable the RxJava adapter using '-DuseRxJava[2]=true'. (RxJava 1.x or 2.x)");
supportedLibraries.put(RESTTEMPLATE, "HTTP client: Spring RestTemplate 4.x. JSON processing: Jackson 2.8.x");
supportedLibraries.put(WEBCLIENT, "HTTP client: Spring WebClient 5.x. JSON processing: Jackson 2.9.x");
supportedLibraries.put(RESTEASY, "HTTP client: Resteasy client 3.x. JSON processing: Jackson 2.8.x");
supportedLibraries.put(VERTX, "HTTP client: VertX client 3.x. JSON processing: Jackson 2.8.x");
supportedLibraries.put(GOOGLE_API_CLIENT, "HTTP client: Google API client 1.x. JSON processing: Jackson 2.8.x");
supportedLibraries.put(REST_ASSURED, "HTTP client: rest-assured : 3.x. JSON processing: Gson 2.x. Only for Java8");
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(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(JERSEY2, "HTTP client: Jersey client 2.25.1. JSON processing: Jackson 2.8.9");
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(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_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(RESTTEMPLATE, "HTTP client: Spring RestTemplate 4.3.9-RELEASE. JSON processing: Jackson 2.8.9");
supportedLibraries.put(WEBCLIENT, "HTTP client: Spring WebClient 5.0.7-RELEASE. JSON processing: Jackson 2.9.5");
supportedLibraries.put(RESTEASY, "HTTP client: Resteasy client 3.1.3.Final. JSON processing: Jackson 2.8.9");
supportedLibraries.put(VERTX, "HTTP client: VertX client 3.2.4. JSON processing: Jackson 2.8.9");
supportedLibraries.put(GOOGLE_API_CLIENT, "HTTP client: Google API client 1.23.0. JSON processing: Jackson 2.8.9");
supportedLibraries.put(REST_ASSURED, "HTTP client: rest-assured : 3.1.0. JSON processing: Gson 2.6.1. Only for Java8");
CliOption libraryOption = new CliOption(CodegenConstants.LIBRARY, "library template (sub-template) to use");
libraryOption.setEnum(supportedLibraries);

View File

@@ -51,8 +51,8 @@ public class JavascriptClientCodegen extends DefaultCodegen implements CodegenCo
final String[][] JAVASCRIPT_SUPPORTING_FILES = new String[][]{
new String[]{"package.mustache", "package.json"},
// new String[]{"index.mustache", "src/index.js", },
// new String[]{"ApiClient.mustache", "src/ApiClient.js"},
new String[]{"index.mustache", "src/index.js"},
new String[]{"ApiClient.mustache", "src/ApiClient.js"},
new String[]{"git_push.sh.mustache", "git_push.sh"},
new String[]{"README.mustache", "README.md"},
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[][]{
new String[]{"package.mustache", "package.json"},
// new String[]{"index.mustache", "src/index.js"},
// new String[]{"ApiClient.mustache", "src/ApiClient.js"},
new String[]{"index.mustache", "src/index.js"},
new String[]{"ApiClient.mustache", "src/ApiClient.js"},
new String[]{"git_push.sh.mustache", "git_push.sh"},
new String[]{"README.mustache", "README.md"},
new String[]{"mocha.opts", "mocha.opts"},
@@ -85,7 +85,7 @@ public class JavascriptClientCodegen extends DefaultCodegen implements CodegenCo
protected String modelDocPath = "docs/";
protected String apiTestPath = "api/";
protected String modelTestPath = "model/";
protected boolean useES6 = true; // default is ES6
protected boolean useES6 = true; // default is ES5
private String modelPropertyNaming = "camelCase";
public JavascriptClientCodegen() {
@@ -205,7 +205,7 @@ public class JavascriptClientCodegen extends DefaultCodegen implements CodegenCo
@Override
public String getHelp() {
return "Generates a JavaScript client library.";
return "Generates a Javascript client library.";
}
@Override
@@ -337,10 +337,6 @@ public class JavascriptClientCodegen extends DefaultCodegen implements CodegenCo
for (String[] supportingTemplateFile : supportingTemplateFiles) {
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
@@ -377,12 +373,12 @@ public class JavascriptClientCodegen extends DefaultCodegen implements CodegenCo
@Override
public String apiTestFileFolder() {
return createPath(outputFolder, "test", invokerPackage, apiTestPath);
return (outputFolder + "/test/" + apiTestPath).replace('/', File.separatorChar);
}
@Override
public String modelTestFileFolder() {
return createPath(outputFolder, "test", invokerPackage, modelTestPath);
return (outputFolder + "/test/" + modelTestPath).replace('/', File.separatorChar);
}
@Override
@@ -792,7 +788,7 @@ public class JavascriptClientCodegen extends DefaultCodegen implements CodegenCo
* @param type Primitive type
* @return Normalized type
*/
private String normalizeType(String type) {
public String normalizeType(String type) {
return type.replaceAll("\\b(Boolean|Integer|Number|String|Date|Blob)\\b", "'$1'");
}
@@ -871,11 +867,10 @@ public class JavascriptClientCodegen extends DefaultCodegen implements CodegenCo
return codegenModel;
}
/*
private String sanitizePath(String p) {
//prefer replace a ', instead of a fuLL URL encode for readability
return p.replaceAll("'", "%27");
}*/
}
private String trimBrackets(String s) {
if (s != null) {
@@ -964,7 +959,7 @@ public class JavascriptClientCodegen extends DefaultCodegen implements CodegenCo
if (operations != null) {
List<CodegenOperation> ops = (List<CodegenOperation>) operations.get("operation");
for (CodegenOperation operation : ops) {
List<String> argList = new ArrayList<>();
List<String> argList = new ArrayList<String>();
boolean hasOptionalParams = false;
for (CodegenParameter p : operation.allParams) {
if (p.required) {
@@ -981,7 +976,7 @@ public class JavascriptClientCodegen extends DefaultCodegen implements CodegenCo
if (hasOptionalParams) {
argList.add("opts");
}
}
if (!usePromises) {
argList.add("callback");
@@ -1019,7 +1014,7 @@ public class JavascriptClientCodegen extends DefaultCodegen implements CodegenCo
// 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.
List<CodegenProperty> required = new ArrayList<>();
List<CodegenProperty> allRequired = supportsInheritance || supportsMixins ? new ArrayList<>() : required;
List<CodegenProperty> allRequired = supportsInheritance || supportsMixins ? new ArrayList<CodegenProperty>() : required;
cm.vendorExtensions.put("x-required", required);
cm.vendorExtensions.put("x-all-required", allRequired);
@@ -1125,6 +1120,15 @@ public class JavascriptClientCodegen extends DefaultCodegen implements CodegenCo
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
public String toEnumName(CodegenProperty property) {
return sanitizeName(camelize(property.name)) + "Enum";
@@ -1156,18 +1160,12 @@ public class JavascriptClientCodegen extends DefaultCodegen implements CodegenCo
@Override
public String escapeQuotationMark(String input) {
if (input == null) {
return "";
}
// remove ', " to avoid code injection
return input.replace("\"", "").replace("'", "");
}
@Override
public String escapeUnsafeCharacters(String input) {
if (input == null) {
return "";
}
return input.replace("*/", "*_/").replace("/*", "/_*");
}

View File

@@ -164,12 +164,7 @@ public class JavascriptFlowtypedClientCodegen extends AbstractTypeScriptClientCo
}
if (additionalProperties.containsKey(SNAPSHOT) && Boolean.valueOf(additionalProperties.get(SNAPSHOT).toString())) {
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()));
}
this.setNpmVersion(npmVersion + "-SNAPSHOT." + SNAPSHOT_SUFFIX_FORMAT.format(new Date()));
}
additionalProperties.put(NPM_VERSION, npmVersion);

View File

@@ -44,7 +44,7 @@ public class KotlinSpringServerCodegen extends AbstractKotlinCodegen
LoggerFactory.getLogger(KotlinSpringServerCodegen.class);
private static final HashSet<String> VARIABLE_RESERVED_WORDS =
new HashSet<>(Arrays.asList(
new HashSet<String>(Arrays.asList(
"ApiClient",
"ApiException",
"ApiResponse"
@@ -109,10 +109,6 @@ public class KotlinSpringServerCodegen extends AbstractKotlinCodegen
importMapping.put("Date", "java.time.LocalDate");
importMapping.put("DateTime", "java.time.OffsetDateTime");
// use resource for file handling
typeMapping.put("file", "org.springframework.core.io.Resource");
languageSpecificPrimitives.addAll(Arrays.asList(
"Any",
"Byte",
@@ -566,33 +562,4 @@ public class KotlinSpringServerCodegen extends AbstractKotlinCodegen
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;
}
}

View File

@@ -38,8 +38,6 @@ import java.util.*;
import java.util.Map.Entry;
import java.util.regex.Pattern;
import static org.openapitools.codegen.utils.StringUtils.*;
public class NodeJSServerCodegen extends DefaultCodegen implements CodegenConfig {
private static final Logger LOGGER = LoggerFactory.getLogger(NodeJSServerCodegen.class);
@@ -162,7 +160,7 @@ public class NodeJSServerCodegen extends DefaultCodegen implements CodegenConfig
if (name.length() == 0) {
return "DefaultController";
}
return camelize(name);
return initialCaps(name);
}
@Override

View File

@@ -30,8 +30,6 @@ import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;
import java.util.*;
import static org.openapitools.codegen.utils.StringUtils.*;
public class PhpSlimServerCodegen extends AbstractPhpCodegen {
private static final Logger LOGGER = LoggerFactory.getLogger(PhpSlimServerCodegen.class);
@@ -177,7 +175,7 @@ public class PhpSlimServerCodegen extends AbstractPhpCodegen {
if (name.length() == 0) {
return toAbstractName("DefaultApi");
}
return toAbstractName(camelize(name) + "Api");
return toAbstractName(initialCaps(name) + "Api");
}
@Override
@@ -185,7 +183,7 @@ public class PhpSlimServerCodegen extends AbstractPhpCodegen {
if (name.length() == 0) {
return "DefaultApiTest";
}
return camelize(name) + "ApiTest";
return initialCaps(name) + "ApiTest";
}
/**

View File

@@ -324,10 +324,10 @@ public class PythonAbstractConnexionServerCodegen extends DefaultCodegen impleme
// Fix path parameters to be in snake_case
if (pathname.contains("{")) {
String fixedPath = new String();
for (String token : pathname.substring(1).split("/")) {
for (String token: pathname.substring(1).split("/")) {
if (token.startsWith("{")) {
String snake_case_token = "{" + this.toParamName(token.substring(1, token.length() - 1)) + "}";
if (!token.equals(snake_case_token)) {
String snake_case_token = "{" + this.toParamName(token.substring(1, token.length()-1)) + "}";
if(!token.equals(snake_case_token)) {
token = snake_case_token;
}
}
@@ -336,7 +336,6 @@ public class PythonAbstractConnexionServerCodegen extends DefaultCodegen impleme
if (!fixedPath.equals(pathname)) {
LOGGER.warn("Path '" + pathname + "' is not consistant with Python variable names. It will be replaced by '" + fixedPath + "'");
paths.remove(pathname);
path.addExtension("x-python-connexion-openapi-name", pathname);
paths.put(fixedPath, path);
}
}
@@ -360,12 +359,11 @@ public class PythonAbstractConnexionServerCodegen extends DefaultCodegen impleme
);
}
if (operation.getParameters() != null) {
for (Parameter parameter : operation.getParameters()) {
for (Parameter parameter: operation.getParameters()) {
String swaggerParameterName = parameter.getName();
String pythonParameterName = this.toParamName(swaggerParameterName);
if (!swaggerParameterName.equals(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);
}
if (swaggerParameterName.isEmpty()) {
@@ -379,7 +377,8 @@ public class PythonAbstractConnexionServerCodegen extends DefaultCodegen impleme
String bodyParameterName = "body";
if (operation.getExtensions() != null && operation.getExtensions().containsKey("x-codegen-request-body-name")) {
bodyParameterName = (String) operation.getExtensions().get("x-codegen-request-body-name");
} else {
}
else {
// Used by code generator
operation.addExtension("x-codegen-request-body-name", bodyParameterName);
}
@@ -393,7 +392,7 @@ public class PythonAbstractConnexionServerCodegen extends DefaultCodegen impleme
// Sort path names after variable name fix
List<String> fixedPathnames = new ArrayList(paths.keySet());
Collections.sort(fixedPathnames);
for (String pathname : fixedPathnames) {
for (String pathname: fixedPathnames) {
PathItem pathItem = paths.remove(pathname);
paths.put(pathname, pathItem);
}
@@ -402,7 +401,7 @@ public class PythonAbstractConnexionServerCodegen extends DefaultCodegen impleme
}
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);
}
}
@@ -411,17 +410,18 @@ public class PythonAbstractConnexionServerCodegen extends DefaultCodegen impleme
Components components = openAPI.getComponents();
if (components != null && components.getSecuritySchemes() != null) {
Map<String, SecurityScheme> securitySchemes = components.getSecuritySchemes();
for (String securityName : securitySchemes.keySet()) {
for(String securityName: securitySchemes.keySet()) {
SecurityScheme securityScheme = securitySchemes.get(securityName);
String baseFunctionName = controllerPackage + ".security_controller_.";
switch (securityScheme.getType()) {
switch(securityScheme.getType()) {
case APIKEY:
addSecurityExtension(securityScheme, "x-apikeyInfoFunc", baseFunctionName + "info_from_" + securityName);
break;
case HTTP:
if ("basic".equals(securityScheme.getScheme())) {
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);
}
break;
@@ -474,68 +474,6 @@ public class PythonAbstractConnexionServerCodegen extends DefaultCodegen impleme
@Override
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);
for (Map<String, Object> operations : getOperations(objs)) {
@@ -643,7 +581,6 @@ public class PythonAbstractConnexionServerCodegen extends DefaultCodegen impleme
/**
* Return the default value of the property
*
* @param p OpenAPI property object
* @return string presentation of the default value of the property
*/
@@ -754,7 +691,8 @@ public class PythonAbstractConnexionServerCodegen extends DefaultCodegen impleme
if (example == null) {
if (Boolean.TRUE.equals(p.isListContainer)) {
example = "[]";
} else {
}
else {
example = "None";
}
} else if (Boolean.TRUE.equals(p.isListContainer)) {
@@ -861,7 +799,7 @@ public class PythonAbstractConnexionServerCodegen extends DefaultCodegen impleme
for (CodegenOperation operation : operationList) {
Map<String, String> skipTests = new HashMap<>();
// Set flag to deactivate tests due to connexion issue.
if (operation.consumes != null) {
if (operation.consumes != null ) {
if (operation.consumes.size() == 1) {
Map<String, String> consume = operation.consumes.get(0);
if (!("application/json".equals(consume.get(MEDIA_TYPE))
@@ -872,7 +810,8 @@ public class PythonAbstractConnexionServerCodegen extends DefaultCodegen impleme
}
}
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);
skipTests.put("reason", "Connexion does not support multiple consummes. See https://github.com/zalando/connexion/pull/760");
operation.vendorExtensions.put("x-prefered-consume", consume);
@@ -880,7 +819,8 @@ public class PythonAbstractConnexionServerCodegen extends DefaultCodegen impleme
operation.isMultipart = Boolean.TRUE;
}
}
} else {
}
else {
// A body without consumes means '*/*' has been used instead of application/json
if (operation.bodyParam != null) {
Map<String, String> consume = new HashMap<>();
@@ -890,19 +830,19 @@ public class PythonAbstractConnexionServerCodegen extends DefaultCodegen impleme
}
}
// Choose to consume 'application/json' if available, else choose the last one.
if (operation.produces != null) {
for (Map<String, String> produce : operation.produces) {
if (operation.produces != null ) {
for (Map<String, String> produce: operation.produces) {
operation.vendorExtensions.put("x-prefered-produce", produce);
if (produce.get(MEDIA_TYPE).equals("application/json")) {
break;
}
}
}
if (!skipTests.isEmpty()) {
if (! skipTests.isEmpty()) {
operation.vendorExtensions.put("x-skip-test", skipTests);
}
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")) {
operation.bodyParam.example = example.get("example");
}

Some files were not shown because too many files have changed in this diff Show More