forked from loafle/openapi-generator-original
Merge branch 'master' into java-docs
Conflicts: modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/JavaClientCodegen.java samples/client/petstore/java/default/pom.xml samples/client/petstore/java/default/src/main/java/io/swagger/client/model/Animal.java samples/client/petstore/java/default/src/main/java/io/swagger/client/model/Cat.java samples/client/petstore/java/default/src/main/java/io/swagger/client/model/Dog.java samples/client/petstore/java/default/src/main/java/io/swagger/client/model/Name.java samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/Name.java samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/model/Cat.java samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/model/Dog.java samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/model/Name.java samples/client/petstore/java/retrofit/src/main/java/io/swagger/client/StringUtil.java samples/client/petstore/java/retrofit/src/main/java/io/swagger/client/model/Model200Response.java samples/client/petstore/java/retrofit/src/main/java/io/swagger/client/model/ModelReturn.java samples/client/petstore/java/retrofit/src/main/java/io/swagger/client/model/Name.java samples/client/petstore/java/retrofit2/src/main/java/io/swagger/client/StringUtil.java samples/client/petstore/java/retrofit2/src/main/java/io/swagger/client/model/Model200Response.java samples/client/petstore/java/retrofit2/src/main/java/io/swagger/client/model/ModelReturn.java samples/client/petstore/java/retrofit2/src/main/java/io/swagger/client/model/Name.java samples/client/petstore/java/retrofit2rx/src/main/java/io/swagger/client/StringUtil.java samples/client/petstore/java/retrofit2rx/src/main/java/io/swagger/client/model/Model200Response.java samples/client/petstore/java/retrofit2rx/src/main/java/io/swagger/client/model/ModelReturn.java samples/client/petstore/java/retrofit2rx/src/main/java/io/swagger/client/model/Name.java
This commit is contained in:
commit
f10d4c8e23
11
.gitignore
vendored
11
.gitignore
vendored
@ -43,6 +43,7 @@ samples/server-generator/scalatra/output/.history
|
|||||||
# nodejs
|
# nodejs
|
||||||
samples/server-generator/node/output/node_modules
|
samples/server-generator/node/output/node_modules
|
||||||
samples/server/petstore/nodejs/node_modules
|
samples/server/petstore/nodejs/node_modules
|
||||||
|
samples/server/petstore/nodejs-server/node_modules
|
||||||
|
|
||||||
# qt5 cpp
|
# qt5 cpp
|
||||||
samples/client/petstore/qt5cpp/PetStore/moc_*
|
samples/client/petstore/qt5cpp/PetStore/moc_*
|
||||||
@ -55,6 +56,12 @@ samples/client/petstore/qt5cpp/PetStore/Makefile
|
|||||||
**/.gradle/
|
**/.gradle/
|
||||||
samples/client/petstore/java/hello.txt
|
samples/client/petstore/java/hello.txt
|
||||||
samples/client/petstore/android/default/hello.txt
|
samples/client/petstore/android/default/hello.txt
|
||||||
|
samples/client/petstore/android/volley/.gradle/
|
||||||
|
samples/client/petstore/android/volley/build/
|
||||||
|
samples/client/petstore/java/jersey2/.gradle/
|
||||||
|
samples/client/petstore/java/jersey2/build/
|
||||||
|
samples/client/petstore/java/okhttp-gson/.gradle/
|
||||||
|
samples/client/petstore/java/okhttp-gson/build/
|
||||||
|
|
||||||
#PHP
|
#PHP
|
||||||
samples/client/petstore/php/SwaggerClient-php/composer.lock
|
samples/client/petstore/php/SwaggerClient-php/composer.lock
|
||||||
@ -87,6 +94,10 @@ samples/client/petstore/csharp/SwaggerClientTest/bin
|
|||||||
samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/vendor/
|
samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/vendor/
|
||||||
samples/client/petstore/csharp/SwaggerClientTest/bin/Debug/
|
samples/client/petstore/csharp/SwaggerClientTest/bin/Debug/
|
||||||
samples/client/petstore/csharp/SwaggerClientTest/obj/Debug/
|
samples/client/petstore/csharp/SwaggerClientTest/obj/Debug/
|
||||||
|
samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/nuget.exe
|
||||||
|
samples/client/petstore/csharp/SwaggerClientTest/TestResult.xml
|
||||||
|
samples/client/petstore/csharp/SwaggerClientTest/nuget.exe
|
||||||
|
samples/client/petstore/csharp/SwaggerClientTest/testrunner/
|
||||||
|
|
||||||
# Python
|
# Python
|
||||||
*.pyc
|
*.pyc
|
||||||
|
@ -13,6 +13,7 @@
|
|||||||
|
|
||||||
- Search the [open issue](https://github.com/swagger-api/swagger-codegen/issues) to ensure no one else has reported something similar and no one is actively working on similar proposed change.
|
- Search the [open issue](https://github.com/swagger-api/swagger-codegen/issues) to ensure no one else has reported something similar and no one is actively working on similar proposed change.
|
||||||
- If no one has suggested something similar, open an ["issue"](https://github.com/swagger-api/swagger-codegen/issues) with your suggestion to gather feedback from the community.
|
- If no one has suggested something similar, open an ["issue"](https://github.com/swagger-api/swagger-codegen/issues) with your suggestion to gather feedback from the community.
|
||||||
|
- It's recommended to **create a new git branch** for the change
|
||||||
|
|
||||||
## How to contribute
|
## How to contribute
|
||||||
|
|
||||||
@ -31,8 +32,10 @@ For a list of variables available in the template, please refer to this [page](h
|
|||||||
Code change should conform to the programming style guide of the respective langauages:
|
Code change should conform to the programming style guide of the respective langauages:
|
||||||
- C#: https://msdn.microsoft.com/en-us/library/vstudio/ff926074.aspx
|
- C#: https://msdn.microsoft.com/en-us/library/vstudio/ff926074.aspx
|
||||||
- Java: https://google.github.io/styleguide/javaguide.html
|
- Java: https://google.github.io/styleguide/javaguide.html
|
||||||
- JavaScript - https://github.com/airbnb/javascript/tree/master/es5
|
- JavaScript: https://github.com/airbnb/javascript/tree/master/es5
|
||||||
|
- Go: https://github.com/golang/go/wiki/CodeReviewComments
|
||||||
- ObjC: https://github.com/NYTimes/objective-c-style-guide
|
- ObjC: https://github.com/NYTimes/objective-c-style-guide
|
||||||
|
- Perl: http://perldoc.perl.org/perlstyle.html
|
||||||
- PHP: https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-2-coding-style-guide.md
|
- PHP: https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-2-coding-style-guide.md
|
||||||
- Python: https://www.python.org/dev/peps/pep-0008/
|
- Python: https://www.python.org/dev/peps/pep-0008/
|
||||||
- Ruby: https://github.com/bbatsov/ruby-style-guide
|
- Ruby: https://github.com/bbatsov/ruby-style-guide
|
||||||
|
22
README.md
22
README.md
@ -6,6 +6,8 @@
|
|||||||
|
|
||||||
:star::star::star: If you would like to contribute, please refer to [guidelines](https://github.com/swagger-api/swagger-codegen/blob/master/CONTRIBUTING.md) and a list of [open tasks](https://github.com/swagger-api/swagger-codegen/issues?q=is%3Aopen+is%3Aissue+label%3A%22Need+community+contribution%22).:star::star::star:
|
:star::star::star: If you would like to contribute, please refer to [guidelines](https://github.com/swagger-api/swagger-codegen/blob/master/CONTRIBUTING.md) and a list of [open tasks](https://github.com/swagger-api/swagger-codegen/issues?q=is%3Aopen+is%3Aissue+label%3A%22Need+community+contribution%22).:star::star::star:
|
||||||
|
|
||||||
|
:notebook_with_decorative_cover: For more information, please refer to the [Wiki page](https://github.com/swagger-api/swagger-codegen/wiki) and [FAQ](https://github.com/swagger-api/swagger-codegen/wiki/FAQ) :notebook_with_decorative_cover:
|
||||||
|
|
||||||
## Overview
|
## Overview
|
||||||
This is the swagger codegen project, which allows generation of client libraries automatically from a Swagger-compliant server.
|
This is the swagger codegen project, which allows generation of client libraries automatically from a Swagger-compliant server.
|
||||||
|
|
||||||
@ -46,6 +48,7 @@ Check out [Swagger-Spec](https://github.com/OAI/OpenAPI-Specification) for addit
|
|||||||
- [Scala Scalatra](#scala-scalatra)
|
- [Scala Scalatra](#scala-scalatra)
|
||||||
- [Java JAX-RS (Java JAX-RS (Jersey v1.18)](#java-jax-rs-jersey-v118)
|
- [Java JAX-RS (Java JAX-RS (Jersey v1.18)](#java-jax-rs-jersey-v118)
|
||||||
- [Java JAX-RS (Apache CXF 2 / 3)](#java-jax-rs-apache-cxf-2--3)
|
- [Java JAX-RS (Apache CXF 2 / 3)](#java-jax-rs-apache-cxf-2--3)
|
||||||
|
- [Java JAX-RS (Resteasy)](#java-jax-rs-resteasy)
|
||||||
- [Java Spring MVC](#java-spring-mvc)
|
- [Java Spring MVC](#java-spring-mvc)
|
||||||
- [Haskell Servant](#haskell-servant)
|
- [Haskell Servant](#haskell-servant)
|
||||||
- [ASP.NET 5 Web API](#aspnet-5-web-api)
|
- [ASP.NET 5 Web API](#aspnet-5-web-api)
|
||||||
@ -63,8 +66,8 @@ The OpenAPI Specification has undergone 3 revisions since initial creation in 20
|
|||||||
|
|
||||||
Swagger Codegen Version | Release Date | OpenAPI Spec compatibility | Notes
|
Swagger Codegen Version | Release Date | OpenAPI Spec compatibility | Notes
|
||||||
-------------------------- | ------------ | -------------------------- | -----
|
-------------------------- | ------------ | -------------------------- | -----
|
||||||
2.1.6-SNAPSHOT | | 1.0, 1.1, 1.2, 2.0 | [master](https://github.com/swagger-api/swagger-codegen)
|
2.1.7-SNAPSHOT | | 1.0, 1.1, 1.2, 2.0 | [master](https://github.com/swagger-api/swagger-codegen)
|
||||||
2.1.5 (**current stable**) | 2015-01-06 | 1.0, 1.1, 1.2, 2.0 | [tag v2.1.5](https://github.com/swagger-api/swagger-codegen/tree/v2.1.5)
|
2.1.6 (**current stable**) | 2016-04-06 | 1.0, 1.1, 1.2, 2.0 | [tag v2.1.6](https://github.com/swagger-api/swagger-codegen/tree/v2.1.6)
|
||||||
2.0.17 | 2014-08-22 | 1.1, 1.2 | [tag v2.0.17](https://github.com/swagger-api/swagger-codegen/tree/v2.0.17)
|
2.0.17 | 2014-08-22 | 1.1, 1.2 | [tag v2.0.17](https://github.com/swagger-api/swagger-codegen/tree/v2.0.17)
|
||||||
1.0.4 | 2012-04-12 | 1.0, 1.1 | [tag v1.0.4](https://github.com/swagger-api/swagger-codegen/tree/swagger-codegen_2.9.1-1.1)
|
1.0.4 | 2012-04-12 | 1.0, 1.1 | [tag v1.0.4](https://github.com/swagger-api/swagger-codegen/tree/swagger-codegen_2.9.1-1.1)
|
||||||
|
|
||||||
@ -73,7 +76,7 @@ Swagger Codegen Version | Release Date | OpenAPI Spec compatibility | Notes
|
|||||||
If you're looking for the latest stable version, you can grab it directly from maven central (you'll need java 7 runtime at a minimum):
|
If you're looking for the latest stable version, you can grab it directly from maven central (you'll need java 7 runtime at a minimum):
|
||||||
|
|
||||||
```
|
```
|
||||||
wget http://repo1.maven.org/maven2/io/swagger/swagger-codegen-cli/2.1.5/swagger-codegen-cli-2.1.5.jar -O swagger-codegen-cli.jar
|
wget http://repo1.maven.org/maven2/io/swagger/swagger-codegen-cli/2.1.6/swagger-codegen-cli-2.1.6.jar -O swagger-codegen-cli.jar
|
||||||
|
|
||||||
java -jar swagger-codegen-cli.jar help
|
java -jar swagger-codegen-cli.jar help
|
||||||
```
|
```
|
||||||
@ -387,6 +390,7 @@ JavaCXFServerCodegen.java
|
|||||||
JavaClientCodegen.java
|
JavaClientCodegen.java
|
||||||
JavaInflectorServerCodegen.java
|
JavaInflectorServerCodegen.java
|
||||||
JavaJerseyServerCodegen.java
|
JavaJerseyServerCodegen.java
|
||||||
|
JavaResteasyServerCodegen.java
|
||||||
JavascriptClientCodegen.java
|
JavascriptClientCodegen.java
|
||||||
NodeJSServerCodegen.java
|
NodeJSServerCodegen.java
|
||||||
ObjcClientCodegen.java
|
ObjcClientCodegen.java
|
||||||
@ -563,7 +567,7 @@ You can also use the codegen to generate a server for a couple different framewo
|
|||||||
```
|
```
|
||||||
java -jar modules/swagger-codegen-cli/target/swagger-codegen-cli.jar generate \
|
java -jar modules/swagger-codegen-cli/target/swagger-codegen-cli.jar generate \
|
||||||
-i http://petstore.swagger.io/v2/swagger.json \
|
-i http://petstore.swagger.io/v2/swagger.json \
|
||||||
-l nodejs \
|
-l nodejs-server \
|
||||||
-o samples/server/petstore/nodejs
|
-o samples/server/petstore/nodejs
|
||||||
```
|
```
|
||||||
|
|
||||||
@ -645,6 +649,14 @@ You must register this class into your JAX-RS configuration file:
|
|||||||
|
|
||||||
This is no longer necessary if you are using CXF >=v3.x
|
This is no longer necessary if you are using CXF >=v3.x
|
||||||
|
|
||||||
|
### Java JAX-RS (Resteasy)
|
||||||
|
|
||||||
|
```
|
||||||
|
java -jar modules/swagger-codegen-cli/target/swagger-codegen-cli.jar generate \
|
||||||
|
-i http://petstore.swagger.io/v2/swagger.json \
|
||||||
|
-l jaxrs-resteasy \
|
||||||
|
-o samples/server/petstore/jaxrs-resteasy
|
||||||
|
```
|
||||||
|
|
||||||
### Java Spring MVC
|
### Java Spring MVC
|
||||||
|
|
||||||
@ -730,6 +742,7 @@ Here are some companies/projects using Swagger Codegen in production. To add you
|
|||||||
- [Acunetix](https://www.acunetix.com/)
|
- [Acunetix](https://www.acunetix.com/)
|
||||||
- [Atlassian](https://www.atlassian.com/)
|
- [Atlassian](https://www.atlassian.com/)
|
||||||
- [beemo](http://www.beemo.eu)
|
- [beemo](http://www.beemo.eu)
|
||||||
|
- [Cachet Financial](http://www.cachetfinancial.com/)
|
||||||
- [CloudBoost](https://www.CloudBoost.io/)
|
- [CloudBoost](https://www.CloudBoost.io/)
|
||||||
- [Cupix](http://www.cupix.com)
|
- [Cupix](http://www.cupix.com)
|
||||||
- [DocuSign](https://www.docusign.com)
|
- [DocuSign](https://www.docusign.com)
|
||||||
@ -738,6 +751,7 @@ Here are some companies/projects using Swagger Codegen in production. To add you
|
|||||||
- [everystory.us](http://everystory.us)
|
- [everystory.us](http://everystory.us)
|
||||||
- [Expected Behavior](http://www.expectedbehavior.com/)
|
- [Expected Behavior](http://www.expectedbehavior.com/)
|
||||||
- [FH Münster - University of Applied Sciences](http://www.fh-muenster.de)
|
- [FH Münster - University of Applied Sciences](http://www.fh-muenster.de)
|
||||||
|
- [Interactive Intelligence](http://developer.mypurecloud.com/)
|
||||||
- [LANDR Audio](https://www.landr.com/)
|
- [LANDR Audio](https://www.landr.com/)
|
||||||
- [LiveAgent](https://www.ladesk.com/)
|
- [LiveAgent](https://www.ladesk.com/)
|
||||||
- [Kuary](https://kuary.com/)
|
- [Kuary](https://kuary.com/)
|
||||||
|
@ -26,6 +26,6 @@ fi
|
|||||||
|
|
||||||
# if you've executed sbt assembly previously it will use that instead.
|
# if you've executed sbt assembly previously it will use that instead.
|
||||||
export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties"
|
export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties"
|
||||||
ags="$@ generate -t modules/swagger-codegen/src/main/resources/akka-scala -i modules/swagger-codegen/src/test/resources/2_0/petstore.json -l akka-scala -o samples/client/petstore/akka-scala"
|
ags="$@ generate -t modules/swagger-codegen/src/main/resources/akka-scala -i modules/swagger-codegen/src/test/resources/2_0/petstore.yaml -l akka-scala -o samples/client/petstore/akka-scala"
|
||||||
|
|
||||||
java $JAVA_OPTS -jar $executable $ags
|
java $JAVA_OPTS -jar $executable $ags
|
||||||
|
@ -1,24 +0,0 @@
|
|||||||
#!/bin/sh
|
|
||||||
|
|
||||||
SCRIPT="$0"
|
|
||||||
|
|
||||||
while [ -h "$SCRIPT" ] ; do
|
|
||||||
ls=`ls -ld "$SCRIPT"`
|
|
||||||
link=`expr "$ls" : '.*-> \(.*\)$'`
|
|
||||||
if expr "$link" : '/.*' > /dev/null; then
|
|
||||||
SCRIPT="$link"
|
|
||||||
else
|
|
||||||
SCRIPT=`dirname "$SCRIPT"`/"$link"
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
|
|
||||||
if [ ! -d "${APP_DIR}" ]; then
|
|
||||||
APP_DIR=`dirname "$SCRIPT"`/..
|
|
||||||
APP_DIR=`cd "${APP_DIR}"; pwd`
|
|
||||||
fi
|
|
||||||
|
|
||||||
cd $APP_DIR
|
|
||||||
./bin/android-java-wordnik-api.sh
|
|
||||||
./bin/java-wordnik-api.sh
|
|
||||||
./bin/objc-wordnik-api.sh
|
|
||||||
./bin/scala-wordnik-api.sh
|
|
@ -1,31 +0,0 @@
|
|||||||
#!/bin/sh
|
|
||||||
|
|
||||||
SCRIPT="$0"
|
|
||||||
|
|
||||||
while [ -h "$SCRIPT" ] ; do
|
|
||||||
ls=`ls -ld "$SCRIPT"`
|
|
||||||
link=`expr "$ls" : '.*-> \(.*\)$'`
|
|
||||||
if expr "$link" : '/.*' > /dev/null; then
|
|
||||||
SCRIPT="$link"
|
|
||||||
else
|
|
||||||
SCRIPT=`dirname "$SCRIPT"`/"$link"
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
|
|
||||||
if [ ! -d "${APP_DIR}" ]; then
|
|
||||||
APP_DIR=`dirname "$SCRIPT"`/..
|
|
||||||
APP_DIR=`cd "${APP_DIR}"; pwd`
|
|
||||||
fi
|
|
||||||
|
|
||||||
executable="./modules/swagger-codegen-cli/target/swagger-codegen-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/swagger-codegen/src/test/resources/2_0/wordnik.json -l android -o samples/client/wordnik/android-java"
|
|
||||||
|
|
||||||
java $JAVA_OPTS -jar $executable $ags
|
|
@ -26,6 +26,6 @@ fi
|
|||||||
|
|
||||||
# if you've executed sbt assembly previously it will use that instead.
|
# if you've executed sbt assembly previously it will use that instead.
|
||||||
export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties"
|
export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties"
|
||||||
ags="$@ generate -l aspnet5 -i modules/swagger-codegen/src/test/resources/2_0/petstore.json -o samples/server/petstore/aspnet5"
|
ags="$@ generate -l aspnet5 -i modules/swagger-codegen/src/test/resources/2_0/petstore.yaml -o samples/server/petstore/aspnet5"
|
||||||
|
|
||||||
java $JAVA_OPTS -jar $executable $ags
|
java $JAVA_OPTS -jar $executable $ags
|
||||||
|
@ -26,6 +26,6 @@ fi
|
|||||||
|
|
||||||
# if you've executed sbt assembly previously it will use that instead.
|
# if you've executed sbt assembly previously it will use that instead.
|
||||||
export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties"
|
export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties"
|
||||||
ags="$@ generate -i modules/swagger-codegen/src/test/resources/2_0/petstore.json -l CsharpDotNet2 -o samples/client/petstore/csharp-dotnet2/SwaggerClientTest/Lib/SwaggerClient"
|
ags="$@ generate -i modules/swagger-codegen/src/test/resources/2_0/petstore.yaml -l CsharpDotNet2 -o samples/client/petstore/csharp-dotnet2/SwaggerClientTest/Lib/SwaggerClient"
|
||||||
|
|
||||||
java $JAVA_OPTS -jar $executable $ags
|
java $JAVA_OPTS -jar $executable $ags
|
||||||
|
@ -26,6 +26,6 @@ fi
|
|||||||
|
|
||||||
# if you've executed sbt assembly previously it will use that instead.
|
# if you've executed sbt assembly previously it will use that instead.
|
||||||
export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties"
|
export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties"
|
||||||
ags="$@ generate -i modules/swagger-codegen/src/test/resources/2_0/petstore.json -l csharp -o samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient"
|
ags="$@ generate -i modules/swagger-codegen/src/test/resources/2_0/petstore-with-fake-endpoints-models-for-testing.yaml -l csharp -o samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient"
|
||||||
|
|
||||||
java $JAVA_OPTS -jar $executable $ags
|
java $JAVA_OPTS -jar $executable $ags
|
||||||
|
@ -26,6 +26,6 @@ fi
|
|||||||
|
|
||||||
# if you've executed sbt assembly previously it will use that instead.
|
# if you've executed sbt assembly previously it will use that instead.
|
||||||
export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties"
|
export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties"
|
||||||
ags="$@ generate -i modules/swagger-codegen/src/test/resources/2_0/petstore.json -l dart -o samples/client/petstore/dart"
|
ags="$@ generate -i modules/swagger-codegen/src/test/resources/2_0/petstore.yaml -l dart -o samples/client/petstore/dart"
|
||||||
|
|
||||||
java $JAVA_OPTS -jar $executable $ags
|
java $JAVA_OPTS -jar $executable $ags
|
||||||
|
@ -26,6 +26,6 @@ fi
|
|||||||
|
|
||||||
# if you've executed sbt assembly previously it will use that instead.
|
# if you've executed sbt assembly previously it will use that instead.
|
||||||
export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties"
|
export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties"
|
||||||
ags="$@ generate -i modules/swagger-codegen/src/test/resources/2_0/petstore.json -l dynamic-html -o samples/dynamic-html"
|
ags="$@ generate -i modules/swagger-codegen/src/test/resources/2_0/petstore.yaml -l dynamic-html -o samples/dynamic-html"
|
||||||
|
|
||||||
java $JAVA_OPTS -jar $executable $ags
|
java $JAVA_OPTS -jar $executable $ags
|
||||||
|
@ -26,6 +26,6 @@ fi
|
|||||||
|
|
||||||
# if you've executed sbt assembly previously it will use that instead.
|
# if you've executed sbt assembly previously it will use that instead.
|
||||||
export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties"
|
export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties"
|
||||||
ags="$@ generate -t modules/swagger-codegen/src/main/resources/flash -i modules/swagger-codegen/src/test/resources/2_0/petstore.json -l flash -o samples/client/petstore/flash"
|
ags="$@ generate -t modules/swagger-codegen/src/main/resources/flash -i modules/swagger-codegen/src/test/resources/2_0/petstore.yaml -l flash -o samples/client/petstore/flash"
|
||||||
|
|
||||||
java $JAVA_OPTS -jar $executable $ags
|
java $JAVA_OPTS -jar $executable $ags
|
||||||
|
@ -26,6 +26,6 @@ fi
|
|||||||
|
|
||||||
# if you've executed sbt assembly previously it will use that instead.
|
# if you've executed sbt assembly previously it will use that instead.
|
||||||
export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties"
|
export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties"
|
||||||
ags="$@ generate -i modules/swagger-codegen/src/test/resources/2_0/petstore.json -l python-flask -o samples/server/petstore/flaskConnexion "
|
ags="$@ generate -i modules/swagger-codegen/src/test/resources/2_0/petstore.yaml -l python-flask -o samples/server/petstore/flaskConnexion "
|
||||||
|
|
||||||
java $JAVA_OPTS -Dservice -jar $executable $ags
|
java $JAVA_OPTS -Dservice -jar $executable $ags
|
||||||
|
@ -26,6 +26,6 @@ fi
|
|||||||
|
|
||||||
# if you've executed sbt assembly previously it will use that instead.
|
# if you've executed sbt assembly previously it will use that instead.
|
||||||
export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties"
|
export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties"
|
||||||
ags="$@ generate -t modules/swagger-codegen/src/main/resources/go -i modules/swagger-codegen/src/test/resources/2_0/petstore.json -l go -o samples/client/petstore/go"
|
ags="$@ generate -t modules/swagger-codegen/src/main/resources/go -i modules/swagger-codegen/src/test/resources/2_0/petstore.yaml -l go -o samples/client/petstore/go/go-petstore"
|
||||||
|
|
||||||
java $JAVA_OPTS -jar $executable $ags
|
java $JAVA_OPTS -jar $executable $ags
|
||||||
|
@ -26,6 +26,6 @@ fi
|
|||||||
|
|
||||||
# if you've executed sbt assembly previously it will use that instead.
|
# if you've executed sbt assembly previously it will use that instead.
|
||||||
export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties"
|
export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties"
|
||||||
ags="$@ generate -t modules/swagger-codegen/src/main/resources/haskell-servant -i modules/swagger-codegen/src/test/resources/2_0/petstore.json -l haskell-servant -o samples/server/petstore/haskell-servant"
|
ags="$@ generate -t modules/swagger-codegen/src/main/resources/haskell-servant -i modules/swagger-codegen/src/test/resources/2_0/petstore.yaml -l haskell-servant -o samples/server/petstore/haskell-servant"
|
||||||
|
|
||||||
java $JAVA_OPTS -jar $executable $ags
|
java $JAVA_OPTS -jar $executable $ags
|
||||||
|
@ -26,6 +26,6 @@ fi
|
|||||||
|
|
||||||
# if you've executed sbt assembly previously it will use that instead.
|
# if you've executed sbt assembly previously it will use that instead.
|
||||||
export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties"
|
export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties"
|
||||||
ags="$@ generate -i modules/swagger-codegen/src/test/resources/2_0/petstore.json -l html -o samples/html"
|
ags="$@ generate -i modules/swagger-codegen/src/test/resources/2_0/petstore.yaml -l html -o samples/html"
|
||||||
|
|
||||||
java $JAVA_OPTS -jar $executable $ags
|
java $JAVA_OPTS -jar $executable $ags
|
||||||
|
@ -26,6 +26,6 @@ fi
|
|||||||
|
|
||||||
# if you've executed sbt assembly previously it will use that instead.
|
# if you've executed sbt assembly previously it will use that instead.
|
||||||
export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties"
|
export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties"
|
||||||
ags="$@ generate -t modules/swagger-codegen/src/main/resources/JavaInflector -i modules/swagger-codegen/src/test/resources/2_0/petstore.json -l inflector -o samples/server/petstore/java-inflector"
|
ags="$@ generate -t modules/swagger-codegen/src/main/resources/JavaInflector -i modules/swagger-codegen/src/test/resources/2_0/petstore.yaml -l inflector -o samples/server/petstore/java-inflector"
|
||||||
|
|
||||||
java $JAVA_OPTS -jar $executable $ags
|
java $JAVA_OPTS -jar $executable $ags
|
||||||
|
@ -7,3 +7,4 @@
|
|||||||
./bin/java-petstore-okhttp-gson.sh
|
./bin/java-petstore-okhttp-gson.sh
|
||||||
./bin/java-petstore-retrofit.sh
|
./bin/java-petstore-retrofit.sh
|
||||||
./bin/java-petstore-retrofit2.sh
|
./bin/java-petstore-retrofit2.sh
|
||||||
|
./bin/java-petstore-retrofit2rx.sh
|
||||||
|
@ -26,6 +26,6 @@ fi
|
|||||||
|
|
||||||
# if you've executed sbt assembly previously it will use that instead.
|
# if you've executed sbt assembly previously it will use that instead.
|
||||||
export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties"
|
export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties"
|
||||||
ags="$@ generate -i modules/swagger-codegen/src/test/resources/2_0/petstore.json -l java -c bin/java-petstore-feign.json -o samples/client/petstore/java/feign"
|
ags="$@ generate -i modules/swagger-codegen/src/test/resources/2_0/petstore-with-fake-endpoints-models-for-testing.yaml -l java -c bin/java-petstore-feign.json -o samples/client/petstore/java/feign"
|
||||||
|
|
||||||
java $JAVA_OPTS -jar $executable $ags
|
java $JAVA_OPTS -jar $executable $ags
|
||||||
|
@ -26,6 +26,6 @@ fi
|
|||||||
|
|
||||||
# if you've executed sbt assembly previously it will use that instead.
|
# if you've executed sbt assembly previously it will use that instead.
|
||||||
export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties"
|
export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties"
|
||||||
ags="$@ generate -i modules/swagger-codegen/src/test/resources/2_0/petstore.json -l java -c bin/java-petstore-jersey2.json -o samples/client/petstore/java/jersey2"
|
ags="$@ generate -i modules/swagger-codegen/src/test/resources/2_0/petstore-with-fake-endpoints-models-for-testing.yaml -l java -c bin/java-petstore-jersey2.json -o samples/client/petstore/java/jersey2"
|
||||||
|
|
||||||
java $JAVA_OPTS -jar $executable $ags
|
java $JAVA_OPTS -jar $executable $ags
|
||||||
|
@ -26,6 +26,6 @@ fi
|
|||||||
|
|
||||||
# if you've executed sbt assembly previously it will use that instead.
|
# if you've executed sbt assembly previously it will use that instead.
|
||||||
export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties"
|
export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties"
|
||||||
ags="$@ generate -i modules/swagger-codegen/src/test/resources/2_0/petstore.json -l java -c bin/java-petstore-okhttp-gson.json -o samples/client/petstore/java/okhttp-gson"
|
ags="$@ generate -i modules/swagger-codegen/src/test/resources/2_0/petstore-with-fake-endpoints-models-for-testing.yaml -l java -c bin/java-petstore-okhttp-gson.json -o samples/client/petstore/java/okhttp-gson"
|
||||||
|
|
||||||
java $JAVA_OPTS -jar $executable $ags
|
java $JAVA_OPTS -jar $executable $ags
|
||||||
|
@ -26,6 +26,6 @@ fi
|
|||||||
|
|
||||||
# if you've executed sbt assembly previously it will use that instead.
|
# if you've executed sbt assembly previously it will use that instead.
|
||||||
export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties"
|
export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties"
|
||||||
ags="$@ generate -i modules/swagger-codegen/src/test/resources/2_0/petstore.json -l java -c bin/java-petstore-retrofit.json -o samples/client/petstore/java/retrofit"
|
ags="$@ generate -i modules/swagger-codegen/src/test/resources/2_0/petstore-with-fake-endpoints-models-for-testing.yaml -l java -c bin/java-petstore-retrofit.json -o samples/client/petstore/java/retrofit"
|
||||||
|
|
||||||
java $JAVA_OPTS -jar $executable $ags
|
java $JAVA_OPTS -jar $executable $ags
|
||||||
|
@ -26,6 +26,6 @@ fi
|
|||||||
|
|
||||||
# if you've executed sbt assembly previously it will use that instead.
|
# if you've executed sbt assembly previously it will use that instead.
|
||||||
export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties"
|
export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties"
|
||||||
ags="$@ generate -i modules/swagger-codegen/src/test/resources/2_0/petstore.json -l java -c bin/java-petstore-retrofit2.json -o samples/client/petstore/java/retrofit2"
|
ags="$@ generate -i modules/swagger-codegen/src/test/resources/2_0/petstore-with-fake-endpoints-models-for-testing.yaml -l java -c bin/java-petstore-retrofit2.json -o samples/client/petstore/java/retrofit2"
|
||||||
|
|
||||||
java $JAVA_OPTS -jar $executable $ags
|
java $JAVA_OPTS -jar $executable $ags
|
||||||
|
@ -26,6 +26,6 @@ fi
|
|||||||
|
|
||||||
# if you've executed sbt assembly previously it will use that instead.
|
# if you've executed sbt assembly previously it will use that instead.
|
||||||
export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties"
|
export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties"
|
||||||
ags="$@ generate -i modules/swagger-codegen/src/test/resources/2_0/petstore.json -l java -c bin/java-petstore-retrofit2rx.json -o samples/client/petstore/java/retrofit2rx -DuseRxJava=true"
|
ags="$@ generate -i modules/swagger-codegen/src/test/resources/2_0/petstore-with-fake-endpoints-models-for-testing.yaml -l java -c bin/java-petstore-retrofit2rx.json -o samples/client/petstore/java/retrofit2rx -DuseRxJava=true"
|
||||||
|
|
||||||
java $JAVA_OPTS -jar $executable $ags
|
java $JAVA_OPTS -jar $executable $ags
|
||||||
|
@ -26,6 +26,6 @@ fi
|
|||||||
|
|
||||||
# if you've executed sbt assembly previously it will use that instead.
|
# if you've executed sbt assembly previously it will use that instead.
|
||||||
export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties"
|
export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties"
|
||||||
ags="$@ generate -i modules/swagger-codegen/src/test/resources/2_0/petstore.json -l java -o samples/client/petstore/java/default"
|
ags="$@ generate -i modules/swagger-codegen/src/test/resources/2_0/petstore-with-fake-endpoints-models-for-testing.yaml -l java -o samples/client/petstore/java/default -DhideGenerationTimestamp=true"
|
||||||
|
|
||||||
java $JAVA_OPTS -jar $executable $ags
|
java $JAVA_OPTS -jar $executable $ags
|
||||||
|
@ -1,31 +0,0 @@
|
|||||||
#!/bin/sh
|
|
||||||
|
|
||||||
SCRIPT="$0"
|
|
||||||
|
|
||||||
while [ -h "$SCRIPT" ] ; do
|
|
||||||
ls=`ls -ld "$SCRIPT"`
|
|
||||||
link=`expr "$ls" : '.*-> \(.*\)$'`
|
|
||||||
if expr "$link" : '/.*' > /dev/null; then
|
|
||||||
SCRIPT="$link"
|
|
||||||
else
|
|
||||||
SCRIPT=`dirname "$SCRIPT"`/"$link"
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
|
|
||||||
if [ ! -d "${APP_DIR}" ]; then
|
|
||||||
APP_DIR=`dirname "$SCRIPT"`/..
|
|
||||||
APP_DIR=`cd "${APP_DIR}"; pwd`
|
|
||||||
fi
|
|
||||||
|
|
||||||
executable="./modules/swagger-codegen-cli/target/swagger-codegen-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/swagger-codegen/src/test/resources/2_0/wordnik.json -l java -o samples/client/wordnik/java"
|
|
||||||
|
|
||||||
java $JAVA_OPTS -jar $executable $ags
|
|
@ -26,6 +26,6 @@ fi
|
|||||||
|
|
||||||
# if you've executed sbt assembly previously it will use that instead.
|
# if you've executed sbt assembly previously it will use that instead.
|
||||||
export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties"
|
export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties"
|
||||||
ags="$@ generate -i modules/swagger-codegen/src/test/resources/2_0/petstore.json -l javascript-closure-angular -o samples/client/petstore/javascript-closure-angular"
|
ags="$@ generate -i modules/swagger-codegen/src/test/resources/2_0/petstore.yaml -l javascript-closure-angular -o samples/client/petstore/javascript-closure-angular"
|
||||||
|
|
||||||
java $JAVA_OPTS -jar $executable $ags
|
java $JAVA_OPTS -jar $executable $ags
|
||||||
|
@ -26,6 +26,6 @@ fi
|
|||||||
|
|
||||||
# if you've executed sbt assembly previously it will use that instead.
|
# if you've executed sbt assembly previously it will use that instead.
|
||||||
export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties"
|
export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties"
|
||||||
ags="$@ generate -t modules/swagger-codegen/src/main/resources/JavaJaxRS -i modules/swagger-codegen/src/test/resources/2_0/petstore.json -l jaxrs-cxf -o samples/server/petstore/jaxrs-cxf"
|
ags="$@ generate -t modules/swagger-codegen/src/main/resources/JavaJaxRS -i modules/swagger-codegen/src/test/resources/2_0/petstore.yaml -l jaxrs-cxf -o samples/server/petstore/jaxrs-cxf -DhideGenerationTimestamp=true"
|
||||||
|
|
||||||
java $JAVA_OPTS -jar $executable $ags
|
java $JAVA_OPTS -jar $executable $ags
|
||||||
|
@ -26,6 +26,6 @@ fi
|
|||||||
|
|
||||||
# if you've executed sbt assembly previously it will use that instead.
|
# if you've executed sbt assembly previously it will use that instead.
|
||||||
export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties"
|
export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties"
|
||||||
ags="$@ generate -t modules/swagger-codegen/src/main/resources/JavaJaxRS -i modules/swagger-codegen/src/test/resources/2_0/petstore.json -l jaxrs -o samples/server/petstore/jaxrs"
|
ags="$@ generate -t modules/swagger-codegen/src/main/resources/JavaJaxRS -i modules/swagger-codegen/src/test/resources/2_0/petstore.yaml -l jaxrs -o samples/server/petstore/jaxrs -DhideGenerationTimestamp=true"
|
||||||
|
|
||||||
java $JAVA_OPTS -jar $executable $ags
|
java $JAVA_OPTS -jar $executable $ags
|
||||||
|
@ -26,6 +26,6 @@ fi
|
|||||||
|
|
||||||
# if you've executed sbt assembly previously it will use that instead.
|
# if you've executed sbt assembly previously it will use that instead.
|
||||||
export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties"
|
export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties"
|
||||||
ags="$@ generate -t modules/swagger-codegen/src/main/resources/JavaJaxRS -i modules/swagger-codegen/src/test/resources/2_0/petstore.json -l jaxrs-resteasy -o samples/server/petstore/jaxrs-resteasy"
|
ags="$@ generate -t modules/swagger-codegen/src/main/resources/JavaJaxRS -i modules/swagger-codegen/src/test/resources/2_0/petstore.yaml -l jaxrs-resteasy -o samples/server/petstore/jaxrs-resteasy -DhideGenerationTimestamp=true"
|
||||||
|
|
||||||
java $JAVA_OPTS -jar $executable $ags
|
java $JAVA_OPTS -jar $executable $ags
|
||||||
|
@ -26,6 +26,6 @@ fi
|
|||||||
|
|
||||||
# if you've executed sbt assembly previously it will use that instead.
|
# if you've executed sbt assembly previously it will use that instead.
|
||||||
export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties"
|
export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties"
|
||||||
ags="$@ generate -i modules/swagger-codegen/src/test/resources/2_0/wordnik.json -l scala -o samples/client/wordnik/scala"
|
ags="$@ generate -t modules/swagger-codegen/src/main/resources/JavaJaxRS -i modules/swagger-codegen/src/test/resources/2_0/petstore.yaml -l jaxrs -o samples/server/petstore/jersey2 --library=jersey2 -DhideGenerationTimestamp=true"
|
||||||
|
|
||||||
java $JAVA_OPTS -jar $executable $ags
|
java $JAVA_OPTS -jar $executable $ags
|
@ -26,6 +26,6 @@ fi
|
|||||||
|
|
||||||
# if you've executed sbt assembly previously it will use that instead.
|
# if you've executed sbt assembly previously it will use that instead.
|
||||||
export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties"
|
export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties"
|
||||||
ags="$@ generate -i modules/swagger-codegen/src/test/resources/2_0/petstore.json -l nodejs-server -o samples/server/petstore/nodejs"
|
ags="$@ generate -i modules/swagger-codegen/src/test/resources/2_0/petstore.yaml -l nodejs-server -o samples/server/petstore/nodejs"
|
||||||
|
|
||||||
java $JAVA_OPTS -Dservice -jar $executable $ags
|
java $JAVA_OPTS -Dservice -jar $executable $ags
|
||||||
|
@ -1,31 +0,0 @@
|
|||||||
#!/bin/sh
|
|
||||||
|
|
||||||
SCRIPT="$0"
|
|
||||||
|
|
||||||
while [ -h "$SCRIPT" ] ; do
|
|
||||||
ls=`ls -ld "$SCRIPT"`
|
|
||||||
link=`expr "$ls" : '.*-> \(.*\)$'`
|
|
||||||
if expr "$link" : '/.*' > /dev/null; then
|
|
||||||
SCRIPT="$link"
|
|
||||||
else
|
|
||||||
SCRIPT=`dirname "$SCRIPT"`/"$link"
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
|
|
||||||
if [ ! -d "${APP_DIR}" ]; then
|
|
||||||
APP_DIR=`dirname "$SCRIPT"`/..
|
|
||||||
APP_DIR=`cd "${APP_DIR}"; pwd`
|
|
||||||
fi
|
|
||||||
|
|
||||||
executable="./modules/swagger-codegen-cli/target/swagger-codegen-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/swagger-codegen/src/test/resources/2_0/wordnik.json -l objc -o samples/client/wordnik/objc"
|
|
||||||
|
|
||||||
java $JAVA_OPTS -jar $executable $ags
|
|
@ -27,7 +27,7 @@ fi
|
|||||||
# if you've executed sbt assembly previously it will use that instead.
|
# if you've executed sbt assembly previously it will use that instead.
|
||||||
export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties"
|
export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties"
|
||||||
# complex module name used for testing
|
# complex module name used for testing
|
||||||
ags="$@ generate -i modules/swagger-codegen/src/test/resources/2_0/petstore.json -l perl -o samples/client/petstore/perl"
|
ags="$@ generate -i modules/swagger-codegen/src/test/resources/2_0/petstore-with-fake-endpoints-models-for-testing.yaml -l perl -o samples/client/petstore/perl"
|
||||||
|
|
||||||
java $JAVA_OPTS -jar $executable $ags
|
java $JAVA_OPTS -jar $executable $ags
|
||||||
|
|
||||||
|
@ -26,6 +26,6 @@ fi
|
|||||||
|
|
||||||
# if you've executed sbt assembly previously it will use that instead.
|
# if you've executed sbt assembly previously it will use that instead.
|
||||||
export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties"
|
export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties"
|
||||||
ags="$@ generate -t modules/swagger-codegen/src/main/resources/php -i modules/swagger-codegen/src/test/resources/2_0/petstore.json -l php -o samples/client/petstore/php"
|
ags="$@ generate -t modules/swagger-codegen/src/main/resources/php -i modules/swagger-codegen/src/test/resources/2_0/petstore-with-fake-endpoints-models-for-testing.yaml -l php -o samples/client/petstore/php"
|
||||||
|
|
||||||
java $JAVA_OPTS -jar $executable $ags
|
java $JAVA_OPTS -jar $executable $ags
|
||||||
|
@ -26,6 +26,6 @@ fi
|
|||||||
|
|
||||||
# if you've executed sbt assembly previously it will use that instead.
|
# if you've executed sbt assembly previously it will use that instead.
|
||||||
export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties"
|
export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties"
|
||||||
ags="$@ generate -t modules/swagger-codegen/src/main/resources/python -i modules/swagger-codegen/src/test/resources/2_0/petstore.json -l python -o samples/client/petstore/python"
|
ags="$@ generate -t modules/swagger-codegen/src/main/resources/python -i modules/swagger-codegen/src/test/resources/2_0/petstore-with-fake-endpoints-models-for-testing.yaml -l python -o samples/client/petstore/python"
|
||||||
|
|
||||||
java $JAVA_OPTS -jar $executable $ags
|
java $JAVA_OPTS -jar $executable $ags
|
||||||
|
@ -26,6 +26,6 @@ fi
|
|||||||
|
|
||||||
# if you've executed sbt assembly previously it will use that instead.
|
# if you've executed sbt assembly previously it will use that instead.
|
||||||
export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties"
|
export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties"
|
||||||
ags="$@ generate -t modules/swagger-codegen/src/main/resources/qt5cpp -i modules/swagger-codegen/src/test/resources/2_0/petstore.json -l qt5cpp -o samples/client/petstore/qt5cpp"
|
ags="$@ generate -t modules/swagger-codegen/src/main/resources/qt5cpp -i modules/swagger-codegen/src/test/resources/2_0/petstore.yaml -l qt5cpp -o samples/client/petstore/qt5cpp"
|
||||||
|
|
||||||
java $JAVA_OPTS -jar $executable $ags
|
java $JAVA_OPTS -jar $executable $ags
|
||||||
|
@ -26,6 +26,6 @@ fi
|
|||||||
|
|
||||||
# if you've executed sbt assembly previously it will use that instead.
|
# if you've executed sbt assembly previously it will use that instead.
|
||||||
export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties"
|
export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties"
|
||||||
ags="$@ generate -t modules/swagger-codegen/src/main/resources/ruby -i modules/swagger-codegen/src/test/resources/2_0/petstore.json -l ruby -c bin/ruby-petstore.json -o samples/client/petstore/ruby"
|
ags="$@ generate -t modules/swagger-codegen/src/main/resources/ruby -i modules/swagger-codegen/src/test/resources/2_0/petstore-with-fake-endpoints-models-for-testing.yaml -l ruby -c bin/ruby-petstore.json -o samples/client/petstore/ruby"
|
||||||
|
|
||||||
java $JAVA_OPTS -jar $executable $ags
|
java $JAVA_OPTS -jar $executable $ags
|
||||||
|
@ -26,6 +26,6 @@ fi
|
|||||||
|
|
||||||
# if you've executed sbt assembly previously it will use that instead.
|
# if you've executed sbt assembly previously it will use that instead.
|
||||||
export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties"
|
export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties"
|
||||||
ags="$@ generate -t modules/swagger-codegen/src/main/resources/asyncscala -i modules/swagger-codegen/src/test/resources/2_0/petstore.json -l async-scala -o samples/client/petstore/async-scala"
|
ags="$@ generate -t modules/swagger-codegen/src/main/resources/asyncscala -i modules/swagger-codegen/src/test/resources/2_0/petstore.yaml -l async-scala -o samples/client/petstore/async-scala"
|
||||||
|
|
||||||
java $JAVA_OPTS -jar $executable $ags
|
java $JAVA_OPTS -jar $executable $ags
|
||||||
|
@ -26,6 +26,6 @@ fi
|
|||||||
|
|
||||||
# if you've executed sbt assembly previously it will use that instead.
|
# if you've executed sbt assembly previously it will use that instead.
|
||||||
export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties"
|
export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties"
|
||||||
ags="$@ generate -t modules/swagger-codegen/src/main/resources/scala -i modules/swagger-codegen/src/test/resources/2_0/petstore.json -l scala -o samples/client/petstore/scala"
|
ags="$@ generate -t modules/swagger-codegen/src/main/resources/scala -i modules/swagger-codegen/src/test/resources/2_0/petstore.yaml -l scala -o samples/client/petstore/scala"
|
||||||
|
|
||||||
java $JAVA_OPTS -jar $executable $ags
|
java $JAVA_OPTS -jar $executable $ags
|
||||||
|
@ -26,6 +26,6 @@ fi
|
|||||||
|
|
||||||
# if you've executed sbt assembly previously it will use that instead.
|
# if you've executed sbt assembly previously it will use that instead.
|
||||||
export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties"
|
export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties"
|
||||||
ags="$@ generate -t modules/swagger-codegen/src/main/resources/scalatra -i modules/swagger-codegen/src/test/resources/2_0/petstore.json -l scalatra -o samples/server/petstore/scalatra"
|
ags="$@ generate -t modules/swagger-codegen/src/main/resources/scalatra -i modules/swagger-codegen/src/test/resources/2_0/petstore.yaml -l scalatra -o samples/server/petstore/scalatra"
|
||||||
|
|
||||||
java $JAVA_OPTS -jar $executable $ags
|
java $JAVA_OPTS -jar $executable $ags
|
||||||
|
@ -26,6 +26,6 @@ fi
|
|||||||
|
|
||||||
# if you've executed sbt assembly previously it will use that instead.
|
# if you've executed sbt assembly previously it will use that instead.
|
||||||
export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties"
|
export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties"
|
||||||
ags="$@ generate -t modules/swagger-codegen/src/main/resources/silex -i modules/swagger-codegen/src/test/resources/2_0/petstore.json -l silex-PHP -o samples/server/petstore/silex"
|
ags="$@ generate -t modules/swagger-codegen/src/main/resources/silex -i modules/swagger-codegen/src/test/resources/2_0/petstore.yaml -l silex-PHP -o samples/server/petstore/silex"
|
||||||
|
|
||||||
java $JAVA_OPTS -jar $executable $ags
|
java $JAVA_OPTS -jar $executable $ags
|
||||||
|
@ -26,6 +26,6 @@ fi
|
|||||||
|
|
||||||
# if you've executed sbt assembly previously it will use that instead.
|
# if you've executed sbt assembly previously it will use that instead.
|
||||||
export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties"
|
export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties"
|
||||||
ags="$@ generate -t modules/swagger-codegen/src/main/resources/sinatra -i modules/swagger-codegen/src/test/resources/2_0/petstore.json -l sinatra -o samples/server/petstore/sinatra"
|
ags="$@ generate -t modules/swagger-codegen/src/main/resources/sinatra -i modules/swagger-codegen/src/test/resources/2_0/petstore.yaml -l sinatra -o samples/server/petstore/sinatra"
|
||||||
|
|
||||||
java $JAVA_OPTS -jar $executable $ags
|
java $JAVA_OPTS -jar $executable $ags
|
||||||
|
@ -26,6 +26,6 @@ fi
|
|||||||
|
|
||||||
# if you've executed sbt assembly previously it will use that instead.
|
# if you've executed sbt assembly previously it will use that instead.
|
||||||
export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties"
|
export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties"
|
||||||
ags="$@ generate -t modules/swagger-codegen/src/main/resources/slim -i modules/swagger-codegen/src/test/resources/2_0/petstore.json -l slim -o samples/server/petstore/slim"
|
ags="$@ generate -t modules/swagger-codegen/src/main/resources/slim -i modules/swagger-codegen/src/test/resources/2_0/petstore.yaml -l slim -o samples/server/petstore/slim"
|
||||||
|
|
||||||
java $JAVA_OPTS -jar $executable $ags
|
java $JAVA_OPTS -jar $executable $ags
|
||||||
|
@ -26,6 +26,6 @@ fi
|
|||||||
|
|
||||||
# if you've executed sbt assembly previously it will use that instead.
|
# if you've executed sbt assembly previously it will use that instead.
|
||||||
export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties"
|
export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties"
|
||||||
ags="$@ generate -t modules/swagger-codegen/src/main/resources/JavaSpringMVC -i modules/swagger-codegen/src/test/resources/2_0/petstore.json -l spring-mvc -o samples/server/petstore/spring-mvc-j8-async -c bin/spring-mvc-petstore-j8-async.json"
|
ags="$@ generate -t modules/swagger-codegen/src/main/resources/JavaSpringMVC -i modules/swagger-codegen/src/test/resources/2_0/petstore.yaml -l spring-mvc -o samples/server/petstore/spring-mvc-j8-async -c bin/spring-mvc-petstore-j8-async.json"
|
||||||
|
|
||||||
java $JAVA_OPTS -jar $executable $ags
|
java $JAVA_OPTS -jar $executable $ags
|
||||||
|
@ -26,6 +26,6 @@ fi
|
|||||||
|
|
||||||
# if you've executed sbt assembly previously it will use that instead.
|
# if you've executed sbt assembly previously it will use that instead.
|
||||||
export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties"
|
export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties"
|
||||||
ags="$@ generate -t modules/swagger-codegen/src/main/resources/JavaSpringMVC -i modules/swagger-codegen/src/test/resources/2_0/petstore.json -l spring-mvc -o samples/server/petstore/spring-mvc"
|
ags="$@ generate -t modules/swagger-codegen/src/main/resources/JavaSpringMVC -i modules/swagger-codegen/src/test/resources/2_0/petstore.yaml -l spring-mvc -o samples/server/petstore/spring-mvc"
|
||||||
|
|
||||||
java $JAVA_OPTS -jar $executable $ags
|
java $JAVA_OPTS -jar $executable $ags
|
||||||
|
@ -26,6 +26,6 @@ fi
|
|||||||
|
|
||||||
# if you've executed sbt assembly previously it will use that instead.
|
# if you've executed sbt assembly previously it will use that instead.
|
||||||
export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties"
|
export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties"
|
||||||
ags="$@ generate -t modules/swagger-codegen/src/main/resources/tizen -i modules/swagger-codegen/src/test/resources/2_0/petstore.json -l tizen -o samples/client/petstore/tizen"
|
ags="$@ generate -t modules/swagger-codegen/src/main/resources/tizen -i modules/swagger-codegen/src/test/resources/2_0/petstore.yaml -l tizen -o samples/client/petstore/tizen"
|
||||||
|
|
||||||
java $JAVA_OPTS -jar $executable $ags
|
java $JAVA_OPTS -jar $executable $ags
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>io.swagger</groupId>
|
<groupId>io.swagger</groupId>
|
||||||
<artifactId>swagger-codegen-project</artifactId>
|
<artifactId>swagger-codegen-project</artifactId>
|
||||||
<version>2.1.6-SNAPSHOT</version>
|
<version>2.1.6</version>
|
||||||
<relativePath>../..</relativePath>
|
<relativePath>../..</relativePath>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>io.swagger</groupId>
|
<groupId>io.swagger</groupId>
|
||||||
<artifactId>swagger-codegen-project</artifactId>
|
<artifactId>swagger-codegen-project</artifactId>
|
||||||
<version>2.1.6-SNAPSHOT</version>
|
<version>2.1.6</version>
|
||||||
<relativePath>../..</relativePath>
|
<relativePath>../..</relativePath>
|
||||||
</parent>
|
</parent>
|
||||||
<artifactId>swagger-codegen-maven-plugin</artifactId>
|
<artifactId>swagger-codegen-maven-plugin</artifactId>
|
||||||
|
@ -0,0 +1,67 @@
|
|||||||
|
{
|
||||||
|
"swagger": "2.0",
|
||||||
|
"info": {
|
||||||
|
"version": "1.0.0",
|
||||||
|
"title": "SDK Unit Testing - File Downloading"
|
||||||
|
},
|
||||||
|
"schemes": [
|
||||||
|
"http"
|
||||||
|
],
|
||||||
|
"host": "localhost:3000",
|
||||||
|
"basePath": "/unittesting",
|
||||||
|
"paths": {
|
||||||
|
"/request/file_uploading": {
|
||||||
|
"get": {
|
||||||
|
"operationId": "file_uploading",
|
||||||
|
"tags": [
|
||||||
|
"Request"
|
||||||
|
],
|
||||||
|
"parameters": [
|
||||||
|
{"name": "f1",
|
||||||
|
"in": "formData",
|
||||||
|
"type": "string",
|
||||||
|
"format": "binary",
|
||||||
|
"required": true
|
||||||
|
},
|
||||||
|
{"name": "f2",
|
||||||
|
"in": "formData",
|
||||||
|
"type": "string",
|
||||||
|
"format": "binary",
|
||||||
|
"required": false
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"consumes": [
|
||||||
|
"multipart/form-data"
|
||||||
|
],
|
||||||
|
"responses": {
|
||||||
|
"200": {
|
||||||
|
"description": "OK",
|
||||||
|
"schema": {
|
||||||
|
"type": "string"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"/response/file_downloading": {
|
||||||
|
"get": {
|
||||||
|
"operationId": "file_downloading",
|
||||||
|
"tags": [
|
||||||
|
"Response"
|
||||||
|
],
|
||||||
|
"produces": [
|
||||||
|
"multipart/form-data"
|
||||||
|
],
|
||||||
|
"responses": {
|
||||||
|
"200": {
|
||||||
|
"description": "OK",
|
||||||
|
"schema": {
|
||||||
|
"type": "string",
|
||||||
|
"format": "binary"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,30 @@
|
|||||||
|
{
|
||||||
|
"swagger": "2.0",
|
||||||
|
"info": {
|
||||||
|
"version": "1.0.0",
|
||||||
|
"title": "SDK Unit Testing - File Downloading"
|
||||||
|
},
|
||||||
|
"schemes": [
|
||||||
|
"http"
|
||||||
|
],
|
||||||
|
"host": "localhost:3000",
|
||||||
|
"basePath": "/unittesting",
|
||||||
|
"paths": {
|
||||||
|
"/response/file_downloading": {
|
||||||
|
"get": {
|
||||||
|
"operationId": "file_downloading",
|
||||||
|
"tags": [
|
||||||
|
"Response"
|
||||||
|
],
|
||||||
|
"responses": {
|
||||||
|
"200": {
|
||||||
|
"description": "OK",
|
||||||
|
"schema": {
|
||||||
|
"type": "file"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -3,7 +3,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>io.swagger</groupId>
|
<groupId>io.swagger</groupId>
|
||||||
<artifactId>swagger-codegen-project</artifactId>
|
<artifactId>swagger-codegen-project</artifactId>
|
||||||
<version>2.1.6-SNAPSHOT</version>
|
<version>2.1.6</version>
|
||||||
<relativePath>../..</relativePath>
|
<relativePath>../..</relativePath>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
@ -115,6 +115,14 @@
|
|||||||
</execution>
|
</execution>
|
||||||
</executions>
|
</executions>
|
||||||
</plugin>
|
</plugin>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
|
<artifactId>maven-compiler-plugin</artifactId>
|
||||||
|
<configuration>
|
||||||
|
<source>1.7</source>
|
||||||
|
<target>1.7</target>
|
||||||
|
</configuration>
|
||||||
|
</plugin>
|
||||||
</plugins>
|
</plugins>
|
||||||
</build>
|
</build>
|
||||||
<profiles>
|
<profiles>
|
||||||
|
@ -15,7 +15,7 @@ public class CodegenOperation {
|
|||||||
isListContainer, isMultipart, hasMore = Boolean.TRUE,
|
isListContainer, isMultipart, hasMore = Boolean.TRUE,
|
||||||
isResponseBinary = Boolean.FALSE, hasReference = Boolean.FALSE;
|
isResponseBinary = Boolean.FALSE, hasReference = Boolean.FALSE;
|
||||||
public String path, operationId, returnType, httpMethod, returnBaseType,
|
public String path, operationId, returnType, httpMethod, returnBaseType,
|
||||||
returnContainer, summary, notes, baseName, defaultResponse, discriminator;
|
returnContainer, summary, unescapedNotes, notes, baseName, defaultResponse, discriminator;
|
||||||
public List<Map<String, String>> consumes, produces;
|
public List<Map<String, String>> consumes, produces;
|
||||||
public CodegenParameter bodyParam;
|
public CodegenParameter bodyParam;
|
||||||
public List<CodegenParameter> allParams = new ArrayList<CodegenParameter>();
|
public List<CodegenParameter> allParams = new ArrayList<CodegenParameter>();
|
||||||
|
@ -9,7 +9,7 @@ public class CodegenParameter {
|
|||||||
public Boolean isFormParam, isQueryParam, isPathParam, isHeaderParam,
|
public Boolean isFormParam, isQueryParam, isPathParam, isHeaderParam,
|
||||||
isCookieParam, isBodyParam, hasMore, isContainer,
|
isCookieParam, isBodyParam, hasMore, isContainer,
|
||||||
secondaryParam, isCollectionFormatMulti, isPrimitiveType;
|
secondaryParam, isCollectionFormatMulti, isPrimitiveType;
|
||||||
public String baseName, paramName, dataType, datatypeWithEnum, collectionFormat, description, baseType, defaultValue;
|
public String baseName, paramName, dataType, datatypeWithEnum, collectionFormat, description, unescapedDescription, baseType, defaultValue;
|
||||||
public String example; // example value (x-example)
|
public String example; // example value (x-example)
|
||||||
public String jsonSchema;
|
public String jsonSchema;
|
||||||
public Boolean isString, isInteger, isLong, isFloat, isDouble, isByteArray, isBinary, isBoolean, isDate, isDateTime;
|
public Boolean isString, isInteger, isLong, isFloat, isDouble, isByteArray, isBinary, isBoolean, isDate, isDateTime;
|
||||||
|
@ -32,6 +32,7 @@ public class CodegenProperty {
|
|||||||
public Boolean exclusiveMinimum;
|
public Boolean exclusiveMinimum;
|
||||||
public Boolean exclusiveMaximum;
|
public Boolean exclusiveMaximum;
|
||||||
public Boolean hasMore, required, secondaryParam;
|
public Boolean hasMore, required, secondaryParam;
|
||||||
|
public Boolean hasMoreNonReadOnly; // for model constructor, true if next properyt is not readonly
|
||||||
public Boolean isPrimitiveType, isContainer, isNotContainer;
|
public Boolean isPrimitiveType, isContainer, isNotContainer;
|
||||||
public Boolean isString, isInteger, isLong, isFloat, isDouble, isByteArray, isBinary, isBoolean, isDate, isDateTime;
|
public Boolean isString, isInteger, isLong, isFloat, isDouble, isByteArray, isBinary, isBoolean, isDate, isDateTime;
|
||||||
public Boolean isListContainer, isMapContainer;
|
public Boolean isListContainer, isMapContainer;
|
||||||
@ -63,6 +64,7 @@ public class CodegenProperty {
|
|||||||
result = prime * result + ((exclusiveMinimum == null) ? 0 : exclusiveMinimum.hashCode());
|
result = prime * result + ((exclusiveMinimum == null) ? 0 : exclusiveMinimum.hashCode());
|
||||||
result = prime * result + ((getter == null) ? 0 : getter.hashCode());
|
result = prime * result + ((getter == null) ? 0 : getter.hashCode());
|
||||||
result = prime * result + ((hasMore == null) ? 0 : hasMore.hashCode());
|
result = prime * result + ((hasMore == null) ? 0 : hasMore.hashCode());
|
||||||
|
result = prime * result + ((hasMoreNonReadOnly == null) ? 0 : hasMoreNonReadOnly.hashCode());
|
||||||
result = prime * result + ((isContainer == null) ? 0 : isContainer.hashCode());
|
result = prime * result + ((isContainer == null) ? 0 : isContainer.hashCode());
|
||||||
result = prime * result + (isEnum ? 1231 : 1237);
|
result = prime * result + (isEnum ? 1231 : 1237);
|
||||||
result = prime * result + ((isNotContainer == null) ? 0 : isNotContainer.hashCode());
|
result = prime * result + ((isNotContainer == null) ? 0 : isNotContainer.hashCode());
|
||||||
|
@ -2,55 +2,22 @@ package io.swagger.codegen;
|
|||||||
|
|
||||||
import com.google.common.base.Function;
|
import com.google.common.base.Function;
|
||||||
import com.google.common.collect.Lists;
|
import com.google.common.collect.Lists;
|
||||||
|
|
||||||
import io.swagger.codegen.examples.ExampleGenerator;
|
import io.swagger.codegen.examples.ExampleGenerator;
|
||||||
import io.swagger.models.ArrayModel;
|
import io.swagger.models.*;
|
||||||
import io.swagger.models.ComposedModel;
|
import io.swagger.models.auth.*;
|
||||||
import io.swagger.models.Model;
|
import io.swagger.models.parameters.*;
|
||||||
import io.swagger.models.ModelImpl;
|
|
||||||
import io.swagger.models.Operation;
|
|
||||||
import io.swagger.models.RefModel;
|
|
||||||
import io.swagger.models.Response;
|
|
||||||
import io.swagger.models.Swagger;
|
|
||||||
import io.swagger.models.auth.ApiKeyAuthDefinition;
|
|
||||||
import io.swagger.models.auth.BasicAuthDefinition;
|
|
||||||
import io.swagger.models.auth.In;
|
|
||||||
import io.swagger.models.auth.OAuth2Definition;
|
|
||||||
import io.swagger.models.auth.SecuritySchemeDefinition;
|
|
||||||
import io.swagger.models.parameters.BodyParameter;
|
|
||||||
import io.swagger.models.parameters.CookieParameter;
|
|
||||||
import io.swagger.models.parameters.FormParameter;
|
|
||||||
import io.swagger.models.parameters.HeaderParameter;
|
|
||||||
import io.swagger.models.parameters.Parameter;
|
|
||||||
import io.swagger.models.parameters.PathParameter;
|
|
||||||
import io.swagger.models.parameters.QueryParameter;
|
|
||||||
import io.swagger.models.parameters.SerializableParameter;
|
|
||||||
import io.swagger.models.properties.*;
|
import io.swagger.models.properties.*;
|
||||||
import io.swagger.models.properties.PropertyBuilder.PropertyId;
|
import io.swagger.models.properties.PropertyBuilder.PropertyId;
|
||||||
import io.swagger.util.Json;
|
import io.swagger.util.Json;
|
||||||
|
import org.apache.commons.lang.StringEscapeUtils;
|
||||||
import org.apache.commons.lang.StringUtils;
|
import org.apache.commons.lang.StringUtils;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.util.ArrayList;
|
import java.util.*;
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.Collection;
|
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.Comparator;
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.HashSet;
|
|
||||||
import java.util.Iterator;
|
|
||||||
import java.util.LinkedHashMap;
|
|
||||||
import java.util.LinkedHashSet;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.Map.Entry;
|
import java.util.Map.Entry;
|
||||||
import java.util.Set;
|
|
||||||
import java.util.TreeSet;
|
|
||||||
import java.util.regex.Matcher;
|
import java.util.regex.Matcher;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
@ -203,11 +170,7 @@ public class DefaultCodegen {
|
|||||||
@SuppressWarnings("static-method")
|
@SuppressWarnings("static-method")
|
||||||
public String escapeText(String input) {
|
public String escapeText(String input) {
|
||||||
if (input != null) {
|
if (input != null) {
|
||||||
input = input.trim(); // FIXME: a parameter should not be assigned. Also declare the methods parameters as 'final'.
|
return StringEscapeUtils.escapeJava(input).replace("\\/", "/");
|
||||||
String output = input.replaceAll("\n", "\\\\n");
|
|
||||||
output = output.replace("\r", "\\r");
|
|
||||||
output = output.replace("\"", "\\\"");
|
|
||||||
return output;
|
|
||||||
}
|
}
|
||||||
return input;
|
return input;
|
||||||
}
|
}
|
||||||
@ -1162,6 +1125,24 @@ public class DefaultCodegen {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (p instanceof BaseIntegerProperty) {
|
||||||
|
BaseIntegerProperty sp = (BaseIntegerProperty) p;
|
||||||
|
property.isInteger = true;
|
||||||
|
/*if (sp.getEnum() != null) {
|
||||||
|
List<Integer> _enum = sp.getEnum();
|
||||||
|
property._enum = new ArrayList<String>();
|
||||||
|
for(Integer i : _enum) {
|
||||||
|
property._enum.add(i.toString());
|
||||||
|
}
|
||||||
|
property.isEnum = true;
|
||||||
|
|
||||||
|
// legacy support
|
||||||
|
Map<String, Object> allowableValues = new HashMap<String, Object>();
|
||||||
|
allowableValues.put("values", _enum);
|
||||||
|
property.allowableValues = allowableValues;
|
||||||
|
}*/
|
||||||
|
}
|
||||||
|
|
||||||
if (p instanceof IntegerProperty) {
|
if (p instanceof IntegerProperty) {
|
||||||
IntegerProperty sp = (IntegerProperty) p;
|
IntegerProperty sp = (IntegerProperty) p;
|
||||||
property.isInteger = true;
|
property.isInteger = true;
|
||||||
@ -1210,6 +1191,24 @@ public class DefaultCodegen {
|
|||||||
property.isByteArray = true;
|
property.isByteArray = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (p instanceof DecimalProperty) {
|
||||||
|
DecimalProperty sp = (DecimalProperty) p;
|
||||||
|
property.isFloat = true;
|
||||||
|
/*if (sp.getEnum() != null) {
|
||||||
|
List<Double> _enum = sp.getEnum();
|
||||||
|
property._enum = new ArrayList<String>();
|
||||||
|
for(Double i : _enum) {
|
||||||
|
property._enum.add(i.toString());
|
||||||
|
}
|
||||||
|
property.isEnum = true;
|
||||||
|
|
||||||
|
// legacy support
|
||||||
|
Map<String, Object> allowableValues = new HashMap<String, Object>();
|
||||||
|
allowableValues.put("values", _enum);
|
||||||
|
property.allowableValues = allowableValues;
|
||||||
|
}*/
|
||||||
|
}
|
||||||
|
|
||||||
if (p instanceof DoubleProperty) {
|
if (p instanceof DoubleProperty) {
|
||||||
DoubleProperty sp = (DoubleProperty) p;
|
DoubleProperty sp = (DoubleProperty) p;
|
||||||
property.isDouble = true;
|
property.isDouble = true;
|
||||||
@ -1398,6 +1397,7 @@ public class DefaultCodegen {
|
|||||||
op.path = path;
|
op.path = path;
|
||||||
op.operationId = toOperationId(operationId);
|
op.operationId = toOperationId(operationId);
|
||||||
op.summary = escapeText(operation.getSummary());
|
op.summary = escapeText(operation.getSummary());
|
||||||
|
op.unescapedNotes = operation.getDescription();
|
||||||
op.notes = escapeText(operation.getDescription());
|
op.notes = escapeText(operation.getDescription());
|
||||||
op.tags = operation.getTags();
|
op.tags = operation.getTags();
|
||||||
op.hasConsumes = false;
|
op.hasConsumes = false;
|
||||||
@ -1579,33 +1579,20 @@ public class DefaultCodegen {
|
|||||||
|
|
||||||
|
|
||||||
allParams.add(p);
|
allParams.add(p);
|
||||||
|
// Issue #2561 (neilotoole) : Moved setting of is<Type>Param flags
|
||||||
|
// from here to fromParameter().
|
||||||
if (param instanceof QueryParameter) {
|
if (param instanceof QueryParameter) {
|
||||||
p.isQueryParam = new Boolean(true);
|
|
||||||
queryParams.add(p.copy());
|
queryParams.add(p.copy());
|
||||||
} else if (param instanceof PathParameter) {
|
} else if (param instanceof PathParameter) {
|
||||||
p.required = true;
|
|
||||||
p.isPathParam = new Boolean(true);
|
|
||||||
pathParams.add(p.copy());
|
pathParams.add(p.copy());
|
||||||
} else if (param instanceof HeaderParameter) {
|
} else if (param instanceof HeaderParameter) {
|
||||||
p.isHeaderParam = new Boolean(true);
|
|
||||||
headerParams.add(p.copy());
|
headerParams.add(p.copy());
|
||||||
} else if (param instanceof CookieParameter) {
|
} else if (param instanceof CookieParameter) {
|
||||||
p.isCookieParam = new Boolean(true);
|
|
||||||
cookieParams.add(p.copy());
|
cookieParams.add(p.copy());
|
||||||
} else if (param instanceof BodyParameter) {
|
} else if (param instanceof BodyParameter) {
|
||||||
p.isBodyParam = new Boolean(true);
|
|
||||||
p.isBinary = p.dataType.toLowerCase().startsWith("byte");
|
|
||||||
bodyParam = p;
|
bodyParam = p;
|
||||||
bodyParams.add(p.copy());
|
bodyParams.add(p.copy());
|
||||||
} else if (param instanceof FormParameter) {
|
} else if (param instanceof FormParameter) {
|
||||||
if ("file".equalsIgnoreCase(((FormParameter) param).getType())) {
|
|
||||||
p.isFile = true;
|
|
||||||
} else if("file".equals(p.baseType)){
|
|
||||||
p.isFile = true;
|
|
||||||
} else {
|
|
||||||
p.notFile = true;
|
|
||||||
}
|
|
||||||
p.isFormParam = new Boolean(true);
|
|
||||||
formParams.add(p.copy());
|
formParams.add(p.copy());
|
||||||
}
|
}
|
||||||
if (p.required == null || !p.required) {
|
if (p.required == null || !p.required) {
|
||||||
@ -1720,6 +1707,7 @@ public class DefaultCodegen {
|
|||||||
CodegenParameter p = CodegenModelFactory.newInstance(CodegenModelType.PARAMETER);
|
CodegenParameter p = CodegenModelFactory.newInstance(CodegenModelType.PARAMETER);
|
||||||
p.baseName = param.getName();
|
p.baseName = param.getName();
|
||||||
p.description = escapeText(param.getDescription());
|
p.description = escapeText(param.getDescription());
|
||||||
|
p.unescapedDescription = param.getDescription();
|
||||||
if (param.getRequired()) {
|
if (param.getRequired()) {
|
||||||
p.required = param.getRequired();
|
p.required = param.getRequired();
|
||||||
}
|
}
|
||||||
@ -1933,6 +1921,33 @@ public class DefaultCodegen {
|
|||||||
// should be overridden by lang codegen
|
// should be overridden by lang codegen
|
||||||
setParameterExampleValue(p);
|
setParameterExampleValue(p);
|
||||||
|
|
||||||
|
// Issue #2561 (neilotoole) : Set the is<TYPE>Param flags.
|
||||||
|
// This code has been moved to here from #fromOperation
|
||||||
|
// because these values should be set before calling #postProcessParameter.
|
||||||
|
// See: https://github.com/swagger-api/swagger-codegen/issues/2561
|
||||||
|
if (param instanceof QueryParameter) {
|
||||||
|
p.isQueryParam = true;
|
||||||
|
} else if (param instanceof PathParameter) {
|
||||||
|
p.required = true;
|
||||||
|
p.isPathParam = true;
|
||||||
|
} else if (param instanceof HeaderParameter) {
|
||||||
|
p.isHeaderParam = true;
|
||||||
|
} else if (param instanceof CookieParameter) {
|
||||||
|
p.isCookieParam = true;
|
||||||
|
} else if (param instanceof BodyParameter) {
|
||||||
|
p.isBodyParam = true;
|
||||||
|
p.isBinary = p.dataType.toLowerCase().startsWith("byte");
|
||||||
|
} else if (param instanceof FormParameter) {
|
||||||
|
if ("file".equalsIgnoreCase(((FormParameter) param).getType())) {
|
||||||
|
p.isFile = true;
|
||||||
|
} else if("file".equals(p.baseType)){
|
||||||
|
p.isFile = true;
|
||||||
|
} else {
|
||||||
|
p.notFile = true;
|
||||||
|
}
|
||||||
|
p.isFormParam = true;
|
||||||
|
}
|
||||||
|
|
||||||
postProcessParameter(p);
|
postProcessParameter(p);
|
||||||
return p;
|
return p;
|
||||||
}
|
}
|
||||||
@ -2257,9 +2272,12 @@ public class DefaultCodegen {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void addVars(CodegenModel m, List<CodegenProperty> vars, Map<String, Property> properties, Set<String> mandatory) {
|
private void addVars(CodegenModel m, List<CodegenProperty> vars, Map<String, Property> properties, Set<String> mandatory) {
|
||||||
final int totalCount = properties.size();
|
// convert set to list so that we can access the next entry in the loop
|
||||||
int count = 0;
|
List<Map.Entry<String, Property>> propertyList = new ArrayList<Map.Entry<String, Property>>(properties.entrySet());
|
||||||
for (Map.Entry<String, Property> entry : properties.entrySet()) {
|
final int totalCount = propertyList.size();
|
||||||
|
for (int i = 0; i < totalCount; i++) {
|
||||||
|
Map.Entry<String, Property> entry = propertyList.get(i);
|
||||||
|
|
||||||
final String key = entry.getKey();
|
final String key = entry.getKey();
|
||||||
final Property prop = entry.getValue();
|
final Property prop = entry.getValue();
|
||||||
|
|
||||||
@ -2273,13 +2291,19 @@ public class DefaultCodegen {
|
|||||||
// m.hasEnums to be set incorrectly if allProperties has enumerations but properties does not.
|
// m.hasEnums to be set incorrectly if allProperties has enumerations but properties does not.
|
||||||
m.hasEnums = true;
|
m.hasEnums = true;
|
||||||
}
|
}
|
||||||
count++;
|
|
||||||
if (count != totalCount) {
|
if (i+1 != totalCount) {
|
||||||
cp.hasMore = true;
|
cp.hasMore = true;
|
||||||
|
// check the next entry to see if it's read only
|
||||||
|
if (!Boolean.TRUE.equals(propertyList.get(i+1).getValue().getReadOnly())) {
|
||||||
|
cp.hasMoreNonReadOnly = true; // next entry is not ready only
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (cp.isContainer != null) {
|
if (cp.isContainer != null) {
|
||||||
addImport(m, typeMapping.get("array"));
|
addImport(m, typeMapping.get("array"));
|
||||||
}
|
}
|
||||||
|
|
||||||
addImport(m, cp.baseType);
|
addImport(m, cp.baseType);
|
||||||
addImport(m, cp.complexType);
|
addImport(m, cp.complexType);
|
||||||
vars.add(cp);
|
vars.add(cp);
|
||||||
|
@ -8,6 +8,7 @@ import io.swagger.models.auth.SecuritySchemeDefinition;
|
|||||||
import io.swagger.models.parameters.Parameter;
|
import io.swagger.models.parameters.Parameter;
|
||||||
import io.swagger.util.Json;
|
import io.swagger.util.Json;
|
||||||
import org.apache.commons.io.IOUtils;
|
import org.apache.commons.io.IOUtils;
|
||||||
|
import org.apache.commons.lang3.ObjectUtils;
|
||||||
import org.joda.time.DateTime;
|
import org.joda.time.DateTime;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
@ -16,7 +17,6 @@ import java.io.*;
|
|||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
||||||
import static org.apache.commons.lang3.StringUtils.isNotEmpty;
|
import static org.apache.commons.lang3.StringUtils.isNotEmpty;
|
||||||
import org.apache.commons.lang3.ObjectUtils;
|
|
||||||
|
|
||||||
public class DefaultGenerator extends AbstractGenerator implements Generator {
|
public class DefaultGenerator extends AbstractGenerator implements Generator {
|
||||||
protected Logger LOGGER = LoggerFactory.getLogger(DefaultGenerator.class);
|
protected Logger LOGGER = LoggerFactory.getLogger(DefaultGenerator.class);
|
||||||
|
@ -148,7 +148,14 @@ public class CodegenConfigurator {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public CodegenConfigurator setTemplateDir(String templateDir) {
|
public CodegenConfigurator setTemplateDir(String templateDir) {
|
||||||
this.templateDir = new File(templateDir).getAbsolutePath();
|
File f = new File(templateDir);
|
||||||
|
|
||||||
|
// check to see if the folder exists
|
||||||
|
if (!(f != null && f.exists() && f.isDirectory())) {
|
||||||
|
throw new IllegalArgumentException("Template directory " + templateDir + " does not exist.");
|
||||||
|
}
|
||||||
|
|
||||||
|
this.templateDir = f.getAbsolutePath();
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -89,7 +89,7 @@ public abstract class AbstractCSharpCodegen extends DefaultCodegen implements Co
|
|||||||
"Int64",
|
"Int64",
|
||||||
"Float",
|
"Float",
|
||||||
"Guid",
|
"Guid",
|
||||||
"Stream", // not really a primitive, we include it to avoid model import
|
"System.IO.Stream", // not really a primitive, we include it to avoid model import
|
||||||
"Object")
|
"Object")
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -101,6 +101,7 @@ public abstract class AbstractCSharpCodegen extends DefaultCodegen implements Co
|
|||||||
typeMapping = new HashMap<String, String>();
|
typeMapping = new HashMap<String, String>();
|
||||||
typeMapping.put("string", "string");
|
typeMapping.put("string", "string");
|
||||||
typeMapping.put("binary", "byte[]");
|
typeMapping.put("binary", "byte[]");
|
||||||
|
typeMapping.put("bytearray", "byte[]");
|
||||||
typeMapping.put("boolean", "bool?");
|
typeMapping.put("boolean", "bool?");
|
||||||
typeMapping.put("integer", "int?");
|
typeMapping.put("integer", "int?");
|
||||||
typeMapping.put("float", "float?");
|
typeMapping.put("float", "float?");
|
||||||
@ -109,7 +110,7 @@ public abstract class AbstractCSharpCodegen extends DefaultCodegen implements Co
|
|||||||
typeMapping.put("number", "double?");
|
typeMapping.put("number", "double?");
|
||||||
typeMapping.put("datetime", "DateTime?");
|
typeMapping.put("datetime", "DateTime?");
|
||||||
typeMapping.put("date", "DateTime?");
|
typeMapping.put("date", "DateTime?");
|
||||||
typeMapping.put("file", "Stream");
|
typeMapping.put("file", "System.IO.Stream");
|
||||||
typeMapping.put("array", "List");
|
typeMapping.put("array", "List");
|
||||||
typeMapping.put("list", "List");
|
typeMapping.put("list", "List");
|
||||||
typeMapping.put("map", "Dictionary");
|
typeMapping.put("map", "Dictionary");
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
package io.swagger.codegen.languages;
|
package io.swagger.codegen.languages;
|
||||||
|
|
||||||
import io.swagger.codegen.CodegenOperation;
|
import io.swagger.codegen.CodegenOperation;
|
||||||
|
import io.swagger.codegen.CodegenParameter;
|
||||||
import io.swagger.codegen.CodegenResponse;
|
import io.swagger.codegen.CodegenResponse;
|
||||||
import io.swagger.codegen.CodegenType;
|
import io.swagger.codegen.CodegenType;
|
||||||
import io.swagger.models.Operation;
|
import io.swagger.models.Operation;
|
||||||
@ -95,6 +96,25 @@ public abstract class AbstractJavaJAXRSServerCodegen extends JavaClientCodegen
|
|||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
List<CodegenOperation> ops = (List<CodegenOperation>) operations.get("operation");
|
List<CodegenOperation> ops = (List<CodegenOperation>) operations.get("operation");
|
||||||
for ( CodegenOperation operation : ops ) {
|
for ( CodegenOperation operation : ops ) {
|
||||||
|
boolean isMultipartPost = false;
|
||||||
|
List<Map<String, String>> consumes = operation.consumes;
|
||||||
|
if(consumes != null) {
|
||||||
|
for(Map<String, String> consume : consumes) {
|
||||||
|
String mt = consume.get("mediaType");
|
||||||
|
if(mt != null) {
|
||||||
|
if(mt.startsWith("multipart/form-data")) {
|
||||||
|
isMultipartPost = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for(CodegenParameter parameter : operation.allParams) {
|
||||||
|
if(isMultipartPost) {
|
||||||
|
parameter.vendorExtensions.put("x-multipart", "true");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
List<CodegenResponse> responses = operation.responses;
|
List<CodegenResponse> responses = operation.responses;
|
||||||
if ( responses != null ) {
|
if ( responses != null ) {
|
||||||
for ( CodegenResponse resp : responses ) {
|
for ( CodegenResponse resp : responses ) {
|
||||||
|
@ -59,6 +59,7 @@ public abstract class AbstractTypeScriptClientCodegen extends DefaultCodegen imp
|
|||||||
//TODO binary should be mapped to byte array
|
//TODO binary should be mapped to byte array
|
||||||
// mapped to String as a workaround
|
// mapped to String as a workaround
|
||||||
typeMapping.put("binary", "string");
|
typeMapping.put("binary", "string");
|
||||||
|
typeMapping.put("ByteArray", "string");
|
||||||
|
|
||||||
cliOptions.add(new CliOption(CodegenConstants.MODEL_PROPERTY_NAMING, CodegenConstants.MODEL_PROPERTY_NAMING_DESC).defaultValue("camelCase"));
|
cliOptions.add(new CliOption(CodegenConstants.MODEL_PROPERTY_NAMING, CodegenConstants.MODEL_PROPERTY_NAMING_DESC).defaultValue("camelCase"));
|
||||||
|
|
||||||
|
@ -168,7 +168,7 @@ public class AkkaScalaClientCodegen extends DefaultCodegen implements CodegenCon
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getHelp() {
|
public String getHelp() {
|
||||||
return "Generates a Scala client library base on Akka/Spray.";
|
return "Generates a Scala client library (beta) base on Akka/Spray.";
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -11,6 +11,7 @@ import io.swagger.codegen.SupportingFile;
|
|||||||
import io.swagger.codegen.CodegenProperty;
|
import io.swagger.codegen.CodegenProperty;
|
||||||
import io.swagger.codegen.CodegenModel;
|
import io.swagger.codegen.CodegenModel;
|
||||||
import io.swagger.codegen.CodegenOperation;
|
import io.swagger.codegen.CodegenOperation;
|
||||||
|
import io.swagger.codegen.CodegenParameter;
|
||||||
import io.swagger.models.properties.*;
|
import io.swagger.models.properties.*;
|
||||||
import io.swagger.codegen.CliOption;
|
import io.swagger.codegen.CliOption;
|
||||||
import io.swagger.models.Model;
|
import io.swagger.models.Model;
|
||||||
@ -34,6 +35,7 @@ public class CSharpClientCodegen extends AbstractCSharpCodegen {
|
|||||||
private static final Logger LOGGER = LoggerFactory.getLogger(CSharpClientCodegen.class);
|
private static final Logger LOGGER = LoggerFactory.getLogger(CSharpClientCodegen.class);
|
||||||
private static final String NET45 = "v4.5";
|
private static final String NET45 = "v4.5";
|
||||||
private static final String NET35 = "v3.5";
|
private static final String NET35 = "v3.5";
|
||||||
|
private static final String UWP = "uwp";
|
||||||
private static final String DATA_TYPE_WITH_ENUM_EXTENSION = "plainDatatypeWithEnum";
|
private static final String DATA_TYPE_WITH_ENUM_EXTENSION = "plainDatatypeWithEnum";
|
||||||
|
|
||||||
protected String packageGuid = "{" + java.util.UUID.randomUUID().toString().toUpperCase() + "}";
|
protected String packageGuid = "{" + java.util.UUID.randomUUID().toString().toUpperCase() + "}";
|
||||||
@ -44,10 +46,13 @@ public class CSharpClientCodegen extends AbstractCSharpCodegen {
|
|||||||
protected String packageCopyright = "No Copyright";
|
protected String packageCopyright = "No Copyright";
|
||||||
protected String clientPackage = "IO.Swagger.Client";
|
protected String clientPackage = "IO.Swagger.Client";
|
||||||
protected String localVariablePrefix = "";
|
protected String localVariablePrefix = "";
|
||||||
|
protected String apiDocPath = "docs/";
|
||||||
|
protected String modelDocPath = "docs/";
|
||||||
|
|
||||||
protected String targetFramework = NET45;
|
protected String targetFramework = NET45;
|
||||||
protected String targetFrameworkNuget = "net45";
|
protected String targetFrameworkNuget = "net45";
|
||||||
protected boolean supportsAsync = Boolean.TRUE;
|
protected boolean supportsAsync = Boolean.TRUE;
|
||||||
|
protected boolean supportsUWP = Boolean.FALSE;
|
||||||
|
|
||||||
|
|
||||||
protected final Map<String, String> frameworks;
|
protected final Map<String, String> frameworks;
|
||||||
@ -60,6 +65,9 @@ public class CSharpClientCodegen extends AbstractCSharpCodegen {
|
|||||||
modelTestTemplateFiles.put("model_test.mustache", ".cs");
|
modelTestTemplateFiles.put("model_test.mustache", ".cs");
|
||||||
apiTestTemplateFiles.put("api_test.mustache", ".cs");
|
apiTestTemplateFiles.put("api_test.mustache", ".cs");
|
||||||
|
|
||||||
|
modelDocTemplateFiles.put("model_doc.mustache", ".md");
|
||||||
|
apiDocTemplateFiles.put("api_doc.mustache", ".md");
|
||||||
|
|
||||||
// C# client default
|
// C# client default
|
||||||
setSourceFolder("src" + File.separator + "main" + File.separator + "csharp");
|
setSourceFolder("src" + File.separator + "main" + File.separator + "csharp");
|
||||||
|
|
||||||
@ -89,6 +97,7 @@ public class CSharpClientCodegen extends AbstractCSharpCodegen {
|
|||||||
frameworks = new ImmutableMap.Builder<String, String>()
|
frameworks = new ImmutableMap.Builder<String, String>()
|
||||||
.put(NET35, ".NET Framework 3.5 compatible")
|
.put(NET35, ".NET Framework 3.5 compatible")
|
||||||
.put(NET45, ".NET Framework 4.5+ compatible")
|
.put(NET45, ".NET Framework 4.5+ compatible")
|
||||||
|
.put(UWP, "Universal Windows Platform - beta support")
|
||||||
.build();
|
.build();
|
||||||
framework.defaultValue(this.targetFramework);
|
framework.defaultValue(this.targetFramework);
|
||||||
framework.setEnum(frameworks);
|
framework.setEnum(frameworks);
|
||||||
@ -156,6 +165,13 @@ public class CSharpClientCodegen extends AbstractCSharpCodegen {
|
|||||||
if(additionalProperties.containsKey("supportsAsync")){
|
if(additionalProperties.containsKey("supportsAsync")){
|
||||||
additionalProperties.remove("supportsAsync");
|
additionalProperties.remove("supportsAsync");
|
||||||
}
|
}
|
||||||
|
} else if (UWP.equals(this.targetFramework)){
|
||||||
|
setTargetFrameworkNuget("uwp");
|
||||||
|
setSupportsAsync(Boolean.TRUE);
|
||||||
|
setSupportsUWP(Boolean.TRUE);
|
||||||
|
additionalProperties.put("supportsAsync", this.supportsUWP);
|
||||||
|
additionalProperties.put("supportsUWP", this.supportsAsync);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
setTargetFrameworkNuget("net45");
|
setTargetFrameworkNuget("net45");
|
||||||
setSupportsAsync(Boolean.TRUE);
|
setSupportsAsync(Boolean.TRUE);
|
||||||
@ -209,17 +225,19 @@ public class CSharpClientCodegen extends AbstractCSharpCodegen {
|
|||||||
supportingFiles.add(new SupportingFile("compile.mustache", "", "compile.bat"));
|
supportingFiles.add(new SupportingFile("compile.mustache", "", "compile.bat"));
|
||||||
supportingFiles.add(new SupportingFile("compile-mono.sh.mustache", "", "compile-mono.sh"));
|
supportingFiles.add(new SupportingFile("compile-mono.sh.mustache", "", "compile-mono.sh"));
|
||||||
supportingFiles.add(new SupportingFile("packages.config.mustache", "vendor" + java.io.File.separator, "packages.config"));
|
supportingFiles.add(new SupportingFile("packages.config.mustache", "vendor" + java.io.File.separator, "packages.config"));
|
||||||
supportingFiles.add(new SupportingFile("README.md", "", "README.md"));
|
supportingFiles.add(new SupportingFile("README.mustache", "", "README.md"));
|
||||||
supportingFiles.add(new SupportingFile("git_push.sh.mustache", "", "git_push.sh"));
|
supportingFiles.add(new SupportingFile("git_push.sh.mustache", "", "git_push.sh"));
|
||||||
supportingFiles.add(new SupportingFile("gitignore.mustache", "", ".gitignore"));
|
supportingFiles.add(new SupportingFile("gitignore.mustache", "", ".gitignore"));
|
||||||
|
|
||||||
|
|
||||||
if (optionalAssemblyInfoFlag) {
|
if (optionalAssemblyInfoFlag) {
|
||||||
supportingFiles.add(new SupportingFile("AssemblyInfo.mustache", packageFolder + File.separator + "Properties", "AssemblyInfo.cs"));
|
supportingFiles.add(new SupportingFile("AssemblyInfo.mustache", packageFolder + File.separator + "Properties", "AssemblyInfo.cs"));
|
||||||
}
|
}
|
||||||
if (optionalProjectFileFlag) {
|
if (optionalProjectFileFlag) {
|
||||||
supportingFiles.add(new SupportingFile("Project.mustache", packageFolder, clientPackage + ".csproj"));
|
supportingFiles.add(new SupportingFile("Project.mustache", packageFolder, clientPackage + ".csproj"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
additionalProperties.put("apiDocPath", apiDocPath);
|
||||||
|
additionalProperties.put("modelDocPath", modelDocPath);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -290,20 +308,20 @@ public class CSharpClientCodegen extends AbstractCSharpCodegen {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Map<String, Object> postProcessModels(Map<String, Object> objMap) {
|
public Map<String, Object> postProcessModels(Map<String, Object> objMap) {
|
||||||
Map<String, Object> objs = super.postProcessModels(objMap);
|
Map<String, Object> objs = super.postProcessModels(objMap);
|
||||||
|
|
||||||
List<Object> models = (List<Object>) objs.get("models");
|
List<Object> models = (List<Object>) objs.get("models");
|
||||||
for (Object _mo : models) {
|
for (Object _mo : models) {
|
||||||
Map<String, Object> mo = (Map<String, Object>) _mo;
|
Map<String, Object> mo = (Map<String, Object>) _mo;
|
||||||
CodegenModel cm = (CodegenModel) mo.get("model");
|
CodegenModel cm = (CodegenModel) mo.get("model");
|
||||||
for (CodegenProperty var : cm.vars) {
|
for (CodegenProperty var : cm.vars) {
|
||||||
Map<String, Object> allowableValues = var.allowableValues;
|
Map<String, Object> allowableValues = var.allowableValues;
|
||||||
|
|
||||||
// handle ArrayProperty
|
// handle ArrayProperty
|
||||||
if (var.items != null) {
|
if (var.items != null) {
|
||||||
allowableValues = var.items.allowableValues;
|
allowableValues = var.items.allowableValues;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (allowableValues == null) {
|
if (allowableValues == null) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -339,12 +357,12 @@ public class CSharpClientCodegen extends AbstractCSharpCodegen {
|
|||||||
if (var.datatypeWithEnum != null) {
|
if (var.datatypeWithEnum != null) {
|
||||||
var.vendorExtensions.put(DATA_TYPE_WITH_ENUM_EXTENSION, var.datatypeWithEnum.substring(0, var.datatypeWithEnum.length() - 1));
|
var.vendorExtensions.put(DATA_TYPE_WITH_ENUM_EXTENSION, var.datatypeWithEnum.substring(0, var.datatypeWithEnum.length() - 1));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (var.defaultValue != null) {
|
if (var.defaultValue != null) {
|
||||||
String enumName = null;
|
String enumName = null;
|
||||||
|
|
||||||
for (Map<String, String> enumVar : enumVars) {
|
for (Map<String, String> enumVar : enumVars) {
|
||||||
|
|
||||||
if (var.defaultValue.replace("\"", "").equals(enumVar.get("value"))) {
|
if (var.defaultValue.replace("\"", "").equals(enumVar.get("value"))) {
|
||||||
enumName = enumVar.get("name");
|
enumName = enumVar.get("name");
|
||||||
break;
|
break;
|
||||||
@ -403,7 +421,7 @@ public class CSharpClientCodegen extends AbstractCSharpCodegen {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(removedChildEnum) {
|
if(removedChildEnum) {
|
||||||
// If we removed an entry from this model's vars, we need to ensure hasMore is updated
|
// If we removed an entry from this model's vars, we need to ensure hasMore is updated
|
||||||
int count = 0, numVars = codegenProperties.size();
|
int count = 0, numVars = codegenProperties.size();
|
||||||
@ -453,4 +471,24 @@ public class CSharpClientCodegen extends AbstractCSharpCodegen {
|
|||||||
public void setSupportsAsync(Boolean supportsAsync){
|
public void setSupportsAsync(Boolean supportsAsync){
|
||||||
this.supportsAsync = supportsAsync;
|
this.supportsAsync = supportsAsync;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setSupportsUWP(Boolean supportsUWP){
|
||||||
|
this.supportsUWP = supportsUWP;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toModelDocFilename(String name) {
|
||||||
|
return toModelFilename(name);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String apiDocFileFolder() {
|
||||||
|
return (outputFolder + "/" + apiDocPath).replace('/', File.separatorChar);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String modelDocFileFolder() {
|
||||||
|
return (outputFolder + "/" + modelDocPath).replace('/', File.separatorChar);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -60,7 +60,7 @@ public class CsharpDotNet2ClientCodegen extends DefaultCodegen implements Codege
|
|||||||
"Integer",
|
"Integer",
|
||||||
"Long",
|
"Long",
|
||||||
"Float",
|
"Float",
|
||||||
"Stream", // not really a primitive, we include it to avoid model import
|
"System.IO.Stream", // not really a primitive, we include it to avoid model import
|
||||||
"Object")
|
"Object")
|
||||||
);
|
);
|
||||||
instantiationTypes.put("array", "List");
|
instantiationTypes.put("array", "List");
|
||||||
@ -76,7 +76,7 @@ public class CsharpDotNet2ClientCodegen extends DefaultCodegen implements Codege
|
|||||||
typeMapping.put("number", "double?");
|
typeMapping.put("number", "double?");
|
||||||
typeMapping.put("datetime", "DateTime?");
|
typeMapping.put("datetime", "DateTime?");
|
||||||
typeMapping.put("date", "DateTime?");
|
typeMapping.put("date", "DateTime?");
|
||||||
typeMapping.put("file", "Stream");
|
typeMapping.put("file", "System.IO.Stream");
|
||||||
typeMapping.put("array", "List");
|
typeMapping.put("array", "List");
|
||||||
typeMapping.put("list", "List");
|
typeMapping.put("list", "List");
|
||||||
typeMapping.put("map", "Dictionary");
|
typeMapping.put("map", "Dictionary");
|
||||||
|
@ -52,9 +52,8 @@ public class DartClientCodegen extends DefaultCodegen implements CodegenConfig {
|
|||||||
Arrays.asList(
|
Arrays.asList(
|
||||||
"String",
|
"String",
|
||||||
"bool",
|
"bool",
|
||||||
"num",
|
|
||||||
"int",
|
"int",
|
||||||
"float")
|
"double")
|
||||||
);
|
);
|
||||||
instantiationTypes.put("array", "List");
|
instantiationTypes.put("array", "List");
|
||||||
instantiationTypes.put("map", "Map");
|
instantiationTypes.put("map", "Map");
|
||||||
@ -66,11 +65,11 @@ public class DartClientCodegen extends DefaultCodegen implements CodegenConfig {
|
|||||||
typeMapping.put("boolean", "bool");
|
typeMapping.put("boolean", "bool");
|
||||||
typeMapping.put("string", "String");
|
typeMapping.put("string", "String");
|
||||||
typeMapping.put("int", "int");
|
typeMapping.put("int", "int");
|
||||||
typeMapping.put("float", "num");
|
typeMapping.put("float", "double");
|
||||||
typeMapping.put("long", "int");
|
typeMapping.put("long", "int");
|
||||||
typeMapping.put("short", "int");
|
typeMapping.put("short", "int");
|
||||||
typeMapping.put("char", "String");
|
typeMapping.put("char", "String");
|
||||||
typeMapping.put("double", "num");
|
typeMapping.put("double", "double");
|
||||||
typeMapping.put("object", "Object");
|
typeMapping.put("object", "Object");
|
||||||
typeMapping.put("integer", "int");
|
typeMapping.put("integer", "int");
|
||||||
typeMapping.put("Date", "DateTime");
|
typeMapping.put("Date", "DateTime");
|
||||||
|
@ -25,6 +25,7 @@ public class FlaskConnexionCodegen extends DefaultCodegen implements CodegenConf
|
|||||||
|
|
||||||
public static final String CONTROLLER_PACKAGE = "controllerPackage";
|
public static final String CONTROLLER_PACKAGE = "controllerPackage";
|
||||||
public static final String DEFAULT_CONTROLLER = "defaultController";
|
public static final String DEFAULT_CONTROLLER = "defaultController";
|
||||||
|
public static final String SUPPORT_PYTHON2= "supportPython2";
|
||||||
|
|
||||||
protected String apiVersion = "1.0.0";
|
protected String apiVersion = "1.0.0";
|
||||||
protected int serverPort = 8080;
|
protected int serverPort = 8080;
|
||||||
@ -105,11 +106,17 @@ public class FlaskConnexionCodegen extends DefaultCodegen implements CodegenConf
|
|||||||
"",
|
"",
|
||||||
"README.md")
|
"README.md")
|
||||||
);
|
);
|
||||||
|
supportingFiles.add(new SupportingFile("__init__.mustache",
|
||||||
|
"",
|
||||||
|
"__init__.py")
|
||||||
|
);
|
||||||
|
|
||||||
cliOptions.add(new CliOption(CONTROLLER_PACKAGE, "controller package").
|
cliOptions.add(new CliOption(CONTROLLER_PACKAGE, "controller package").
|
||||||
defaultValue("controllers"));
|
defaultValue("controllers"));
|
||||||
cliOptions.add(new CliOption(DEFAULT_CONTROLLER, "default controller").
|
cliOptions.add(new CliOption(DEFAULT_CONTROLLER, "default controller").
|
||||||
defaultValue("default_controller"));
|
defaultValue("default_controller"));
|
||||||
|
cliOptions.add(new CliOption(SUPPORT_PYTHON2, "support python2").
|
||||||
|
defaultValue("false"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -124,6 +131,7 @@ public class FlaskConnexionCodegen extends DefaultCodegen implements CodegenConf
|
|||||||
this.controllerPackage = "controllers";
|
this.controllerPackage = "controllers";
|
||||||
additionalProperties.put(CONTROLLER_PACKAGE, this.controllerPackage);
|
additionalProperties.put(CONTROLLER_PACKAGE, this.controllerPackage);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (additionalProperties.containsKey(DEFAULT_CONTROLLER)) {
|
if (additionalProperties.containsKey(DEFAULT_CONTROLLER)) {
|
||||||
this.defaultController = additionalProperties.get(DEFAULT_CONTROLLER).toString();
|
this.defaultController = additionalProperties.get(DEFAULT_CONTROLLER).toString();
|
||||||
}
|
}
|
||||||
@ -132,11 +140,19 @@ public class FlaskConnexionCodegen extends DefaultCodegen implements CodegenConf
|
|||||||
additionalProperties.put(DEFAULT_CONTROLLER, this.defaultController);
|
additionalProperties.put(DEFAULT_CONTROLLER, this.defaultController);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (Boolean.TRUE.equals(additionalProperties.get(SUPPORT_PYTHON2))) {
|
||||||
|
additionalProperties.put(SUPPORT_PYTHON2, Boolean.TRUE);
|
||||||
|
}
|
||||||
|
|
||||||
if(!new java.io.File(controllerPackage + File.separator + defaultController + ".py").exists()) {
|
if(!new java.io.File(controllerPackage + File.separator + defaultController + ".py").exists()) {
|
||||||
supportingFiles.add(new SupportingFile("controller.mustache",
|
supportingFiles.add(new SupportingFile("controller.mustache",
|
||||||
controllerPackage,
|
controllerPackage,
|
||||||
defaultController + ".py")
|
defaultController + ".py")
|
||||||
);
|
);
|
||||||
|
supportingFiles.add(new SupportingFile("__init__.mustache",
|
||||||
|
controllerPackage,
|
||||||
|
"__init__.py")
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4,6 +4,7 @@ import io.swagger.codegen.*;
|
|||||||
import io.swagger.models.properties.ArrayProperty;
|
import io.swagger.models.properties.ArrayProperty;
|
||||||
import io.swagger.models.properties.MapProperty;
|
import io.swagger.models.properties.MapProperty;
|
||||||
import io.swagger.models.properties.Property;
|
import io.swagger.models.properties.Property;
|
||||||
|
import io.swagger.models.parameters.Parameter;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
@ -18,6 +19,8 @@ public class GoClientCodegen extends DefaultCodegen implements CodegenConfig {
|
|||||||
|
|
||||||
protected String packageName = "swagger";
|
protected String packageName = "swagger";
|
||||||
protected String packageVersion = "1.0.0";
|
protected String packageVersion = "1.0.0";
|
||||||
|
protected String apiDocPath = "docs/";
|
||||||
|
protected String modelDocPath = "docs/";
|
||||||
|
|
||||||
public CodegenType getTag() {
|
public CodegenType getTag() {
|
||||||
return CodegenType.CLIENT;
|
return CodegenType.CLIENT;
|
||||||
@ -36,6 +39,10 @@ public class GoClientCodegen extends DefaultCodegen implements CodegenConfig {
|
|||||||
outputFolder = "generated-code/go";
|
outputFolder = "generated-code/go";
|
||||||
modelTemplateFiles.put("model.mustache", ".go");
|
modelTemplateFiles.put("model.mustache", ".go");
|
||||||
apiTemplateFiles.put("api.mustache", ".go");
|
apiTemplateFiles.put("api.mustache", ".go");
|
||||||
|
|
||||||
|
modelDocTemplateFiles.put("model_doc.mustache", ".md");
|
||||||
|
apiDocTemplateFiles.put("api_doc.mustache", ".md");
|
||||||
|
|
||||||
templateDir = "go";
|
templateDir = "go";
|
||||||
|
|
||||||
setReservedWordsLowerCase(
|
setReservedWordsLowerCase(
|
||||||
@ -79,11 +86,12 @@ public class GoClientCodegen extends DefaultCodegen implements CodegenConfig {
|
|||||||
typeMapping.clear();
|
typeMapping.clear();
|
||||||
typeMapping.put("integer", "int32");
|
typeMapping.put("integer", "int32");
|
||||||
typeMapping.put("long", "int64");
|
typeMapping.put("long", "int64");
|
||||||
|
typeMapping.put("number", "float32");
|
||||||
typeMapping.put("float", "float32");
|
typeMapping.put("float", "float32");
|
||||||
typeMapping.put("double", "float64");
|
typeMapping.put("double", "float64");
|
||||||
typeMapping.put("boolean", "bool");
|
typeMapping.put("boolean", "bool");
|
||||||
typeMapping.put("string", "string");
|
typeMapping.put("string", "string");
|
||||||
typeMapping.put("Date", "time.Time");
|
typeMapping.put("date", "time.Time");
|
||||||
typeMapping.put("DateTime", "time.Time");
|
typeMapping.put("DateTime", "time.Time");
|
||||||
typeMapping.put("password", "string");
|
typeMapping.put("password", "string");
|
||||||
typeMapping.put("File", "*os.File");
|
typeMapping.put("File", "*os.File");
|
||||||
@ -91,6 +99,7 @@ public class GoClientCodegen extends DefaultCodegen implements CodegenConfig {
|
|||||||
// map binary to string as a workaround
|
// map binary to string as a workaround
|
||||||
// the correct solution is to use []byte
|
// the correct solution is to use []byte
|
||||||
typeMapping.put("binary", "string");
|
typeMapping.put("binary", "string");
|
||||||
|
typeMapping.put("ByteArray", "string");
|
||||||
|
|
||||||
importMapping = new HashMap<String, String>();
|
importMapping = new HashMap<String, String>();
|
||||||
importMapping.put("time.Time", "time");
|
importMapping.put("time.Time", "time");
|
||||||
@ -101,7 +110,6 @@ public class GoClientCodegen extends DefaultCodegen implements CodegenConfig {
|
|||||||
.defaultValue("swagger"));
|
.defaultValue("swagger"));
|
||||||
cliOptions.add(new CliOption(CodegenConstants.PACKAGE_VERSION, "Go package version.")
|
cliOptions.add(new CliOption(CodegenConstants.PACKAGE_VERSION, "Go package version.")
|
||||||
.defaultValue("1.0.0"));
|
.defaultValue("1.0.0"));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -124,6 +132,9 @@ public class GoClientCodegen extends DefaultCodegen implements CodegenConfig {
|
|||||||
|
|
||||||
additionalProperties.put(CodegenConstants.PACKAGE_NAME, packageName);
|
additionalProperties.put(CodegenConstants.PACKAGE_NAME, packageName);
|
||||||
additionalProperties.put(CodegenConstants.PACKAGE_VERSION, packageVersion);
|
additionalProperties.put(CodegenConstants.PACKAGE_VERSION, packageVersion);
|
||||||
|
|
||||||
|
additionalProperties.put("apiDocPath", apiDocPath);
|
||||||
|
additionalProperties.put("modelDocPath", modelDocPath);
|
||||||
|
|
||||||
modelPackage = packageName;
|
modelPackage = packageName;
|
||||||
apiPackage = packageName;
|
apiPackage = packageName;
|
||||||
@ -131,6 +142,9 @@ public class GoClientCodegen extends DefaultCodegen implements CodegenConfig {
|
|||||||
supportingFiles.add(new SupportingFile("README.mustache", "", "README.md"));
|
supportingFiles.add(new SupportingFile("README.mustache", "", "README.md"));
|
||||||
supportingFiles.add(new SupportingFile("git_push.sh.mustache", "", "git_push.sh"));
|
supportingFiles.add(new SupportingFile("git_push.sh.mustache", "", "git_push.sh"));
|
||||||
supportingFiles.add(new SupportingFile("gitignore.mustache", "", ".gitignore"));
|
supportingFiles.add(new SupportingFile("gitignore.mustache", "", ".gitignore"));
|
||||||
|
supportingFiles.add(new SupportingFile("configuration.mustache", "", "configuration.go"));
|
||||||
|
supportingFiles.add(new SupportingFile("api_client.mustache", "", "api_client.go"));
|
||||||
|
supportingFiles.add(new SupportingFile("pom.mustache", "", "pom.xml"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -154,11 +168,11 @@ public class GoClientCodegen extends DefaultCodegen implements CodegenConfig {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String apiFileFolder() {
|
public String apiFileFolder() {
|
||||||
return outputFolder + File.separator + packageName;
|
return outputFolder + File.separator;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String modelFileFolder() {
|
public String modelFileFolder() {
|
||||||
return outputFolder + File.separator + packageName;
|
return outputFolder + File.separator;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -194,6 +208,13 @@ public class GoClientCodegen extends DefaultCodegen implements CodegenConfig {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toModelName(String name) {
|
public String toModelName(String name) {
|
||||||
|
// camelize the model name
|
||||||
|
// phone_number => PhoneNumber
|
||||||
|
return camelize(toModelFilename(name));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toModelFilename(String name) {
|
||||||
if (!StringUtils.isEmpty(modelNamePrefix)) {
|
if (!StringUtils.isEmpty(modelNamePrefix)) {
|
||||||
name = modelNamePrefix + "_" + name;
|
name = modelNamePrefix + "_" + name;
|
||||||
}
|
}
|
||||||
@ -210,17 +231,68 @@ public class GoClientCodegen extends DefaultCodegen implements CodegenConfig {
|
|||||||
name = "model_" + name; // e.g. return => ModelReturn (after camelize)
|
name = "model_" + name; // e.g. return => ModelReturn (after camelize)
|
||||||
}
|
}
|
||||||
|
|
||||||
// camelize the model name
|
return underscore(name);
|
||||||
// phone_number => PhoneNumber
|
|
||||||
return camelize(name);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toModelFilename(String name) {
|
public String toApiFilename(String name) {
|
||||||
// should be the same as the model name
|
// replace - with _ e.g. created-at => created_at
|
||||||
|
name = name.replaceAll("-", "_"); // FIXME: a parameter should not be assigned. Also declare the methods parameters as 'final'.
|
||||||
|
|
||||||
|
// e.g. PetApi.go => pet_api.go
|
||||||
|
return underscore(name) + "_api";
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Overrides postProcessParameter to add a vendor extension "x-exportParamName".
|
||||||
|
* This is useful when paramName starts with a lowercase letter, but we need that
|
||||||
|
* param to be exportable (starts with an Uppercase letter).
|
||||||
|
*
|
||||||
|
* @param parameter CodegenParameter object to be processed.
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void postProcessParameter(CodegenParameter parameter){
|
||||||
|
|
||||||
|
// Give the base class a chance to process
|
||||||
|
super.postProcessParameter(parameter);
|
||||||
|
|
||||||
|
char firstChar = parameter.paramName.charAt(0);
|
||||||
|
|
||||||
|
if (Character.isUpperCase(firstChar)) {
|
||||||
|
// First char is already uppercase, just use paramName.
|
||||||
|
parameter.vendorExtensions.put("x-exportParamName", parameter.paramName);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
// It's a lowercase first char, let's convert it to uppercase
|
||||||
|
StringBuilder sb = new StringBuilder(parameter.paramName);
|
||||||
|
sb.setCharAt(0, Character.toUpperCase(firstChar));
|
||||||
|
parameter.vendorExtensions.put("x-exportParamName", sb.toString());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String apiDocFileFolder() {
|
||||||
|
return (outputFolder + "/" + apiDocPath).replace('/', File.separatorChar);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String modelDocFileFolder() {
|
||||||
|
return (outputFolder + "/" + modelDocPath).replace('/', File.separatorChar);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toModelDocFilename(String name) {
|
||||||
return toModelName(name);
|
return toModelName(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toApiDocFilename(String name) {
|
||||||
|
return toApiName(name);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getTypeDeclaration(Property p) {
|
public String getTypeDeclaration(Property p) {
|
||||||
if(p instanceof ArrayProperty) {
|
if(p instanceof ArrayProperty) {
|
||||||
@ -332,5 +404,4 @@ public class GoClientCodegen extends DefaultCodegen implements CodegenConfig {
|
|||||||
public void setPackageVersion(String packageVersion) {
|
public void setPackageVersion(String packageVersion) {
|
||||||
this.packageVersion = packageVersion;
|
this.packageVersion = packageVersion;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,345 +1,514 @@
|
|||||||
package io.swagger.codegen.languages;
|
package io.swagger.codegen.languages;
|
||||||
|
|
||||||
import io.swagger.codegen.*;
|
import io.swagger.codegen.*;
|
||||||
|
import io.swagger.models.ModelImpl;
|
||||||
|
import io.swagger.models.parameters.Parameter;
|
||||||
import io.swagger.models.properties.*;
|
import io.swagger.models.properties.*;
|
||||||
import io.swagger.models.Model;
|
import io.swagger.models.Model;
|
||||||
import io.swagger.models.Operation;
|
import io.swagger.models.Operation;
|
||||||
import io.swagger.models.Swagger;
|
import io.swagger.models.Swagger;
|
||||||
|
import sun.reflect.generics.reflectiveObjects.NotImplementedException;
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
|
||||||
public class HaskellServantCodegen extends DefaultCodegen implements CodegenConfig {
|
public class HaskellServantCodegen extends DefaultCodegen implements CodegenConfig {
|
||||||
|
|
||||||
// source folder where to write the files
|
// source folder where to write the files
|
||||||
protected String sourceFolder = "src";
|
protected String sourceFolder = "src";
|
||||||
protected String apiVersion = "0.0.1";
|
protected String apiVersion = "0.0.1";
|
||||||
|
|
||||||
/**
|
|
||||||
* Configures the type of generator.
|
|
||||||
*
|
|
||||||
* @return the CodegenType for this generator
|
|
||||||
* @see io.swagger.codegen.CodegenType
|
|
||||||
*/
|
|
||||||
public CodegenType getTag() {
|
|
||||||
return CodegenType.SERVER;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
// How to encode special characters like $
|
||||||
* Configures a friendly name for the generator. This will be used by the generator
|
// They are translated to words like "Dollar" and prefixed with '
|
||||||
* to select the library with the -l flag.
|
// Then translated back during JSON encoding and decoding
|
||||||
*
|
private Map<Character, String> specialCharReplacements = new HashMap<Character, String>();
|
||||||
* @return the friendly name for the generator
|
|
||||||
*/
|
|
||||||
public String getName() {
|
|
||||||
return "haskell-servant";
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns human-friendly help for the generator. Provide the consumer with help
|
|
||||||
* tips, parameters here
|
|
||||||
*
|
|
||||||
* @return A string value for the help message
|
|
||||||
*/
|
|
||||||
public String getHelp() {
|
|
||||||
return "Generates a HaskellServantCodegen library.";
|
|
||||||
}
|
|
||||||
|
|
||||||
public HaskellServantCodegen() {
|
|
||||||
super();
|
|
||||||
|
|
||||||
// set the output folder here
|
|
||||||
outputFolder = "generated-code/HaskellServantCodegen";
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Models. You can write model files using the modelTemplateFiles map.
|
* Configures the type of generator.
|
||||||
* if you want to create one template for file, you can do so here.
|
*
|
||||||
* for multiple files for model, just put another entry in the `modelTemplateFiles` with
|
* @return the CodegenType for this generator
|
||||||
* a different extension
|
* @see io.swagger.codegen.CodegenType
|
||||||
*/
|
*/
|
||||||
modelTemplateFiles.put(
|
public CodegenType getTag() {
|
||||||
"model.mustache", // the template to use
|
return CodegenType.SERVER;
|
||||||
".hs"); // the extension for each file to write
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Api classes. You can write classes for each Api file with the apiTemplateFiles map.
|
* Configures a friendly name for the generator. This will be used by the generator
|
||||||
* as with models, add multiple entries with different extensions for multiple files per
|
* to select the library with the -l flag.
|
||||||
* class
|
*
|
||||||
|
* @return the friendly name for the generator
|
||||||
*/
|
*/
|
||||||
apiTemplateFiles.put(
|
public String getName() {
|
||||||
"api.mustache", // the template to use
|
return "haskell";
|
||||||
".hs"); // the extension for each file to write
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Returns human-friendly help for the generator. Provide the consumer with help
|
||||||
|
* tips, parameters here
|
||||||
|
*
|
||||||
|
* @return A string value for the help message
|
||||||
|
*/
|
||||||
|
public String getHelp() {
|
||||||
|
return "Generates a Haskell server and client library.";
|
||||||
|
}
|
||||||
|
|
||||||
|
public HaskellServantCodegen() {
|
||||||
|
super();
|
||||||
|
|
||||||
|
// Initialize special characters
|
||||||
|
specialCharReplacements.put('$', "Dollar");
|
||||||
|
specialCharReplacements.put('^', "Caret");
|
||||||
|
specialCharReplacements.put('|', "Pipe");
|
||||||
|
specialCharReplacements.put('=', "Equal");
|
||||||
|
specialCharReplacements.put('*', "Star");
|
||||||
|
specialCharReplacements.put('-', "Dash");
|
||||||
|
specialCharReplacements.put('&', "Ampersand");
|
||||||
|
specialCharReplacements.put('%', "Percent");
|
||||||
|
specialCharReplacements.put('#', "Hash");
|
||||||
|
specialCharReplacements.put('@', "At");
|
||||||
|
specialCharReplacements.put('!', "Exclamation");
|
||||||
|
specialCharReplacements.put('+', "Plus");
|
||||||
|
|
||||||
|
|
||||||
|
// set the output folder here
|
||||||
|
outputFolder = "generated-code/haskell-servant";
|
||||||
|
|
||||||
|
/*
|
||||||
* Template Location. This is the location which templates will be read from. The generator
|
* Template Location. This is the location which templates will be read from. The generator
|
||||||
* will use the resource stream to attempt to read the templates.
|
* will use the resource stream to attempt to read the templates.
|
||||||
*/
|
*/
|
||||||
embeddedTemplateDir = templateDir = "haskell-servant";
|
embeddedTemplateDir = templateDir = "haskell-servant";
|
||||||
|
|
||||||
/**
|
/*
|
||||||
* Api Package. Optional, if needed, this can be used in templates
|
* Api Package. Optional, if needed, this can be used in templates
|
||||||
*/
|
*/
|
||||||
apiPackage = "Api";
|
apiPackage = "API";
|
||||||
|
|
||||||
/**
|
/*
|
||||||
* Model Package. Optional, if needed, this can be used in templates
|
* Model Package. Optional, if needed, this can be used in templates
|
||||||
*/
|
*/
|
||||||
modelPackage = "Model";
|
modelPackage = "Types";
|
||||||
|
|
||||||
/**
|
// Haskell keywords and reserved function names, taken mostly from https://wiki.haskell.org/Keywords
|
||||||
* Reserved words. Override this with reserved words specific to your language
|
setReservedWordsLowerCase(
|
||||||
*/
|
Arrays.asList(
|
||||||
// from https://wiki.haskell.org/Keywords
|
// Keywords
|
||||||
setReservedWordsLowerCase(
|
"as", "case", "of",
|
||||||
Arrays.asList(
|
"class", "data", "family",
|
||||||
"as", "case", "of",
|
"default", "deriving",
|
||||||
"class", "data", // "data family", "data instance",
|
"do", "forall", "foreign", "hiding",
|
||||||
"default", "deriving", // "deriving instance",
|
"if", "then", "else",
|
||||||
"do",
|
"import", "infix", "infixl", "infixr",
|
||||||
"forall", "foreign", "hiding",
|
"instance", "let", "in",
|
||||||
"id",
|
"mdo", "module", "newtype",
|
||||||
"if", "then", "else",
|
"proc", "qualified", "rec",
|
||||||
"import", "infix", "infixl", "infixr",
|
"type", "where"
|
||||||
"instance", "let", "in",
|
)
|
||||||
"mdo", "module", "newtype",
|
);
|
||||||
"proc", "qualified", "rec",
|
|
||||||
"type", // "type family", "type instance",
|
|
||||||
"where"
|
|
||||||
)
|
|
||||||
);
|
|
||||||
|
|
||||||
/**
|
/*
|
||||||
* Additional Properties. These values can be passed to the templates and
|
* Additional Properties. These values can be passed to the templates and
|
||||||
* are available in models, apis, and supporting files
|
* are available in models, apis, and supporting files
|
||||||
*/
|
*/
|
||||||
additionalProperties.put("apiVersion", apiVersion);
|
additionalProperties.put("apiVersion", apiVersion);
|
||||||
|
|
||||||
/**
|
/*
|
||||||
* Supporting Files. You can write single files for the generator with the
|
* Supporting Files. You can write single files for the generator with the
|
||||||
* entire object tree available. If the input file has a suffix of `.mustache
|
* entire object tree available. If the input file has a suffix of `.mustache
|
||||||
* it will be processed by the template engine. Otherwise, it will be copied
|
* it will be processed by the template engine. Otherwise, it will be copied
|
||||||
*/
|
*/
|
||||||
supportingFiles.add(new SupportingFile("README.mustache", "", "README.md"));
|
supportingFiles.add(new SupportingFile("README.mustache", "", "README.md"));
|
||||||
supportingFiles.add(new SupportingFile("stack.mustache", "", "stack.yaml"));
|
supportingFiles.add(new SupportingFile("stack.mustache", "", "stack.yaml"));
|
||||||
supportingFiles.add(new SupportingFile("haskell-servant-codegen.mustache", "", "haskell-servant-codegen.cabal"));
|
supportingFiles.add(new SupportingFile("Setup.mustache", "", "Setup.hs"));
|
||||||
supportingFiles.add(new SupportingFile("Setup.mustache", "", "Setup.hs"));
|
|
||||||
supportingFiles.add(new SupportingFile("LICENSE", "", "LICENSE"));
|
|
||||||
supportingFiles.add(new SupportingFile("Apis.mustache", "lib", "Apis.hs"));
|
|
||||||
supportingFiles.add(new SupportingFile("Utils.mustache", "lib", "Utils.hs"));
|
|
||||||
supportingFiles.add(new SupportingFile("Client.mustache", "client", "Main.hs"));
|
|
||||||
supportingFiles.add(new SupportingFile("Server.mustache", "server", "Main.hs"));
|
|
||||||
|
|
||||||
/**
|
/*
|
||||||
* Language Specific Primitives. These types will not trigger imports by
|
* Language Specific Primitives. These types will not trigger imports by
|
||||||
* the client generator
|
* the client generator
|
||||||
*/
|
*/
|
||||||
languageSpecificPrimitives = new HashSet<String>(
|
languageSpecificPrimitives = new HashSet<String>(
|
||||||
Arrays.asList(
|
Arrays.asList(
|
||||||
"Bool",
|
"Bool",
|
||||||
"String",
|
"String",
|
||||||
"Int",
|
"Int",
|
||||||
"Integer",
|
"Integer",
|
||||||
"Float",
|
"Float",
|
||||||
"Char",
|
"Char",
|
||||||
"Double",
|
"Double",
|
||||||
"List",
|
"List",
|
||||||
"FilePath"
|
"FilePath"
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
typeMapping.clear();
|
typeMapping.clear();
|
||||||
// typeMapping.put("enum", "NSString");
|
typeMapping.put("array", "List");
|
||||||
typeMapping.put("array", "List");
|
typeMapping.put("set", "Set");
|
||||||
typeMapping.put("set", "Set");
|
typeMapping.put("boolean", "Bool");
|
||||||
typeMapping.put("boolean", "Bool");
|
typeMapping.put("string", "Text");
|
||||||
typeMapping.put("string", "String");
|
typeMapping.put("int", "Int");
|
||||||
typeMapping.put("int", "Int");
|
typeMapping.put("long", "Integer");
|
||||||
typeMapping.put("long", "Integer");
|
typeMapping.put("short", "Int");
|
||||||
typeMapping.put("float", "Float");
|
typeMapping.put("char", "Char");
|
||||||
// typeMapping.put("byte", "Byte");
|
typeMapping.put("float", "Float");
|
||||||
typeMapping.put("short", "Int");
|
typeMapping.put("double", "Double");
|
||||||
typeMapping.put("char", "Char");
|
typeMapping.put("DateTime", "Integer");
|
||||||
typeMapping.put("double", "Double");
|
typeMapping.put("file", "FilePath");
|
||||||
typeMapping.put("DateTime", "Integer");
|
typeMapping.put("number", "Double");
|
||||||
// typeMapping.put("object", "Map");
|
typeMapping.put("integer", "Int");
|
||||||
typeMapping.put("file", "FilePath");
|
typeMapping.put("any", "Value");
|
||||||
|
|
||||||
importMapping.clear();
|
importMapping.clear();
|
||||||
importMapping.put("Map", "qualified Data.Map as Map");
|
importMapping.put("Map", "qualified Data.Map as Map");
|
||||||
|
|
||||||
cliOptions.add(new CliOption(CodegenConstants.MODEL_PACKAGE, CodegenConstants.MODEL_PACKAGE_DESC));
|
cliOptions.add(new CliOption(CodegenConstants.MODEL_PACKAGE, CodegenConstants.MODEL_PACKAGE_DESC));
|
||||||
cliOptions.add(new CliOption(CodegenConstants.API_PACKAGE, CodegenConstants.API_PACKAGE_DESC));
|
cliOptions.add(new CliOption(CodegenConstants.API_PACKAGE, CodegenConstants.API_PACKAGE_DESC));
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Escapes a reserved word as defined in the `reservedWords` array. Handle escaping
|
|
||||||
* those terms here. This logic is only called if a variable matches the reseved words
|
|
||||||
*
|
|
||||||
* @return the escaped term
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public String escapeReservedWord(String name) {
|
|
||||||
return name + "_";
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Location to write model files. You can use the modelPackage() as defined when the class is
|
|
||||||
* instantiated
|
|
||||||
*/
|
|
||||||
public String modelFileFolder() {
|
|
||||||
return outputFolder + File.separatorChar + "lib" + File.separatorChar + modelPackage().replace('.', File.separatorChar);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Location to write api files. You can use the apiPackage() as defined when the class is
|
|
||||||
* instantiated
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public String apiFileFolder() {
|
|
||||||
return outputFolder + File.separatorChar + "lib" + File.separatorChar + apiPackage().replace('.', File.separatorChar);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Optional - type declaration. This is a String which is used by the templates to instantiate your
|
|
||||||
* types. There is typically special handling for different property types
|
|
||||||
*
|
|
||||||
* @return a string value used as the `dataType` field for model templates, `returnType` for api templates
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public String getTypeDeclaration(Property p) {
|
|
||||||
if(p instanceof ArrayProperty) {
|
|
||||||
ArrayProperty ap = (ArrayProperty) p;
|
|
||||||
Property inner = ap.getItems();
|
|
||||||
return "[" + getTypeDeclaration(inner) + "]";
|
|
||||||
}
|
}
|
||||||
else if (p instanceof MapProperty) {
|
|
||||||
MapProperty mp = (MapProperty) p;
|
|
||||||
Property inner = mp.getAdditionalProperties();
|
|
||||||
return "Map.Map String " + getTypeDeclaration(inner);
|
|
||||||
}
|
|
||||||
return super.getTypeDeclaration(p);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Optional - swagger type conversion. This is used to map swagger types in a `Property` into
|
* Escapes a reserved word as defined in the `reservedWords` array. Handle escaping
|
||||||
* either language specific types via `typeMapping` or into complex models if there is not a mapping.
|
* those terms here. This logic is only called if a variable matches the reseved words
|
||||||
*
|
*
|
||||||
* @return a string value of the type or complex model for this property
|
* @return the escaped term
|
||||||
* @see io.swagger.models.properties.Property
|
*/
|
||||||
*/
|
@Override
|
||||||
@Override
|
public String escapeReservedWord(String name) {
|
||||||
public String getSwaggerType(Property p) {
|
return name + "_";
|
||||||
String swaggerType = super.getSwaggerType(p);
|
}
|
||||||
String type = null;
|
|
||||||
if(typeMapping.containsKey(swaggerType)) {
|
@Override
|
||||||
type = typeMapping.get(swaggerType);
|
public void preprocessSwagger(Swagger swagger) {
|
||||||
if(languageSpecificPrimitives.contains(type))
|
// From the title, compute a reasonable name for the package and the API
|
||||||
|
String title = swagger.getInfo().getTitle();
|
||||||
|
|
||||||
|
// Drop any API suffix
|
||||||
|
if(title == null) {
|
||||||
|
title = "Swagger";
|
||||||
|
} else {
|
||||||
|
title = title.trim();
|
||||||
|
if (title.toUpperCase().endsWith("API")) {
|
||||||
|
title = title.substring(0, title.length() - 3);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
String[] words = title.split(" ");
|
||||||
|
|
||||||
|
// The package name is made by appending the lowercased words of the title interspersed with dashes
|
||||||
|
List<String> wordsLower = new ArrayList<String>();
|
||||||
|
for (String word : words) {
|
||||||
|
wordsLower.add(word.toLowerCase());
|
||||||
|
}
|
||||||
|
String cabalName = joinStrings("-", wordsLower);
|
||||||
|
|
||||||
|
// The API name is made by appending the capitalized words of the title
|
||||||
|
List<String> wordsCaps = new ArrayList<String>();
|
||||||
|
for (String word : words) {
|
||||||
|
wordsCaps.add(word.substring(0, 1).toUpperCase() + word.substring(1));
|
||||||
|
}
|
||||||
|
String apiName = joinStrings("", wordsCaps);
|
||||||
|
|
||||||
|
// Set the filenames to write for the API
|
||||||
|
supportingFiles.add(new SupportingFile("haskell-servant-codegen.mustache", "", cabalName + ".cabal"));
|
||||||
|
supportingFiles.add(new SupportingFile("API.mustache", "lib/" + apiName, "API.hs"));
|
||||||
|
supportingFiles.add(new SupportingFile("Types.mustache", "lib/" + apiName, "Types.hs"));
|
||||||
|
|
||||||
|
|
||||||
|
additionalProperties.put("title", apiName);
|
||||||
|
additionalProperties.put("titleLower", apiName.substring(0, 1).toLowerCase() + apiName.substring(1));
|
||||||
|
additionalProperties.put("package", cabalName);
|
||||||
|
|
||||||
|
// Due to the way servant resolves types, we need a high context stack limit
|
||||||
|
additionalProperties.put("contextStackLimit", swagger.getPaths().size() * 2 + 300);
|
||||||
|
|
||||||
|
List<Map<String, Object>> replacements = new ArrayList<>();
|
||||||
|
Object[] replacementChars = specialCharReplacements.keySet().toArray();
|
||||||
|
for(int i = 0; i < replacementChars.length; i++) {
|
||||||
|
Character c = (Character) replacementChars[i];
|
||||||
|
Map<String, Object> o = new HashMap<>();
|
||||||
|
o.put("char", Character.toString(c));
|
||||||
|
o.put("replacement", "'" + specialCharReplacements.get(c));
|
||||||
|
o.put("hasMore", i != replacementChars.length - 1);
|
||||||
|
replacements.add(o);
|
||||||
|
}
|
||||||
|
additionalProperties.put("specialCharReplacements", replacements);
|
||||||
|
|
||||||
|
super.preprocessSwagger(swagger);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Optional - type declaration. This is a String which is used by the templates to instantiate your
|
||||||
|
* types. There is typically special handling for different property types
|
||||||
|
*
|
||||||
|
* @return a string value used as the `dataType` field for model templates, `returnType` for api templates
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public String getTypeDeclaration(Property p) {
|
||||||
|
if (p instanceof ArrayProperty) {
|
||||||
|
ArrayProperty ap = (ArrayProperty) p;
|
||||||
|
Property inner = ap.getItems();
|
||||||
|
return "[" + getTypeDeclaration(inner) + "]";
|
||||||
|
} else if (p instanceof MapProperty) {
|
||||||
|
MapProperty mp = (MapProperty) p;
|
||||||
|
Property inner = mp.getAdditionalProperties();
|
||||||
|
return "Map.Map String " + getTypeDeclaration(inner);
|
||||||
|
}
|
||||||
|
return fixModelChars(super.getTypeDeclaration(p));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Optional - swagger type conversion. This is used to map swagger types in a `Property` into
|
||||||
|
* either language specific types via `typeMapping` or into complex models if there is not a mapping.
|
||||||
|
*
|
||||||
|
* @return a string value of the type or complex model for this property
|
||||||
|
* @see io.swagger.models.properties.Property
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public String getSwaggerType(Property p) {
|
||||||
|
String swaggerType = super.getSwaggerType(p);
|
||||||
|
String type = null;
|
||||||
|
if (typeMapping.containsKey(swaggerType)) {
|
||||||
|
type = typeMapping.get(swaggerType);
|
||||||
|
if (languageSpecificPrimitives.contains(type))
|
||||||
|
return toModelName(type);
|
||||||
|
} else if(swaggerType == "object") {
|
||||||
|
type = "Value";
|
||||||
|
} else if(typeMapping.containsValue(swaggerType)) {
|
||||||
|
type = swaggerType + "_";
|
||||||
|
} else {
|
||||||
|
type = swaggerType;
|
||||||
|
}
|
||||||
return toModelName(type);
|
return toModelName(type);
|
||||||
}
|
}
|
||||||
else
|
|
||||||
type = swaggerType;
|
|
||||||
return toModelName(type);
|
|
||||||
}
|
|
||||||
|
|
||||||
private String capturePath(String path, List<CodegenParameter> pathParams) {
|
@Override
|
||||||
for (CodegenParameter p : pathParams) {
|
public String toInstantiationType(Property p) {
|
||||||
String pName = "{"+p.baseName+"}";
|
if (p instanceof MapProperty) {
|
||||||
if (path.indexOf(pName) >= 0) {
|
MapProperty ap = (MapProperty) p;
|
||||||
path = path.replace(pName, "Capture " + "\""+p.baseName+"\" " + p.dataType);
|
Property additionalProperties2 = ap.getAdditionalProperties();
|
||||||
}
|
String type = additionalProperties2.getType();
|
||||||
|
if (null == type) {
|
||||||
|
LOGGER.error("No Type defined for Additional Property " + additionalProperties2 + "\n" //
|
||||||
|
+ "\tIn Property: " + p);
|
||||||
|
}
|
||||||
|
String inner = getSwaggerType(additionalProperties2);
|
||||||
|
return "(Map.Map Text " + inner + ")";
|
||||||
|
} else if (p instanceof ArrayProperty) {
|
||||||
|
ArrayProperty ap = (ArrayProperty) p;
|
||||||
|
String inner = getSwaggerType(ap.getItems());
|
||||||
|
// Return only the inner type; the wrapping with QueryList is done
|
||||||
|
// somewhere else, where we have access to the collection format.
|
||||||
|
return inner;
|
||||||
|
} else {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return path;
|
|
||||||
}
|
|
||||||
|
|
||||||
private String queryPath(String path, List<CodegenParameter> queryParams) {
|
|
||||||
for (CodegenParameter p : queryParams) {
|
// Intersperse a separator string between a list of strings, like String.join.
|
||||||
path += " :> QueryParam \"" + p.baseName + "\" " + p.dataType;
|
private String joinStrings(String sep, List<String> ss) {
|
||||||
|
StringBuilder sb = new StringBuilder();
|
||||||
|
for (String s : ss) {
|
||||||
|
if (sb.length() > 0) {
|
||||||
|
sb.append(sep);
|
||||||
|
}
|
||||||
|
sb.append(s);
|
||||||
|
}
|
||||||
|
return sb.toString();
|
||||||
}
|
}
|
||||||
return path;
|
|
||||||
}
|
|
||||||
|
|
||||||
private String bodyPath(String path, List<CodegenParameter> bodyParams) {
|
// Convert an HTTP path to a Servant route, including captured parameters.
|
||||||
for (CodegenParameter p : bodyParams) {
|
// For example, the path /api/jobs/info/{id}/last would become:
|
||||||
path += " :> ReqBody '[JSON] " + p.dataType;
|
// "api" :> "jobs" :> "info" :> Capture "id" IdType :> "last"
|
||||||
|
// IdType is provided by the capture params.
|
||||||
|
private List<String> pathToServantRoute(String path, List<CodegenParameter> pathParams) {
|
||||||
|
// Map the capture params by their names.
|
||||||
|
HashMap<String, String> captureTypes = new HashMap<String, String>();
|
||||||
|
for (CodegenParameter param : pathParams) {
|
||||||
|
captureTypes.put(param.baseName, param.dataType);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Cut off the leading slash, if it is present.
|
||||||
|
if (path.startsWith("/")) {
|
||||||
|
path = path.substring(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Convert the path into a list of servant route components.
|
||||||
|
List<String> pathComponents = new ArrayList<String>();
|
||||||
|
for (String piece : path.split("/")) {
|
||||||
|
if (piece.startsWith("{") && piece.endsWith("}")) {
|
||||||
|
String name = piece.substring(1, piece.length() - 1);
|
||||||
|
pathComponents.add("Capture \"" + name + "\" " + captureTypes.get(name));
|
||||||
|
} else {
|
||||||
|
pathComponents.add("\"" + piece + "\"");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Intersperse the servant route pieces with :> to construct the final API type
|
||||||
|
return pathComponents;
|
||||||
}
|
}
|
||||||
return path;
|
|
||||||
}
|
|
||||||
|
|
||||||
private String formPath(String path, List<CodegenParameter> formParams) {
|
// Extract the arguments that are passed in the route path parameters
|
||||||
String names = "Form";
|
private List<String> pathToClientType(String path, List<CodegenParameter> pathParams) {
|
||||||
for (CodegenParameter p : formParams) {
|
// Map the capture params by their names.
|
||||||
if(p.dataType.equals("FilePath")){
|
HashMap<String, String> captureTypes = new HashMap<String, String>();
|
||||||
// file data processing
|
for (CodegenParameter param : pathParams) {
|
||||||
}
|
captureTypes.put(param.baseName, param.dataType);
|
||||||
names += p.baseName;
|
}
|
||||||
|
|
||||||
|
// Cut off the leading slash, if it is present.
|
||||||
|
if (path.startsWith("/")) {
|
||||||
|
path = path.substring(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Convert the path into a list of servant route components.
|
||||||
|
List<String> type = new ArrayList<String>();
|
||||||
|
for (String piece : path.split("/")) {
|
||||||
|
if (piece.startsWith("{") && piece.endsWith("}")) {
|
||||||
|
String name = piece.substring(1, piece.length() - 1);
|
||||||
|
type.add(captureTypes.get(name));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return type;
|
||||||
}
|
}
|
||||||
if(formParams.size() > 0){
|
|
||||||
path += " :> ReqBody '[FormUrlEncoded] " + names;
|
|
||||||
|
@Override
|
||||||
|
public CodegenOperation fromOperation(String resourcePath, String httpMethod, Operation operation, Map<String, Model> definitions, Swagger swagger) {
|
||||||
|
CodegenOperation op = super.fromOperation(resourcePath, httpMethod, operation, definitions, swagger);
|
||||||
|
|
||||||
|
List<String> path = pathToServantRoute(op.path, op.pathParams);
|
||||||
|
List<String> type = pathToClientType(op.path, op.pathParams);
|
||||||
|
|
||||||
|
// Query parameters appended to routes
|
||||||
|
for (CodegenParameter param : op.queryParams) {
|
||||||
|
String paramType = param.dataType;
|
||||||
|
if(param.isListContainer != null && param.isListContainer) {
|
||||||
|
paramType = makeQueryListType(paramType, param.collectionFormat);
|
||||||
|
}
|
||||||
|
path.add("QueryParam \"" + param.baseName + "\" " + paramType);
|
||||||
|
type.add("Maybe " + param.dataType);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Either body or form data parameters appended to route
|
||||||
|
// As far as I know, you cannot have two ReqBody routes.
|
||||||
|
// Is it possible to have body params AND have form params?
|
||||||
|
String bodyType = null;
|
||||||
|
if (op.getHasBodyParam()) {
|
||||||
|
for (CodegenParameter param : op.bodyParams) {
|
||||||
|
path.add("ReqBody '[JSON] " + param.dataType);
|
||||||
|
bodyType = param.dataType;
|
||||||
|
}
|
||||||
|
} else if(op.getHasFormParams()) {
|
||||||
|
// Use the FormX data type, where X is the conglomerate of all things being passed
|
||||||
|
String formName = "Form" + camelize(op.operationId);
|
||||||
|
bodyType = formName;
|
||||||
|
path.add("ReqBody '[FormUrlEncoded] " + formName);
|
||||||
|
}
|
||||||
|
if(bodyType != null) {
|
||||||
|
type.add(bodyType);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Special headers appended to route
|
||||||
|
for (CodegenParameter param : op.headerParams) {
|
||||||
|
path.add("Header \"" + param.baseName + "\" " + param.dataType);
|
||||||
|
|
||||||
|
String paramType = param.dataType;
|
||||||
|
if(param.isListContainer != null && param.isListContainer) {
|
||||||
|
paramType = makeQueryListType(paramType, param.collectionFormat);
|
||||||
|
}
|
||||||
|
type.add("Maybe " + paramType);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Add the HTTP method and return type
|
||||||
|
String returnType = op.returnType;
|
||||||
|
if (returnType == null || returnType.equals("null")) {
|
||||||
|
returnType = "()";
|
||||||
|
}
|
||||||
|
if (returnType.indexOf(" ") >= 0) {
|
||||||
|
returnType = "(" + returnType + ")";
|
||||||
|
}
|
||||||
|
path.add("Verb '" + op.httpMethod.toUpperCase() + " 200 '[JSON] " + returnType);
|
||||||
|
type.add("m " + returnType);
|
||||||
|
|
||||||
|
op.vendorExtensions.put("x-routeType", joinStrings(" :> ", path));
|
||||||
|
op.vendorExtensions.put("x-clientType", joinStrings(" -> ", type));
|
||||||
|
op.vendorExtensions.put("x-formName", "Form" + camelize(op.operationId));
|
||||||
|
for(CodegenParameter param : op.formParams) {
|
||||||
|
param.vendorExtensions.put("x-formPrefix", camelize(op.operationId, true));
|
||||||
|
}
|
||||||
|
return op;
|
||||||
}
|
}
|
||||||
return path;
|
|
||||||
}
|
|
||||||
|
|
||||||
private String headerPath(String path, List<CodegenParameter> headerParams) {
|
private String makeQueryListType(String type, String collectionFormat) {
|
||||||
for (CodegenParameter p : headerParams) {
|
type = type.substring(1, type.length() - 1);
|
||||||
path += " :> Header \"" + p.baseName + "\" " + p.dataType;
|
switch(collectionFormat) {
|
||||||
|
case "csv": return "(QueryList 'CommaSeparated (" + type + "))";
|
||||||
|
case "tsv": return "(QueryList 'TabSeparated (" + type + "))";
|
||||||
|
case "ssv": return "(QueryList 'SpaceSeparated (" + type + "))";
|
||||||
|
case "pipes": return "(QueryList 'PipeSeparated (" + type + "))";
|
||||||
|
case "multi": return "(QueryList 'MultiParamArray (" + type + "))";
|
||||||
|
default:
|
||||||
|
throw new NotImplementedException();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return path;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
private String fixOperatorChars(String string) {
|
||||||
private String filterReturnType(String rt) {
|
StringBuilder sb = new StringBuilder();
|
||||||
if (rt == null || rt.equals("null")) {
|
for (char c : string.toCharArray()) {
|
||||||
return "()";
|
if (specialCharReplacements.containsKey(c)) {
|
||||||
} else if (rt.indexOf(" ") >= 0) {
|
sb.append("'");
|
||||||
return "(" + rt + ")";
|
sb.append(specialCharReplacements.get(c));
|
||||||
|
} else {
|
||||||
|
sb.append(c);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return sb.toString();
|
||||||
}
|
}
|
||||||
return rt;
|
|
||||||
}
|
|
||||||
|
|
||||||
private String addReturnPath(String path, String httpMethod, String returnType) {
|
// Remove characters from a string that do not belong in a model classname
|
||||||
return path + " :> " + upperCaseFirst(httpMethod) + " '[JSON] " + filterReturnType(returnType);
|
private String fixModelChars(String string) {
|
||||||
}
|
return string.replace(".", "").replace("-", "");
|
||||||
|
|
||||||
private String joinStrings(String sep, List<String> ss) {
|
|
||||||
StringBuilder sb = new StringBuilder();
|
|
||||||
for (String s : ss) {
|
|
||||||
if (sb.length() > 0) {
|
|
||||||
sb.append(sep);
|
|
||||||
}
|
|
||||||
sb.append(s);
|
|
||||||
}
|
}
|
||||||
return sb.toString();
|
|
||||||
}
|
|
||||||
|
|
||||||
private String replacePathSplitter(String path) {
|
// Override fromModel to create the appropriate model namings
|
||||||
String[] ps = path.replaceFirst("/", "").split("/", 0);
|
@Override
|
||||||
List<String> rs = new ArrayList<String>();
|
public CodegenModel fromModel(String name, Model mod, Map<String, Model> allDefinitions) {
|
||||||
for (String p : ps) {
|
CodegenModel model = super.fromModel(name, mod, allDefinitions);
|
||||||
if (p.indexOf("{") < 0) {
|
|
||||||
rs.add("\"" + p + "\"");
|
// Clean up the class name to remove invalid characters
|
||||||
} else {
|
model.classname = fixModelChars(model.classname);
|
||||||
rs.add(p);
|
if(typeMapping.containsValue(model.classname)) {
|
||||||
}
|
model.classname += "_";
|
||||||
|
}
|
||||||
|
|
||||||
|
// From the model name, compute the prefix for the fields.
|
||||||
|
String prefix = camelize(model.classname, true);
|
||||||
|
for(CodegenProperty prop : model.vars) {
|
||||||
|
prop.name = prefix + camelize(fixOperatorChars(prop.name));
|
||||||
|
}
|
||||||
|
|
||||||
|
// Create newtypes for things with non-object types
|
||||||
|
String dataOrNewtype = "data";
|
||||||
|
String modelType = ((ModelImpl) mod).getType();
|
||||||
|
if(modelType != "object" && typeMapping.containsKey(modelType)) {
|
||||||
|
String newtype = typeMapping.get(modelType);
|
||||||
|
model.vendorExtensions.put("x-customNewtype", newtype);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Provide the prefix as a vendor extension, so that it can be used in the ToJSON and FromJSON instances.
|
||||||
|
model.vendorExtensions.put("x-prefix", prefix);
|
||||||
|
model.vendorExtensions.put("x-data", dataOrNewtype);
|
||||||
|
|
||||||
|
return model;
|
||||||
}
|
}
|
||||||
return joinStrings(" :> ", rs);
|
|
||||||
}
|
|
||||||
|
|
||||||
private String upperCaseFirst(String str) {
|
|
||||||
char[] array = str.toLowerCase().toCharArray();
|
|
||||||
array[0] = Character.toUpperCase(array[0]);
|
|
||||||
return new String(array);
|
|
||||||
}
|
|
||||||
|
|
||||||
private String parseScheme(String basePath) {
|
|
||||||
return "Http";
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public CodegenOperation fromOperation(String resourcePath, String httpMethod, Operation operation, Map<String, Model> definitions, Swagger swagger){
|
|
||||||
CodegenOperation op = super.fromOperation(resourcePath, httpMethod, operation, definitions, swagger);
|
|
||||||
String path = op.path;
|
|
||||||
op.nickname = addReturnPath(headerPath(formPath(bodyPath(queryPath(capturePath(replacePathSplitter(path), op.pathParams), op.queryParams), op.bodyParams), op.formParams), op.headerParams), op.httpMethod, op.returnType);
|
|
||||||
return op;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public CodegenParameter fromParameter(Parameter param, Set<String> imports) {
|
||||||
|
CodegenParameter p = super.fromParameter(param, imports);
|
||||||
|
p.vendorExtensions.put("x-formParamName", camelize(p.baseName));
|
||||||
|
p.dataType = fixModelChars(p.dataType);
|
||||||
|
return p;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -42,6 +42,7 @@ public class JavaClientCodegen extends DefaultCodegen implements CodegenConfig {
|
|||||||
protected Boolean serializableModel = false;
|
protected Boolean serializableModel = false;
|
||||||
protected boolean serializeBigDecimalAsString = false;
|
protected boolean serializeBigDecimalAsString = false;
|
||||||
protected boolean useRxJava = false;
|
protected boolean useRxJava = false;
|
||||||
|
protected boolean hideGenerationTimestamp = false;
|
||||||
protected String apiDocPath = "docs/";
|
protected String apiDocPath = "docs/";
|
||||||
protected String modelDocPath = "docs/";
|
protected String modelDocPath = "docs/";
|
||||||
|
|
||||||
@ -101,6 +102,7 @@ public class JavaClientCodegen extends DefaultCodegen implements CodegenConfig {
|
|||||||
.SERIALIZE_BIG_DECIMAL_AS_STRING_DESC));
|
.SERIALIZE_BIG_DECIMAL_AS_STRING_DESC));
|
||||||
cliOptions.add(CliOption.newBoolean(FULL_JAVA_UTIL, "whether to use fully qualified name for classes under java.util"));
|
cliOptions.add(CliOption.newBoolean(FULL_JAVA_UTIL, "whether to use fully qualified name for classes under java.util"));
|
||||||
cliOptions.add(CliOption.newBoolean(USE_RX_JAVA, "Whether to use the RxJava adapter with the retrofit2 library."));
|
cliOptions.add(CliOption.newBoolean(USE_RX_JAVA, "Whether to use the RxJava adapter with the retrofit2 library."));
|
||||||
|
cliOptions.add(new CliOption("hideGenerationTimestamp", "hides the timestamp when files were generated"));
|
||||||
|
|
||||||
supportedLibraries.put(DEFAULT_LIBRARY, "HTTP client: Jersey client 1.18. JSON processing: Jackson 2.4.2");
|
supportedLibraries.put(DEFAULT_LIBRARY, "HTTP client: Jersey client 1.18. JSON processing: Jackson 2.4.2");
|
||||||
supportedLibraries.put("feign", "HTTP client: Netflix Feign 8.1.1");
|
supportedLibraries.put("feign", "HTTP client: Netflix Feign 8.1.1");
|
||||||
|
@ -6,11 +6,8 @@ import io.swagger.models.Operation;
|
|||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
||||||
public class JavaJerseyServerCodegen extends AbstractJavaJAXRSServerCodegen
|
public class JavaJerseyServerCodegen extends AbstractJavaJAXRSServerCodegen {
|
||||||
{
|
public JavaJerseyServerCodegen() {
|
||||||
|
|
||||||
public JavaJerseyServerCodegen()
|
|
||||||
{
|
|
||||||
super();
|
super();
|
||||||
|
|
||||||
sourceFolder = "src/gen/java";
|
sourceFolder = "src/gen/java";
|
||||||
@ -43,6 +40,7 @@ public class JavaJerseyServerCodegen extends AbstractJavaJAXRSServerCodegen
|
|||||||
Map<String, String> supportedLibraries = new LinkedHashMap<String, String>();
|
Map<String, String> supportedLibraries = new LinkedHashMap<String, String>();
|
||||||
|
|
||||||
supportedLibraries.put(DEFAULT_LIBRARY, "Jersey core 1.18.1");
|
supportedLibraries.put(DEFAULT_LIBRARY, "Jersey core 1.18.1");
|
||||||
|
supportedLibraries.put("jersey2", "Jersey core 2.x");
|
||||||
library.setEnum(supportedLibraries);
|
library.setEnum(supportedLibraries);
|
||||||
|
|
||||||
cliOptions.add(library);
|
cliOptions.add(library);
|
||||||
@ -85,6 +83,9 @@ public class JavaJerseyServerCodegen extends AbstractJavaJAXRSServerCodegen
|
|||||||
supportingFiles.add(new SupportingFile("ApiOriginFilter.mustache", (sourceFolder + '/' + apiPackage).replace(".", "/"), "ApiOriginFilter.java"));
|
supportingFiles.add(new SupportingFile("ApiOriginFilter.mustache", (sourceFolder + '/' + apiPackage).replace(".", "/"), "ApiOriginFilter.java"));
|
||||||
supportingFiles.add(new SupportingFile("ApiResponseMessage.mustache", (sourceFolder + '/' + apiPackage).replace(".", "/"), "ApiResponseMessage.java"));
|
supportingFiles.add(new SupportingFile("ApiResponseMessage.mustache", (sourceFolder + '/' + apiPackage).replace(".", "/"), "ApiResponseMessage.java"));
|
||||||
supportingFiles.add(new SupportingFile("NotFoundException.mustache", (sourceFolder + '/' + apiPackage).replace(".", "/"), "NotFoundException.java"));
|
supportingFiles.add(new SupportingFile("NotFoundException.mustache", (sourceFolder + '/' + apiPackage).replace(".", "/"), "NotFoundException.java"));
|
||||||
|
supportingFiles.add(new SupportingFile("jacksonJsonProvider.mustache", (sourceFolder + '/' + apiPackage).replace(".", "/"), "JacksonJsonProvider.java"));
|
||||||
|
writeOptional(outputFolder, new SupportingFile("bootstrap.mustache", (implFolder + '/' + apiPackage).replace(".", "/"), "Bootstrap.java"));
|
||||||
|
|
||||||
writeOptional(outputFolder, new SupportingFile("web.mustache", ("src/main/webapp/WEB-INF"), "web.xml"));
|
writeOptional(outputFolder, new SupportingFile("web.mustache", ("src/main/webapp/WEB-INF"), "web.xml"));
|
||||||
supportingFiles.add(new SupportingFile("StringUtil.mustache", (sourceFolder + '/' + apiPackage).replace(".", "/"), "StringUtil.java"));
|
supportingFiles.add(new SupportingFile("StringUtil.mustache", (sourceFolder + '/' + apiPackage).replace(".", "/"), "StringUtil.java"));
|
||||||
|
|
||||||
@ -92,6 +93,24 @@ public class JavaJerseyServerCodegen extends AbstractJavaJAXRSServerCodegen
|
|||||||
setDateLibrary(additionalProperties.get("dateLibrary").toString());
|
setDateLibrary(additionalProperties.get("dateLibrary").toString());
|
||||||
additionalProperties.put(dateLibrary, "true");
|
additionalProperties.put(dateLibrary, "true");
|
||||||
}
|
}
|
||||||
|
if(DEFAULT_LIBRARY.equals(library) || library == null) {
|
||||||
|
if(templateDir.startsWith(JAXRS_TEMPLATE_DIRECTORY_NAME)) {
|
||||||
|
// set to the default location
|
||||||
|
templateDir = JAXRS_TEMPLATE_DIRECTORY_NAME + File.separator + "jersey1_18";
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
templateDir += File.separator + "jersey1_18";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if("jersey2".equals(library)) {
|
||||||
|
if(templateDir.startsWith(JAXRS_TEMPLATE_DIRECTORY_NAME)) {
|
||||||
|
// set to the default location
|
||||||
|
templateDir = JAXRS_TEMPLATE_DIRECTORY_NAME + File.separator + "jersey2";
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
templateDir += File.separator + "jersey2";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if ( "joda".equals(dateLibrary) ) {
|
if ( "joda".equals(dateLibrary) ) {
|
||||||
supportingFiles.add(new SupportingFile("JodaDateTimeProvider.mustache", (sourceFolder + '/' + apiPackage).replace(".", "/"), "JodaDateTimeProvider.java"));
|
supportingFiles.add(new SupportingFile("JodaDateTimeProvider.mustache", (sourceFolder + '/' + apiPackage).replace(".", "/"), "JodaDateTimeProvider.java"));
|
||||||
@ -128,5 +147,9 @@ public class JavaJerseyServerCodegen extends AbstractJavaJAXRSServerCodegen
|
|||||||
}
|
}
|
||||||
opList.add(co);
|
opList.add(co);
|
||||||
co.baseName = basePath;
|
co.baseName = basePath;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void hideGenerationTimestamp(boolean hideGenerationTimestamp) {
|
||||||
|
this.hideGenerationTimestamp = hideGenerationTimestamp;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -122,7 +122,7 @@ public class JavascriptClientCodegen extends DefaultCodegen implements CodegenCo
|
|||||||
typeMapping.put("float", "Number");
|
typeMapping.put("float", "Number");
|
||||||
typeMapping.put("number", "Number");
|
typeMapping.put("number", "Number");
|
||||||
typeMapping.put("DateTime", "Date"); // Should this be dateTime?
|
typeMapping.put("DateTime", "Date"); // Should this be dateTime?
|
||||||
typeMapping.put("Date", "Date"); // Should this be date?
|
typeMapping.put("date", "Date"); // Should this be date?
|
||||||
typeMapping.put("long", "Integer");
|
typeMapping.put("long", "Integer");
|
||||||
typeMapping.put("short", "Integer");
|
typeMapping.put("short", "Integer");
|
||||||
typeMapping.put("char", "String");
|
typeMapping.put("char", "String");
|
||||||
|
@ -79,7 +79,7 @@ public class JavascriptClosureAngularClientCodegen extends DefaultCodegen implem
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getHelp() {
|
public String getHelp() {
|
||||||
return "Generates a Javascript AngularJS client library annotated with Google Closure Compiler annotations" +
|
return "Generates a Javascript AngularJS client library (beta) annotated with Google Closure Compiler annotations" +
|
||||||
"(https://developers.google.com/closure/compiler/docs/js-for-compiler?hl=en)";
|
"(https://developers.google.com/closure/compiler/docs/js-for-compiler?hl=en)";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -278,7 +278,9 @@ public class NodeJSServerCodegen extends DefaultCodegen implements CodegenConfig
|
|||||||
if(operation.getOperationId() == null) {
|
if(operation.getOperationId() == null) {
|
||||||
operation.setOperationId(getOrGenerateOperationId(operation, pathname, method.toString()));
|
operation.setOperationId(getOrGenerateOperationId(operation, pathname, method.toString()));
|
||||||
}
|
}
|
||||||
operation.getVendorExtensions().put("x-swagger-router-controller", toApiName(tag));
|
if(operation.getVendorExtensions().get("x-swagger-router-controller") == null) {
|
||||||
|
operation.getVendorExtensions().put("x-swagger-router-controller", sanitizeTag(tag));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -4,6 +4,7 @@ import io.swagger.codegen.CliOption;
|
|||||||
import io.swagger.codegen.CodegenConfig;
|
import io.swagger.codegen.CodegenConfig;
|
||||||
import io.swagger.codegen.CodegenConstants;
|
import io.swagger.codegen.CodegenConstants;
|
||||||
import io.swagger.codegen.CodegenOperation;
|
import io.swagger.codegen.CodegenOperation;
|
||||||
|
import io.swagger.codegen.CodegenParameter;
|
||||||
import io.swagger.codegen.CodegenProperty;
|
import io.swagger.codegen.CodegenProperty;
|
||||||
import io.swagger.codegen.CodegenType;
|
import io.swagger.codegen.CodegenType;
|
||||||
import io.swagger.codegen.DefaultCodegen;
|
import io.swagger.codegen.DefaultCodegen;
|
||||||
@ -36,6 +37,8 @@ public class ObjcClientCodegen extends DefaultCodegen implements CodegenConfig {
|
|||||||
protected String license = "MIT";
|
protected String license = "MIT";
|
||||||
protected String gitRepoURL = "https://github.com/swagger-api/swagger-codegen";
|
protected String gitRepoURL = "https://github.com/swagger-api/swagger-codegen";
|
||||||
protected String[] specialWords = {"new", "copy"};
|
protected String[] specialWords = {"new", "copy"};
|
||||||
|
protected String apiDocPath = "docs/";
|
||||||
|
protected String modelDocPath = "docs/";
|
||||||
|
|
||||||
public ObjcClientCodegen() {
|
public ObjcClientCodegen() {
|
||||||
super();
|
super();
|
||||||
@ -46,6 +49,8 @@ public class ObjcClientCodegen extends DefaultCodegen implements CodegenConfig {
|
|||||||
apiTemplateFiles.put("api-header.mustache", ".h");
|
apiTemplateFiles.put("api-header.mustache", ".h");
|
||||||
apiTemplateFiles.put("api-body.mustache", ".m");
|
apiTemplateFiles.put("api-body.mustache", ".m");
|
||||||
embeddedTemplateDir = templateDir = "objc";
|
embeddedTemplateDir = templateDir = "objc";
|
||||||
|
modelDocTemplateFiles.put("model_doc.mustache", ".md");
|
||||||
|
apiDocTemplateFiles.put("api_doc.mustache", ".md");
|
||||||
|
|
||||||
defaultIncludes.clear();
|
defaultIncludes.clear();
|
||||||
defaultIncludes.add("bool");
|
defaultIncludes.add("bool");
|
||||||
@ -90,7 +95,7 @@ public class ObjcClientCodegen extends DefaultCodegen implements CodegenConfig {
|
|||||||
//TODO binary should be mapped to byte array
|
//TODO binary should be mapped to byte array
|
||||||
// mapped to String as a workaround
|
// mapped to String as a workaround
|
||||||
typeMapping.put("binary", "NSString");
|
typeMapping.put("binary", "NSString");
|
||||||
|
typeMapping.put("ByteArray", "NSString");
|
||||||
|
|
||||||
// ref: http://www.tutorialspoint.com/objective_c/objective_c_basic_syntax.htm
|
// ref: http://www.tutorialspoint.com/objective_c/objective_c_basic_syntax.htm
|
||||||
setReservedWordsLowerCase(
|
setReservedWordsLowerCase(
|
||||||
@ -199,6 +204,10 @@ public class ObjcClientCodegen extends DefaultCodegen implements CodegenConfig {
|
|||||||
additionalProperties.put(GIT_REPO_URL, gitRepoURL);
|
additionalProperties.put(GIT_REPO_URL, gitRepoURL);
|
||||||
additionalProperties.put(LICENSE, license);
|
additionalProperties.put(LICENSE, license);
|
||||||
|
|
||||||
|
// make api and model doc path available in mustache template
|
||||||
|
additionalProperties.put("apiDocPath", apiDocPath);
|
||||||
|
additionalProperties.put("modelDocPath", modelDocPath);
|
||||||
|
|
||||||
String swaggerFolder = podName;
|
String swaggerFolder = podName;
|
||||||
|
|
||||||
modelPackage = swaggerFolder;
|
modelPackage = swaggerFolder;
|
||||||
@ -388,6 +397,26 @@ public class ObjcClientCodegen extends DefaultCodegen implements CodegenConfig {
|
|||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String apiDocFileFolder() {
|
||||||
|
return (outputFolder + "/" + apiDocPath).replace("/", File.separator);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String modelDocFileFolder() {
|
||||||
|
return (outputFolder + "/" + modelDocPath).replace("/", File.separator);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toModelDocFilename(String name) {
|
||||||
|
return toModelName(name);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toApiDocFilename(String name) {
|
||||||
|
return toApiName(name);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String apiFileFolder() {
|
public String apiFileFolder() {
|
||||||
return outputFolder + File.separatorChar + apiPackage();
|
return outputFolder + File.separatorChar + apiPackage();
|
||||||
@ -562,4 +591,75 @@ public class ObjcClientCodegen extends DefaultCodegen implements CodegenConfig {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setParameterExampleValue(CodegenParameter p) {
|
||||||
|
String example;
|
||||||
|
|
||||||
|
if (p.defaultValue == null) {
|
||||||
|
example = p.example;
|
||||||
|
} else {
|
||||||
|
example = p.defaultValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
String type = p.baseType;
|
||||||
|
if (type == null) {
|
||||||
|
type = p.dataType;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ("NSString*".equalsIgnoreCase(type)) {
|
||||||
|
if (example == null) {
|
||||||
|
example = p.paramName + "_example";
|
||||||
|
}
|
||||||
|
example = "@\"" + escapeText(example) + "\"";
|
||||||
|
} else if ("NSNumber*".equals(type)) {
|
||||||
|
if (example == null) {
|
||||||
|
example = "56";
|
||||||
|
}
|
||||||
|
example = "@" + example;
|
||||||
|
/* OBJC uses NSNumber to represent both int, long, double and float
|
||||||
|
} else if ("Float".equalsIgnoreCase(type) || "Double".equalsIgnoreCase(type)) {
|
||||||
|
if (example == null) {
|
||||||
|
example = "3.4";
|
||||||
|
} */
|
||||||
|
} else if ("BOOLEAN".equalsIgnoreCase(type) || "bool".equalsIgnoreCase(type)) {
|
||||||
|
if (example == null) {
|
||||||
|
example = "True";
|
||||||
|
}
|
||||||
|
} else if ("NSURL*".equalsIgnoreCase(type)) {
|
||||||
|
if (example == null) {
|
||||||
|
example = "/path/to/file";
|
||||||
|
}
|
||||||
|
//[NSURL fileURLWithPath:@"path/to/file"]
|
||||||
|
example = "[NSURL fileURLWithPath:@\"" + escapeText(example) + "\"]";
|
||||||
|
/*} else if ("NSDate".equalsIgnoreCase(type)) {
|
||||||
|
if (example == null) {
|
||||||
|
example = "2013-10-20";
|
||||||
|
}
|
||||||
|
example = "'" + escapeText(example) + "'";*/
|
||||||
|
} else if ("NSDate*".equalsIgnoreCase(type)) {
|
||||||
|
if (example == null) {
|
||||||
|
example = "2013-10-20T19:20:30+01:00";
|
||||||
|
}
|
||||||
|
example = "@\"" + escapeText(example) + "\"";
|
||||||
|
} else if (!languageSpecificPrimitives.contains(type)) {
|
||||||
|
// type is a model class, e.g. User
|
||||||
|
type = type.replace("*", "");
|
||||||
|
// e.g. [[SWGPet alloc] init
|
||||||
|
example = "[[" + type + " alloc] init]";
|
||||||
|
} else {
|
||||||
|
LOGGER.warn("Type " + type + " not handled properly in setParameterExampleValue");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (example == null) {
|
||||||
|
example = "NULL";
|
||||||
|
} else if (Boolean.TRUE.equals(p.isListContainer)) {
|
||||||
|
example = "@[" + example + "]";
|
||||||
|
} else if (Boolean.TRUE.equals(p.isMapContainer)) {
|
||||||
|
example = "@{@\"key\" : " + example + "}";
|
||||||
|
}
|
||||||
|
|
||||||
|
p.example = example;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -95,6 +95,7 @@ public class PerlClientCodegen extends DefaultCodegen implements CodegenConfig {
|
|||||||
//TODO binary should be mapped to byte array
|
//TODO binary should be mapped to byte array
|
||||||
// mapped to String as a workaround
|
// mapped to String as a workaround
|
||||||
typeMapping.put("binary", "string");
|
typeMapping.put("binary", "string");
|
||||||
|
typeMapping.put("ByteArray", "string");
|
||||||
|
|
||||||
cliOptions.clear();
|
cliOptions.clear();
|
||||||
cliOptions.add(new CliOption(MODULE_NAME, "Perl module name (convention: CamelCase or Long::Module).").defaultValue("SwaggerClient"));
|
cliOptions.add(new CliOption(MODULE_NAME, "Perl module name (convention: CamelCase or Long::Module).").defaultValue("SwaggerClient"));
|
||||||
|
@ -96,6 +96,7 @@ public class PhpClientCodegen extends DefaultCodegen implements CodegenConfig {
|
|||||||
typeMapping = new HashMap<String, String>();
|
typeMapping = new HashMap<String, String>();
|
||||||
typeMapping.put("integer", "int");
|
typeMapping.put("integer", "int");
|
||||||
typeMapping.put("long", "int");
|
typeMapping.put("long", "int");
|
||||||
|
typeMapping.put("number", "float");
|
||||||
typeMapping.put("float", "float");
|
typeMapping.put("float", "float");
|
||||||
typeMapping.put("double", "double");
|
typeMapping.put("double", "double");
|
||||||
typeMapping.put("string", "string");
|
typeMapping.put("string", "string");
|
||||||
@ -109,6 +110,7 @@ public class PhpClientCodegen extends DefaultCodegen implements CodegenConfig {
|
|||||||
typeMapping.put("list", "array");
|
typeMapping.put("list", "array");
|
||||||
typeMapping.put("object", "object");
|
typeMapping.put("object", "object");
|
||||||
typeMapping.put("binary", "string");
|
typeMapping.put("binary", "string");
|
||||||
|
typeMapping.put("ByteArray", "string");
|
||||||
|
|
||||||
cliOptions.add(new CliOption(CodegenConstants.MODEL_PACKAGE, CodegenConstants.MODEL_PACKAGE_DESC));
|
cliOptions.add(new CliOption(CodegenConstants.MODEL_PACKAGE, CodegenConstants.MODEL_PACKAGE_DESC));
|
||||||
cliOptions.add(new CliOption(CodegenConstants.API_PACKAGE, CodegenConstants.API_PACKAGE_DESC));
|
cliOptions.add(new CliOption(CodegenConstants.API_PACKAGE, CodegenConstants.API_PACKAGE_DESC));
|
||||||
|
@ -3,6 +3,7 @@ package io.swagger.codegen.languages;
|
|||||||
import io.swagger.codegen.CliOption;
|
import io.swagger.codegen.CliOption;
|
||||||
import io.swagger.codegen.CodegenConfig;
|
import io.swagger.codegen.CodegenConfig;
|
||||||
import io.swagger.codegen.CodegenConstants;
|
import io.swagger.codegen.CodegenConstants;
|
||||||
|
import io.swagger.codegen.CodegenParameter;
|
||||||
import io.swagger.codegen.CodegenType;
|
import io.swagger.codegen.CodegenType;
|
||||||
import io.swagger.codegen.DefaultCodegen;
|
import io.swagger.codegen.DefaultCodegen;
|
||||||
import io.swagger.codegen.SupportingFile;
|
import io.swagger.codegen.SupportingFile;
|
||||||
@ -17,6 +18,8 @@ import org.apache.commons.lang.StringUtils;
|
|||||||
public class PythonClientCodegen extends DefaultCodegen implements CodegenConfig {
|
public class PythonClientCodegen extends DefaultCodegen implements CodegenConfig {
|
||||||
protected String packageName;
|
protected String packageName;
|
||||||
protected String packageVersion;
|
protected String packageVersion;
|
||||||
|
protected String apiDocPath = "docs/";
|
||||||
|
protected String modelDocPath = "docs/";
|
||||||
|
|
||||||
public PythonClientCodegen() {
|
public PythonClientCodegen() {
|
||||||
super();
|
super();
|
||||||
@ -28,6 +31,9 @@ public class PythonClientCodegen extends DefaultCodegen implements CodegenConfig
|
|||||||
apiTemplateFiles.put("api.mustache", ".py");
|
apiTemplateFiles.put("api.mustache", ".py");
|
||||||
embeddedTemplateDir = templateDir = "python";
|
embeddedTemplateDir = templateDir = "python";
|
||||||
|
|
||||||
|
modelDocTemplateFiles.put("model_doc.mustache", ".md");
|
||||||
|
apiDocTemplateFiles.put("api_doc.mustache", ".md");
|
||||||
|
|
||||||
languageSpecificPrimitives.clear();
|
languageSpecificPrimitives.clear();
|
||||||
languageSpecificPrimitives.add("int");
|
languageSpecificPrimitives.add("int");
|
||||||
languageSpecificPrimitives.add("float");
|
languageSpecificPrimitives.add("float");
|
||||||
@ -36,6 +42,7 @@ public class PythonClientCodegen extends DefaultCodegen implements CodegenConfig
|
|||||||
languageSpecificPrimitives.add("str");
|
languageSpecificPrimitives.add("str");
|
||||||
languageSpecificPrimitives.add("datetime");
|
languageSpecificPrimitives.add("datetime");
|
||||||
languageSpecificPrimitives.add("date");
|
languageSpecificPrimitives.add("date");
|
||||||
|
languageSpecificPrimitives.add("object");
|
||||||
|
|
||||||
typeMapping.clear();
|
typeMapping.clear();
|
||||||
typeMapping.put("integer", "int");
|
typeMapping.put("integer", "int");
|
||||||
@ -54,6 +61,7 @@ public class PythonClientCodegen extends DefaultCodegen implements CodegenConfig
|
|||||||
//TODO binary should be mapped to byte array
|
//TODO binary should be mapped to byte array
|
||||||
// mapped to String as a workaround
|
// mapped to String as a workaround
|
||||||
typeMapping.put("binary", "str");
|
typeMapping.put("binary", "str");
|
||||||
|
typeMapping.put("ByteArray", "str");
|
||||||
|
|
||||||
// from https://docs.python.org/release/2.5.4/ref/keywords.html
|
// from https://docs.python.org/release/2.5.4/ref/keywords.html
|
||||||
setReservedWordsLowerCase(
|
setReservedWordsLowerCase(
|
||||||
@ -97,6 +105,10 @@ public class PythonClientCodegen extends DefaultCodegen implements CodegenConfig
|
|||||||
additionalProperties.put(CodegenConstants.PACKAGE_NAME, packageName);
|
additionalProperties.put(CodegenConstants.PACKAGE_NAME, packageName);
|
||||||
additionalProperties.put(CodegenConstants.PACKAGE_VERSION, packageVersion);
|
additionalProperties.put(CodegenConstants.PACKAGE_VERSION, packageVersion);
|
||||||
|
|
||||||
|
// make api and model doc path available in mustache template
|
||||||
|
additionalProperties.put("apiDocPath", apiDocPath);
|
||||||
|
additionalProperties.put("modelDocPath", modelDocPath);
|
||||||
|
|
||||||
String swaggerFolder = packageName;
|
String swaggerFolder = packageName;
|
||||||
|
|
||||||
modelPackage = swaggerFolder + File.separatorChar + "models";
|
modelPackage = swaggerFolder + File.separatorChar + "models";
|
||||||
@ -138,6 +150,27 @@ public class PythonClientCodegen extends DefaultCodegen implements CodegenConfig
|
|||||||
return "_" + name;
|
return "_" + name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String apiDocFileFolder() {
|
||||||
|
return (outputFolder + "/" + apiDocPath);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String modelDocFileFolder() {
|
||||||
|
return (outputFolder + "/" + modelDocPath);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toModelDocFilename(String name) {
|
||||||
|
return toModelName(name);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toApiDocFilename(String name) {
|
||||||
|
return toApiName(name);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String apiFileFolder() {
|
public String apiFileFolder() {
|
||||||
return outputFolder + File.separatorChar + apiPackage().replace('.', File.separatorChar);
|
return outputFolder + File.separatorChar + apiPackage().replace('.', File.separatorChar);
|
||||||
@ -388,4 +421,70 @@ public class PythonClientCodegen extends DefaultCodegen implements CodegenConfig
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setParameterExampleValue(CodegenParameter p) {
|
||||||
|
String example;
|
||||||
|
|
||||||
|
if (p.defaultValue == null) {
|
||||||
|
example = p.example;
|
||||||
|
} else {
|
||||||
|
example = p.defaultValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
String type = p.baseType;
|
||||||
|
if (type == null) {
|
||||||
|
type = p.dataType;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ("String".equalsIgnoreCase(type) || "str".equalsIgnoreCase(type)) {
|
||||||
|
if (example == null) {
|
||||||
|
example = p.paramName + "_example";
|
||||||
|
}
|
||||||
|
example = "'" + escapeText(example) + "'";
|
||||||
|
} else if ("Integer".equals(type) || "int".equals(type)) {
|
||||||
|
if (example == null) {
|
||||||
|
example = "56";
|
||||||
|
}
|
||||||
|
} else if ("Float".equalsIgnoreCase(type) || "Double".equalsIgnoreCase(type)) {
|
||||||
|
if (example == null) {
|
||||||
|
example = "3.4";
|
||||||
|
}
|
||||||
|
} else if ("BOOLEAN".equalsIgnoreCase(type) || "bool".equalsIgnoreCase(type)) {
|
||||||
|
if (example == null) {
|
||||||
|
example = "True";
|
||||||
|
}
|
||||||
|
} else if ("file".equalsIgnoreCase(type)) {
|
||||||
|
if (example == null) {
|
||||||
|
example = "/path/to/file";
|
||||||
|
}
|
||||||
|
example = "'" + escapeText(example) + "'";
|
||||||
|
} else if ("Date".equalsIgnoreCase(type)) {
|
||||||
|
if (example == null) {
|
||||||
|
example = "2013-10-20";
|
||||||
|
}
|
||||||
|
example = "'" + escapeText(example) + "'";
|
||||||
|
} else if ("DateTime".equalsIgnoreCase(type)) {
|
||||||
|
if (example == null) {
|
||||||
|
example = "2013-10-20T19:20:30+01:00";
|
||||||
|
}
|
||||||
|
example = "'" + escapeText(example) + "'";
|
||||||
|
} else if (!languageSpecificPrimitives.contains(type)) {
|
||||||
|
// type is a model class, e.g. User
|
||||||
|
example = this.packageName + "." + type + "()";
|
||||||
|
} else {
|
||||||
|
LOGGER.warn("Type " + type + " not handled properly in setParameterExampleValue");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (example == null) {
|
||||||
|
example = "NULL";
|
||||||
|
} else if (Boolean.TRUE.equals(p.isListContainer)) {
|
||||||
|
example = "[" + example + "]";
|
||||||
|
} else if (Boolean.TRUE.equals(p.isMapContainer)) {
|
||||||
|
example = "{'key': " + example + "}";
|
||||||
|
}
|
||||||
|
|
||||||
|
p.example = example;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -116,6 +116,7 @@ public class RubyClientCodegen extends DefaultCodegen implements CodegenConfig {
|
|||||||
typeMapping.put("object", "Object");
|
typeMapping.put("object", "Object");
|
||||||
typeMapping.put("file", "File");
|
typeMapping.put("file", "File");
|
||||||
typeMapping.put("binary", "String");
|
typeMapping.put("binary", "String");
|
||||||
|
typeMapping.put("ByteArray", "String");
|
||||||
|
|
||||||
// remove modelPackage and apiPackage added by default
|
// remove modelPackage and apiPackage added by default
|
||||||
Iterator<CliOption> itr = cliOptions.iterator();
|
Iterator<CliOption> itr = cliOptions.iterator();
|
||||||
|
@ -101,6 +101,7 @@ public class ScalaClientCodegen extends DefaultCodegen implements CodegenConfig
|
|||||||
//TODO binary should be mapped to byte array
|
//TODO binary should be mapped to byte array
|
||||||
// mapped to String as a workaround
|
// mapped to String as a workaround
|
||||||
typeMapping.put("binary", "String");
|
typeMapping.put("binary", "String");
|
||||||
|
typeMapping.put("ByteArray", "String");
|
||||||
|
|
||||||
languageSpecificPrimitives = new HashSet<String>(
|
languageSpecificPrimitives = new HashSet<String>(
|
||||||
Arrays.asList(
|
Arrays.asList(
|
||||||
|
@ -32,18 +32,6 @@ public class SpringMVCServerCodegen extends JavaClientCodegen {
|
|||||||
additionalProperties.put(CodegenConstants.API_PACKAGE, apiPackage);
|
additionalProperties.put(CodegenConstants.API_PACKAGE, apiPackage);
|
||||||
additionalProperties.put(CONFIG_PACKAGE, configPackage);
|
additionalProperties.put(CONFIG_PACKAGE, configPackage);
|
||||||
|
|
||||||
languageSpecificPrimitives = new HashSet<String>(
|
|
||||||
Arrays.asList(
|
|
||||||
"byte[]",
|
|
||||||
"String",
|
|
||||||
"boolean",
|
|
||||||
"Boolean",
|
|
||||||
"Double",
|
|
||||||
"Integer",
|
|
||||||
"Long",
|
|
||||||
"Float")
|
|
||||||
);
|
|
||||||
|
|
||||||
cliOptions.add(new CliOption(CONFIG_PACKAGE, "configuration package for generated code"));
|
cliOptions.add(new CliOption(CONFIG_PACKAGE, "configuration package for generated code"));
|
||||||
|
|
||||||
supportedLibraries.clear();
|
supportedLibraries.clear();
|
||||||
|
@ -74,6 +74,8 @@ public class SwiftCodegen extends DefaultCodegen implements CodegenConfig {
|
|||||||
languageSpecificPrimitives = new HashSet<String>(
|
languageSpecificPrimitives = new HashSet<String>(
|
||||||
Arrays.asList(
|
Arrays.asList(
|
||||||
"Int",
|
"Int",
|
||||||
|
"Int32",
|
||||||
|
"Int64",
|
||||||
"Float",
|
"Float",
|
||||||
"Double",
|
"Double",
|
||||||
"Bool",
|
"Bool",
|
||||||
@ -93,9 +95,10 @@ public class SwiftCodegen extends DefaultCodegen implements CodegenConfig {
|
|||||||
"Empty",
|
"Empty",
|
||||||
"AnyObject")
|
"AnyObject")
|
||||||
);
|
);
|
||||||
setReservedWordsLowerCase(
|
reservedWords = new HashSet<String>(
|
||||||
Arrays.asList(
|
Arrays.asList(
|
||||||
"class", "break", "as", "associativity", "deinit", "case", "dynamicType", "convenience", "enum", "continue",
|
"Int", "Int32", "Int64", "Int64", "Float", "Double", "Bool", "Void", "String", "Character", "AnyObject",
|
||||||
|
"class", "Class", "break", "as", "associativity", "deinit", "case", "dynamicType", "convenience", "enum", "continue",
|
||||||
"false", "dynamic", "extension", "default", "is", "didSet", "func", "do", "nil", "final", "import", "else",
|
"false", "dynamic", "extension", "default", "is", "didSet", "func", "do", "nil", "final", "import", "else",
|
||||||
"self", "get", "init", "fallthrough", "Self", "infix", "internal", "for", "super", "inout", "let", "if",
|
"self", "get", "init", "fallthrough", "Self", "infix", "internal", "for", "super", "inout", "let", "if",
|
||||||
"true", "lazy", "operator", "in", "COLUMN", "left", "private", "return", "FILE", "mutating", "protocol",
|
"true", "lazy", "operator", "in", "COLUMN", "left", "private", "return", "FILE", "mutating", "protocol",
|
||||||
@ -115,10 +118,10 @@ public class SwiftCodegen extends DefaultCodegen implements CodegenConfig {
|
|||||||
typeMapping.put("string", "String");
|
typeMapping.put("string", "String");
|
||||||
typeMapping.put("char", "Character");
|
typeMapping.put("char", "Character");
|
||||||
typeMapping.put("short", "Int");
|
typeMapping.put("short", "Int");
|
||||||
typeMapping.put("int", "Int");
|
typeMapping.put("int", "Int32");
|
||||||
typeMapping.put("long", "Int");
|
typeMapping.put("long", "Int64");
|
||||||
typeMapping.put("integer", "Int");
|
typeMapping.put("integer", "Int32");
|
||||||
typeMapping.put("Integer", "Int");
|
typeMapping.put("Integer", "Int32");
|
||||||
typeMapping.put("float", "Float");
|
typeMapping.put("float", "Float");
|
||||||
typeMapping.put("number", "Double");
|
typeMapping.put("number", "Double");
|
||||||
typeMapping.put("double", "Double");
|
typeMapping.put("double", "Double");
|
||||||
@ -127,6 +130,7 @@ public class SwiftCodegen extends DefaultCodegen implements CodegenConfig {
|
|||||||
//TODO binary should be mapped to byte array
|
//TODO binary should be mapped to byte array
|
||||||
// mapped to String as a workaround
|
// mapped to String as a workaround
|
||||||
typeMapping.put("binary", "String");
|
typeMapping.put("binary", "String");
|
||||||
|
typeMapping.put("ByteArray", "String");
|
||||||
|
|
||||||
importMapping = new HashMap<String, String>();
|
importMapping = new HashMap<String, String>();
|
||||||
|
|
||||||
@ -200,6 +204,11 @@ public class SwiftCodegen extends DefaultCodegen implements CodegenConfig {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected boolean isReservedWord(String word) {
|
||||||
|
return word != null && reservedWords.contains(word); //don't lowercase as super does
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String escapeReservedWord(String name) {
|
public String escapeReservedWord(String name) {
|
||||||
return "_" + name; // add an underscore to the name
|
return "_" + name; // add an underscore to the name
|
||||||
@ -331,10 +340,9 @@ public class SwiftCodegen extends DefaultCodegen implements CodegenConfig {
|
|||||||
// Ensure that the enum type doesn't match a reserved word or
|
// Ensure that the enum type doesn't match a reserved word or
|
||||||
// the variable name doesn't match the generated enum type or the
|
// the variable name doesn't match the generated enum type or the
|
||||||
// Swift compiler will generate an error
|
// Swift compiler will generate an error
|
||||||
if (isReservedWord(codegenProperty.datatypeWithEnum) ||
|
if (isReservedWord(codegenProperty.datatypeWithEnum) || name.equals(codegenProperty.datatypeWithEnum)) {
|
||||||
name.equals(codegenProperty.datatypeWithEnum)) {
|
codegenProperty.datatypeWithEnum = codegenProperty.datatypeWithEnum + "Enum";
|
||||||
codegenProperty.datatypeWithEnum = escapeReservedWord(codegenProperty.datatypeWithEnum);
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return codegenProperty;
|
return codegenProperty;
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.IO;
|
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using RestSharp;
|
using RestSharp;
|
||||||
using {{packageName}}.Client;
|
using {{packageName}}.Client;
|
||||||
|
@ -32,12 +32,12 @@ class {{classname}} {
|
|||||||
def queryParams = [:]
|
def queryParams = [:]
|
||||||
def headerParams = [:]
|
def headerParams = [:]
|
||||||
|
|
||||||
{{#requiredParamCount}}
|
{{#allParams}}
|
||||||
// verify required params are set
|
// verify required params are set
|
||||||
if({{/requiredParamCount}}{{#requiredParams}} {{paramName}} == null {{#hasMore}}|| {{/hasMore}}{{/requiredParams}}{{#requiredParamCount}}) {
|
if({{/allParams}}{{#required}} {{paramName}} == null {{#hasMore}}|| {{/hasMore}}{{/required}}{{#allParams}}) {
|
||||||
throw new RuntimeException("missing required params")
|
throw new RuntimeException("missing required params")
|
||||||
}
|
}
|
||||||
{{/requiredParamCount}}
|
{{/allParams}}
|
||||||
|
|
||||||
{{#queryParams}}if(!"null".equals(String.valueOf({{paramName}})))
|
{{#queryParams}}if(!"null".equals(String.valueOf({{paramName}})))
|
||||||
queryParams.put("{{paramName}}", String.valueOf({{paramName}}))
|
queryParams.put("{{paramName}}", String.valueOf({{paramName}}))
|
||||||
@ -53,4 +53,4 @@ class {{classname}} {
|
|||||||
}
|
}
|
||||||
{{/operation}}
|
{{/operation}}
|
||||||
}
|
}
|
||||||
{{/operations}}
|
{{/operations}}
|
||||||
|
@ -9,8 +9,8 @@ buildscript {
|
|||||||
jcenter()
|
jcenter()
|
||||||
}
|
}
|
||||||
dependencies {
|
dependencies {
|
||||||
classpath 'com.android.tools.build:gradle:1.2.2'
|
classpath 'com.android.tools.build:gradle:1.5.+'
|
||||||
classpath 'com.github.dcendents:android-maven-plugin:1.2'
|
classpath 'com.github.dcendents:android-maven-gradle-plugin:1.3'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -25,11 +25,11 @@ if(hasProperty('target') && target == 'android') {
|
|||||||
apply plugin: 'com.github.dcendents.android-maven'
|
apply plugin: 'com.github.dcendents.android-maven'
|
||||||
|
|
||||||
android {
|
android {
|
||||||
compileSdkVersion 22
|
compileSdkVersion 23
|
||||||
buildToolsVersion '22.0.0'
|
buildToolsVersion '23.0.2'
|
||||||
defaultConfig {
|
defaultConfig {
|
||||||
minSdkVersion 14
|
minSdkVersion 14
|
||||||
targetSdkVersion 22
|
targetSdkVersion 23
|
||||||
}
|
}
|
||||||
compileOptions {
|
compileOptions {
|
||||||
sourceCompatibility JavaVersion.VERSION_1_7
|
sourceCompatibility JavaVersion.VERSION_1_7
|
||||||
@ -98,7 +98,7 @@ ext {
|
|||||||
jackson_version = "2.4.2"
|
jackson_version = "2.4.2"
|
||||||
jersey_version = "1.18"
|
jersey_version = "1.18"
|
||||||
jodatime_version = "2.3"
|
jodatime_version = "2.3"
|
||||||
junit_version = "4.8.1"
|
junit_version = "4.12"
|
||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
|
@ -1 +1 @@
|
|||||||
@javax.annotation.Generated(value = "{{generatorClass}}", date = "{{generatedDate}}")
|
{{^hideGenerationTimestamp}}@javax.annotation.Generated(value = "{{generatorClass}}", date = "{{generatedDate}}"){{/hideGenerationTimestamp}}
|
@ -9,8 +9,8 @@ buildscript {
|
|||||||
jcenter()
|
jcenter()
|
||||||
}
|
}
|
||||||
dependencies {
|
dependencies {
|
||||||
classpath 'com.android.tools.build:gradle:1.2.2'
|
classpath 'com.android.tools.build:gradle:1.5.+'
|
||||||
classpath 'com.github.dcendents:android-maven-plugin:1.2'
|
classpath 'com.github.dcendents:android-maven-gradle-plugin:1.3'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -25,11 +25,11 @@ if(hasProperty('target') && target == 'android') {
|
|||||||
apply plugin: 'com.github.dcendents.android-maven'
|
apply plugin: 'com.github.dcendents.android-maven'
|
||||||
|
|
||||||
android {
|
android {
|
||||||
compileSdkVersion 22
|
compileSdkVersion 23
|
||||||
buildToolsVersion '22.0.0'
|
buildToolsVersion '23.0.2'
|
||||||
defaultConfig {
|
defaultConfig {
|
||||||
minSdkVersion 14
|
minSdkVersion 14
|
||||||
targetSdkVersion 22
|
targetSdkVersion 23
|
||||||
}
|
}
|
||||||
compileOptions {
|
compileOptions {
|
||||||
sourceCompatibility JavaVersion.VERSION_1_7
|
sourceCompatibility JavaVersion.VERSION_1_7
|
||||||
|
@ -110,7 +110,7 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>io.swagger</groupId>
|
<groupId>io.swagger</groupId>
|
||||||
<artifactId>swagger-annotations</artifactId>
|
<artifactId>swagger-annotations</artifactId>
|
||||||
<version>${swagger-annotations-version}</version>
|
<version>${swagger-core-version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<!-- HTTP client: Netflix Feign -->
|
<!-- HTTP client: Netflix Feign -->
|
||||||
@ -179,7 +179,7 @@
|
|||||||
</dependency>
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
<properties>
|
<properties>
|
||||||
<swagger-annotations-version>1.5.0</swagger-annotations-version>
|
<swagger-core-version>1.5.8</swagger-core-version>
|
||||||
<feign-version>8.1.1</feign-version>
|
<feign-version>8.1.1</feign-version>
|
||||||
<jackson-version>2.6.3</jackson-version>
|
<jackson-version>2.6.3</jackson-version>
|
||||||
<jodatime-version>2.5</jodatime-version>
|
<jodatime-version>2.5</jodatime-version>
|
||||||
|
@ -9,8 +9,8 @@ buildscript {
|
|||||||
jcenter()
|
jcenter()
|
||||||
}
|
}
|
||||||
dependencies {
|
dependencies {
|
||||||
classpath 'com.android.tools.build:gradle:1.2.2'
|
classpath 'com.android.tools.build:gradle:1.5.+'
|
||||||
classpath 'com.github.dcendents:android-maven-plugin:1.2'
|
classpath 'com.github.dcendents:android-maven-gradle-plugin:1.3'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -25,11 +25,11 @@ if(hasProperty('target') && target == 'android') {
|
|||||||
apply plugin: 'com.github.dcendents.android-maven'
|
apply plugin: 'com.github.dcendents.android-maven'
|
||||||
|
|
||||||
android {
|
android {
|
||||||
compileSdkVersion 22
|
compileSdkVersion 23
|
||||||
buildToolsVersion '22.0.0'
|
buildToolsVersion '23.0.2'
|
||||||
defaultConfig {
|
defaultConfig {
|
||||||
minSdkVersion 14
|
minSdkVersion 14
|
||||||
targetSdkVersion 22
|
targetSdkVersion 23
|
||||||
}
|
}
|
||||||
compileOptions {
|
compileOptions {
|
||||||
sourceCompatibility JavaVersion.VERSION_1_7
|
sourceCompatibility JavaVersion.VERSION_1_7
|
||||||
|
@ -131,7 +131,7 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>io.swagger</groupId>
|
<groupId>io.swagger</groupId>
|
||||||
<artifactId>swagger-annotations</artifactId>
|
<artifactId>swagger-annotations</artifactId>
|
||||||
<version>${swagger-annotations-version}</version>
|
<version>${swagger-core-version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<!-- HTTP client: jersey-client -->
|
<!-- HTTP client: jersey-client -->
|
||||||
@ -194,7 +194,7 @@
|
|||||||
</dependency>
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
<properties>
|
<properties>
|
||||||
<swagger-annotations-version>1.5.0</swagger-annotations-version>
|
<swagger-core-version>1.5.8</swagger-core-version>
|
||||||
<jersey-version>2.22</jersey-version>
|
<jersey-version>2.22</jersey-version>
|
||||||
<jackson-version>2.4.2</jackson-version>
|
<jackson-version>2.4.2</jackson-version>
|
||||||
<jodatime-version>2.3</jodatime-version>
|
<jodatime-version>2.3</jodatime-version>
|
||||||
|
@ -9,8 +9,8 @@ buildscript {
|
|||||||
jcenter()
|
jcenter()
|
||||||
}
|
}
|
||||||
dependencies {
|
dependencies {
|
||||||
classpath 'com.android.tools.build:gradle:1.2.2'
|
classpath 'com.android.tools.build:gradle:1.5.+'
|
||||||
classpath 'com.github.dcendents:android-maven-plugin:1.2'
|
classpath 'com.github.dcendents:android-maven-gradle-plugin:1.3'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -25,11 +25,11 @@ if(hasProperty('target') && target == 'android') {
|
|||||||
apply plugin: 'com.github.dcendents.android-maven'
|
apply plugin: 'com.github.dcendents.android-maven'
|
||||||
|
|
||||||
android {
|
android {
|
||||||
compileSdkVersion 22
|
compileSdkVersion 23
|
||||||
buildToolsVersion '22.0.0'
|
buildToolsVersion '23.0.2'
|
||||||
defaultConfig {
|
defaultConfig {
|
||||||
minSdkVersion 14
|
minSdkVersion 14
|
||||||
targetSdkVersion 22
|
targetSdkVersion 23
|
||||||
}
|
}
|
||||||
compileOptions {
|
compileOptions {
|
||||||
sourceCompatibility JavaVersion.VERSION_1_7
|
sourceCompatibility JavaVersion.VERSION_1_7
|
||||||
@ -98,5 +98,5 @@ dependencies {
|
|||||||
compile 'com.squareup.okhttp:okhttp:2.7.2'
|
compile 'com.squareup.okhttp:okhttp:2.7.2'
|
||||||
compile 'com.squareup.okhttp:logging-interceptor:2.7.2'
|
compile 'com.squareup.okhttp:logging-interceptor:2.7.2'
|
||||||
compile 'com.google.code.gson:gson:2.3.1'
|
compile 'com.google.code.gson:gson:2.3.1'
|
||||||
testCompile 'junit:junit:4.8.1'
|
testCompile 'junit:junit:4.12'
|
||||||
}
|
}
|
||||||
|
@ -132,7 +132,7 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>io.swagger</groupId>
|
<groupId>io.swagger</groupId>
|
||||||
<artifactId>swagger-annotations</artifactId>
|
<artifactId>swagger-annotations</artifactId>
|
||||||
<version>${swagger-annotations-version}</version>
|
<version>${swagger-core-version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.squareup.okhttp</groupId>
|
<groupId>com.squareup.okhttp</groupId>
|
||||||
@ -159,10 +159,10 @@
|
|||||||
</dependency>
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
<properties>
|
<properties>
|
||||||
<swagger-annotations-version>1.5.0</swagger-annotations-version>
|
<swagger-core-version>1.5.8</swagger-core-version>
|
||||||
<okhttp-version>2.7.2</okhttp-version>
|
<okhttp-version>2.7.2</okhttp-version>
|
||||||
<gson-version>2.3.1</gson-version>
|
<gson-version>2.3.1</gson-version>
|
||||||
<maven-plugin-version>1.0.0</maven-plugin-version>
|
<maven-plugin-version>1.0.0</maven-plugin-version>
|
||||||
<junit-version>4.8.1</junit-version>
|
<junit-version>4.12</junit-version>
|
||||||
</properties>
|
</properties>
|
||||||
</project>
|
</project>
|
||||||
|
@ -9,8 +9,8 @@ buildscript {
|
|||||||
jcenter()
|
jcenter()
|
||||||
}
|
}
|
||||||
dependencies {
|
dependencies {
|
||||||
classpath 'com.android.tools.build:gradle:1.2.2'
|
classpath 'com.android.tools.build:gradle:1.5.+'
|
||||||
classpath 'com.github.dcendents:android-maven-plugin:1.2'
|
classpath 'com.github.dcendents:android-maven-gradle-plugin:1.3'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -25,11 +25,11 @@ if(hasProperty('target') && target == 'android') {
|
|||||||
apply plugin: 'com.github.dcendents.android-maven'
|
apply plugin: 'com.github.dcendents.android-maven'
|
||||||
|
|
||||||
android {
|
android {
|
||||||
compileSdkVersion 22
|
compileSdkVersion 23
|
||||||
buildToolsVersion '22.0.0'
|
buildToolsVersion '23.0.2'
|
||||||
defaultConfig {
|
defaultConfig {
|
||||||
minSdkVersion 14
|
minSdkVersion 14
|
||||||
targetSdkVersion 22
|
targetSdkVersion 23
|
||||||
}
|
}
|
||||||
compileOptions {
|
compileOptions {
|
||||||
sourceCompatibility JavaVersion.VERSION_1_7
|
sourceCompatibility JavaVersion.VERSION_1_7
|
||||||
|
@ -110,7 +110,7 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>io.swagger</groupId>
|
<groupId>io.swagger</groupId>
|
||||||
<artifactId>swagger-annotations</artifactId>
|
<artifactId>swagger-annotations</artifactId>
|
||||||
<version>${swagger-annotations-version}</version>
|
<version>${swagger-core-version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.squareup.retrofit</groupId>
|
<groupId>com.squareup.retrofit</groupId>
|
||||||
@ -137,7 +137,7 @@
|
|||||||
</dependency>
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
<properties>
|
<properties>
|
||||||
<swagger-annotations-version>1.5.0</swagger-annotations-version>
|
<swagger-core-version>1.5.8</swagger-core-version>
|
||||||
<retrofit-version>1.9.0</retrofit-version>
|
<retrofit-version>1.9.0</retrofit-version>
|
||||||
<okhttp-version>2.4.0</okhttp-version>
|
<okhttp-version>2.4.0</okhttp-version>
|
||||||
<oltu-version>1.0.0</oltu-version>
|
<oltu-version>1.0.0</oltu-version>
|
||||||
|
@ -9,8 +9,8 @@ buildscript {
|
|||||||
jcenter()
|
jcenter()
|
||||||
}
|
}
|
||||||
dependencies {
|
dependencies {
|
||||||
classpath 'com.android.tools.build:gradle:1.2.2'
|
classpath 'com.android.tools.build:gradle:1.5.+'
|
||||||
classpath 'com.github.dcendents:android-maven-plugin:1.2'
|
classpath 'com.github.dcendents:android-maven-gradle-plugin:1.3'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -25,11 +25,11 @@ if(hasProperty('target') && target == 'android') {
|
|||||||
apply plugin: 'com.github.dcendents.android-maven'
|
apply plugin: 'com.github.dcendents.android-maven'
|
||||||
|
|
||||||
android {
|
android {
|
||||||
compileSdkVersion 22
|
compileSdkVersion 23
|
||||||
buildToolsVersion '22.0.0'
|
buildToolsVersion '23.0.2'
|
||||||
defaultConfig {
|
defaultConfig {
|
||||||
minSdkVersion 14
|
minSdkVersion 14
|
||||||
targetSdkVersion 22
|
targetSdkVersion 23
|
||||||
}
|
}
|
||||||
compileOptions {
|
compileOptions {
|
||||||
sourceCompatibility JavaVersion.VERSION_1_7
|
sourceCompatibility JavaVersion.VERSION_1_7
|
||||||
@ -46,6 +46,10 @@ if(hasProperty('target') && target == 'android') {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
dependencies {
|
||||||
|
provided 'javax.annotation:jsr250-api:1.0'
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
afterEvaluate {
|
afterEvaluate {
|
||||||
|
@ -111,7 +111,7 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>io.swagger</groupId>
|
<groupId>io.swagger</groupId>
|
||||||
<artifactId>swagger-annotations</artifactId>
|
<artifactId>swagger-annotations</artifactId>
|
||||||
<version>${swagger-annotations-version}</version>
|
<version>${swagger-core-version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.squareup.retrofit2</groupId>
|
<groupId>com.squareup.retrofit2</groupId>
|
||||||
@ -153,7 +153,7 @@
|
|||||||
</dependency>
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
<properties>
|
<properties>
|
||||||
<swagger-annotations-version>1.5.0</swagger-annotations-version>
|
<swagger-core-version>1.5.8</swagger-core-version>
|
||||||
<retrofit-version>2.0.0-beta4</retrofit-version>{{#useRxJava}}
|
<retrofit-version>2.0.0-beta4</retrofit-version>{{#useRxJava}}
|
||||||
<rxjava-version>1.0.16</rxjava-version>{{/useRxJava}}
|
<rxjava-version>1.0.16</rxjava-version>{{/useRxJava}}
|
||||||
<oltu-version>1.0.0</oltu-version>
|
<oltu-version>1.0.0</oltu-version>
|
||||||
|
@ -171,11 +171,11 @@
|
|||||||
</dependencies>
|
</dependencies>
|
||||||
<properties>
|
<properties>
|
||||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||||
<swagger-annotations-version>1.5.4</swagger-annotations-version>
|
<swagger-annotations-version>1.5.8</swagger-annotations-version>
|
||||||
<jersey-version>1.18</jersey-version>
|
<jersey-version>1.18</jersey-version>
|
||||||
<jackson-version>2.4.2</jackson-version>
|
<jackson-version>2.4.2</jackson-version>
|
||||||
<jodatime-version>2.3</jodatime-version>
|
<jodatime-version>2.3</jodatime-version>
|
||||||
<maven-plugin-version>1.0.0</maven-plugin-version>
|
<maven-plugin-version>1.0.0</maven-plugin-version>
|
||||||
<junit-version>4.8.1</junit-version>
|
<junit-version>4.12</junit-version>
|
||||||
</properties>
|
</properties>
|
||||||
</project>
|
</project>
|
||||||
|
@ -111,7 +111,7 @@
|
|||||||
</repositories>
|
</repositories>
|
||||||
<properties>
|
<properties>
|
||||||
<maven-plugin-version>1.0.0</maven-plugin-version>
|
<maven-plugin-version>1.0.0</maven-plugin-version>
|
||||||
<swagger-inflector-version>1.0.4-SNAPSHOT</swagger-inflector-version>
|
<swagger-inflector-version>1.0.4</swagger-inflector-version>
|
||||||
<jetty-version>9.2.9.v20150224</jetty-version>
|
<jetty-version>9.2.9.v20150224</jetty-version>
|
||||||
<logback-version>1.0.1</logback-version>
|
<logback-version>1.0.1</logback-version>
|
||||||
<junit-version>4.8.2</junit-version>
|
<junit-version>4.8.2</junit-version>
|
||||||
|
@ -46,10 +46,10 @@ public class {{classname}} {
|
|||||||
{{/hasMore}}{{/authMethods}}
|
{{/hasMore}}{{/authMethods}}
|
||||||
}{{/hasAuthMethods}}, tags={ {{#vendorExtensions.x-tags}}"{{tag}}"{{#hasMore}}, {{/hasMore}}{{/vendorExtensions.x-tags}} })
|
}{{/hasAuthMethods}}, tags={ {{#vendorExtensions.x-tags}}"{{tag}}"{{#hasMore}}, {{/hasMore}}{{/vendorExtensions.x-tags}} })
|
||||||
@io.swagger.annotations.ApiResponses(value = { {{#responses}}
|
@io.swagger.annotations.ApiResponses(value = { {{#responses}}
|
||||||
@io.swagger.annotations.ApiResponse(code = {{{code}}}, message = "{{{message}}}", response = {{{returnType}}}.class{{#returnContainer}}, responseContainer = "{{{returnContainer}}}"{{/returnContainer}}){{#hasMore}},
|
@io.swagger.annotations.ApiResponse(code = {{{code}}}, message = "{{{message}}}", response = {{{returnType}}}.class{{#returnContainer}}, responseContainer = "{{{returnContainer}}}"{{/returnContainer}}){{#hasMore}},{{/hasMore}}{{/responses}} })
|
||||||
{{/hasMore}}{{/responses}} })
|
public Response {{nickname}}(
|
||||||
|
{{#allParams}}{{>queryParams}}{{>pathParams}}{{>headerParams}}{{>bodyParams}}{{>formParams}},
|
||||||
public Response {{nickname}}({{#allParams}}{{>queryParams}}{{>pathParams}}{{>headerParams}}{{>bodyParams}}{{>formParams}},{{/allParams}}@Context SecurityContext securityContext)
|
{{/allParams}}@Context SecurityContext securityContext)
|
||||||
throws NotFoundException {
|
throws NotFoundException {
|
||||||
return delegate.{{nickname}}({{#allParams}}{{#isFile}}inputStream, fileDetail{{/isFile}}{{^isFile}}{{paramName}}{{/isFile}},{{/allParams}}securityContext);
|
return delegate.{{nickname}}({{#allParams}}{{#isFile}}inputStream, fileDetail{{/isFile}}{{^isFile}}{{paramName}}{{/isFile}},{{/allParams}}securityContext);
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,31 @@
|
|||||||
|
package {{apiPackage}};
|
||||||
|
|
||||||
|
import io.swagger.jaxrs.config.SwaggerContextService;
|
||||||
|
import io.swagger.models.*;
|
||||||
|
|
||||||
|
import io.swagger.models.auth.*;
|
||||||
|
|
||||||
|
import javax.servlet.http.HttpServlet;
|
||||||
|
import javax.servlet.ServletContext;
|
||||||
|
import javax.servlet.ServletConfig;
|
||||||
|
import javax.servlet.ServletException;
|
||||||
|
|
||||||
|
public class Bootstrap extends HttpServlet {
|
||||||
|
@Override
|
||||||
|
public void init(ServletConfig config) throws ServletException {
|
||||||
|
Info info = new Info()
|
||||||
|
.title("{{title}}")
|
||||||
|
.description("{{{appDescription}}}")
|
||||||
|
.termsOfService("{{termsOfService}}")
|
||||||
|
.contact(new Contact()
|
||||||
|
.email("{{infoEmail}}"))
|
||||||
|
.license(new License()
|
||||||
|
.name("{{licenseInfo}}")
|
||||||
|
.url("{{licenseUrl}}"));
|
||||||
|
|
||||||
|
ServletContext context = config.getServletContext();
|
||||||
|
Swagger swagger = new Swagger().info(info);
|
||||||
|
|
||||||
|
new SwaggerContextService().withServletConfig(config).updateSwagger(swagger);
|
||||||
|
}
|
||||||
|
}
|
@ -1,2 +1,2 @@
|
|||||||
{{#isFormParam}}{{#notFile}}@ApiParam(value = "{{{description}}}"{{#required}}, required=true{{/required}}{{#allowableValues}}, {{> allowableValues }}{{/allowableValues}}{{#defaultValue}}, defaultValue="{{{defaultValue}}}"{{/defaultValue}})@FormParam("{{paramName}}") {{{dataType}}} {{paramName}}{{/notFile}}{{#isFile}} @FormDataParam("file") InputStream inputStream,
|
{{#isFormParam}}{{#notFile}}{{^vendorExtensions.x-multipart}}@ApiParam(value = "{{{description}}}"{{#required}}, required=true{{/required}}{{#allowableValues}}, {{> allowableValues }}{{/allowableValues}}{{#defaultValue}}, defaultValue="{{{defaultValue}}}"{{/defaultValue}}){{/vendorExtensions.x-multipart}}{{#vendorExtensions.x-multipart}}@FormDataParam("{{paramName}}") {{{dataType}}} {{paramName}}{{/vendorExtensions.x-multipart}}{{^vendorExtensions.x-multipart}}@FormParam("{{paramName}}") {{{dataType}}} {{paramName}}{{/vendorExtensions.x-multipart}}{{/notFile}}{{#isFile}}@FormDataParam("file") InputStream inputStream,
|
||||||
@FormDataParam("file") FormDataContentDisposition fileDetail{{/isFile}}{{/isFormParam}}
|
@FormDataParam("file") FormDataContentDisposition fileDetail{{/isFile}}{{/isFormParam}}
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user