forked from loafle/openapi-generator-original
Compare commits
173 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
371a021ef5 | ||
|
|
be3a49183e | ||
|
|
5f67ec021d | ||
|
|
d8cdcbf042 | ||
|
|
c147cfde1b | ||
|
|
e8095c6a04 | ||
|
|
c220dbb2f5 | ||
|
|
bef5c74da7 | ||
|
|
ab96b318e2 | ||
|
|
950fb43fdf | ||
|
|
1f58526615 | ||
|
|
148a842f3b | ||
|
|
b74c1b98a2 | ||
|
|
e6f6e66167 | ||
|
|
47738f6cd6 | ||
|
|
f82d4fa033 | ||
|
|
ce7a5682d5 | ||
|
|
125338a081 | ||
|
|
41ffc70d93 | ||
|
|
d76c7cc5e8 | ||
|
|
a2496df401 | ||
|
|
122af80881 | ||
|
|
89fe3403a7 | ||
|
|
5b4eb96ba1 | ||
|
|
670f103859 | ||
|
|
d5bf43b824 | ||
|
|
3238fd2853 | ||
|
|
0547f0d6d8 | ||
|
|
3dc31ced8e | ||
|
|
7d8c9dc40a | ||
|
|
81f981c54d | ||
|
|
26c33d344d | ||
|
|
5103045246 | ||
|
|
3bd01b988e | ||
|
|
811b5940eb | ||
|
|
1fde95f997 | ||
|
|
25fa3e86f9 | ||
|
|
0b8acb5b0c | ||
|
|
24d8c621c2 | ||
|
|
bbe422947f | ||
|
|
ed9dea6a89 | ||
|
|
7bd37468bc | ||
|
|
390ec38ec7 | ||
|
|
1886abb9f9 | ||
|
|
ef526422e9 | ||
|
|
9cc4e1fee0 | ||
|
|
abd5b3f4de | ||
|
|
103cc7410b | ||
|
|
30776d75a9 | ||
|
|
f5e20b4e88 | ||
|
|
aacc235665 | ||
|
|
cfe8dfc112 | ||
|
|
df05295f40 | ||
|
|
61b86c74fb | ||
|
|
c6e6a6560a | ||
|
|
1bdd15c55c | ||
|
|
85c8eb3d76 | ||
|
|
4895a35200 | ||
|
|
8c357dd1d6 | ||
|
|
fa7bd21420 | ||
|
|
434b4fd359 | ||
|
|
0f8e1f8105 | ||
|
|
d7c959fe42 | ||
|
|
3d7ff26c67 | ||
|
|
2d491dce71 | ||
|
|
c91b004b0b | ||
|
|
75cd4bf437 | ||
|
|
7c1daab896 | ||
|
|
c377153336 | ||
|
|
aa58497247 | ||
|
|
293096f565 | ||
|
|
4e17221494 | ||
|
|
33b33cb384 | ||
|
|
a67f168fa6 | ||
|
|
b2cb215741 | ||
|
|
8d4cfcae78 | ||
|
|
46a222088e | ||
|
|
c8764fe0d0 | ||
|
|
3b4465d999 | ||
|
|
75403f1900 | ||
|
|
34137c703b | ||
|
|
3cd37bf5e9 | ||
|
|
c23b473636 | ||
|
|
748eaa849e | ||
|
|
0675f1686e | ||
|
|
154d0fc9de | ||
|
|
39228c7c94 | ||
|
|
0beb4aa303 | ||
|
|
743219aa08 | ||
|
|
81f5108bac | ||
|
|
2b66128954 | ||
|
|
b3403015fd | ||
|
|
9489f7d3eb | ||
|
|
30c2503f9f | ||
|
|
8184732da2 | ||
|
|
aaba4b9e82 | ||
|
|
52cfd0f86f | ||
|
|
bf17a91275 | ||
|
|
a1e7c517d3 | ||
|
|
55bf8b1f96 | ||
|
|
d5528e5d2a | ||
|
|
13ec3dc6bb | ||
|
|
f74bf84017 | ||
|
|
a916696f28 | ||
|
|
f6c523bcd6 | ||
|
|
c888434580 | ||
|
|
8818cf9ff4 | ||
|
|
bee6803bcb | ||
|
|
9c7710e695 | ||
|
|
dfe4944552 | ||
|
|
97855baf83 | ||
|
|
889549a352 | ||
|
|
269c657471 | ||
|
|
9fcb8a310d | ||
|
|
d16b761aaf | ||
|
|
7fbb499ad1 | ||
|
|
4f0b7dfaed | ||
|
|
ef857176a6 | ||
|
|
9e6896c8f0 | ||
|
|
72be69d2ed | ||
|
|
5001b54eca | ||
|
|
92e8efde1a | ||
|
|
41bab483e0 | ||
|
|
b8f6667f00 | ||
|
|
ca4a90d64d | ||
|
|
37404909bf | ||
|
|
118fd4d84d | ||
|
|
207622a8f8 | ||
|
|
d780e3a5f5 | ||
|
|
b9479ae8b7 | ||
|
|
60af9e7a83 | ||
|
|
77097ec76a | ||
|
|
323c778059 | ||
|
|
b3a6535d1e | ||
|
|
dc8eb8e8ad | ||
|
|
cd79ae1ab4 | ||
|
|
87b79e5946 | ||
|
|
be65a26db0 | ||
|
|
3659767e0a | ||
|
|
34d3a5e8d0 | ||
|
|
5e4e84ffe7 | ||
|
|
421c462ba9 | ||
|
|
0d9878373c | ||
|
|
4da6ecf6a6 | ||
|
|
d4611e4645 | ||
|
|
f37bd4ab49 | ||
|
|
e73f2a5c64 | ||
|
|
749a17d292 | ||
|
|
e6f08df30c | ||
|
|
07d2e7245e | ||
|
|
e077e80dcb | ||
|
|
39cb6a24db | ||
|
|
d120902e4b | ||
|
|
9056a5a56c | ||
|
|
cb547c113a | ||
|
|
fab499e612 | ||
|
|
4d9b5feb77 | ||
|
|
fb68c6c93d | ||
|
|
f14f4c1e93 | ||
|
|
83e7cdb6a3 | ||
|
|
a4c589c346 | ||
|
|
e6803aed97 | ||
|
|
bf8e1ade56 | ||
|
|
1ea80ab83a | ||
|
|
836aed999e | ||
|
|
43d1c5bffc | ||
|
|
4c1c009bd1 | ||
|
|
ae67961f60 | ||
|
|
cd6a805910 | ||
|
|
e258fb97ca | ||
|
|
0259c45b7a | ||
|
|
0c7bb8b2ca | ||
|
|
6002a983c3 |
2
.gitignore
vendored
2
.gitignore
vendored
@@ -56,6 +56,8 @@ samples/client/petstore/qt5cpp/PetStore/Makefile
|
||||
#Java/Android
|
||||
**/.gradle
|
||||
samples/client/petstore/java/hello.txt
|
||||
samples/client/petstore/java/okhttp-gson/hello.txt
|
||||
samples/client/petstore/java/jersey2-java8/hello.txt
|
||||
samples/client/petstore/android/default/hello.txt
|
||||
samples/client/petstore/android/volley/.gradle/
|
||||
samples/client/petstore/android/volley/build/
|
||||
|
||||
17
.travis.yml
17
.travis.yml
@@ -4,16 +4,33 @@ jdk:
|
||||
- oraclejdk7
|
||||
- oraclejdk8
|
||||
|
||||
cache:
|
||||
directories:
|
||||
- $HOME/.m2
|
||||
|
||||
services:
|
||||
- docker
|
||||
|
||||
addons:
|
||||
hosts:
|
||||
- petstore.swagger.io
|
||||
|
||||
before_install:
|
||||
# required when sudo: required for the Ruby petstore tests
|
||||
- gem install bundler
|
||||
- npm install -g typescript
|
||||
- sudo pip install virtualenv
|
||||
# to run petstore server locally via docker
|
||||
- docker pull swaggerapi/petstore
|
||||
- docker run -d -e SWAGGER_HOST=http://petstore.swagger.io -e SWAGGER_BASE_PATH=/v2 -p 80:8080 swaggerapi/petstore
|
||||
- docker ps -a
|
||||
# show host table to confirm petstore.swagger.io is mapped to localhost
|
||||
- cat /etc/hosts
|
||||
|
||||
install:
|
||||
# Add Godeps dependencies to GOPATH and PATH
|
||||
- export GOPATH="${TRAVIS_BUILD_DIR}/Godeps/_workspace"
|
||||
- export PATH="${TRAVIS_BUILD_DIR}/Godeps/_workspace/bin:$PATH"
|
||||
|
||||
script:
|
||||
- mvn verify -Psamples
|
||||
|
||||
28
README.md
28
README.md
@@ -1,9 +1,10 @@
|
||||
# Swagger Code Generator
|
||||
|
||||
[](https://travis-ci.org/swagger-api/swagger-codegen)
|
||||
[](https://travis-ci.org/swagger-api/swagger-codegen)
|
||||
[](https://app.shippable.com/projects/5782588a3be4f4faa56c5bea)
|
||||
[](https://ci.appveyor.com/project/WilliamCheng/swagger-codegen-wh2wu)
|
||||
[](https://maven-badges.herokuapp.com/maven-central/io.swagger/swagger-codegen-project)
|
||||
[](http://issuestats.com/github/swagger-api/swagger-codegen) [](http://issuestats.com/github/swagger-api/swagger-codegen)
|
||||
[](https://ci.appveyor.com/project/WilliamCheng/swagger-codegen-wh2wu)
|
||||
|
||||
: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:
|
||||
|
||||
@@ -59,8 +60,10 @@ The OpenAPI Specification has undergone 3 revisions since initial creation in 20
|
||||
|
||||
Swagger Codegen Version | Release Date | OpenAPI Spec compatibility | Notes
|
||||
-------------------------- | ------------ | -------------------------- | -----
|
||||
2.2.0 | 2016-07-15 | 1.0, 1.1, 1.2, 2.0 | [tag v2.2.0](https://github.com/swagger-api/swagger-codegen/tree/v2.2.0)
|
||||
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.3.0 (upcoming minor release) | TBD | 1.0, 1.1, 1.2, 2.0 | Minor release with breaking changes
|
||||
2.2.1 (upcoming patch release) | TBD | 1.0, 1.1, 1.2, 2.0 | Patch release with non-breaking changes
|
||||
2.2.0 (**current stable**) | 2016-07-15 | 1.0, 1.1, 1.2, 2.0 | [tag v2.2.0](https://github.com/swagger-api/swagger-codegen/tree/v2.2.0)
|
||||
2.1.6 | 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)
|
||||
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)
|
||||
|
||||
@@ -69,7 +72,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):
|
||||
|
||||
```
|
||||
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
|
||||
wget http://repo1.maven.org/maven2/io/swagger/swagger-codegen-cli/2.2.0/swagger-codegen-cli-2.2.0.jar -O swagger-codegen-cli.jar
|
||||
|
||||
java -jar swagger-codegen-cli.jar help
|
||||
```
|
||||
@@ -148,7 +151,7 @@ java -jar modules/swagger-codegen-cli/target/swagger-codegen-cli.jar generate \
|
||||
```
|
||||
(if you're on Windows, replace the last command with `java -jar modules\swagger-codegen-cli\target\swagger-codegen-cli.jar generate -i http://petstore.swagger.io/v2/swagger.json -l php -o c:\temp\php_api_client`)
|
||||
|
||||
You can also download the JAR (latest relesae) directly from [maven.org]( http://central.maven.org/maven2/io/swagger/swagger-codegen/2.1.6/swagger-codegen-2.1.6.jar)
|
||||
You can also download the JAR (latest relesae) directly from [maven.org]( http://central.maven.org/maven2/io/swagger/swagger-codegen/2.2.0/swagger-codegen-2.2.0.jar)
|
||||
|
||||
To get a list of **general** options available, please run `java -jar modules/swagger-codegen-cli/target/swagger-codegen-cli.jar help generate`
|
||||
|
||||
@@ -751,7 +754,8 @@ Here are some companies/projects using Swagger Codegen in production. To add you
|
||||
- [CloudBoost](https://www.CloudBoost.io/)
|
||||
- [Conplement](http://www.conplement.de/)
|
||||
- [Cupix](http://www.cupix.com)
|
||||
- [DBBest Technologies](https://www.dbbest.com)
|
||||
- [DBBest Technologies](https://www.dbbest.com)
|
||||
- [DecentFoX](http://decentfox.com/)
|
||||
- [DocuSign](https://www.docusign.com)
|
||||
- [Ergon](http://www.ergon.ch/)
|
||||
- [eureka](http://eure.jp/)
|
||||
@@ -760,6 +764,7 @@ Here are some companies/projects using Swagger Codegen in production. To add you
|
||||
- [Finder](http://en.finder.pl/)
|
||||
- [FH Münster - University of Applied Sciences](http://www.fh-muenster.de)
|
||||
- [Gear Zero Network](https://www.gearzero.ca)
|
||||
- [Germin8](http://www.germin8.com)
|
||||
- [GraphHopper](https://graphhopper.com/)
|
||||
- [Gravitate Solutions](http://gravitatesolutions.com/)
|
||||
- [IMS Health](http://www.imshealth.com/en/solution-areas/technology-and-applications)
|
||||
@@ -784,6 +789,7 @@ Here are some companies/projects using Swagger Codegen in production. To add you
|
||||
- [Revault Sàrl](http://revault.ch)
|
||||
- [Royal Bank of Canada (RBC)](http://www.rbc.com/canada.html)
|
||||
- [SCOOP Software GmbH](http://www.scoop-software.de)
|
||||
- [Skurt](http://www.skurt.com)
|
||||
- [SmartRecruiters](https://www.smartrecruiters.com/)
|
||||
- [StyleRecipe](http://stylerecipe.co.jp)
|
||||
- [Svenska Spel AB](https://www.svenskaspel.se/)
|
||||
@@ -810,6 +816,7 @@ Swaagger Codegen core team members are contributors who have been making signfic
|
||||
| Groovy | |
|
||||
| Go | @guohuang (2016/05/01) @neilotoole (2016/05/01) |
|
||||
| Java | @cbornet (2016/05/01) @xhh (2016/05/01) @epaul (2016/06/04) |
|
||||
| Java (Spring Cloud) | @cbornet (2016/07/19) |
|
||||
| NodeJS/Javascript | @xhh (2016/05/01) |
|
||||
| ObjC | @mateuszmackowiak (2016/05/09) |
|
||||
| Perl | @wing328 (2016/05/01) |
|
||||
@@ -828,8 +835,8 @@ Swaagger Codegen core team members are contributors who have been making signfic
|
||||
| C# ASP.NET5 | @jimschubert (2016/05/01) |
|
||||
| Go Server | @guohuang (2016/06/13) |
|
||||
| Haskell Servant | |
|
||||
| Java Spring Boot | |
|
||||
| Java SpringMVC | @kolyjjj (2016/05/01) |
|
||||
| Java Spring Boot | @cbornet (2016/07/19) |
|
||||
| Java Spring MVC | @kolyjjj (2016/05/01) @cbornet (2016/07/19) |
|
||||
| Java JAX-RS | |
|
||||
| NancyFX | |
|
||||
| NodeJS | @kolyjjj (2016/05/01) |
|
||||
@@ -873,6 +880,9 @@ Here is a list of template creators:
|
||||
* PHP Lumen: @abcsum
|
||||
* PHP Slim: @jfastnacht
|
||||
* Ruby on Rails 5: @zlx
|
||||
* Documentation
|
||||
* HTML Doc 2: @jhitchcock
|
||||
* Confluence Wiki: @jhitchcock
|
||||
|
||||
## How to join the core team
|
||||
|
||||
|
||||
11
appveyor.yml
11
appveyor.yml
@@ -1,7 +1,9 @@
|
||||
# for CI with appveyor.yml
|
||||
# Ref: http://www.yegor256.com/2015/01/10/windows-appveyor-maven.html
|
||||
version: '{build}'
|
||||
version: '{branch}-{build}'
|
||||
os: Windows Server 2012
|
||||
hosts:
|
||||
petstore.swagger.io: 127.0.0.1
|
||||
install:
|
||||
- ps: |
|
||||
Add-Type -AssemblyName System.IO.Compression.FileSystem
|
||||
@@ -15,9 +17,16 @@ install:
|
||||
- cmd: SET PATH=C:\maven\apache-maven-3.2.5\bin;%JAVA_HOME%\bin;%PATH%
|
||||
- cmd: SET MAVEN_OPTS=-XX:MaxPermSize=2g -Xmx4g
|
||||
- cmd: SET JAVA_OPTS=-XX:MaxPermSize=2g -Xmx4g
|
||||
- git clone https://github.com/wing328/swagger-samples
|
||||
- ps: Start-Process -FilePath 'C:\maven\apache-maven-3.2.5\bin\mvn' -ArgumentList 'jetty:run' -WorkingDirectory "$env:appveyor_build_folder\swagger-samples\java\java-jersey-jaxrs"
|
||||
build_script:
|
||||
- nuget restore samples\client\petstore\csharp\SwaggerClient\IO.Swagger.sln
|
||||
- msbuild samples\client\petstore\csharp\SwaggerClient\IO.Swagger.sln /logger:"C:\Program Files\AppVeyor\BuildAgent\Appveyor.MSBuildLogger.dll"
|
||||
- mvn clean install --batch-mode
|
||||
test_script:
|
||||
# test c# API client
|
||||
- nunit-console samples\client\petstore\csharp\SwaggerClient\src\IO.Swagger.Test\bin\Debug\IO.Swagger.Test.dll --result=myresults.xml;format=AppVeyor
|
||||
# generate all petstore clients
|
||||
- .\bin\windows\run-all-petstore.cmd
|
||||
cache:
|
||||
- C:\maven\
|
||||
|
||||
31
bin/cwiki-petstore.sh
Executable file
31
bin/cwiki-petstore.sh
Executable file
@@ -0,0 +1,31 @@
|
||||
#!/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/petstore.yaml -l cwiki -o samples/documentation/cwiki"
|
||||
|
||||
java $JAVA_OPTS -jar $executable $ags
|
||||
@@ -26,9 +26,16 @@ 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/petstore.yaml -l dart -o samples/client/petstore/dart"
|
||||
|
||||
# for dart vm lib generation:
|
||||
#ags="$@ generate -i modules/swagger-codegen/src/test/resources/2_0/petstore.yaml -l dart -o samples/client/petstore/dart --additional-properties browserClient=false"
|
||||
ags="$@ generate -i modules/swagger-codegen/src/test/resources/2_0/petstore.yaml -l dart -o samples/client/petstore/dart/swagger"
|
||||
|
||||
# then options to generate the library for vm would be:
|
||||
#ags="$@ generate -i modules/swagger-codegen/src/test/resources/2_0/petstore.yaml -l dart -o samples/client/petstore/dart/swagger_vm -DbrowserClient=false -DpubName=swagger_vm"
|
||||
java $JAVA_OPTS -jar $executable $ags
|
||||
|
||||
# There is a proposal to allow importing different libraries depending on the environment:
|
||||
# https://github.com/munificent/dep-interface-libraries
|
||||
# When this is implemented there will only be one library.
|
||||
|
||||
# The current petstore test will then work for both: the browser library and the vm library.
|
||||
|
||||
|
||||
@@ -26,7 +26,7 @@ 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/petstore-with-fake-endpoints-models-for-testing.yaml -l java -o samples/client/petstore/java/jersey1 -DhideGenerationTimestamp=true --library=jersey1"
|
||||
ags="$@ generate -t modules/swagger-codegen/src/main/resources/Java -i modules/swagger-codegen/src/test/resources/2_0/petstore-with-fake-endpoints-models-for-testing.yaml -l java -o samples/client/petstore/java/jersey1 -DhideGenerationTimestamp=true --library=jersey1"
|
||||
|
||||
echo "Removing files and folders under samples/client/petstore/java/jersey1/src/main"
|
||||
rm -rf samples/client/petstore/java/jersey1/src/main
|
||||
|
||||
@@ -26,7 +26,7 @@ fi
|
||||
|
||||
# if you've executed sbt assembly previously it will use that instead.
|
||||
export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties"
|
||||
ags="$@ generate -t modules/swagger-codegen/src/main/resources/JavaJaxRS -i modules/swagger-codegen/src/test/resources/2_0/petstore.yaml -l jaxrs -o samples/server/petstore/jaxrs/jersey2 -DhideGenerationTimestamp=true"
|
||||
ags="$@ generate -t modules/swagger-codegen/src/main/resources/JavaJaxRS -i modules/swagger-codegen/src/test/resources/2_0/petstore-with-fake-endpoints-models-for-testing.yaml -l jaxrs -o samples/server/petstore/jaxrs/jersey2 -DhideGenerationTimestamp=true"
|
||||
|
||||
echo "Removing files and folders under samples/server/petstore/jaxrs/jersey2/src/main"
|
||||
rm -rf samples/server/petstore/jaxrs/jersey2/src/main
|
||||
|
||||
31
bin/nancyfx-petstore-server.sh
Executable file
31
bin/nancyfx-petstore-server.sh
Executable file
@@ -0,0 +1,31 @@
|
||||
#!/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 -t modules/swagger-codegen/src/main/resources/nancyfx -i modules/swagger-codegen/src/test/resources/2_0/petstore.yaml -l nancyfx -o samples/server/petstore/nancyfx"
|
||||
|
||||
java $JAVA_OPTS -jar $executable $ags
|
||||
8
bin/objc-petstore-all.sh
Executable file
8
bin/objc-petstore-all.sh
Executable file
@@ -0,0 +1,8 @@
|
||||
#!/bin/sh
|
||||
|
||||
# default setting
|
||||
./bin/objc-petstore.sh
|
||||
|
||||
# coredata support
|
||||
./bin/objc-petstore-coredata.sh
|
||||
|
||||
7
bin/spring-all-pestore.sh
Executable file
7
bin/spring-all-pestore.sh
Executable file
@@ -0,0 +1,7 @@
|
||||
#!/bin/sh
|
||||
|
||||
./bin/spring-cloud-feign-petstore.sh
|
||||
./bin/spring-stubs.sh
|
||||
./bin/spring-mvc-petstore-j8-async-server.sh
|
||||
./bin/springboot-petstore-server.sh
|
||||
./bin/spring-mvc-petstore-server.sh
|
||||
@@ -5,6 +5,6 @@ If Not Exist %executable% (
|
||||
)
|
||||
|
||||
REM set JAVA_OPTS=%JAVA_OPTS% -Xmx1024M -DloggerPath=conf/log4j.properties
|
||||
set ags=generate -i modules\swagger-codegen\src\test\resources\2_0\petstore.json -l nancyfx -o samples\server\petstore\nancyfx\
|
||||
set ags=generate -i modules\swagger-codegen\src\test\resources\2_0\petstore.yaml -l nancyfx -o samples\server\petstore\nancyfx\
|
||||
|
||||
java %JAVA_OPTS% -jar %executable% %ags%
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<parent>
|
||||
<groupId>io.swagger</groupId>
|
||||
<artifactId>swagger-codegen-project</artifactId>
|
||||
<version>2.2.0</version>
|
||||
<version>2.2.1</version>
|
||||
<relativePath>../..</relativePath>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
<parent>
|
||||
<groupId>io.swagger</groupId>
|
||||
<artifactId>swagger-codegen-project</artifactId>
|
||||
<version>2.2.0</version>
|
||||
<version>2.2.1</version>
|
||||
<relativePath>../..</relativePath>
|
||||
</parent>
|
||||
<artifactId>swagger-codegen-maven-plugin</artifactId>
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<parent>
|
||||
<groupId>io.swagger</groupId>
|
||||
<artifactId>swagger-codegen-project</artifactId>
|
||||
<version>2.2.0</version>
|
||||
<version>2.2.1</version>
|
||||
<relativePath>../..</relativePath>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
@@ -25,17 +25,17 @@
|
||||
<extension>
|
||||
<groupId>org.jvnet.wagon-svn</groupId>
|
||||
<artifactId>wagon-svn</artifactId>
|
||||
<version>1.8</version>
|
||||
<version>1.12</version>
|
||||
</extension>
|
||||
<extension>
|
||||
<groupId>org.apache.maven.wagon</groupId>
|
||||
<artifactId>wagon-ssh-external</artifactId>
|
||||
<version>1.0-alpha-6</version>
|
||||
<version>2.10</version>
|
||||
</extension>
|
||||
<extension>
|
||||
<groupId>org.apache.maven.wagon</groupId>
|
||||
<artifactId>wagon-webdav</artifactId>
|
||||
<version>1.0-beta-1</version>
|
||||
<version>1.0-beta-2</version>
|
||||
</extension>
|
||||
</extensions>
|
||||
<directory>target</directory>
|
||||
@@ -44,7 +44,7 @@
|
||||
<plugin>
|
||||
<groupId>org.codehaus.mojo</groupId>
|
||||
<artifactId>exec-maven-plugin</artifactId>
|
||||
<version>1.3.2</version>
|
||||
<version>1.5.0</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<goals>
|
||||
@@ -72,16 +72,16 @@
|
||||
</plugin>
|
||||
<plugin>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<version>3.0</version>
|
||||
<version>3.5.1</version>
|
||||
<configuration>
|
||||
<source>1.6</source>
|
||||
<target>1.6</target>
|
||||
<source>1.7</source>
|
||||
<target>1.7</target>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-jar-plugin</artifactId>
|
||||
<version>2.4</version>
|
||||
<version>3.0.2</version>
|
||||
<configuration>
|
||||
<archive>
|
||||
<manifestEntries>
|
||||
@@ -92,21 +92,6 @@
|
||||
</manifestEntries>
|
||||
</archive>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-site-plugin</artifactId>
|
||||
<version>2.1</version>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-release-plugin</artifactId>
|
||||
<!-- <version>2.1</version> -->
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-jar-plugin</artifactId>
|
||||
<version>2.6</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<goals>
|
||||
@@ -117,11 +102,13 @@
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<configuration>
|
||||
<source>1.7</source>
|
||||
<target>1.7</target>
|
||||
</configuration>
|
||||
<artifactId>maven-site-plugin</artifactId>
|
||||
<version>3.5.1</version>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-release-plugin</artifactId>
|
||||
<version>2.5.3</version>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
@@ -166,7 +153,7 @@
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-javadoc-plugin</artifactId>
|
||||
<version>2.9</version>
|
||||
<version>2.10.4</version>
|
||||
<configuration>
|
||||
<aggregate>true</aggregate>
|
||||
<debug>true</debug>
|
||||
@@ -180,7 +167,7 @@
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-jxr-plugin</artifactId>
|
||||
<version>2.3</version>
|
||||
<version>2.5</version>
|
||||
<configuration>
|
||||
<aggregate>true</aggregate>
|
||||
</configuration>
|
||||
@@ -188,7 +175,7 @@
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-project-info-reports-plugin</artifactId>
|
||||
<version>2.6</version>
|
||||
<version>2.9</version>
|
||||
<reportSets>
|
||||
<reportSet>
|
||||
<reports>
|
||||
@@ -200,7 +187,7 @@
|
||||
</plugins>
|
||||
</reporting>
|
||||
<properties>
|
||||
<diffutils-version>1.2.1</diffutils-version>
|
||||
<diffutils-version>1.3.0</diffutils-version>
|
||||
</properties>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
|
||||
@@ -46,6 +46,8 @@ public class CodegenProperty implements Cloneable {
|
||||
public Boolean hasValidation; // true if pattern, maximum, etc are set (only used in the mustache template)
|
||||
public Boolean isInherited;
|
||||
public String nameInCamelCase; // property name in camel case
|
||||
// enum name based on the property name, usually use as a prefix (e.g. VAR_NAME) for enum name (e.g. VAR_NAME_VALUE1)
|
||||
public String enumName;
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
@@ -111,6 +113,7 @@ public class CodegenProperty implements Cloneable {
|
||||
result = prime * result + ((isListContainer == null) ? 0 : isListContainer.hashCode());
|
||||
result = prime * result + Objects.hashCode(isInherited);
|
||||
result = prime * result + Objects.hashCode(nameInCamelCase);
|
||||
result = prime * result + Objects.hashCode(enumName);
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -271,6 +274,9 @@ public class CodegenProperty implements Cloneable {
|
||||
if (!Objects.equals(this.nameInCamelCase, other.nameInCamelCase)) {
|
||||
return false;
|
||||
}
|
||||
if (!Objects.equals(this.enumName, other.enumName)) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -106,7 +106,7 @@ public class DefaultCodegen {
|
||||
// How to encode special characters like $
|
||||
// They are translated to words like "Dollar" and prefixed with '
|
||||
// Then translated back during JSON encoding and decoding
|
||||
protected Map<Character, String> specialCharReplacements = new HashMap<Character, String>();
|
||||
protected Map<String, String> specialCharReplacements = new HashMap<String, String>();
|
||||
|
||||
public List<CliOption> cliOptions() {
|
||||
return cliOptions;
|
||||
@@ -789,21 +789,37 @@ public class DefaultCodegen {
|
||||
*/
|
||||
protected void initalizeSpecialCharacterMapping() {
|
||||
// Initialize special characters
|
||||
specialCharReplacements.put('$', "Dollar");
|
||||
specialCharReplacements.put('^', "Caret");
|
||||
specialCharReplacements.put('|', "Pipe");
|
||||
specialCharReplacements.put('=', "Equal");
|
||||
specialCharReplacements.put('*', "Star");
|
||||
specialCharReplacements.put('-', "Minus");
|
||||
specialCharReplacements.put('&', "Ampersand");
|
||||
specialCharReplacements.put('%', "Percent");
|
||||
specialCharReplacements.put('#', "Hash");
|
||||
specialCharReplacements.put('@', "At");
|
||||
specialCharReplacements.put('!', "Exclamation");
|
||||
specialCharReplacements.put('+', "Plus");
|
||||
specialCharReplacements.put(':', "Colon");
|
||||
specialCharReplacements.put('>', "GreaterThan");
|
||||
specialCharReplacements.put('<', "LessThan");
|
||||
specialCharReplacements.put("$", "Dollar");
|
||||
specialCharReplacements.put("^", "Caret");
|
||||
specialCharReplacements.put("|", "Pipe");
|
||||
specialCharReplacements.put("=", "Equal");
|
||||
specialCharReplacements.put("*", "Star");
|
||||
specialCharReplacements.put("-", "Minus");
|
||||
specialCharReplacements.put("&", "Ampersand");
|
||||
specialCharReplacements.put("%", "Percent");
|
||||
specialCharReplacements.put("#", "Hash");
|
||||
specialCharReplacements.put("@", "At");
|
||||
specialCharReplacements.put("!", "Exclamation");
|
||||
specialCharReplacements.put("+", "Plus");
|
||||
specialCharReplacements.put(":", "Colon");
|
||||
specialCharReplacements.put(">", "Greater_Than");
|
||||
specialCharReplacements.put("<", "Less_Than");
|
||||
specialCharReplacements.put(".", "Period");
|
||||
specialCharReplacements.put("_", "Underscore");
|
||||
|
||||
specialCharReplacements.put("<=", "Less_Than_Or_Equal_To");
|
||||
specialCharReplacements.put(">=", "Greater_Than_Or_Equal_To");
|
||||
specialCharReplacements.put("!=", "Not_Equal");
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the symbol name of a symbol
|
||||
*
|
||||
* @param input Symbol (e.g. $)
|
||||
* @return Symbol name (e.g. Dollar)
|
||||
*/
|
||||
protected String getSymbolName(String input) {
|
||||
return specialCharReplacements.get(input);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1334,7 +1350,7 @@ public class DefaultCodegen {
|
||||
|
||||
property.name = toVarName(name);
|
||||
property.baseName = name;
|
||||
property.nameInCamelCase = camelize(name, false);
|
||||
property.nameInCamelCase = camelize(property.name, false);
|
||||
property.description = escapeText(p.getDescription());
|
||||
property.unescapedDescription = p.getDescription();
|
||||
property.getter = "get" + getterAndSetterCapitalize(name);
|
||||
@@ -1559,6 +1575,7 @@ public class DefaultCodegen {
|
||||
// this can cause issues for clients which don't support enums
|
||||
if (property.isEnum) {
|
||||
property.datatypeWithEnum = toEnumName(property);
|
||||
property.enumName = toEnumName(property);
|
||||
} else {
|
||||
property.datatypeWithEnum = property.datatype;
|
||||
}
|
||||
@@ -1606,11 +1623,14 @@ public class DefaultCodegen {
|
||||
property.items = innerProperty;
|
||||
// inner item is Enum
|
||||
if (isPropertyInnerMostEnum(property)) {
|
||||
// isEnum is set to true when the type is an enum
|
||||
// or the inner type of an array/map is an enum
|
||||
property.isEnum = true;
|
||||
// update datatypeWithEnum and default value for array
|
||||
// e.g. List<string> => List<StatusEnum>
|
||||
updateDataTypeWithEnumForArray(property);
|
||||
|
||||
// set allowable values to enum values (including array/map of enum)
|
||||
property.allowableValues = getInnerEnumAllowableValues(property);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1633,10 +1653,14 @@ public class DefaultCodegen {
|
||||
property.items = innerProperty;
|
||||
// inner item is Enum
|
||||
if (isPropertyInnerMostEnum(property)) {
|
||||
// isEnum is set to true when the type is an enum
|
||||
// or the inner type of an array/map is an enum
|
||||
property.isEnum = true;
|
||||
// update datatypeWithEnum and default value for map
|
||||
// e.g. Dictionary<string, string> => Dictionary<string, StatusEnum>
|
||||
updateDataTypeWithEnumForMap(property);
|
||||
// set allowable values to enum values (including array/map of enum)
|
||||
property.allowableValues = getInnerEnumAllowableValues(property);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1657,6 +1681,17 @@ public class DefaultCodegen {
|
||||
return currentProperty.isEnum;
|
||||
}
|
||||
|
||||
protected Map<String, Object> getInnerEnumAllowableValues(CodegenProperty property) {
|
||||
CodegenProperty currentProperty = property;
|
||||
while (currentProperty != null && (Boolean.TRUE.equals(currentProperty.isMapContainer)
|
||||
|| Boolean.TRUE.equals(currentProperty.isListContainer))) {
|
||||
currentProperty = currentProperty.items;
|
||||
}
|
||||
|
||||
return currentProperty.allowableValues;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Update datatypeWithEnum for array container
|
||||
* @param property Codegen property
|
||||
@@ -1670,9 +1705,13 @@ public class DefaultCodegen {
|
||||
// set both datatype and datetypeWithEnum as only the inner type is enum
|
||||
property.datatypeWithEnum = property.datatypeWithEnum.replace(baseItem.baseType, toEnumName(baseItem));
|
||||
|
||||
// naming the enum with respect to the language enum naming convention
|
||||
// e.g. remove [], {} from array/map of enum
|
||||
property.enumName = toEnumName(property);
|
||||
|
||||
// set default value for variable with inner enum
|
||||
if (property.defaultValue != null) {
|
||||
property.defaultValue = property.defaultValue.replace(property.items.baseType, toEnumName(property.items));
|
||||
property.defaultValue = property.defaultValue.replace(baseItem.baseType, toEnumName(baseItem));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1689,6 +1728,10 @@ public class DefaultCodegen {
|
||||
// set both datatype and datetypeWithEnum as only the inner type is enum
|
||||
property.datatypeWithEnum = property.datatypeWithEnum.replace(", " + baseItem.baseType, ", " + toEnumName(baseItem));
|
||||
|
||||
// naming the enum with respect to the language enum naming convention
|
||||
// e.g. remove [], {} from array/map of enum
|
||||
property.enumName = toEnumName(property);
|
||||
|
||||
// set default value for variable with inner enum
|
||||
if (property.defaultValue != null) {
|
||||
property.defaultValue = property.defaultValue.replace(", " + property.items.baseType, ", " + toEnumName(property.items));
|
||||
|
||||
@@ -17,7 +17,7 @@ import org.slf4j.LoggerFactory;
|
||||
import java.io.*;
|
||||
import java.util.*;
|
||||
|
||||
import static org.apache.commons.lang3.StringUtils.isNotEmpty;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
public class DefaultGenerator extends AbstractGenerator implements Generator {
|
||||
protected Logger LOGGER = LoggerFactory.getLogger(DefaultGenerator.class);
|
||||
@@ -149,10 +149,16 @@ public class DefaultGenerator extends AbstractGenerator implements Generator {
|
||||
if (info.getVersion() != null) {
|
||||
config.additionalProperties().put("appVersion", config.escapeText(info.getVersion()));
|
||||
}
|
||||
if (info.getDescription() != null) {
|
||||
|
||||
if (StringUtils.isEmpty(info.getDescription())) {
|
||||
// set a default description if none if provided
|
||||
config.additionalProperties().put("appDescription",
|
||||
"No descripton provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen)");
|
||||
} else {
|
||||
config.additionalProperties().put("appDescription",
|
||||
config.escapeText(info.getDescription()));
|
||||
}
|
||||
|
||||
if (info.getContact() != null) {
|
||||
Contact contact = info.getContact();
|
||||
config.additionalProperties().put("infoUrl", config.escapeText(contact.getUrl()));
|
||||
@@ -274,6 +280,7 @@ public class DefaultGenerator extends AbstractGenerator implements Generator {
|
||||
try {
|
||||
//don't generate models that have an import mapping
|
||||
if(config.importMapping().containsKey(name)) {
|
||||
LOGGER.info("Model " + name + " not imported due to import mapping");
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -522,7 +529,7 @@ public class DefaultGenerator extends AbstractGenerator implements Generator {
|
||||
for (SupportingFile support : config.supportingFiles()) {
|
||||
try {
|
||||
String outputFolder = config.outputFolder();
|
||||
if (isNotEmpty(support.folder)) {
|
||||
if (StringUtils.isNotEmpty(support.folder)) {
|
||||
outputFolder += File.separator + support.folder;
|
||||
}
|
||||
File of = new File(outputFolder);
|
||||
|
||||
@@ -41,6 +41,9 @@ public abstract class AbstractCSharpCodegen extends DefaultCodegen implements Co
|
||||
public AbstractCSharpCodegen() {
|
||||
super();
|
||||
|
||||
// C# does not use import mapping
|
||||
importMapping.clear();
|
||||
|
||||
outputFolder = "generated-code" + File.separator + this.getName();
|
||||
embeddedTemplateDir = templateDir = this.getName();
|
||||
|
||||
|
||||
@@ -1,20 +1,43 @@
|
||||
package io.swagger.codegen.languages;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.ListIterator;
|
||||
import java.util.Map;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import org.apache.commons.lang3.BooleanUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
import com.google.common.base.Strings;
|
||||
import io.swagger.codegen.*;
|
||||
|
||||
import io.swagger.codegen.CliOption;
|
||||
import io.swagger.codegen.CodegenConfig;
|
||||
import io.swagger.codegen.CodegenConstants;
|
||||
import io.swagger.codegen.CodegenModel;
|
||||
import io.swagger.codegen.CodegenOperation;
|
||||
import io.swagger.codegen.CodegenParameter;
|
||||
import io.swagger.codegen.CodegenProperty;
|
||||
import io.swagger.codegen.DefaultCodegen;
|
||||
import io.swagger.models.Model;
|
||||
import io.swagger.models.Operation;
|
||||
import io.swagger.models.Path;
|
||||
import io.swagger.models.Swagger;
|
||||
import io.swagger.models.parameters.FormParameter;
|
||||
import io.swagger.models.parameters.Parameter;
|
||||
import io.swagger.models.properties.*;
|
||||
import org.apache.commons.lang3.BooleanUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.*;
|
||||
import java.util.regex.Pattern;
|
||||
import io.swagger.models.properties.ArrayProperty;
|
||||
import io.swagger.models.properties.BooleanProperty;
|
||||
import io.swagger.models.properties.DoubleProperty;
|
||||
import io.swagger.models.properties.FloatProperty;
|
||||
import io.swagger.models.properties.IntegerProperty;
|
||||
import io.swagger.models.properties.LongProperty;
|
||||
import io.swagger.models.properties.MapProperty;
|
||||
import io.swagger.models.properties.Property;
|
||||
import io.swagger.models.properties.StringProperty;
|
||||
|
||||
|
||||
public abstract class AbstractJavaCodegen extends DefaultCodegen implements CodegenConfig {
|
||||
@@ -43,6 +66,7 @@ public abstract class AbstractJavaCodegen extends DefaultCodegen implements Code
|
||||
|
||||
public AbstractJavaCodegen() {
|
||||
super();
|
||||
supportsInheritance = true;
|
||||
modelTemplateFiles.put("model.mustache", ".java");
|
||||
apiTemplateFiles.put("api.mustache", ".java");
|
||||
apiTestTemplateFiles.put("api_test.mustache", ".java");
|
||||
@@ -221,10 +245,14 @@ public abstract class AbstractJavaCodegen extends DefaultCodegen implements Code
|
||||
importMapping.put("ApiModelProperty", "io.swagger.annotations.ApiModelProperty");
|
||||
importMapping.put("ApiModel", "io.swagger.annotations.ApiModel");
|
||||
importMapping.put("JsonProperty", "com.fasterxml.jackson.annotation.JsonProperty");
|
||||
importMapping.put("JsonCreator", "com.fasterxml.jackson.annotation.JsonCreator");
|
||||
importMapping.put("JsonValue", "com.fasterxml.jackson.annotation.JsonValue");
|
||||
importMapping.put("SerializedName", "com.google.gson.annotations.SerializedName");
|
||||
importMapping.put("Objects", "java.util.Objects");
|
||||
importMapping.put("StringUtil", invokerPackage + ".StringUtil");
|
||||
// import JsonCreator if JsonProperty is imported
|
||||
// used later in recursive import in postProcessingModels
|
||||
importMapping.put("com.fasterxml.jackson.annotation.JsonProperty", "com.fasterxml.jackson.annotation.JsonCreator");
|
||||
|
||||
if(additionalProperties.containsKey(DATE_LIBRARY)) {
|
||||
setDateLibrary(additionalProperties.get("dateLibrary").toString());
|
||||
@@ -615,6 +643,23 @@ public abstract class AbstractJavaCodegen extends DefaultCodegen implements Code
|
||||
|
||||
@Override
|
||||
public Map<String, Object> postProcessModels(Map<String, Object> objs) {
|
||||
// recursivly add import for mapping one type to multipe imports
|
||||
List<Map<String, String>> recursiveImports = (List<Map<String, String>>) objs.get("imports");
|
||||
if (recursiveImports == null)
|
||||
return objs;
|
||||
|
||||
ListIterator<Map<String, String>> listIterator = recursiveImports.listIterator();
|
||||
while (listIterator.hasNext()) {
|
||||
String _import = listIterator.next().get("import");
|
||||
// if the import package happens to be found in the importMapping (key)
|
||||
// add the corresponding import package to the list
|
||||
if (importMapping.containsKey(_import)) {
|
||||
Map<String, String> newImportMap= new HashMap<String, String>();
|
||||
newImportMap.put("import", importMapping.get(_import));
|
||||
listIterator.add(newImportMap);
|
||||
}
|
||||
}
|
||||
|
||||
return postProcessModelsEnum(objs);
|
||||
}
|
||||
|
||||
@@ -706,6 +751,11 @@ public abstract class AbstractJavaCodegen extends DefaultCodegen implements Code
|
||||
|
||||
@Override
|
||||
public String toEnumVarName(String value, String datatype) {
|
||||
// for symbol, e.g. $, #
|
||||
if (getSymbolName(value) != null) {
|
||||
return getSymbolName(value).toUpperCase();
|
||||
}
|
||||
|
||||
// number
|
||||
if ("Integer".equals(datatype) || "Long".equals(datatype) ||
|
||||
"Float".equals(datatype) || "Double".equals(datatype)) {
|
||||
@@ -717,7 +767,7 @@ public abstract class AbstractJavaCodegen extends DefaultCodegen implements Code
|
||||
}
|
||||
|
||||
// string
|
||||
String var = value.replaceAll("\\W+", "_").replaceAll("_+", "_").toUpperCase();
|
||||
String var = value.replaceAll("\\W+", "_").toUpperCase();
|
||||
if (var.matches("\\d.*")) {
|
||||
return "_" + var;
|
||||
} else {
|
||||
|
||||
@@ -0,0 +1,641 @@
|
||||
package io.swagger.codegen.languages;
|
||||
|
||||
import io.swagger.codegen.CliOption;
|
||||
import io.swagger.codegen.CodegenConfig;
|
||||
import io.swagger.codegen.CodegenConstants;
|
||||
import io.swagger.codegen.CodegenOperation;
|
||||
import io.swagger.codegen.CodegenParameter;
|
||||
import io.swagger.codegen.CodegenProperty;
|
||||
import io.swagger.codegen.CodegenType;
|
||||
import io.swagger.codegen.DefaultCodegen;
|
||||
import io.swagger.codegen.SupportingFile;
|
||||
import io.swagger.models.properties.*;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.HashSet;
|
||||
import java.util.regex.Matcher;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
public abstract class AbstractPhpCodegen extends DefaultCodegen implements CodegenConfig {
|
||||
|
||||
static Logger LOGGER = LoggerFactory.getLogger(AbstractPhpCodegen.class);
|
||||
|
||||
public static final String VARIABLE_NAMING_CONVENTION = "variableNamingConvention";
|
||||
public static final String PACKAGE_PATH = "packagePath";
|
||||
public static final String SRC_BASE_PATH = "srcBasePath";
|
||||
// composerVendorName/composerProjectName has be replaced by gitUserId/gitRepoId. prepare to remove these.
|
||||
// public static final String COMPOSER_VENDOR_NAME = "composerVendorName";
|
||||
// public static final String COMPOSER_PROJECT_NAME = "composerProjectName";
|
||||
// protected String composerVendorName = null;
|
||||
// protected String composerProjectName = null;
|
||||
protected String invokerPackage = "php";
|
||||
protected String packagePath = "php-base";
|
||||
protected String artifactVersion = null;
|
||||
protected String srcBasePath = "lib";
|
||||
protected String testBasePath = "test";
|
||||
protected String docsBasePath = "docs";
|
||||
protected String apiDirName = "Api";
|
||||
protected String modelDirName = "Model";
|
||||
protected String variableNamingConvention= "snake_case";
|
||||
protected String apiDocPath = docsBasePath + "/" + apiDirName;
|
||||
protected String modelDocPath = docsBasePath + "/" + modelDirName;
|
||||
|
||||
public AbstractPhpCodegen() {
|
||||
super();
|
||||
|
||||
modelTemplateFiles.put("model.mustache", ".php");
|
||||
apiTemplateFiles.put("api.mustache", ".php");
|
||||
apiTestTemplateFiles.put("api_test.mustache", ".php");
|
||||
modelDocTemplateFiles.put("model_doc.mustache", ".md");
|
||||
apiDocTemplateFiles.put("api_doc.mustache", ".md");
|
||||
|
||||
apiPackage = invokerPackage + "\\" + apiDirName;
|
||||
modelPackage = invokerPackage + "\\" + modelDirName;
|
||||
|
||||
setReservedWordsLowerCase(
|
||||
Arrays.asList(
|
||||
// local variables used in api methods (endpoints)
|
||||
"resourcePath", "httpBody", "queryParams", "headerParams",
|
||||
"formParams", "_header_accept", "_tempBody",
|
||||
|
||||
// PHP reserved words
|
||||
"__halt_compiler", "abstract", "and", "array", "as", "break", "callable", "case", "catch", "class", "clone", "const", "continue", "declare", "default", "die", "do", "echo", "else", "elseif", "empty", "enddeclare", "endfor", "endforeach", "endif", "endswitch", "endwhile", "eval", "exit", "extends", "final", "for", "foreach", "function", "global", "goto", "if", "implements", "include", "include_once", "instanceof", "insteadof", "interface", "isset", "list", "namespace", "new", "or", "print", "private", "protected", "public", "require", "require_once", "return", "static", "switch", "throw", "trait", "try", "unset", "use", "var", "while", "xor")
|
||||
);
|
||||
|
||||
// ref: http://php.net/manual/en/language.types.intro.php
|
||||
languageSpecificPrimitives = new HashSet<String>(
|
||||
Arrays.asList(
|
||||
"bool",
|
||||
"boolean",
|
||||
"int",
|
||||
"integer",
|
||||
"double",
|
||||
"float",
|
||||
"string",
|
||||
"object",
|
||||
"DateTime",
|
||||
"mixed",
|
||||
"number",
|
||||
"void",
|
||||
"byte")
|
||||
);
|
||||
|
||||
instantiationTypes.put("array", "array");
|
||||
instantiationTypes.put("map", "map");
|
||||
|
||||
|
||||
// provide primitives to mustache template
|
||||
String primitives = "'" + StringUtils.join(languageSpecificPrimitives, "', '") + "'";
|
||||
additionalProperties.put("primitives", primitives);
|
||||
|
||||
// ref: https://github.com/OAI/OpenAPI-Specification/blob/master/versions/2.0.md#data-types
|
||||
typeMapping = new HashMap<String, String>();
|
||||
typeMapping.put("integer", "int");
|
||||
typeMapping.put("long", "int");
|
||||
typeMapping.put("number", "float");
|
||||
typeMapping.put("float", "float");
|
||||
typeMapping.put("double", "double");
|
||||
typeMapping.put("string", "string");
|
||||
typeMapping.put("byte", "int");
|
||||
typeMapping.put("boolean", "bool");
|
||||
typeMapping.put("Date", "\\DateTime");
|
||||
typeMapping.put("DateTime", "\\DateTime");
|
||||
typeMapping.put("file", "\\SplFileObject");
|
||||
typeMapping.put("map", "map");
|
||||
typeMapping.put("array", "array");
|
||||
typeMapping.put("list", "array");
|
||||
typeMapping.put("object", "object");
|
||||
typeMapping.put("binary", "string");
|
||||
typeMapping.put("ByteArray", "string");
|
||||
typeMapping.put("UUID", "string");
|
||||
|
||||
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(VARIABLE_NAMING_CONVENTION, "naming convention of variable name, e.g. camelCase.")
|
||||
.defaultValue("snake_case"));
|
||||
cliOptions.add(new CliOption(CodegenConstants.INVOKER_PACKAGE, "The main namespace to use for all classes. e.g. Yay\\Pets"));
|
||||
cliOptions.add(new CliOption(PACKAGE_PATH, "The main package name for classes. e.g. GeneratedPetstore"));
|
||||
cliOptions.add(new CliOption(SRC_BASE_PATH, "The directory under packagePath to serve as source root."));
|
||||
// cliOptions.add(new CliOption(COMPOSER_VENDOR_NAME, "The vendor name used in the composer package name. The template uses {{composerVendorName}}/{{composerProjectName}} for the composer package name. e.g. yaypets. IMPORTANT NOTE (2016/03): composerVendorName will be deprecated and replaced by gitUserId in the next swagger-codegen release"));
|
||||
cliOptions.add(new CliOption(CodegenConstants.GIT_USER_ID, CodegenConstants.GIT_USER_ID_DESC));
|
||||
// cliOptions.add(new CliOption(COMPOSER_PROJECT_NAME, "The project name used in the composer package name. The template uses {{composerVendorName}}/{{composerProjectName}} for the composer package name. e.g. petstore-client. IMPORTANT NOTE (2016/03): composerProjectName will be deprecated and replaced by gitRepoId in the next swagger-codegen release"));
|
||||
cliOptions.add(new CliOption(CodegenConstants.GIT_REPO_ID, CodegenConstants.GIT_REPO_ID_DESC));
|
||||
cliOptions.add(new CliOption(CodegenConstants.ARTIFACT_VERSION, "The version to use in the composer package version field. e.g. 1.2.3"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void processOpts() {
|
||||
super.processOpts();
|
||||
|
||||
if (additionalProperties.containsKey(PACKAGE_PATH)) {
|
||||
this.setPackagePath((String) additionalProperties.get(PACKAGE_PATH));
|
||||
} else {
|
||||
additionalProperties.put(PACKAGE_PATH, packagePath);
|
||||
}
|
||||
|
||||
if (additionalProperties.containsKey(SRC_BASE_PATH)) {
|
||||
this.setSrcBasePath((String) additionalProperties.get(SRC_BASE_PATH));
|
||||
} else {
|
||||
additionalProperties.put(SRC_BASE_PATH, srcBasePath);
|
||||
}
|
||||
|
||||
if (additionalProperties.containsKey(CodegenConstants.INVOKER_PACKAGE)) {
|
||||
this.setInvokerPackage((String) additionalProperties.get(CodegenConstants.INVOKER_PACKAGE));
|
||||
} else {
|
||||
additionalProperties.put(CodegenConstants.INVOKER_PACKAGE, invokerPackage);
|
||||
}
|
||||
|
||||
if (!additionalProperties.containsKey(CodegenConstants.MODEL_PACKAGE)) {
|
||||
additionalProperties.put(CodegenConstants.MODEL_PACKAGE, modelPackage);
|
||||
}
|
||||
|
||||
if (!additionalProperties.containsKey(CodegenConstants.API_PACKAGE)) {
|
||||
additionalProperties.put(CodegenConstants.API_PACKAGE, apiPackage);
|
||||
}
|
||||
|
||||
// if (additionalProperties.containsKey(COMPOSER_PROJECT_NAME)) {
|
||||
// this.setComposerProjectName((String) additionalProperties.get(COMPOSER_PROJECT_NAME));
|
||||
// } else {
|
||||
// additionalProperties.put(COMPOSER_PROJECT_NAME, composerProjectName);
|
||||
// }
|
||||
|
||||
if (additionalProperties.containsKey(CodegenConstants.GIT_USER_ID)) {
|
||||
this.setGitUserId((String) additionalProperties.get(CodegenConstants.GIT_USER_ID));
|
||||
} else {
|
||||
additionalProperties.put(CodegenConstants.GIT_USER_ID, gitUserId);
|
||||
}
|
||||
|
||||
// if (additionalProperties.containsKey(COMPOSER_VENDOR_NAME)) {
|
||||
// this.setComposerVendorName((String) additionalProperties.get(COMPOSER_VENDOR_NAME));
|
||||
// } else {
|
||||
// additionalProperties.put(COMPOSER_VENDOR_NAME, composerVendorName);
|
||||
// }
|
||||
|
||||
if (additionalProperties.containsKey(CodegenConstants.GIT_REPO_ID)) {
|
||||
this.setGitRepoId((String) additionalProperties.get(CodegenConstants.GIT_REPO_ID));
|
||||
} else {
|
||||
additionalProperties.put(CodegenConstants.GIT_REPO_ID, gitRepoId);
|
||||
}
|
||||
|
||||
if (additionalProperties.containsKey(CodegenConstants.ARTIFACT_VERSION)) {
|
||||
this.setArtifactVersion((String) additionalProperties.get(CodegenConstants.ARTIFACT_VERSION));
|
||||
} else {
|
||||
additionalProperties.put(CodegenConstants.ARTIFACT_VERSION, artifactVersion);
|
||||
}
|
||||
|
||||
if (additionalProperties.containsKey(VARIABLE_NAMING_CONVENTION)) {
|
||||
this.setParameterNamingConvention((String) additionalProperties.get(VARIABLE_NAMING_CONVENTION));
|
||||
}
|
||||
|
||||
additionalProperties.put("escapedInvokerPackage", invokerPackage.replace("\\", "\\\\"));
|
||||
|
||||
// make api and model doc path available in mustache template
|
||||
additionalProperties.put("apiDocPath", apiDocPath);
|
||||
additionalProperties.put("modelDocPath", modelDocPath);
|
||||
|
||||
// make test path available in mustache template
|
||||
additionalProperties.put("testBasePath", testBasePath);
|
||||
|
||||
// // apache v2 license
|
||||
// supportingFiles.add(new SupportingFile("LICENSE", getPackagePath(), "LICENSE"));
|
||||
}
|
||||
|
||||
public String getPackagePath() {
|
||||
return packagePath;
|
||||
}
|
||||
|
||||
public String toPackagePath(String packageName, String basePath) {
|
||||
packageName = packageName.replace(invokerPackage, ""); // FIXME: a parameter should not be assigned. Also declare the methods parameters as 'final'.
|
||||
if (basePath != null && basePath.length() > 0) {
|
||||
basePath = basePath.replaceAll("[\\\\/]?$", "") + File.separatorChar; // FIXME: a parameter should not be assigned. Also declare the methods parameters as 'final'.
|
||||
}
|
||||
|
||||
String regFirstPathSeparator;
|
||||
if ("/".equals(File.separator)) { // for mac, linux
|
||||
regFirstPathSeparator = "^/";
|
||||
} else { // for windows
|
||||
regFirstPathSeparator = "^\\\\";
|
||||
}
|
||||
|
||||
String regLastPathSeparator;
|
||||
if ("/".equals(File.separator)) { // for mac, linux
|
||||
regLastPathSeparator = "/$";
|
||||
} else { // for windows
|
||||
regLastPathSeparator = "\\\\$";
|
||||
}
|
||||
|
||||
return (getPackagePath() + File.separatorChar + basePath
|
||||
// Replace period, backslash, forward slash with file separator in package name
|
||||
+ packageName.replaceAll("[\\.\\\\/]", Matcher.quoteReplacement(File.separator))
|
||||
// Trim prefix file separators from package path
|
||||
.replaceAll(regFirstPathSeparator, ""))
|
||||
// Trim trailing file separators from the overall path
|
||||
.replaceAll(regLastPathSeparator+ "$", "");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String escapeReservedWord(String name) {
|
||||
return "_" + name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String apiFileFolder() {
|
||||
return (outputFolder + "/" + toPackagePath(apiPackage, srcBasePath));
|
||||
}
|
||||
|
||||
@Override
|
||||
public String modelFileFolder() {
|
||||
return (outputFolder + "/" + toPackagePath(modelPackage, srcBasePath));
|
||||
}
|
||||
|
||||
@Override
|
||||
public String apiTestFileFolder() {
|
||||
return (outputFolder + "/" + getPackagePath() + "/" + testBasePath + "/" + apiDirName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String modelTestFileFolder() {
|
||||
return (outputFolder + "/" + getPackagePath() + "/" + testBasePath + "/" + modelDirName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String apiDocFileFolder() {
|
||||
return (outputFolder + "/" + getPackagePath() + "/" + apiDocPath);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String modelDocFileFolder() {
|
||||
return (outputFolder + "/" + getPackagePath() + "/" + modelDocPath);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toModelDocFilename(String name) {
|
||||
return toModelName(name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toApiDocFilename(String name) {
|
||||
return toApiName(name);
|
||||
}
|
||||
|
||||
@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 getSwaggerType(p) + "[string," + getTypeDeclaration(inner) + "]";
|
||||
} else if (p instanceof RefProperty) {
|
||||
String type = super.getTypeDeclaration(p);
|
||||
return (!languageSpecificPrimitives.contains(type))
|
||||
? "\\" + modelPackage + "\\" + type : type;
|
||||
}
|
||||
return super.getTypeDeclaration(p);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTypeDeclaration(String name) {
|
||||
if (!languageSpecificPrimitives.contains(name)) {
|
||||
return "\\" + modelPackage + "\\" + name;
|
||||
}
|
||||
return super.getTypeDeclaration(name);
|
||||
}
|
||||
|
||||
@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 type;
|
||||
} else if (instantiationTypes.containsKey(type)) {
|
||||
return type;
|
||||
}
|
||||
} else {
|
||||
type = swaggerType;
|
||||
}
|
||||
if (type == null) {
|
||||
return null;
|
||||
}
|
||||
return toModelName(type);
|
||||
}
|
||||
|
||||
public void setInvokerPackage(String invokerPackage) {
|
||||
this.invokerPackage = invokerPackage;
|
||||
}
|
||||
|
||||
public void setArtifactVersion(String artifactVersion) {
|
||||
this.artifactVersion = artifactVersion;
|
||||
}
|
||||
|
||||
public void setPackagePath(String packagePath) {
|
||||
this.packagePath = packagePath;
|
||||
}
|
||||
|
||||
public void setSrcBasePath(String srcBasePath) {
|
||||
this.srcBasePath = srcBasePath;
|
||||
}
|
||||
|
||||
public void setParameterNamingConvention(String variableNamingConvention) {
|
||||
this.variableNamingConvention = variableNamingConvention;
|
||||
}
|
||||
|
||||
// public void setComposerVendorName(String composerVendorName) {
|
||||
// this.composerVendorName = composerVendorName;
|
||||
// }
|
||||
|
||||
// public void setComposerProjectName(String composerProjectName) {
|
||||
// this.composerProjectName = composerProjectName;
|
||||
// }
|
||||
|
||||
@Override
|
||||
public String toVarName(String name) {
|
||||
// sanitize name
|
||||
name = sanitizeName(name); // FIXME: a parameter should not be assigned. Also declare the methods parameters as 'final'.
|
||||
|
||||
if ("camelCase".equals(variableNamingConvention)) {
|
||||
// return the name in camelCase style
|
||||
// phone_number => phoneNumber
|
||||
name = camelize(name, true);
|
||||
} else { // default to snake case
|
||||
// return the name in underscore style
|
||||
// PhoneNumber => phone_number
|
||||
name = underscore(name);
|
||||
}
|
||||
|
||||
// parameter name starting with number won't compile
|
||||
// need to escape it by appending _ at the beginning
|
||||
if (name.matches("^\\d.*")) {
|
||||
name = "_" + name;
|
||||
}
|
||||
|
||||
return name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toParamName(String name) {
|
||||
// should be the same as variable name
|
||||
return toVarName(name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toModelName(String name) {
|
||||
// remove [
|
||||
name = name.replaceAll("\\]", "");
|
||||
|
||||
// Note: backslash ("\\") is allowed for e.g. "\\DateTime"
|
||||
name = name.replaceAll("[^\\w\\\\]+", "_"); // FIXME: a parameter should not be assigned. Also declare the methods parameters as 'final'.
|
||||
|
||||
// remove dollar sign
|
||||
name = name.replaceAll("$", "");
|
||||
|
||||
// model name cannot use reserved keyword
|
||||
if (isReservedWord(name)) {
|
||||
LOGGER.warn(name + " (reserved word) cannot be used as model name. Renamed to " + camelize("model_" + name));
|
||||
name = "model_" + name; // e.g. return => ModelReturn (after camelize)
|
||||
}
|
||||
|
||||
// model name starts with number
|
||||
if (name.matches("^\\d.*")) {
|
||||
LOGGER.warn(name + " (model name starts with number) cannot be used as model name. Renamed to " + camelize("model_" + name));
|
||||
name = "model_" + name; // e.g. 200Response => Model200Response (after camelize)
|
||||
}
|
||||
|
||||
// add prefix and/or suffic only if name does not start wth \ (e.g. \DateTime)
|
||||
if (!name.matches("^\\\\.*")) {
|
||||
name = modelNamePrefix + name + modelNameSuffix;
|
||||
}
|
||||
|
||||
// camelize the model name
|
||||
// phone_number => PhoneNumber
|
||||
return camelize(name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toModelFilename(String name) {
|
||||
// should be the same as the model name
|
||||
return toModelName(name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toModelTestFilename(String name) {
|
||||
// should be the same as the model name
|
||||
return toModelName(name) + "Test";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toOperationId(String operationId) {
|
||||
// throw exception if method name is empty
|
||||
if (StringUtils.isEmpty(operationId)) {
|
||||
throw new RuntimeException("Empty method name (operationId) not allowed");
|
||||
}
|
||||
|
||||
// method name cannot use reserved keyword, e.g. return
|
||||
if (isReservedWord(operationId)) {
|
||||
LOGGER.warn(operationId + " (reserved word) cannot be used as method name. Renamed to " + camelize(sanitizeName("call_" + operationId), true));
|
||||
operationId = "call_" + operationId;
|
||||
}
|
||||
|
||||
return camelize(sanitizeName(operationId), true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the default value of the property
|
||||
*
|
||||
* @param p Swagger property object
|
||||
* @return string presentation of the default value of the property
|
||||
*/
|
||||
@Override
|
||||
public String toDefaultValue(Property p) {
|
||||
if (p instanceof StringProperty) {
|
||||
StringProperty dp = (StringProperty) p;
|
||||
if (dp.getDefault() != null) {
|
||||
return "'" + dp.getDefault().toString() + "'";
|
||||
}
|
||||
} else if (p instanceof BooleanProperty) {
|
||||
BooleanProperty dp = (BooleanProperty) p;
|
||||
if (dp.getDefault() != null) {
|
||||
return dp.getDefault().toString();
|
||||
}
|
||||
} else if (p instanceof DateProperty) {
|
||||
// TODO
|
||||
} else if (p instanceof DateTimeProperty) {
|
||||
// TODO
|
||||
} else if (p instanceof DoubleProperty) {
|
||||
DoubleProperty dp = (DoubleProperty) p;
|
||||
if (dp.getDefault() != null) {
|
||||
return dp.getDefault().toString();
|
||||
}
|
||||
} else if (p instanceof FloatProperty) {
|
||||
FloatProperty dp = (FloatProperty) p;
|
||||
if (dp.getDefault() != null) {
|
||||
return dp.getDefault().toString();
|
||||
}
|
||||
} else if (p instanceof IntegerProperty) {
|
||||
IntegerProperty dp = (IntegerProperty) p;
|
||||
if (dp.getDefault() != null) {
|
||||
return dp.getDefault().toString();
|
||||
}
|
||||
} else if (p instanceof LongProperty) {
|
||||
LongProperty dp = (LongProperty) p;
|
||||
if (dp.getDefault() != null) {
|
||||
return dp.getDefault().toString();
|
||||
}
|
||||
}
|
||||
|
||||
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)) {
|
||||
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 ("\\SplFileObject".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 = "new \\DateTime(\"" + escapeText(example) + "\")";
|
||||
} else if ("DateTime".equalsIgnoreCase(type)) {
|
||||
if (example == null) {
|
||||
example = "2013-10-20T19:20:30+01:00";
|
||||
}
|
||||
example = "new \\DateTime(\"" + escapeText(example) + "\")";
|
||||
} else if (!languageSpecificPrimitives.contains(type)) {
|
||||
// type is a model class, e.g. User
|
||||
example = "new " + type + "()";
|
||||
} else {
|
||||
LOGGER.warn("Type " + type + " not handled properly in setParameterExampleValue");
|
||||
}
|
||||
|
||||
if (example == null) {
|
||||
example = "NULL";
|
||||
} else if (Boolean.TRUE.equals(p.isListContainer)) {
|
||||
example = "array(" + example + ")";
|
||||
} else if (Boolean.TRUE.equals(p.isMapContainer)) {
|
||||
example = "array('key' => " + example + ")";
|
||||
}
|
||||
|
||||
p.example = example;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toEnumValue(String value, String datatype) {
|
||||
if ("int".equals(datatype) || "double".equals(datatype) || "float".equals(datatype)) {
|
||||
return value;
|
||||
} else {
|
||||
return "\'" + escapeText(value) + "\'";
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toEnumDefaultValue(String value, String datatype) {
|
||||
return datatype + "_" + value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toEnumVarName(String name, String datatype) {
|
||||
// number
|
||||
if ("int".equals(datatype) || "double".equals(datatype) || "float".equals(datatype)) {
|
||||
String varName = new String(name);
|
||||
varName = varName.replaceAll("-", "MINUS_");
|
||||
varName = varName.replaceAll("\\+", "PLUS_");
|
||||
varName = varName.replaceAll("\\.", "_DOT_");
|
||||
return varName;
|
||||
}
|
||||
|
||||
// string
|
||||
String enumName = sanitizeName(underscore(name).toUpperCase());
|
||||
enumName = enumName.replaceFirst("^_", "");
|
||||
enumName = enumName.replaceFirst("_$", "");
|
||||
|
||||
if (enumName.matches("\\d.*")) { // starts with number
|
||||
return "_" + enumName;
|
||||
} else {
|
||||
return enumName;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toEnumName(CodegenProperty property) {
|
||||
String enumName = underscore(toModelName(property.name)).toUpperCase();
|
||||
|
||||
if (enumName.matches("\\d.*")) { // starts with number
|
||||
return "_" + enumName;
|
||||
} else {
|
||||
return enumName;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Object> postProcessModels(Map<String, Object> objs) {
|
||||
// process enum in models
|
||||
return postProcessModelsEnum(objs);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Object> postProcessOperations(Map<String, Object> objs) {
|
||||
Map<String, Object> operations = (Map<String, Object>) objs.get("operations");
|
||||
List<CodegenOperation> operationList = (List<CodegenOperation>) operations.get("operation");
|
||||
for (CodegenOperation op : operationList) {
|
||||
op.vendorExtensions.put("x-testOperationId", camelize(op.operationId));
|
||||
}
|
||||
return objs;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String escapeQuotationMark(String input) {
|
||||
// remove ' to avoid code injection
|
||||
return input.replace("'", "");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String escapeUnsafeCharacters(String input) {
|
||||
return input.replace("*/", "");
|
||||
}
|
||||
|
||||
}
|
||||
@@ -26,6 +26,11 @@ public abstract class AbstractTypeScriptClientCodegen extends DefaultCodegen imp
|
||||
|
||||
public AbstractTypeScriptClientCodegen() {
|
||||
super();
|
||||
|
||||
// clear import mapping (from default generator) as TS does not use it
|
||||
// at the moment
|
||||
importMapping.clear();
|
||||
|
||||
supportsInheritance = true;
|
||||
setReservedWordsLowerCase(Arrays.asList(
|
||||
// local variable names used in API methods (endpoints)
|
||||
|
||||
@@ -0,0 +1,95 @@
|
||||
package io.swagger.codegen.languages;
|
||||
|
||||
import io.swagger.codegen.*;
|
||||
import io.swagger.models.properties.ArrayProperty;
|
||||
import io.swagger.models.properties.MapProperty;
|
||||
import io.swagger.models.properties.Property;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class ConfluenceWikiGenerator extends DefaultCodegen implements CodegenConfig {
|
||||
private static final String ALL_OPERATIONS = "";
|
||||
protected String invokerPackage = "io.swagger.client";
|
||||
protected String groupId = "io.swagger";
|
||||
protected String artifactId = "swagger-client";
|
||||
protected String artifactVersion = "1.0.0";
|
||||
|
||||
public ConfluenceWikiGenerator() {
|
||||
super();
|
||||
outputFolder = "docs";
|
||||
embeddedTemplateDir = templateDir = "confluenceWikiDocs";
|
||||
|
||||
defaultIncludes = new HashSet<String>();
|
||||
|
||||
cliOptions.add(new CliOption("appName", "short name of the application"));
|
||||
cliOptions.add(new CliOption("appDescription", "description of the application"));
|
||||
cliOptions.add(new CliOption("infoUrl", "a URL where users can get more information about the application"));
|
||||
cliOptions.add(new CliOption("infoEmail", "an email address to contact for inquiries about the application"));
|
||||
cliOptions.add(new CliOption("licenseInfo", "a short description of the license"));
|
||||
cliOptions.add(new CliOption("licenseUrl", "a URL pointing to the full license"));
|
||||
cliOptions.add(new CliOption(CodegenConstants.INVOKER_PACKAGE, CodegenConstants.INVOKER_PACKAGE_DESC));
|
||||
cliOptions.add(new CliOption(CodegenConstants.GROUP_ID, CodegenConstants.GROUP_ID_DESC));
|
||||
cliOptions.add(new CliOption(CodegenConstants.ARTIFACT_ID, CodegenConstants.ARTIFACT_ID_DESC));
|
||||
cliOptions.add(new CliOption(CodegenConstants.ARTIFACT_VERSION, CodegenConstants.ARTIFACT_VERSION_DESC));
|
||||
|
||||
additionalProperties.put("appName", "Swagger Sample");
|
||||
additionalProperties.put("appDescription", "A sample swagger server");
|
||||
additionalProperties.put("infoUrl", "https://helloreverb.com");
|
||||
additionalProperties.put("infoEmail", "hello@helloreverb.com");
|
||||
additionalProperties.put("licenseInfo", "All rights reserved");
|
||||
additionalProperties.put("licenseUrl", "http://apache.org/licenses/LICENSE-2.0.html");
|
||||
additionalProperties.put(CodegenConstants.INVOKER_PACKAGE, invokerPackage);
|
||||
additionalProperties.put(CodegenConstants.GROUP_ID, groupId);
|
||||
additionalProperties.put(CodegenConstants.ARTIFACT_ID, artifactId);
|
||||
additionalProperties.put(CodegenConstants.ARTIFACT_VERSION, artifactVersion);
|
||||
|
||||
supportingFiles.add(new SupportingFile("index.mustache", "", "confluence-markup.txt"));
|
||||
reservedWords = new HashSet<String>();
|
||||
|
||||
languageSpecificPrimitives = new HashSet<String>();
|
||||
importMapping = new HashMap<String, String>();
|
||||
}
|
||||
|
||||
@Override
|
||||
public CodegenType getTag() {
|
||||
return CodegenType.DOCUMENTATION;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "cwiki";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getHelp() {
|
||||
return "Generates confluence wiki markup.";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTypeDeclaration(Property p) {
|
||||
if (p instanceof ArrayProperty) {
|
||||
ArrayProperty ap = (ArrayProperty) p;
|
||||
Property inner = ap.getItems();
|
||||
return getSwaggerType(p) + "[" + getTypeDeclaration(inner) + "]";
|
||||
} else if (p instanceof MapProperty) {
|
||||
MapProperty mp = (MapProperty) p;
|
||||
Property inner = mp.getAdditionalProperties();
|
||||
|
||||
return getSwaggerType(p) + "[String, " + getTypeDeclaration(inner) + "]";
|
||||
}
|
||||
return super.getTypeDeclaration(p);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Object> postProcessOperations(Map<String, Object> objs) {
|
||||
Map<String, Object> operations = (Map<String, Object>) objs.get("operations");
|
||||
List<CodegenOperation> operationList = (List<CodegenOperation>) operations.get("operation");
|
||||
for (CodegenOperation op : operationList) {
|
||||
op.httpMethod = op.httpMethod.toLowerCase();
|
||||
}
|
||||
return objs;
|
||||
}
|
||||
}
|
||||
@@ -24,6 +24,11 @@ public class CsharpDotNet2ClientCodegen extends DefaultCodegen implements Codege
|
||||
|
||||
public CsharpDotNet2ClientCodegen() {
|
||||
super();
|
||||
|
||||
// clear import mapping (from default generator) as C# (2.0) does not use it
|
||||
// at the moment
|
||||
importMapping.clear();
|
||||
|
||||
outputFolder = "generated-code" + File.separator + "CsharpDotNet2";
|
||||
modelTemplateFiles.put("model.mustache", ".cs");
|
||||
apiTemplateFiles.put("api.mustache", ".cs");
|
||||
|
||||
@@ -28,6 +28,11 @@ public class DartClientCodegen extends DefaultCodegen implements CodegenConfig {
|
||||
|
||||
public DartClientCodegen() {
|
||||
super();
|
||||
|
||||
// clear import mapping (from default generator) as dart does not use it
|
||||
// at the moment
|
||||
importMapping.clear();
|
||||
|
||||
outputFolder = "generated-code/dart";
|
||||
modelTemplateFiles.put("model.mustache", ".dart");
|
||||
apiTemplateFiles.put("api.mustache", ".dart");
|
||||
@@ -140,6 +145,7 @@ public class DartClientCodegen extends DefaultCodegen implements CodegenConfig {
|
||||
|
||||
final String libFolder = sourceFolder + File.separator + "lib";
|
||||
supportingFiles.add(new SupportingFile("pubspec.mustache", "", "pubspec.yaml"));
|
||||
supportingFiles.add(new SupportingFile("analysis_options.mustache", "", ".analysis_options"));
|
||||
supportingFiles.add(new SupportingFile("api_client.mustache", libFolder, "api_client.dart"));
|
||||
supportingFiles.add(new SupportingFile("api_exception.mustache", libFolder, "api_exception.dart"));
|
||||
supportingFiles.add(new SupportingFile("api_helper.mustache", libFolder, "api_helper.dart"));
|
||||
|
||||
@@ -382,13 +382,21 @@ public class GoClientCodegen extends DefaultCodegen implements CodegenConfig {
|
||||
// if the return type is not primitive, import encoding/json
|
||||
for (CodegenOperation operation : operations) {
|
||||
if(operation.returnBaseType != null && needToImport(operation.returnBaseType)) {
|
||||
Map<String, String> customImport = new HashMap<String, String>();
|
||||
customImport.put("import", "encoding/json");
|
||||
imports.add(customImport);
|
||||
imports.add(createMapping("import", "encoding/json"));
|
||||
break; //just need to import once
|
||||
}
|
||||
}
|
||||
|
||||
// this will only import "strings" "fmt" if there are items in pathParams
|
||||
for (CodegenOperation operation : operations) {
|
||||
if(operation.pathParams != null && operation.pathParams.size() > 0) {
|
||||
imports.add(createMapping("import", "fmt"));
|
||||
imports.add(createMapping("import", "strings"));
|
||||
break; //just need to import once
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// recursivly add import for mapping one type to multipe imports
|
||||
List<Map<String, String>> recursiveImports = (List<Map<String, String>>) objs.get("imports");
|
||||
if (recursiveImports == null)
|
||||
@@ -400,9 +408,7 @@ public class GoClientCodegen extends DefaultCodegen implements CodegenConfig {
|
||||
// if the import package happens to be found in the importMapping (key)
|
||||
// add the corresponding import package to the list
|
||||
if (importMapping.containsKey(_import)) {
|
||||
Map<String, String> newImportMap= new HashMap<String, String>();
|
||||
newImportMap.put("import", importMapping.get(_import));
|
||||
listIterator.add(newImportMap);
|
||||
listIterator.add(createMapping("import", importMapping.get(_import)));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -432,9 +438,7 @@ public class GoClientCodegen extends DefaultCodegen implements CodegenConfig {
|
||||
// if the import package happens to be found in the importMapping (key)
|
||||
// add the corresponding import package to the list
|
||||
if (importMapping.containsKey(_import)) {
|
||||
Map<String, String> newImportMap= new HashMap<String, String>();
|
||||
newImportMap.put("import", importMapping.get(_import));
|
||||
listIterator.add(newImportMap);
|
||||
listIterator.add(createMapping("import", importMapping.get(_import)));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -465,4 +469,11 @@ public class GoClientCodegen extends DefaultCodegen implements CodegenConfig {
|
||||
public String escapeUnsafeCharacters(String input) {
|
||||
return input.replace("*/", "*_/").replace("/*", "/_*");
|
||||
}
|
||||
|
||||
public Map<String, String> createMapping(String key, String value){
|
||||
Map<String, String> customImport = new HashMap<String, String>();
|
||||
customImport.put(key, value);
|
||||
|
||||
return customImport;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,6 +12,10 @@ public class GroovyClientCodegen extends AbstractJavaCodegen {
|
||||
public GroovyClientCodegen() {
|
||||
super();
|
||||
|
||||
// clear import mapping (from default generator) as groovy does not use it
|
||||
// at the moment
|
||||
importMapping.clear();
|
||||
|
||||
sourceFolder = projectFolder + File.separator + "groovy";
|
||||
outputFolder = "generated-code/groovy";
|
||||
modelTemplateFiles.put("model.mustache", ".groovy");
|
||||
|
||||
@@ -49,8 +49,10 @@ public class HaskellServantCodegen extends DefaultCodegen implements CodegenConf
|
||||
public HaskellServantCodegen() {
|
||||
super();
|
||||
|
||||
// override the mapping for "-" (Minus) to keep the original mapping in Haskell
|
||||
specialCharReplacements.put('-', "Dash");
|
||||
// override the mapping to keep the original mapping in Haskell
|
||||
specialCharReplacements.put("-", "Dash");
|
||||
specialCharReplacements.put(">", "GreaterThan");
|
||||
specialCharReplacements.put("<", "LessThan");
|
||||
|
||||
// set the output folder here
|
||||
outputFolder = "generated-code/haskell-servant";
|
||||
@@ -203,9 +205,9 @@ public class HaskellServantCodegen extends DefaultCodegen implements CodegenConf
|
||||
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];
|
||||
String c = (String) replacementChars[i];
|
||||
Map<String, Object> o = new HashMap<>();
|
||||
o.put("char", Character.toString(c));
|
||||
o.put("char", c);
|
||||
o.put("replacement", "'" + specialCharReplacements.get(c));
|
||||
o.put("hasMore", i != replacementChars.length - 1);
|
||||
replacements.add(o);
|
||||
@@ -471,6 +473,11 @@ public class HaskellServantCodegen extends DefaultCodegen implements CodegenConf
|
||||
|
||||
// Create newtypes for things with non-object types
|
||||
String dataOrNewtype = "data";
|
||||
// check if it's a ModelImpl before casting
|
||||
if (!(mod instanceof ModelImpl)) {
|
||||
return model;
|
||||
}
|
||||
|
||||
String modelType = ((ModelImpl) mod).getType();
|
||||
if(modelType != "object" && typeMapping.containsKey(modelType)) {
|
||||
String newtype = typeMapping.get(modelType);
|
||||
|
||||
@@ -15,7 +15,6 @@ public class JavaCXFServerCodegen extends AbstractJavaJAXRSServerCodegen
|
||||
public JavaCXFServerCodegen()
|
||||
{
|
||||
super();
|
||||
supportsInheritance = true;
|
||||
sourceFolder = "gen" + File.separator + "java";
|
||||
outputFolder = "generated-code/JavaJaxRS-CXF";
|
||||
apiTestTemplateFiles.clear(); // TODO: add test template
|
||||
|
||||
@@ -183,6 +183,11 @@ public class JavaClientCodegen extends AbstractJavaCodegen {
|
||||
if(additionalProperties.containsKey("gson")) {
|
||||
model.imports.add("SerializedName");
|
||||
}
|
||||
} else { // enum class
|
||||
//Needed imports for Jackson's JsonCreator
|
||||
if(additionalProperties.containsKey("jackson")) {
|
||||
model.imports.add("JsonCreator");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -25,7 +25,6 @@ public class JavaJAXRSSpecServerCodegen extends AbstractJavaJAXRSServerCodegen
|
||||
public JavaJAXRSSpecServerCodegen()
|
||||
{
|
||||
super();
|
||||
supportsInheritance = true;
|
||||
sourceFolder = "src/main/java";
|
||||
invokerPackage = "io.swagger.api";
|
||||
artifactId = "swagger-jaxrs-server";
|
||||
|
||||
@@ -762,9 +762,11 @@ public class JavascriptClientCodegen extends DefaultCodegen implements CodegenCo
|
||||
+ (StringUtils.isEmpty(modelPackage) ? "" : (modelPackage + "/")) + dataType;
|
||||
}
|
||||
|
||||
/*
|
||||
private String getJSDocTypeWithBraces(CodegenModel cm, CodegenProperty cp) {
|
||||
return "{" + getJSDocType(cm, cp) + "}";
|
||||
}
|
||||
*/
|
||||
|
||||
private String getJSDocType(CodegenModel cm, CodegenProperty cp) {
|
||||
if (Boolean.TRUE.equals(cp.isContainer)) {
|
||||
@@ -787,9 +789,11 @@ public class JavascriptClientCodegen extends DefaultCodegen implements CodegenCo
|
||||
return cp.isEnum || !languageSpecificPrimitives.contains(cp.baseType == null ? cp.datatype : cp.baseType);
|
||||
}
|
||||
|
||||
/*
|
||||
private String getJSDocTypeWithBraces(CodegenParameter cp) {
|
||||
return "{" + getJSDocType(cp) + "}";
|
||||
}
|
||||
*/
|
||||
|
||||
private String getJSDocType(CodegenParameter cp) {
|
||||
String dataType = trimBrackets(cp.dataType);
|
||||
@@ -808,10 +812,12 @@ public class JavascriptClientCodegen extends DefaultCodegen implements CodegenCo
|
||||
return cp.isEnum || !languageSpecificPrimitives.contains(cp.baseType == null ? cp.dataType : cp.baseType);
|
||||
}
|
||||
|
||||
/*
|
||||
private String getJSDocTypeWithBraces(CodegenOperation co) {
|
||||
String jsDocType = getJSDocType(co);
|
||||
return jsDocType == null ? null : "{" + jsDocType + "}";
|
||||
}
|
||||
*/
|
||||
|
||||
private String getJSDocType(CodegenOperation co) {
|
||||
String returnType = trimBrackets(co.returnType);
|
||||
@@ -860,10 +866,10 @@ public class JavascriptClientCodegen extends DefaultCodegen implements CodegenCo
|
||||
|
||||
// Store JSDoc type specification into vendor-extension: x-jsdoc-type.
|
||||
for (CodegenParameter cp : operation.allParams) {
|
||||
String jsdocType = getJSDocTypeWithBraces(cp);
|
||||
String jsdocType = getJSDocType(cp);
|
||||
cp.vendorExtensions.put("x-jsdoc-type", jsdocType);
|
||||
}
|
||||
String jsdocType = getJSDocTypeWithBraces(operation);
|
||||
String jsdocType = getJSDocType(operation);
|
||||
operation.vendorExtensions.put("x-jsdoc-type", jsdocType);
|
||||
}
|
||||
}
|
||||
@@ -889,7 +895,7 @@ public class JavascriptClientCodegen extends DefaultCodegen implements CodegenCo
|
||||
|
||||
for (CodegenProperty var : cm.vars) {
|
||||
// Add JSDoc @type value for this property.
|
||||
String jsDocType = getJSDocTypeWithBraces(cm, var);
|
||||
String jsDocType = getJSDocType(cm, var);
|
||||
var.vendorExtensions.put("x-jsdoc-type", jsDocType);
|
||||
|
||||
if (Boolean.TRUE.equals(var.required)) {
|
||||
|
||||
@@ -10,10 +10,9 @@ import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.TreeMap;
|
||||
|
||||
public class LumenServerCodegen extends DefaultCodegen implements CodegenConfig {
|
||||
|
||||
// source folder where to write the files
|
||||
protected String sourceFolder = "";
|
||||
public class LumenServerCodegen extends AbstractPhpCodegen
|
||||
{
|
||||
@SuppressWarnings("hiding")
|
||||
protected String apiVersion = "1.0.0";
|
||||
|
||||
/**
|
||||
@@ -43,47 +42,19 @@ public class LumenServerCodegen extends DefaultCodegen implements CodegenConfig
|
||||
* @return A string value for the help message
|
||||
*/
|
||||
public String getHelp() {
|
||||
return "Generates a LumenServerCodegen client library.";
|
||||
return "Generates a LumenServerCodegen server library.";
|
||||
}
|
||||
|
||||
public LumenServerCodegen() {
|
||||
super();
|
||||
|
||||
// set the output folder here
|
||||
outputFolder = "lumen";
|
||||
String packagePath = "";
|
||||
embeddedTemplateDir = templateDir = "lumen";
|
||||
|
||||
/**
|
||||
* Models. You can write model files using the modelTemplateFiles map.
|
||||
* 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
|
||||
* a different extension
|
||||
* packPath
|
||||
*/
|
||||
// modelTemplateFiles.put(
|
||||
// "model.mustache", // the template to use
|
||||
// ".sample"); // the extension for each file to write
|
||||
|
||||
/**
|
||||
* Api classes. You can write classes for each Api file with the apiTemplateFiles map.
|
||||
* as with models, add multiple entries with different extensions for multiple files per
|
||||
* class
|
||||
*/
|
||||
// apiTemplateFiles.put(
|
||||
// "api.mustache", // the template to use
|
||||
// ".sample"); // the extension for each file to write
|
||||
|
||||
|
||||
// no api files
|
||||
// apiTemplateFiles.clear();
|
||||
apiTemplateFiles.put("api.mustache", ".php");
|
||||
|
||||
// embeddedTemplateDir = templateDir = "slim";
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
templateDir = "lumen";
|
||||
invokerPackage = "lumen";
|
||||
packagePath = "";
|
||||
|
||||
/**
|
||||
* Api Package. Optional, if needed, this can be used in templates
|
||||
@@ -95,14 +66,11 @@ public class LumenServerCodegen extends DefaultCodegen implements CodegenConfig
|
||||
*/
|
||||
modelPackage = "models";
|
||||
|
||||
/**
|
||||
* Reserved words. Override this with reserved words specific to your language
|
||||
*/
|
||||
reservedWords = new HashSet<String> (
|
||||
Arrays.asList(
|
||||
"sample1", // replace with static values
|
||||
"sample2")
|
||||
);
|
||||
// template files want to be ignored
|
||||
modelTemplateFiles.clear();
|
||||
apiTestTemplateFiles.clear();
|
||||
apiDocTemplateFiles.clear();
|
||||
modelDocTemplateFiles.clear();
|
||||
|
||||
/**
|
||||
* Additional Properties. These values can be passed to the templates and
|
||||
@@ -115,55 +83,18 @@ public class LumenServerCodegen extends DefaultCodegen implements CodegenConfig
|
||||
* 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
|
||||
*/
|
||||
supportingFiles.add(new SupportingFile("composer.mustache", packagePath, "composer.json"));
|
||||
supportingFiles.add(new SupportingFile("readme.md", packagePath, "readme.md"));
|
||||
supportingFiles.add(new SupportingFile("app.php", packagePath + File.separator + "bootstrap", "app.php"));
|
||||
supportingFiles.add(new SupportingFile("index.php", packagePath + File.separator + "public", "index.php"));
|
||||
supportingFiles.add(new SupportingFile("User.php", packagePath + File.separator + "app", "User.php"));
|
||||
supportingFiles.add(new SupportingFile("Kernel.php", packagePath + File.separator + "app" + File.separator + "Console", "Kernel.php"));
|
||||
supportingFiles.add(new SupportingFile("Handler.php", packagePath + File.separator + "app" + File.separator + "Exceptions", "Handler.php"));
|
||||
supportingFiles.add(new SupportingFile("routes.mustache", packagePath + File.separator + "app" + File.separator + "Http", "routes.php"));
|
||||
supportingFiles.add(new SupportingFile("composer.mustache", packagePath + File.separator + srcBasePath, "composer.json"));
|
||||
supportingFiles.add(new SupportingFile("readme.md", packagePath + File.separator + srcBasePath, "readme.md"));
|
||||
supportingFiles.add(new SupportingFile("app.php", packagePath + File.separator + srcBasePath + File.separator + "bootstrap", "app.php"));
|
||||
supportingFiles.add(new SupportingFile("index.php", packagePath + File.separator + srcBasePath + File.separator + "public", "index.php"));
|
||||
supportingFiles.add(new SupportingFile("User.php", packagePath + File.separator + srcBasePath + File.separator + "app", "User.php"));
|
||||
supportingFiles.add(new SupportingFile("Kernel.php", packagePath + File.separator + srcBasePath + File.separator + "app" + File.separator + "Console", "Kernel.php"));
|
||||
supportingFiles.add(new SupportingFile("Handler.php", packagePath + File.separator + srcBasePath + File.separator + "app" + File.separator + "Exceptions", "Handler.php"));
|
||||
supportingFiles.add(new SupportingFile("routes.mustache", packagePath + File.separator + srcBasePath + File.separator + "app" + File.separator + "Http", "routes.php"));
|
||||
|
||||
supportingFiles.add(new SupportingFile("Controller.php", packagePath + File.separator + "app" + File.separator + "Http" + File.separator + "Controllers" + File.separator, "Controller.php"));
|
||||
supportingFiles.add(new SupportingFile("Authenticate.php", packagePath + File.separator + "app" + File.separator + "Http" + File.separator + "Middleware" + File.separator, "Authenticate.php"));
|
||||
supportingFiles.add(new SupportingFile("Controller.php", packagePath + File.separator + srcBasePath + File.separator + "app" + File.separator + "Http" + File.separator + "Controllers" + File.separator, "Controller.php"));
|
||||
supportingFiles.add(new SupportingFile("Authenticate.php", packagePath + File.separator + srcBasePath + File.separator + "app" + File.separator + "Http" + File.separator + "Middleware" + File.separator, "Authenticate.php"));
|
||||
|
||||
/**
|
||||
* Language Specific Primitives. These types will not trigger imports by
|
||||
* the client generator
|
||||
*/
|
||||
languageSpecificPrimitives = new HashSet<String>(
|
||||
Arrays.asList(
|
||||
"Type1", // replace these with your types
|
||||
"Type2")
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* 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; // add an underscore to the name
|
||||
}
|
||||
|
||||
/**
|
||||
* Location to write model files. You can use the modelPackage() as defined when the class is
|
||||
* instantiated
|
||||
*/
|
||||
public String modelFileFolder() {
|
||||
return outputFolder + "/" + 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 + "/" + apiPackage().replace('.', File.separatorChar);//"/app/Http/controllers";
|
||||
}
|
||||
|
||||
// override with any special post-processing
|
||||
@@ -185,57 +116,4 @@ public class LumenServerCodegen extends DefaultCodegen implements CodegenConfig
|
||||
|
||||
return objs;
|
||||
}
|
||||
/**
|
||||
* 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 getSwaggerType(p) + "[" + getTypeDeclaration(inner) + "]";
|
||||
}
|
||||
else if (p instanceof MapProperty) {
|
||||
MapProperty mp = (MapProperty) p;
|
||||
Property inner = mp.getAdditionalProperties();
|
||||
return getSwaggerType(p) + "[String, " + getTypeDeclaration(inner) + "]";
|
||||
}
|
||||
return 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
|
||||
type = swaggerType;
|
||||
return toModelName(type);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String escapeQuotationMark(String input) {
|
||||
// remove ' to avoid code injection
|
||||
return input.replace("'", "");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String escapeUnsafeCharacters(String input) {
|
||||
return input.replace("*/", "*_/").replace("/*", "/_*");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -222,7 +222,7 @@ public class NancyFXServerCodegen extends AbstractCSharpCodegen {
|
||||
}
|
||||
|
||||
private void postProcessParentModels(final Map<String, Object> models) {
|
||||
log.info("Processing parents: " + parentModels);
|
||||
log.debug("Processing parents: " + parentModels);
|
||||
for (final String parent : parentModels) {
|
||||
final CodegenModel parentModel = modelByName(parent, models);
|
||||
parentModel.hasChildren = true;
|
||||
@@ -301,7 +301,7 @@ public class NancyFXServerCodegen extends AbstractCSharpCodegen {
|
||||
} else {
|
||||
result = enumName;
|
||||
}
|
||||
log.info(String.format("toEnumVarName('%s', %s) = '%s'", name, datatype, enumName));
|
||||
log.debug(String.format("toEnumVarName('%s', %s) = '%s'", name, datatype, enumName));
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -313,7 +313,7 @@ public class NancyFXServerCodegen extends AbstractCSharpCodegen {
|
||||
} else {
|
||||
apiName = capitalize(name);
|
||||
}
|
||||
log.info(String.format("toApiName('%s') = '%s'", name, apiName));
|
||||
log.debug(String.format("toApiName('%s') = '%s'", name, apiName));
|
||||
return apiName;
|
||||
}
|
||||
|
||||
@@ -334,7 +334,7 @@ public class NancyFXServerCodegen extends AbstractCSharpCodegen {
|
||||
} else {
|
||||
result = null;
|
||||
}
|
||||
log.info(String.format("toModelImport('%s') = '%s'", name, result));
|
||||
log.debug(String.format("toModelImport('%s') = '%s'", name, result));
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
@@ -320,4 +320,14 @@ public class NodeJSServerCodegen extends DefaultCodegen implements CodegenConfig
|
||||
return removeNonNameElementToCamelCase(name, "[-:;#]");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String escapeUnsafeCharacters(String input) {
|
||||
return input.replace("*/", "*_/").replace("/*", "/_*");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String escapeQuotationMark(String input) {
|
||||
// remove " to avoid code injection
|
||||
return input.replace("\"", "");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -703,6 +703,8 @@ public class ObjcClientCodegen extends DefaultCodegen implements CodegenConfig {
|
||||
example = "2013-10-20T19:20:30+01:00";
|
||||
}
|
||||
example = "@\"" + escapeText(example) + "\"";
|
||||
} else if ("NSData".equalsIgnoreCase(type)) {
|
||||
example = "1234";
|
||||
} else if (!languageSpecificPrimitives.contains(type)) {
|
||||
// type is a model class, e.g. User
|
||||
type = type.replace("*", "");
|
||||
|
||||
@@ -42,6 +42,11 @@ public class PerlClientCodegen extends DefaultCodegen implements CodegenConfig {
|
||||
|
||||
public PerlClientCodegen() {
|
||||
super();
|
||||
|
||||
// clear import mapping (from default generator) as perl does not use it
|
||||
// at the moment
|
||||
importMapping.clear();
|
||||
|
||||
modelPackage = File.separatorChar + "Object";
|
||||
outputFolder = "generated-code" + File.separatorChar + "perl";
|
||||
modelTemplateFiles.put("object.mustache", ".pm");
|
||||
|
||||
@@ -50,6 +50,11 @@ public class PhpClientCodegen extends DefaultCodegen implements CodegenConfig {
|
||||
public PhpClientCodegen() {
|
||||
super();
|
||||
|
||||
// clear import mapping (from default generator) as php does not use it
|
||||
// at the moment
|
||||
importMapping.clear();
|
||||
|
||||
|
||||
supportsInheritance = true;
|
||||
outputFolder = "generated-code" + File.separator + "php";
|
||||
modelTemplateFiles.put("model.mustache", ".php");
|
||||
@@ -640,6 +645,9 @@ public class PhpClientCodegen extends DefaultCodegen implements CodegenConfig {
|
||||
public String toEnumName(CodegenProperty property) {
|
||||
String enumName = underscore(toModelName(property.name)).toUpperCase();
|
||||
|
||||
// remove [] for array or map of enum
|
||||
enumName = enumName.replace("[]", "");
|
||||
|
||||
if (enumName.matches("\\d.*")) { // starts with number
|
||||
return "_" + enumName;
|
||||
} else {
|
||||
|
||||
@@ -33,6 +33,10 @@ public class PythonClientCodegen extends DefaultCodegen implements CodegenConfig
|
||||
public PythonClientCodegen() {
|
||||
super();
|
||||
|
||||
// clear import mapping (from default generator) as python does not use it
|
||||
// at the moment
|
||||
importMapping.clear();
|
||||
|
||||
modelPackage = "models";
|
||||
apiPackage = "api";
|
||||
outputFolder = "generated-code" + File.separatorChar + "python";
|
||||
|
||||
@@ -124,6 +124,7 @@ public class Qt5CPPGenerator extends DefaultCodegen implements CodegenConfig {
|
||||
//TODO binary should be mapped to byte array
|
||||
// mapped to String as a workaround
|
||||
typeMapping.put("binary", "QString");
|
||||
typeMapping.put("ByteArray", "QByteArray");
|
||||
|
||||
importMapping = new HashMap<String, String>();
|
||||
|
||||
@@ -138,6 +139,7 @@ public class Qt5CPPGenerator extends DefaultCodegen implements CodegenConfig {
|
||||
systemIncludes.add("QMap");
|
||||
systemIncludes.add("QDate");
|
||||
systemIncludes.add("QDateTime");
|
||||
systemIncludes.add("QByteArray");
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -54,6 +54,11 @@ public class RubyClientCodegen extends DefaultCodegen implements CodegenConfig {
|
||||
|
||||
public RubyClientCodegen() {
|
||||
super();
|
||||
|
||||
// clear import mapping (from default generator) as ruby does not use it
|
||||
// at the moment
|
||||
importMapping.clear();
|
||||
|
||||
modelPackage = "models";
|
||||
apiPackage = "api";
|
||||
outputFolder = "generated-code" + File.separator + "ruby";
|
||||
@@ -225,7 +230,6 @@ public class RubyClientCodegen extends DefaultCodegen implements CodegenConfig {
|
||||
supportingFiles.add(new SupportingFile("README.mustache", "", "README.md"));
|
||||
supportingFiles.add(new SupportingFile("git_push.sh.mustache", "", "git_push.sh"));
|
||||
supportingFiles.add(new SupportingFile("gitignore.mustache", "", ".gitignore"));
|
||||
supportingFiles.add(new SupportingFile("LICENSE", "", "LICENSE"));
|
||||
|
||||
// test files should not be overwritten
|
||||
writeOptional(outputFolder, new SupportingFile("rspec.mustache", "", ".rspec"));
|
||||
|
||||
@@ -42,7 +42,7 @@ public class ScalatraServerCodegen extends DefaultCodegen implements CodegenConf
|
||||
"import", "public", "throws", "case", "enum", "instanceof", "return", "transient",
|
||||
"catch", "extends", "int", "short", "try", "char", "final", "interface", "static",
|
||||
"void", "class", "finally", "long", "strictfp", "volatile", "const", "float",
|
||||
"native", "super", "while")
|
||||
"native", "super", "while", "type")
|
||||
);
|
||||
|
||||
defaultIncludes = new HashSet<String>(
|
||||
|
||||
@@ -30,6 +30,10 @@ public class SlimFrameworkServerCodegen extends DefaultCodegen implements Codege
|
||||
public SlimFrameworkServerCodegen() {
|
||||
super();
|
||||
|
||||
// clear import mapping (from default generator) as slim does not use it
|
||||
// at the moment
|
||||
importMapping.clear();
|
||||
|
||||
invokerPackage = camelize("SwaggerServer");
|
||||
|
||||
//String packagePath = "SwaggerServer";
|
||||
|
||||
@@ -18,6 +18,11 @@ public class StaticDocCodegen extends DefaultCodegen implements CodegenConfig {
|
||||
|
||||
public StaticDocCodegen() {
|
||||
super();
|
||||
|
||||
// clear import mapping (from default generator) as this generator does not use it
|
||||
// at the moment
|
||||
importMapping.clear();
|
||||
|
||||
outputFolder = "docs";
|
||||
modelTemplateFiles.put("model.mustache", ".html");
|
||||
apiTemplateFiles.put("operation.mustache", ".html");
|
||||
|
||||
@@ -0,0 +1,154 @@
|
||||
package io.swagger.codegen.languages;
|
||||
|
||||
import io.swagger.codegen.*;
|
||||
import io.swagger.models.Model;
|
||||
import io.swagger.models.Operation;
|
||||
import io.swagger.models.Swagger;
|
||||
import io.swagger.models.properties.ArrayProperty;
|
||||
import io.swagger.models.properties.MapProperty;
|
||||
import io.swagger.models.properties.Property;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class StaticHtml2Generator extends DefaultCodegen implements CodegenConfig {
|
||||
private static final String ALL_OPERATIONS = "";
|
||||
protected String invokerPackage = "io.swagger.client";
|
||||
protected String groupId = "io.swagger";
|
||||
protected String artifactId = "swagger-client";
|
||||
protected String artifactVersion = "1.0.0";
|
||||
protected String sourceFolder = "src/main/scala";
|
||||
|
||||
public StaticHtml2Generator() {
|
||||
super();
|
||||
outputFolder = "docs";
|
||||
embeddedTemplateDir = templateDir = "htmlDocs2";
|
||||
|
||||
defaultIncludes = new HashSet<String>();
|
||||
|
||||
cliOptions.add(new CliOption("appName", "short name of the application"));
|
||||
cliOptions.add(new CliOption("appDescription", "description of the application"));
|
||||
cliOptions.add(new CliOption("infoUrl", "a URL where users can get more information about the application"));
|
||||
cliOptions.add(new CliOption("infoEmail", "an email address to contact for inquiries about the application"));
|
||||
cliOptions.add(new CliOption("licenseInfo", "a short description of the license"));
|
||||
cliOptions.add(new CliOption("licenseUrl", "a URL pointing to the full license"));
|
||||
cliOptions.add(new CliOption(CodegenConstants.INVOKER_PACKAGE, CodegenConstants.INVOKER_PACKAGE_DESC));
|
||||
cliOptions.add(new CliOption(CodegenConstants.GROUP_ID, CodegenConstants.GROUP_ID_DESC));
|
||||
cliOptions.add(new CliOption(CodegenConstants.ARTIFACT_ID, CodegenConstants.ARTIFACT_ID_DESC));
|
||||
cliOptions.add(new CliOption(CodegenConstants.ARTIFACT_VERSION, CodegenConstants.ARTIFACT_VERSION_DESC));
|
||||
|
||||
additionalProperties.put("appName", "Swagger Sample");
|
||||
additionalProperties.put("appDescription", "A sample swagger server");
|
||||
additionalProperties.put("infoUrl", "https://helloreverb.com");
|
||||
additionalProperties.put("infoEmail", "hello@helloreverb.com");
|
||||
additionalProperties.put("licenseInfo", "All rights reserved");
|
||||
additionalProperties.put("licenseUrl", "http://apache.org/licenses/LICENSE-2.0.html");
|
||||
additionalProperties.put(CodegenConstants.INVOKER_PACKAGE, invokerPackage);
|
||||
additionalProperties.put(CodegenConstants.GROUP_ID, groupId);
|
||||
additionalProperties.put(CodegenConstants.ARTIFACT_ID, artifactId);
|
||||
additionalProperties.put(CodegenConstants.ARTIFACT_VERSION, artifactVersion);
|
||||
|
||||
supportingFiles.add(new SupportingFile("index.mustache", "", "index.html"));
|
||||
reservedWords = new HashSet<String>();
|
||||
|
||||
languageSpecificPrimitives = new HashSet<String>();
|
||||
importMapping = new HashMap<String, String>();
|
||||
}
|
||||
|
||||
@Override
|
||||
public CodegenType getTag() {
|
||||
return CodegenType.DOCUMENTATION;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "html2";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getHelp() {
|
||||
return "Generates a static HTML file.";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTypeDeclaration(Property p) {
|
||||
if (p instanceof ArrayProperty) {
|
||||
ArrayProperty ap = (ArrayProperty) p;
|
||||
Property inner = ap.getItems();
|
||||
return getSwaggerType(p) + "[" + getTypeDeclaration(inner) + "]";
|
||||
} else if (p instanceof MapProperty) {
|
||||
MapProperty mp = (MapProperty) p;
|
||||
Property inner = mp.getAdditionalProperties();
|
||||
|
||||
return getSwaggerType(p) + "[String, " + getTypeDeclaration(inner) + "]";
|
||||
}
|
||||
return super.getTypeDeclaration(p);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Object> postProcessOperations(Map<String, Object> objs) {
|
||||
Map<String, Object> operations = (Map<String, Object>) objs.get("operations");
|
||||
List<CodegenOperation> operationList = (List<CodegenOperation>) operations.get("operation");
|
||||
for (CodegenOperation op : operationList) {
|
||||
op.httpMethod = op.httpMethod.toLowerCase();
|
||||
}
|
||||
return objs;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public CodegenOperation fromOperation(String path, String httpMethod, Operation operation, Map<String, Model> definitions, Swagger swagger) {
|
||||
CodegenOperation op = super.fromOperation(path, httpMethod, operation, definitions, swagger);
|
||||
if (op.returnType != null) {
|
||||
op.returnType = normalizeType(op.returnType);
|
||||
}
|
||||
|
||||
//path is an unescaped variable in the mustache template api.mustache line 82 '<&path>'
|
||||
op.path = sanitizePath(op.path);
|
||||
|
||||
// Set vendor-extension to be used in template:
|
||||
// x-codegen-hasMoreRequired
|
||||
// x-codegen-hasMoreOptional
|
||||
// x-codegen-hasRequiredParams
|
||||
CodegenParameter lastRequired = null;
|
||||
CodegenParameter lastOptional = null;
|
||||
for (CodegenParameter p : op.allParams) {
|
||||
if (p.required != null && p.required) {
|
||||
lastRequired = p;
|
||||
} else {
|
||||
lastOptional = p;
|
||||
}
|
||||
}
|
||||
for (CodegenParameter p : op.allParams) {
|
||||
if (p == lastRequired) {
|
||||
p.vendorExtensions.put("x-codegen-hasMoreRequired", false);
|
||||
} else if (p == lastOptional) {
|
||||
p.vendorExtensions.put("x-codegen-hasMoreOptional", false);
|
||||
} else {
|
||||
p.vendorExtensions.put("x-codegen-hasMoreRequired", true);
|
||||
p.vendorExtensions.put("x-codegen-hasMoreOptional", true);
|
||||
}
|
||||
}
|
||||
op.vendorExtensions.put("x-codegen-hasRequiredParams", lastRequired != null);
|
||||
|
||||
return op;
|
||||
}
|
||||
|
||||
|
||||
private String sanitizePath(String p) {
|
||||
//prefer replace a ', instead of a fuLL URL encode for readability
|
||||
return p.replaceAll("'", "%27");
|
||||
}
|
||||
|
||||
/**
|
||||
* Normalize type by wrapping primitive types with single quotes.
|
||||
*
|
||||
* @param type Primitive type
|
||||
* @return Normalized type
|
||||
*/
|
||||
public String normalizeType(String type) {
|
||||
return type.replaceAll("\\b(Boolean|Integer|Number|String|Date)\\b", "'$1'");
|
||||
}
|
||||
}
|
||||
@@ -38,6 +38,7 @@ public class SwiftCodegen extends DefaultCodegen implements CodegenConfig {
|
||||
public static final String POD_SCREENSHOTS = "podScreenshots";
|
||||
public static final String POD_DOCUMENTATION_URL = "podDocumentationURL";
|
||||
public static final String SWIFT_USE_API_NAMESPACE = "swiftUseApiNamespace";
|
||||
public static final String DEFAULT_POD_AUTHORS = "Swagger Codegen";
|
||||
protected static final String LIBRARY_PROMISE_KIT = "PromiseKit";
|
||||
protected static final String[] RESPONSE_LIBRARIES = { LIBRARY_PROMISE_KIT };
|
||||
protected String projectName = "SwaggerClient";
|
||||
@@ -86,8 +87,10 @@ public class SwiftCodegen extends DefaultCodegen implements CodegenConfig {
|
||||
);
|
||||
defaultIncludes = new HashSet<String>(
|
||||
Arrays.asList(
|
||||
"NSData",
|
||||
"NSDate",
|
||||
"NSURL", // for file
|
||||
"NSUUID",
|
||||
"Array",
|
||||
"Dictionary",
|
||||
"Set",
|
||||
@@ -127,10 +130,9 @@ public class SwiftCodegen extends DefaultCodegen implements CodegenConfig {
|
||||
typeMapping.put("double", "Double");
|
||||
typeMapping.put("object", "AnyObject");
|
||||
typeMapping.put("file", "NSURL");
|
||||
//TODO binary should be mapped to byte array
|
||||
// mapped to String as a workaround
|
||||
typeMapping.put("binary", "String");
|
||||
typeMapping.put("ByteArray", "String");
|
||||
typeMapping.put("binary", "NSData");
|
||||
typeMapping.put("ByteArray", "NSData");
|
||||
typeMapping.put("UUID", "NSUUID");
|
||||
|
||||
importMapping = new HashMap<String, String>();
|
||||
|
||||
@@ -191,6 +193,10 @@ public class SwiftCodegen extends DefaultCodegen implements CodegenConfig {
|
||||
}
|
||||
additionalProperties.put(SWIFT_USE_API_NAMESPACE, swiftUseApiNamespace);
|
||||
|
||||
if (!additionalProperties.containsKey(POD_AUTHORS)) {
|
||||
additionalProperties.put(POD_AUTHORS, DEFAULT_POD_AUTHORS);
|
||||
}
|
||||
|
||||
supportingFiles.add(new SupportingFile("Podspec.mustache", "", projectName + ".podspec"));
|
||||
supportingFiles.add(new SupportingFile("Cartfile.mustache", "", "Cartfile"));
|
||||
supportingFiles.add(new SupportingFile("APIHelper.mustache", sourceFolder, "APIHelper.swift"));
|
||||
@@ -251,6 +257,11 @@ public class SwiftCodegen extends DefaultCodegen implements CodegenConfig {
|
||||
return toModelName(type);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isDataTypeBinary(final String dataType) {
|
||||
return dataType != null && dataType.equals("NSData");
|
||||
}
|
||||
|
||||
/**
|
||||
* Output the proper model name (capitalized)
|
||||
*
|
||||
@@ -336,10 +347,10 @@ public class SwiftCodegen extends DefaultCodegen implements CodegenConfig {
|
||||
List<Map<String, String>> swiftEnums = new ArrayList<Map<String, String>>();
|
||||
List<String> values = (List<String>) codegenProperty.allowableValues.get("values");
|
||||
|
||||
for (String value : values) {
|
||||
for (Object value : values) {
|
||||
Map<String, String> map = new HashMap<String, String>();
|
||||
map.put("enum", toSwiftyEnumName(value));
|
||||
map.put("raw", value);
|
||||
map.put("enum", toSwiftyEnumName(String.valueOf(value)));
|
||||
map.put("raw", String.valueOf(value));
|
||||
swiftEnums.add(map);
|
||||
}
|
||||
codegenProperty.allowableValues.put("values", swiftEnums);
|
||||
|
||||
@@ -15,6 +15,11 @@ public class TypeScriptFetchClientCodegen extends AbstractTypeScriptClientCodege
|
||||
|
||||
public TypeScriptFetchClientCodegen() {
|
||||
super();
|
||||
|
||||
// clear import mapping (from default generator) as TS does not use it
|
||||
// at the moment
|
||||
importMapping.clear();
|
||||
|
||||
outputFolder = "generated-code/typescript-fetch";
|
||||
embeddedTemplateDir = templateDir = "TypeScript-Fetch";
|
||||
this.cliOptions.add(new CliOption(NPM_NAME, "The name under which you want to publish generated npm package"));
|
||||
|
||||
@@ -26,6 +26,11 @@ public class TypeScriptNodeClientCodegen extends AbstractTypeScriptClientCodegen
|
||||
|
||||
public TypeScriptNodeClientCodegen() {
|
||||
super();
|
||||
|
||||
// clear import mapping (from default generator) as TS does not use it
|
||||
// at the moment
|
||||
importMapping.clear();
|
||||
|
||||
outputFolder = "generated-code/typescript-node";
|
||||
embeddedTemplateDir = templateDir = "typescript-node";
|
||||
|
||||
|
||||
@@ -27,7 +27,7 @@ public interface {{classname}} extends ApiClient.Api {
|
||||
@Headers({
|
||||
"Content-type: {{vendorExtensions.x-contentType}}",
|
||||
"Accept: {{vendorExtensions.x-accepts}}",{{#headerParams}}
|
||||
"{{paramName}}: {{=<% %>=}}{<%paramName%>}<%={{ }}=%>"{{#hasMore}},
|
||||
"{{baseName}}: {{=<% %>=}}{<%paramName%>}<%={{ }}=%>"{{#hasMore}},
|
||||
{{/hasMore}}{{/headerParams}}
|
||||
})
|
||||
{{#returnType}}{{{returnType}}} {{/returnType}}{{^returnType}}void {{/returnType}}{{nickname}}({{#allParams}}{{^isBodyParam}}@Param("{{paramName}}") {{/isBodyParam}}{{{dataType}}} {{paramName}}{{#hasMore}}, {{/hasMore}}{{/allParams}});
|
||||
|
||||
@@ -498,8 +498,15 @@ public class ApiClient {
|
||||
* Deserialize response body to Java object according to the Content-Type.
|
||||
*/
|
||||
public <T> T deserialize(Response response, GenericType<T> returnType) throws ApiException {
|
||||
// Handle file downloading.
|
||||
if (returnType.equals(File.class)) {
|
||||
if (response == null || returnType == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if ("byte[]".equals(returnType.toString())) {
|
||||
// Handle binary response (byte array).
|
||||
return (T) response.readEntity(byte[].class);
|
||||
} else if (returnType.equals(File.class)) {
|
||||
// Handle file downloading.
|
||||
@SuppressWarnings("unchecked")
|
||||
T file = (T) downloadFileFromResponse(response);
|
||||
return file;
|
||||
|
||||
@@ -1,3 +1,7 @@
|
||||
{{#jackson}}
|
||||
import com.fasterxml.jackson.annotation.JsonCreator;
|
||||
{{/jackson}}
|
||||
|
||||
/**
|
||||
* {{^description}}Gets or Sets {{{name}}}{{/description}}{{#description}}{{{description}}}{{/description}}
|
||||
*/
|
||||
@@ -24,4 +28,16 @@ public enum {{#datatypeWithEnum}}{{{.}}}{{/datatypeWithEnum}}{{^datatypeWithEnum
|
||||
public String toString() {
|
||||
return String.valueOf(value);
|
||||
}
|
||||
{{#jackson}}
|
||||
|
||||
@JsonCreator
|
||||
public static {{#datatypeWithEnum}}{{{.}}}{{/datatypeWithEnum}}{{^datatypeWithEnum}}{{{classname}}}{{/datatypeWithEnum}} fromValue(String text) {
|
||||
for ({{#datatypeWithEnum}}{{{.}}}{{/datatypeWithEnum}}{{^datatypeWithEnum}}{{{classname}}}{{/datatypeWithEnum}} b : {{#datatypeWithEnum}}{{{.}}}{{/datatypeWithEnum}}{{^datatypeWithEnum}}{{{classname}}}{{/datatypeWithEnum}}.values()) {
|
||||
if (String.valueOf(b.value).equals(text)) {
|
||||
return b;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
{{/jackson}}
|
||||
}
|
||||
|
||||
@@ -30,4 +30,16 @@
|
||||
public String toString() {
|
||||
return String.valueOf(value);
|
||||
}
|
||||
{{#jackson}}
|
||||
|
||||
@JsonCreator
|
||||
public static {{#datatypeWithEnum}}{{{.}}}{{/datatypeWithEnum}}{{^datatypeWithEnum}}{{{classname}}}{{/datatypeWithEnum}} fromValue(String text) {
|
||||
for ({{#datatypeWithEnum}}{{{.}}}{{/datatypeWithEnum}}{{^datatypeWithEnum}}{{{classname}}}{{/datatypeWithEnum}} b : {{#datatypeWithEnum}}{{{.}}}{{/datatypeWithEnum}}{{^datatypeWithEnum}}{{{classname}}}{{/datatypeWithEnum}}.values()) {
|
||||
if (String.valueOf(b.value).equals(text)) {
|
||||
return b;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
{{/jackson}}
|
||||
}
|
||||
|
||||
@@ -32,6 +32,20 @@ public class {{classname}} {{#parent}}extends {{{parent}}}{{/parent}} {{#seriali
|
||||
this.{{name}} = {{name}};
|
||||
return this;
|
||||
}
|
||||
{{#isListContainer}}
|
||||
|
||||
public {{classname}} add{{nameInCamelCase}}Item({{{items.datatypeWithEnum}}} {{name}}Item) {
|
||||
this.{{name}}.add({{name}}Item);
|
||||
return this;
|
||||
}
|
||||
{{/isListContainer}}
|
||||
{{#isMapContainer}}
|
||||
|
||||
public {{classname}} put{{nameInCamelCase}}Item(String key, {{{items.datatypeWithEnum}}} {{name}}Item) {
|
||||
this.{{name}}.put(key, {{name}}Item);
|
||||
return this;
|
||||
}
|
||||
{{/isMapContainer}}
|
||||
|
||||
{{/isReadOnly}}
|
||||
/**
|
||||
|
||||
@@ -107,6 +107,11 @@
|
||||
{{/java8}}
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-javadoc-plugin</artifactId>
|
||||
<version>2.10.4</version>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
<dependencies>
|
||||
|
||||
@@ -5,6 +5,7 @@ import {{package}}.{{classname}}Service;
|
||||
import {{package}}.factories.{{classname}}ServiceFactory;
|
||||
|
||||
import io.swagger.annotations.ApiParam;
|
||||
import io.swagger.jaxrs.*;
|
||||
|
||||
{{#imports}}import {{import}};
|
||||
{{/imports}}
|
||||
|
||||
@@ -1,17 +1,33 @@
|
||||
/**
|
||||
* {{^description}}Gets or Sets {{{name}}}{{/description}}{{#description}}{{{description}}}{{/description}}
|
||||
*/
|
||||
public enum {{#datatypeWithEnum}}{{{.}}}{{/datatypeWithEnum}}{{^datatypeWithEnum}}{{classname}}{{/datatypeWithEnum}} {
|
||||
{{#gson}}
|
||||
{{#allowableValues}}
|
||||
{{#enumVars}}
|
||||
@SerializedName({{#isInteger}}"{{/isInteger}}{{#isDouble}}"{{/isDouble}}{{#isLong}}"{{/isLong}}{{#isFloat}}"{{/isFloat}}{{{value}}}{{#isInteger}}"{{/isInteger}}{{#isDouble}}"{{/isDouble}}{{#isLong}}"{{/isLong}}{{#isFloat}}"{{/isFloat}})
|
||||
{{{name}}}({{{value}}}){{^-last}},
|
||||
{{/-last}}{{#-last}};{{/-last}}
|
||||
{{/enumVars}}
|
||||
{{/allowableValues}}
|
||||
{{/gson}}
|
||||
{{^gson}}
|
||||
{{#allowableValues}}
|
||||
{{#enumVars}}
|
||||
{{{name}}}({{{value}}}){{^-last}},
|
||||
{{/-last}}{{#-last}};{{/-last}}
|
||||
{{/enumVars}}
|
||||
{{/allowableValues}}
|
||||
{{/gson}}
|
||||
|
||||
public enum {{{datatypeWithEnum}}} {
|
||||
{{#allowableValues}}{{#enumVars}}{{{name}}}({{{value}}}){{^-last}},
|
||||
{{/-last}}{{#-last}};{{/-last}}{{/enumVars}}{{/allowableValues}}
|
||||
private {{{datatype}}} value;
|
||||
|
||||
private String value;
|
||||
|
||||
{{{datatypeWithEnum}}}(String value) {
|
||||
{{#datatypeWithEnum}}{{{.}}}{{/datatypeWithEnum}}{{^datatypeWithEnum}}{{classname}}{{/datatypeWithEnum}}({{{datatype}}} value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
@Override
|
||||
@JsonValue
|
||||
public String toString() {
|
||||
return value;
|
||||
return String.valueOf(value);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,3 +1,27 @@
|
||||
public enum {{classname}} {
|
||||
{{#allowableValues}}{{.}}{{^-last}}, {{/-last}}{{/allowableValues}}
|
||||
}
|
||||
/**
|
||||
* {{^description}}Gets or Sets {{{name}}}{{/description}}{{#description}}{{{description}}}{{/description}}
|
||||
*/
|
||||
public enum {{#datatypeWithEnum}}{{{.}}}{{/datatypeWithEnum}}{{^datatypeWithEnum}}{{{classname}}}{{/datatypeWithEnum}} {
|
||||
{{#gson}}
|
||||
{{#allowableValues}}{{#enumVars}}
|
||||
@SerializedName({{#isInteger}}"{{/isInteger}}{{#isDouble}}"{{/isDouble}}{{#isLong}}"{{/isLong}}{{#isFloat}}"{{/isFloat}}{{{value}}}{{#isInteger}}"{{/isInteger}}{{#isDouble}}"{{/isDouble}}{{#isLong}}"{{/isLong}}{{#isFloat}}"{{/isFloat}})
|
||||
{{{name}}}({{{value}}}){{^-last}},
|
||||
{{/-last}}{{#-last}};{{/-last}}{{/enumVars}}{{/allowableValues}}
|
||||
{{/gson}}
|
||||
{{^gson}}
|
||||
{{#allowableValues}}{{#enumVars}}
|
||||
{{{name}}}({{{value}}}){{^-last}},
|
||||
{{/-last}}{{#-last}};{{/-last}}{{/enumVars}}{{/allowableValues}}
|
||||
{{/gson}}
|
||||
|
||||
private {{{dataType}}} value;
|
||||
|
||||
{{#datatypeWithEnum}}{{{.}}}{{/datatypeWithEnum}}{{^datatypeWithEnum}}{{{classname}}}{{/datatypeWithEnum}}({{{dataType}}} value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return String.valueOf(value);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -36,6 +36,7 @@
|
||||
<webAppSourceDirectory>target/${project.artifactId}-${project.version}</webAppSourceDirectory>
|
||||
<stopPort>8079</stopPort>
|
||||
<stopKey>stopit</stopKey>
|
||||
<stopWait>10</stopWait>
|
||||
<httpConnector>
|
||||
<port>{{serverPort}}</port>
|
||||
<idleTimeout>60000</idleTimeout>
|
||||
|
||||
@@ -1,53 +1,102 @@
|
||||
{{#description}}@ApiModel(description = "{{{description}}}"){{/description}}
|
||||
/**
|
||||
* {{#description}}{{.}}{{/description}}{{^description}}{{classname}}{{/description}}
|
||||
*/{{#description}}
|
||||
@ApiModel(description = "{{{description}}}"){{/description}}
|
||||
{{>generatedAnnotation}}
|
||||
public class {{classname}} {{#parent}}extends {{{parent}}}{{/parent}} {{#serializableModel}}implements Serializable{{/serializableModel}} {
|
||||
{{#vars}}{{#isEnum}}
|
||||
|
||||
{{>enumClass}}{{/isEnum}}{{#items.isEnum}}{{#items}}
|
||||
|
||||
{{>enumClass}}{{/items}}{{/items.isEnum}}
|
||||
private {{{datatypeWithEnum}}} {{name}} = {{{defaultValue}}};{{/vars}}
|
||||
|
||||
{{#vars}}
|
||||
/**{{#description}}
|
||||
* {{{description}}}{{/description}}{{#minimum}}
|
||||
* minimum: {{minimum}}{{/minimum}}{{#maximum}}
|
||||
* maximum: {{maximum}}{{/maximum}}
|
||||
**/
|
||||
{{#isEnum}}
|
||||
{{^isContainer}}
|
||||
{{>enumClass}}
|
||||
{{/isContainer}}
|
||||
{{/isEnum}}
|
||||
{{#items.isEnum}}
|
||||
{{#items}}
|
||||
{{^isContainer}}
|
||||
{{>enumClass}}
|
||||
{{/isContainer}}
|
||||
{{/items}}
|
||||
{{/items.isEnum}}
|
||||
{{#jackson}}
|
||||
@JsonProperty("{{baseName}}")
|
||||
{{/jackson}}
|
||||
{{#gson}}
|
||||
@SerializedName("{{baseName}}")
|
||||
{{/gson}}
|
||||
private {{{datatypeWithEnum}}} {{name}} = {{{defaultValue}}};
|
||||
|
||||
{{/vars}}
|
||||
{{#vars}}
|
||||
{{^isReadOnly}}
|
||||
public {{classname}} {{name}}({{{datatypeWithEnum}}} {{name}}) {
|
||||
this.{{name}} = {{name}};
|
||||
return this;
|
||||
}
|
||||
{{#isListContainer}}
|
||||
|
||||
{{#vendorExtensions.extraAnnotation}}{{vendorExtensions.extraAnnotation}}{{/vendorExtensions.extraAnnotation}}
|
||||
public {{classname}} add{{nameInCamelCase}}Item({{{items.datatypeWithEnum}}} {{name}}Item) {
|
||||
this.{{name}}.add({{name}}Item);
|
||||
return this;
|
||||
}
|
||||
{{/isListContainer}}
|
||||
{{#isMapContainer}}
|
||||
|
||||
public {{classname}} put{{nameInCamelCase}}Item(String key, {{{items.datatypeWithEnum}}} {{name}}Item) {
|
||||
this.{{name}}.put(key, {{name}}Item);
|
||||
return this;
|
||||
}
|
||||
{{/isMapContainer}}
|
||||
|
||||
{{/isReadOnly}}
|
||||
/**
|
||||
{{#description}}
|
||||
* {{{description}}}
|
||||
{{/description}}
|
||||
{{^description}}
|
||||
* Get {{name}}
|
||||
{{/description}}
|
||||
{{#minimum}}
|
||||
* minimum: {{minimum}}
|
||||
{{/minimum}}
|
||||
{{#maximum}}
|
||||
* maximum: {{maximum}}
|
||||
{{/maximum}}
|
||||
* @return {{name}}
|
||||
**/
|
||||
{{#vendorExtensions.extraAnnotation}}
|
||||
{{vendorExtensions.extraAnnotation}}
|
||||
{{/vendorExtensions.extraAnnotation}}
|
||||
@ApiModelProperty({{#example}}example = "{{example}}", {{/example}}{{#required}}required = {{required}}, {{/required}}value = "{{{description}}}")
|
||||
@JsonProperty("{{baseName}}")
|
||||
public {{{datatypeWithEnum}}} {{getter}}() {
|
||||
return {{name}};
|
||||
}
|
||||
{{^isReadOnly}}
|
||||
|
||||
public void {{setter}}({{{datatypeWithEnum}}} {{name}}) {
|
||||
this.{{name}} = {{name}};
|
||||
}
|
||||
{{/isReadOnly}}
|
||||
|
||||
{{/vars}}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
public boolean equals(java.lang.Object o) {
|
||||
if (this == o) {
|
||||
return true;
|
||||
}
|
||||
if (o == null || getClass() != o.getClass()) {
|
||||
return false;
|
||||
}
|
||||
{{classname}} {{classVarName}} = ({{classname}}) o;{{#hasVars}}
|
||||
return {{#vars}}Objects.equals({{name}}, {{classVarName}}.{{name}}){{#hasMore}} &&
|
||||
{{/hasMore}}{{^hasMore}};{{/hasMore}}{{/vars}}{{/hasVars}}{{^hasVars}}
|
||||
}{{#hasVars}}
|
||||
{{classname}} {{classVarName}} = ({{classname}}) o;
|
||||
return {{#vars}}Objects.equals(this.{{name}}, {{classVarName}}.{{name}}){{#hasMore}} &&
|
||||
{{/hasMore}}{{/vars}}{{#parent}} &&
|
||||
super.equals(o){{/parent}};{{/hasVars}}{{^hasVars}}
|
||||
return true;{{/hasVars}}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash({{#vars}}{{name}}{{#hasMore}}, {{/hasMore}}{{/vars}});
|
||||
return Objects.hash({{#vars}}{{name}}{{#hasMore}}, {{/hasMore}}{{/vars}}{{#parent}}{{#hasVars}}, {{/hasVars}}super.hashCode(){{/parent}});
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -64,7 +113,7 @@ public class {{classname}} {{#parent}}extends {{{parent}}}{{/parent}} {{#seriali
|
||||
* Convert the given object to string with each line indented by 4 spaces
|
||||
* (except the first line).
|
||||
*/
|
||||
private String toIndentedString(Object o) {
|
||||
private String toIndentedString(java.lang.Object o) {
|
||||
if (o == null) {
|
||||
return "null";
|
||||
}
|
||||
|
||||
@@ -36,6 +36,7 @@
|
||||
<webAppSourceDirectory>target/${project.artifactId}-${project.version}</webAppSourceDirectory>
|
||||
<stopPort>8079</stopPort>
|
||||
<stopKey>stopit</stopKey>
|
||||
<stopWait>10</stopWait>
|
||||
<httpConnector>
|
||||
<port>{{serverPort}}</port>
|
||||
<idleTimeout>60000</idleTimeout>
|
||||
|
||||
@@ -1 +1 @@
|
||||
{{#isBodyParam}}@ApiParam(value = "{{{description}}}" {{#required}},required=true{{/required}} {{#allowableValues}}, allowableValues="{{{allowableValues}}}"{{/allowableValues}}{{#defaultValue}}, defaultValue="{{{defaultValue}}}"{{/defaultValue}}) @RequestBody {{{dataType}}} {{paramName}}{{/isBodyParam}}
|
||||
{{#isBodyParam}}@ApiParam(value = "{{{description}}}" {{#required}},required=true{{/required}} {{^isContainer}}{{#allowableValues}}, allowableValues="{{{allowableValues}}}"{{/allowableValues}}{{/isContainer}}{{#defaultValue}}, defaultValue="{{{defaultValue}}}"{{/defaultValue}}) @RequestBody {{{dataType}}} {{paramName}}{{/isBodyParam}}
|
||||
|
||||
@@ -1,17 +1,33 @@
|
||||
/**
|
||||
* {{^description}}Gets or Sets {{{name}}}{{/description}}{{#description}}{{{description}}}{{/description}}
|
||||
*/
|
||||
public enum {{#datatypeWithEnum}}{{{.}}}{{/datatypeWithEnum}}{{^datatypeWithEnum}}{{classname}}{{/datatypeWithEnum}} {
|
||||
{{#gson}}
|
||||
{{#allowableValues}}
|
||||
{{#enumVars}}
|
||||
@SerializedName({{#isInteger}}"{{/isInteger}}{{#isDouble}}"{{/isDouble}}{{#isLong}}"{{/isLong}}{{#isFloat}}"{{/isFloat}}{{{value}}}{{#isInteger}}"{{/isInteger}}{{#isDouble}}"{{/isDouble}}{{#isLong}}"{{/isLong}}{{#isFloat}}"{{/isFloat}})
|
||||
{{{name}}}({{{value}}}){{^-last}},
|
||||
{{/-last}}{{#-last}};{{/-last}}
|
||||
{{/enumVars}}
|
||||
{{/allowableValues}}
|
||||
{{/gson}}
|
||||
{{^gson}}
|
||||
{{#allowableValues}}
|
||||
{{#enumVars}}
|
||||
{{{name}}}({{{value}}}){{^-last}},
|
||||
{{/-last}}{{#-last}};{{/-last}}
|
||||
{{/enumVars}}
|
||||
{{/allowableValues}}
|
||||
{{/gson}}
|
||||
|
||||
public enum {{{datatypeWithEnum}}} {
|
||||
{{#allowableValues}}{{#enumVars}}{{{name}}}({{{value}}}){{^-last}},
|
||||
{{/-last}}{{#-last}};{{/-last}}{{/enumVars}}{{/allowableValues}}
|
||||
private {{{datatype}}} value;
|
||||
|
||||
private String value;
|
||||
|
||||
{{{datatypeWithEnum}}}(String value) {
|
||||
{{#datatypeWithEnum}}{{{.}}}{{/datatypeWithEnum}}{{^datatypeWithEnum}}{{classname}}{{/datatypeWithEnum}}({{{datatype}}} value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
@Override
|
||||
@JsonValue
|
||||
public String toString() {
|
||||
return value;
|
||||
return String.valueOf(value);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,3 +1,27 @@
|
||||
public enum {{classname}} {
|
||||
{{#allowableValues}}{{.}}{{^-last}}, {{/-last}}{{/allowableValues}}
|
||||
}
|
||||
/**
|
||||
* {{^description}}Gets or Sets {{{name}}}{{/description}}{{#description}}{{{description}}}{{/description}}
|
||||
*/
|
||||
public enum {{#datatypeWithEnum}}{{{.}}}{{/datatypeWithEnum}}{{^datatypeWithEnum}}{{{classname}}}{{/datatypeWithEnum}} {
|
||||
{{#gson}}
|
||||
{{#allowableValues}}{{#enumVars}}
|
||||
@SerializedName({{#isInteger}}"{{/isInteger}}{{#isDouble}}"{{/isDouble}}{{#isLong}}"{{/isLong}}{{#isFloat}}"{{/isFloat}}{{{value}}}{{#isInteger}}"{{/isInteger}}{{#isDouble}}"{{/isDouble}}{{#isLong}}"{{/isLong}}{{#isFloat}}"{{/isFloat}})
|
||||
{{{name}}}({{{value}}}){{^-last}},
|
||||
{{/-last}}{{#-last}};{{/-last}}{{/enumVars}}{{/allowableValues}}
|
||||
{{/gson}}
|
||||
{{^gson}}
|
||||
{{#allowableValues}}{{#enumVars}}
|
||||
{{{name}}}({{{value}}}){{^-last}},
|
||||
{{/-last}}{{#-last}};{{/-last}}{{/enumVars}}{{/allowableValues}}
|
||||
{{/gson}}
|
||||
|
||||
private {{{dataType}}} value;
|
||||
|
||||
{{#datatypeWithEnum}}{{{.}}}{{/datatypeWithEnum}}{{^datatypeWithEnum}}{{{classname}}}{{/datatypeWithEnum}}({{{dataType}}} value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return String.valueOf(value);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1 +1 @@
|
||||
{{#isFormParam}}{{#notFile}}@ApiParam(value = "{{{description}}}"{{#required}}, required=true{{/required}} {{#allowableValues}}, allowableValues="{{{allowableValues}}}"{{/allowableValues}}{{#defaultValue}}, defaultValue="{{{defaultValue}}}"{{/defaultValue}}) @RequestPart(value="{{paramName}}"{{#required}}, required=true{{/required}}{{^required}}, required=false{{/required}}) {{{dataType}}} {{paramName}}{{/notFile}}{{#isFile}}@ApiParam(value = "file detail") @RequestPart("file") MultipartFile {{baseName}}{{/isFile}}{{/isFormParam}}
|
||||
{{#isFormParam}}{{#notFile}}@ApiParam(value = "{{{description}}}"{{#required}}, required=true{{/required}} {{^isContainer}}{{#allowableValues}}, allowableValues="{{{allowableValues}}}"{{/allowableValues}}{{/isContainer}}{{#defaultValue}}, defaultValue="{{{defaultValue}}}"{{/defaultValue}}) @RequestPart(value="{{paramName}}"{{#required}}, required=true{{/required}}{{^required}}, required=false{{/required}}) {{{dataType}}} {{paramName}}{{/notFile}}{{#isFile}}@ApiParam(value = "file detail") @RequestPart("file") MultipartFile {{baseName}}{{/isFile}}{{/isFormParam}}
|
||||
|
||||
@@ -1 +1 @@
|
||||
{{#isHeaderParam}}@ApiParam(value = "{{{description}}}" {{#required}},required=true{{/required}} {{#allowableValues}}, allowableValues="{{{allowableValues}}}"{{/allowableValues}}{{#defaultValue}}, defaultValue="{{{defaultValue}}}"{{/defaultValue}}) @RequestHeader(value="{{baseName}}", required={{#required}}true{{/required}}{{^required}}false{{/required}}) {{{dataType}}} {{paramName}}{{/isHeaderParam}}
|
||||
{{#isHeaderParam}}@ApiParam(value = "{{{description}}}" {{#required}},required=true{{/required}} {{^isContainer}}{{#allowableValues}}, allowableValues="{{{allowableValues}}}"{{/allowableValues}}{{/isContainer}}{{#defaultValue}}, defaultValue="{{{defaultValue}}}"{{/defaultValue}}) @RequestHeader(value="{{baseName}}", required={{#required}}true{{/required}}{{^required}}false{{/required}}) {{{dataType}}} {{paramName}}{{/isHeaderParam}}
|
||||
|
||||
@@ -3,6 +3,8 @@ package {{package}};
|
||||
import org.springframework.cloud.netflix.feign.FeignClient;
|
||||
import {{configPackage}}.ClientConfiguration;
|
||||
|
||||
@FeignClient(name="${ {{{title}}}.name:{{{title}}}}", url="${ {{{title}}}.url:{{{basePath}}}}", configuration = ClientConfiguration.class)
|
||||
{{=<% %>=}}
|
||||
@FeignClient(name="${<%title%>.name:<%title%>}", url="${<%title%>.url:<%basePath%>}", configuration = ClientConfiguration.class)
|
||||
<%={{ }}=%>
|
||||
public interface {{classname}}Client extends {{classname}} {
|
||||
}
|
||||
@@ -1,53 +1,102 @@
|
||||
{{#description}}@ApiModel(description = "{{{description}}}"){{/description}}
|
||||
/**
|
||||
* {{#description}}{{.}}{{/description}}{{^description}}{{classname}}{{/description}}
|
||||
*/{{#description}}
|
||||
@ApiModel(description = "{{{description}}}"){{/description}}
|
||||
{{>generatedAnnotation}}
|
||||
public class {{classname}} {{#parent}}extends {{{parent}}}{{/parent}} {{#serializableModel}}implements Serializable{{/serializableModel}} {
|
||||
{{#vars}}{{#isEnum}}
|
||||
|
||||
{{>enumClass}}{{/isEnum}}{{#items.isEnum}}{{#items}}
|
||||
|
||||
{{>enumClass}}{{/items}}{{/items.isEnum}}
|
||||
private {{{datatypeWithEnum}}} {{name}} = {{{defaultValue}}};{{/vars}}
|
||||
|
||||
{{#vars}}
|
||||
/**{{#description}}
|
||||
* {{{description}}}{{/description}}{{#minimum}}
|
||||
* minimum: {{minimum}}{{/minimum}}{{#maximum}}
|
||||
* maximum: {{maximum}}{{/maximum}}
|
||||
**/
|
||||
{{#isEnum}}
|
||||
{{^isContainer}}
|
||||
{{>enumClass}}
|
||||
{{/isContainer}}
|
||||
{{/isEnum}}
|
||||
{{#items.isEnum}}
|
||||
{{#items}}
|
||||
{{^isContainer}}
|
||||
{{>enumClass}}
|
||||
{{/isContainer}}
|
||||
{{/items}}
|
||||
{{/items.isEnum}}
|
||||
{{#jackson}}
|
||||
@JsonProperty("{{baseName}}")
|
||||
{{/jackson}}
|
||||
{{#gson}}
|
||||
@SerializedName("{{baseName}}")
|
||||
{{/gson}}
|
||||
private {{{datatypeWithEnum}}} {{name}} = {{{defaultValue}}};
|
||||
|
||||
{{/vars}}
|
||||
{{#vars}}
|
||||
{{^isReadOnly}}
|
||||
public {{classname}} {{name}}({{{datatypeWithEnum}}} {{name}}) {
|
||||
this.{{name}} = {{name}};
|
||||
return this;
|
||||
}
|
||||
{{#isListContainer}}
|
||||
|
||||
{{#vendorExtensions.extraAnnotation}}{{vendorExtensions.extraAnnotation}}{{/vendorExtensions.extraAnnotation}}
|
||||
public {{classname}} add{{nameInCamelCase}}Item({{{items.datatypeWithEnum}}} {{name}}Item) {
|
||||
this.{{name}}.add({{name}}Item);
|
||||
return this;
|
||||
}
|
||||
{{/isListContainer}}
|
||||
{{#isMapContainer}}
|
||||
|
||||
public {{classname}} put{{nameInCamelCase}}Item(String key, {{{items.datatypeWithEnum}}} {{name}}Item) {
|
||||
this.{{name}}.put(key, {{name}}Item);
|
||||
return this;
|
||||
}
|
||||
{{/isMapContainer}}
|
||||
|
||||
{{/isReadOnly}}
|
||||
/**
|
||||
{{#description}}
|
||||
* {{{description}}}
|
||||
{{/description}}
|
||||
{{^description}}
|
||||
* Get {{name}}
|
||||
{{/description}}
|
||||
{{#minimum}}
|
||||
* minimum: {{minimum}}
|
||||
{{/minimum}}
|
||||
{{#maximum}}
|
||||
* maximum: {{maximum}}
|
||||
{{/maximum}}
|
||||
* @return {{name}}
|
||||
**/
|
||||
{{#vendorExtensions.extraAnnotation}}
|
||||
{{vendorExtensions.extraAnnotation}}
|
||||
{{/vendorExtensions.extraAnnotation}}
|
||||
@ApiModelProperty({{#example}}example = "{{example}}", {{/example}}{{#required}}required = {{required}}, {{/required}}value = "{{{description}}}")
|
||||
@JsonProperty("{{baseName}}")
|
||||
public {{{datatypeWithEnum}}} {{getter}}() {
|
||||
return {{name}};
|
||||
}
|
||||
{{^isReadOnly}}
|
||||
|
||||
public void {{setter}}({{{datatypeWithEnum}}} {{name}}) {
|
||||
this.{{name}} = {{name}};
|
||||
}
|
||||
{{/isReadOnly}}
|
||||
|
||||
{{/vars}}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
public boolean equals(java.lang.Object o) {
|
||||
if (this == o) {
|
||||
return true;
|
||||
}
|
||||
if (o == null || getClass() != o.getClass()) {
|
||||
return false;
|
||||
}
|
||||
{{classname}} {{classVarName}} = ({{classname}}) o;{{#hasVars}}
|
||||
return {{#vars}}Objects.equals({{name}}, {{classVarName}}.{{name}}){{#hasMore}} &&
|
||||
{{/hasMore}}{{^hasMore}};{{/hasMore}}{{/vars}}{{/hasVars}}{{^hasVars}}
|
||||
}{{#hasVars}}
|
||||
{{classname}} {{classVarName}} = ({{classname}}) o;
|
||||
return {{#vars}}Objects.equals(this.{{name}}, {{classVarName}}.{{name}}){{#hasMore}} &&
|
||||
{{/hasMore}}{{/vars}}{{#parent}} &&
|
||||
super.equals(o){{/parent}};{{/hasVars}}{{^hasVars}}
|
||||
return true;{{/hasVars}}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash({{#vars}}{{name}}{{#hasMore}}, {{/hasMore}}{{/vars}});
|
||||
return Objects.hash({{#vars}}{{name}}{{#hasMore}}, {{/hasMore}}{{/vars}}{{#parent}}{{#hasVars}}, {{/hasVars}}super.hashCode(){{/parent}});
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -64,7 +113,7 @@ public class {{classname}} {{#parent}}extends {{{parent}}}{{/parent}} {{#seriali
|
||||
* Convert the given object to string with each line indented by 4 spaces
|
||||
* (except the first line).
|
||||
*/
|
||||
private String toIndentedString(Object o) {
|
||||
private String toIndentedString(java.lang.Object o) {
|
||||
if (o == null) {
|
||||
return "null";
|
||||
}
|
||||
|
||||
@@ -1 +1 @@
|
||||
{{#isQueryParam}}@ApiParam(value = "{{{description}}}"{{#required}}, required = true{{/required}}{{#allowableValues}}, allowableValues = "{{{allowableValues}}}"{{/allowableValues}}{{#defaultValue}}, defaultValue = "{{{defaultValue}}}"{{/defaultValue}}) @RequestParam(value = "{{paramName}}"{{#required}}, required = true{{/required}}{{^required}}, required = false{{/required}}{{#defaultValue}}, defaultValue="{{{defaultValue}}}"{{/defaultValue}}) {{{dataType}}} {{paramName}}{{/isQueryParam}}
|
||||
{{#isQueryParam}}@ApiParam(value = "{{{description}}}"{{#required}}, required = true{{/required}}{{^isContainer}}{{#allowableValues}}, allowableValues = "{{{allowableValues}}}"{{/allowableValues}}{{/isContainer}}{{#defaultValue}}, defaultValue = "{{{defaultValue}}}"{{/defaultValue}}) @RequestParam(value = "{{paramName}}"{{#required}}, required = true{{/required}}{{^required}}, required = false{{/required}}{{#defaultValue}}, defaultValue="{{{defaultValue}}}"{{/defaultValue}}) {{{dataType}}} {{paramName}}{{/isQueryParam}}
|
||||
|
||||
@@ -133,7 +133,7 @@
|
||||
{{#emitJSDoc}} /**
|
||||
* Checks whether the given parameter value represents file-like content.
|
||||
* @param param The parameter to check.
|
||||
* @returns {Boolean} <code>true</code> if <code>param</code> represents a file.
|
||||
* @returns {Boolean} <code>true</code> if <code>param</code> represents a file.
|
||||
*/
|
||||
{{/emitJSDoc}} exports.prototype.isFileParam = function(param) {
|
||||
// fs.ReadStream in Node.js (but not in runtime like browserify)
|
||||
@@ -185,7 +185,7 @@
|
||||
|
||||
{{#emitJSDoc}} /**
|
||||
* Enumeration of collection format separator strategies.
|
||||
* @enum {String}
|
||||
* @enum {String}
|
||||
* @readonly
|
||||
*/
|
||||
exports.CollectionFormatEnum = {
|
||||
@@ -330,8 +330,8 @@
|
||||
* @param {Array.<String>} accepts An array of acceptable response MIME types.
|
||||
* @param {(String|Array|ObjectFunction)} returnType The required type to return; can be a string for simple types or the
|
||||
* constructor for a complex type.{{^usePromises}}
|
||||
* @param {module:{{#invokerPackage}}{{invokerPackage}}/{{/invokerPackage}}ApiClient~callApiCallback} callback The callback function.
|
||||
{{/usePromises}} * @returns {{#usePromises}}{Promise} A Promise object{{/usePromises}}{{^usePromises}}{Object} The SuperAgent request object{{/usePromises}}.
|
||||
* @param {module:{{#invokerPackage}}{{invokerPackage}}/{{/invokerPackage}}ApiClient~callApiCallback} callback The callback function.{{/usePromises}}
|
||||
* @returns {{#usePromises}}{Promise} A {@link https://www.promisejs.org/|Promise} object{{/usePromises}}{{^usePromises}}{Object} The SuperAgent request object{{/usePromises}}.
|
||||
*/
|
||||
{{/emitJSDoc}} exports.prototype.callApi = function callApi(path, httpMethod, pathParams,
|
||||
queryParams, headerParams, formParams, bodyParam, authNames, contentTypes, accepts,
|
||||
|
||||
@@ -58,7 +58,7 @@ Please follow the [installation](#installation) instruction and execute the foll
|
||||
```javascript
|
||||
var {{{moduleName}}} = require('{{{projectName}}}');
|
||||
{{#apiInfo}}{{#apis}}{{#-first}}{{#operations}}{{#operation}}{{#-first}}{{#hasAuthMethods}}
|
||||
var defaultClient = {{{moduleName}}}.ApiClient.default;
|
||||
var defaultClient = {{{moduleName}}}.ApiClient.instance;
|
||||
{{#authMethods}}{{#isBasic}}
|
||||
// Configure HTTP basic authorization: {{{name}}}
|
||||
var {{{name}}} = defaultClient.authentications['{{{name}}}'];
|
||||
|
||||
@@ -38,18 +38,19 @@
|
||||
* Callback function to receive the result of the <operationId> operation.
|
||||
* @callback module:<#invokerPackage><invokerPackage>/</invokerPackage><#apiPackage><apiPackage>/</apiPackage><classname>~<operationId>Callback
|
||||
* @param {String} error Error message, if any.
|
||||
* @param <#vendorExtensions.x-jsdoc-type><&vendorExtensions.x-jsdoc-type> data The data returned by the service call.</vendorExtensions.x-jsdoc-type><^vendorExtensions.x-jsdoc-type>data This operation does not return a value.</vendorExtensions.x-jsdoc-type>
|
||||
* @param <#vendorExtensions.x-jsdoc-type>{<&vendorExtensions.x-jsdoc-type>} data The data returned by the service call.</vendorExtensions.x-jsdoc-type><^vendorExtensions.x-jsdoc-type>data This operation does not return a value.</vendorExtensions.x-jsdoc-type>
|
||||
* @param {String} response The complete HTTP response.
|
||||
*/</usePromises>
|
||||
|
||||
/**<#summary>
|
||||
* <summary></summary><#notes>
|
||||
* <notes></notes><#allParams><#required>
|
||||
* @param <&vendorExtensions.x-jsdoc-type> <paramName> <description></required></allParams><#hasOptionalParams>
|
||||
* @param {<&vendorExtensions.x-jsdoc-type>} <paramName> <description></required></allParams><#hasOptionalParams>
|
||||
* @param {Object} opts Optional parameters<#allParams><^required>
|
||||
* @param <&vendorExtensions.x-jsdoc-type> opts.<paramName> <description><#defaultValue> (default to <.>)</defaultValue></required></allParams></hasOptionalParams><^usePromises>
|
||||
* @param {module:<#invokerPackage><&invokerPackage>/</invokerPackage><#apiPackage><&apiPackage>/</apiPackage><&classname>~<operationId>Callback} callback The callback function, accepting three arguments: error, data, response</usePromises><#returnType>
|
||||
* data is of type: <&vendorExtensions.x-jsdoc-type></returnType>
|
||||
* @param {<&vendorExtensions.x-jsdoc-type>} opts.<paramName> <description><#defaultValue> (default to <.>)</defaultValue></required></allParams></hasOptionalParams><^usePromises>
|
||||
* @param {module:<#invokerPackage><&invokerPackage>/</invokerPackage><#apiPackage><&apiPackage>/</apiPackage><&classname>~<operationId>Callback} callback The callback function, accepting three arguments: error, data, response<#returnType>
|
||||
* data is of type: {@link <&vendorExtensions.x-jsdoc-type>}</returnType></usePromises><#usePromises>
|
||||
* @return {Promise} a {@link https://www.promisejs.org/|Promise}<#returnType>, with data of type {@link <&vendorExtensions.x-jsdoc-type>}</returnType></usePromises>
|
||||
*/
|
||||
</emitJSDoc> this.<operationId> = function(<vendorExtensions.x-codegen-argList>) {<#hasOptionalParams>
|
||||
opts = opts || {};</hasOptionalParams>
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
* @class{{#useInheritance}}{{#parent}}
|
||||
* @extends {{#parentModel}}module:{{#invokerPackage}}{{invokerPackage}}/{{/invokerPackage}}{{#modelPackage}}{{modelPackage}}/{{/modelPackage}}{{classname}}{{/parentModel}}{{^parentModel}}{{#vendorExtensions.x-isArray}}Array{{/vendorExtensions.x-isArray}}{{#vendorExtensions.x-isMap}}Object{{/vendorExtensions.x-isMap}}{{/parentModel}}{{/parent}}{{#interfaces}}
|
||||
* @implements module:{{#invokerPackage}}{{invokerPackage}}/{{/invokerPackage}}{{#modelPackage}}{{modelPackage}}/{{/modelPackage}}{{.}}{{/interfaces}}{{/useInheritance}}{{#vendorExtensions.x-all-required}}
|
||||
* @param {{name}} {{{vendorExtensions.x-jsdoc-type}}} {{#description}}{{{description}}}{{/description}}{{/vendorExtensions.x-all-required}}
|
||||
* @param {{name}} {{=< >=}}{<&vendorExtensions.x-jsdoc-type>}<={{ }}=> {{#description}}{{{description}}}{{/description}}{{/vendorExtensions.x-all-required}}
|
||||
*/
|
||||
{{/emitJSDoc}}
|
||||
var exports = function({{#vendorExtensions.x-all-required}}{{name}}{{^-last}}, {{/-last}}{{/vendorExtensions.x-all-required}}) {
|
||||
@@ -56,7 +56,7 @@
|
||||
{{#emitJSDoc}}
|
||||
/**{{#description}}
|
||||
* {{{description}}}{{/description}}
|
||||
* @member {{{vendorExtensions.x-jsdoc-type}}} {{baseName}}{{#defaultValue}}
|
||||
* @member {{=< >=}}{<&vendorExtensions.x-jsdoc-type>}<={{ }}=> {{baseName}}{{#defaultValue}}
|
||||
* @default {{{defaultValue}}}{{/defaultValue}}
|
||||
*/
|
||||
{{/emitJSDoc}}
|
||||
@@ -66,7 +66,7 @@
|
||||
{{#emitJSDoc}}
|
||||
/**{{#description}}
|
||||
* {{{description}}}{{/description}}
|
||||
* @member {{{vendorExtensions.x-jsdoc-type}}} {{baseName}}{{#defaultValue}}
|
||||
* @member {{=< >=}}{<&vendorExtensions.x-jsdoc-type>}<={{ }}=> {{baseName}}{{#defaultValue}}
|
||||
* @default {{{defaultValue}}}{{/defaultValue}}
|
||||
*/
|
||||
{{/emitJSDoc}}
|
||||
@@ -78,7 +78,7 @@ exports.prototype['{{baseName}}'] = {{#defaultValue}}{{{defaultValue}}}{{/defaul
|
||||
* Returns {{{description}}}{{/description}}{{#minimum}}
|
||||
* minimum: {{minimum}}{{/minimum}}{{#maximum}}
|
||||
* maximum: {{maximum}}{{/maximum}}
|
||||
* @return {{{vendorExtensions.x-jsdoc-type}}}
|
||||
* @return {{=< >=}}{<&vendorExtensions.x-jsdoc-type>}<={{ }}=>
|
||||
*/
|
||||
{{/emitJSDoc}}
|
||||
exports.prototype.{{getter}} = function() {
|
||||
@@ -88,7 +88,7 @@ exports.prototype['{{baseName}}'] = {{#defaultValue}}{{{defaultValue}}}{{/defaul
|
||||
{{#emitJSDoc}}
|
||||
/**{{#description}}
|
||||
* Sets {{{description}}}{{/description}}
|
||||
* @param {{{vendorExtensions.x-jsdoc-type}}} {{name}}{{#description}} {{{description}}}{{/description}}
|
||||
* @param {{=< >=}}{<&vendorExtensions.x-jsdoc-type>}<={{ }}=> {{name}}{{#description}} {{{description}}}{{/description}}
|
||||
*/
|
||||
{{/emitJSDoc}}
|
||||
exports.prototype.{{setter}} = function({{name}}) {
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
io.swagger.codegen.languages.AndroidClientCodegen
|
||||
io.swagger.codegen.languages.AspNet5ServerCodegen
|
||||
io.swagger.codegen.languages.AsyncScalaClientCodegen
|
||||
io.swagger.codegen.languages.ConfluenceWikiGenerator
|
||||
io.swagger.codegen.languages.CSharpClientCodegen
|
||||
io.swagger.codegen.languages.CppRestClientCodegen
|
||||
io.swagger.codegen.languages.DartClientCodegen
|
||||
@@ -35,6 +36,7 @@ io.swagger.codegen.languages.SlimFrameworkServerCodegen
|
||||
io.swagger.codegen.languages.SpringCodegen
|
||||
io.swagger.codegen.languages.StaticDocCodegen
|
||||
io.swagger.codegen.languages.StaticHtmlGenerator
|
||||
io.swagger.codegen.languages.StaticHtml2Generator
|
||||
io.swagger.codegen.languages.SwaggerGenerator
|
||||
io.swagger.codegen.languages.SwaggerYamlGenerator
|
||||
io.swagger.codegen.languages.SwiftCodegen
|
||||
|
||||
@@ -161,7 +161,26 @@ export class {{classname}} extends BaseAPI {
|
||||
return {{classname}}Fp.{{nickname}}({{#hasParams}}params{{/hasParams}})(this.fetch, this.basePath);
|
||||
}
|
||||
{{/operation}}
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* {{classname}} - factory interface{{#description}}
|
||||
* {{&description}}{{/description}}
|
||||
*/
|
||||
export const {{classname}}Factory = function (fetch?: FetchAPI, basePath?: string) {
|
||||
return {
|
||||
{{#operation}}
|
||||
/** {{#summary}}
|
||||
* {{summary}}{{/summary}}{{#notes}}
|
||||
* {{notes}}{{/notes}}{{#allParams}}
|
||||
* @param {{paramName}} {{description}}{{/allParams}}
|
||||
*/
|
||||
{{nickname}}({{#hasParams}}params: { {{#allParams}} {{paramName}}{{^required}}?{{/required}}: {{{dataType}}};{{/allParams}} }{{/hasParams}}) {
|
||||
return {{classname}}Fp.{{nickname}}({{#hasParams}}params{{/hasParams}})(fetch, basePath);
|
||||
},
|
||||
{{/operation}}
|
||||
}
|
||||
};
|
||||
|
||||
{{/operations}}
|
||||
{{/apis}}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
# Swagger Codegen for the {{name}} library
|
||||
|
||||
## Overview
|
||||
This is a boiler-plate project to generate your own client library with Swagger. It's goal is
|
||||
This is a boiler-plate project to generate your own client library with Swagger. Its goal is
|
||||
to get you started with the basic plumbing so you can put in your own logic. It won't work without
|
||||
your changes applied.
|
||||
|
||||
|
||||
@@ -0,0 +1,94 @@
|
||||
h1. {{{appName}}} {{{appDescription}}}
|
||||
|
||||
{{#version}}*Version:* {{{version}}}{{/version}}
|
||||
|
||||
----
|
||||
|
||||
{toc:printable=true|style=square|minLevel=2|maxLevel=3|type=list|outline=false|include=.*}
|
||||
|
||||
h2. Endpoints
|
||||
{{#apiInfo}}{{#apis}}{{#operations}}{{#operation}}
|
||||
h3. {{nickname}}
|
||||
{status:colour=Yellow|title={{httpMethod}}|subtle=false}
|
||||
{code}
|
||||
{{httpMethod}} {{path}}
|
||||
{code}
|
||||
*Summary:* {{summary}}
|
||||
*Description:* {{notes}}
|
||||
|
||||
|
||||
h4. Parameters
|
||||
{{#hasPathParams}}
|
||||
h5. Path Parameters
|
||||
||Name||Description||Required||Default||Pattern||
|
||||
{{#pathParams}}{{>param}}
|
||||
{{/pathParams}}
|
||||
{{/hasPathParams}}
|
||||
|
||||
{{#hasBodyParam}}
|
||||
h5. Body Parameter
|
||||
||Name||Description||Required||Default||Pattern||
|
||||
{{#bodyParams}}{{>param}}
|
||||
{{/bodyParams}}
|
||||
{{/hasBodyParam}}
|
||||
|
||||
{{#hasHeaderParam}}
|
||||
h5. Header Parameters
|
||||
||Name||Description||Required||Default||Pattern||
|
||||
{{#headerParam}}{{>param}}
|
||||
{{/headerParam}}
|
||||
{{/hasHeaderParam}}
|
||||
|
||||
{{#hasQueryParams}}
|
||||
h5. Query Parameters
|
||||
||Name||Description||Required||Default||Pattern||
|
||||
{{#queryParams}}{{>param}}
|
||||
{{/queryParams}}
|
||||
{{/hasQueryParams}}
|
||||
|
||||
|
||||
|
||||
|
||||
h4. Responses
|
||||
{{#responses}}
|
||||
*Status Code:* {{code}}
|
||||
*Message:* {{message}}
|
||||
{code:title=Response Type}
|
||||
{{{dataType}}}
|
||||
{code}
|
||||
See [#models]
|
||||
|
||||
{{#hasExamples}}
|
||||
{{#examples}}
|
||||
{code:title=Example {{{contentType}}} |collapse=true }
|
||||
{{{example}}}
|
||||
{code}
|
||||
{{/examples}}
|
||||
{{/hasExamples}}
|
||||
|
||||
|
||||
{code:title=Response Schema |collapse=true}
|
||||
{{{jsonSchema}}}
|
||||
{code}
|
||||
{{#examples}}
|
||||
{code:title=Example {{{contentType}}} |collapse=true }
|
||||
{{{example}}}
|
||||
{code}
|
||||
{{/examples}}
|
||||
{{/responses}}
|
||||
----
|
||||
{{/operation}}
|
||||
{{/operations}}
|
||||
{{/apis}}
|
||||
{{/apiInfo}}
|
||||
|
||||
h2. Models
|
||||
|
||||
{{#models}}
|
||||
{{#model}}
|
||||
h3. {{classname}}
|
||||
||Field Name||Required||Type||Description||
|
||||
{{#vars}} |{{name}} |{{#isNotRequired}}(x){{/isNotRequired}} |{{datatype}} |{{description}} |
|
||||
{{/vars}}
|
||||
{{/model}}
|
||||
{{/models}}
|
||||
@@ -0,0 +1 @@
|
||||
|{{paramName}} |{{description}} |{{^required}}(x){{/required}}{{#required}}(/){{/required}} |{{defaultValue}} | {{pattern}} |
|
||||
@@ -158,7 +158,28 @@ namespace {{packageName}}.Client
|
||||
/// <returns></returns>
|
||||
public void AddDefaultHeader(string key, string value)
|
||||
{
|
||||
_defaultHeaderMap.Add(key, value);
|
||||
_defaultHeaderMap[key] = value;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Add Api Key Header.
|
||||
/// </summary>
|
||||
/// <param name="key">Api Key name.</param>
|
||||
/// <param name="value">Api Key value.</param>
|
||||
/// <returns></returns>
|
||||
public void AddApiKey(string key, string value)
|
||||
{
|
||||
ApiKey[key] = value;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sets the API key prefix.
|
||||
/// </summary>
|
||||
/// <param name="key">Api Key name.</param>
|
||||
/// <param name="value">Api Key value.</param>
|
||||
public void AddApiKeyPrefix(string key, string value)
|
||||
{
|
||||
ApiKeyPrefix[key] = value;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -31,8 +31,8 @@ limitations under the License.
|
||||
<ProjectGuid>{{packageGuid}}</ProjectGuid>
|
||||
<OutputType>Library</OutputType>
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<RootNamespace>{{packageTitle}}</RootNamespace>
|
||||
<AssemblyName>{{packageTitle}}</AssemblyName>
|
||||
<RootNamespace>{{packageName}}</RootNamespace>
|
||||
<AssemblyName>{{packageName}}</AssemblyName>
|
||||
{{^supportsUWP}}
|
||||
<TargetFrameworkVersion>{{targetFramework}}</TargetFrameworkVersion>
|
||||
{{/supportsUWP}}
|
||||
|
||||
@@ -83,10 +83,10 @@ limitations under the License.
|
||||
<HintPath Condition="Exists('{{binRelativePath}}')">{{binRelativePath}}\RestSharp.105.1.0\lib\{{targetFrameworkNuget}}\RestSharp.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="nunit.framework">
|
||||
<HintPath Condition="Exists('$(SolutionDir)\packages')">$(SolutionDir)\packages\NUnit.3.2.1\lib\nunit.framework.dll</HintPath>
|
||||
<HintPath Condition="Exists('..\packages')">..\packages\NUnit.3.2.1\lib\nunit.framework.dll</HintPath>
|
||||
<HintPath Condition="Exists('..\..\packages')">..\..\packages\NUnit.3.2.1\lib\nunit.framework.dll</HintPath>
|
||||
<HintPath Condition="Exists('{{binRelativePath}}')">{{binRelativePath}}\NUnit.3.2.1\lib\nunit.framework.dll</HintPath>
|
||||
<HintPath Condition="Exists('$(SolutionDir)\packages')">$(SolutionDir)\packages\NUnit.2.6.4\lib\nunit.framework.dll</HintPath>
|
||||
<HintPath Condition="Exists('..\packages')">..\packages\NUnit.2.6.4\lib\nunit.framework.dll</HintPath>
|
||||
<HintPath Condition="Exists('..\..\packages')">..\..\packages\NUnit.2.6.4\lib\nunit.framework.dll</HintPath>
|
||||
<HintPath Condition="Exists('{{binRelativePath}}')">{{binRelativePath}}\NUnit.2.6.4\lib\nunit.framework.dll</HintPath>
|
||||
</Reference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
|
||||
@@ -51,8 +51,8 @@ namespace {{packageName}}.Test
|
||||
[Test]
|
||||
public void {{operationId}}InstanceTest()
|
||||
{
|
||||
// test 'IsInstanceOfType' {{classname}}
|
||||
Assert.IsInstanceOfType(typeof({{classname}}), instance, "instance is a {{classname}}");
|
||||
// TODO uncomment below to test 'IsInstanceOfType' {{classname}}
|
||||
//Assert.IsInstanceOfType(typeof({{classname}}), instance, "instance is a {{classname}}");
|
||||
}
|
||||
|
||||
{{#operations}}{{#operation}}
|
||||
|
||||
@@ -147,39 +147,39 @@ UpgradeLog*.htm
|
||||
*.swp
|
||||
*.swo
|
||||
|
||||
# svn
|
||||
.svn
|
||||
# svn
|
||||
.svn
|
||||
|
||||
# SQL Server files
|
||||
**/App_Data/*.mdf
|
||||
**/App_Data/*.ldf
|
||||
**/App_Data/*.sdf
|
||||
# SQL Server files
|
||||
**/App_Data/*.mdf
|
||||
**/App_Data/*.ldf
|
||||
**/App_Data/*.sdf
|
||||
|
||||
|
||||
#LightSwitch generated files
|
||||
GeneratedArtifacts/
|
||||
_Pvt_Extensions/
|
||||
ModelManifest.xml
|
||||
#LightSwitch generated files
|
||||
GeneratedArtifacts/
|
||||
_Pvt_Extensions/
|
||||
ModelManifest.xml
|
||||
|
||||
# =========================
|
||||
# Windows detritus
|
||||
# =========================
|
||||
# =========================
|
||||
# Windows detritus
|
||||
# =========================
|
||||
|
||||
# Windows image file caches
|
||||
Thumbs.db
|
||||
ehthumbs.db
|
||||
# Windows image file caches
|
||||
Thumbs.db
|
||||
ehthumbs.db
|
||||
|
||||
# Folder config file
|
||||
Desktop.ini
|
||||
# Folder config file
|
||||
Desktop.ini
|
||||
|
||||
# Recycle Bin used on file shares
|
||||
$RECYCLE.BIN/
|
||||
# Recycle Bin used on file shares
|
||||
$RECYCLE.BIN/
|
||||
|
||||
# Mac desktop service store files
|
||||
.DS_Store
|
||||
# Mac desktop service store files
|
||||
.DS_Store
|
||||
|
||||
# SASS Compiler cache
|
||||
.sass-cache
|
||||
# SASS Compiler cache
|
||||
.sass-cache
|
||||
|
||||
# Visual Studio 2014 CTP
|
||||
**/*.sln.ide
|
||||
# Visual Studio 2014 CTP
|
||||
**/*.sln.ide
|
||||
|
||||
@@ -26,8 +26,8 @@ mozroots --import --sync
|
||||
mono nuget.exe install src/{{{packageName}}}.Test/packages.config -o packages
|
||||
|
||||
echo "[INFO] Install NUnit runners via NuGet"
|
||||
mono nuget.exe install NUnit.Runners -Version 3.2.1 -OutputDirectory packages
|
||||
mono nuget.exe install NUnit.Runners -Version 2.6.4 -OutputDirectory packages
|
||||
|
||||
echo "[INFO] Build the solution and run the unit test"
|
||||
xbuild {{{packageName}}}.sln && \
|
||||
mono ./packages/NUnit.ConsoleRunner.3.2.1/tools/nunit3-console.exe src/{{{packageName}}}.Test/bin/Debug/{{{packageName}}}.Test.dll
|
||||
mono ./packages/NUnit.Runners.2.6.4/tools/nunit-console.exe src/{{{packageName}}}.Test/bin/Debug/{{{packageName}}}.Test.dll
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<packages>
|
||||
<package id="NUnit" version="3.2.1" targetFramework="{{targetFrameworkNuget}}" />
|
||||
<package id="NUnit" version="2.6.4" targetFramework="{{targetFrameworkNuget}}" />
|
||||
<package id="RestSharp" version="105.1.0" targetFramework="{{targetFrameworkNuget}}" developmentDependency="true" />
|
||||
<package id="Newtonsoft.Json" version="8.0.3" targetFramework="{{targetFrameworkNuget}}" developmentDependency="true" />
|
||||
</packages>
|
||||
|
||||
@@ -0,0 +1,2 @@
|
||||
analyzer:
|
||||
strong-mode: true
|
||||
@@ -36,9 +36,13 @@ class {{classname}} {
|
||||
Map<String, String> headerParams = {};
|
||||
Map<String, String> formParams = {};
|
||||
{{#queryParams}}
|
||||
if("null" != {{paramName}}) {
|
||||
{{^required}}
|
||||
if({{paramName}} != null) {
|
||||
{{/required}}
|
||||
queryParams.addAll(_convertParametersForCollectionFormat("{{collectionFormat}}", "{{baseName}}", {{paramName}}));
|
||||
{{^required}}
|
||||
}
|
||||
{{/required}}
|
||||
{{/queryParams}}
|
||||
{{#headerParams}}headerParams["{{baseName}}"] = {{paramName}};
|
||||
{{/headerParams}}
|
||||
@@ -84,7 +88,7 @@ class {{classname}} {
|
||||
if(response.statusCode >= 400) {
|
||||
throw new ApiException(response.statusCode, response.body);
|
||||
} else if(response.body != null) {
|
||||
return {{#returnType}} apiClient.deserialize(response.body, '{{{returnType}}}') {{/returnType}};
|
||||
return {{#returnType}}apiClient.deserialize(response.body, '{{{returnType}}}') as {{{returnType}}} {{/returnType}};
|
||||
} else {
|
||||
return {{#returnType}}null{{/returnType}};
|
||||
}
|
||||
|
||||
@@ -15,7 +15,8 @@ class ApiClient {
|
||||
Map<String, String> _defaultHeaderMap = {};
|
||||
Map<String, Authentication> _authentications = {};
|
||||
|
||||
final dson = new Dartson.JSON();
|
||||
final dson = new Dartson.JSON()
|
||||
..addTransformer(new DateTimeParser(), DateTime);
|
||||
final DateFormat _dateFormatter = new DateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSZ");
|
||||
|
||||
final _RegList = new RegExp(r'^List<(.*)>$');
|
||||
@@ -72,20 +73,18 @@ class ApiClient {
|
||||
Match match;
|
||||
if (value is List &&
|
||||
(match = _RegList.firstMatch(targetType)) != null) {
|
||||
var valueL = value as List;
|
||||
var newTargetType = match[1];
|
||||
return valueL.map((v) => _deserialize(v, newTargetType)).toList();
|
||||
return value.map((v) => _deserialize(v, newTargetType)).toList();
|
||||
} else if (value is Map &&
|
||||
(match = _RegMap.firstMatch(targetType)) != null) {
|
||||
var valueM = value as Map;
|
||||
var newTargetType = match[1];
|
||||
return new Map.fromIterables(valueM.keys,
|
||||
valueM.values.map((v) => _deserialize(v, newTargetType)));
|
||||
return new Map.fromIterables(value.keys,
|
||||
value.values.map((v) => _deserialize(v, newTargetType)));
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch(e) {
|
||||
// Just throw the ApiException below
|
||||
} catch (e, stack) {
|
||||
throw new ApiException.withInner(500, 'Exception during deserialization.', e, stack);
|
||||
}
|
||||
throw new ApiException(500, 'Could not find a suitable class for deserialization');
|
||||
}
|
||||
@@ -116,7 +115,7 @@ class ApiClient {
|
||||
// If collectionFormat is 'multi' a key might appear multiple times.
|
||||
Future<Response> invokeAPI(String path,
|
||||
String method,
|
||||
List<QueryParam> queryParams,
|
||||
Iterable<QueryParam> queryParams,
|
||||
Object body,
|
||||
Map<String, String> headerParams,
|
||||
Map<String, String> formParams,
|
||||
@@ -152,6 +151,8 @@ class ApiClient {
|
||||
return client.put(url, headers: headerParams, body: msgBody);
|
||||
case "DELETE":
|
||||
return client.delete(url, headers: headerParams);
|
||||
case "PATCH":
|
||||
return client.patch(url, headers: headerParams, body: msgBody);
|
||||
default:
|
||||
return client.get(url, headers: headerParams);
|
||||
}
|
||||
|
||||
@@ -3,7 +3,21 @@ part of {{pubName}}.api;
|
||||
class ApiException implements Exception {
|
||||
int code = 0;
|
||||
String message = null;
|
||||
Exception innerException = null;
|
||||
StackTrace stackTrace = null;
|
||||
|
||||
ApiException(this.code, this.message);
|
||||
|
||||
}
|
||||
ApiException.withInner(this.code, this.message, this.innerException, this.stackTrace);
|
||||
|
||||
String toString() {
|
||||
if (message == null) return "ApiException";
|
||||
|
||||
if (innerException == null) {
|
||||
return "ApiException $code: $message";
|
||||
}
|
||||
|
||||
return "ApiException $code: $message (Inner exception: ${innerException})\n\n" +
|
||||
stackTrace.toString();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,19 +3,19 @@ part of {{pubName}}.api;
|
||||
const _delimiters = const {'csv': ',', 'ssv': ' ', 'tsv': '\t', 'pipes': '|'};
|
||||
|
||||
// port from Java version
|
||||
List<QueryParam> _convertParametersForCollectionFormat(
|
||||
Iterable<QueryParam> _convertParametersForCollectionFormat(
|
||||
String collectionFormat, String name, dynamic value) {
|
||||
var params = [];
|
||||
var params = <QueryParam>[];
|
||||
|
||||
// preconditions
|
||||
if (name == null || name.isEmpty || value == null) return params;
|
||||
|
||||
if (value is! List) {
|
||||
params.add(new QueryParam(name, value as String));
|
||||
params.add(new QueryParam(name, '$value'));
|
||||
return params;
|
||||
}
|
||||
|
||||
List<String> values = value as List<String>;
|
||||
List values = value as List;
|
||||
|
||||
// get the collection format
|
||||
collectionFormat = (collectionFormat == null || collectionFormat.isEmpty)
|
||||
@@ -23,7 +23,7 @@ List<QueryParam> _convertParametersForCollectionFormat(
|
||||
: collectionFormat; // default: csv
|
||||
|
||||
if (collectionFormat == "multi") {
|
||||
return values.map((v) => new QueryParam(name, v));
|
||||
return values.map((v) => new QueryParam(name, '$v'));
|
||||
}
|
||||
|
||||
String delimiter = _delimiters[collectionFormat] ?? ",";
|
||||
|
||||
@@ -5,6 +5,7 @@ import 'dart:convert';{{#browserClient}}
|
||||
import 'package:http/browser_client.dart';{{/browserClient}}
|
||||
import 'package:http/http.dart';
|
||||
import 'package:dartson/dartson.dart';
|
||||
import 'package:dartson/transformers/date_time.dart';
|
||||
import 'package:intl/intl.dart';
|
||||
|
||||
part 'api_client.dart';
|
||||
|
||||
@@ -40,14 +40,14 @@ var routes = Routes{
|
||||
Route{
|
||||
"Index",
|
||||
"GET",
|
||||
"/",
|
||||
"{{basePathWithoutHost}}/",
|
||||
Index,
|
||||
},
|
||||
{{#apiInfo}}{{#apis}}{{#operations}}{{#operation}}
|
||||
Route{
|
||||
"{{operationId}}",
|
||||
"{{httpMethod}}",
|
||||
"{{path}}",
|
||||
"{{basePathWithoutHost}}{{path}}",
|
||||
{{operationId}},
|
||||
},
|
||||
{{/operation}}{{/operations}}{{/apis}}{{/apiInfo}}
|
||||
|
||||
@@ -3,11 +3,8 @@ package {{packageName}}
|
||||
|
||||
{{#operations}}
|
||||
import (
|
||||
"strings"
|
||||
"fmt"
|
||||
"errors"
|
||||
"net/url"
|
||||
{{#imports}}"{{import}}"
|
||||
{{#imports}} "{{import}}"
|
||||
{{/imports}}
|
||||
)
|
||||
|
||||
@@ -45,11 +42,7 @@ func (a {{{classname}}}) {{{nickname}}}({{#allParams}}{{paramName}} {{{dataType}
|
||||
// create path and map variables
|
||||
path := a.Configuration.BasePath + "{{path}}"{{#pathParams}}
|
||||
path = strings.Replace(path, "{"+"{{baseName}}"+"}", fmt.Sprintf("%v", {{paramName}}), -1){{/pathParams}}
|
||||
{{#allParams}}{{#required}}
|
||||
// verify the required parameter '{{paramName}}' is set
|
||||
if &{{paramName}} == nil {
|
||||
return {{#returnType}}{{#isListContainer}}*{{/isListContainer}}new({{{returnType}}}), {{/returnType}}nil, errors.New("Missing required parameter '{{paramName}}' when calling {{classname}}->{{operationId}}")
|
||||
}{{/required}}{{/allParams}}
|
||||
|
||||
|
||||
headerParams := make(map[string]string)
|
||||
queryParams := url.Values{}
|
||||
@@ -58,22 +51,30 @@ func (a {{{classname}}}) {{{nickname}}}({{#allParams}}{{paramName}} {{{dataType}
|
||||
var fileName string
|
||||
var fileBytes []byte
|
||||
{{#authMethods}}
|
||||
// authentication ({{name}}) required
|
||||
{{#isApiKey}}{{#isKeyInHeader}}
|
||||
// authentication '({{name}})' required
|
||||
{{#isApiKey}}
|
||||
{{#isKeyInHeader}}
|
||||
// set key with prefix in header
|
||||
headerParams["{{keyParamName}}"] = a.Configuration.GetAPIKeyWithPrefix("{{keyParamName}}")
|
||||
{{/isKeyInHeader}}{{#isKeyInQuery}}
|
||||
// set key with prefix in querystring{{#hasKeyParamName}}
|
||||
{{/isKeyInHeader}}
|
||||
{{#isKeyInQuery}}
|
||||
// set key with prefix in query string
|
||||
queryParams["{{keyParamName}}"] = a.Configuration.GetAPIKeyWithPrefix("{{keyParamName}}")
|
||||
{{/hasKeyParamName}}{{/isKeyInQuery}}{{/isApiKey}}{{#isBasic}}
|
||||
{{/isKeyInQuery}}
|
||||
{{/isApiKey}}
|
||||
{{#isBasic}}
|
||||
// http basic authentication required
|
||||
if a.Configuration.Username != "" || a.Configuration.Password != ""{
|
||||
headerParams["Authorization"] = "Basic " + a.Configuration.GetBasicAuthEncodedString()
|
||||
}{{/isBasic}}{{#isOAuth}}
|
||||
}
|
||||
{{/isBasic}}
|
||||
{{#isOAuth}}
|
||||
// oauth required
|
||||
if a.Configuration.AccessToken != ""{
|
||||
headerParams["Authorization"] = "Bearer " + a.Configuration.AccessToken
|
||||
}{{/isOAuth}}{{/authMethods}}
|
||||
}
|
||||
{{/isOAuth}}
|
||||
{{/authMethods}}
|
||||
// add default headers if any
|
||||
for key := range a.Configuration.DefaultHeader {
|
||||
headerParams[key] = a.Configuration.DefaultHeader[key]
|
||||
@@ -84,14 +85,14 @@ func (a {{{classname}}}) {{{nickname}}}({{#allParams}}{{paramName}} {{{dataType}
|
||||
var collectionFormat = "{{#collectionFormat}}{{collectionFormat}}{{/collectionFormat}}"
|
||||
if collectionFormat == "multi" {
|
||||
for _, value := range {{paramName}} {
|
||||
queryParams.Add("{{paramName}}", value)
|
||||
queryParams.Add("{{baseName}}", value)
|
||||
}
|
||||
} else {
|
||||
queryParams.Add("{{paramName}}", a.Configuration.APIClient.ParameterToString({{paramName}}, collectionFormat))
|
||||
queryParams.Add("{{baseName}}", a.Configuration.APIClient.ParameterToString({{paramName}}, collectionFormat))
|
||||
}
|
||||
{{/isListContainer}}
|
||||
{{^isListContainer}}
|
||||
queryParams.Add("{{paramName}}", a.Configuration.APIClient.ParameterToString({{paramName}}, ""))
|
||||
queryParams.Add("{{baseName}}", a.Configuration.APIClient.ParameterToString({{paramName}}, ""))
|
||||
{{/isListContainer}}
|
||||
{{/queryParams}}{{/hasQueryParams}}
|
||||
|
||||
|
||||
@@ -94,7 +94,7 @@ func (c *APIClient) ParameterToString(obj interface{},collectionFormat string) s
|
||||
}
|
||||
}
|
||||
|
||||
return obj.(string)
|
||||
return fmt.Sprintf("%v", obj)
|
||||
}
|
||||
|
||||
func prepareRequest(postBody interface{},
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -0,0 +1,101 @@
|
||||
/* Pretty printing styles. Used with prettify.js. */
|
||||
/* Vim sunburst theme by David Leibovic */
|
||||
pre .str {
|
||||
color: #65B042;
|
||||
}
|
||||
/* string - green */
|
||||
pre .kwd {
|
||||
color: #E28964;
|
||||
}
|
||||
/* keyword - dark pink */
|
||||
pre .com {
|
||||
color: #AEAEAE;
|
||||
font-style: italic;
|
||||
}
|
||||
/* comment - gray */
|
||||
pre .typ {
|
||||
color: #89bdff;
|
||||
}
|
||||
/* type - light blue */
|
||||
pre .lit {
|
||||
color: #3387CC;
|
||||
}
|
||||
/* literal - blue */
|
||||
pre .pun {
|
||||
color: #fff;
|
||||
}
|
||||
/* punctuation - white */
|
||||
pre .pln {
|
||||
color: #fff;
|
||||
}
|
||||
/* plaintext - white */
|
||||
pre .tag {
|
||||
color: #89bdff;
|
||||
}
|
||||
/* html/xml tag - light blue */
|
||||
pre .atn {
|
||||
color: #bdb76b;
|
||||
}
|
||||
/* html/xml attribute name - khaki */
|
||||
pre .atv {
|
||||
color: #65B042;
|
||||
}
|
||||
/* html/xml attribute value - green */
|
||||
pre .dec {
|
||||
color: #3387CC;
|
||||
}
|
||||
/* decimal - blue */
|
||||
/* Specify class=linenums on a pre to get line numbering */
|
||||
ol.linenums {
|
||||
margin-top: 0;
|
||||
margin-bottom: 0;
|
||||
color: #AEAEAE;
|
||||
}
|
||||
/* IE indents via margin-left */
|
||||
li.L0,
|
||||
li.L1,
|
||||
li.L2,
|
||||
li.L3,
|
||||
li.L5,
|
||||
li.L6,
|
||||
li.L7,
|
||||
li.L8 {
|
||||
list-style-type: none;
|
||||
}
|
||||
/* Alternate shading for lines */
|
||||
@media print {
|
||||
pre .str {
|
||||
color: #060;
|
||||
}
|
||||
pre .kwd {
|
||||
color: #006;
|
||||
font-weight: bold;
|
||||
}
|
||||
pre .com {
|
||||
color: #600;
|
||||
font-style: italic;
|
||||
}
|
||||
pre .typ {
|
||||
color: #404;
|
||||
font-weight: bold;
|
||||
}
|
||||
pre .lit {
|
||||
color: #044;
|
||||
}
|
||||
pre .pun {
|
||||
color: #440;
|
||||
}
|
||||
pre .pln {
|
||||
color: #000;
|
||||
}
|
||||
pre .tag {
|
||||
color: #006;
|
||||
font-weight: bold;
|
||||
}
|
||||
pre .atn {
|
||||
color: #404;
|
||||
}
|
||||
pre .atv {
|
||||
color: #060;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,555 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
|
||||
<title>{{{appName}}}</title>
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
|
||||
<meta charset="UTF-8" />
|
||||
|
||||
|
||||
{{>js_jquery}}
|
||||
|
||||
{{>js_prettify}}
|
||||
{{>js_bootstrap}}
|
||||
|
||||
<script>
|
||||
|
||||
$( document ).ready(function() {
|
||||
|
||||
var textFile = null;
|
||||
|
||||
/// Function to be used to download a text json schema
|
||||
function makeTextFile(text) {
|
||||
|
||||
var data = new Blob([text], {type: 'text/plain'});
|
||||
|
||||
// If we are replacing a previously generated file we need to
|
||||
// manually revoke the object URL to avoid memory leaks.
|
||||
if (textFile !== null) {
|
||||
window.URL.revokeObjectURL(textFile);
|
||||
}
|
||||
|
||||
textFile = window.URL.createObjectURL(data);
|
||||
|
||||
var a = document.createElement("a");
|
||||
document.body.appendChild(a);
|
||||
a.style = "display: none";
|
||||
|
||||
a.href = textFile;
|
||||
a.download = 'schema.txt';
|
||||
a.click();
|
||||
|
||||
return textFile;
|
||||
};
|
||||
|
||||
/// TODO: Implement resizing for expanding within iframe
|
||||
function callResize() {
|
||||
window.parent.postMessage('resize', "*");
|
||||
|
||||
}
|
||||
|
||||
|
||||
// load google web fonts
|
||||
loadGoogleFontCss();
|
||||
|
||||
|
||||
// Bootstrap Scrollspy
|
||||
$(this).scrollspy({ target: '#scrollingNav', offset: 18 });
|
||||
|
||||
// Content-Scroll on Navigation click.
|
||||
$('.sidenav').find('a').on('click', function(e) {
|
||||
e.preventDefault();
|
||||
var id = $(this).attr('href');
|
||||
if ($(id).length > 0)
|
||||
$('html,body').animate({ scrollTop: parseInt($(id).offset().top) }, 400);
|
||||
window.location.hash = $(this).attr('href');
|
||||
});
|
||||
|
||||
// Quickjump on Pageload to hash position.
|
||||
if(window.location.hash) {
|
||||
var id = window.location.hash;
|
||||
if ($(id).length > 0)
|
||||
$('html,body').animate({ scrollTop: parseInt($(id).offset().top) }, 0);
|
||||
}
|
||||
|
||||
|
||||
function initDynamic() {
|
||||
|
||||
// tabs
|
||||
$('.nav-tabs-examples a').click(function (e) {
|
||||
e.preventDefault();
|
||||
$(this).tab('show');
|
||||
});
|
||||
|
||||
|
||||
$('.nav-tabs-examples').find('a:first').tab('show');
|
||||
|
||||
// call scrollspy refresh method
|
||||
$(window).scrollspy('refresh');
|
||||
|
||||
}
|
||||
initDynamic();
|
||||
|
||||
// Pre- / Code-Format
|
||||
prettyPrint();
|
||||
|
||||
|
||||
/**
|
||||
* Load google fonts.
|
||||
*/
|
||||
function loadGoogleFontCss() {
|
||||
WebFont.load({
|
||||
active: function() {
|
||||
// Update scrollspy
|
||||
$(window).scrollspy('refresh')
|
||||
},
|
||||
google: {
|
||||
families: ['Source Code Pro', 'Source Sans Pro:n4,n6,n7']
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
</script>
|
||||
|
||||
<style type="text/css">
|
||||
{{>css_bootstrap}}
|
||||
{{>css_prettify}}
|
||||
|
||||
{{>styles}}
|
||||
|
||||
</style>
|
||||
|
||||
|
||||
</head>
|
||||
<body>
|
||||
<script>
|
||||
|
||||
// Script section to load models into a JS Var
|
||||
|
||||
var defs = {}
|
||||
|
||||
{{#models}}
|
||||
{{#model}}
|
||||
defs.{{name}} = {{{modelJson}}};
|
||||
{{/model}}
|
||||
{{/models}}
|
||||
</script>
|
||||
|
||||
<div class="container-fluid">
|
||||
<div class="row-fluid">
|
||||
<div id="sidenav" class="span2">
|
||||
<nav id="scrollingNav">
|
||||
<ul class="sidenav nav nav-list">
|
||||
|
||||
|
||||
<!-- Logo Area -->
|
||||
<!--<div style="width: 80%; background-color: #4c8eca; color: white; padding: 20px; text-align: center; margin-bottom: 20px; ">
|
||||
|
||||
API Docs 2
|
||||
|
||||
</div>
|
||||
-->
|
||||
<li class="nav-fixed nav-header active" data-group="_"><a href="#api-_">API Summary</a></li>
|
||||
|
||||
{{#apiInfo}}
|
||||
|
||||
{{#apis}}
|
||||
{{#operations}}
|
||||
<li class="nav-header" data-group="{{baseName}}"><a href="#api-{{baseName}}">API Methods - {{baseName}}</a></li>
|
||||
{{#operation}}
|
||||
<li data-group="{{baseName}}" data-name="{{nickname}}" class="">
|
||||
<a href="#api-{{baseName}}-{{nickname}}">{{nickname}}</a>
|
||||
</li>
|
||||
{{/operation}}
|
||||
{{/operations}}
|
||||
{{/apis}}
|
||||
|
||||
{{/apiInfo}}
|
||||
|
||||
|
||||
|
||||
</ul>
|
||||
</nav>
|
||||
</div>
|
||||
<div id="content">
|
||||
<div id="project">
|
||||
<div class="pull-left">
|
||||
<h1>{{{appName}}}</h1>
|
||||
</div>
|
||||
<div class="clearfix"></div>
|
||||
</div>
|
||||
<div id="header">
|
||||
<div id="api-_">
|
||||
<h2 id="welcome-to-apidoc">API and SDK Documentation</h2>
|
||||
|
||||
{{#version}}
|
||||
<div class="app-desc">Version: {{{version}}}</div>
|
||||
{{/version}}
|
||||
|
||||
|
||||
<hr>
|
||||
|
||||
<p>{{{appDescription}}}</p>
|
||||
</div>
|
||||
</div>
|
||||
<div id="sections">
|
||||
|
||||
{{#apiInfo}}
|
||||
|
||||
{{#apis}}
|
||||
{{#operations}}
|
||||
<section id="api-{{baseName}}">
|
||||
<h1>{{baseName}}</h1>
|
||||
{{#operation}}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<div id="api-{{baseName}}-{{nickname}}">
|
||||
|
||||
<article id="api-{{baseName}}-{{nickname}}-0" data-group="User" data-name="{{nickname}}" data-version="0">
|
||||
<div class="pull-left">
|
||||
<h1>{{nickname}}</h1>
|
||||
</div>
|
||||
<div class="pull-right">
|
||||
|
||||
</div>
|
||||
<div class="clearfix"></div>
|
||||
|
||||
<p></p>
|
||||
<p>{{notes}}</p>
|
||||
<p></p>
|
||||
<br />
|
||||
|
||||
<pre class="prettyprint language-html prettyprinted" data-type="{{httpMethod}}"><code><span class="pln">{{path}}</span></code></pre>
|
||||
|
||||
<p>
|
||||
<h3>Usage and SDK Samples</h3>
|
||||
</p>
|
||||
|
||||
<ul class="nav nav-tabs nav-tabs-examples">
|
||||
<li class="active">
|
||||
<a href="#examples-{{baseName}}-{{nickname}}-0-curl">Curl</a>
|
||||
</li>
|
||||
<li class="">
|
||||
<a href="#examples-{{baseName}}-{{nickname}}-0-java">Java</a>
|
||||
</li>
|
||||
<li class="">
|
||||
<a href="#examples-{{baseName}}-{{nickname}}-0-android">Android</a>
|
||||
</li>
|
||||
<!--<li class="">
|
||||
<a href="#examples-{{baseName}}-{{nickname}}-0-groovy">Groovy</a>
|
||||
</li>-->
|
||||
<li class="">
|
||||
<a href="#examples-{{baseName}}-{{nickname}}-0-objc">Obj-C</a>
|
||||
</li>
|
||||
<li class="">
|
||||
<a href="#examples-{{baseName}}-{{nickname}}-0-javascript">JavaScript</a>
|
||||
</li>
|
||||
<!--<li class="">
|
||||
<a href="#examples-{{baseName}}-{{nickname}}-0-angular">Angular</a>
|
||||
</li>-->
|
||||
<li class="">
|
||||
<a href="#examples-{{baseName}}-{{nickname}}-0-csharp">C#</a>
|
||||
</li>
|
||||
<li class="">
|
||||
<a href="#examples-{{baseName}}-{{nickname}}-0-php">PHP</a>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<div class="tab-content">
|
||||
<div class="tab-pane active" id="examples-{{baseName}}-{{nickname}}-0-curl">
|
||||
<pre class="prettyprint"><code class="language-bsh">
|
||||
curl -X <span style="text-transform: uppercase;">{{httpMethod}}</span> -H "apiKey: [[apiKey]]" -H "apiSecret: [[apiSecret]]" "{{basePath}}{{path}}{{#hasQueryParams}}?{{#queryParams}}{{^-first}}&{{/-first}}{{paramName}}={{vendorExtensions.x-eg}}{{/queryParams}}{{/hasQueryParams}}"
|
||||
|
||||
|
||||
</code></pre>
|
||||
</div>
|
||||
|
||||
<div class="tab-pane" id="examples-{{baseName}}-{{nickname}}-0-java">
|
||||
<pre class="prettyprint"><code class="language-java">
|
||||
{{>sample_java}}
|
||||
</code></pre>
|
||||
</div>
|
||||
|
||||
|
||||
<div class="tab-pane" id="examples-{{baseName}}-{{nickname}}-0-android">
|
||||
<pre class="prettyprint"><code class="language-java">
|
||||
{{>sample_android}}
|
||||
</code></pre>
|
||||
</div>
|
||||
|
||||
<!--
|
||||
<div class="tab-pane" id="examples-{{baseName}}-{{nickname}}-0-groovy">
|
||||
<pre class="prettyprint language-json prettyprinted" data-type="json"><code>Coming Soon!</code></pre>
|
||||
</div> -->
|
||||
|
||||
|
||||
<div class="tab-pane" id="examples-{{baseName}}-{{nickname}}-0-objc">
|
||||
<pre class="prettyprint"><code class="language-cpp">
|
||||
{{>sample_objc}}
|
||||
</code></pre>
|
||||
</div>
|
||||
<div class="tab-pane" id="examples-{{baseName}}-{{nickname}}-0-javascript">
|
||||
<pre class="prettyprint"><code class="language-js">
|
||||
{{>sample_js}}
|
||||
</code></pre>
|
||||
</div>
|
||||
|
||||
<!--<div class="tab-pane" id="examples-{{baseName}}-{{nickname}}-0-angular">
|
||||
<pre class="prettyprint language-json prettyprinted" data-type="json"><code>Coming Soon!</code></pre>
|
||||
</div>-->
|
||||
|
||||
<div class="tab-pane" id="examples-{{baseName}}-{{nickname}}-0-csharp">
|
||||
<pre class="prettyprint"><code class="language-cs">
|
||||
{{>sample_csharp}}
|
||||
</code></pre>
|
||||
</div>
|
||||
|
||||
|
||||
<div class="tab-pane" id="examples-{{baseName}}-{{nickname}}-0-php">
|
||||
<pre class="prettyprint"><code class="language-php">
|
||||
{{>sample_php}}
|
||||
</code></pre>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<h2>Parameters</h2>
|
||||
|
||||
|
||||
|
||||
{{#hasPathParams}}
|
||||
<div class="methodsubtabletitle">Path parameters</div>
|
||||
<table id="methodsubtable">
|
||||
<tr>
|
||||
<th width="150px">Name</th>
|
||||
<th>Description</th>
|
||||
</tr>
|
||||
<!---->
|
||||
{{#pathParams}}
|
||||
{{>param}}
|
||||
{{/pathParams}}
|
||||
</table>
|
||||
{{/hasPathParams}}
|
||||
|
||||
{{#hasHeaderParams}}
|
||||
<div class="methodsubtabletitle">Header parameters</div>
|
||||
<table id="methodsubtable">
|
||||
<tr>
|
||||
<th width="150px">Name</th>
|
||||
<th>Description</th>
|
||||
</tr>
|
||||
<!---->
|
||||
{{#headerParams}}
|
||||
{{>param}}
|
||||
{{/headerParams}}
|
||||
|
||||
</table>
|
||||
{{/hasHeaderParams}}
|
||||
|
||||
|
||||
{{#hasBodyParam}}
|
||||
<div class="methodsubtabletitle">Body parameters</div>
|
||||
<table id="methodsubtable">
|
||||
<tr>
|
||||
<th width="150px">Name</th>
|
||||
<th>Description</th>
|
||||
</tr>
|
||||
<!---->
|
||||
{{#bodyParams}}
|
||||
{{>paramB}}
|
||||
{{/bodyParams}}
|
||||
|
||||
</table>
|
||||
{{/hasBodyParam}}
|
||||
|
||||
{{#hasQueryParams}}
|
||||
<div class="methodsubtabletitle">Query parameters</div>
|
||||
<table id="methodsubtable">
|
||||
<tr>
|
||||
<th width="150px">Name</th>
|
||||
<th>Description</th>
|
||||
</tr>
|
||||
<!---->
|
||||
{{#queryParams}}
|
||||
{{>param}}
|
||||
{{/queryParams}}
|
||||
</table>
|
||||
{{/hasQueryParams}}
|
||||
|
||||
<h2>Responses</h2>
|
||||
{{#responses}}
|
||||
|
||||
<h3> Status: {{code}} - {{message}} </h3>
|
||||
|
||||
<ul class="nav nav-tabs nav-tabs-examples" >
|
||||
|
||||
<li class="active">
|
||||
<a href="#examples-{{baseName}}-{{nickname}}-schema">Schema</a>
|
||||
</li>
|
||||
|
||||
{{#examples}}
|
||||
<li class="">
|
||||
<a href="#examples-{{baseName}}-{{nickname}}-example">Response Example</a>
|
||||
</li>
|
||||
{{/examples}}
|
||||
|
||||
</ul>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<div class="tab-content" style='margin-bottom: 10px;'>
|
||||
|
||||
|
||||
|
||||
<div class="tab-pane active" id="examples-{{baseName}}-{{nickname}}-schema">
|
||||
|
||||
|
||||
|
||||
|
||||
<div id='examples-{{baseName}}-{{nickname}}-schema-{{code}}' style="padding: 30px; border-left: 1px solid #eee; border-right: 1px solid #eee; border-bottom: 1px solid #eee;">
|
||||
|
||||
<script>
|
||||
$(document).ready(function() {
|
||||
var schemaWrapper = {{{jsonSchema}}};
|
||||
var schema = schemaWrapper.schema;
|
||||
schemaWrapper.definitions = defs;
|
||||
//console.log(JSON.stringify(schema))
|
||||
JsonRefs.resolveRefs(schemaWrapper, {
|
||||
"depth": 3,
|
||||
"resolveRemoteRefs": false,
|
||||
"resolveFileRefs": false
|
||||
}, function(err, resolved, metadata) {
|
||||
|
||||
//console.log(JSON.stringify(resolved));
|
||||
|
||||
|
||||
|
||||
var view = new JSONSchemaView(resolved.schema, 3);
|
||||
$('#examples-{{baseName}}-{{nickname}}-schema-data').val(JSON.stringify(resolved.schema));
|
||||
var result = $('#examples-{{baseName}}-{{nickname}}-schema-{{code}}');
|
||||
result.empty();
|
||||
result.append(view.render());
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
});
|
||||
</script>
|
||||
</div>
|
||||
<input id='examples-{{baseName}}-{{nickname}}-schema-data' type='hidden' value=''></input>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
{{#examples}}
|
||||
<div class="tab-pane" id="examples-{{baseName}}-{{nickname}}-example">
|
||||
<pre class="prettyprint"><code class="json">{{example}}</code></pre>
|
||||
</div>
|
||||
{{/examples}}
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
{{/responses}}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</article>
|
||||
|
||||
</div>
|
||||
|
||||
<hr>
|
||||
|
||||
{{/operation}}
|
||||
</section>
|
||||
|
||||
{{/operations}}
|
||||
{{/apis}}
|
||||
|
||||
{{/apiInfo}}
|
||||
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<div id="footer">
|
||||
<div id="api-_footer">
|
||||
<p>Suggestions, contact, support and error reporting;
|
||||
{{#infoUrl}}
|
||||
<div class="app-desc">Information URL: <a href="{{{infoUrl}}}">{{{infoUrl}}}</a></div>
|
||||
{{/infoUrl}}
|
||||
{{#infoEmail}}
|
||||
<div class="app-desc">Contact Info: <a href="{{{infoEmail}}}">{{{infoEmail}}}</a></div>
|
||||
{{/infoEmail}}
|
||||
</p>
|
||||
{{#licenseInfo}}
|
||||
<div class="license-info">{{{licenseInfo}}}</div>
|
||||
{{/licenseInfo}}
|
||||
{{#licenseUrl}}
|
||||
<div class="license-url">{{{licenseUrl}}}</div>
|
||||
{{/licenseUrl}}
|
||||
</div>
|
||||
</div>
|
||||
<div id="generator">
|
||||
<div class="content">
|
||||
Generated {{generatedDate}}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
{{>js_jsonschemaview}}
|
||||
{{>js_jsonref}}
|
||||
{{>js_webfontloader}}
|
||||
|
||||
|
||||
|
||||
|
||||
<script>
|
||||
$(document).ready(function () {
|
||||
$('.nav-tabs-examples').find('a:first').tab('show');
|
||||
$(this).scrollspy({ target: '#scrollingNav', offset: 18 });
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user