mirror of
https://github.com/OpenAPITools/openapi-generator.git
synced 2025-07-03 06:00:52 +00:00
Merge remote-tracking branch 'upstream/develop_2.0' into develop_2.0
This commit is contained in:
commit
62d4516fe7
@ -1,3 +1,4 @@
|
|||||||
|
sudo: false
|
||||||
language: java
|
language: java
|
||||||
script: mvn verify
|
script: mvn verify
|
||||||
jdk:
|
jdk:
|
||||||
|
10
README.md
10
README.md
@ -46,7 +46,7 @@ You can build a client against the swagger sample [petstore](http://petstore.swa
|
|||||||
This will run the generator with this command:
|
This will run the generator with this command:
|
||||||
|
|
||||||
```
|
```
|
||||||
java -jar modules/swagger-codegen-distribution/target/swagger-codegen-distribution-2.1.3-M1-SNAPSHOT.jar \
|
java -jar modules/swagger-codegen-cli/target/swagger-codegen-cli.jar generate \
|
||||||
-i http://petstore.swagger.io/v2/swagger.json \
|
-i http://petstore.swagger.io/v2/swagger.json \
|
||||||
-l java \
|
-l java \
|
||||||
-o samples/client/petstore/java
|
-o samples/client/petstore/java
|
||||||
@ -97,7 +97,7 @@ You can look at `modules/swagger-codegen/src/main/resources/${your-language}` fo
|
|||||||
If you're starting a project with a new language and don't see what you need, swagger-codegen can help you create a project to generate your own libraries:
|
If you're starting a project with a new language and don't see what you need, swagger-codegen can help you create a project to generate your own libraries:
|
||||||
|
|
||||||
```
|
```
|
||||||
java -cp modules/swagger-codegen-distribution/target/swagger-codegen-distribution-2.1.3-M1-SNAPSHOT.jar \
|
java -cp modules/swagger-codegen-cli/target/swagger-codegen-cli.jar generate \
|
||||||
com.wordnik.swagger.codegen.MetaGenerator \
|
com.wordnik.swagger.codegen.MetaGenerator \
|
||||||
-o output/myLibrary -n myClientCodegen -p com.my.company.codegen
|
-o output/myLibrary -n myClientCodegen -p com.my.company.codegen
|
||||||
```
|
```
|
||||||
@ -200,7 +200,7 @@ You can also use the codegen to generate a server for a couple different framewo
|
|||||||
|
|
||||||
### node.js
|
### node.js
|
||||||
```
|
```
|
||||||
java -jar modules/swagger-codegen-distribution/target/swagger-codegen-distribution-2.1.3-M1-SNAPSHOT.jar \
|
java -jar modules/swagger-codegen-cli/target/swagger-codegen-cli.jar generate \
|
||||||
-i http://petstore.swagger.io/v2/swagger.json \
|
-i http://petstore.swagger.io/v2/swagger.json \
|
||||||
-l nodejs \
|
-l nodejs \
|
||||||
-o samples/server/petstore/nodejs
|
-o samples/server/petstore/nodejs
|
||||||
@ -212,7 +212,7 @@ java -jar modules/swagger-codegen-distribution/target/swagger-codegen-distributi
|
|||||||
|
|
||||||
### scala scalatra
|
### scala scalatra
|
||||||
```
|
```
|
||||||
java -jar modules/swagger-codegen-distribution/target/swagger-codegen-distribution-2.1.3-M1-SNAPSHOT.jar \
|
java -jar modules/swagger-codegen-cli/target/swagger-codegen-cli.jar generate \
|
||||||
-i http://petstore.swagger.io/v2/swagger.json \
|
-i http://petstore.swagger.io/v2/swagger.json \
|
||||||
-l scalatra \
|
-l scalatra \
|
||||||
-o samples/server/petstore/scalatra
|
-o samples/server/petstore/scalatra
|
||||||
@ -221,7 +221,7 @@ java -jar modules/swagger-codegen-distribution/target/swagger-codegen-distributi
|
|||||||
### java jax-rs
|
### java jax-rs
|
||||||
|
|
||||||
```
|
```
|
||||||
java -jar modules/swagger-codegen-distribution/target/swagger-codegen-distribution-2.1.3-M1-SNAPSHOT.jar \
|
java -jar modules/swagger-codegen-cli/target/swagger-codegen-cli.jar generate \
|
||||||
-i http://petstore.swagger.io/v2/swagger.json \
|
-i http://petstore.swagger.io/v2/swagger.json \
|
||||||
-l jaxrs \
|
-l jaxrs \
|
||||||
-o samples/server/petstore/jaxrs
|
-o samples/server/petstore/jaxrs
|
||||||
|
@ -17,12 +17,7 @@ if [ ! -d "${APP_DIR}" ]; then
|
|||||||
APP_DIR=`cd "${APP_DIR}"; pwd`
|
APP_DIR=`cd "${APP_DIR}"; pwd`
|
||||||
fi
|
fi
|
||||||
|
|
||||||
root=./modules/swagger-codegen-distribution/pom.xml
|
executable="./modules/swagger-codegen-cli/target/swagger-codegen-cli.jar"
|
||||||
|
|
||||||
# gets version of swagger-codegen
|
|
||||||
version=$(sed '/<project>/,/<\/project>/d;/<version>/!d;s/ *<\/\?version> *//g' $root | sed -n '2p' | sed -e 's,.*<version>\([^<]*\)</version>.*,\1,g')
|
|
||||||
|
|
||||||
executable="./modules/swagger-codegen-distribution/target/swagger-codegen-distribution-$version.jar"
|
|
||||||
|
|
||||||
if [ ! -f "$executable" ]
|
if [ ! -f "$executable" ]
|
||||||
then
|
then
|
||||||
@ -31,6 +26,6 @@ fi
|
|||||||
|
|
||||||
# if you've executed sbt assembly previously it will use that instead.
|
# if you've executed sbt assembly previously it will use that instead.
|
||||||
export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties"
|
export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties"
|
||||||
ags="$@ -i modules/swagger-codegen/src/test/resources/2_0/petstore.json -l android -o samples/client/petstore/android-java"
|
ags="$@ generate -i modules/swagger-codegen/src/test/resources/2_0/petstore.json -l android -o samples/client/petstore/android-java"
|
||||||
|
|
||||||
java $JAVA_OPTS -jar $executable $ags
|
java $JAVA_OPTS -jar $executable $ags
|
||||||
|
@ -17,12 +17,7 @@ if [ ! -d "${APP_DIR}" ]; then
|
|||||||
APP_DIR=`cd "${APP_DIR}"; pwd`
|
APP_DIR=`cd "${APP_DIR}"; pwd`
|
||||||
fi
|
fi
|
||||||
|
|
||||||
root=./modules/swagger-codegen-distribution/pom.xml
|
executable="./modules/swagger-codegen-cli/target/swagger-codegen-cli.jar"
|
||||||
|
|
||||||
# gets version of swagger-codegen
|
|
||||||
version=$(sed '/<project>/,/<\/project>/d;/<version>/!d;s/ *<\/\?version> *//g' $root | sed -n '2p' | sed -e 's,.*<version>\([^<]*\)</version>.*,\1,g')
|
|
||||||
|
|
||||||
executable="./modules/swagger-codegen-distribution/target/swagger-codegen-distribution-$version.jar"
|
|
||||||
|
|
||||||
if [ ! -f "$executable" ]
|
if [ ! -f "$executable" ]
|
||||||
then
|
then
|
||||||
@ -31,6 +26,6 @@ fi
|
|||||||
|
|
||||||
# if you've executed sbt assembly previously it will use that instead.
|
# if you've executed sbt assembly previously it will use that instead.
|
||||||
export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties"
|
export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties"
|
||||||
ags="$@ -i modules/swagger-codegen/src/test/resources/2_0/wordnik.json -l android -o samples/client/wordnik/android-java"
|
ags="$@ generate -i modules/swagger-codegen/src/test/resources/2_0/wordnik.json -l android -o samples/client/wordnik/android-java"
|
||||||
|
|
||||||
java $JAVA_OPTS -jar $executable $ags
|
java $JAVA_OPTS -jar $executable $ags
|
||||||
|
@ -17,12 +17,7 @@ if [ ! -d "${APP_DIR}" ]; then
|
|||||||
APP_DIR=`cd "${APP_DIR}"; pwd`
|
APP_DIR=`cd "${APP_DIR}"; pwd`
|
||||||
fi
|
fi
|
||||||
|
|
||||||
root=./modules/swagger-codegen-distribution/pom.xml
|
executable="./modules/swagger-codegen-cli/target/swagger-codegen-cli.jar"
|
||||||
|
|
||||||
# gets version of swagger-codegen
|
|
||||||
version=$(sed '/<project>/,/<\/project>/d;/<version>/!d;s/ *<\/\?version> *//g' $root | sed -n '2p' | sed -e 's,.*<version>\([^<]*\)</version>.*,\1,g')
|
|
||||||
|
|
||||||
executable="./modules/swagger-codegen-distribution/target/swagger-codegen-distribution-$version.jar"
|
|
||||||
|
|
||||||
if [ ! -f "$executable" ]
|
if [ ! -f "$executable" ]
|
||||||
then
|
then
|
||||||
@ -31,6 +26,6 @@ fi
|
|||||||
|
|
||||||
# if you've executed sbt assembly previously it will use that instead.
|
# if you've executed sbt assembly previously it will use that instead.
|
||||||
export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties"
|
export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties"
|
||||||
ags="$@ -i modules/swagger-codegen/src/test/resources/2_0/petstore.json -l dynamic-html -o samples/dynamic-html"
|
ags="$@ generate -i modules/swagger-codegen/src/test/resources/2_0/petstore.json -l dynamic-html -o samples/dynamic-html"
|
||||||
|
|
||||||
java $JAVA_OPTS -jar $executable $ags
|
java $JAVA_OPTS -jar $executable $ags
|
||||||
|
@ -17,12 +17,7 @@ if [ ! -d "${APP_DIR}" ]; then
|
|||||||
APP_DIR=`cd "${APP_DIR}"; pwd`
|
APP_DIR=`cd "${APP_DIR}"; pwd`
|
||||||
fi
|
fi
|
||||||
|
|
||||||
root=./modules/swagger-codegen-distribution/pom.xml
|
executable="./modules/swagger-codegen-cli/target/swagger-codegen-cli.jar"
|
||||||
|
|
||||||
# gets version of swagger-codegen
|
|
||||||
version=$(sed '/<project>/,/<\/project>/d;/<version>/!d;s/ *<\/\?version> *//g' $root | sed -n '2p' | sed -e 's,.*<version>\([^<]*\)</version>.*,\1,g')
|
|
||||||
|
|
||||||
executable="./modules/swagger-codegen-distribution/target/swagger-codegen-distribution-$version.jar"
|
|
||||||
|
|
||||||
if [ ! -f "$executable" ]
|
if [ ! -f "$executable" ]
|
||||||
then
|
then
|
||||||
@ -31,6 +26,6 @@ fi
|
|||||||
|
|
||||||
# if you've executed sbt assembly previously it will use that instead.
|
# if you've executed sbt assembly previously it will use that instead.
|
||||||
export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties"
|
export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties"
|
||||||
ags="$@ -i modules/swagger-codegen/src/test/resources/2_0/petstore.json -l html -o samples/html"
|
ags="$@ generate -i modules/swagger-codegen/src/test/resources/2_0/petstore.json -l html -o samples/html"
|
||||||
|
|
||||||
java $JAVA_OPTS -jar $executable $ags
|
java $JAVA_OPTS -jar $executable $ags
|
||||||
|
@ -17,12 +17,7 @@ if [ ! -d "${APP_DIR}" ]; then
|
|||||||
APP_DIR=`cd "${APP_DIR}"; pwd`
|
APP_DIR=`cd "${APP_DIR}"; pwd`
|
||||||
fi
|
fi
|
||||||
|
|
||||||
root=./modules/swagger-codegen-distribution/pom.xml
|
executable="./modules/swagger-codegen-cli/target/swagger-codegen-cli.jar"
|
||||||
|
|
||||||
# gets version of swagger-codegen
|
|
||||||
version=$(sed '/<project>/,/<\/project>/d;/<version>/!d;s/ *<\/\?version> *//g' $root | sed -n '2p' | sed -e 's,.*<version>\([^<]*\)</version>.*,\1,g')
|
|
||||||
|
|
||||||
executable="./modules/swagger-codegen-distribution/target/swagger-codegen-distribution-$version.jar"
|
|
||||||
|
|
||||||
if [ ! -f "$executable" ]
|
if [ ! -f "$executable" ]
|
||||||
then
|
then
|
||||||
@ -31,6 +26,6 @@ fi
|
|||||||
|
|
||||||
# if you've executed sbt assembly previously it will use that instead.
|
# if you've executed sbt assembly previously it will use that instead.
|
||||||
export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties"
|
export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties"
|
||||||
ags="$@ -i modules/swagger-codegen/src/test/resources/2_0/petstore.json -l java -o samples/client/petstore/java"
|
ags="$@ generate -i modules/swagger-codegen/src/test/resources/2_0/petstore.json -l java -o samples/client/petstore/java"
|
||||||
|
|
||||||
java $JAVA_OPTS -jar $executable $ags
|
java $JAVA_OPTS -jar $executable $ags
|
||||||
|
@ -17,12 +17,7 @@ if [ ! -d "${APP_DIR}" ]; then
|
|||||||
APP_DIR=`cd "${APP_DIR}"; pwd`
|
APP_DIR=`cd "${APP_DIR}"; pwd`
|
||||||
fi
|
fi
|
||||||
|
|
||||||
root=./modules/swagger-codegen-distribution/pom.xml
|
executable="./modules/swagger-codegen-cli/target/swagger-codegen-cli.jar"
|
||||||
|
|
||||||
# gets version of swagger-codegen
|
|
||||||
version=$(sed '/<project>/,/<\/project>/d;/<version>/!d;s/ *<\/\?version> *//g' $root | sed -n '2p' | sed -e 's,.*<version>\([^<]*\)</version>.*,\1,g')
|
|
||||||
|
|
||||||
executable="./modules/swagger-codegen-distribution/target/swagger-codegen-distribution-$version.jar"
|
|
||||||
|
|
||||||
if [ ! -f "$executable" ]
|
if [ ! -f "$executable" ]
|
||||||
then
|
then
|
||||||
@ -31,6 +26,6 @@ fi
|
|||||||
|
|
||||||
# if you've executed sbt assembly previously it will use that instead.
|
# if you've executed sbt assembly previously it will use that instead.
|
||||||
export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties"
|
export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties"
|
||||||
ags="$@ -i modules/swagger-codegen/src/test/resources/2_0/wordnik.json -l java -o samples/client/wordnik/java"
|
ags="$@ generate -i modules/swagger-codegen/src/test/resources/2_0/wordnik.json -l java -o samples/client/wordnik/java"
|
||||||
|
|
||||||
java $JAVA_OPTS -jar $executable $ags
|
java $JAVA_OPTS -jar $executable $ags
|
||||||
|
@ -17,12 +17,7 @@ if [ ! -d "${APP_DIR}" ]; then
|
|||||||
APP_DIR=`cd "${APP_DIR}"; pwd`
|
APP_DIR=`cd "${APP_DIR}"; pwd`
|
||||||
fi
|
fi
|
||||||
|
|
||||||
root=./modules/swagger-codegen-distribution/pom.xml
|
executable="./modules/swagger-codegen-cli/target/swagger-codegen-cli.jar"
|
||||||
|
|
||||||
# gets version of swagger-codegen
|
|
||||||
version=$(sed '/<project>/,/<\/project>/d;/<version>/!d;s/ *<\/\?version> *//g' $root | sed -n '2p' | sed -e 's,.*<version>\([^<]*\)</version>.*,\1,g')
|
|
||||||
|
|
||||||
executable="./modules/swagger-codegen-distribution/target/swagger-codegen-distribution-$version.jar"
|
|
||||||
|
|
||||||
if [ ! -f "$executable" ]
|
if [ ! -f "$executable" ]
|
||||||
then
|
then
|
||||||
@ -31,6 +26,6 @@ fi
|
|||||||
|
|
||||||
# if you've executed sbt assembly previously it will use that instead.
|
# if you've executed sbt assembly previously it will use that instead.
|
||||||
export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties"
|
export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties"
|
||||||
ags="$@ -i modules/swagger-codegen/src/test/resources/2_0/petstore.json -l jaxrs -o samples/server/petstore/jaxrs"
|
ags="$@ generate -i modules/swagger-codegen/src/test/resources/2_0/petstore.json -l jaxrs -o samples/server/petstore/jaxrs"
|
||||||
|
|
||||||
java $JAVA_OPTS -jar $executable $ags
|
java $JAVA_OPTS -jar $executable $ags
|
||||||
|
@ -17,12 +17,7 @@ if [ ! -d "${APP_DIR}" ]; then
|
|||||||
APP_DIR=`cd "${APP_DIR}"; pwd`
|
APP_DIR=`cd "${APP_DIR}"; pwd`
|
||||||
fi
|
fi
|
||||||
|
|
||||||
root=./modules/swagger-codegen-distribution/pom.xml
|
executable="./modules/swagger-codegen-cli/target/swagger-codegen-cli.jar"
|
||||||
|
|
||||||
# gets version of swagger-codegen
|
|
||||||
version=$(sed '/<project>/,/<\/project>/d;/<version>/!d;s/ *<\/\?version> *//g' $root | sed -n '2p' | sed -e 's,.*<version>\([^<]*\)</version>.*,\1,g')
|
|
||||||
|
|
||||||
executable="./modules/swagger-codegen-distribution/target/swagger-codegen-distribution-$version.jar"
|
|
||||||
|
|
||||||
if [ ! -f "$executable" ]
|
if [ ! -f "$executable" ]
|
||||||
then
|
then
|
||||||
@ -31,6 +26,6 @@ fi
|
|||||||
|
|
||||||
# if you've executed sbt assembly previously it will use that instead.
|
# if you've executed sbt assembly previously it will use that instead.
|
||||||
export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties"
|
export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties"
|
||||||
ags="$@ -i modules/swagger-codegen/src/test/resources/2_0/petstore.json -l nodejs -o samples/server/petstore/nodejs"
|
ags="$@ generate -i modules/swagger-codegen/src/test/resources/2_0/petstore.json -l nodejs -o samples/server/petstore/nodejs"
|
||||||
|
|
||||||
java $JAVA_OPTS -Dservice -jar $executable $ags
|
java $JAVA_OPTS -Dservice -jar $executable $ags
|
||||||
|
@ -17,12 +17,7 @@ if [ ! -d "${APP_DIR}" ]; then
|
|||||||
APP_DIR=`cd "${APP_DIR}"; pwd`
|
APP_DIR=`cd "${APP_DIR}"; pwd`
|
||||||
fi
|
fi
|
||||||
|
|
||||||
root=./modules/swagger-codegen-distribution/pom.xml
|
executable="./modules/swagger-codegen-cli/target/swagger-codegen-cli.jar"
|
||||||
|
|
||||||
# gets version of swagger-codegen
|
|
||||||
version=$(sed '/<project>/,/<\/project>/d;/<version>/!d;s/ *<\/\?version> *//g' $root | sed -n '2p' | sed -e 's,.*<version>\([^<]*\)</version>.*,\1,g')
|
|
||||||
|
|
||||||
executable="./modules/swagger-codegen-distribution/target/swagger-codegen-distribution-$version.jar"
|
|
||||||
|
|
||||||
if [ ! -f "$executable" ]
|
if [ ! -f "$executable" ]
|
||||||
then
|
then
|
||||||
@ -31,6 +26,6 @@ fi
|
|||||||
|
|
||||||
# if you've executed sbt assembly previously it will use that instead.
|
# if you've executed sbt assembly previously it will use that instead.
|
||||||
export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties"
|
export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties"
|
||||||
ags="$@ -i modules/swagger-codegen/src/test/resources/2_0/petstore.json -l objc -o samples/client/petstore/objc"
|
ags="$@ generate -i modules/swagger-codegen/src/test/resources/2_0/petstore.json -l objc -o samples/client/petstore/objc"
|
||||||
|
|
||||||
java $JAVA_OPTS -jar $executable $ags
|
java -DappName=PetstoreClient $JAVA_OPTS -jar $executable $ags
|
||||||
|
@ -17,12 +17,7 @@ if [ ! -d "${APP_DIR}" ]; then
|
|||||||
APP_DIR=`cd "${APP_DIR}"; pwd`
|
APP_DIR=`cd "${APP_DIR}"; pwd`
|
||||||
fi
|
fi
|
||||||
|
|
||||||
root=./modules/swagger-codegen-distribution/pom.xml
|
executable="./modules/swagger-codegen-cli/target/swagger-codegen-cli.jar"
|
||||||
|
|
||||||
# gets version of swagger-codegen
|
|
||||||
version=$(sed '/<project>/,/<\/project>/d;/<version>/!d;s/ *<\/\?version> *//g' $root | sed -n '2p' | sed -e 's,.*<version>\([^<]*\)</version>.*,\1,g')
|
|
||||||
|
|
||||||
executable="./modules/swagger-codegen-distribution/target/swagger-codegen-distribution-$version.jar"
|
|
||||||
|
|
||||||
if [ ! -f "$executable" ]
|
if [ ! -f "$executable" ]
|
||||||
then
|
then
|
||||||
@ -31,6 +26,6 @@ fi
|
|||||||
|
|
||||||
# if you've executed sbt assembly previously it will use that instead.
|
# if you've executed sbt assembly previously it will use that instead.
|
||||||
export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties"
|
export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties"
|
||||||
ags="$@ -i modules/swagger-codegen/src/test/resources/2_0/wordnik.json -l objc -o samples/client/wordnik/objc"
|
ags="$@ generate -i modules/swagger-codegen/src/test/resources/2_0/wordnik.json -l objc -o samples/client/wordnik/objc"
|
||||||
|
|
||||||
java $JAVA_OPTS -jar $executable $ags
|
java $JAVA_OPTS -jar $executable $ags
|
||||||
|
@ -17,12 +17,7 @@ if [ ! -d "${APP_DIR}" ]; then
|
|||||||
APP_DIR=`cd "${APP_DIR}"; pwd`
|
APP_DIR=`cd "${APP_DIR}"; pwd`
|
||||||
fi
|
fi
|
||||||
|
|
||||||
root=./modules/swagger-codegen-distribution/pom.xml
|
executable="./modules/swagger-codegen-cli/target/swagger-codegen-cli.jar"
|
||||||
|
|
||||||
# gets version of swagger-codegen
|
|
||||||
version=$(sed '/<project>/,/<\/project>/d;/<version>/!d;s/ *<\/\?version> *//g' $root | sed -n '2p' | sed -e 's,.*<version>\([^<]*\)</version>.*,\1,g')
|
|
||||||
|
|
||||||
executable="./modules/swagger-codegen-distribution/target/swagger-codegen-distribution-$version.jar"
|
|
||||||
|
|
||||||
if [ ! -f "$executable" ]
|
if [ ! -f "$executable" ]
|
||||||
then
|
then
|
||||||
@ -31,6 +26,6 @@ fi
|
|||||||
|
|
||||||
# if you've executed sbt assembly previously it will use that instead.
|
# if you've executed sbt assembly previously it will use that instead.
|
||||||
export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties"
|
export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties"
|
||||||
ags="$@ -i modules/swagger-codegen/src/test/resources/2_0/petstore.json -l php -o samples/client/petstore/php"
|
ags="$@ generate -i modules/swagger-codegen/src/test/resources/2_0/petstore.json -l php -o samples/client/petstore/php"
|
||||||
|
|
||||||
java $JAVA_OPTS -jar $executable $ags
|
java $JAVA_OPTS -jar $executable $ags
|
||||||
|
@ -17,12 +17,7 @@ if [ ! -d "${APP_DIR}" ]; then
|
|||||||
APP_DIR=`cd "${APP_DIR}"; pwd`
|
APP_DIR=`cd "${APP_DIR}"; pwd`
|
||||||
fi
|
fi
|
||||||
|
|
||||||
root=./modules/swagger-codegen-distribution/pom.xml
|
executable="./modules/swagger-codegen-cli/target/swagger-codegen-cli.jar"
|
||||||
|
|
||||||
# gets version of swagger-codegen
|
|
||||||
version=$(sed '/<project>/,/<\/project>/d;/<version>/!d;s/ *<\/\?version> *//g' $root | sed -n '2p' | sed -e 's,.*<version>\([^<]*\)</version>.*,\1,g')
|
|
||||||
|
|
||||||
executable="./modules/swagger-codegen-distribution/target/swagger-codegen-distribution-$version.jar"
|
|
||||||
|
|
||||||
if [ ! -f "$executable" ]
|
if [ ! -f "$executable" ]
|
||||||
then
|
then
|
||||||
@ -31,6 +26,6 @@ fi
|
|||||||
|
|
||||||
# if you've executed sbt assembly previously it will use that instead.
|
# if you've executed sbt assembly previously it will use that instead.
|
||||||
export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties"
|
export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties"
|
||||||
ags="$@ -i modules/swagger-codegen/src/test/resources/2_0/petstore.json -l python -o samples/client/petstore/python"
|
ags="$@ generate -i modules/swagger-codegen/src/test/resources/2_0/petstore.json -l python -o samples/client/petstore/python"
|
||||||
|
|
||||||
java $JAVA_OPTS -jar $executable $ags
|
java $JAVA_OPTS -jar $executable $ags
|
||||||
|
@ -17,12 +17,7 @@ if [ ! -d "${APP_DIR}" ]; then
|
|||||||
APP_DIR=`cd "${APP_DIR}"; pwd`
|
APP_DIR=`cd "${APP_DIR}"; pwd`
|
||||||
fi
|
fi
|
||||||
|
|
||||||
root=./modules/swagger-codegen-distribution/pom.xml
|
executable="./modules/swagger-codegen-cli/target/swagger-codegen-cli.jar"
|
||||||
|
|
||||||
# gets version of swagger-codegen
|
|
||||||
version=$(sed '/<project>/,/<\/project>/d;/<version>/!d;s/ *<\/\?version> *//g' $root | sed -n '2p' | sed -e 's,.*<version>\([^<]*\)</version>.*,\1,g')
|
|
||||||
|
|
||||||
executable="./modules/swagger-codegen-distribution/target/swagger-codegen-distribution-$version.jar"
|
|
||||||
|
|
||||||
if [ ! -f "$executable" ]
|
if [ ! -f "$executable" ]
|
||||||
then
|
then
|
||||||
@ -31,6 +26,6 @@ fi
|
|||||||
|
|
||||||
# if you've executed sbt assembly previously it will use that instead.
|
# if you've executed sbt assembly previously it will use that instead.
|
||||||
export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties"
|
export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties"
|
||||||
ags="$@ -i modules/swagger-codegen/src/test/resources/2_0/petstore.json -l ruby -o samples/client/petstore/ruby"
|
ags="$@ generate -i modules/swagger-codegen/src/test/resources/2_0/petstore.json -l ruby -o samples/client/petstore/ruby"
|
||||||
|
|
||||||
java $JAVA_OPTS -jar $executable $ags
|
java $JAVA_OPTS -jar $executable $ags
|
||||||
|
@ -17,12 +17,7 @@ if [ ! -d "${APP_DIR}" ]; then
|
|||||||
APP_DIR=`cd "${APP_DIR}"; pwd`
|
APP_DIR=`cd "${APP_DIR}"; pwd`
|
||||||
fi
|
fi
|
||||||
|
|
||||||
root=./modules/swagger-codegen-distribution/pom.xml
|
executable="./modules/swagger-codegen-cli/target/swagger-codegen-cli.jar"
|
||||||
|
|
||||||
# gets version of swagger-codegen
|
|
||||||
version=$(sed '/<project>/,/<\/project>/d;/<version>/!d;s/ *<\/\?version> *//g' $root | sed -n '2p' | sed -e 's,.*<version>\([^<]*\)</version>.*,\1,g')
|
|
||||||
|
|
||||||
executable="./modules/swagger-codegen-distribution/target/swagger-codegen-distribution-$version.jar"
|
|
||||||
|
|
||||||
if [ ! -f "$executable" ]
|
if [ ! -f "$executable" ]
|
||||||
then
|
then
|
||||||
@ -31,6 +26,6 @@ fi
|
|||||||
|
|
||||||
# if you've executed sbt assembly previously it will use that instead.
|
# if you've executed sbt assembly previously it will use that instead.
|
||||||
export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties"
|
export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties"
|
||||||
ags="$@ -i modules/swagger-codegen/src/test/resources/2_0/petstore.json -l async-scala -o samples/client/petstore/async-scala"
|
ags="$@ generate -i modules/swagger-codegen/src/test/resources/2_0/petstore.json -l async-scala -o samples/client/petstore/async-scala"
|
||||||
|
|
||||||
java $JAVA_OPTS -jar $executable $ags
|
java $JAVA_OPTS -jar $executable $ags
|
||||||
|
@ -17,12 +17,7 @@ if [ ! -d "${APP_DIR}" ]; then
|
|||||||
APP_DIR=`cd "${APP_DIR}"; pwd`
|
APP_DIR=`cd "${APP_DIR}"; pwd`
|
||||||
fi
|
fi
|
||||||
|
|
||||||
root=./modules/swagger-codegen-distribution/pom.xml
|
executable="./modules/swagger-codegen-cli/target/swagger-codegen-cli.jar"
|
||||||
|
|
||||||
# gets version of swagger-codegen
|
|
||||||
version=$(sed '/<project>/,/<\/project>/d;/<version>/!d;s/ *<\/\?version> *//g' $root | sed -n '2p' | sed -e 's,.*<version>\([^<]*\)</version>.*,\1,g')
|
|
||||||
|
|
||||||
executable="./modules/swagger-codegen-distribution/target/swagger-codegen-distribution-$version.jar"
|
|
||||||
|
|
||||||
if [ ! -f "$executable" ]
|
if [ ! -f "$executable" ]
|
||||||
then
|
then
|
||||||
@ -31,6 +26,6 @@ fi
|
|||||||
|
|
||||||
# if you've executed sbt assembly previously it will use that instead.
|
# if you've executed sbt assembly previously it will use that instead.
|
||||||
export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties"
|
export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties"
|
||||||
ags="$@ -i modules/swagger-codegen/src/test/resources/2_0/petstore.json -l scala -o samples/client/petstore/scala"
|
ags="$@ generate -i modules/swagger-codegen/src/test/resources/2_0/petstore.json -l scala -o samples/client/petstore/scala"
|
||||||
|
|
||||||
java $JAVA_OPTS -jar $executable $ags
|
java $JAVA_OPTS -jar $executable $ags
|
||||||
|
@ -17,12 +17,7 @@ if [ ! -d "${APP_DIR}" ]; then
|
|||||||
APP_DIR=`cd "${APP_DIR}"; pwd`
|
APP_DIR=`cd "${APP_DIR}"; pwd`
|
||||||
fi
|
fi
|
||||||
|
|
||||||
root=./modules/swagger-codegen-distribution/pom.xml
|
executable="./modules/swagger-codegen-cli/target/swagger-codegen-cli.jar"
|
||||||
|
|
||||||
# gets version of swagger-codegen
|
|
||||||
version=$(sed '/<project>/,/<\/project>/d;/<version>/!d;s/ *<\/\?version> *//g' $root | sed -n '2p' | sed -e 's,.*<version>\([^<]*\)</version>.*,\1,g')
|
|
||||||
|
|
||||||
executable="./modules/swagger-codegen-distribution/target/swagger-codegen-distribution-$version.jar"
|
|
||||||
|
|
||||||
if [ ! -f "$executable" ]
|
if [ ! -f "$executable" ]
|
||||||
then
|
then
|
||||||
@ -31,6 +26,6 @@ fi
|
|||||||
|
|
||||||
# if you've executed sbt assembly previously it will use that instead.
|
# if you've executed sbt assembly previously it will use that instead.
|
||||||
export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties"
|
export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties"
|
||||||
ags="$@ -i modules/swagger-codegen/src/test/resources/2_0/wordnik.json -l scala -o samples/client/wordnik/scala"
|
ags="$@ generate -i modules/swagger-codegen/src/test/resources/2_0/wordnik.json -l scala -o samples/client/wordnik/scala"
|
||||||
|
|
||||||
java $JAVA_OPTS -jar $executable $ags
|
java $JAVA_OPTS -jar $executable $ags
|
||||||
|
@ -17,12 +17,7 @@ if [ ! -d "${APP_DIR}" ]; then
|
|||||||
APP_DIR=`cd "${APP_DIR}"; pwd`
|
APP_DIR=`cd "${APP_DIR}"; pwd`
|
||||||
fi
|
fi
|
||||||
|
|
||||||
root=./modules/swagger-codegen-distribution/pom.xml
|
executable="./modules/swagger-codegen-cli/target/swagger-codegen-cli.jar"
|
||||||
|
|
||||||
# gets version of swagger-codegen
|
|
||||||
version=$(sed '/<project>/,/<\/project>/d;/<version>/!d;s/ *<\/\?version> *//g' $root | sed -n '2p' | sed -e 's,.*<version>\([^<]*\)</version>.*,\1,g')
|
|
||||||
|
|
||||||
executable="./modules/swagger-codegen-distribution/target/swagger-codegen-distribution-$version.jar"
|
|
||||||
|
|
||||||
if [ ! -f "$executable" ]
|
if [ ! -f "$executable" ]
|
||||||
then
|
then
|
||||||
@ -31,6 +26,6 @@ fi
|
|||||||
|
|
||||||
# if you've executed sbt assembly previously it will use that instead.
|
# if you've executed sbt assembly previously it will use that instead.
|
||||||
export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties"
|
export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties"
|
||||||
ags="$@ -i modules/swagger-codegen/src/test/resources/2_0/petstore.json -l scalatra -o samples/server/petstore/scalatra"
|
ags="$@ generate -i modules/swagger-codegen/src/test/resources/2_0/petstore.json -l scalatra -o samples/server/petstore/scalatra"
|
||||||
|
|
||||||
java $JAVA_OPTS -jar $executable $ags
|
java $JAVA_OPTS -jar $executable $ags
|
||||||
|
@ -17,12 +17,7 @@ if [ ! -d "${APP_DIR}" ]; then
|
|||||||
APP_DIR=`cd "${APP_DIR}"; pwd`
|
APP_DIR=`cd "${APP_DIR}"; pwd`
|
||||||
fi
|
fi
|
||||||
|
|
||||||
root=./modules/swagger-codegen-distribution/pom.xml
|
executable="./modules/swagger-codegen-cli/target/swagger-codegen-cli.jar"
|
||||||
|
|
||||||
# gets version of swagger-codegen
|
|
||||||
version=$(sed '/<project>/,/<\/project>/d;/<version>/!d;s/ *<\/\?version> *//g' $root | sed -n '2p' | sed -e 's,.*<version>\([^<]*\)</version>.*,\1,g')
|
|
||||||
|
|
||||||
executable="./modules/swagger-codegen-distribution/target/swagger-codegen-distribution-$version.jar"
|
|
||||||
|
|
||||||
if [ ! -f "$executable" ]
|
if [ ! -f "$executable" ]
|
||||||
then
|
then
|
||||||
@ -31,6 +26,6 @@ fi
|
|||||||
|
|
||||||
# if you've executed sbt assembly previously it will use that instead.
|
# if you've executed sbt assembly previously it will use that instead.
|
||||||
export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties"
|
export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties"
|
||||||
ags="$@ -i modules/swagger-codegen/src/test/resources/2_0/petstore.json -l tizen -o samples/client/petstore/tizen"
|
ags="$@ generate -i modules/swagger-codegen/src/test/resources/2_0/petstore.json -l tizen -o samples/client/petstore/tizen"
|
||||||
|
|
||||||
java $JAVA_OPTS -jar $executable $ags
|
java $JAVA_OPTS -jar $executable $ags
|
||||||
|
95
modules/swagger-codegen-cli/pom.xml
Normal file
95
modules/swagger-codegen-cli/pom.xml
Normal file
@ -0,0 +1,95 @@
|
|||||||
|
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
|
||||||
|
<parent>
|
||||||
|
<groupId>com.wordnik</groupId>
|
||||||
|
<artifactId>swagger-codegen-project</artifactId>
|
||||||
|
<version>2.1.3-M1-SNAPSHOT</version>
|
||||||
|
<relativePath>../..</relativePath>
|
||||||
|
</parent>
|
||||||
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
<artifactId>swagger-codegen-cli</artifactId>
|
||||||
|
<packaging>jar</packaging>
|
||||||
|
|
||||||
|
<name>swagger-codegen (executable)</name>
|
||||||
|
|
||||||
|
<build>
|
||||||
|
<finalName>swagger-codegen-cli</finalName>
|
||||||
|
<plugins>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
|
<artifactId>maven-jar-plugin</artifactId>
|
||||||
|
<configuration>
|
||||||
|
<archive>
|
||||||
|
<manifest>
|
||||||
|
<mainClass>com.wordnik.swagger.codegen.SwaggerCodegen</mainClass>
|
||||||
|
</manifest>
|
||||||
|
</archive>
|
||||||
|
</configuration>
|
||||||
|
</plugin>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
|
<artifactId>maven-shade-plugin</artifactId>
|
||||||
|
<version>2.3</version>
|
||||||
|
<executions>
|
||||||
|
<execution>
|
||||||
|
<id>reduced-pom</id>
|
||||||
|
<phase>package</phase>
|
||||||
|
<goals>
|
||||||
|
<goal>shade</goal>
|
||||||
|
</goals>
|
||||||
|
<configuration>
|
||||||
|
<minimizeJar>false</minimizeJar>
|
||||||
|
<createDependencyReducedPom>true</createDependencyReducedPom>
|
||||||
|
<dependencyReducedPomLocation>
|
||||||
|
${java.io.tmpdir}/dependency-reduced-pom.xml
|
||||||
|
</dependencyReducedPomLocation>
|
||||||
|
</configuration>
|
||||||
|
</execution>
|
||||||
|
<execution>
|
||||||
|
<id>process-resources</id>
|
||||||
|
<phase>package</phase>
|
||||||
|
<goals>
|
||||||
|
<goal>shade</goal>
|
||||||
|
</goals>
|
||||||
|
<configuration>
|
||||||
|
<transformers>
|
||||||
|
<transformer implementation="org.apache.maven.plugins.shade.resource.ServicesResourceTransformer"/>
|
||||||
|
</transformers>
|
||||||
|
</configuration>
|
||||||
|
</execution>
|
||||||
|
</executions>
|
||||||
|
</plugin>
|
||||||
|
</plugins>
|
||||||
|
</build>
|
||||||
|
|
||||||
|
<dependencies>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.wordnik</groupId>
|
||||||
|
<artifactId>swagger-codegen</artifactId>
|
||||||
|
<version>${project.version}</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!--https://github.com/airlift/airline-->
|
||||||
|
<dependency>
|
||||||
|
<groupId>io.airlift</groupId>
|
||||||
|
<artifactId>airline</artifactId>
|
||||||
|
<version>0.7</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.googlecode.lambdaj</groupId>
|
||||||
|
<artifactId>lambdaj</artifactId>
|
||||||
|
<version>2.3.3</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.slf4j</groupId>
|
||||||
|
<artifactId>slf4j-simple</artifactId>
|
||||||
|
<version>${slf4j-version}</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
</dependencies>
|
||||||
|
|
||||||
|
</project>
|
@ -0,0 +1,30 @@
|
|||||||
|
package com.wordnik.swagger.codegen;
|
||||||
|
|
||||||
|
import com.wordnik.swagger.codegen.cmd.Generate;
|
||||||
|
import com.wordnik.swagger.codegen.cmd.Langs;
|
||||||
|
import com.wordnik.swagger.codegen.cmd.Meta;
|
||||||
|
import io.airlift.airline.Cli;
|
||||||
|
import io.airlift.airline.Help;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* User: lanwen
|
||||||
|
* Date: 24.03.15
|
||||||
|
* Time: 17:56
|
||||||
|
*/
|
||||||
|
public class SwaggerCodegen {
|
||||||
|
|
||||||
|
|
||||||
|
public static void main(String[] args) {
|
||||||
|
Cli.CliBuilder<Runnable> builder = Cli.<Runnable>builder("swagger")
|
||||||
|
.withDescription("Swagger code generator CLI. More info on swagger.io")
|
||||||
|
.withDefaultCommand(Langs.class)
|
||||||
|
.withCommands(
|
||||||
|
Generate.class,
|
||||||
|
Meta.class,
|
||||||
|
Langs.class,
|
||||||
|
Help.class
|
||||||
|
);
|
||||||
|
|
||||||
|
builder.build().parse(args).run();
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,120 @@
|
|||||||
|
package com.wordnik.swagger.codegen.cmd;
|
||||||
|
|
||||||
|
import com.wordnik.swagger.codegen.ClientOptInput;
|
||||||
|
import com.wordnik.swagger.codegen.ClientOpts;
|
||||||
|
import com.wordnik.swagger.codegen.CodegenConfig;
|
||||||
|
import com.wordnik.swagger.codegen.DefaultGenerator;
|
||||||
|
import com.wordnik.swagger.models.Swagger;
|
||||||
|
import io.airlift.airline.Command;
|
||||||
|
import io.airlift.airline.Option;
|
||||||
|
import io.swagger.parser.SwaggerParser;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.util.ServiceLoader;
|
||||||
|
|
||||||
|
import static java.util.ServiceLoader.load;
|
||||||
|
import static org.apache.commons.lang3.StringUtils.isNotEmpty;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* User: lanwen
|
||||||
|
* Date: 24.03.15
|
||||||
|
* Time: 20:22
|
||||||
|
*/
|
||||||
|
|
||||||
|
@Command(name = "generate", description = "Generate code with chosen lang")
|
||||||
|
public class Generate implements Runnable {
|
||||||
|
|
||||||
|
public static final Logger LOG = LoggerFactory.getLogger(Generate.class);
|
||||||
|
|
||||||
|
public static final String TEMPLATE_DIR_PARAM = "templateDir";
|
||||||
|
|
||||||
|
@Option(name = {"-v", "--verbose"}, description = "verbose mode")
|
||||||
|
public boolean verbose;
|
||||||
|
|
||||||
|
@Option(name = {"-l", "--lang"}, title = "language", required = true,
|
||||||
|
description = "client language to generate (maybe class name in classpath, required)")
|
||||||
|
public String lang;
|
||||||
|
|
||||||
|
@Option(name = {"-o", "--output"}, title = "output directory",
|
||||||
|
description = "where to write the generated files (current dir by default)")
|
||||||
|
public String output = "";
|
||||||
|
|
||||||
|
@Option(name = {"-i", "--input-spec"}, title = "spec file", required = true,
|
||||||
|
description = "location of the swagger spec, as URL or file (required)")
|
||||||
|
public String spec;
|
||||||
|
|
||||||
|
@Option(name = {"-t", "--template-dir"}, title = "template directory",
|
||||||
|
description = "folder containing the template files")
|
||||||
|
public String templateDir;
|
||||||
|
|
||||||
|
@Option(name = {"-a", "--auth"}, title = "authorization",
|
||||||
|
description = "adds authorization headers when fetching the swagger definitions remotely. " +
|
||||||
|
"Pass in a URL-encoded string of name:header with a comma separating multiple values")
|
||||||
|
public String auth;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
verbosed(verbose);
|
||||||
|
|
||||||
|
ClientOptInput input = new ClientOptInput();
|
||||||
|
|
||||||
|
if (isNotEmpty(auth)) {
|
||||||
|
input.setAuth(auth);
|
||||||
|
}
|
||||||
|
|
||||||
|
CodegenConfig config = forName(lang);
|
||||||
|
config.setOutputDir(new File(output).getAbsolutePath());
|
||||||
|
|
||||||
|
if (null != templateDir) {
|
||||||
|
config.additionalProperties().put(TEMPLATE_DIR_PARAM, new File(templateDir).getAbsolutePath());
|
||||||
|
}
|
||||||
|
|
||||||
|
input.setConfig(config);
|
||||||
|
|
||||||
|
Swagger swagger = new SwaggerParser().read(spec, input.getAuthorizationValues(), true);
|
||||||
|
new DefaultGenerator().opts(input.opts(new ClientOpts()).swagger(swagger)).generate();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* If true parameter, adds system properties which enables debug mode in generator
|
||||||
|
* @param verbose - if true, enables debug mode
|
||||||
|
*/
|
||||||
|
private void verbosed(boolean verbose) {
|
||||||
|
if (!verbose) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
LOG.info("\nVERBOSE MODE: ON. Additional debug options are injected" +
|
||||||
|
"\n - [debugSwagger] prints the swagger specification as interpreted by the codegen" +
|
||||||
|
"\n - [debugModels] prints models passed to the template engine" +
|
||||||
|
"\n - [debugOperations] prints operations passed to the template engine" +
|
||||||
|
"\n - [debugSupportingFiles] prints additional data passed to the template engine");
|
||||||
|
|
||||||
|
System.setProperty("debugSwagger", "");
|
||||||
|
System.setProperty("debugModels", "");
|
||||||
|
System.setProperty("debugOperations", "");
|
||||||
|
System.setProperty("debugSupportingFiles", "");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tries to load config class with SPI first, then with class name directly from classpath
|
||||||
|
* @param name name of config, or full qualified class name in classpath
|
||||||
|
* @return config class
|
||||||
|
*/
|
||||||
|
private static CodegenConfig forName(String name) {
|
||||||
|
ServiceLoader<CodegenConfig> loader = load(CodegenConfig.class);
|
||||||
|
for (CodegenConfig config : loader) {
|
||||||
|
if (config.getName().equals(name)) {
|
||||||
|
return config;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// else try to load directly
|
||||||
|
try {
|
||||||
|
return (CodegenConfig) Class.forName(name).newInstance();
|
||||||
|
} catch (Exception e) {
|
||||||
|
throw new RuntimeException("Can't load config class with name ".concat(name), e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,23 @@
|
|||||||
|
package com.wordnik.swagger.codegen.cmd;
|
||||||
|
|
||||||
|
import ch.lambdaj.collection.LambdaIterable;
|
||||||
|
import com.wordnik.swagger.codegen.CodegenConfig;
|
||||||
|
import io.airlift.airline.Command;
|
||||||
|
|
||||||
|
import static ch.lambdaj.Lambda.on;
|
||||||
|
import static ch.lambdaj.collection.LambdaCollections.with;
|
||||||
|
import static java.util.ServiceLoader.load;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* User: lanwen
|
||||||
|
* Date: 24.03.15
|
||||||
|
* Time: 20:25
|
||||||
|
*/
|
||||||
|
@Command(name = "langs", description = "Shows available langs")
|
||||||
|
public class Langs implements Runnable {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
LambdaIterable<String> langs = with(load(CodegenConfig.class)).extract(on(CodegenConfig.class).getName());
|
||||||
|
System.out.printf("Available languages: %s%n", langs);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,144 @@
|
|||||||
|
package com.wordnik.swagger.codegen.cmd;
|
||||||
|
|
||||||
|
import ch.lambdaj.function.convert.Converter;
|
||||||
|
import com.google.common.collect.ImmutableList;
|
||||||
|
import com.google.common.collect.ImmutableMap;
|
||||||
|
import com.samskivert.mustache.Mustache;
|
||||||
|
import com.wordnik.swagger.codegen.DefaultGenerator;
|
||||||
|
import com.wordnik.swagger.codegen.SupportingFile;
|
||||||
|
import io.airlift.airline.Command;
|
||||||
|
import io.airlift.airline.Option;
|
||||||
|
import org.apache.commons.io.FileUtils;
|
||||||
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.Reader;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
import static ch.lambdaj.collection.LambdaCollections.with;
|
||||||
|
import static com.google.common.base.Joiner.on;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* User: lanwen
|
||||||
|
* Date: 24.03.15
|
||||||
|
* Time: 20:22
|
||||||
|
*/
|
||||||
|
|
||||||
|
@Command(name = "meta", description = "MetaGenerator. Generator for creating a new template set " +
|
||||||
|
"and configuration for Codegen. The output will be based on the language you " +
|
||||||
|
"specify, and includes default templates to include.")
|
||||||
|
public class Meta implements Runnable {
|
||||||
|
|
||||||
|
public static final Logger LOG = LoggerFactory.getLogger(Meta.class);
|
||||||
|
|
||||||
|
public static final String TEMPLATE_DIR_CLASSPATH = "codegen";
|
||||||
|
public static final String MUSTACHE_EXTENSION = ".mustache";
|
||||||
|
|
||||||
|
@Option(name = {"-o", "--output"}, title = "output directory",
|
||||||
|
description = "where to write the generated files (current dir by default)")
|
||||||
|
public String outputFolder = "";
|
||||||
|
|
||||||
|
@Option(name = {"-n", "--name"}, title = "name",
|
||||||
|
description = "the human-readable name of the generator")
|
||||||
|
public String name = "default";
|
||||||
|
|
||||||
|
@Option(name = {"-p", "--package"}, title = "package",
|
||||||
|
description = "the package to put the main class into (defaults to com.wordnik.swagger.codegen)")
|
||||||
|
public String targetPackage = "com.wordnik.swagger.codegen";
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
final File targetDir = new File(outputFolder);
|
||||||
|
LOG.info("writing to folder [{}]", targetDir.getAbsolutePath());
|
||||||
|
|
||||||
|
String mainClass = StringUtils.capitalize(name) + "Generator";
|
||||||
|
|
||||||
|
List<SupportingFile> supportingFiles = ImmutableList.of(
|
||||||
|
new SupportingFile("pom.mustache", "", "pom.xml"),
|
||||||
|
new SupportingFile("generatorClass.mustache",
|
||||||
|
on(File.separator).join("src/main/java", asPath(targetPackage)), mainClass.concat(".java")),
|
||||||
|
new SupportingFile("README.mustache", "", "README.md"),
|
||||||
|
new SupportingFile("api.template", "src/main/resources" + File.separator + name, "api.mustache"),
|
||||||
|
new SupportingFile("model.template", "src/main/resources" + File.separator + name, "model.mustache"),
|
||||||
|
new SupportingFile("services.mustache",
|
||||||
|
"src/main/resources/META-INF/services", "com.wordnik.swagger.codegen.CodegenConfig")
|
||||||
|
);
|
||||||
|
|
||||||
|
Map<String, Object> data = new ImmutableMap.Builder<String, Object>()
|
||||||
|
.put("generatorPackage", targetPackage)
|
||||||
|
.put("generatorClass", mainClass)
|
||||||
|
.put("name", name)
|
||||||
|
.put("fullyQualifiedGeneratorClass", targetPackage + "." + mainClass).build();
|
||||||
|
|
||||||
|
|
||||||
|
with(supportingFiles).convert(processFiles(targetDir, data));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Converter method to process supporting files: execute with mustache,
|
||||||
|
* or simply copy to destination directory
|
||||||
|
* @param targetDir - destination directory
|
||||||
|
* @param data - map with additional params needed to process templates
|
||||||
|
* @return converter object to pass to lambdaj
|
||||||
|
*/
|
||||||
|
private Converter<SupportingFile, File> processFiles(final File targetDir, final Map<String, Object> data) {
|
||||||
|
return new Converter<SupportingFile, File>() {
|
||||||
|
private DefaultGenerator generator = new DefaultGenerator();
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public File convert(SupportingFile support) {
|
||||||
|
try {
|
||||||
|
File destinationFolder = new File(new File(targetDir.getAbsolutePath()), support.folder);
|
||||||
|
File outputFile = new File(destinationFolder, support.destinationFilename);
|
||||||
|
|
||||||
|
String template = generator
|
||||||
|
.readTemplate(new File(TEMPLATE_DIR_CLASSPATH, support.templateFile).getPath());
|
||||||
|
String formatted = template;
|
||||||
|
|
||||||
|
if (support.templateFile.endsWith(MUSTACHE_EXTENSION)) {
|
||||||
|
LOG.info("writing file to {}", outputFile.getAbsolutePath());
|
||||||
|
formatted = Mustache.compiler().withLoader(loader(generator))
|
||||||
|
.defaultValue("")
|
||||||
|
.compile(template)
|
||||||
|
.execute(data);
|
||||||
|
} else {
|
||||||
|
LOG.info("copying file to {}", outputFile.getAbsolutePath());
|
||||||
|
}
|
||||||
|
|
||||||
|
FileUtils.writeStringToFile(outputFile, formatted);
|
||||||
|
return outputFile;
|
||||||
|
|
||||||
|
} catch (IOException e) {
|
||||||
|
throw new RuntimeException("Can't generate project", e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates mustache loader for template using classpath loader
|
||||||
|
* @param generator - class with reader getter
|
||||||
|
* @return loader for template
|
||||||
|
*/
|
||||||
|
private Mustache.TemplateLoader loader(final DefaultGenerator generator) {
|
||||||
|
return new Mustache.TemplateLoader() {
|
||||||
|
public Reader getTemplate(String name) {
|
||||||
|
return generator.getTemplateReader(TEMPLATE_DIR_CLASSPATH
|
||||||
|
+ File.separator + name.concat(MUSTACHE_EXTENSION));
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Converts package name to path on file system
|
||||||
|
* @param packageName - package name to convert
|
||||||
|
* @return relative path
|
||||||
|
*/
|
||||||
|
private String asPath(String packageName) {
|
||||||
|
return packageName.replace(".", File.separator);
|
||||||
|
}
|
||||||
|
}
|
@ -1,80 +0,0 @@
|
|||||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
|
|
||||||
<parent>
|
|
||||||
<groupId>com.wordnik</groupId>
|
|
||||||
<artifactId>swagger-codegen-project</artifactId>
|
|
||||||
<version>2.1.3-M1-SNAPSHOT</version>
|
|
||||||
<relativePath>../..</relativePath>
|
|
||||||
</parent>
|
|
||||||
<modelVersion>4.0.0</modelVersion>
|
|
||||||
<groupId>com.wordnik</groupId>
|
|
||||||
<artifactId>swagger-codegen-distribution</artifactId>
|
|
||||||
<packaging>jar</packaging>
|
|
||||||
<name>swagger-codegen (executable)</name>
|
|
||||||
<version>2.1.3-M1-SNAPSHOT</version>
|
|
||||||
<build>
|
|
||||||
<testSourceDirectory>src/test/scala</testSourceDirectory>
|
|
||||||
<outputDirectory>target/classes</outputDirectory>
|
|
||||||
<testOutputDirectory>target/test-classes</testOutputDirectory>
|
|
||||||
<defaultGoal>install</defaultGoal>
|
|
||||||
<directory>target</directory>
|
|
||||||
<finalName>${project.artifactId}-${project.version}</finalName>
|
|
||||||
<plugins>
|
|
||||||
<plugin>
|
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
|
||||||
<artifactId>maven-jar-plugin</artifactId>
|
|
||||||
<configuration>
|
|
||||||
<archive>
|
|
||||||
<manifest>
|
|
||||||
<mainClass>com.wordnik.swagger.codegen.Codegen</mainClass>
|
|
||||||
</manifest>
|
|
||||||
</archive>
|
|
||||||
</configuration>
|
|
||||||
</plugin>
|
|
||||||
<plugin>
|
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
|
||||||
<artifactId>maven-shade-plugin</artifactId>
|
|
||||||
<version>2.3</version>
|
|
||||||
<executions>
|
|
||||||
<execution>
|
|
||||||
<phase>package</phase>
|
|
||||||
<goals>
|
|
||||||
<goal>shade</goal>
|
|
||||||
</goals>
|
|
||||||
<configuration>
|
|
||||||
<minimizeJar>false</minimizeJar>
|
|
||||||
<createDependencyReducedPom>true</createDependencyReducedPom>
|
|
||||||
<dependencyReducedPomLocation>
|
|
||||||
${java.io.tmpdir}/dependency-reduced-pom.xml
|
|
||||||
</dependencyReducedPomLocation>
|
|
||||||
</configuration>
|
|
||||||
</execution>
|
|
||||||
</executions>
|
|
||||||
</plugin>
|
|
||||||
<plugin>
|
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
|
||||||
<artifactId>maven-shade-plugin</artifactId>
|
|
||||||
<version>2.3</version>
|
|
||||||
<executions>
|
|
||||||
<execution>
|
|
||||||
<phase>package</phase>
|
|
||||||
<goals>
|
|
||||||
<goal>shade</goal>
|
|
||||||
</goals>
|
|
||||||
<configuration>
|
|
||||||
<transformers>
|
|
||||||
<transformer implementation="org.apache.maven.plugins.shade.resource.ServicesResourceTransformer"/>
|
|
||||||
</transformers>
|
|
||||||
</configuration>
|
|
||||||
</execution>
|
|
||||||
</executions>
|
|
||||||
</plugin>
|
|
||||||
</plugins>
|
|
||||||
</build>
|
|
||||||
<dependencies>
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.wordnik</groupId>
|
|
||||||
<artifactId>swagger-codegen</artifactId>
|
|
||||||
<version>${project.parent.version}</version>
|
|
||||||
</dependency>
|
|
||||||
</dependencies>
|
|
||||||
</project>
|
|
@ -745,6 +745,8 @@ public class DefaultCodegen {
|
|||||||
op.isMapContainer = Boolean.TRUE;
|
op.isMapContainer = Boolean.TRUE;
|
||||||
else if ("list".equalsIgnoreCase(cm.containerType))
|
else if ("list".equalsIgnoreCase(cm.containerType))
|
||||||
op.isListContainer = Boolean.TRUE;
|
op.isListContainer = Boolean.TRUE;
|
||||||
|
else if ("array".equalsIgnoreCase(cm.containerType))
|
||||||
|
op.isListContainer = Boolean.TRUE;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
op.returnSimpleType = true;
|
op.returnSimpleType = true;
|
||||||
|
@ -1,15 +1,30 @@
|
|||||||
package com.wordnik.swagger.codegen;
|
package com.wordnik.swagger.codegen;
|
||||||
|
|
||||||
import com.wordnik.swagger.models.*;
|
import com.samskivert.mustache.Mustache;
|
||||||
|
import com.samskivert.mustache.Template;
|
||||||
|
import com.wordnik.swagger.models.Contact;
|
||||||
|
import com.wordnik.swagger.models.Info;
|
||||||
|
import com.wordnik.swagger.models.License;
|
||||||
|
import com.wordnik.swagger.models.Model;
|
||||||
|
import com.wordnik.swagger.models.Operation;
|
||||||
|
import com.wordnik.swagger.models.Path;
|
||||||
|
import com.wordnik.swagger.models.Swagger;
|
||||||
import com.wordnik.swagger.models.auth.SecuritySchemeDefinition;
|
import com.wordnik.swagger.models.auth.SecuritySchemeDefinition;
|
||||||
import com.wordnik.swagger.util.*;
|
import com.wordnik.swagger.util.Json;
|
||||||
import com.samskivert.mustache.*;
|
|
||||||
|
|
||||||
import org.apache.commons.io.FileUtils;
|
import org.apache.commons.io.FileUtils;
|
||||||
|
|
||||||
import java.util.*;
|
import java.io.File;
|
||||||
import java.util.regex.*;
|
import java.io.Reader;
|
||||||
import java.io.*;
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.LinkedHashMap;
|
||||||
|
import java.util.LinkedHashSet;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
|
import static org.apache.commons.lang3.StringUtils.capitalize;
|
||||||
|
import static org.apache.commons.lang3.StringUtils.isNotEmpty;
|
||||||
|
|
||||||
public class DefaultGenerator extends AbstractGenerator implements Generator {
|
public class DefaultGenerator extends AbstractGenerator implements Generator {
|
||||||
protected CodegenConfig config;
|
protected CodegenConfig config;
|
||||||
@ -20,64 +35,71 @@ public class DefaultGenerator extends AbstractGenerator implements Generator {
|
|||||||
this.opts = opts;
|
this.opts = opts;
|
||||||
|
|
||||||
this.swagger = opts.getSwagger();
|
this.swagger = opts.getSwagger();
|
||||||
ClientOpts clientOpts = opts.getOpts();
|
|
||||||
this.config = opts.getConfig();
|
this.config = opts.getConfig();
|
||||||
this.config.additionalProperties().putAll(clientOpts.getProperties());
|
this.config.additionalProperties().putAll(opts.getOpts().getProperties());
|
||||||
|
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<File> generate() {
|
public List<File> generate() {
|
||||||
if(swagger == null || config == null) {
|
if (swagger == null || config == null) {
|
||||||
throw new RuntimeException("missing swagger input or config!");
|
throw new RuntimeException("missing swagger input or config!");
|
||||||
}
|
}
|
||||||
if(System.getProperty("debugSwagger") != null) {
|
if (System.getProperty("debugSwagger") != null) {
|
||||||
Json.prettyPrint(swagger);
|
Json.prettyPrint(swagger);
|
||||||
}
|
}
|
||||||
List<File> files = new ArrayList<File>();
|
List<File> files = new ArrayList<File>();
|
||||||
try {
|
try {
|
||||||
config.processOpts();
|
config.processOpts();
|
||||||
if(swagger.getInfo() != null) {
|
if (swagger.getInfo() != null) {
|
||||||
Info info = swagger.getInfo();
|
Info info = swagger.getInfo();
|
||||||
if(info.getTitle() != null)
|
if (info.getTitle() != null) {
|
||||||
config.additionalProperties().put("appName", info.getTitle());
|
config.additionalProperties().put("appName", info.getTitle());
|
||||||
if(info.getVersion() != null)
|
}
|
||||||
|
if (info.getVersion() != null) {
|
||||||
config.additionalProperties().put("appVersion", info.getVersion());
|
config.additionalProperties().put("appVersion", info.getVersion());
|
||||||
if(info.getDescription() != null)
|
}
|
||||||
|
if (info.getDescription() != null) {
|
||||||
config.additionalProperties().put("appDescription", info.getDescription());
|
config.additionalProperties().put("appDescription", info.getDescription());
|
||||||
if(info.getContact() != null) {
|
}
|
||||||
|
if (info.getContact() != null) {
|
||||||
Contact contact = info.getContact();
|
Contact contact = info.getContact();
|
||||||
config.additionalProperties().put("infoUrl", contact.getUrl());
|
config.additionalProperties().put("infoUrl", contact.getUrl());
|
||||||
if(contact.getEmail() != null)
|
if (contact.getEmail() != null) {
|
||||||
config.additionalProperties().put("infoEmail", contact.getEmail());
|
config.additionalProperties().put("infoEmail", contact.getEmail());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if(info.getLicense() != null) {
|
if (info.getLicense() != null) {
|
||||||
License license = info.getLicense();
|
License license = info.getLicense();
|
||||||
if(license.getName() != null)
|
if (license.getName() != null) {
|
||||||
config.additionalProperties().put("licenseInfo", license.getName());
|
config.additionalProperties().put("licenseInfo", license.getName());
|
||||||
if(license.getUrl() != null)
|
}
|
||||||
|
if (license.getUrl() != null) {
|
||||||
config.additionalProperties().put("licenseUrl", license.getUrl());
|
config.additionalProperties().put("licenseUrl", license.getUrl());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if(info.getVersion() != null) {
|
if (info.getVersion() != null) {
|
||||||
config.additionalProperties().put("version", info.getVersion());
|
config.additionalProperties().put("version", info.getVersion());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
StringBuilder hostBuilder = new StringBuilder();
|
StringBuilder hostBuilder = new StringBuilder();
|
||||||
if(swagger.getSchemes() != null && swagger.getSchemes().size() > 0) {
|
if (swagger.getSchemes() != null && swagger.getSchemes().size() > 0) {
|
||||||
hostBuilder.append(swagger.getSchemes().get(0).toValue());
|
hostBuilder.append(swagger.getSchemes().get(0).toValue());
|
||||||
hostBuilder.append("://");
|
hostBuilder.append("://");
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
hostBuilder.append("https://");
|
hostBuilder.append("https://");
|
||||||
if(swagger.getHost() != null)
|
}
|
||||||
|
if (swagger.getHost() != null) {
|
||||||
hostBuilder.append(swagger.getHost());
|
hostBuilder.append(swagger.getHost());
|
||||||
else
|
} else {
|
||||||
hostBuilder.append("localhost");
|
hostBuilder.append("localhost");
|
||||||
if(swagger.getBasePath() != null)
|
}
|
||||||
|
if (swagger.getBasePath() != null) {
|
||||||
hostBuilder.append(swagger.getBasePath());
|
hostBuilder.append(swagger.getBasePath());
|
||||||
else
|
} else {
|
||||||
hostBuilder.append("/");
|
hostBuilder.append("/");
|
||||||
|
}
|
||||||
String contextPath = swagger.getBasePath() == null ? "/" : swagger.getBasePath();
|
String contextPath = swagger.getBasePath() == null ? "/" : swagger.getBasePath();
|
||||||
String basePath = hostBuilder.toString();
|
String basePath = hostBuilder.toString();
|
||||||
|
|
||||||
@ -87,41 +109,41 @@ public class DefaultGenerator extends AbstractGenerator implements Generator {
|
|||||||
|
|
||||||
// models
|
// models
|
||||||
Map<String, Model> definitions = swagger.getDefinitions();
|
Map<String, Model> definitions = swagger.getDefinitions();
|
||||||
if(definitions != null) {
|
if (definitions != null) {
|
||||||
for(String name: definitions.keySet()) {
|
for (String name : definitions.keySet()) {
|
||||||
Model model = definitions.get(name);
|
Model model = definitions.get(name);
|
||||||
Map<String, Model> modelMap = new HashMap<String, Model>();
|
Map<String, Model> modelMap = new HashMap<String, Model>();
|
||||||
modelMap.put(name, model);
|
modelMap.put(name, model);
|
||||||
Map<String, Object> models = processModels(config, modelMap);
|
Map<String, Object> models = processModels(config, modelMap);
|
||||||
models.putAll(config.additionalProperties());
|
models.putAll(config.additionalProperties());
|
||||||
|
|
||||||
allModels.add(((List<Object>)models.get("models")).get(0));
|
allModels.add(((List<Object>) models.get("models")).get(0));
|
||||||
|
|
||||||
for(String templateName : config.modelTemplateFiles().keySet()) {
|
for (String templateName : config.modelTemplateFiles().keySet()) {
|
||||||
String suffix = config.modelTemplateFiles().get(templateName);
|
String suffix = config.modelTemplateFiles().get(templateName);
|
||||||
String filename = config.modelFileFolder() + File.separator + config.toModelFilename(name) + suffix;
|
String filename = config.modelFileFolder() + File.separator + config.toModelFilename(name) + suffix;
|
||||||
String template = readTemplate(config.templateDir() + File.separator + templateName);
|
String template = readTemplate(config.templateDir() + File.separator + templateName);
|
||||||
Template tmpl = Mustache.compiler()
|
Template tmpl = Mustache.compiler()
|
||||||
.withLoader(new Mustache.TemplateLoader() {
|
.withLoader(new Mustache.TemplateLoader() {
|
||||||
public Reader getTemplate (String name) {
|
public Reader getTemplate(String name) {
|
||||||
return getTemplateReader(config.templateDir() + File.separator + name + ".mustache");
|
return getTemplateReader(config.templateDir() + File.separator + name + ".mustache");
|
||||||
};
|
}
|
||||||
})
|
})
|
||||||
.defaultValue("")
|
.defaultValue("")
|
||||||
.compile(template);
|
.compile(template);
|
||||||
writeToFile(filename, tmpl.execute(models));
|
writeToFile(filename, tmpl.execute(models));
|
||||||
files.add(new File(filename));
|
files.add(new File(filename));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(System.getProperty("debugModels") != null) {
|
if (System.getProperty("debugModels") != null) {
|
||||||
System.out.println("############ Model info ############");
|
System.out.println("############ Model info ############");
|
||||||
Json.prettyPrint(allModels);
|
Json.prettyPrint(allModels);
|
||||||
}
|
}
|
||||||
|
|
||||||
// apis
|
// apis
|
||||||
Map<String, List<CodegenOperation>> paths = processPaths(swagger.getPaths());
|
Map<String, List<CodegenOperation>> paths = processPaths(swagger.getPaths());
|
||||||
for(String tag : paths.keySet()) {
|
for (String tag : paths.keySet()) {
|
||||||
List<CodegenOperation> ops = paths.get(tag);
|
List<CodegenOperation> ops = paths.get(tag);
|
||||||
Map<String, Object> operation = processOperations(config, tag, ops);
|
Map<String, Object> operation = processOperations(config, tag, ops);
|
||||||
operation.put("basePath", basePath);
|
operation.put("basePath", basePath);
|
||||||
@ -131,36 +153,37 @@ public class DefaultGenerator extends AbstractGenerator implements Generator {
|
|||||||
operation.putAll(config.additionalProperties());
|
operation.putAll(config.additionalProperties());
|
||||||
operation.put("classname", config.toApiName(tag));
|
operation.put("classname", config.toApiName(tag));
|
||||||
operation.put("classVarName", config.toApiVarName(tag));
|
operation.put("classVarName", config.toApiVarName(tag));
|
||||||
|
|
||||||
allOperations.add(new HashMap<String, Object>(operation));
|
allOperations.add(new HashMap<String, Object>(operation));
|
||||||
for(int i = 0; i < allOperations.size(); i++) {
|
for (int i = 0; i < allOperations.size(); i++) {
|
||||||
Map<String, Object> oo = (Map<String, Object>) allOperations.get(i);
|
Map<String, Object> oo = (Map<String, Object>) allOperations.get(i);
|
||||||
if(i < (allOperations.size() -1))
|
if (i < (allOperations.size() - 1)) {
|
||||||
oo.put("hasMore", "true");
|
oo.put("hasMore", "true");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for(String templateName : config.apiTemplateFiles().keySet()) {
|
for (String templateName : config.apiTemplateFiles().keySet()) {
|
||||||
String suffix = config.apiTemplateFiles().get(templateName);
|
String suffix = config.apiTemplateFiles().get(templateName);
|
||||||
String filename = config.apiFileFolder() +
|
String filename = config.apiFileFolder() +
|
||||||
File.separator +
|
File.separator +
|
||||||
config.toApiFilename(tag) +
|
config.toApiFilename(tag) +
|
||||||
suffix;
|
suffix;
|
||||||
|
|
||||||
String template = readTemplate(config.templateDir() + File.separator + templateName);
|
String template = readTemplate(config.templateDir() + File.separator + templateName);
|
||||||
Template tmpl = Mustache.compiler()
|
Template tmpl = Mustache.compiler()
|
||||||
.withLoader(new Mustache.TemplateLoader() {
|
.withLoader(new Mustache.TemplateLoader() {
|
||||||
public Reader getTemplate (String name) {
|
public Reader getTemplate(String name) {
|
||||||
return getTemplateReader(config.templateDir() + File.separator + name + ".mustache");
|
return getTemplateReader(config.templateDir() + File.separator + name + ".mustache");
|
||||||
};
|
}
|
||||||
})
|
})
|
||||||
.defaultValue("")
|
.defaultValue("")
|
||||||
.compile(template);
|
.compile(template);
|
||||||
|
|
||||||
writeToFile(filename, tmpl.execute(operation));
|
writeToFile(filename, tmpl.execute(operation));
|
||||||
files.add(new File(filename));
|
files.add(new File(filename));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(System.getProperty("debugOperations") != null) {
|
if (System.getProperty("debugOperations") != null) {
|
||||||
System.out.println("############ Operation info ############");
|
System.out.println("############ Operation info ############");
|
||||||
Json.prettyPrint(allOperations);
|
Json.prettyPrint(allOperations);
|
||||||
}
|
}
|
||||||
@ -172,7 +195,7 @@ public class DefaultGenerator extends AbstractGenerator implements Generator {
|
|||||||
|
|
||||||
Map<String, Object> apis = new HashMap<String, Object>();
|
Map<String, Object> apis = new HashMap<String, Object>();
|
||||||
apis.put("apis", allOperations);
|
apis.put("apis", allOperations);
|
||||||
if(swagger.getHost() != null) {
|
if (swagger.getHost() != null) {
|
||||||
bundle.put("host", swagger.getHost());
|
bundle.put("host", swagger.getHost());
|
||||||
}
|
}
|
||||||
bundle.put("basePath", basePath);
|
bundle.put("basePath", basePath);
|
||||||
@ -184,7 +207,7 @@ public class DefaultGenerator extends AbstractGenerator implements Generator {
|
|||||||
if (swagger.getExternalDocs() != null) {
|
if (swagger.getExternalDocs() != null) {
|
||||||
bundle.put("externalDocs", swagger.getExternalDocs());
|
bundle.put("externalDocs", swagger.getExternalDocs());
|
||||||
}
|
}
|
||||||
for(int i = 0; i < allModels.size() - 1; i++) {
|
for (int i = 0; i < allModels.size() - 1; i++) {
|
||||||
HashMap<String, CodegenModel> cm = (HashMap<String, CodegenModel>) allModels.get(i);
|
HashMap<String, CodegenModel> cm = (HashMap<String, CodegenModel>) allModels.get(i);
|
||||||
CodegenModel m = cm.get("model");
|
CodegenModel m = cm.get("model");
|
||||||
m.hasMoreModels = true;
|
m.hasMoreModels = true;
|
||||||
@ -192,35 +215,36 @@ public class DefaultGenerator extends AbstractGenerator implements Generator {
|
|||||||
|
|
||||||
config.postProcessSupportingFileData(bundle);
|
config.postProcessSupportingFileData(bundle);
|
||||||
|
|
||||||
if(System.getProperty("debugSupportingFiles") != null) {
|
if (System.getProperty("debugSupportingFiles") != null) {
|
||||||
System.out.println("############ Supporting file info ############");
|
System.out.println("############ Supporting file info ############");
|
||||||
Json.prettyPrint(bundle);
|
Json.prettyPrint(bundle);
|
||||||
}
|
}
|
||||||
|
|
||||||
for(SupportingFile support : config.supportingFiles()) {
|
for (SupportingFile support : config.supportingFiles()) {
|
||||||
String outputFolder = config.outputFolder();
|
String outputFolder = config.outputFolder();
|
||||||
if(support.folder != null && !"".equals(support.folder))
|
if (isNotEmpty(support.folder)) {
|
||||||
outputFolder += File.separator + support.folder;
|
outputFolder += File.separator + support.folder;
|
||||||
|
}
|
||||||
File of = new File(outputFolder);
|
File of = new File(outputFolder);
|
||||||
if(!of.isDirectory())
|
if (!of.isDirectory()) {
|
||||||
of.mkdirs();
|
of.mkdirs();
|
||||||
|
}
|
||||||
String outputFilename = outputFolder + File.separator + support.destinationFilename;
|
String outputFilename = outputFolder + File.separator + support.destinationFilename;
|
||||||
|
|
||||||
if(support.templateFile.endsWith("mustache")) {
|
if (support.templateFile.endsWith("mustache")) {
|
||||||
String template = readTemplate(config.templateDir() + File.separator + support.templateFile);
|
String template = readTemplate(config.templateDir() + File.separator + support.templateFile);
|
||||||
Template tmpl = Mustache.compiler()
|
Template tmpl = Mustache.compiler()
|
||||||
.withLoader(new Mustache.TemplateLoader() {
|
.withLoader(new Mustache.TemplateLoader() {
|
||||||
public Reader getTemplate (String name) {
|
public Reader getTemplate(String name) {
|
||||||
return getTemplateReader(config.templateDir() + File.separator + name + ".mustache");
|
return getTemplateReader(config.templateDir() + File.separator + name + ".mustache");
|
||||||
};
|
}
|
||||||
})
|
})
|
||||||
.defaultValue("")
|
.defaultValue("")
|
||||||
.compile(template);
|
.compile(template);
|
||||||
|
|
||||||
writeToFile(outputFilename, tmpl.execute(bundle));
|
writeToFile(outputFilename, tmpl.execute(bundle));
|
||||||
files.add(new File(outputFilename));
|
files.add(new File(outputFilename));
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
String template = readTemplate(config.templateDir() + File.separator + support.templateFile);
|
String template = readTemplate(config.templateDir() + File.separator + support.templateFile);
|
||||||
FileUtils.writeStringToFile(new File(outputFilename), template);
|
FileUtils.writeStringToFile(new File(outputFilename), template);
|
||||||
System.out.println("copying file to " + outputFilename);
|
System.out.println("copying file to " + outputFilename);
|
||||||
@ -229,8 +253,7 @@ public class DefaultGenerator extends AbstractGenerator implements Generator {
|
|||||||
}
|
}
|
||||||
|
|
||||||
config.processSwagger(swagger);
|
config.processSwagger(swagger);
|
||||||
}
|
} catch (Exception e) {
|
||||||
catch (Exception e) {
|
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
return files;
|
return files;
|
||||||
@ -238,9 +261,8 @@ public class DefaultGenerator extends AbstractGenerator implements Generator {
|
|||||||
|
|
||||||
public Map<String, List<CodegenOperation>> processPaths(Map<String, Path> paths) {
|
public Map<String, List<CodegenOperation>> processPaths(Map<String, Path> paths) {
|
||||||
Map<String, List<CodegenOperation>> ops = new HashMap<String, List<CodegenOperation>>();
|
Map<String, List<CodegenOperation>> ops = new HashMap<String, List<CodegenOperation>>();
|
||||||
List<String> tags = null;
|
|
||||||
|
|
||||||
for(String resourcePath : paths.keySet()) {
|
for (String resourcePath : paths.keySet()) {
|
||||||
Path path = paths.get(resourcePath);
|
Path path = paths.get(resourcePath);
|
||||||
processOperation(resourcePath, "get", path.getGet(), ops);
|
processOperation(resourcePath, "get", path.getGet(), ops);
|
||||||
processOperation(resourcePath, "put", path.getPut(), ops);
|
processOperation(resourcePath, "put", path.getPut(), ops);
|
||||||
@ -254,18 +276,15 @@ public class DefaultGenerator extends AbstractGenerator implements Generator {
|
|||||||
|
|
||||||
public SecuritySchemeDefinition fromSecurity(String name) {
|
public SecuritySchemeDefinition fromSecurity(String name) {
|
||||||
Map<String, SecuritySchemeDefinition> map = swagger.getSecurityDefinitions();
|
Map<String, SecuritySchemeDefinition> map = swagger.getSecurityDefinitions();
|
||||||
if(map == null)
|
if (map == null) {
|
||||||
return null;
|
return null;
|
||||||
SecuritySchemeDefinition scheme = map.get(name);
|
}
|
||||||
if(scheme == null)
|
return map.get(name);
|
||||||
return null;
|
|
||||||
return scheme;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public void processOperation(String resourcePath, String httpMethod, Operation operation, Map<String, List<CodegenOperation>> operations) {
|
public void processOperation(String resourcePath, String httpMethod, Operation operation, Map<String, List<CodegenOperation>> operations) {
|
||||||
if(operation != null) {
|
if (operation != null) {
|
||||||
List<String> tags = operation.getTags();
|
List<String> tags = operation.getTags();
|
||||||
if (tags == null) {
|
if (tags == null) {
|
||||||
tags = new ArrayList<String>();
|
tags = new ArrayList<String>();
|
||||||
@ -279,20 +298,22 @@ public class DefaultGenerator extends AbstractGenerator implements Generator {
|
|||||||
config.addOperationToGroup(sanitizeTag(tag), resourcePath, operation, co, operations);
|
config.addOperationToGroup(sanitizeTag(tag), resourcePath, operation, co, operations);
|
||||||
|
|
||||||
List<Map<String, List<String>>> securities = operation.getSecurity();
|
List<Map<String, List<String>>> securities = operation.getSecurity();
|
||||||
if(securities == null)
|
if (securities == null) {
|
||||||
continue;
|
continue;
|
||||||
|
}
|
||||||
Map<String, SecuritySchemeDefinition> authMethods = new HashMap<String, SecuritySchemeDefinition>();
|
Map<String, SecuritySchemeDefinition> authMethods = new HashMap<String, SecuritySchemeDefinition>();
|
||||||
for (Map<String, List<String>> security : securities) {
|
for (Map<String, List<String>> security : securities) {
|
||||||
if (security.size() != 1) {
|
if (security.size() != 1) {
|
||||||
//Not sure what to do
|
//Not sure what to do
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
String securityName = security.keySet().iterator().next();
|
String securityName = security.keySet().iterator().next();
|
||||||
SecuritySchemeDefinition securityDefinition = fromSecurity(securityName);
|
SecuritySchemeDefinition securityDefinition = fromSecurity(securityName);
|
||||||
if(securityDefinition != null)
|
if (securityDefinition != null) {
|
||||||
authMethods.put(securityName, securityDefinition);
|
authMethods.put(securityName, securityDefinition);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if(!authMethods.isEmpty()) {
|
if (!authMethods.isEmpty()) {
|
||||||
co.authMethods = config.fromSecurity(authMethods);
|
co.authMethods = config.fromSecurity(authMethods);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -301,13 +322,11 @@ public class DefaultGenerator extends AbstractGenerator implements Generator {
|
|||||||
|
|
||||||
protected String sanitizeTag(String tag) {
|
protected String sanitizeTag(String tag) {
|
||||||
// remove spaces and make strong case
|
// remove spaces and make strong case
|
||||||
String [] parts = tag.split(" ");
|
String[] parts = tag.split(" ");
|
||||||
StringBuffer buf = new StringBuffer();
|
StringBuilder buf = new StringBuilder();
|
||||||
for(String part: parts) {
|
for (String part : parts) {
|
||||||
if(!"".equals(part)) {
|
if (isNotEmpty(part)) {
|
||||||
buf.append(Character.toUpperCase(part.charAt(0)));
|
buf.append(capitalize(part));
|
||||||
if(part.length() > 1)
|
|
||||||
buf.append(part.substring(1));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return buf.toString().replaceAll("[^a-zA-Z ]", "");
|
return buf.toString().replaceAll("[^a-zA-Z ]", "");
|
||||||
@ -322,30 +341,31 @@ public class DefaultGenerator extends AbstractGenerator implements Generator {
|
|||||||
operations.put("package", config.apiPackage());
|
operations.put("package", config.apiPackage());
|
||||||
|
|
||||||
Set<String> allImports = new LinkedHashSet<String>();
|
Set<String> allImports = new LinkedHashSet<String>();
|
||||||
for(CodegenOperation op: ops) {
|
for (CodegenOperation op : ops) {
|
||||||
allImports.addAll(op.imports);
|
allImports.addAll(op.imports);
|
||||||
}
|
}
|
||||||
|
|
||||||
List<Map<String, String>> imports = new ArrayList<Map<String, String>>();
|
List<Map<String, String>> imports = new ArrayList<Map<String, String>>();
|
||||||
for(String i: allImports) {
|
for (String nextImport : allImports) {
|
||||||
Map<String, String> im = new LinkedHashMap<String, String>();
|
Map<String, String> im = new LinkedHashMap<String, String>();
|
||||||
String m = config.importMapping().get(i);
|
String mapping = config.importMapping().get(nextImport);
|
||||||
if(m == null)
|
if (mapping == null) {
|
||||||
m = config.toModelImport(i);
|
mapping = config.toModelImport(nextImport);
|
||||||
if(m != null) {
|
}
|
||||||
im.put("import", m);
|
if (mapping != null) {
|
||||||
|
im.put("import", mapping);
|
||||||
imports.add(im);
|
imports.add(im);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
operations.put("imports", imports);
|
operations.put("imports", imports);
|
||||||
config.postProcessOperations(operations);
|
config.postProcessOperations(operations);
|
||||||
if(objs.size() > 0) {
|
if (objs.size() > 0) {
|
||||||
List<CodegenOperation> os = (List<CodegenOperation>) objs.get("operation");
|
List<CodegenOperation> os = (List<CodegenOperation>) objs.get("operation");
|
||||||
|
|
||||||
if(os != null && os.size() > 0) {
|
if (os != null && os.size() > 0) {
|
||||||
CodegenOperation op = os.get(os.size() - 1);
|
CodegenOperation op = os.get(os.size() - 1);
|
||||||
op.hasMore = null;
|
op.hasMore = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return operations;
|
return operations;
|
||||||
@ -355,9 +375,8 @@ public class DefaultGenerator extends AbstractGenerator implements Generator {
|
|||||||
Map<String, Object> objs = new HashMap<String, Object>();
|
Map<String, Object> objs = new HashMap<String, Object>();
|
||||||
objs.put("package", config.modelPackage());
|
objs.put("package", config.modelPackage());
|
||||||
List<Object> models = new ArrayList<Object>();
|
List<Object> models = new ArrayList<Object>();
|
||||||
List<Object> model = new ArrayList<Object>();
|
|
||||||
Set<String> allImports = new LinkedHashSet<String>();
|
Set<String> allImports = new LinkedHashSet<String>();
|
||||||
for(String key: definitions.keySet()) {
|
for (String key : definitions.keySet()) {
|
||||||
Model mm = definitions.get(key);
|
Model mm = definitions.get(key);
|
||||||
CodegenModel cm = config.fromModel(key, mm);
|
CodegenModel cm = config.fromModel(key, mm);
|
||||||
Map<String, Object> mo = new HashMap<String, Object>();
|
Map<String, Object> mo = new HashMap<String, Object>();
|
||||||
@ -368,19 +387,20 @@ public class DefaultGenerator extends AbstractGenerator implements Generator {
|
|||||||
objs.put("models", models);
|
objs.put("models", models);
|
||||||
|
|
||||||
List<Map<String, String>> imports = new ArrayList<Map<String, String>>();
|
List<Map<String, String>> imports = new ArrayList<Map<String, String>>();
|
||||||
for(String i: allImports) {
|
for (String nextImport : allImports) {
|
||||||
Map<String, String> im = new LinkedHashMap<String, String>();
|
Map<String, String> im = new LinkedHashMap<String, String>();
|
||||||
String m = config.importMapping().get(i);
|
String mapping = config.importMapping().get(nextImport);
|
||||||
if(m == null)
|
if (mapping == null) {
|
||||||
m = config.toModelImport(i);
|
mapping = config.toModelImport(nextImport);
|
||||||
if(m != null && !config.defaultIncludes().contains(m)) {
|
}
|
||||||
im.put("import", m);
|
if (mapping != null && !config.defaultIncludes().contains(mapping)) {
|
||||||
|
im.put("import", mapping);
|
||||||
imports.add(im);
|
imports.add(im);
|
||||||
}
|
}
|
||||||
// add instantiation types
|
// add instantiation types
|
||||||
m = config.instantiationTypes().get(i);
|
mapping = config.instantiationTypes().get(nextImport);
|
||||||
if(m != null && !config.defaultIncludes().contains(m)) {
|
if (mapping != null && !config.defaultIncludes().contains(mapping)) {
|
||||||
im.put("import", m);
|
im.put("import", mapping);
|
||||||
imports.add(im);
|
imports.add(im);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -24,6 +24,7 @@ public class ExampleGenerator {
|
|||||||
|
|
||||||
public List<Map<String, String>> generate(Map<String, String> examples, List<String> mediaTypes, Property property) {
|
public List<Map<String, String>> generate(Map<String, String> examples, List<String> mediaTypes, Property property) {
|
||||||
List<Map<String, String>> output = new ArrayList<Map<String, String>>();
|
List<Map<String, String>> output = new ArrayList<Map<String, String>>();
|
||||||
|
Set<String> processedModels = new HashSet<String>();
|
||||||
if(examples == null ) {
|
if(examples == null ) {
|
||||||
if(mediaTypes == null) {
|
if(mediaTypes == null) {
|
||||||
// assume application/json for this
|
// assume application/json for this
|
||||||
@ -33,7 +34,7 @@ public class ExampleGenerator {
|
|||||||
Map<String, String> kv = new HashMap<String, String>();
|
Map<String, String> kv = new HashMap<String, String>();
|
||||||
kv.put("contentType", mediaType);
|
kv.put("contentType", mediaType);
|
||||||
if(property != null && mediaType.startsWith("application/json")) {
|
if(property != null && mediaType.startsWith("application/json")) {
|
||||||
String example = Json.pretty(resolvePropertyToExample(mediaType, property));
|
String example = Json.pretty(resolvePropertyToExample(mediaType, property, processedModels));
|
||||||
|
|
||||||
if(example != null) {
|
if(example != null) {
|
||||||
example = example.replaceAll("\n", "\\\\n");
|
example = example.replaceAll("\n", "\\\\n");
|
||||||
@ -69,7 +70,7 @@ public class ExampleGenerator {
|
|||||||
return output;
|
return output;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected Object resolvePropertyToExample(String mediaType, Property property) {
|
protected Object resolvePropertyToExample(String mediaType, Property property, Set<String> processedModels) {
|
||||||
if(property.getExample() != null) {
|
if(property.getExample() != null) {
|
||||||
return property.getExample();
|
return property.getExample();
|
||||||
}
|
}
|
||||||
@ -83,7 +84,7 @@ public class ExampleGenerator {
|
|||||||
Property innerType = ((ArrayProperty)property).getItems();
|
Property innerType = ((ArrayProperty)property).getItems();
|
||||||
if(innerType != null) {
|
if(innerType != null) {
|
||||||
Object[] output = new Object[]{
|
Object[] output = new Object[]{
|
||||||
resolvePropertyToExample(mediaType, innerType)
|
resolvePropertyToExample(mediaType, innerType, processedModels)
|
||||||
};
|
};
|
||||||
return output;
|
return output;
|
||||||
}
|
}
|
||||||
@ -116,11 +117,11 @@ public class ExampleGenerator {
|
|||||||
Map<String, Object> mp = new HashMap<String, Object>();
|
Map<String, Object> mp = new HashMap<String, Object>();
|
||||||
if(property.getName() != null) {
|
if(property.getName() != null) {
|
||||||
mp.put(property.getName(),
|
mp.put(property.getName(),
|
||||||
resolvePropertyToExample(mediaType, ((MapProperty)property).getAdditionalProperties()));
|
resolvePropertyToExample(mediaType, ((MapProperty)property).getAdditionalProperties(), processedModels));
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
mp.put("key",
|
mp.put("key",
|
||||||
resolvePropertyToExample(mediaType, ((MapProperty)property).getAdditionalProperties()));
|
resolvePropertyToExample(mediaType, ((MapProperty)property).getAdditionalProperties(), processedModels));
|
||||||
}
|
}
|
||||||
return mp;
|
return mp;
|
||||||
}
|
}
|
||||||
@ -128,9 +129,10 @@ public class ExampleGenerator {
|
|||||||
return "{}";
|
return "{}";
|
||||||
}
|
}
|
||||||
else if(property instanceof RefProperty) {
|
else if(property instanceof RefProperty) {
|
||||||
Model model = examples.get(((RefProperty)property).getSimpleRef());
|
String simpleName = ((RefProperty)property).getSimpleRef();
|
||||||
|
Model model = examples.get(simpleName);
|
||||||
if(model != null)
|
if(model != null)
|
||||||
return resolveModelToExample(mediaType, model);
|
return resolveModelToExample(simpleName, mediaType, model, processedModels);
|
||||||
}
|
}
|
||||||
else if(property instanceof UUIDProperty) {
|
else if(property instanceof UUIDProperty) {
|
||||||
return "046b6c7f-0b8a-43b9-b35d-6489e6daee91";
|
return "046b6c7f-0b8a-43b9-b35d-6489e6daee91";
|
||||||
@ -139,14 +141,20 @@ public class ExampleGenerator {
|
|||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
public Object resolveModelToExample(String mediaType, Model model) {
|
public Object resolveModelToExample(String name, String mediaType, Model model, Set<String> processedModels) {
|
||||||
|
if(processedModels.contains(name)) {
|
||||||
|
return "";
|
||||||
|
}
|
||||||
if(model instanceof ModelImpl) {
|
if(model instanceof ModelImpl) {
|
||||||
|
processedModels.add(name);
|
||||||
ModelImpl impl = (ModelImpl) model;
|
ModelImpl impl = (ModelImpl) model;
|
||||||
Map<String, Object> values = new HashMap<String, Object>();
|
Map<String, Object> values = new HashMap<String, Object>();
|
||||||
|
|
||||||
for(String name : impl.getProperties().keySet()) {
|
if(impl != null && impl.getProperties() != null) {
|
||||||
Property property = impl.getProperties().get(name);
|
for(String propertyName : impl.getProperties().keySet()) {
|
||||||
values.put(name, resolvePropertyToExample(mediaType, property));
|
Property property = impl.getProperties().get(propertyName);
|
||||||
|
values.put(propertyName, resolvePropertyToExample(mediaType, property, processedModels));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return values;
|
return values;
|
||||||
|
@ -34,7 +34,11 @@ public class ObjcClientCodegen extends DefaultCodegen implements CodegenConfig {
|
|||||||
templateDir = "objc";
|
templateDir = "objc";
|
||||||
modelPackage = "";
|
modelPackage = "";
|
||||||
|
|
||||||
additionalProperties.put("projectName", "swaggerClient");
|
String appName = System.getProperty("appName");
|
||||||
|
if(appName == null) {
|
||||||
|
appName = "swaggerClient";
|
||||||
|
}
|
||||||
|
additionalProperties.put("projectName", appName);
|
||||||
|
|
||||||
defaultIncludes = new HashSet<String>(
|
defaultIncludes = new HashSet<String>(
|
||||||
Arrays.asList(
|
Arrays.asList(
|
||||||
@ -229,4 +233,4 @@ public class ObjcClientCodegen extends DefaultCodegen implements CodegenConfig {
|
|||||||
public String escapeReservedWord(String name) {
|
public String escapeReservedWord(String name) {
|
||||||
return "_" + name;
|
return "_" + name;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -39,7 +39,11 @@ public class RubyClientCodegen extends DefaultCodegen implements CodegenConfig {
|
|||||||
|
|
||||||
reservedWords = new HashSet<String> (
|
reservedWords = new HashSet<String> (
|
||||||
Arrays.asList(
|
Arrays.asList(
|
||||||
"int")
|
"__FILE__", "and", "def", "end", "in", "or", "self", "unless", "__LINE__",
|
||||||
|
"begin", "defined?", "ensure", "module", "redo", "super", "until", "BEGIN",
|
||||||
|
"break", "do", "false", "next", "rescue", "then", "when", "END", "case",
|
||||||
|
"else", "for", "nil", "retry", "true", "while", "alias", "class", "elsif",
|
||||||
|
"if", "not", "return", "undef", "yield")
|
||||||
);
|
);
|
||||||
|
|
||||||
additionalProperties.put("invokerPackage", invokerPackage);
|
additionalProperties.put("invokerPackage", invokerPackage);
|
||||||
@ -117,4 +121,70 @@ public class RubyClientCodegen extends DefaultCodegen implements CodegenConfig {
|
|||||||
public String toDefaultValue(Property p) {
|
public String toDefaultValue(Property p) {
|
||||||
return "null";
|
return "null";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toVarName(String name) {
|
||||||
|
// replace - with _ e.g. created-at => created_at
|
||||||
|
name = name.replaceAll("-", "_");
|
||||||
|
|
||||||
|
// if it's all uppper case, convert to lower case
|
||||||
|
if (name.matches("^[A-Z_]*$"))
|
||||||
|
name = name.toLowerCase();
|
||||||
|
|
||||||
|
// camelize (lower first character) the variable name
|
||||||
|
// petId => pet_id
|
||||||
|
name = underscore(name);
|
||||||
|
|
||||||
|
// for reserved word or word starting with number, append _
|
||||||
|
if(reservedWords.contains(name) || name.matches("^\\d.*"))
|
||||||
|
name = escapeReservedWord(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) {
|
||||||
|
// model name cannot use reserved keyword, e.g. return
|
||||||
|
if(reservedWords.contains(name))
|
||||||
|
throw new RuntimeException(name + " (reserved word) cannot be used as a model name");
|
||||||
|
|
||||||
|
// camelize the model name
|
||||||
|
// phone_number => PhoneNumber
|
||||||
|
return camelize(name);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toModelFilename(String name) {
|
||||||
|
// model name cannot use reserved keyword, e.g. return
|
||||||
|
if(reservedWords.contains(name))
|
||||||
|
throw new RuntimeException(name + " (reserved word) cannot be used as a model name");
|
||||||
|
|
||||||
|
// underscore the model file name
|
||||||
|
// PhoneNumber.rb => phone_number.rb
|
||||||
|
return underscore(name);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toApiFilename(String name) {
|
||||||
|
// replace - with _ e.g. created-at => created_at
|
||||||
|
name = name.replaceAll("-", "_");
|
||||||
|
|
||||||
|
// e.g. PhoneNumberApi.rb => phone_number_api.rb
|
||||||
|
return underscore(name) + "_api";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toApiName(String name) {
|
||||||
|
if(name.length() == 0)
|
||||||
|
return "DefaultApi";
|
||||||
|
// e.g. phone_number_api => PhoneNumberApi
|
||||||
|
return camelize(name) + "Api";
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -110,18 +110,25 @@ static NSString * basePath = @"{{basePath}}";
|
|||||||
}
|
}
|
||||||
{{/bodyParam}}
|
{{/bodyParam}}
|
||||||
{{^bodyParam}}
|
{{^bodyParam}}
|
||||||
bodyDictionary = [[NSMutableArray alloc] init];
|
|
||||||
|
|
||||||
NSMutableDictionary * formParams = [[NSMutableDictionary alloc]init];
|
NSMutableDictionary * formParams = [[NSMutableDictionary alloc]init];
|
||||||
|
|
||||||
{{#formParams}}{{#notFile}}
|
{{#formParams}}
|
||||||
|
{{#notFile}}
|
||||||
formParams[@"{{paramName}}"] = {{paramName}};
|
formParams[@"{{paramName}}"] = {{paramName}};
|
||||||
{{/notFile}}{{#isFile}}
|
{{/notFile}}{{#isFile}}
|
||||||
requestContentType = @"multipart/form-data";
|
requestContentType = @"multipart/form-data";
|
||||||
|
if(bodyDictionary == nil) {
|
||||||
|
bodyDictionary = [[NSMutableArray alloc] init];
|
||||||
|
}
|
||||||
[bodyDictionary addObject:{{paramName}}];
|
[bodyDictionary addObject:{{paramName}}];
|
||||||
{{paramName}}.paramName = @"{{baseName}}";
|
{{paramName}}.paramName = @"{{baseName}}";
|
||||||
{{/isFile}}{{/formParams}}
|
{{/isFile}}
|
||||||
|
if(bodyDictionary == nil) {
|
||||||
|
bodyDictionary = [[NSMutableArray alloc] init];
|
||||||
|
}
|
||||||
[bodyDictionary addObject:formParams];
|
[bodyDictionary addObject:formParams];
|
||||||
|
{{/formParams}}
|
||||||
{{/bodyParam}}
|
{{/bodyParam}}
|
||||||
|
|
||||||
{{#requiredParamCount}}
|
{{#requiredParamCount}}
|
||||||
@ -134,11 +141,26 @@ static NSString * basePath = @"{{basePath}}";
|
|||||||
|
|
||||||
SWGApiClient* client = [SWGApiClient sharedClientFromPool:basePath];
|
SWGApiClient* client = [SWGApiClient sharedClientFromPool:basePath];
|
||||||
|
|
||||||
{{#returnContainer}}{{>apiBodyResponseWithContainer}}{{/returnContainer}}
|
{{#returnContainer}}
|
||||||
|
// response is in a container
|
||||||
|
{{>apiBodyResponseWithContainer}}{{/returnContainer}}
|
||||||
|
|
||||||
{{#returnSimpleType}}
|
{{#returnSimpleType}}
|
||||||
{{#returnTypeIsPrimitive}}{{>apiPrimitiveResponse}}{{/returnTypeIsPrimitive}}
|
// non container response
|
||||||
{{#returnBaseType}}{{>apiNonPrimitiveResponse}}{{/returnBaseType}}
|
|
||||||
|
{{#returnTypeIsPrimitive}}
|
||||||
|
// primitive response
|
||||||
|
{{>apiPrimitiveResponse}}{{/returnTypeIsPrimitive}}
|
||||||
|
|
||||||
|
{{#returnBaseType}}
|
||||||
|
// complex response
|
||||||
|
{{>apiNonPrimitiveResponse}}{{/returnBaseType}}
|
||||||
{{/returnSimpleType}}
|
{{/returnSimpleType}}
|
||||||
|
|
||||||
|
{{^returnSimpleType}}{{^returnContainer}}
|
||||||
|
// it's void
|
||||||
|
{{>voidResponse}}
|
||||||
|
{{/returnContainer}}{{/returnSimpleType}}
|
||||||
}
|
}
|
||||||
|
|
||||||
{{/operation}}
|
{{/operation}}
|
||||||
|
@ -13,12 +13,11 @@
|
|||||||
{{^returnBaseType}}completionBlock(error);{{/returnBaseType}}
|
{{^returnBaseType}}completionBlock(error);{{/returnBaseType}}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
{{#returnBaseType}}
|
{{#returnType}}{{returnType}} result = nil;
|
||||||
{{returnBaseType}} *result = nil;
|
|
||||||
if (data) {
|
if (data) {
|
||||||
result = [[{{#instantiationType}}NSClassFromString(@"{{{instantiationType}}}") {{/instantiationType}}{{^instantiationType}}{{{returnBaseType}}} {{/instantiationType}} alloc]initWithValues: data];
|
result = [[{{#instantiationType}}NSClassFromString(@"{{{instantiationType}}}") {{/instantiationType}}{{^instantiationType}}{{{returnBaseType}}} {{/instantiationType}} alloc] {{#returnContainer}}{{#isMapContainer}}initWithDictionary{{/isMapContainer}}{{#isListContainer}}initWithValues{{/isListContainer}}{{/returnContainer}}{{^returnContainer}}initWithValues {{/returnContainer}}: data];
|
||||||
}
|
}
|
||||||
{{#returnBaseType}}completionBlock(result , nil);{{/returnBaseType}}
|
{{#returnType}}completionBlock(result , nil);{{/returnType}}
|
||||||
{{/returnBaseType}}
|
{{/returnType}}
|
||||||
}];
|
}];
|
||||||
{{/returnTypeIsPrimitive}}
|
{{/returnTypeIsPrimitive}}
|
@ -0,0 +1,14 @@
|
|||||||
|
return [client stringWithCompletionBlock: requestUrl
|
||||||
|
method: @"{{httpMethod}}"
|
||||||
|
queryParams: queryParams
|
||||||
|
body: bodyDictionary
|
||||||
|
headerParams: headerParams
|
||||||
|
requestContentType: requestContentType
|
||||||
|
responseContentType: responseContentType
|
||||||
|
completionBlock: ^(NSString *data, NSError *error) {
|
||||||
|
if (error) {
|
||||||
|
completionBlock(error);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
completionBlock(nil);
|
||||||
|
}];
|
@ -17,12 +17,17 @@ Copyright 2015 Reverb Technologies, Inc.
|
|||||||
{{#models}}
|
{{#models}}
|
||||||
{{#model}}
|
{{#model}}
|
||||||
|
|
||||||
class {{classname}}:
|
class {{classname}}(object):
|
||||||
"""NOTE: This class is auto generated by the swagger code generator program.
|
"""NOTE: This class is auto generated by the swagger code generator program.
|
||||||
Do not edit the class manually."""
|
Do not edit the class manually."""
|
||||||
|
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
|
"""
|
||||||
|
Attributes:
|
||||||
|
swaggerTypes (dict): The key is attribute name and the value is attribute type.
|
||||||
|
attributeMap (dict): The key is attribute name and the value is json key in definition.
|
||||||
|
"""
|
||||||
self.swaggerTypes = {
|
self.swaggerTypes = {
|
||||||
{{#vars}}
|
{{#vars}}
|
||||||
'{{name}}': '{{{datatype}}}'{{#hasMore}},
|
'{{name}}': '{{{datatype}}}'{{#hasMore}},
|
||||||
@ -30,6 +35,11 @@ class {{classname}}:
|
|||||||
{{/vars}}{{newline}}
|
{{/vars}}{{newline}}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
self.attributeMap = {
|
||||||
|
{{#vars}}
|
||||||
|
'{{name}}': '{{baseName}}'{{#hasMore}},{{/hasMore}}
|
||||||
|
{{/vars}}
|
||||||
|
}
|
||||||
|
|
||||||
{{#vars}}
|
{{#vars}}
|
||||||
{{#description}}#{{description}}
|
{{#description}}#{{description}}
|
||||||
|
@ -131,10 +131,14 @@ class ApiClient(object):
|
|||||||
if isinstance(obj, dict):
|
if isinstance(obj, dict):
|
||||||
objDict = obj
|
objDict = obj
|
||||||
else:
|
else:
|
||||||
objDict = obj.__dict__
|
# Convert model obj to dict except attributes `swaggerTypes`, `attributeMap`
|
||||||
|
# and attributes which value is not None.
|
||||||
|
# Convert attribute name to json key in model definition for request.
|
||||||
|
objDict = {obj.attributeMap[key]: val
|
||||||
|
for key, val in obj.__dict__.iteritems()
|
||||||
|
if key != 'swaggerTypes' and key != 'attributeMap' and val is not None}
|
||||||
return {key: ApiClient.sanitizeForSerialization(val)
|
return {key: ApiClient.sanitizeForSerialization(val)
|
||||||
for (key, val) in objDict.iteritems()
|
for (key, val) in objDict.iteritems()}
|
||||||
if key != 'swaggerTypes'}
|
|
||||||
|
|
||||||
def buildMultipartFormData(self, postData, files):
|
def buildMultipartFormData(self, postData, files):
|
||||||
def escape_quotes(s):
|
def escape_quotes(s):
|
||||||
@ -199,8 +203,8 @@ class ApiClient(object):
|
|||||||
instance = objClass()
|
instance = objClass()
|
||||||
|
|
||||||
for attr, attrType in instance.swaggerTypes.iteritems():
|
for attr, attrType in instance.swaggerTypes.iteritems():
|
||||||
if obj is not None and attr in obj and type(obj) in [list, dict]:
|
if obj is not None and instance.attributeMap[attr] in obj and type(obj) in [list, dict]:
|
||||||
value = obj[attr]
|
value = obj[instance.attributeMap[attr]]
|
||||||
if attrType in ['str', 'int', 'long', 'float', 'bool']:
|
if attrType in ['str', 'int', 'long', 'float', 'bool']:
|
||||||
attrType = eval(attrType)
|
attrType = eval(attrType)
|
||||||
try:
|
try:
|
||||||
|
15
pom.xml
15
pom.xml
@ -277,10 +277,23 @@
|
|||||||
</plugins>
|
</plugins>
|
||||||
</build>
|
</build>
|
||||||
</profile>
|
</profile>
|
||||||
|
<profile>
|
||||||
|
<!-- Samples -->
|
||||||
|
<id>samples</id>
|
||||||
|
<activation>
|
||||||
|
<property>
|
||||||
|
<name>env</name>
|
||||||
|
<value>samples</value>
|
||||||
|
</property>
|
||||||
|
</activation>
|
||||||
|
<modules>
|
||||||
|
<module>samples/client/petstore/objc</module>
|
||||||
|
</modules>
|
||||||
|
</profile>
|
||||||
</profiles>
|
</profiles>
|
||||||
<modules>
|
<modules>
|
||||||
<module>modules/swagger-codegen</module>
|
<module>modules/swagger-codegen</module>
|
||||||
<module>modules/swagger-codegen-distribution</module>
|
<module>modules/swagger-codegen-cli</module>
|
||||||
<module>modules/swagger-generator</module>
|
<module>modules/swagger-generator</module>
|
||||||
</modules>
|
</modules>
|
||||||
<reporting>
|
<reporting>
|
||||||
|
@ -22,7 +22,8 @@
|
|||||||
EA6699BD1811D2FB00A70D03 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = EA6699991811D2FA00A70D03 /* Foundation.framework */; };
|
EA6699BD1811D2FB00A70D03 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = EA6699991811D2FA00A70D03 /* Foundation.framework */; };
|
||||||
EA6699BE1811D2FB00A70D03 /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = EA66999D1811D2FA00A70D03 /* UIKit.framework */; };
|
EA6699BE1811D2FB00A70D03 /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = EA66999D1811D2FA00A70D03 /* UIKit.framework */; };
|
||||||
EA6699C61811D2FB00A70D03 /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = EA6699C41811D2FB00A70D03 /* InfoPlist.strings */; };
|
EA6699C61811D2FB00A70D03 /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = EA6699C41811D2FB00A70D03 /* InfoPlist.strings */; };
|
||||||
EA6699C81811D2FB00A70D03 /* PetstoreClientTests.m in Sources */ = {isa = PBXBuildFile; fileRef = EA6699C71811D2FB00A70D03 /* PetstoreClientTests.m */; };
|
EA6699C81811D2FB00A70D03 /* PetApiTest.m in Sources */ = {isa = PBXBuildFile; fileRef = EA6699C71811D2FB00A70D03 /* PetApiTest.m */; };
|
||||||
|
EA8CD3ED1AC2763600C47D0B /* SenTestingKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = EA8CD3EC1AC2763600C47D0B /* SenTestingKit.framework */; };
|
||||||
EAEA85E41811D3AE00F06E69 /* SWGApiClient.m in Sources */ = {isa = PBXBuildFile; fileRef = EAEA85CD1811D3AE00F06E69 /* SWGApiClient.m */; };
|
EAEA85E41811D3AE00F06E69 /* SWGApiClient.m in Sources */ = {isa = PBXBuildFile; fileRef = EAEA85CD1811D3AE00F06E69 /* SWGApiClient.m */; };
|
||||||
EAEA85E51811D3AE00F06E69 /* SWGCategory.m in Sources */ = {isa = PBXBuildFile; fileRef = EAEA85CF1811D3AE00F06E69 /* SWGCategory.m */; };
|
EAEA85E51811D3AE00F06E69 /* SWGCategory.m in Sources */ = {isa = PBXBuildFile; fileRef = EAEA85CF1811D3AE00F06E69 /* SWGCategory.m */; };
|
||||||
EAEA85E61811D3AE00F06E69 /* SWGDate.m in Sources */ = {isa = PBXBuildFile; fileRef = EAEA85D11811D3AE00F06E69 /* SWGDate.m */; };
|
EAEA85E61811D3AE00F06E69 /* SWGDate.m in Sources */ = {isa = PBXBuildFile; fileRef = EAEA85D11811D3AE00F06E69 /* SWGDate.m */; };
|
||||||
@ -73,7 +74,9 @@
|
|||||||
EA6699BB1811D2FB00A70D03 /* XCTest.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = XCTest.framework; path = Library/Frameworks/XCTest.framework; sourceTree = DEVELOPER_DIR; };
|
EA6699BB1811D2FB00A70D03 /* XCTest.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = XCTest.framework; path = Library/Frameworks/XCTest.framework; sourceTree = DEVELOPER_DIR; };
|
||||||
EA6699C31811D2FB00A70D03 /* PetstoreClientTests-Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = "PetstoreClientTests-Info.plist"; sourceTree = "<group>"; };
|
EA6699C31811D2FB00A70D03 /* PetstoreClientTests-Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = "PetstoreClientTests-Info.plist"; sourceTree = "<group>"; };
|
||||||
EA6699C51811D2FB00A70D03 /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/InfoPlist.strings; sourceTree = "<group>"; };
|
EA6699C51811D2FB00A70D03 /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/InfoPlist.strings; sourceTree = "<group>"; };
|
||||||
EA6699C71811D2FB00A70D03 /* PetstoreClientTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = PetstoreClientTests.m; sourceTree = "<group>"; };
|
EA6699C71811D2FB00A70D03 /* PetApiTest.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = PetApiTest.m; sourceTree = "<group>"; };
|
||||||
|
EA8CD3EB1AC274BE00C47D0B /* PetApiTest.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = PetApiTest.h; sourceTree = "<group>"; };
|
||||||
|
EA8CD3EC1AC2763600C47D0B /* SenTestingKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = SenTestingKit.framework; path = Library/Frameworks/SenTestingKit.framework; sourceTree = DEVELOPER_DIR; };
|
||||||
EAEA85CC1811D3AE00F06E69 /* SWGApiClient.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SWGApiClient.h; sourceTree = "<group>"; };
|
EAEA85CC1811D3AE00F06E69 /* SWGApiClient.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SWGApiClient.h; sourceTree = "<group>"; };
|
||||||
EAEA85CD1811D3AE00F06E69 /* SWGApiClient.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SWGApiClient.m; sourceTree = "<group>"; };
|
EAEA85CD1811D3AE00F06E69 /* SWGApiClient.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SWGApiClient.m; sourceTree = "<group>"; };
|
||||||
EAEA85CE1811D3AE00F06E69 /* SWGCategory.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SWGCategory.h; sourceTree = "<group>"; };
|
EAEA85CE1811D3AE00F06E69 /* SWGCategory.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SWGCategory.h; sourceTree = "<group>"; };
|
||||||
@ -120,6 +123,7 @@
|
|||||||
isa = PBXFrameworksBuildPhase;
|
isa = PBXFrameworksBuildPhase;
|
||||||
buildActionMask = 2147483647;
|
buildActionMask = 2147483647;
|
||||||
files = (
|
files = (
|
||||||
|
EA8CD3ED1AC2763600C47D0B /* SenTestingKit.framework in Frameworks */,
|
||||||
EAEA85F11811D8F100F06E69 /* libPods.a in Frameworks */,
|
EAEA85F11811D8F100F06E69 /* libPods.a in Frameworks */,
|
||||||
EA6699BC1811D2FB00A70D03 /* XCTest.framework in Frameworks */,
|
EA6699BC1811D2FB00A70D03 /* XCTest.framework in Frameworks */,
|
||||||
EA6699BE1811D2FB00A70D03 /* UIKit.framework in Frameworks */,
|
EA6699BE1811D2FB00A70D03 /* UIKit.framework in Frameworks */,
|
||||||
@ -163,6 +167,7 @@
|
|||||||
EA6699981811D2FA00A70D03 /* Frameworks */ = {
|
EA6699981811D2FA00A70D03 /* Frameworks */ = {
|
||||||
isa = PBXGroup;
|
isa = PBXGroup;
|
||||||
children = (
|
children = (
|
||||||
|
EA8CD3EC1AC2763600C47D0B /* SenTestingKit.framework */,
|
||||||
EAEA85F01811D8F100F06E69 /* libPods.a */,
|
EAEA85F01811D8F100F06E69 /* libPods.a */,
|
||||||
EA6699991811D2FA00A70D03 /* Foundation.framework */,
|
EA6699991811D2FA00A70D03 /* Foundation.framework */,
|
||||||
EA66999B1811D2FA00A70D03 /* CoreGraphics.framework */,
|
EA66999B1811D2FA00A70D03 /* CoreGraphics.framework */,
|
||||||
@ -203,7 +208,8 @@
|
|||||||
EA6699C11811D2FB00A70D03 /* PetstoreClientTests */ = {
|
EA6699C11811D2FB00A70D03 /* PetstoreClientTests */ = {
|
||||||
isa = PBXGroup;
|
isa = PBXGroup;
|
||||||
children = (
|
children = (
|
||||||
EA6699C71811D2FB00A70D03 /* PetstoreClientTests.m */,
|
EA8CD3EB1AC274BE00C47D0B /* PetApiTest.h */,
|
||||||
|
EA6699C71811D2FB00A70D03 /* PetApiTest.m */,
|
||||||
EA6699C21811D2FB00A70D03 /* Supporting Files */,
|
EA6699C21811D2FB00A70D03 /* Supporting Files */,
|
||||||
);
|
);
|
||||||
path = PetstoreClientTests;
|
path = PetstoreClientTests;
|
||||||
@ -409,7 +415,7 @@
|
|||||||
isa = PBXSourcesBuildPhase;
|
isa = PBXSourcesBuildPhase;
|
||||||
buildActionMask = 2147483647;
|
buildActionMask = 2147483647;
|
||||||
files = (
|
files = (
|
||||||
EA6699C81811D2FB00A70D03 /* PetstoreClientTests.m in Sources */,
|
EA6699C81811D2FB00A70D03 /* PetApiTest.m in Sources */,
|
||||||
);
|
);
|
||||||
runOnlyForDeploymentPostprocessing = 0;
|
runOnlyForDeploymentPostprocessing = 0;
|
||||||
};
|
};
|
||||||
|
@ -58,7 +58,8 @@
|
|||||||
ignoresPersistentStateOnLaunch = "NO"
|
ignoresPersistentStateOnLaunch = "NO"
|
||||||
debugDocumentVersioning = "YES"
|
debugDocumentVersioning = "YES"
|
||||||
allowLocationSimulation = "YES">
|
allowLocationSimulation = "YES">
|
||||||
<BuildableProductRunnable>
|
<BuildableProductRunnable
|
||||||
|
runnableDebuggingMode = "0">
|
||||||
<BuildableReference
|
<BuildableReference
|
||||||
BuildableIdentifier = "primary"
|
BuildableIdentifier = "primary"
|
||||||
BlueprintIdentifier = "EA6699951811D2FA00A70D03"
|
BlueprintIdentifier = "EA6699951811D2FA00A70D03"
|
||||||
@ -76,7 +77,8 @@
|
|||||||
useCustomWorkingDirectory = "NO"
|
useCustomWorkingDirectory = "NO"
|
||||||
buildConfiguration = "Release"
|
buildConfiguration = "Release"
|
||||||
debugDocumentVersioning = "YES">
|
debugDocumentVersioning = "YES">
|
||||||
<BuildableProductRunnable>
|
<BuildableProductRunnable
|
||||||
|
runnableDebuggingMode = "0">
|
||||||
<BuildableReference
|
<BuildableReference
|
||||||
BuildableIdentifier = "primary"
|
BuildableIdentifier = "primary"
|
||||||
BlueprintIdentifier = "EA6699951811D2FA00A70D03"
|
BlueprintIdentifier = "EA6699951811D2FA00A70D03"
|
||||||
|
@ -21,16 +21,16 @@
|
|||||||
// Do any additional setup after loading the view, typically from a nib.
|
// Do any additional setup after loading the view, typically from a nib.
|
||||||
|
|
||||||
SWGPetApi * api = [[SWGPetApi alloc] init];
|
SWGPetApi * api = [[SWGPetApi alloc] init];
|
||||||
|
/*
|
||||||
// [api getPetByIdWithCompletionBlock:@10 completionHandler:^(SWGPet *output, NSError *error) {
|
[api getPetByIdWithCompletionBlock:@10 completionHandler:^(SWGPet *output, NSError *error) {
|
||||||
// NSLog(@"%@", [output asDictionary]);
|
NSLog(@"%@", [output asDictionary]);
|
||||||
// [output set_id:@101];
|
[output set_id:@101];
|
||||||
// [api addPetWithCompletionBlock:output completionHandler:^(NSError *error) {
|
[api addPetWithCompletionBlock:output completionHandler:^(NSError *error) {
|
||||||
// NSLog(@"Done!");
|
NSLog(@"Done!");
|
||||||
// }];
|
}];
|
||||||
|
|
||||||
// load data into file
|
// load data into file
|
||||||
// }];
|
}];
|
||||||
NSString *filePath = [[NSBundle mainBundle] pathForResource:@"test-1" ofType:@"png"];
|
NSString *filePath = [[NSBundle mainBundle] pathForResource:@"test-1" ofType:@"png"];
|
||||||
NSData *myData = [NSData dataWithContentsOfFile:filePath];
|
NSData *myData = [NSData dataWithContentsOfFile:filePath];
|
||||||
|
|
||||||
@ -52,6 +52,7 @@
|
|||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
];
|
];
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)didReceiveMemoryWarning
|
- (void)didReceiveMemoryWarning
|
||||||
|
@ -0,0 +1,9 @@
|
|||||||
|
#import <XCTest/XCTest.h>
|
||||||
|
#import "SWGPetApi.h"
|
||||||
|
|
||||||
|
@interface PetApiTest : XCTestCase {
|
||||||
|
@private
|
||||||
|
SWGPetApi * api;
|
||||||
|
}
|
||||||
|
|
||||||
|
@end
|
@ -0,0 +1,179 @@
|
|||||||
|
#import "PetApiTest.h"
|
||||||
|
#import "SWGFile.h"
|
||||||
|
|
||||||
|
@implementation PetApiTest
|
||||||
|
|
||||||
|
- (void)setUp {
|
||||||
|
[super setUp];
|
||||||
|
api = [[SWGPetApi alloc ]init];
|
||||||
|
// [[SWGApiClient sharedClientFromPool]setLoggingEnabled:true];
|
||||||
|
[SWGPetApi setBasePath:@"http://localhost:8002/api"];
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)tearDown {
|
||||||
|
[super tearDown];
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)testGetPetById {
|
||||||
|
XCTestExpectation *expectation = [self expectationWithDescription:@"testGetPetById"];
|
||||||
|
[api getPetByIdWithCompletionBlock:@1 completionHandler:^(SWGPet *output, NSError *error) {
|
||||||
|
if(error){
|
||||||
|
XCTFail(@"got error %@", error);
|
||||||
|
}
|
||||||
|
if(output){
|
||||||
|
XCTAssertNotNil([output _id], @"token was nil");
|
||||||
|
}
|
||||||
|
[expectation fulfill];
|
||||||
|
}];
|
||||||
|
[self waitForExpectationsWithTimeout:2.0 handler:nil];
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void) testAddPet {
|
||||||
|
XCTestExpectation *expectation = [self expectationWithDescription:@"testAddPet"];
|
||||||
|
|
||||||
|
SWGPet * petToAdd = [[SWGPet alloc] init];
|
||||||
|
[petToAdd set_id:@1000];
|
||||||
|
NSMutableArray* tags = [[NSMutableArray alloc] init];
|
||||||
|
for(int i = 0; i < 5; i++){
|
||||||
|
SWGTag * tag = [[SWGTag alloc] init];
|
||||||
|
[tag set_id:[NSNumber numberWithInt:i]];
|
||||||
|
[tag setName:[NSString stringWithFormat:@"tag-%d", i]];
|
||||||
|
[tags addObject:tag];
|
||||||
|
}
|
||||||
|
[petToAdd setTags:tags];
|
||||||
|
[petToAdd setStatus:@"lost"];
|
||||||
|
|
||||||
|
SWGCategory * category = [[SWGCategory alloc] init];
|
||||||
|
[category setName:@"sold"];
|
||||||
|
[petToAdd setCategory:category];
|
||||||
|
[petToAdd setName:@"dragon"];
|
||||||
|
|
||||||
|
NSMutableArray* photos = [[NSMutableArray alloc] init];
|
||||||
|
for(int i = 0; i < 10; i++){
|
||||||
|
NSString * url = [NSString stringWithFormat:@"http://foo.com/photo/%d", i];
|
||||||
|
[photos addObject:url];
|
||||||
|
}
|
||||||
|
[petToAdd setPhotoUrls:photos];
|
||||||
|
|
||||||
|
[api addPetWithCompletionBlock:petToAdd completionHandler:^(NSError *error) {
|
||||||
|
if(error){
|
||||||
|
XCTFail(@"got error %@", error);
|
||||||
|
}
|
||||||
|
[expectation fulfill];
|
||||||
|
}];
|
||||||
|
|
||||||
|
[self waitForExpectationsWithTimeout:2.0 handler:nil];
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void) testUpdatePet {
|
||||||
|
XCTestExpectation *expectation = [self expectationWithDescription:@"testUpdatePet"];
|
||||||
|
SWGPet * petToAdd = [[SWGPet alloc] init];
|
||||||
|
[petToAdd set_id:[NSNumber numberWithInt:1000]];
|
||||||
|
NSMutableArray* tags = [[NSMutableArray alloc] init];
|
||||||
|
for(int i = 0; i < 5; i++){
|
||||||
|
SWGTag * tag = [[SWGTag alloc] init];
|
||||||
|
[tag set_id:[NSNumber numberWithInt:i]];
|
||||||
|
[tag setName:[NSString stringWithFormat:@"tag-%d", i]];
|
||||||
|
[tags addObject:tag];
|
||||||
|
}
|
||||||
|
[petToAdd setTags:tags];
|
||||||
|
[petToAdd setStatus:@"lost"];
|
||||||
|
|
||||||
|
SWGCategory * category = [[SWGCategory alloc] init];
|
||||||
|
[category setName:@"sold"];
|
||||||
|
[petToAdd setCategory:category];
|
||||||
|
[petToAdd setName:@"dragon"];
|
||||||
|
|
||||||
|
NSMutableArray* photos = [[NSMutableArray alloc] init];
|
||||||
|
for(int i = 0; i < 10; i++){
|
||||||
|
NSString * url = [NSString stringWithFormat:@"http://foo.com/photo/%d", i];
|
||||||
|
[photos addObject:url];
|
||||||
|
}
|
||||||
|
[petToAdd setPhotoUrls:photos];
|
||||||
|
|
||||||
|
[api addPetWithCompletionBlock:petToAdd completionHandler:^(NSError *error) {
|
||||||
|
if(error) {
|
||||||
|
XCTFail(@"got error %@", error);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
[api getPetByIdWithCompletionBlock:[NSString stringWithFormat:@"%@",[petToAdd _id]] completionHandler:^(SWGPet *output, NSError *error) {
|
||||||
|
if(error) {
|
||||||
|
XCTFail(@"got error %@", error);
|
||||||
|
}
|
||||||
|
if(output == nil){
|
||||||
|
NSLog(@"failed to fetch pet");
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
SWGPet* pet = [[SWGPet alloc] initWithValues:[output asDictionary]];
|
||||||
|
NSLog(@"got the pet");
|
||||||
|
|
||||||
|
[pet setName:@"programmer"];
|
||||||
|
[pet setStatus:@"confused"];
|
||||||
|
|
||||||
|
[api updatePetWithCompletionBlock:pet
|
||||||
|
completionHandler:^(NSError *error) {
|
||||||
|
if(error) {
|
||||||
|
XCTFail(@"got error %@", error);
|
||||||
|
}
|
||||||
|
[api getPetByIdWithCompletionBlock:@1000 completionHandler:^(SWGPet *output, NSError *error) {
|
||||||
|
if(error) {
|
||||||
|
XCTFail(@"got error %@", error);
|
||||||
|
}
|
||||||
|
if(output == nil){
|
||||||
|
NSLog(@"failed to fetch pet");
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
SWGPet* pet = [[SWGPet alloc] initWithValues:[output asDictionary]];
|
||||||
|
XCTAssertNotNil([pet _id], @"pet was nil");
|
||||||
|
XCTAssertEqualObjects([pet name], @"programmer", @"pet name was not updated");
|
||||||
|
XCTAssertEqualObjects([pet status], @"confused", @"pet status was not updated");
|
||||||
|
}
|
||||||
|
[expectation fulfill];
|
||||||
|
|
||||||
|
}];
|
||||||
|
}];
|
||||||
|
}
|
||||||
|
}];
|
||||||
|
}
|
||||||
|
}];
|
||||||
|
[self waitForExpectationsWithTimeout:2.0 handler:nil];
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)testGetPetByStatus {
|
||||||
|
XCTestExpectation *expectation = [self expectationWithDescription:@"testGetPetByStatus"];
|
||||||
|
[api findPetsByStatusWithCompletionBlock:@"available" completionHandler:^(NSArray *output, NSError *error) {
|
||||||
|
if(error) {
|
||||||
|
XCTFail(@"got error %@", error);
|
||||||
|
}
|
||||||
|
if(output == nil){
|
||||||
|
XCTFail(@"failed to fetch pets");
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
[expectation fulfill];
|
||||||
|
}
|
||||||
|
}];
|
||||||
|
[self waitForExpectationsWithTimeout:2.0 handler:nil];
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)testGetPetByTags {
|
||||||
|
XCTestExpectation *expectation = [self expectationWithDescription:@"testGetPetByTags"];
|
||||||
|
[api findPetsByTagsWithCompletionBlock:@"tag1,tag2" completionHandler:^(NSArray *output, NSError *error) {
|
||||||
|
if(error){
|
||||||
|
XCTFail(@"got error %@", error);
|
||||||
|
}
|
||||||
|
if(output){
|
||||||
|
for(SWGPet * pet in output) {
|
||||||
|
bool hasTag = false;
|
||||||
|
for(SWGTag * tag in [pet tags]){
|
||||||
|
if([[tag name] isEqualToString:@"tag1"] || [[tag name] isEqualToString:@"tag2"])
|
||||||
|
hasTag = true;
|
||||||
|
}
|
||||||
|
if(!hasTag)
|
||||||
|
XCTFail(@"failed to find tag in pet");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
[expectation fulfill];
|
||||||
|
}];
|
||||||
|
[self waitForExpectationsWithTimeout:2.0 handler:nil];
|
||||||
|
}
|
||||||
|
@end
|
@ -1,34 +0,0 @@
|
|||||||
//
|
|
||||||
// PetstoreClientTests.m
|
|
||||||
// PetstoreClientTests
|
|
||||||
//
|
|
||||||
// Created by Tony Tam on 10/18/13.
|
|
||||||
// Copyright (c) 2013 Reverb. All rights reserved.
|
|
||||||
//
|
|
||||||
|
|
||||||
#import <XCTest/XCTest.h>
|
|
||||||
|
|
||||||
@interface PetstoreClientTests : XCTestCase
|
|
||||||
|
|
||||||
@end
|
|
||||||
|
|
||||||
@implementation PetstoreClientTests
|
|
||||||
|
|
||||||
- (void)setUp
|
|
||||||
{
|
|
||||||
[super setUp];
|
|
||||||
// Put setup code here. This method is called before the invocation of each test method in the class.
|
|
||||||
}
|
|
||||||
|
|
||||||
- (void)tearDown
|
|
||||||
{
|
|
||||||
// Put teardown code here. This method is called after the invocation of each test method in the class.
|
|
||||||
[super tearDown];
|
|
||||||
}
|
|
||||||
|
|
||||||
- (void)testExample
|
|
||||||
{
|
|
||||||
XCTFail(@"No implementation for \"%s\"", __PRETTY_FUNCTION__);
|
|
||||||
}
|
|
||||||
|
|
||||||
@end
|
|
24
samples/client/petstore/objc/PetstoreClient/pom.xml
Normal file
24
samples/client/petstore/objc/PetstoreClient/pom.xml
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
<project>
|
||||||
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
<groupId>de.felixschulze.my-project</groupId>
|
||||||
|
<artifactId>PetstoreClient</artifactId>
|
||||||
|
<packaging>xcode</packaging>
|
||||||
|
<version>1.0-SNAPSHOT</version>
|
||||||
|
<name>Swagger Petstore Client</name>
|
||||||
|
<build>
|
||||||
|
<plugins>
|
||||||
|
<plugin>
|
||||||
|
<groupId>de.felixschulze.maven.plugins.xcode</groupId>
|
||||||
|
<artifactId>xcode-maven-plugin</artifactId>
|
||||||
|
<version>1.2</version>
|
||||||
|
<configuration>
|
||||||
|
<xcodeProject>PetstoreClient.xcodeproj</xcodeProject>
|
||||||
|
<xcodeTarget>PetstoreClient</xcodeTarget>
|
||||||
|
<xcodeConfiguration>Debug</xcodeConfiguration>
|
||||||
|
<xcodeSdk>iphoneos</xcodeSdk>
|
||||||
|
</configuration>
|
||||||
|
<extensions>true</extensions>
|
||||||
|
</plugin>
|
||||||
|
</plugins>
|
||||||
|
</build>
|
||||||
|
</project>
|
@ -1,3 +1,3 @@
|
|||||||
platform :ios, '6.0'
|
platform :ios, '6.0'
|
||||||
xcodeproj 'swaggerClient/swaggerClient.xcodeproj'
|
xcodeproj 'PetstoreClient/PetstoreClient.xcodeproj'
|
||||||
pod 'AFNetworking', '~> 2.1'
|
pod 'AFNetworking', '~> 2.1'
|
||||||
|
@ -27,4 +27,4 @@ DEPENDENCIES:
|
|||||||
SPEC CHECKSUMS:
|
SPEC CHECKSUMS:
|
||||||
AFNetworking: 8bee59492a6ff15d69130efa4d0dc67e0094a52a
|
AFNetworking: 8bee59492a6ff15d69130efa4d0dc67e0094a52a
|
||||||
|
|
||||||
COCOAPODS: 0.35.0
|
COCOAPODS: 0.36.0
|
||||||
|
@ -109,6 +109,26 @@ static NSString * basePath = @"http://petstore.swagger.io/v2";
|
|||||||
SWGApiClient* client = [SWGApiClient sharedClientFromPool:basePath];
|
SWGApiClient* client = [SWGApiClient sharedClientFromPool:basePath];
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// it's void
|
||||||
|
return [client stringWithCompletionBlock: requestUrl
|
||||||
|
method: @"PUT"
|
||||||
|
queryParams: queryParams
|
||||||
|
body: bodyDictionary
|
||||||
|
headerParams: headerParams
|
||||||
|
requestContentType: requestContentType
|
||||||
|
responseContentType: responseContentType
|
||||||
|
completionBlock: ^(NSString *data, NSError *error) {
|
||||||
|
if (error) {
|
||||||
|
completionBlock(error);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
completionBlock(nil);
|
||||||
|
}];
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -170,6 +190,26 @@ static NSString * basePath = @"http://petstore.swagger.io/v2";
|
|||||||
SWGApiClient* client = [SWGApiClient sharedClientFromPool:basePath];
|
SWGApiClient* client = [SWGApiClient sharedClientFromPool:basePath];
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// it's void
|
||||||
|
return [client stringWithCompletionBlock: requestUrl
|
||||||
|
method: @"POST"
|
||||||
|
queryParams: queryParams
|
||||||
|
body: bodyDictionary
|
||||||
|
headerParams: headerParams
|
||||||
|
requestContentType: requestContentType
|
||||||
|
responseContentType: responseContentType
|
||||||
|
completionBlock: ^(NSString *data, NSError *error) {
|
||||||
|
if (error) {
|
||||||
|
completionBlock(error);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
completionBlock(nil);
|
||||||
|
}];
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -199,18 +239,18 @@ static NSString * basePath = @"http://petstore.swagger.io/v2";
|
|||||||
id bodyDictionary = nil;
|
id bodyDictionary = nil;
|
||||||
|
|
||||||
|
|
||||||
bodyDictionary = [[NSMutableArray alloc] init];
|
|
||||||
|
|
||||||
NSMutableDictionary * formParams = [[NSMutableDictionary alloc]init];
|
NSMutableDictionary * formParams = [[NSMutableDictionary alloc]init];
|
||||||
|
|
||||||
|
|
||||||
[bodyDictionary addObject:formParams];
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
SWGApiClient* client = [SWGApiClient sharedClientFromPool:basePath];
|
SWGApiClient* client = [SWGApiClient sharedClientFromPool:basePath];
|
||||||
|
|
||||||
|
|
||||||
|
// response is in a container
|
||||||
// array container response type
|
// array container response type
|
||||||
return [client dictionary: requestUrl
|
return [client dictionary: requestUrl
|
||||||
method: @"GET"
|
method: @"GET"
|
||||||
@ -225,8 +265,24 @@ static NSString * basePath = @"http://petstore.swagger.io/v2";
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if([data isKindOfClass:[NSArray class]]){
|
||||||
|
NSMutableArray * objs = [[NSMutableArray alloc] initWithCapacity:[data count]];
|
||||||
|
for (NSDictionary* dict in (NSArray*)data) {
|
||||||
|
|
||||||
|
|
||||||
|
SWGPet* d = [[SWGPet alloc]initWithValues: dict];
|
||||||
|
|
||||||
|
[objs addObject:d];
|
||||||
|
}
|
||||||
|
completionBlock(objs, nil);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}];
|
}];
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -256,18 +312,18 @@ static NSString * basePath = @"http://petstore.swagger.io/v2";
|
|||||||
id bodyDictionary = nil;
|
id bodyDictionary = nil;
|
||||||
|
|
||||||
|
|
||||||
bodyDictionary = [[NSMutableArray alloc] init];
|
|
||||||
|
|
||||||
NSMutableDictionary * formParams = [[NSMutableDictionary alloc]init];
|
NSMutableDictionary * formParams = [[NSMutableDictionary alloc]init];
|
||||||
|
|
||||||
|
|
||||||
[bodyDictionary addObject:formParams];
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
SWGApiClient* client = [SWGApiClient sharedClientFromPool:basePath];
|
SWGApiClient* client = [SWGApiClient sharedClientFromPool:basePath];
|
||||||
|
|
||||||
|
|
||||||
|
// response is in a container
|
||||||
// array container response type
|
// array container response type
|
||||||
return [client dictionary: requestUrl
|
return [client dictionary: requestUrl
|
||||||
method: @"GET"
|
method: @"GET"
|
||||||
@ -282,8 +338,24 @@ static NSString * basePath = @"http://petstore.swagger.io/v2";
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if([data isKindOfClass:[NSArray class]]){
|
||||||
|
NSMutableArray * objs = [[NSMutableArray alloc] initWithCapacity:[data count]];
|
||||||
|
for (NSDictionary* dict in (NSArray*)data) {
|
||||||
|
|
||||||
|
|
||||||
|
SWGPet* d = [[SWGPet alloc]initWithValues: dict];
|
||||||
|
|
||||||
|
[objs addObject:d];
|
||||||
|
}
|
||||||
|
completionBlock(objs, nil);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}];
|
}];
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -312,12 +384,10 @@ static NSString * basePath = @"http://petstore.swagger.io/v2";
|
|||||||
id bodyDictionary = nil;
|
id bodyDictionary = nil;
|
||||||
|
|
||||||
|
|
||||||
bodyDictionary = [[NSMutableArray alloc] init];
|
|
||||||
|
|
||||||
NSMutableDictionary * formParams = [[NSMutableDictionary alloc]init];
|
NSMutableDictionary * formParams = [[NSMutableDictionary alloc]init];
|
||||||
|
|
||||||
|
|
||||||
[bodyDictionary addObject:formParams];
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -325,8 +395,14 @@ static NSString * basePath = @"http://petstore.swagger.io/v2";
|
|||||||
SWGApiClient* client = [SWGApiClient sharedClientFromPool:basePath];
|
SWGApiClient* client = [SWGApiClient sharedClientFromPool:basePath];
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// non container response
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// complex response
|
||||||
|
|
||||||
// comples response type
|
// comples response type
|
||||||
return [client dictionary: requestUrl
|
return [client dictionary: requestUrl
|
||||||
@ -342,16 +418,17 @@ static NSString * basePath = @"http://petstore.swagger.io/v2";
|
|||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
SWGPet* result = nil;
|
||||||
SWGPet *result = nil;
|
|
||||||
if (data) {
|
if (data) {
|
||||||
result = [[SWGPet alloc]initWithValues: data];
|
result = [[SWGPet alloc] initWithValues : data];
|
||||||
}
|
}
|
||||||
completionBlock(result , nil);
|
completionBlock(result , nil);
|
||||||
|
|
||||||
}];
|
}];
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
-(NSNumber*) updatePetWithFormWithCompletionBlock: (NSString*) petId
|
-(NSNumber*) updatePetWithFormWithCompletionBlock: (NSString*) petId
|
||||||
@ -381,23 +458,53 @@ static NSString * basePath = @"http://petstore.swagger.io/v2";
|
|||||||
id bodyDictionary = nil;
|
id bodyDictionary = nil;
|
||||||
|
|
||||||
|
|
||||||
bodyDictionary = [[NSMutableArray alloc] init];
|
|
||||||
|
|
||||||
NSMutableDictionary * formParams = [[NSMutableDictionary alloc]init];
|
NSMutableDictionary * formParams = [[NSMutableDictionary alloc]init];
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
formParams[@"name"] = name;
|
formParams[@"name"] = name;
|
||||||
|
|
||||||
|
if(bodyDictionary == nil) {
|
||||||
|
bodyDictionary = [[NSMutableArray alloc] init];
|
||||||
|
}
|
||||||
|
[bodyDictionary addObject:formParams];
|
||||||
|
|
||||||
|
|
||||||
formParams[@"status"] = status;
|
formParams[@"status"] = status;
|
||||||
|
|
||||||
|
if(bodyDictionary == nil) {
|
||||||
|
bodyDictionary = [[NSMutableArray alloc] init];
|
||||||
|
}
|
||||||
[bodyDictionary addObject:formParams];
|
[bodyDictionary addObject:formParams];
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
SWGApiClient* client = [SWGApiClient sharedClientFromPool:basePath];
|
SWGApiClient* client = [SWGApiClient sharedClientFromPool:basePath];
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// it's void
|
||||||
|
return [client stringWithCompletionBlock: requestUrl
|
||||||
|
method: @"POST"
|
||||||
|
queryParams: queryParams
|
||||||
|
body: bodyDictionary
|
||||||
|
headerParams: headerParams
|
||||||
|
requestContentType: requestContentType
|
||||||
|
responseContentType: responseContentType
|
||||||
|
completionBlock: ^(NSString *data, NSError *error) {
|
||||||
|
if (error) {
|
||||||
|
completionBlock(error);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
completionBlock(nil);
|
||||||
|
}];
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -429,12 +536,10 @@ static NSString * basePath = @"http://petstore.swagger.io/v2";
|
|||||||
id bodyDictionary = nil;
|
id bodyDictionary = nil;
|
||||||
|
|
||||||
|
|
||||||
bodyDictionary = [[NSMutableArray alloc] init];
|
|
||||||
|
|
||||||
NSMutableDictionary * formParams = [[NSMutableDictionary alloc]init];
|
NSMutableDictionary * formParams = [[NSMutableDictionary alloc]init];
|
||||||
|
|
||||||
|
|
||||||
[bodyDictionary addObject:formParams];
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -442,6 +547,26 @@ static NSString * basePath = @"http://petstore.swagger.io/v2";
|
|||||||
SWGApiClient* client = [SWGApiClient sharedClientFromPool:basePath];
|
SWGApiClient* client = [SWGApiClient sharedClientFromPool:basePath];
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// it's void
|
||||||
|
return [client stringWithCompletionBlock: requestUrl
|
||||||
|
method: @"DELETE"
|
||||||
|
queryParams: queryParams
|
||||||
|
body: bodyDictionary
|
||||||
|
headerParams: headerParams
|
||||||
|
requestContentType: requestContentType
|
||||||
|
responseContentType: responseContentType
|
||||||
|
completionBlock: ^(NSString *data, NSError *error) {
|
||||||
|
if (error) {
|
||||||
|
completionBlock(error);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
completionBlock(nil);
|
||||||
|
}];
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -472,31 +597,44 @@ static NSString * basePath = @"http://petstore.swagger.io/v2";
|
|||||||
id bodyDictionary = nil;
|
id bodyDictionary = nil;
|
||||||
|
|
||||||
|
|
||||||
bodyDictionary = [[NSMutableArray alloc] init];
|
|
||||||
|
|
||||||
NSMutableDictionary * formParams = [[NSMutableDictionary alloc]init];
|
NSMutableDictionary * formParams = [[NSMutableDictionary alloc]init];
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
formParams[@"additionalMetadata"] = additionalMetadata;
|
formParams[@"additionalMetadata"] = additionalMetadata;
|
||||||
|
|
||||||
|
if(bodyDictionary == nil) {
|
||||||
|
bodyDictionary = [[NSMutableArray alloc] init];
|
||||||
|
}
|
||||||
|
[bodyDictionary addObject:formParams];
|
||||||
|
|
||||||
|
|
||||||
requestContentType = @"multipart/form-data";
|
requestContentType = @"multipart/form-data";
|
||||||
|
if(bodyDictionary == nil) {
|
||||||
|
bodyDictionary = [[NSMutableArray alloc] init];
|
||||||
|
}
|
||||||
[bodyDictionary addObject:file];
|
[bodyDictionary addObject:file];
|
||||||
file.paramName = @"file";
|
file.paramName = @"file";
|
||||||
|
|
||||||
|
if(bodyDictionary == nil) {
|
||||||
|
bodyDictionary = [[NSMutableArray alloc] init];
|
||||||
|
}
|
||||||
[bodyDictionary addObject:formParams];
|
[bodyDictionary addObject:formParams];
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
SWGApiClient* client = [SWGApiClient sharedClientFromPool:basePath];
|
SWGApiClient* client = [SWGApiClient sharedClientFromPool:basePath];
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// primitive response type
|
|
||||||
|
|
||||||
|
// it's void
|
||||||
// no return base type
|
return [client stringWithCompletionBlock: requestUrl
|
||||||
return [client stringWithCompletionBlock: requestUrl
|
|
||||||
method: @"POST"
|
method: @"POST"
|
||||||
queryParams: queryParams
|
queryParams: queryParams
|
||||||
body: bodyDictionary
|
body: bodyDictionary
|
||||||
@ -510,9 +648,7 @@ static NSString * basePath = @"http://petstore.swagger.io/v2";
|
|||||||
}
|
}
|
||||||
completionBlock(nil);
|
completionBlock(nil);
|
||||||
}];
|
}];
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -73,18 +73,18 @@ static NSString * basePath = @"http://petstore.swagger.io/v2";
|
|||||||
id bodyDictionary = nil;
|
id bodyDictionary = nil;
|
||||||
|
|
||||||
|
|
||||||
bodyDictionary = [[NSMutableArray alloc] init];
|
|
||||||
|
|
||||||
NSMutableDictionary * formParams = [[NSMutableDictionary alloc]init];
|
NSMutableDictionary * formParams = [[NSMutableDictionary alloc]init];
|
||||||
|
|
||||||
|
|
||||||
[bodyDictionary addObject:formParams];
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
SWGApiClient* client = [SWGApiClient sharedClientFromPool:basePath];
|
SWGApiClient* client = [SWGApiClient sharedClientFromPool:basePath];
|
||||||
|
|
||||||
|
|
||||||
|
// response is in a container
|
||||||
// map container response type
|
// map container response type
|
||||||
return [client dictionary: requestUrl
|
return [client dictionary: requestUrl
|
||||||
method: @"GET"
|
method: @"GET"
|
||||||
@ -107,6 +107,9 @@ static NSString * basePath = @"http://petstore.swagger.io/v2";
|
|||||||
|
|
||||||
}];
|
}];
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -168,8 +171,14 @@ static NSString * basePath = @"http://petstore.swagger.io/v2";
|
|||||||
SWGApiClient* client = [SWGApiClient sharedClientFromPool:basePath];
|
SWGApiClient* client = [SWGApiClient sharedClientFromPool:basePath];
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// non container response
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// complex response
|
||||||
|
|
||||||
// comples response type
|
// comples response type
|
||||||
return [client dictionary: requestUrl
|
return [client dictionary: requestUrl
|
||||||
@ -185,16 +194,17 @@ static NSString * basePath = @"http://petstore.swagger.io/v2";
|
|||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
SWGOrder* result = nil;
|
||||||
SWGOrder *result = nil;
|
|
||||||
if (data) {
|
if (data) {
|
||||||
result = [[SWGOrder alloc]initWithValues: data];
|
result = [[SWGOrder alloc] initWithValues : data];
|
||||||
}
|
}
|
||||||
completionBlock(result , nil);
|
completionBlock(result , nil);
|
||||||
|
|
||||||
}];
|
}];
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
-(NSNumber*) getOrderByIdWithCompletionBlock: (NSString*) orderId
|
-(NSNumber*) getOrderByIdWithCompletionBlock: (NSString*) orderId
|
||||||
@ -222,12 +232,10 @@ static NSString * basePath = @"http://petstore.swagger.io/v2";
|
|||||||
id bodyDictionary = nil;
|
id bodyDictionary = nil;
|
||||||
|
|
||||||
|
|
||||||
bodyDictionary = [[NSMutableArray alloc] init];
|
|
||||||
|
|
||||||
NSMutableDictionary * formParams = [[NSMutableDictionary alloc]init];
|
NSMutableDictionary * formParams = [[NSMutableDictionary alloc]init];
|
||||||
|
|
||||||
|
|
||||||
[bodyDictionary addObject:formParams];
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -235,8 +243,14 @@ static NSString * basePath = @"http://petstore.swagger.io/v2";
|
|||||||
SWGApiClient* client = [SWGApiClient sharedClientFromPool:basePath];
|
SWGApiClient* client = [SWGApiClient sharedClientFromPool:basePath];
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// non container response
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// complex response
|
||||||
|
|
||||||
// comples response type
|
// comples response type
|
||||||
return [client dictionary: requestUrl
|
return [client dictionary: requestUrl
|
||||||
@ -252,16 +266,17 @@ static NSString * basePath = @"http://petstore.swagger.io/v2";
|
|||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
SWGOrder* result = nil;
|
||||||
SWGOrder *result = nil;
|
|
||||||
if (data) {
|
if (data) {
|
||||||
result = [[SWGOrder alloc]initWithValues: data];
|
result = [[SWGOrder alloc] initWithValues : data];
|
||||||
}
|
}
|
||||||
completionBlock(result , nil);
|
completionBlock(result , nil);
|
||||||
|
|
||||||
}];
|
}];
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
-(NSNumber*) deleteOrderWithCompletionBlock: (NSString*) orderId
|
-(NSNumber*) deleteOrderWithCompletionBlock: (NSString*) orderId
|
||||||
@ -289,12 +304,10 @@ static NSString * basePath = @"http://petstore.swagger.io/v2";
|
|||||||
id bodyDictionary = nil;
|
id bodyDictionary = nil;
|
||||||
|
|
||||||
|
|
||||||
bodyDictionary = [[NSMutableArray alloc] init];
|
|
||||||
|
|
||||||
NSMutableDictionary * formParams = [[NSMutableDictionary alloc]init];
|
NSMutableDictionary * formParams = [[NSMutableDictionary alloc]init];
|
||||||
|
|
||||||
|
|
||||||
[bodyDictionary addObject:formParams];
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -302,6 +315,26 @@ static NSString * basePath = @"http://petstore.swagger.io/v2";
|
|||||||
SWGApiClient* client = [SWGApiClient sharedClientFromPool:basePath];
|
SWGApiClient* client = [SWGApiClient sharedClientFromPool:basePath];
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// it's void
|
||||||
|
return [client stringWithCompletionBlock: requestUrl
|
||||||
|
method: @"DELETE"
|
||||||
|
queryParams: queryParams
|
||||||
|
body: bodyDictionary
|
||||||
|
headerParams: headerParams
|
||||||
|
requestContentType: requestContentType
|
||||||
|
responseContentType: responseContentType
|
||||||
|
completionBlock: ^(NSString *data, NSError *error) {
|
||||||
|
if (error) {
|
||||||
|
completionBlock(error);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
completionBlock(nil);
|
||||||
|
}];
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -108,12 +108,12 @@ static NSString * basePath = @"http://petstore.swagger.io/v2";
|
|||||||
SWGApiClient* client = [SWGApiClient sharedClientFromPool:basePath];
|
SWGApiClient* client = [SWGApiClient sharedClientFromPool:basePath];
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// primitive response type
|
|
||||||
|
|
||||||
|
// it's void
|
||||||
// no return base type
|
return [client stringWithCompletionBlock: requestUrl
|
||||||
return [client stringWithCompletionBlock: requestUrl
|
|
||||||
method: @"POST"
|
method: @"POST"
|
||||||
queryParams: queryParams
|
queryParams: queryParams
|
||||||
body: bodyDictionary
|
body: bodyDictionary
|
||||||
@ -127,9 +127,7 @@ static NSString * basePath = @"http://petstore.swagger.io/v2";
|
|||||||
}
|
}
|
||||||
completionBlock(nil);
|
completionBlock(nil);
|
||||||
}];
|
}];
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -191,12 +189,12 @@ static NSString * basePath = @"http://petstore.swagger.io/v2";
|
|||||||
SWGApiClient* client = [SWGApiClient sharedClientFromPool:basePath];
|
SWGApiClient* client = [SWGApiClient sharedClientFromPool:basePath];
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// primitive response type
|
|
||||||
|
|
||||||
|
// it's void
|
||||||
// no return base type
|
return [client stringWithCompletionBlock: requestUrl
|
||||||
return [client stringWithCompletionBlock: requestUrl
|
|
||||||
method: @"POST"
|
method: @"POST"
|
||||||
queryParams: queryParams
|
queryParams: queryParams
|
||||||
body: bodyDictionary
|
body: bodyDictionary
|
||||||
@ -210,9 +208,7 @@ static NSString * basePath = @"http://petstore.swagger.io/v2";
|
|||||||
}
|
}
|
||||||
completionBlock(nil);
|
completionBlock(nil);
|
||||||
}];
|
}];
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -274,12 +270,12 @@ static NSString * basePath = @"http://petstore.swagger.io/v2";
|
|||||||
SWGApiClient* client = [SWGApiClient sharedClientFromPool:basePath];
|
SWGApiClient* client = [SWGApiClient sharedClientFromPool:basePath];
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// primitive response type
|
|
||||||
|
|
||||||
|
// it's void
|
||||||
// no return base type
|
return [client stringWithCompletionBlock: requestUrl
|
||||||
return [client stringWithCompletionBlock: requestUrl
|
|
||||||
method: @"POST"
|
method: @"POST"
|
||||||
queryParams: queryParams
|
queryParams: queryParams
|
||||||
body: bodyDictionary
|
body: bodyDictionary
|
||||||
@ -293,9 +289,7 @@ static NSString * basePath = @"http://petstore.swagger.io/v2";
|
|||||||
}
|
}
|
||||||
completionBlock(nil);
|
completionBlock(nil);
|
||||||
}];
|
}];
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -328,12 +322,10 @@ static NSString * basePath = @"http://petstore.swagger.io/v2";
|
|||||||
id bodyDictionary = nil;
|
id bodyDictionary = nil;
|
||||||
|
|
||||||
|
|
||||||
bodyDictionary = [[NSMutableArray alloc] init];
|
|
||||||
|
|
||||||
NSMutableDictionary * formParams = [[NSMutableDictionary alloc]init];
|
NSMutableDictionary * formParams = [[NSMutableDictionary alloc]init];
|
||||||
|
|
||||||
|
|
||||||
[bodyDictionary addObject:formParams];
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -341,7 +333,12 @@ static NSString * basePath = @"http://petstore.swagger.io/v2";
|
|||||||
SWGApiClient* client = [SWGApiClient sharedClientFromPool:basePath];
|
SWGApiClient* client = [SWGApiClient sharedClientFromPool:basePath];
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// non container response
|
||||||
|
|
||||||
|
|
||||||
|
// primitive response
|
||||||
// primitive response type
|
// primitive response type
|
||||||
return [client stringWithCompletionBlock: requestUrl
|
return [client stringWithCompletionBlock: requestUrl
|
||||||
method: @"GET"
|
method: @"GET"
|
||||||
@ -361,8 +358,13 @@ static NSString * basePath = @"http://petstore.swagger.io/v2";
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// complex response
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
-(NSNumber*) logoutUserWithCompletionBlock:
|
-(NSNumber*) logoutUserWithCompletionBlock:
|
||||||
@ -388,12 +390,10 @@ static NSString * basePath = @"http://petstore.swagger.io/v2";
|
|||||||
id bodyDictionary = nil;
|
id bodyDictionary = nil;
|
||||||
|
|
||||||
|
|
||||||
bodyDictionary = [[NSMutableArray alloc] init];
|
|
||||||
|
|
||||||
NSMutableDictionary * formParams = [[NSMutableDictionary alloc]init];
|
NSMutableDictionary * formParams = [[NSMutableDictionary alloc]init];
|
||||||
|
|
||||||
|
|
||||||
[bodyDictionary addObject:formParams];
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -401,12 +401,12 @@ static NSString * basePath = @"http://petstore.swagger.io/v2";
|
|||||||
SWGApiClient* client = [SWGApiClient sharedClientFromPool:basePath];
|
SWGApiClient* client = [SWGApiClient sharedClientFromPool:basePath];
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// primitive response type
|
|
||||||
|
|
||||||
|
// it's void
|
||||||
// no return base type
|
return [client stringWithCompletionBlock: requestUrl
|
||||||
return [client stringWithCompletionBlock: requestUrl
|
|
||||||
method: @"GET"
|
method: @"GET"
|
||||||
queryParams: queryParams
|
queryParams: queryParams
|
||||||
body: bodyDictionary
|
body: bodyDictionary
|
||||||
@ -420,9 +420,7 @@ static NSString * basePath = @"http://petstore.swagger.io/v2";
|
|||||||
}
|
}
|
||||||
completionBlock(nil);
|
completionBlock(nil);
|
||||||
}];
|
}];
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -451,12 +449,10 @@ static NSString * basePath = @"http://petstore.swagger.io/v2";
|
|||||||
id bodyDictionary = nil;
|
id bodyDictionary = nil;
|
||||||
|
|
||||||
|
|
||||||
bodyDictionary = [[NSMutableArray alloc] init];
|
|
||||||
|
|
||||||
NSMutableDictionary * formParams = [[NSMutableDictionary alloc]init];
|
NSMutableDictionary * formParams = [[NSMutableDictionary alloc]init];
|
||||||
|
|
||||||
|
|
||||||
[bodyDictionary addObject:formParams];
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -464,8 +460,14 @@ static NSString * basePath = @"http://petstore.swagger.io/v2";
|
|||||||
SWGApiClient* client = [SWGApiClient sharedClientFromPool:basePath];
|
SWGApiClient* client = [SWGApiClient sharedClientFromPool:basePath];
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// non container response
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// complex response
|
||||||
|
|
||||||
// comples response type
|
// comples response type
|
||||||
return [client dictionary: requestUrl
|
return [client dictionary: requestUrl
|
||||||
@ -481,16 +483,17 @@ static NSString * basePath = @"http://petstore.swagger.io/v2";
|
|||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
SWGUser* result = nil;
|
||||||
SWGUser *result = nil;
|
|
||||||
if (data) {
|
if (data) {
|
||||||
result = [[SWGUser alloc]initWithValues: data];
|
result = [[SWGUser alloc] initWithValues : data];
|
||||||
}
|
}
|
||||||
completionBlock(result , nil);
|
completionBlock(result , nil);
|
||||||
|
|
||||||
}];
|
}];
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
-(NSNumber*) updateUserWithCompletionBlock: (NSString*) username
|
-(NSNumber*) updateUserWithCompletionBlock: (NSString*) username
|
||||||
@ -553,6 +556,26 @@ static NSString * basePath = @"http://petstore.swagger.io/v2";
|
|||||||
SWGApiClient* client = [SWGApiClient sharedClientFromPool:basePath];
|
SWGApiClient* client = [SWGApiClient sharedClientFromPool:basePath];
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// it's void
|
||||||
|
return [client stringWithCompletionBlock: requestUrl
|
||||||
|
method: @"PUT"
|
||||||
|
queryParams: queryParams
|
||||||
|
body: bodyDictionary
|
||||||
|
headerParams: headerParams
|
||||||
|
requestContentType: requestContentType
|
||||||
|
responseContentType: responseContentType
|
||||||
|
completionBlock: ^(NSString *data, NSError *error) {
|
||||||
|
if (error) {
|
||||||
|
completionBlock(error);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
completionBlock(nil);
|
||||||
|
}];
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -581,12 +604,10 @@ static NSString * basePath = @"http://petstore.swagger.io/v2";
|
|||||||
id bodyDictionary = nil;
|
id bodyDictionary = nil;
|
||||||
|
|
||||||
|
|
||||||
bodyDictionary = [[NSMutableArray alloc] init];
|
|
||||||
|
|
||||||
NSMutableDictionary * formParams = [[NSMutableDictionary alloc]init];
|
NSMutableDictionary * formParams = [[NSMutableDictionary alloc]init];
|
||||||
|
|
||||||
|
|
||||||
[bodyDictionary addObject:formParams];
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -594,6 +615,26 @@ static NSString * basePath = @"http://petstore.swagger.io/v2";
|
|||||||
SWGApiClient* client = [SWGApiClient sharedClientFromPool:basePath];
|
SWGApiClient* client = [SWGApiClient sharedClientFromPool:basePath];
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// it's void
|
||||||
|
return [client stringWithCompletionBlock: requestUrl
|
||||||
|
method: @"DELETE"
|
||||||
|
queryParams: queryParams
|
||||||
|
body: bodyDictionary
|
||||||
|
headerParams: headerParams
|
||||||
|
requestContentType: requestContentType
|
||||||
|
responseContentType: responseContentType
|
||||||
|
completionBlock: ^(NSString *data, NSError *error) {
|
||||||
|
if (error) {
|
||||||
|
completionBlock(error);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
completionBlock(nil);
|
||||||
|
}];
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
108
samples/client/petstore/objc/pom.xml
Normal file
108
samples/client/petstore/objc/pom.xml
Normal file
@ -0,0 +1,108 @@
|
|||||||
|
<project>
|
||||||
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
<groupId>de.felixschulze.my-project</groupId>
|
||||||
|
<artifactId>PetstoreClient</artifactId>
|
||||||
|
<packaging>pom</packaging>
|
||||||
|
<version>1.0-SNAPSHOT</version>
|
||||||
|
<name>Objective-C Swagger Petstore Client</name>
|
||||||
|
<build>
|
||||||
|
<plugins>
|
||||||
|
<plugin>
|
||||||
|
<artifactId>maven-dependency-plugin</artifactId>
|
||||||
|
<executions>
|
||||||
|
<execution>
|
||||||
|
<phase>package</phase>
|
||||||
|
<goals>
|
||||||
|
<goal>copy-dependencies</goal>
|
||||||
|
</goals>
|
||||||
|
<configuration>
|
||||||
|
<outputDirectory>${project.build.directory}</outputDirectory>
|
||||||
|
</configuration>
|
||||||
|
</execution>
|
||||||
|
</executions>
|
||||||
|
</plugin>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.eclipse.jetty</groupId>
|
||||||
|
<artifactId>jetty-maven-plugin</artifactId>
|
||||||
|
<version>${jetty-version}</version>
|
||||||
|
<configuration>
|
||||||
|
<war>${project.build.directory}/swagger-java-jersey-sample-app-${webapp-version}.war</war>
|
||||||
|
<stopKey>alpha</stopKey>
|
||||||
|
<stopPort>9099</stopPort>
|
||||||
|
<httpConnector>
|
||||||
|
<port>8002</port>
|
||||||
|
</httpConnector>
|
||||||
|
</configuration>
|
||||||
|
<executions>
|
||||||
|
<execution>
|
||||||
|
<id>start-jetty</id>
|
||||||
|
<phase>pre-integration-test</phase>
|
||||||
|
<goals>
|
||||||
|
<goal>deploy-war</goal>
|
||||||
|
</goals>
|
||||||
|
</execution>
|
||||||
|
</executions>
|
||||||
|
</plugin>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.codehaus.mojo</groupId>
|
||||||
|
<artifactId>exec-maven-plugin</artifactId>
|
||||||
|
<version>1.2.1</version>
|
||||||
|
<executions>
|
||||||
|
<execution>
|
||||||
|
<id>install-pods</id>
|
||||||
|
<phase>pre-integration-test</phase>
|
||||||
|
<goals>
|
||||||
|
<goal>exec</goal>
|
||||||
|
</goals>
|
||||||
|
<configuration>
|
||||||
|
<executable>pod</executable>
|
||||||
|
<arguments>
|
||||||
|
<argument>install</argument>
|
||||||
|
</arguments>
|
||||||
|
</configuration>
|
||||||
|
</execution>
|
||||||
|
<execution>
|
||||||
|
<id>xcodebuild-test</id>
|
||||||
|
<phase>integration-test</phase>
|
||||||
|
<goals>
|
||||||
|
<goal>exec</goal>
|
||||||
|
</goals>
|
||||||
|
<configuration>
|
||||||
|
<executable>xcodebuild</executable>
|
||||||
|
<arguments>
|
||||||
|
<argument>-workspace</argument>
|
||||||
|
<argument>PetstoreClient.xcworkspace</argument>
|
||||||
|
<argument>-scheme</argument>
|
||||||
|
<argument>PetstoreClient</argument>
|
||||||
|
<argument>test</argument>
|
||||||
|
<argument>-destination</argument>
|
||||||
|
<argument>platform=iOS Simulator,name=iPhone 6,OS=8.2</argument>
|
||||||
|
</arguments>
|
||||||
|
</configuration>
|
||||||
|
</execution>
|
||||||
|
</executions>
|
||||||
|
</plugin>
|
||||||
|
</plugins>
|
||||||
|
</build>
|
||||||
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.wordnik</groupId>
|
||||||
|
<artifactId>swagger-java-jersey-sample-app</artifactId>
|
||||||
|
<version>${webapp-version}</version>
|
||||||
|
<type>war</type>
|
||||||
|
</dependency>
|
||||||
|
</dependencies>
|
||||||
|
<repositories>
|
||||||
|
<repository>
|
||||||
|
<id>sonatype-snapshots</id>
|
||||||
|
<url>https://oss.sonatype.org/content/repositories/snapshots</url>
|
||||||
|
<snapshots>
|
||||||
|
<enabled>true</enabled>
|
||||||
|
</snapshots>
|
||||||
|
</repository>
|
||||||
|
</repositories>
|
||||||
|
<properties>
|
||||||
|
<webapp-version>1.5.4-M1-SNAPSHOT</webapp-version>
|
||||||
|
<jetty-version>9.2.9.v20150224</jetty-version>
|
||||||
|
</properties>
|
||||||
|
</project>
|
@ -1,60 +0,0 @@
|
|||||||
<?php
|
|
||||||
/**
|
|
||||||
* Copyright 2015 Reverb Technologies, Inc.
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* $model.description$
|
|
||||||
*
|
|
||||||
* NOTE: This class is auto generated by the swagger code generator program. Do not edit the class manually.
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
class category implements ArrayAccess {
|
|
||||||
static $swaggerTypes = array(
|
|
||||||
'id' => 'int',
|
|
||||||
'name' => 'string'
|
|
||||||
);
|
|
||||||
|
|
||||||
static $attributeMap = array(
|
|
||||||
'id' => 'id',
|
|
||||||
'name' => 'name'
|
|
||||||
);
|
|
||||||
|
|
||||||
|
|
||||||
public $id; /* int */
|
|
||||||
public $name; /* string */
|
|
||||||
|
|
||||||
public function __construct(array $data) {
|
|
||||||
$this->id = $data["id"];
|
|
||||||
$this->name = $data["name"];
|
|
||||||
}
|
|
||||||
|
|
||||||
public function offsetExists($offset) {
|
|
||||||
return isset($this->$offset);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function offsetGet($offset) {
|
|
||||||
return $this->$offset;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function offsetSet($offset, $value) {
|
|
||||||
$this->$offset = $value;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function offsetUnset($offset) {
|
|
||||||
unset($this->$offset);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,79 +0,0 @@
|
|||||||
<?php
|
|
||||||
/**
|
|
||||||
* Copyright 2015 Reverb Technologies, Inc.
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* $model.description$
|
|
||||||
*
|
|
||||||
* NOTE: This class is auto generated by the swagger code generator program. Do not edit the class manually.
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
class order implements ArrayAccess {
|
|
||||||
static $swaggerTypes = array(
|
|
||||||
'id' => 'int',
|
|
||||||
'pet_id' => 'int',
|
|
||||||
'quantity' => 'int',
|
|
||||||
'ship_date' => 'DateTime',
|
|
||||||
'status' => 'string',
|
|
||||||
'complete' => 'boolean'
|
|
||||||
);
|
|
||||||
|
|
||||||
static $attributeMap = array(
|
|
||||||
'id' => 'id',
|
|
||||||
'pet_id' => 'petId',
|
|
||||||
'quantity' => 'quantity',
|
|
||||||
'ship_date' => 'shipDate',
|
|
||||||
'status' => 'status',
|
|
||||||
'complete' => 'complete'
|
|
||||||
);
|
|
||||||
|
|
||||||
|
|
||||||
public $id; /* int */
|
|
||||||
public $pet_id; /* int */
|
|
||||||
public $quantity; /* int */
|
|
||||||
public $ship_date; /* DateTime */
|
|
||||||
/**
|
|
||||||
* Order Status
|
|
||||||
*/
|
|
||||||
public $status; /* string */
|
|
||||||
public $complete; /* boolean */
|
|
||||||
|
|
||||||
public function __construct(array $data) {
|
|
||||||
$this->id = $data["id"];
|
|
||||||
$this->pet_id = $data["pet_id"];
|
|
||||||
$this->quantity = $data["quantity"];
|
|
||||||
$this->ship_date = $data["ship_date"];
|
|
||||||
$this->status = $data["status"];
|
|
||||||
$this->complete = $data["complete"];
|
|
||||||
}
|
|
||||||
|
|
||||||
public function offsetExists($offset) {
|
|
||||||
return isset($this->$offset);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function offsetGet($offset) {
|
|
||||||
return $this->$offset;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function offsetSet($offset, $value) {
|
|
||||||
$this->$offset = $value;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function offsetUnset($offset) {
|
|
||||||
unset($this->$offset);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,60 +0,0 @@
|
|||||||
<?php
|
|
||||||
/**
|
|
||||||
* Copyright 2015 Reverb Technologies, Inc.
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* $model.description$
|
|
||||||
*
|
|
||||||
* NOTE: This class is auto generated by the swagger code generator program. Do not edit the class manually.
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
class tag implements ArrayAccess {
|
|
||||||
static $swaggerTypes = array(
|
|
||||||
'id' => 'int',
|
|
||||||
'name' => 'string'
|
|
||||||
);
|
|
||||||
|
|
||||||
static $attributeMap = array(
|
|
||||||
'id' => 'id',
|
|
||||||
'name' => 'name'
|
|
||||||
);
|
|
||||||
|
|
||||||
|
|
||||||
public $id; /* int */
|
|
||||||
public $name; /* string */
|
|
||||||
|
|
||||||
public function __construct(array $data) {
|
|
||||||
$this->id = $data["id"];
|
|
||||||
$this->name = $data["name"];
|
|
||||||
}
|
|
||||||
|
|
||||||
public function offsetExists($offset) {
|
|
||||||
return isset($this->$offset);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function offsetGet($offset) {
|
|
||||||
return $this->$offset;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function offsetSet($offset, $value) {
|
|
||||||
$this->$offset = $value;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function offsetUnset($offset) {
|
|
||||||
unset($this->$offset);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,324 +0,0 @@
|
|||||||
require "uri"
|
|
||||||
|
|
||||||
class Pet_api
|
|
||||||
basePath = "http://petstore.swagger.wordnik.com/api"
|
|
||||||
# apiInvoker = APIInvoker
|
|
||||||
|
|
||||||
def self.escapeString(string)
|
|
||||||
URI.encode(string.to_s)
|
|
||||||
end
|
|
||||||
|
|
||||||
def self.get_pet_by_id (pet_id,opts={})
|
|
||||||
query_param_keys = []
|
|
||||||
|
|
||||||
# verify existence of params
|
|
||||||
raise "pet_id is required" if pet_id.nil?
|
|
||||||
# set default values and merge with input
|
|
||||||
options = {
|
|
||||||
:pet_id => pet_id}.merge(opts)
|
|
||||||
|
|
||||||
#resource path
|
|
||||||
path = "/pet/{petId}".sub('{format}','json').sub('{' + 'petId' + '}', escapeString(pet_id))
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# pull querystring keys from options
|
|
||||||
queryopts = options.select do |key,value|
|
|
||||||
query_param_keys.include? key
|
|
||||||
end
|
|
||||||
|
|
||||||
headers = nil
|
|
||||||
post_body = nil
|
|
||||||
response = Swagger::Request.new(:GET, path, {:params=>queryopts,:headers=>headers, :body=>post_body }).make.body
|
|
||||||
Pet.new(response)
|
|
||||||
|
|
||||||
end
|
|
||||||
|
|
||||||
def self.delete_pet (pet_id,opts={})
|
|
||||||
query_param_keys = []
|
|
||||||
|
|
||||||
# verify existence of params
|
|
||||||
raise "pet_id is required" if pet_id.nil?
|
|
||||||
# set default values and merge with input
|
|
||||||
options = {
|
|
||||||
:pet_id => pet_id}.merge(opts)
|
|
||||||
|
|
||||||
#resource path
|
|
||||||
path = "/pet/{petId}".sub('{format}','json').sub('{' + 'petId' + '}', escapeString(pet_id))
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# pull querystring keys from options
|
|
||||||
queryopts = options.select do |key,value|
|
|
||||||
query_param_keys.include? key
|
|
||||||
end
|
|
||||||
|
|
||||||
headers = nil
|
|
||||||
post_body = nil
|
|
||||||
Swagger::Request.new(:DELETE, path, {:params=>queryopts,:headers=>headers, :body=>post_body}).make
|
|
||||||
|
|
||||||
|
|
||||||
end
|
|
||||||
|
|
||||||
def self.partial_update (pet_id,body,opts={})
|
|
||||||
query_param_keys = []
|
|
||||||
|
|
||||||
# verify existence of params
|
|
||||||
raise "pet_id is required" if pet_id.nil?
|
|
||||||
raise "body is required" if body.nil?
|
|
||||||
# set default values and merge with input
|
|
||||||
options = {
|
|
||||||
:pet_id => pet_id,
|
|
||||||
:body => body}.merge(opts)
|
|
||||||
|
|
||||||
#resource path
|
|
||||||
path = "/pet/{petId}".sub('{format}','json').sub('{' + 'petId' + '}', escapeString(pet_id))
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# pull querystring keys from options
|
|
||||||
queryopts = options.select do |key,value|
|
|
||||||
query_param_keys.include? key
|
|
||||||
end
|
|
||||||
|
|
||||||
headers = nil
|
|
||||||
post_body = nil
|
|
||||||
if body != nil
|
|
||||||
if body.is_a?(Array)
|
|
||||||
array = Array.new
|
|
||||||
body.each do |item|
|
|
||||||
if item.respond_to?("to_body".to_sym)
|
|
||||||
array.push item.to_body
|
|
||||||
else
|
|
||||||
array.push item
|
|
||||||
end
|
|
||||||
end
|
|
||||||
post_body = array
|
|
||||||
|
|
||||||
else
|
|
||||||
if body.respond_to?("to_body".to_sym)
|
|
||||||
post_body = body.to_body
|
|
||||||
else
|
|
||||||
post_body = body
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
response = Swagger::Request.new(:PATCH, path, {:params=>queryopts,:headers=>headers, :body=>post_body }).make.body
|
|
||||||
response.map {|response|Pet.new(response)}
|
|
||||||
|
|
||||||
end
|
|
||||||
|
|
||||||
def self.update_pet_with_form (pet_id,name,status,opts={})
|
|
||||||
query_param_keys = []
|
|
||||||
|
|
||||||
# verify existence of params
|
|
||||||
raise "pet_id is required" if pet_id.nil?
|
|
||||||
# set default values and merge with input
|
|
||||||
options = {
|
|
||||||
:pet_id => pet_id,
|
|
||||||
:name => name,
|
|
||||||
:status => status}.merge(opts)
|
|
||||||
|
|
||||||
#resource path
|
|
||||||
path = "/pet/{petId}".sub('{format}','json').sub('{' + 'petId' + '}', escapeString(pet_id))
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# pull querystring keys from options
|
|
||||||
queryopts = options.select do |key,value|
|
|
||||||
query_param_keys.include? key
|
|
||||||
end
|
|
||||||
|
|
||||||
headers = nil
|
|
||||||
post_body = nil
|
|
||||||
Swagger::Request.new(:POST, path, {:params=>queryopts,:headers=>headers, :body=>post_body}).make
|
|
||||||
|
|
||||||
|
|
||||||
end
|
|
||||||
|
|
||||||
def self.upload_file (additional_metadata,body,opts={})
|
|
||||||
query_param_keys = []
|
|
||||||
|
|
||||||
# set default values and merge with input
|
|
||||||
options = {
|
|
||||||
:additional_metadata => additional_metadata,
|
|
||||||
:body => body}.merge(opts)
|
|
||||||
|
|
||||||
#resource path
|
|
||||||
path = "/pet/uploadImage".sub('{format}','json')
|
|
||||||
|
|
||||||
|
|
||||||
# pull querystring keys from options
|
|
||||||
queryopts = options.select do |key,value|
|
|
||||||
query_param_keys.include? key
|
|
||||||
end
|
|
||||||
|
|
||||||
headers = nil
|
|
||||||
post_body = nil
|
|
||||||
if body != nil
|
|
||||||
if body.is_a?(Array)
|
|
||||||
array = Array.new
|
|
||||||
body.each do |item|
|
|
||||||
if item.respond_to?("to_body".to_sym)
|
|
||||||
array.push item.to_body
|
|
||||||
else
|
|
||||||
array.push item
|
|
||||||
end
|
|
||||||
end
|
|
||||||
post_body = array
|
|
||||||
|
|
||||||
else
|
|
||||||
if body.respond_to?("to_body".to_sym)
|
|
||||||
post_body = body.to_body
|
|
||||||
else
|
|
||||||
post_body = body
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
Swagger::Request.new(:POST, path, {:params=>queryopts,:headers=>headers, :body=>post_body}).make
|
|
||||||
|
|
||||||
|
|
||||||
end
|
|
||||||
|
|
||||||
def self.add_pet (body,opts={})
|
|
||||||
query_param_keys = []
|
|
||||||
|
|
||||||
# verify existence of params
|
|
||||||
raise "body is required" if body.nil?
|
|
||||||
# set default values and merge with input
|
|
||||||
options = {
|
|
||||||
:body => body}.merge(opts)
|
|
||||||
|
|
||||||
#resource path
|
|
||||||
path = "/pet".sub('{format}','json')
|
|
||||||
|
|
||||||
|
|
||||||
# pull querystring keys from options
|
|
||||||
queryopts = options.select do |key,value|
|
|
||||||
query_param_keys.include? key
|
|
||||||
end
|
|
||||||
|
|
||||||
headers = nil
|
|
||||||
post_body = nil
|
|
||||||
if body != nil
|
|
||||||
if body.is_a?(Array)
|
|
||||||
array = Array.new
|
|
||||||
body.each do |item|
|
|
||||||
if item.respond_to?("to_body".to_sym)
|
|
||||||
array.push item.to_body
|
|
||||||
else
|
|
||||||
array.push item
|
|
||||||
end
|
|
||||||
end
|
|
||||||
post_body = array
|
|
||||||
|
|
||||||
else
|
|
||||||
if body.respond_to?("to_body".to_sym)
|
|
||||||
post_body = body.to_body
|
|
||||||
else
|
|
||||||
post_body = body
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
Swagger::Request.new(:POST, path, {:params=>queryopts,:headers=>headers, :body=>post_body}).make
|
|
||||||
|
|
||||||
|
|
||||||
end
|
|
||||||
|
|
||||||
def self.update_pet (body,opts={})
|
|
||||||
query_param_keys = []
|
|
||||||
|
|
||||||
# verify existence of params
|
|
||||||
raise "body is required" if body.nil?
|
|
||||||
# set default values and merge with input
|
|
||||||
options = {
|
|
||||||
:body => body}.merge(opts)
|
|
||||||
|
|
||||||
#resource path
|
|
||||||
path = "/pet".sub('{format}','json')
|
|
||||||
|
|
||||||
|
|
||||||
# pull querystring keys from options
|
|
||||||
queryopts = options.select do |key,value|
|
|
||||||
query_param_keys.include? key
|
|
||||||
end
|
|
||||||
|
|
||||||
headers = nil
|
|
||||||
post_body = nil
|
|
||||||
if body != nil
|
|
||||||
if body.is_a?(Array)
|
|
||||||
array = Array.new
|
|
||||||
body.each do |item|
|
|
||||||
if item.respond_to?("to_body".to_sym)
|
|
||||||
array.push item.to_body
|
|
||||||
else
|
|
||||||
array.push item
|
|
||||||
end
|
|
||||||
end
|
|
||||||
post_body = array
|
|
||||||
|
|
||||||
else
|
|
||||||
if body.respond_to?("to_body".to_sym)
|
|
||||||
post_body = body.to_body
|
|
||||||
else
|
|
||||||
post_body = body
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
Swagger::Request.new(:PUT, path, {:params=>queryopts,:headers=>headers, :body=>post_body}).make
|
|
||||||
|
|
||||||
|
|
||||||
end
|
|
||||||
|
|
||||||
def self.find_pets_by_status (status= "available",opts={})
|
|
||||||
query_param_keys = [:status]
|
|
||||||
|
|
||||||
# verify existence of params
|
|
||||||
raise "status is required" if status.nil?
|
|
||||||
# set default values and merge with input
|
|
||||||
options = {
|
|
||||||
:status => status}.merge(opts)
|
|
||||||
|
|
||||||
#resource path
|
|
||||||
path = "/pet/findByStatus".sub('{format}','json')
|
|
||||||
|
|
||||||
|
|
||||||
# pull querystring keys from options
|
|
||||||
queryopts = options.select do |key,value|
|
|
||||||
query_param_keys.include? key
|
|
||||||
end
|
|
||||||
|
|
||||||
headers = nil
|
|
||||||
post_body = nil
|
|
||||||
response = Swagger::Request.new(:GET, path, {:params=>queryopts,:headers=>headers, :body=>post_body }).make.body
|
|
||||||
response.map {|response|Pet.new(response)}
|
|
||||||
|
|
||||||
end
|
|
||||||
|
|
||||||
def self.find_pets_by_tags (tags,opts={})
|
|
||||||
query_param_keys = [:tags]
|
|
||||||
|
|
||||||
# verify existence of params
|
|
||||||
raise "tags is required" if tags.nil?
|
|
||||||
# set default values and merge with input
|
|
||||||
options = {
|
|
||||||
:tags => tags}.merge(opts)
|
|
||||||
|
|
||||||
#resource path
|
|
||||||
path = "/pet/findByTags".sub('{format}','json')
|
|
||||||
|
|
||||||
|
|
||||||
# pull querystring keys from options
|
|
||||||
queryopts = options.select do |key,value|
|
|
||||||
query_param_keys.include? key
|
|
||||||
end
|
|
||||||
|
|
||||||
headers = nil
|
|
||||||
post_body = nil
|
|
||||||
response = Swagger::Request.new(:GET, path, {:params=>queryopts,:headers=>headers, :body=>post_body }).make.body
|
|
||||||
response.map {|response|Pet.new(response)}
|
|
||||||
|
|
||||||
end
|
|
||||||
|
|
||||||
end
|
|
||||||
|
|
@ -1,109 +0,0 @@
|
|||||||
require "uri"
|
|
||||||
|
|
||||||
class Store_api
|
|
||||||
basePath = "http://petstore.swagger.wordnik.com/api"
|
|
||||||
# apiInvoker = APIInvoker
|
|
||||||
|
|
||||||
def self.escapeString(string)
|
|
||||||
URI.encode(string.to_s)
|
|
||||||
end
|
|
||||||
|
|
||||||
def self.get_order_by_id (order_id,opts={})
|
|
||||||
query_param_keys = []
|
|
||||||
|
|
||||||
# verify existence of params
|
|
||||||
raise "order_id is required" if order_id.nil?
|
|
||||||
# set default values and merge with input
|
|
||||||
options = {
|
|
||||||
:order_id => order_id}.merge(opts)
|
|
||||||
|
|
||||||
#resource path
|
|
||||||
path = "/store/order/{orderId}".sub('{format}','json').sub('{' + 'orderId' + '}', escapeString(order_id))
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# pull querystring keys from options
|
|
||||||
queryopts = options.select do |key,value|
|
|
||||||
query_param_keys.include? key
|
|
||||||
end
|
|
||||||
|
|
||||||
headers = nil
|
|
||||||
post_body = nil
|
|
||||||
response = Swagger::Request.new(:GET, path, {:params=>queryopts,:headers=>headers, :body=>post_body }).make.body
|
|
||||||
Order.new(response)
|
|
||||||
|
|
||||||
end
|
|
||||||
|
|
||||||
def self.delete_order (order_id,opts={})
|
|
||||||
query_param_keys = []
|
|
||||||
|
|
||||||
# verify existence of params
|
|
||||||
raise "order_id is required" if order_id.nil?
|
|
||||||
# set default values and merge with input
|
|
||||||
options = {
|
|
||||||
:order_id => order_id}.merge(opts)
|
|
||||||
|
|
||||||
#resource path
|
|
||||||
path = "/store/order/{orderId}".sub('{format}','json').sub('{' + 'orderId' + '}', escapeString(order_id))
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# pull querystring keys from options
|
|
||||||
queryopts = options.select do |key,value|
|
|
||||||
query_param_keys.include? key
|
|
||||||
end
|
|
||||||
|
|
||||||
headers = nil
|
|
||||||
post_body = nil
|
|
||||||
Swagger::Request.new(:DELETE, path, {:params=>queryopts,:headers=>headers, :body=>post_body}).make
|
|
||||||
|
|
||||||
|
|
||||||
end
|
|
||||||
|
|
||||||
def self.place_order (body,opts={})
|
|
||||||
query_param_keys = []
|
|
||||||
|
|
||||||
# verify existence of params
|
|
||||||
raise "body is required" if body.nil?
|
|
||||||
# set default values and merge with input
|
|
||||||
options = {
|
|
||||||
:body => body}.merge(opts)
|
|
||||||
|
|
||||||
#resource path
|
|
||||||
path = "/store/order".sub('{format}','json')
|
|
||||||
|
|
||||||
|
|
||||||
# pull querystring keys from options
|
|
||||||
queryopts = options.select do |key,value|
|
|
||||||
query_param_keys.include? key
|
|
||||||
end
|
|
||||||
|
|
||||||
headers = nil
|
|
||||||
post_body = nil
|
|
||||||
if body != nil
|
|
||||||
if body.is_a?(Array)
|
|
||||||
array = Array.new
|
|
||||||
body.each do |item|
|
|
||||||
if item.respond_to?("to_body".to_sym)
|
|
||||||
array.push item.to_body
|
|
||||||
else
|
|
||||||
array.push item
|
|
||||||
end
|
|
||||||
end
|
|
||||||
post_body = array
|
|
||||||
|
|
||||||
else
|
|
||||||
if body.respond_to?("to_body".to_sym)
|
|
||||||
post_body = body.to_body
|
|
||||||
else
|
|
||||||
post_body = body
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
Swagger::Request.new(:POST, path, {:params=>queryopts,:headers=>headers, :body=>post_body}).make
|
|
||||||
|
|
||||||
|
|
||||||
end
|
|
||||||
|
|
||||||
end
|
|
||||||
|
|
@ -1,297 +0,0 @@
|
|||||||
require "uri"
|
|
||||||
|
|
||||||
class User_api
|
|
||||||
basePath = "http://petstore.swagger.wordnik.com/api"
|
|
||||||
# apiInvoker = APIInvoker
|
|
||||||
|
|
||||||
def self.escapeString(string)
|
|
||||||
URI.encode(string.to_s)
|
|
||||||
end
|
|
||||||
|
|
||||||
def self.update_user (username,body,opts={})
|
|
||||||
query_param_keys = []
|
|
||||||
|
|
||||||
# verify existence of params
|
|
||||||
raise "username is required" if username.nil?
|
|
||||||
raise "body is required" if body.nil?
|
|
||||||
# set default values and merge with input
|
|
||||||
options = {
|
|
||||||
:username => username,
|
|
||||||
:body => body}.merge(opts)
|
|
||||||
|
|
||||||
#resource path
|
|
||||||
path = "/user/{username}".sub('{format}','json').sub('{' + 'username' + '}', escapeString(username))
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# pull querystring keys from options
|
|
||||||
queryopts = options.select do |key,value|
|
|
||||||
query_param_keys.include? key
|
|
||||||
end
|
|
||||||
|
|
||||||
headers = nil
|
|
||||||
post_body = nil
|
|
||||||
if body != nil
|
|
||||||
if body.is_a?(Array)
|
|
||||||
array = Array.new
|
|
||||||
body.each do |item|
|
|
||||||
if item.respond_to?("to_body".to_sym)
|
|
||||||
array.push item.to_body
|
|
||||||
else
|
|
||||||
array.push item
|
|
||||||
end
|
|
||||||
end
|
|
||||||
post_body = array
|
|
||||||
|
|
||||||
else
|
|
||||||
if body.respond_to?("to_body".to_sym)
|
|
||||||
post_body = body.to_body
|
|
||||||
else
|
|
||||||
post_body = body
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
Swagger::Request.new(:PUT, path, {:params=>queryopts,:headers=>headers, :body=>post_body}).make
|
|
||||||
|
|
||||||
|
|
||||||
end
|
|
||||||
|
|
||||||
def self.delete_user (username,opts={})
|
|
||||||
query_param_keys = []
|
|
||||||
|
|
||||||
# verify existence of params
|
|
||||||
raise "username is required" if username.nil?
|
|
||||||
# set default values and merge with input
|
|
||||||
options = {
|
|
||||||
:username => username}.merge(opts)
|
|
||||||
|
|
||||||
#resource path
|
|
||||||
path = "/user/{username}".sub('{format}','json').sub('{' + 'username' + '}', escapeString(username))
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# pull querystring keys from options
|
|
||||||
queryopts = options.select do |key,value|
|
|
||||||
query_param_keys.include? key
|
|
||||||
end
|
|
||||||
|
|
||||||
headers = nil
|
|
||||||
post_body = nil
|
|
||||||
Swagger::Request.new(:DELETE, path, {:params=>queryopts,:headers=>headers, :body=>post_body}).make
|
|
||||||
|
|
||||||
|
|
||||||
end
|
|
||||||
|
|
||||||
def self.get_user_by_name (username,opts={})
|
|
||||||
query_param_keys = []
|
|
||||||
|
|
||||||
# verify existence of params
|
|
||||||
raise "username is required" if username.nil?
|
|
||||||
# set default values and merge with input
|
|
||||||
options = {
|
|
||||||
:username => username}.merge(opts)
|
|
||||||
|
|
||||||
#resource path
|
|
||||||
path = "/user/{username}".sub('{format}','json').sub('{' + 'username' + '}', escapeString(username))
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# pull querystring keys from options
|
|
||||||
queryopts = options.select do |key,value|
|
|
||||||
query_param_keys.include? key
|
|
||||||
end
|
|
||||||
|
|
||||||
headers = nil
|
|
||||||
post_body = nil
|
|
||||||
response = Swagger::Request.new(:GET, path, {:params=>queryopts,:headers=>headers, :body=>post_body }).make.body
|
|
||||||
User.new(response)
|
|
||||||
|
|
||||||
end
|
|
||||||
|
|
||||||
def self.login_user (username,password,opts={})
|
|
||||||
query_param_keys = [:username,:password]
|
|
||||||
|
|
||||||
# verify existence of params
|
|
||||||
raise "username is required" if username.nil?
|
|
||||||
raise "password is required" if password.nil?
|
|
||||||
# set default values and merge with input
|
|
||||||
options = {
|
|
||||||
:username => username,
|
|
||||||
:password => password}.merge(opts)
|
|
||||||
|
|
||||||
#resource path
|
|
||||||
path = "/user/login".sub('{format}','json')
|
|
||||||
|
|
||||||
|
|
||||||
# pull querystring keys from options
|
|
||||||
queryopts = options.select do |key,value|
|
|
||||||
query_param_keys.include? key
|
|
||||||
end
|
|
||||||
|
|
||||||
headers = nil
|
|
||||||
post_body = nil
|
|
||||||
response = Swagger::Request.new(:GET, path, {:params=>queryopts,:headers=>headers, :body=>post_body }).make.body
|
|
||||||
string.new(response)
|
|
||||||
|
|
||||||
end
|
|
||||||
|
|
||||||
def self.logout_user (opts={})
|
|
||||||
query_param_keys = []
|
|
||||||
|
|
||||||
# set default values and merge with input
|
|
||||||
options = {
|
|
||||||
}.merge(opts)
|
|
||||||
|
|
||||||
#resource path
|
|
||||||
path = "/user/logout".sub('{format}','json')
|
|
||||||
|
|
||||||
|
|
||||||
# pull querystring keys from options
|
|
||||||
queryopts = options.select do |key,value|
|
|
||||||
query_param_keys.include? key
|
|
||||||
end
|
|
||||||
|
|
||||||
headers = nil
|
|
||||||
post_body = nil
|
|
||||||
Swagger::Request.new(:GET, path, {:params=>queryopts,:headers=>headers, :body=>post_body}).make
|
|
||||||
|
|
||||||
|
|
||||||
end
|
|
||||||
|
|
||||||
def self.create_user (body,opts={})
|
|
||||||
query_param_keys = []
|
|
||||||
|
|
||||||
# verify existence of params
|
|
||||||
raise "body is required" if body.nil?
|
|
||||||
# set default values and merge with input
|
|
||||||
options = {
|
|
||||||
:body => body}.merge(opts)
|
|
||||||
|
|
||||||
#resource path
|
|
||||||
path = "/user".sub('{format}','json')
|
|
||||||
|
|
||||||
|
|
||||||
# pull querystring keys from options
|
|
||||||
queryopts = options.select do |key,value|
|
|
||||||
query_param_keys.include? key
|
|
||||||
end
|
|
||||||
|
|
||||||
headers = nil
|
|
||||||
post_body = nil
|
|
||||||
if body != nil
|
|
||||||
if body.is_a?(Array)
|
|
||||||
array = Array.new
|
|
||||||
body.each do |item|
|
|
||||||
if item.respond_to?("to_body".to_sym)
|
|
||||||
array.push item.to_body
|
|
||||||
else
|
|
||||||
array.push item
|
|
||||||
end
|
|
||||||
end
|
|
||||||
post_body = array
|
|
||||||
|
|
||||||
else
|
|
||||||
if body.respond_to?("to_body".to_sym)
|
|
||||||
post_body = body.to_body
|
|
||||||
else
|
|
||||||
post_body = body
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
Swagger::Request.new(:POST, path, {:params=>queryopts,:headers=>headers, :body=>post_body}).make
|
|
||||||
|
|
||||||
|
|
||||||
end
|
|
||||||
|
|
||||||
def self.create_users_with_array_input (body,opts={})
|
|
||||||
query_param_keys = []
|
|
||||||
|
|
||||||
# verify existence of params
|
|
||||||
raise "body is required" if body.nil?
|
|
||||||
# set default values and merge with input
|
|
||||||
options = {
|
|
||||||
:body => body}.merge(opts)
|
|
||||||
|
|
||||||
#resource path
|
|
||||||
path = "/user/createWithArray".sub('{format}','json')
|
|
||||||
|
|
||||||
|
|
||||||
# pull querystring keys from options
|
|
||||||
queryopts = options.select do |key,value|
|
|
||||||
query_param_keys.include? key
|
|
||||||
end
|
|
||||||
|
|
||||||
headers = nil
|
|
||||||
post_body = nil
|
|
||||||
if body != nil
|
|
||||||
if body.is_a?(Array)
|
|
||||||
array = Array.new
|
|
||||||
body.each do |item|
|
|
||||||
if item.respond_to?("to_body".to_sym)
|
|
||||||
array.push item.to_body
|
|
||||||
else
|
|
||||||
array.push item
|
|
||||||
end
|
|
||||||
end
|
|
||||||
post_body = array
|
|
||||||
|
|
||||||
else
|
|
||||||
if body.respond_to?("to_body".to_sym)
|
|
||||||
post_body = body.to_body
|
|
||||||
else
|
|
||||||
post_body = body
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
Swagger::Request.new(:POST, path, {:params=>queryopts,:headers=>headers, :body=>post_body}).make
|
|
||||||
|
|
||||||
|
|
||||||
end
|
|
||||||
|
|
||||||
def self.create_users_with_list_input (body,opts={})
|
|
||||||
query_param_keys = []
|
|
||||||
|
|
||||||
# verify existence of params
|
|
||||||
raise "body is required" if body.nil?
|
|
||||||
# set default values and merge with input
|
|
||||||
options = {
|
|
||||||
:body => body}.merge(opts)
|
|
||||||
|
|
||||||
#resource path
|
|
||||||
path = "/user/createWithList".sub('{format}','json')
|
|
||||||
|
|
||||||
|
|
||||||
# pull querystring keys from options
|
|
||||||
queryopts = options.select do |key,value|
|
|
||||||
query_param_keys.include? key
|
|
||||||
end
|
|
||||||
|
|
||||||
headers = nil
|
|
||||||
post_body = nil
|
|
||||||
if body != nil
|
|
||||||
if body.is_a?(Array)
|
|
||||||
array = Array.new
|
|
||||||
body.each do |item|
|
|
||||||
if item.respond_to?("to_body".to_sym)
|
|
||||||
array.push item.to_body
|
|
||||||
else
|
|
||||||
array.push item
|
|
||||||
end
|
|
||||||
end
|
|
||||||
post_body = array
|
|
||||||
|
|
||||||
else
|
|
||||||
if body.respond_to?("to_body".to_sym)
|
|
||||||
post_body = body.to_body
|
|
||||||
else
|
|
||||||
post_body = body
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
Swagger::Request.new(:POST, path, {:params=>queryopts,:headers=>headers, :body=>post_body}).make
|
|
||||||
|
|
||||||
|
|
||||||
end
|
|
||||||
|
|
||||||
end
|
|
||||||
|
|
@ -215,19 +215,19 @@ class PetApi
|
|||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
def self.getPetById (petId, opts={})
|
def self.getPetById (pet_id, opts={})
|
||||||
query_param_keys = []
|
query_param_keys = []
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# set default values and merge with input
|
# set default values and merge with input
|
||||||
options = {
|
options = {
|
||||||
:'petId' => petId
|
:'pet_id' => pet_id
|
||||||
|
|
||||||
}.merge(opts)
|
}.merge(opts)
|
||||||
|
|
||||||
#resource path
|
#resource path
|
||||||
path = "/pet/{petId}".sub('{format}','json').sub('{' + 'petId' + '}', escapeString(petId))
|
path = "/pet/{petId}".sub('{format}','json').sub('{' + 'petId' + '}', escapeString(pet_id))
|
||||||
|
|
||||||
|
|
||||||
# pull querystring keys from options
|
# pull querystring keys from options
|
||||||
@ -257,21 +257,21 @@ class PetApi
|
|||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
def self.updatePetWithForm (petId,name,status, opts={})
|
def self.updatePetWithForm (pet_id,name,status, opts={})
|
||||||
query_param_keys = []
|
query_param_keys = []
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# set default values and merge with input
|
# set default values and merge with input
|
||||||
options = {
|
options = {
|
||||||
:'petId' => petId,
|
:'pet_id' => pet_id,
|
||||||
:'name' => name,
|
:'name' => name,
|
||||||
:'status' => status
|
:'status' => status
|
||||||
|
|
||||||
}.merge(opts)
|
}.merge(opts)
|
||||||
|
|
||||||
#resource path
|
#resource path
|
||||||
path = "/pet/{petId}".sub('{format}','json').sub('{' + 'petId' + '}', escapeString(petId))
|
path = "/pet/{petId}".sub('{format}','json').sub('{' + 'petId' + '}', escapeString(pet_id))
|
||||||
|
|
||||||
|
|
||||||
# pull querystring keys from options
|
# pull querystring keys from options
|
||||||
@ -302,7 +302,7 @@ class PetApi
|
|||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
def self.deletePet (api_key,petId, opts={})
|
def self.deletePet (api_key,pet_id, opts={})
|
||||||
query_param_keys = []
|
query_param_keys = []
|
||||||
|
|
||||||
|
|
||||||
@ -310,12 +310,12 @@ class PetApi
|
|||||||
# set default values and merge with input
|
# set default values and merge with input
|
||||||
options = {
|
options = {
|
||||||
:'api_key' => api_key,
|
:'api_key' => api_key,
|
||||||
:'petId' => petId
|
:'pet_id' => pet_id
|
||||||
|
|
||||||
}.merge(opts)
|
}.merge(opts)
|
||||||
|
|
||||||
#resource path
|
#resource path
|
||||||
path = "/pet/{petId}".sub('{format}','json').sub('{' + 'petId' + '}', escapeString(petId))
|
path = "/pet/{petId}".sub('{format}','json').sub('{' + 'petId' + '}', escapeString(pet_id))
|
||||||
|
|
||||||
|
|
||||||
# pull querystring keys from options
|
# pull querystring keys from options
|
||||||
@ -344,21 +344,21 @@ class PetApi
|
|||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
def self.uploadFile (petId,additionalMetadata,file, opts={})
|
def self.uploadFile (pet_id,additional_metadata,file, opts={})
|
||||||
query_param_keys = []
|
query_param_keys = []
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# set default values and merge with input
|
# set default values and merge with input
|
||||||
options = {
|
options = {
|
||||||
:'petId' => petId,
|
:'pet_id' => pet_id,
|
||||||
:'additionalMetadata' => additionalMetadata,
|
:'additional_metadata' => additional_metadata,
|
||||||
:'file' => file
|
:'file' => file
|
||||||
|
|
||||||
}.merge(opts)
|
}.merge(opts)
|
||||||
|
|
||||||
#resource path
|
#resource path
|
||||||
path = "/pet/{petId}/uploadImage".sub('{format}','json').sub('{' + 'petId' + '}', escapeString(petId))
|
path = "/pet/{petId}/uploadImage".sub('{format}','json').sub('{' + 'petId' + '}', escapeString(pet_id))
|
||||||
|
|
||||||
|
|
||||||
# pull querystring keys from options
|
# pull querystring keys from options
|
||||||
@ -378,7 +378,7 @@ class PetApi
|
|||||||
# form parameters
|
# form parameters
|
||||||
form_parameter_hash = {}
|
form_parameter_hash = {}
|
||||||
|
|
||||||
form_parameter_hash["additionalMetadata"] = additionalMetadata
|
form_parameter_hash["additionalMetadata"] = additional_metadata
|
||||||
form_parameter_hash["file"] = file
|
form_parameter_hash["file"] = file
|
||||||
|
|
||||||
|
|
@ -112,19 +112,19 @@ class StoreApi
|
|||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
def self.getOrderById (orderId, opts={})
|
def self.getOrderById (order_id, opts={})
|
||||||
query_param_keys = []
|
query_param_keys = []
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# set default values and merge with input
|
# set default values and merge with input
|
||||||
options = {
|
options = {
|
||||||
:'orderId' => orderId
|
:'order_id' => order_id
|
||||||
|
|
||||||
}.merge(opts)
|
}.merge(opts)
|
||||||
|
|
||||||
#resource path
|
#resource path
|
||||||
path = "/store/order/{orderId}".sub('{format}','json').sub('{' + 'orderId' + '}', escapeString(orderId))
|
path = "/store/order/{orderId}".sub('{format}','json').sub('{' + 'orderId' + '}', escapeString(order_id))
|
||||||
|
|
||||||
|
|
||||||
# pull querystring keys from options
|
# pull querystring keys from options
|
||||||
@ -154,19 +154,19 @@ class StoreApi
|
|||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
def self.deleteOrder (orderId, opts={})
|
def self.deleteOrder (order_id, opts={})
|
||||||
query_param_keys = []
|
query_param_keys = []
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# set default values and merge with input
|
# set default values and merge with input
|
||||||
options = {
|
options = {
|
||||||
:'orderId' => orderId
|
:'order_id' => order_id
|
||||||
|
|
||||||
}.merge(opts)
|
}.merge(opts)
|
||||||
|
|
||||||
#resource path
|
#resource path
|
||||||
path = "/store/order/{orderId}".sub('{format}','json').sub('{' + 'orderId' + '}', escapeString(orderId))
|
path = "/store/order/{orderId}".sub('{format}','json').sub('{' + 'orderId' + '}', escapeString(order_id))
|
||||||
|
|
||||||
|
|
||||||
# pull querystring keys from options
|
# pull querystring keys from options
|
@ -1,13 +1,13 @@
|
|||||||
|
|
||||||
class Order
|
class Order
|
||||||
attr_accessor :id, :petId, :quantity, :shipDate, :status, :complete
|
attr_accessor :id, :pet_id, :quantity, :ship_date, :status, :complete
|
||||||
# :internal => :external
|
# :internal => :external
|
||||||
def self.attribute_map
|
def self.attribute_map
|
||||||
{
|
{
|
||||||
:id => :'id',
|
:id => :'id',
|
||||||
:petId => :'petId',
|
:pet_id => :'petId',
|
||||||
:quantity => :'quantity',
|
:quantity => :'quantity',
|
||||||
:shipDate => :'shipDate',
|
:ship_date => :'shipDate',
|
||||||
:status => :'status',
|
:status => :'status',
|
||||||
:complete => :'complete'
|
:complete => :'complete'
|
||||||
|
|
||||||
@ -22,16 +22,16 @@ class Order
|
|||||||
@id = attributes["id"]
|
@id = attributes["id"]
|
||||||
end
|
end
|
||||||
|
|
||||||
if self.class.attribute_map[:"petId"]
|
if self.class.attribute_map[:"pet_id"]
|
||||||
@petId = attributes["petId"]
|
@pet_id = attributes["petId"]
|
||||||
end
|
end
|
||||||
|
|
||||||
if self.class.attribute_map[:"quantity"]
|
if self.class.attribute_map[:"quantity"]
|
||||||
@quantity = attributes["quantity"]
|
@quantity = attributes["quantity"]
|
||||||
end
|
end
|
||||||
|
|
||||||
if self.class.attribute_map[:"shipDate"]
|
if self.class.attribute_map[:"ship_date"]
|
||||||
@shipDate = attributes["shipDate"]
|
@ship_date = attributes["shipDate"]
|
||||||
end
|
end
|
||||||
|
|
||||||
if self.class.attribute_map[:"status"]
|
if self.class.attribute_map[:"status"]
|
@ -1,13 +1,13 @@
|
|||||||
|
|
||||||
class Pet
|
class Pet
|
||||||
attr_accessor :id, :category, :name, :photoUrls, :tags, :status
|
attr_accessor :id, :category, :name, :photo_urls, :tags, :status
|
||||||
# :internal => :external
|
# :internal => :external
|
||||||
def self.attribute_map
|
def self.attribute_map
|
||||||
{
|
{
|
||||||
:id => :'id',
|
:id => :'id',
|
||||||
:category => :'category',
|
:category => :'category',
|
||||||
:name => :'name',
|
:name => :'name',
|
||||||
:photoUrls => :'photoUrls',
|
:photo_urls => :'photoUrls',
|
||||||
:tags => :'tags',
|
:tags => :'tags',
|
||||||
:status => :'status'
|
:status => :'status'
|
||||||
|
|
||||||
@ -30,9 +30,9 @@ class Pet
|
|||||||
@name = attributes["name"]
|
@name = attributes["name"]
|
||||||
end
|
end
|
||||||
|
|
||||||
if self.class.attribute_map[:"photoUrls"]
|
if self.class.attribute_map[:"photo_urls"]
|
||||||
if (value = attributes["photoUrls"]).is_a?(Array)
|
if (value = attributes["photoUrls"]).is_a?(Array)
|
||||||
@photoUrls = value
|
@photo_urls = value
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
@ -1,17 +1,17 @@
|
|||||||
|
|
||||||
class User
|
class User
|
||||||
attr_accessor :id, :username, :firstName, :lastName, :email, :password, :phone, :userStatus
|
attr_accessor :id, :username, :first_name, :last_name, :email, :password, :phone, :user_status
|
||||||
# :internal => :external
|
# :internal => :external
|
||||||
def self.attribute_map
|
def self.attribute_map
|
||||||
{
|
{
|
||||||
:id => :'id',
|
:id => :'id',
|
||||||
:username => :'username',
|
:username => :'username',
|
||||||
:firstName => :'firstName',
|
:first_name => :'firstName',
|
||||||
:lastName => :'lastName',
|
:last_name => :'lastName',
|
||||||
:email => :'email',
|
:email => :'email',
|
||||||
:password => :'password',
|
:password => :'password',
|
||||||
:phone => :'phone',
|
:phone => :'phone',
|
||||||
:userStatus => :'userStatus'
|
:user_status => :'userStatus'
|
||||||
|
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
@ -28,12 +28,12 @@ class User
|
|||||||
@username = attributes["username"]
|
@username = attributes["username"]
|
||||||
end
|
end
|
||||||
|
|
||||||
if self.class.attribute_map[:"firstName"]
|
if self.class.attribute_map[:"first_name"]
|
||||||
@firstName = attributes["firstName"]
|
@first_name = attributes["firstName"]
|
||||||
end
|
end
|
||||||
|
|
||||||
if self.class.attribute_map[:"lastName"]
|
if self.class.attribute_map[:"last_name"]
|
||||||
@lastName = attributes["lastName"]
|
@last_name = attributes["lastName"]
|
||||||
end
|
end
|
||||||
|
|
||||||
if self.class.attribute_map[:"email"]
|
if self.class.attribute_map[:"email"]
|
||||||
@ -48,8 +48,8 @@ class User
|
|||||||
@phone = attributes["phone"]
|
@phone = attributes["phone"]
|
||||||
end
|
end
|
||||||
|
|
||||||
if self.class.attribute_map[:"userStatus"]
|
if self.class.attribute_map[:"user_status"]
|
||||||
@userStatus = attributes["userStatus"]
|
@user_status = attributes["userStatus"]
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
Loading…
x
Reference in New Issue
Block a user