forked from loafle/openapi-generator-original
Migrate all scala generators to use OAS3 (#6407)
* migrate all scala generators to use oas3 * add back pom.xml for scala-sttp * skip form model in scalaz * fix scala lagom tests * add new files * skip form models in scala finch petstore * update samples
This commit is contained in:
@@ -1,32 +0,0 @@
|
|||||||
#!/bin/sh
|
|
||||||
|
|
||||||
SCRIPT="$0"
|
|
||||||
echo "# START SCRIPT: $SCRIPT"
|
|
||||||
|
|
||||||
while [ -h "$SCRIPT" ] ; do
|
|
||||||
ls=`ls -ld "$SCRIPT"`
|
|
||||||
link=`expr "$ls" : '.*-> \(.*\)$'`
|
|
||||||
if expr "$link" : '/.*' > /dev/null; then
|
|
||||||
SCRIPT="$link"
|
|
||||||
else
|
|
||||||
SCRIPT=`dirname "$SCRIPT"`/"$link"
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
|
|
||||||
if [ ! -d "${APP_DIR}" ]; then
|
|
||||||
APP_DIR=`dirname "$SCRIPT"`/..
|
|
||||||
APP_DIR=`cd "${APP_DIR}"; pwd`
|
|
||||||
fi
|
|
||||||
|
|
||||||
executable="./modules/openapi-generator-cli/target/openapi-generator-cli.jar"
|
|
||||||
|
|
||||||
if [ ! -f "$executable" ]
|
|
||||||
then
|
|
||||||
mvn clean package
|
|
||||||
fi
|
|
||||||
|
|
||||||
# if you've executed sbt assembly previously it will use that instead.
|
|
||||||
export JAVA_OPTS="${JAVA_OPTS} -Xmx1024M -DloggerPath=conf/log4j.properties"
|
|
||||||
ags="generate --artifact-id "scala-akka-petstore-client" -t modules/openapi-generator/src/main/resources/scala-akka-client -i modules/openapi-generator/src/test/resources/3_0/scala-akka/petstore.yaml -g scala-akka -o samples/openapi3/client/petstore/scala-akka $@"
|
|
||||||
|
|
||||||
java $JAVA_OPTS -jar $executable $ags
|
|
||||||
@@ -1,32 +0,0 @@
|
|||||||
#!/bin/sh
|
|
||||||
|
|
||||||
SCRIPT="$0"
|
|
||||||
echo "# START SCRIPT: $SCRIPT"
|
|
||||||
|
|
||||||
while [ -h "$SCRIPT" ] ; do
|
|
||||||
ls=`ls -ld "$SCRIPT"`
|
|
||||||
link=`expr "$ls" : '.*-> \(.*\)$'`
|
|
||||||
if expr "$link" : '/.*' > /dev/null; then
|
|
||||||
SCRIPT="$link"
|
|
||||||
else
|
|
||||||
SCRIPT=`dirname "$SCRIPT"`/"$link"
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
|
|
||||||
if [ ! -d "${APP_DIR}" ]; then
|
|
||||||
APP_DIR=`dirname "$SCRIPT"`/..
|
|
||||||
APP_DIR=`cd "${APP_DIR}"; pwd`
|
|
||||||
fi
|
|
||||||
|
|
||||||
executable="./modules/openapi-generator-cli/target/openapi-generator-cli.jar"
|
|
||||||
|
|
||||||
if [ ! -f "$executable" ]
|
|
||||||
then
|
|
||||||
mvn clean package
|
|
||||||
fi
|
|
||||||
|
|
||||||
# if you've executed sbt assembly previously it will use that instead.
|
|
||||||
export JAVA_OPTS="${JAVA_OPTS} -Xmx1024M -DloggerPath=conf/log4j.properties"
|
|
||||||
ags="generate -t modules/openapi-generator/src/main/resources/scala-httpclient -i modules/openapi-generator/src/test/resources/3_0/petstore.yaml -g scala-httpclient-deprecated -o samples/client/petstore/scala-httpclient $@"
|
|
||||||
|
|
||||||
java $JAVA_OPTS -jar $executable $ags
|
|
||||||
@@ -1,32 +0,0 @@
|
|||||||
#!/bin/sh
|
|
||||||
|
|
||||||
SCRIPT="$0"
|
|
||||||
echo "# START SCRIPT: $SCRIPT"
|
|
||||||
|
|
||||||
while [ -h "$SCRIPT" ] ; do
|
|
||||||
ls=`ls -ld "$SCRIPT"`
|
|
||||||
link=`expr "$ls" : '.*-> \(.*\)$'`
|
|
||||||
if expr "$link" : '/.*' > /dev/null; then
|
|
||||||
SCRIPT="$link"
|
|
||||||
else
|
|
||||||
SCRIPT=`dirname "$SCRIPT"`/"$link"
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
|
|
||||||
if [ ! -d "${APP_DIR}" ]; then
|
|
||||||
APP_DIR=`dirname "$SCRIPT"`/..
|
|
||||||
APP_DIR=`cd "${APP_DIR}"; pwd`
|
|
||||||
fi
|
|
||||||
|
|
||||||
executable="./modules/openapi-generator-cli/target/openapi-generator-cli.jar"
|
|
||||||
|
|
||||||
if [ ! -f "$executable" ]
|
|
||||||
then
|
|
||||||
mvn clean package
|
|
||||||
fi
|
|
||||||
|
|
||||||
# if you've executed sbt assembly previously it will use that instead.
|
|
||||||
export JAVA_OPTS="${JAVA_OPTS} -Xmx1024M -DloggerPath=conf/log4j.properties"
|
|
||||||
ags="generate -t modules/openapi-generator/src/main/resources/scalatra -i modules/openapi-generator/src/test/resources/3_0/petstore.yaml -g scalatra -o samples/server/petstore/scalatra $@"
|
|
||||||
|
|
||||||
java $JAVA_OPTS -jar $executable $ags
|
|
||||||
@@ -1,32 +0,0 @@
|
|||||||
#!/bin/sh
|
|
||||||
|
|
||||||
SCRIPT="$0"
|
|
||||||
echo "# START SCRIPT: $SCRIPT"
|
|
||||||
|
|
||||||
while [ -h "$SCRIPT" ] ; do
|
|
||||||
ls=`ls -ld "$SCRIPT"`
|
|
||||||
link=`expr "$ls" : '.*-> \(.*\)$'`
|
|
||||||
if expr "$link" : '/.*' > /dev/null; then
|
|
||||||
SCRIPT="$link"
|
|
||||||
else
|
|
||||||
SCRIPT=`dirname "$SCRIPT"`/"$link"
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
|
|
||||||
if [ ! -d "${APP_DIR}" ]; then
|
|
||||||
APP_DIR=`dirname "$SCRIPT"`/..
|
|
||||||
APP_DIR=`cd "${APP_DIR}"; pwd`
|
|
||||||
fi
|
|
||||||
|
|
||||||
executable="./modules/openapi-generator-cli/target/openapi-generator-cli.jar"
|
|
||||||
|
|
||||||
if [ ! -f "$executable" ]
|
|
||||||
then
|
|
||||||
mvn clean package
|
|
||||||
fi
|
|
||||||
|
|
||||||
# if you've executed sbt assembly previously it will use that instead.
|
|
||||||
export JAVA_OPTS="${JAVA_OPTS} -Xmx1024M -DloggerPath=conf/log4j.properties"
|
|
||||||
ags="generate -t modules/openapi-generator/src/main/resources/scalaz -i modules/openapi-generator/src/test/resources/3_0/petstore.yaml -g scalaz -o samples/client/petstore/scalaz $@"
|
|
||||||
|
|
||||||
java $JAVA_OPTS -jar $executable $ags
|
|
||||||
@@ -26,6 +26,6 @@ fi
|
|||||||
|
|
||||||
# if you've executed sbt assembly previously it will use that instead.
|
# if you've executed sbt assembly previously it will use that instead.
|
||||||
export JAVA_OPTS="${JAVA_OPTS} -Xmx1024M -DloggerPath=conf/log4j.properties"
|
export JAVA_OPTS="${JAVA_OPTS} -Xmx1024M -DloggerPath=conf/log4j.properties"
|
||||||
ags="generate -i modules/openapi-generator/src/test/resources/2_0/petstore.yaml -g scala-akka-http-server -o samples/server/petstore/scala-akka-http-server $@"
|
ags="generate -i modules/openapi-generator/src/test/resources/3_0/petstore.yaml -g scala-akka-http-server -o samples/server/petstore/scala-akka-http-server $@"
|
||||||
|
|
||||||
java ${JAVA_OPTS} -jar ${executable} ${ags}
|
java ${JAVA_OPTS} -jar ${executable} ${ags}
|
||||||
|
|||||||
@@ -22,11 +22,11 @@ executable="./modules/openapi-generator-cli/target/openapi-generator-cli.jar"
|
|||||||
|
|
||||||
if [ ! -f "$executable" ]
|
if [ ! -f "$executable" ]
|
||||||
then
|
then
|
||||||
mvn -B clean package
|
mvn clean package
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# if you've executed sbt assembly previously it will use that instead.
|
# if you've executed sbt assembly previously it will use that instead.
|
||||||
export JAVA_OPTS="${JAVA_OPTS} -Xmx1024M -DloggerPath=conf/log4j.properties"
|
export JAVA_OPTS="${JAVA_OPTS} -Xmx1024M -DloggerPath=conf/log4j.properties"
|
||||||
ags="generate --artifact-id "scala-akka-petstore-client" -t modules/openapi-generator/src/main/resources/scala-akka-client -i modules/openapi-generator/src/test/resources/2_0/petstore.yaml -g scala-akka -o samples/client/petstore/scala-akka $@"
|
ags="generate --artifact-id "scala-akka-petstore-client" -t modules/openapi-generator/src/main/resources/scala-akka-client -i modules/openapi-generator/src/test/resources/3_0/scala-akka/petstore.yaml -g scala-akka -o samples/client/petstore/scala-akka $@"
|
||||||
|
|
||||||
java $JAVA_OPTS -jar $executable $ags
|
java $JAVA_OPTS -jar $executable $ags
|
||||||
|
|||||||
@@ -27,6 +27,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} -Xmx1024M -DloggerPath=conf/log4j.properties"
|
export JAVA_OPTS="${JAVA_OPTS} -Xmx1024M -DloggerPath=conf/log4j.properties"
|
||||||
ags="generate -t modules/openapi-generator/src/main/resources/scala-finch -i modules/openapi-generator/src/test/resources/2_0/petstore.yaml -g scala-finch -o samples/server/petstore/scala-finch $@"
|
ags="generate -t modules/openapi-generator/src/main/resources/scala-finch -i modules/openapi-generator/src/test/resources/3_0/petstore.yaml -g scala-finch -o samples/server/petstore/scala-finch -DskipFormModel=true $@"
|
||||||
|
|
||||||
java $JAVA_OPTS -jar $executable $ags
|
java $JAVA_OPTS -jar $executable $ags
|
||||||
|
|||||||
@@ -27,6 +27,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} -Xmx1024M -DloggerPath=conf/log4j.properties"
|
export JAVA_OPTS="${JAVA_OPTS} -Xmx1024M -DloggerPath=conf/log4j.properties"
|
||||||
ags="generate -t modules/openapi-generator/src/main/resources/scala-gatling -i modules/openapi-generator/src/test/resources/2_0/petstore.yaml -g scala-gatling -o samples/client/petstore/scala-gatling $@"
|
ags="generate -t modules/openapi-generator/src/main/resources/scala-gatling -i modules/openapi-generator/src/test/resources/3_0/petstore.yaml -g scala-gatling -o samples/client/petstore/scala-gatling $@"
|
||||||
|
|
||||||
java $JAVA_OPTS -jar $executable $ags
|
java $JAVA_OPTS -jar $executable $ags
|
||||||
|
|||||||
@@ -22,11 +22,11 @@ executable="./modules/openapi-generator-cli/target/openapi-generator-cli.jar"
|
|||||||
|
|
||||||
if [ ! -f "$executable" ]
|
if [ ! -f "$executable" ]
|
||||||
then
|
then
|
||||||
mvn -B clean package
|
mvn clean package
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# if you've executed sbt assembly previously it will use that instead.
|
# if you've executed sbt assembly previously it will use that instead.
|
||||||
export JAVA_OPTS="${JAVA_OPTS} -Xmx1024M -DloggerPath=conf/log4j.properties"
|
export JAVA_OPTS="${JAVA_OPTS} -Xmx1024M -DloggerPath=conf/log4j.properties"
|
||||||
ags="generate -t modules/openapi-generator/src/main/resources/scala-httpclient -i modules/openapi-generator/src/test/resources/2_0/petstore.yaml -g scala-httpclient-deprecated -o samples/client/petstore/scala-httpclient $@"
|
ags="generate -t modules/openapi-generator/src/main/resources/scala-httpclient -i modules/openapi-generator/src/test/resources/3_0/petstore.yaml -g scala-httpclient-deprecated -o samples/client/petstore/scala-httpclient $@"
|
||||||
|
|
||||||
java $JAVA_OPTS -jar $executable $ags
|
java $JAVA_OPTS -jar $executable $ags
|
||||||
|
|||||||
@@ -27,6 +27,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} -Xmx1024M -DloggerPath=conf/log4j.properties"
|
export JAVA_OPTS="${JAVA_OPTS} -Xmx1024M -DloggerPath=conf/log4j.properties"
|
||||||
ags="generate -t modules/openapi-generator/src/main/resources/scala-lagom-server -i modules/openapi-generator/src/test/resources/2_0/petstore.yaml -g scala-lagom-server -o samples/server/petstore/scala-lagom-server $@"
|
ags="generate -t modules/openapi-generator/src/main/resources/scala-lagom-server -i modules/openapi-generator/src/test/resources/3_0/petstore.yaml -g scala-lagom-server -o samples/server/petstore/scala-lagom-server -DskipFormModel=true $@"
|
||||||
|
|
||||||
java $JAVA_OPTS -jar $executable $ags
|
java $JAVA_OPTS -jar $executable $ags
|
||||||
|
|||||||
@@ -27,6 +27,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} -Xmx1024M -DloggerPath=conf/log4j.properties"
|
export JAVA_OPTS="${JAVA_OPTS} -Xmx1024M -DloggerPath=conf/log4j.properties"
|
||||||
ags="generate -t modules/openapi-generator/src/main/resources/scala-play-server -i modules/openapi-generator/src/test/resources/2_0/petstore.yaml -g scala-play-server -o samples/server/petstore/scala-play-server --additional-properties hideGenerationTimestamp=true $@"
|
ags="generate -t modules/openapi-generator/src/main/resources/scala-play-server -i modules/openapi-generator/src/test/resources/3_0/petstore.yaml -g scala-play-server -o samples/server/petstore/scala-play-server --additional-properties hideGenerationTimestamp=true $@"
|
||||||
|
|
||||||
java $JAVA_OPTS -jar $executable $ags
|
java $JAVA_OPTS -jar $executable $ags
|
||||||
|
|||||||
@@ -27,6 +27,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} -Xmx1024M -DloggerPath=conf/log4j.properties"
|
export JAVA_OPTS="${JAVA_OPTS} -Xmx1024M -DloggerPath=conf/log4j.properties"
|
||||||
ags="generate --artifact-id 'scala-sttp-petstore' -t modules/openapi-generator/src/main/resources/scala-sttp -i modules/openapi-generator/src/test/resources/3_0/petstore.yaml -g scala-sttp -o samples/openapi3/client/petstore/scala-sttp $@"
|
ags="generate --artifact-id 'scala-sttp-petstore' -t modules/openapi-generator/src/main/resources/scala-sttp -i modules/openapi-generator/src/test/resources/3_0/petstore.yaml -g scala-sttp -o samples/client/petstore/scala-sttp $@"
|
||||||
|
|
||||||
java $JAVA_OPTS -jar $executable $ags
|
java $JAVA_OPTS -jar $executable $ags
|
||||||
@@ -22,11 +22,11 @@ executable="./modules/openapi-generator-cli/target/openapi-generator-cli.jar"
|
|||||||
|
|
||||||
if [ ! -f "$executable" ]
|
if [ ! -f "$executable" ]
|
||||||
then
|
then
|
||||||
mvn -B clean package
|
mvn clean package
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# if you've executed sbt assembly previously it will use that instead.
|
# if you've executed sbt assembly previously it will use that instead.
|
||||||
export JAVA_OPTS="${JAVA_OPTS} -Xmx1024M -DloggerPath=conf/log4j.properties"
|
export JAVA_OPTS="${JAVA_OPTS} -Xmx1024M -DloggerPath=conf/log4j.properties"
|
||||||
ags="generate -t modules/openapi-generator/src/main/resources/scalatra -i modules/openapi-generator/src/test/resources/2_0/petstore.yaml -g scalatra -o samples/server/petstore/scalatra $@"
|
ags="generate -t modules/openapi-generator/src/main/resources/scalatra -i modules/openapi-generator/src/test/resources/3_0/petstore.yaml -g scalatra -o samples/server/petstore/scalatra $@"
|
||||||
|
|
||||||
java $JAVA_OPTS -jar $executable $ags
|
java $JAVA_OPTS -jar $executable $ags
|
||||||
|
|||||||
@@ -22,11 +22,11 @@ executable="./modules/openapi-generator-cli/target/openapi-generator-cli.jar"
|
|||||||
|
|
||||||
if [ ! -f "$executable" ]
|
if [ ! -f "$executable" ]
|
||||||
then
|
then
|
||||||
mvn -B clean package
|
mvn clean package
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# if you've executed sbt assembly previously it will use that instead.
|
# if you've executed sbt assembly previously it will use that instead.
|
||||||
export JAVA_OPTS="${JAVA_OPTS} -Xmx1024M -DloggerPath=conf/log4j.properties"
|
export JAVA_OPTS="${JAVA_OPTS} -Xmx1024M -DloggerPath=conf/log4j.properties"
|
||||||
ags="generate -t modules/openapi-generator/src/main/resources/scalaz -i modules/openapi-generator/src/test/resources/2_0/petstore.yaml -g scalaz -o samples/client/petstore/scalaz $@"
|
ags="generate -t modules/openapi-generator/src/main/resources/scalaz -i modules/openapi-generator/src/test/resources/3_0/petstore.yaml -g scalaz -o samples/client/petstore/scalaz -DskipFormModel=true $@"
|
||||||
|
|
||||||
java $JAVA_OPTS -jar $executable $ags
|
java $JAVA_OPTS -jar $executable $ags
|
||||||
|
|||||||
@@ -84,8 +84,7 @@ declare -a samples=(
|
|||||||
"${root}/bin/cpp-qt5-qhttpengine-server-petstore.sh"
|
"${root}/bin/cpp-qt5-qhttpengine-server-petstore.sh"
|
||||||
#"${root}/bin/openapi3/powershell-experimental-petstore.sh"
|
#"${root}/bin/openapi3/powershell-experimental-petstore.sh"
|
||||||
"${root}/bin/scala-akka-petstore.sh"
|
"${root}/bin/scala-akka-petstore.sh"
|
||||||
"${root}/bin/openapi3/scala-akka-petstore.sh"
|
"${root}/bin/scala-sttp-petstore.sh"
|
||||||
"${root}/bin/openapi3/scala-sttp-petstore.sh"
|
|
||||||
"${root}/bin/lua-petstore.sh"
|
"${root}/bin/lua-petstore.sh"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
6
pom.xml
6
pom.xml
@@ -1293,8 +1293,8 @@
|
|||||||
<module>samples/openapi3/client/petstore/go-experimental</module>
|
<module>samples/openapi3/client/petstore/go-experimental</module>
|
||||||
<module>samples/openapi3/client/petstore/go</module>
|
<module>samples/openapi3/client/petstore/go</module>
|
||||||
<!-- test java-related projects -->
|
<!-- test java-related projects -->
|
||||||
<module>samples/openapi3/client/petstore/scala-akka</module>
|
<module>samples/client/petstore/scala-akka</module>
|
||||||
<module>samples/openapi3/client/petstore/scala-sttp</module>
|
<module>samples/client/petstore/scala-sttp</module>
|
||||||
<module>samples/client/petstore/scala-httpclient</module>
|
<module>samples/client/petstore/scala-httpclient</module>
|
||||||
<module>samples/client/petstore/scalaz</module>
|
<module>samples/client/petstore/scalaz</module>
|
||||||
<module>samples/client/petstore/clojure</module>
|
<module>samples/client/petstore/clojure</module>
|
||||||
@@ -1387,10 +1387,10 @@
|
|||||||
<!-- clients -->
|
<!-- clients -->
|
||||||
<module>samples/client/petstore/ruby</module>
|
<module>samples/client/petstore/ruby</module>
|
||||||
<!-- test java-related projects -->
|
<!-- test java-related projects -->
|
||||||
<module>samples/openapi3/client/petstore/scala-akka</module>
|
|
||||||
<module>samples/client/petstore/dart2/petstore</module>
|
<module>samples/client/petstore/dart2/petstore</module>
|
||||||
<module>samples/client/petstore/dart-jaguar/openapi</module>
|
<module>samples/client/petstore/dart-jaguar/openapi</module>
|
||||||
<module>samples/client/petstore/dart-jaguar/flutter_petstore/openapi</module>
|
<module>samples/client/petstore/dart-jaguar/flutter_petstore/openapi</module>
|
||||||
|
<module>samples/client/petstore/scala-akka</module>
|
||||||
<module>samples/client/petstore/scala-httpclient</module>
|
<module>samples/client/petstore/scala-httpclient</module>
|
||||||
<module>samples/client/petstore/java/feign</module>
|
<module>samples/client/petstore/java/feign</module>
|
||||||
<module>samples/client/petstore/java/jersey1</module>
|
<module>samples/client/petstore/java/jersey1</module>
|
||||||
|
|||||||
@@ -13,6 +13,8 @@ src/main/scala/org/openapitools/client/core/Serializers.scala
|
|||||||
src/main/scala/org/openapitools/client/core/requests.scala
|
src/main/scala/org/openapitools/client/core/requests.scala
|
||||||
src/main/scala/org/openapitools/client/model/ApiResponse.scala
|
src/main/scala/org/openapitools/client/model/ApiResponse.scala
|
||||||
src/main/scala/org/openapitools/client/model/Category.scala
|
src/main/scala/org/openapitools/client/model/Category.scala
|
||||||
|
src/main/scala/org/openapitools/client/model/InlineObject.scala
|
||||||
|
src/main/scala/org/openapitools/client/model/InlineObject1.scala
|
||||||
src/main/scala/org/openapitools/client/model/Order.scala
|
src/main/scala/org/openapitools/client/model/Order.scala
|
||||||
src/main/scala/org/openapitools/client/model/Pet.scala
|
src/main/scala/org/openapitools/client/model/Pet.scala
|
||||||
src/main/scala/org/openapitools/client/model/Tag.scala
|
src/main/scala/org/openapitools/client/model/Tag.scala
|
||||||
|
|||||||
@@ -91,6 +91,8 @@ Class | Method | HTTP request | Description
|
|||||||
|
|
||||||
- [ApiResponse](ApiResponse.md)
|
- [ApiResponse](ApiResponse.md)
|
||||||
- [Category](Category.md)
|
- [Category](Category.md)
|
||||||
|
- [InlineObject](InlineObject.md)
|
||||||
|
- [InlineObject1](InlineObject1.md)
|
||||||
- [Order](Order.md)
|
- [Order](Order.md)
|
||||||
- [Pet](Pet.md)
|
- [Pet](Pet.md)
|
||||||
- [Tag](Tag.md)
|
- [Tag](Tag.md)
|
||||||
@@ -106,6 +108,12 @@ Authentication schemes defined for the API:
|
|||||||
- **API key parameter name**: api_key
|
- **API key parameter name**: api_key
|
||||||
- **Location**: HTTP header
|
- **Location**: HTTP header
|
||||||
|
|
||||||
|
### auth_cookie
|
||||||
|
|
||||||
|
- **Type**: API key
|
||||||
|
- **API key parameter name**: AUTH_KEY
|
||||||
|
- **Location**:
|
||||||
|
|
||||||
|
|
||||||
## Author
|
## Author
|
||||||
|
|
||||||
|
|||||||
@@ -1 +0,0 @@
|
|||||||
sbt.version=1.3.6
|
|
||||||
@@ -27,13 +27,15 @@ class PetApi(baseUrl: String) {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Expected answers:
|
* Expected answers:
|
||||||
|
* code 200 : Pet (successful operation)
|
||||||
* code 405 : (Invalid input)
|
* code 405 : (Invalid input)
|
||||||
*
|
*
|
||||||
* @param body Pet object that needs to be added to the store
|
* @param pet Pet object that needs to be added to the store
|
||||||
*/
|
*/
|
||||||
def addPet(body: Pet): ApiRequest[Unit] =
|
def addPet(pet: Pet): ApiRequest[Pet] =
|
||||||
ApiRequest[Unit](ApiMethods.POST, baseUrl, "/pet", "application/json")
|
ApiRequest[Pet](ApiMethods.POST, baseUrl, "/pet", "application/json")
|
||||||
.withBody(body)
|
.withBody(pet)
|
||||||
|
.withSuccessResponse[Pet](200)
|
||||||
.withErrorResponse[Unit](405)
|
.withErrorResponse[Unit](405)
|
||||||
|
|
||||||
|
|
||||||
@@ -107,15 +109,17 @@ class PetApi(baseUrl: String) {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Expected answers:
|
* Expected answers:
|
||||||
|
* code 200 : Pet (successful operation)
|
||||||
* code 400 : (Invalid ID supplied)
|
* code 400 : (Invalid ID supplied)
|
||||||
* code 404 : (Pet not found)
|
* code 404 : (Pet not found)
|
||||||
* code 405 : (Validation exception)
|
* code 405 : (Validation exception)
|
||||||
*
|
*
|
||||||
* @param body Pet object that needs to be added to the store
|
* @param pet Pet object that needs to be added to the store
|
||||||
*/
|
*/
|
||||||
def updatePet(body: Pet): ApiRequest[Unit] =
|
def updatePet(pet: Pet): ApiRequest[Pet] =
|
||||||
ApiRequest[Unit](ApiMethods.PUT, baseUrl, "/pet", "application/json")
|
ApiRequest[Pet](ApiMethods.PUT, baseUrl, "/pet", "application/json")
|
||||||
.withBody(body)
|
.withBody(pet)
|
||||||
|
.withSuccessResponse[Pet](200)
|
||||||
.withErrorResponse[Unit](400)
|
.withErrorResponse[Unit](400)
|
||||||
.withErrorResponse[Unit](404)
|
.withErrorResponse[Unit](404)
|
||||||
.withErrorResponse[Unit](405)
|
.withErrorResponse[Unit](405)
|
||||||
@@ -123,6 +127,7 @@ class PetApi(baseUrl: String) {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Expected answers:
|
* Expected answers:
|
||||||
|
* code 200 : (successful operation)
|
||||||
* code 405 : (Invalid input)
|
* code 405 : (Invalid input)
|
||||||
*
|
*
|
||||||
* @param petId ID of pet that needs to be updated
|
* @param petId ID of pet that needs to be updated
|
||||||
@@ -134,6 +139,7 @@ class PetApi(baseUrl: String) {
|
|||||||
.withFormParam("name", name)
|
.withFormParam("name", name)
|
||||||
.withFormParam("status", status)
|
.withFormParam("status", status)
|
||||||
.withPathParam("petId", petId)
|
.withPathParam("petId", petId)
|
||||||
|
.withSuccessResponse[Unit](200)
|
||||||
.withErrorResponse[Unit](405)
|
.withErrorResponse[Unit](405)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -77,11 +77,11 @@ class StoreApi(baseUrl: String) {
|
|||||||
* code 200 : Order (successful operation)
|
* code 200 : Order (successful operation)
|
||||||
* code 400 : (Invalid Order)
|
* code 400 : (Invalid Order)
|
||||||
*
|
*
|
||||||
* @param body order placed for purchasing the pet
|
* @param order order placed for purchasing the pet
|
||||||
*/
|
*/
|
||||||
def placeOrder(body: Order): ApiRequest[Order] =
|
def placeOrder(order: Order): ApiRequest[Order] =
|
||||||
ApiRequest[Order](ApiMethods.POST, baseUrl, "/store/order", "application/json")
|
ApiRequest[Order](ApiMethods.POST, baseUrl, "/store/order", "application/json")
|
||||||
.withBody(body)
|
.withBody(order)
|
||||||
.withSuccessResponse[Order](200)
|
.withSuccessResponse[Order](200)
|
||||||
.withErrorResponse[Unit](400)
|
.withErrorResponse[Unit](400)
|
||||||
|
|
||||||
|
|||||||
@@ -29,11 +29,15 @@ class UserApi(baseUrl: String) {
|
|||||||
* Expected answers:
|
* Expected answers:
|
||||||
* code 0 : (successful operation)
|
* code 0 : (successful operation)
|
||||||
*
|
*
|
||||||
* @param body Created user object
|
* Available security schemes:
|
||||||
|
* auth_cookie (apiKey)
|
||||||
|
*
|
||||||
|
* @param user Created user object
|
||||||
*/
|
*/
|
||||||
def createUser(body: User): ApiRequest[Unit] =
|
def createUser(user: User)(implicit apiKey: ApiKeyValue): ApiRequest[Unit] =
|
||||||
ApiRequest[Unit](ApiMethods.POST, baseUrl, "/user", "application/json")
|
ApiRequest[Unit](ApiMethods.POST, baseUrl, "/user", "application/json")
|
||||||
.withBody(body)
|
.withApiKey(apiKey, "AUTH_KEY", COOKIE)
|
||||||
|
.withBody(user)
|
||||||
.withDefaultSuccessResponse[Unit]
|
.withDefaultSuccessResponse[Unit]
|
||||||
|
|
||||||
|
|
||||||
@@ -41,11 +45,15 @@ class UserApi(baseUrl: String) {
|
|||||||
* Expected answers:
|
* Expected answers:
|
||||||
* code 0 : (successful operation)
|
* code 0 : (successful operation)
|
||||||
*
|
*
|
||||||
* @param body List of user object
|
* Available security schemes:
|
||||||
|
* auth_cookie (apiKey)
|
||||||
|
*
|
||||||
|
* @param user List of user object
|
||||||
*/
|
*/
|
||||||
def createUsersWithArrayInput(body: Seq[User]): ApiRequest[Unit] =
|
def createUsersWithArrayInput(user: Seq[User])(implicit apiKey: ApiKeyValue): ApiRequest[Unit] =
|
||||||
ApiRequest[Unit](ApiMethods.POST, baseUrl, "/user/createWithArray", "application/json")
|
ApiRequest[Unit](ApiMethods.POST, baseUrl, "/user/createWithArray", "application/json")
|
||||||
.withBody(body)
|
.withApiKey(apiKey, "AUTH_KEY", COOKIE)
|
||||||
|
.withBody(user)
|
||||||
.withDefaultSuccessResponse[Unit]
|
.withDefaultSuccessResponse[Unit]
|
||||||
|
|
||||||
|
|
||||||
@@ -53,11 +61,15 @@ class UserApi(baseUrl: String) {
|
|||||||
* Expected answers:
|
* Expected answers:
|
||||||
* code 0 : (successful operation)
|
* code 0 : (successful operation)
|
||||||
*
|
*
|
||||||
* @param body List of user object
|
* Available security schemes:
|
||||||
|
* auth_cookie (apiKey)
|
||||||
|
*
|
||||||
|
* @param user List of user object
|
||||||
*/
|
*/
|
||||||
def createUsersWithListInput(body: Seq[User]): ApiRequest[Unit] =
|
def createUsersWithListInput(user: Seq[User])(implicit apiKey: ApiKeyValue): ApiRequest[Unit] =
|
||||||
ApiRequest[Unit](ApiMethods.POST, baseUrl, "/user/createWithList", "application/json")
|
ApiRequest[Unit](ApiMethods.POST, baseUrl, "/user/createWithList", "application/json")
|
||||||
.withBody(body)
|
.withApiKey(apiKey, "AUTH_KEY", COOKIE)
|
||||||
|
.withBody(user)
|
||||||
.withDefaultSuccessResponse[Unit]
|
.withDefaultSuccessResponse[Unit]
|
||||||
|
|
||||||
|
|
||||||
@@ -68,10 +80,14 @@ class UserApi(baseUrl: String) {
|
|||||||
* code 400 : (Invalid username supplied)
|
* code 400 : (Invalid username supplied)
|
||||||
* code 404 : (User not found)
|
* code 404 : (User not found)
|
||||||
*
|
*
|
||||||
|
* Available security schemes:
|
||||||
|
* auth_cookie (apiKey)
|
||||||
|
*
|
||||||
* @param username The name that needs to be deleted
|
* @param username The name that needs to be deleted
|
||||||
*/
|
*/
|
||||||
def deleteUser(username: String): ApiRequest[Unit] =
|
def deleteUser(username: String)(implicit apiKey: ApiKeyValue): ApiRequest[Unit] =
|
||||||
ApiRequest[Unit](ApiMethods.DELETE, baseUrl, "/user/{username}", "application/json")
|
ApiRequest[Unit](ApiMethods.DELETE, baseUrl, "/user/{username}", "application/json")
|
||||||
|
.withApiKey(apiKey, "AUTH_KEY", COOKIE)
|
||||||
.withPathParam("username", username)
|
.withPathParam("username", username)
|
||||||
.withErrorResponse[Unit](400)
|
.withErrorResponse[Unit](400)
|
||||||
.withErrorResponse[Unit](404)
|
.withErrorResponse[Unit](404)
|
||||||
@@ -97,6 +113,7 @@ class UserApi(baseUrl: String) {
|
|||||||
* Expected answers:
|
* Expected answers:
|
||||||
* code 200 : String (successful operation)
|
* code 200 : String (successful operation)
|
||||||
* Headers :
|
* Headers :
|
||||||
|
* Set-Cookie - Cookie authentication key for use with the `auth_cookie` apiKey authentication.
|
||||||
* X-Rate-Limit - calls per hour allowed by the user
|
* X-Rate-Limit - calls per hour allowed by the user
|
||||||
* X-Expires-After - date in UTC when toekn expires
|
* X-Expires-After - date in UTC when toekn expires
|
||||||
* code 400 : (Invalid username/password supplied)
|
* code 400 : (Invalid username/password supplied)
|
||||||
@@ -112,6 +129,7 @@ class UserApi(baseUrl: String) {
|
|||||||
.withErrorResponse[Unit](400)
|
.withErrorResponse[Unit](400)
|
||||||
|
|
||||||
object LoginUserHeaders {
|
object LoginUserHeaders {
|
||||||
|
def setCookie(r: ApiReturnWithHeaders) = r.getStringHeader("Set-Cookie")
|
||||||
def xRateLimit(r: ApiReturnWithHeaders) = r.getIntHeader("X-Rate-Limit")
|
def xRateLimit(r: ApiReturnWithHeaders) = r.getIntHeader("X-Rate-Limit")
|
||||||
def xExpiresAfter(r: ApiReturnWithHeaders) = r.getOffsetDateTimeHeader("X-Expires-After")
|
def xExpiresAfter(r: ApiReturnWithHeaders) = r.getOffsetDateTimeHeader("X-Expires-After")
|
||||||
}
|
}
|
||||||
@@ -119,9 +137,13 @@ class UserApi(baseUrl: String) {
|
|||||||
/**
|
/**
|
||||||
* Expected answers:
|
* Expected answers:
|
||||||
* code 0 : (successful operation)
|
* code 0 : (successful operation)
|
||||||
|
*
|
||||||
|
* Available security schemes:
|
||||||
|
* auth_cookie (apiKey)
|
||||||
*/
|
*/
|
||||||
def logoutUser(): ApiRequest[Unit] =
|
def logoutUser()(implicit apiKey: ApiKeyValue): ApiRequest[Unit] =
|
||||||
ApiRequest[Unit](ApiMethods.GET, baseUrl, "/user/logout", "application/json")
|
ApiRequest[Unit](ApiMethods.GET, baseUrl, "/user/logout", "application/json")
|
||||||
|
.withApiKey(apiKey, "AUTH_KEY", COOKIE)
|
||||||
.withDefaultSuccessResponse[Unit]
|
.withDefaultSuccessResponse[Unit]
|
||||||
|
|
||||||
|
|
||||||
@@ -132,12 +154,16 @@ class UserApi(baseUrl: String) {
|
|||||||
* code 400 : (Invalid user supplied)
|
* code 400 : (Invalid user supplied)
|
||||||
* code 404 : (User not found)
|
* code 404 : (User not found)
|
||||||
*
|
*
|
||||||
|
* Available security schemes:
|
||||||
|
* auth_cookie (apiKey)
|
||||||
|
*
|
||||||
* @param username name that need to be deleted
|
* @param username name that need to be deleted
|
||||||
* @param body Updated user object
|
* @param user Updated user object
|
||||||
*/
|
*/
|
||||||
def updateUser(username: String, body: User): ApiRequest[Unit] =
|
def updateUser(username: String, user: User)(implicit apiKey: ApiKeyValue): ApiRequest[Unit] =
|
||||||
ApiRequest[Unit](ApiMethods.PUT, baseUrl, "/user/{username}", "application/json")
|
ApiRequest[Unit](ApiMethods.PUT, baseUrl, "/user/{username}", "application/json")
|
||||||
.withBody(body)
|
.withApiKey(apiKey, "AUTH_KEY", COOKIE)
|
||||||
|
.withBody(user)
|
||||||
.withPathParam("username", username)
|
.withPathParam("username", username)
|
||||||
.withErrorResponse[Unit](400)
|
.withErrorResponse[Unit](400)
|
||||||
.withErrorResponse[Unit](404)
|
.withErrorResponse[Unit](404)
|
||||||
|
|||||||
@@ -1 +1 @@
|
|||||||
4.3.0-SNAPSHOT
|
5.0.0-SNAPSHOT
|
||||||
@@ -0,0 +1,18 @@
|
|||||||
|
|
||||||
|
package org.openapitools.client.model
|
||||||
|
|
||||||
|
|
||||||
|
case class InlineObject (
|
||||||
|
/* Updated name of the pet */
|
||||||
|
_name: Option[String],
|
||||||
|
/* Updated status of the pet */
|
||||||
|
_status: Option[String]
|
||||||
|
)
|
||||||
|
object InlineObject {
|
||||||
|
def toStringBody(var_name: Object, var_status: Object) =
|
||||||
|
s"""
|
||||||
|
| {
|
||||||
|
| "name":$var_name,"status":$var_status
|
||||||
|
| }
|
||||||
|
""".stripMargin
|
||||||
|
}
|
||||||
@@ -0,0 +1,19 @@
|
|||||||
|
|
||||||
|
package org.openapitools.client.model
|
||||||
|
|
||||||
|
import java.io.File
|
||||||
|
|
||||||
|
case class InlineObject1 (
|
||||||
|
/* Additional data to pass to server */
|
||||||
|
_additionalMetadata: Option[String],
|
||||||
|
/* file to upload */
|
||||||
|
_file: Option[File]
|
||||||
|
)
|
||||||
|
object InlineObject1 {
|
||||||
|
def toStringBody(var_additionalMetadata: Object, var_file: Object) =
|
||||||
|
s"""
|
||||||
|
| {
|
||||||
|
| "additionalMetadata":$var_additionalMetadata,"file":$var_file
|
||||||
|
| }
|
||||||
|
""".stripMargin
|
||||||
|
}
|
||||||
@@ -1 +1 @@
|
|||||||
4.3.0-SNAPSHOT
|
5.0.0-SNAPSHOT
|
||||||
@@ -80,11 +80,11 @@ class PetApi(
|
|||||||
* Add a new pet to the store
|
* Add a new pet to the store
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
* @param body Pet object that needs to be added to the store
|
* @param pet Pet object that needs to be added to the store
|
||||||
* @return void
|
* @return Pet
|
||||||
*/
|
*/
|
||||||
def addPet(body: Pet) = {
|
def addPet(pet: Pet): Option[Pet] = {
|
||||||
val await = Try(Await.result(addPetAsync(body), Duration.Inf))
|
val await = Try(Await.result(addPetAsync(pet), Duration.Inf))
|
||||||
await match {
|
await match {
|
||||||
case Success(i) => Some(await.get)
|
case Success(i) => Some(await.get)
|
||||||
case Failure(t) => None
|
case Failure(t) => None
|
||||||
@@ -95,11 +95,11 @@ class PetApi(
|
|||||||
* Add a new pet to the store asynchronously
|
* Add a new pet to the store asynchronously
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
* @param body Pet object that needs to be added to the store
|
* @param pet Pet object that needs to be added to the store
|
||||||
* @return Future(void)
|
* @return Future(Pet)
|
||||||
*/
|
*/
|
||||||
def addPetAsync(body: Pet) = {
|
def addPetAsync(pet: Pet): Future[Pet] = {
|
||||||
helper.addPet(body)
|
helper.addPet(pet)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -212,11 +212,11 @@ class PetApi(
|
|||||||
* Update an existing pet
|
* Update an existing pet
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
* @param body Pet object that needs to be added to the store
|
* @param pet Pet object that needs to be added to the store
|
||||||
* @return void
|
* @return Pet
|
||||||
*/
|
*/
|
||||||
def updatePet(body: Pet) = {
|
def updatePet(pet: Pet): Option[Pet] = {
|
||||||
val await = Try(Await.result(updatePetAsync(body), Duration.Inf))
|
val await = Try(Await.result(updatePetAsync(pet), Duration.Inf))
|
||||||
await match {
|
await match {
|
||||||
case Success(i) => Some(await.get)
|
case Success(i) => Some(await.get)
|
||||||
case Failure(t) => None
|
case Failure(t) => None
|
||||||
@@ -227,11 +227,11 @@ class PetApi(
|
|||||||
* Update an existing pet asynchronously
|
* Update an existing pet asynchronously
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
* @param body Pet object that needs to be added to the store
|
* @param pet Pet object that needs to be added to the store
|
||||||
* @return Future(void)
|
* @return Future(Pet)
|
||||||
*/
|
*/
|
||||||
def updatePetAsync(body: Pet) = {
|
def updatePetAsync(pet: Pet): Future[Pet] = {
|
||||||
helper.updatePet(body)
|
helper.updatePet(pet)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -298,7 +298,7 @@ class PetApi(
|
|||||||
|
|
||||||
class PetApiAsyncHelper(client: TransportClient, config: SwaggerConfig) extends ApiClient(client, config) {
|
class PetApiAsyncHelper(client: TransportClient, config: SwaggerConfig) extends ApiClient(client, config) {
|
||||||
|
|
||||||
def addPet(body: Pet)(implicit reader: ClientResponseReader[Unit], writer: RequestWriter[Pet]): Future[Unit] = {
|
def addPet(pet: Pet)(implicit reader: ClientResponseReader[Pet], writer: RequestWriter[Pet]): Future[Pet] = {
|
||||||
// create path and map variables
|
// create path and map variables
|
||||||
val path = (addFmt("/pet"))
|
val path = (addFmt("/pet"))
|
||||||
|
|
||||||
@@ -306,9 +306,9 @@ class PetApiAsyncHelper(client: TransportClient, config: SwaggerConfig) extends
|
|||||||
val queryParams = new mutable.HashMap[String, String]
|
val queryParams = new mutable.HashMap[String, String]
|
||||||
val headerParams = new mutable.HashMap[String, String]
|
val headerParams = new mutable.HashMap[String, String]
|
||||||
|
|
||||||
if (body == null) throw new Exception("Missing required parameter 'body' when calling PetApi->addPet")
|
if (pet == null) throw new Exception("Missing required parameter 'pet' when calling PetApi->addPet")
|
||||||
|
|
||||||
val resFuture = client.submit("POST", path, queryParams.toMap, headerParams.toMap, writer.write(body))
|
val resFuture = client.submit("POST", path, queryParams.toMap, headerParams.toMap, writer.write(pet))
|
||||||
resFuture flatMap { resp =>
|
resFuture flatMap { resp =>
|
||||||
val status = Response.Status.fromStatusCode(resp.statusCode)
|
val status = Response.Status.fromStatusCode(resp.statusCode)
|
||||||
status.getFamily match {
|
status.getFamily match {
|
||||||
@@ -406,7 +406,7 @@ class PetApiAsyncHelper(client: TransportClient, config: SwaggerConfig) extends
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
def updatePet(body: Pet)(implicit reader: ClientResponseReader[Unit], writer: RequestWriter[Pet]): Future[Unit] = {
|
def updatePet(pet: Pet)(implicit reader: ClientResponseReader[Pet], writer: RequestWriter[Pet]): Future[Pet] = {
|
||||||
// create path and map variables
|
// create path and map variables
|
||||||
val path = (addFmt("/pet"))
|
val path = (addFmt("/pet"))
|
||||||
|
|
||||||
@@ -414,9 +414,9 @@ class PetApiAsyncHelper(client: TransportClient, config: SwaggerConfig) extends
|
|||||||
val queryParams = new mutable.HashMap[String, String]
|
val queryParams = new mutable.HashMap[String, String]
|
||||||
val headerParams = new mutable.HashMap[String, String]
|
val headerParams = new mutable.HashMap[String, String]
|
||||||
|
|
||||||
if (body == null) throw new Exception("Missing required parameter 'body' when calling PetApi->updatePet")
|
if (pet == null) throw new Exception("Missing required parameter 'pet' when calling PetApi->updatePet")
|
||||||
|
|
||||||
val resFuture = client.submit("PUT", path, queryParams.toMap, headerParams.toMap, writer.write(body))
|
val resFuture = client.submit("PUT", path, queryParams.toMap, headerParams.toMap, writer.write(pet))
|
||||||
resFuture flatMap { resp =>
|
resFuture flatMap { resp =>
|
||||||
val status = Response.Status.fromStatusCode(resp.statusCode)
|
val status = Response.Status.fromStatusCode(resp.statusCode)
|
||||||
status.getFamily match {
|
status.getFamily match {
|
||||||
|
|||||||
@@ -154,11 +154,11 @@ class StoreApi(
|
|||||||
* Place an order for a pet
|
* Place an order for a pet
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
* @param body order placed for purchasing the pet
|
* @param order order placed for purchasing the pet
|
||||||
* @return Order
|
* @return Order
|
||||||
*/
|
*/
|
||||||
def placeOrder(body: Order): Option[Order] = {
|
def placeOrder(order: Order): Option[Order] = {
|
||||||
val await = Try(Await.result(placeOrderAsync(body), Duration.Inf))
|
val await = Try(Await.result(placeOrderAsync(order), Duration.Inf))
|
||||||
await match {
|
await match {
|
||||||
case Success(i) => Some(await.get)
|
case Success(i) => Some(await.get)
|
||||||
case Failure(t) => None
|
case Failure(t) => None
|
||||||
@@ -169,11 +169,11 @@ class StoreApi(
|
|||||||
* Place an order for a pet asynchronously
|
* Place an order for a pet asynchronously
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
* @param body order placed for purchasing the pet
|
* @param order order placed for purchasing the pet
|
||||||
* @return Future(Order)
|
* @return Future(Order)
|
||||||
*/
|
*/
|
||||||
def placeOrderAsync(body: Order): Future[Order] = {
|
def placeOrderAsync(order: Order): Future[Order] = {
|
||||||
helper.placeOrder(body)
|
helper.placeOrder(order)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -241,7 +241,7 @@ class StoreApiAsyncHelper(client: TransportClient, config: SwaggerConfig) extend
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
def placeOrder(body: Order)(implicit reader: ClientResponseReader[Order], writer: RequestWriter[Order]): Future[Order] = {
|
def placeOrder(order: Order)(implicit reader: ClientResponseReader[Order], writer: RequestWriter[Order]): Future[Order] = {
|
||||||
// create path and map variables
|
// create path and map variables
|
||||||
val path = (addFmt("/store/order"))
|
val path = (addFmt("/store/order"))
|
||||||
|
|
||||||
@@ -249,9 +249,9 @@ class StoreApiAsyncHelper(client: TransportClient, config: SwaggerConfig) extend
|
|||||||
val queryParams = new mutable.HashMap[String, String]
|
val queryParams = new mutable.HashMap[String, String]
|
||||||
val headerParams = new mutable.HashMap[String, String]
|
val headerParams = new mutable.HashMap[String, String]
|
||||||
|
|
||||||
if (body == null) throw new Exception("Missing required parameter 'body' when calling StoreApi->placeOrder")
|
if (order == null) throw new Exception("Missing required parameter 'order' when calling StoreApi->placeOrder")
|
||||||
|
|
||||||
val resFuture = client.submit("POST", path, queryParams.toMap, headerParams.toMap, writer.write(body))
|
val resFuture = client.submit("POST", path, queryParams.toMap, headerParams.toMap, writer.write(order))
|
||||||
resFuture flatMap { resp =>
|
resFuture flatMap { resp =>
|
||||||
val status = Response.Status.fromStatusCode(resp.statusCode)
|
val status = Response.Status.fromStatusCode(resp.statusCode)
|
||||||
status.getFamily match {
|
status.getFamily match {
|
||||||
|
|||||||
@@ -78,11 +78,11 @@ class UserApi(
|
|||||||
* Create user
|
* Create user
|
||||||
* This can only be done by the logged in user.
|
* This can only be done by the logged in user.
|
||||||
*
|
*
|
||||||
* @param body Created user object
|
* @param user Created user object
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
def createUser(body: User) = {
|
def createUser(user: User) = {
|
||||||
val await = Try(Await.result(createUserAsync(body), Duration.Inf))
|
val await = Try(Await.result(createUserAsync(user), Duration.Inf))
|
||||||
await match {
|
await match {
|
||||||
case Success(i) => Some(await.get)
|
case Success(i) => Some(await.get)
|
||||||
case Failure(t) => None
|
case Failure(t) => None
|
||||||
@@ -93,22 +93,22 @@ class UserApi(
|
|||||||
* Create user asynchronously
|
* Create user asynchronously
|
||||||
* This can only be done by the logged in user.
|
* This can only be done by the logged in user.
|
||||||
*
|
*
|
||||||
* @param body Created user object
|
* @param user Created user object
|
||||||
* @return Future(void)
|
* @return Future(void)
|
||||||
*/
|
*/
|
||||||
def createUserAsync(body: User) = {
|
def createUserAsync(user: User) = {
|
||||||
helper.createUser(body)
|
helper.createUser(user)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates list of users with given input array
|
* Creates list of users with given input array
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
* @param body List of user object
|
* @param user List of user object
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
def createUsersWithArrayInput(body: List[User]) = {
|
def createUsersWithArrayInput(user: List[User]) = {
|
||||||
val await = Try(Await.result(createUsersWithArrayInputAsync(body), Duration.Inf))
|
val await = Try(Await.result(createUsersWithArrayInputAsync(user), Duration.Inf))
|
||||||
await match {
|
await match {
|
||||||
case Success(i) => Some(await.get)
|
case Success(i) => Some(await.get)
|
||||||
case Failure(t) => None
|
case Failure(t) => None
|
||||||
@@ -119,22 +119,22 @@ class UserApi(
|
|||||||
* Creates list of users with given input array asynchronously
|
* Creates list of users with given input array asynchronously
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
* @param body List of user object
|
* @param user List of user object
|
||||||
* @return Future(void)
|
* @return Future(void)
|
||||||
*/
|
*/
|
||||||
def createUsersWithArrayInputAsync(body: List[User]) = {
|
def createUsersWithArrayInputAsync(user: List[User]) = {
|
||||||
helper.createUsersWithArrayInput(body)
|
helper.createUsersWithArrayInput(user)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates list of users with given input array
|
* Creates list of users with given input array
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
* @param body List of user object
|
* @param user List of user object
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
def createUsersWithListInput(body: List[User]) = {
|
def createUsersWithListInput(user: List[User]) = {
|
||||||
val await = Try(Await.result(createUsersWithListInputAsync(body), Duration.Inf))
|
val await = Try(Await.result(createUsersWithListInputAsync(user), Duration.Inf))
|
||||||
await match {
|
await match {
|
||||||
case Success(i) => Some(await.get)
|
case Success(i) => Some(await.get)
|
||||||
case Failure(t) => None
|
case Failure(t) => None
|
||||||
@@ -145,11 +145,11 @@ class UserApi(
|
|||||||
* Creates list of users with given input array asynchronously
|
* Creates list of users with given input array asynchronously
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
* @param body List of user object
|
* @param user List of user object
|
||||||
* @return Future(void)
|
* @return Future(void)
|
||||||
*/
|
*/
|
||||||
def createUsersWithListInputAsync(body: List[User]) = {
|
def createUsersWithListInputAsync(user: List[User]) = {
|
||||||
helper.createUsersWithListInput(body)
|
helper.createUsersWithListInput(user)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -261,11 +261,11 @@ class UserApi(
|
|||||||
* This can only be done by the logged in user.
|
* This can only be done by the logged in user.
|
||||||
*
|
*
|
||||||
* @param username name that need to be deleted
|
* @param username name that need to be deleted
|
||||||
* @param body Updated user object
|
* @param user Updated user object
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
def updateUser(username: String, body: User) = {
|
def updateUser(username: String, user: User) = {
|
||||||
val await = Try(Await.result(updateUserAsync(username, body), Duration.Inf))
|
val await = Try(Await.result(updateUserAsync(username, user), Duration.Inf))
|
||||||
await match {
|
await match {
|
||||||
case Success(i) => Some(await.get)
|
case Success(i) => Some(await.get)
|
||||||
case Failure(t) => None
|
case Failure(t) => None
|
||||||
@@ -277,18 +277,18 @@ class UserApi(
|
|||||||
* This can only be done by the logged in user.
|
* This can only be done by the logged in user.
|
||||||
*
|
*
|
||||||
* @param username name that need to be deleted
|
* @param username name that need to be deleted
|
||||||
* @param body Updated user object
|
* @param user Updated user object
|
||||||
* @return Future(void)
|
* @return Future(void)
|
||||||
*/
|
*/
|
||||||
def updateUserAsync(username: String, body: User) = {
|
def updateUserAsync(username: String, user: User) = {
|
||||||
helper.updateUser(username, body)
|
helper.updateUser(username, user)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
class UserApiAsyncHelper(client: TransportClient, config: SwaggerConfig) extends ApiClient(client, config) {
|
class UserApiAsyncHelper(client: TransportClient, config: SwaggerConfig) extends ApiClient(client, config) {
|
||||||
|
|
||||||
def createUser(body: User)(implicit reader: ClientResponseReader[Unit], writer: RequestWriter[User]): Future[Unit] = {
|
def createUser(user: User)(implicit reader: ClientResponseReader[Unit], writer: RequestWriter[User]): Future[Unit] = {
|
||||||
// create path and map variables
|
// create path and map variables
|
||||||
val path = (addFmt("/user"))
|
val path = (addFmt("/user"))
|
||||||
|
|
||||||
@@ -296,9 +296,9 @@ class UserApiAsyncHelper(client: TransportClient, config: SwaggerConfig) extends
|
|||||||
val queryParams = new mutable.HashMap[String, String]
|
val queryParams = new mutable.HashMap[String, String]
|
||||||
val headerParams = new mutable.HashMap[String, String]
|
val headerParams = new mutable.HashMap[String, String]
|
||||||
|
|
||||||
if (body == null) throw new Exception("Missing required parameter 'body' when calling UserApi->createUser")
|
if (user == null) throw new Exception("Missing required parameter 'user' when calling UserApi->createUser")
|
||||||
|
|
||||||
val resFuture = client.submit("POST", path, queryParams.toMap, headerParams.toMap, writer.write(body))
|
val resFuture = client.submit("POST", path, queryParams.toMap, headerParams.toMap, writer.write(user))
|
||||||
resFuture flatMap { resp =>
|
resFuture flatMap { resp =>
|
||||||
val status = Response.Status.fromStatusCode(resp.statusCode)
|
val status = Response.Status.fromStatusCode(resp.statusCode)
|
||||||
status.getFamily match {
|
status.getFamily match {
|
||||||
@@ -308,7 +308,7 @@ class UserApiAsyncHelper(client: TransportClient, config: SwaggerConfig) extends
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
def createUsersWithArrayInput(body: List[User])(implicit reader: ClientResponseReader[Unit], writer: RequestWriter[List[User]]): Future[Unit] = {
|
def createUsersWithArrayInput(user: List[User])(implicit reader: ClientResponseReader[Unit], writer: RequestWriter[List[User]]): Future[Unit] = {
|
||||||
// create path and map variables
|
// create path and map variables
|
||||||
val path = (addFmt("/user/createWithArray"))
|
val path = (addFmt("/user/createWithArray"))
|
||||||
|
|
||||||
@@ -316,9 +316,9 @@ class UserApiAsyncHelper(client: TransportClient, config: SwaggerConfig) extends
|
|||||||
val queryParams = new mutable.HashMap[String, String]
|
val queryParams = new mutable.HashMap[String, String]
|
||||||
val headerParams = new mutable.HashMap[String, String]
|
val headerParams = new mutable.HashMap[String, String]
|
||||||
|
|
||||||
if (body == null) throw new Exception("Missing required parameter 'body' when calling UserApi->createUsersWithArrayInput")
|
if (user == null) throw new Exception("Missing required parameter 'user' when calling UserApi->createUsersWithArrayInput")
|
||||||
|
|
||||||
val resFuture = client.submit("POST", path, queryParams.toMap, headerParams.toMap, writer.write(body))
|
val resFuture = client.submit("POST", path, queryParams.toMap, headerParams.toMap, writer.write(user))
|
||||||
resFuture flatMap { resp =>
|
resFuture flatMap { resp =>
|
||||||
val status = Response.Status.fromStatusCode(resp.statusCode)
|
val status = Response.Status.fromStatusCode(resp.statusCode)
|
||||||
status.getFamily match {
|
status.getFamily match {
|
||||||
@@ -328,7 +328,7 @@ class UserApiAsyncHelper(client: TransportClient, config: SwaggerConfig) extends
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
def createUsersWithListInput(body: List[User])(implicit reader: ClientResponseReader[Unit], writer: RequestWriter[List[User]]): Future[Unit] = {
|
def createUsersWithListInput(user: List[User])(implicit reader: ClientResponseReader[Unit], writer: RequestWriter[List[User]]): Future[Unit] = {
|
||||||
// create path and map variables
|
// create path and map variables
|
||||||
val path = (addFmt("/user/createWithList"))
|
val path = (addFmt("/user/createWithList"))
|
||||||
|
|
||||||
@@ -336,9 +336,9 @@ class UserApiAsyncHelper(client: TransportClient, config: SwaggerConfig) extends
|
|||||||
val queryParams = new mutable.HashMap[String, String]
|
val queryParams = new mutable.HashMap[String, String]
|
||||||
val headerParams = new mutable.HashMap[String, String]
|
val headerParams = new mutable.HashMap[String, String]
|
||||||
|
|
||||||
if (body == null) throw new Exception("Missing required parameter 'body' when calling UserApi->createUsersWithListInput")
|
if (user == null) throw new Exception("Missing required parameter 'user' when calling UserApi->createUsersWithListInput")
|
||||||
|
|
||||||
val resFuture = client.submit("POST", path, queryParams.toMap, headerParams.toMap, writer.write(body))
|
val resFuture = client.submit("POST", path, queryParams.toMap, headerParams.toMap, writer.write(user))
|
||||||
resFuture flatMap { resp =>
|
resFuture flatMap { resp =>
|
||||||
val status = Response.Status.fromStatusCode(resp.statusCode)
|
val status = Response.Status.fromStatusCode(resp.statusCode)
|
||||||
status.getFamily match {
|
status.getFamily match {
|
||||||
@@ -438,7 +438,7 @@ class UserApiAsyncHelper(client: TransportClient, config: SwaggerConfig) extends
|
|||||||
}
|
}
|
||||||
|
|
||||||
def updateUser(username: String,
|
def updateUser(username: String,
|
||||||
body: User)(implicit reader: ClientResponseReader[Unit], writer: RequestWriter[User]): Future[Unit] = {
|
user: User)(implicit reader: ClientResponseReader[Unit], writer: RequestWriter[User]): Future[Unit] = {
|
||||||
// create path and map variables
|
// create path and map variables
|
||||||
val path = (addFmt("/user/{username}")
|
val path = (addFmt("/user/{username}")
|
||||||
replaceAll("\\{" + "username" + "\\}", username.toString))
|
replaceAll("\\{" + "username" + "\\}", username.toString))
|
||||||
@@ -449,9 +449,9 @@ class UserApiAsyncHelper(client: TransportClient, config: SwaggerConfig) extends
|
|||||||
|
|
||||||
if (username == null) throw new Exception("Missing required parameter 'username' when calling UserApi->updateUser")
|
if (username == null) throw new Exception("Missing required parameter 'username' when calling UserApi->updateUser")
|
||||||
|
|
||||||
if (body == null) throw new Exception("Missing required parameter 'body' when calling UserApi->updateUser")
|
if (user == null) throw new Exception("Missing required parameter 'user' when calling UserApi->updateUser")
|
||||||
|
|
||||||
val resFuture = client.submit("PUT", path, queryParams.toMap, headerParams.toMap, writer.write(body))
|
val resFuture = client.submit("PUT", path, queryParams.toMap, headerParams.toMap, writer.write(user))
|
||||||
resFuture flatMap { resp =>
|
resFuture flatMap { resp =>
|
||||||
val status = Response.Status.fromStatusCode(resp.statusCode)
|
val status = Response.Status.fromStatusCode(resp.statusCode)
|
||||||
status.getFamily match {
|
status.getFamily match {
|
||||||
|
|||||||
@@ -0,0 +1,22 @@
|
|||||||
|
/**
|
||||||
|
* OpenAPI Petstore
|
||||||
|
* This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
|
||||||
|
*
|
||||||
|
* The version of the OpenAPI document: 1.0.0
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
||||||
|
* https://openapi-generator.tech
|
||||||
|
* Do not edit the class manually.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package org.openapitools.client.model
|
||||||
|
|
||||||
|
|
||||||
|
case class InlineObject (
|
||||||
|
// Updated name of the pet
|
||||||
|
name: Option[String] = None,
|
||||||
|
// Updated status of the pet
|
||||||
|
status: Option[String] = None
|
||||||
|
)
|
||||||
|
|
||||||
@@ -0,0 +1,23 @@
|
|||||||
|
/**
|
||||||
|
* OpenAPI Petstore
|
||||||
|
* This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
|
||||||
|
*
|
||||||
|
* The version of the OpenAPI document: 1.0.0
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
||||||
|
* https://openapi-generator.tech
|
||||||
|
* Do not edit the class manually.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package org.openapitools.client.model
|
||||||
|
|
||||||
|
import java.io.File
|
||||||
|
|
||||||
|
case class InlineObject1 (
|
||||||
|
// Additional data to pass to server
|
||||||
|
additionalMetadata: Option[String] = None,
|
||||||
|
// file to upload
|
||||||
|
file: Option[File] = None
|
||||||
|
)
|
||||||
|
|
||||||
@@ -1,14 +1,10 @@
|
|||||||
README.md
|
README.md
|
||||||
build.sbt
|
build.sbt
|
||||||
pom.xml
|
|
||||||
src/main/resources/reference.conf
|
|
||||||
src/main/scala/org/openapitools/client/api/EnumsSerializers.scala
|
src/main/scala/org/openapitools/client/api/EnumsSerializers.scala
|
||||||
src/main/scala/org/openapitools/client/api/PetApi.scala
|
src/main/scala/org/openapitools/client/api/PetApi.scala
|
||||||
src/main/scala/org/openapitools/client/api/StoreApi.scala
|
src/main/scala/org/openapitools/client/api/StoreApi.scala
|
||||||
src/main/scala/org/openapitools/client/api/UserApi.scala
|
src/main/scala/org/openapitools/client/api/UserApi.scala
|
||||||
src/main/scala/org/openapitools/client/core/ApiInvoker.scala
|
src/main/scala/org/openapitools/client/core/ApiInvoker.scala
|
||||||
src/main/scala/org/openapitools/client/core/ApiRequest.scala
|
|
||||||
src/main/scala/org/openapitools/client/core/ApiSettings.scala
|
|
||||||
src/main/scala/org/openapitools/client/core/Serializers.scala
|
src/main/scala/org/openapitools/client/core/Serializers.scala
|
||||||
src/main/scala/org/openapitools/client/core/requests.scala
|
src/main/scala/org/openapitools/client/core/requests.scala
|
||||||
src/main/scala/org/openapitools/client/model/ApiResponse.scala
|
src/main/scala/org/openapitools/client/model/ApiResponse.scala
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
# scala-akka-petstore-client
|
# 'scala-sttp-petstore'
|
||||||
|
|
||||||
OpenAPI Petstore
|
OpenAPI Petstore
|
||||||
- API version: 1.0.0
|
- API version: 1.0.0
|
||||||
@@ -37,7 +37,7 @@ Add this dependency to your project's POM:
|
|||||||
```xml
|
```xml
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.openapitools</groupId>
|
<groupId>org.openapitools</groupId>
|
||||||
<artifactId>scala-akka-petstore-client</artifactId>
|
<artifactId>'scala-sttp-petstore'</artifactId>
|
||||||
<version>1.0.0</version>
|
<version>1.0.0</version>
|
||||||
<scope>compile</scope>
|
<scope>compile</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
@@ -48,13 +48,13 @@ Add this dependency to your project's POM:
|
|||||||
Add this dependency to your project's build file:
|
Add this dependency to your project's build file:
|
||||||
|
|
||||||
```groovy
|
```groovy
|
||||||
compile "org.openapitools:scala-akka-petstore-client:1.0.0"
|
compile "org.openapitools:'scala-sttp-petstore':1.0.0"
|
||||||
```
|
```
|
||||||
|
|
||||||
### SBT users
|
### SBT users
|
||||||
|
|
||||||
```scala
|
```scala
|
||||||
libraryDependencies += "org.openapitools" % "scala-akka-petstore-client" % "1.0.0"
|
libraryDependencies += "org.openapitools" % "'scala-sttp-petstore'" % "1.0.0"
|
||||||
```
|
```
|
||||||
|
|
||||||
## Getting Started
|
## Getting Started
|
||||||
@@ -66,25 +66,25 @@ All URIs are relative to *http://petstore.swagger.io/v2*
|
|||||||
Class | Method | HTTP request | Description
|
Class | Method | HTTP request | Description
|
||||||
------------ | ------------- | ------------- | -------------
|
------------ | ------------- | ------------- | -------------
|
||||||
*PetApi* | **addPet** | **POST** /pet | Add a new pet to the store
|
*PetApi* | **addPet** | **POST** /pet | Add a new pet to the store
|
||||||
*PetApi* | **deletePet** | **DELETE** /pet/{petId} | Deletes a pet
|
*PetApi* | **deletePet** | **DELETE** /pet/${petId} | Deletes a pet
|
||||||
*PetApi* | **findPetsByStatus** | **GET** /pet/findByStatus | Finds Pets by status
|
*PetApi* | **findPetsByStatus** | **GET** /pet/findByStatus | Finds Pets by status
|
||||||
*PetApi* | **findPetsByTags** | **GET** /pet/findByTags | Finds Pets by tags
|
*PetApi* | **findPetsByTags** | **GET** /pet/findByTags | Finds Pets by tags
|
||||||
*PetApi* | **getPetById** | **GET** /pet/{petId} | Find pet by ID
|
*PetApi* | **getPetById** | **GET** /pet/${petId} | Find pet by ID
|
||||||
*PetApi* | **updatePet** | **PUT** /pet | Update an existing pet
|
*PetApi* | **updatePet** | **PUT** /pet | Update an existing pet
|
||||||
*PetApi* | **updatePetWithForm** | **POST** /pet/{petId} | Updates a pet in the store with form data
|
*PetApi* | **updatePetWithForm** | **POST** /pet/${petId} | Updates a pet in the store with form data
|
||||||
*PetApi* | **uploadFile** | **POST** /pet/{petId}/uploadImage | uploads an image
|
*PetApi* | **uploadFile** | **POST** /pet/${petId}/uploadImage | uploads an image
|
||||||
*StoreApi* | **deleteOrder** | **DELETE** /store/order/{orderId} | Delete purchase order by ID
|
*StoreApi* | **deleteOrder** | **DELETE** /store/order/${orderId} | Delete purchase order by ID
|
||||||
*StoreApi* | **getInventory** | **GET** /store/inventory | Returns pet inventories by status
|
*StoreApi* | **getInventory** | **GET** /store/inventory | Returns pet inventories by status
|
||||||
*StoreApi* | **getOrderById** | **GET** /store/order/{orderId} | Find purchase order by ID
|
*StoreApi* | **getOrderById** | **GET** /store/order/${orderId} | Find purchase order by ID
|
||||||
*StoreApi* | **placeOrder** | **POST** /store/order | Place an order for a pet
|
*StoreApi* | **placeOrder** | **POST** /store/order | Place an order for a pet
|
||||||
*UserApi* | **createUser** | **POST** /user | Create user
|
*UserApi* | **createUser** | **POST** /user | Create user
|
||||||
*UserApi* | **createUsersWithArrayInput** | **POST** /user/createWithArray | Creates list of users with given input array
|
*UserApi* | **createUsersWithArrayInput** | **POST** /user/createWithArray | Creates list of users with given input array
|
||||||
*UserApi* | **createUsersWithListInput** | **POST** /user/createWithList | Creates list of users with given input array
|
*UserApi* | **createUsersWithListInput** | **POST** /user/createWithList | Creates list of users with given input array
|
||||||
*UserApi* | **deleteUser** | **DELETE** /user/{username} | Delete user
|
*UserApi* | **deleteUser** | **DELETE** /user/${username} | Delete user
|
||||||
*UserApi* | **getUserByName** | **GET** /user/{username} | Get user by user name
|
*UserApi* | **getUserByName** | **GET** /user/${username} | Get user by user name
|
||||||
*UserApi* | **loginUser** | **GET** /user/login | Logs user into the system
|
*UserApi* | **loginUser** | **GET** /user/login | Logs user into the system
|
||||||
*UserApi* | **logoutUser** | **GET** /user/logout | Logs out current logged in user session
|
*UserApi* | **logoutUser** | **GET** /user/logout | Logs out current logged in user session
|
||||||
*UserApi* | **updateUser** | **PUT** /user/{username} | Updated user
|
*UserApi* | **updateUser** | **PUT** /user/${username} | Updated user
|
||||||
|
|
||||||
|
|
||||||
## Documentation for Models
|
## Documentation for Models
|
||||||
@@ -108,12 +108,6 @@ Authentication schemes defined for the API:
|
|||||||
- **API key parameter name**: api_key
|
- **API key parameter name**: api_key
|
||||||
- **Location**: HTTP header
|
- **Location**: HTTP header
|
||||||
|
|
||||||
### auth_cookie
|
|
||||||
|
|
||||||
- **Type**: API key
|
|
||||||
- **API key parameter name**: AUTH_KEY
|
|
||||||
- **Location**:
|
|
||||||
|
|
||||||
|
|
||||||
## Author
|
## Author
|
||||||
|
|
||||||
24
samples/client/petstore/scala-sttp/build.sbt
Normal file
24
samples/client/petstore/scala-sttp/build.sbt
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
version := "1.0.0"
|
||||||
|
name := "'scala-sttp-petstore'"
|
||||||
|
organization := "org.openapitools"
|
||||||
|
|
||||||
|
scalaVersion := "2.13.0"
|
||||||
|
|
||||||
|
crossScalaVersions := Seq(scalaVersion.value, "2.12.10", "2.11.12")
|
||||||
|
|
||||||
|
libraryDependencies ++= Seq(
|
||||||
|
"com.softwaremill.sttp.client" %% "core" % "2.0.0",
|
||||||
|
"com.softwaremill.sttp.client" %% "json4s" % "2.0.0",
|
||||||
|
"org.json4s" %% "json4s-jackson" % "3.6.7",
|
||||||
|
// test dependencies
|
||||||
|
"org.scalatest" %% "scalatest" % "3.0.8" % Test,
|
||||||
|
"junit" % "junit" % "4.13" % "test"
|
||||||
|
)
|
||||||
|
|
||||||
|
scalacOptions := Seq(
|
||||||
|
"-unchecked",
|
||||||
|
"-deprecation",
|
||||||
|
"-feature"
|
||||||
|
)
|
||||||
|
|
||||||
|
publishArtifact in (Compile, packageDoc) := false
|
||||||
32
samples/client/petstore/scala-sttp/pom.xml
Normal file
32
samples/client/petstore/scala-sttp/pom.xml
Normal file
@@ -0,0 +1,32 @@
|
|||||||
|
<project>
|
||||||
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
<groupId>org.openapitools</groupId>
|
||||||
|
<artifactId>scalaz-sttp-petstore-client</artifactId>
|
||||||
|
<packaging>pom</packaging>
|
||||||
|
<version>1.0-SNAPSHOT</version>
|
||||||
|
<name>scala-sttp-petstore-client</name>
|
||||||
|
<build>
|
||||||
|
<plugins>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.codehaus.mojo</groupId>
|
||||||
|
<artifactId>exec-maven-plugin</artifactId>
|
||||||
|
<version>1.5.0</version>
|
||||||
|
<executions>
|
||||||
|
<execution>
|
||||||
|
<id>sbt-test</id>
|
||||||
|
<phase>integration-test</phase>
|
||||||
|
<goals>
|
||||||
|
<goal>exec</goal>
|
||||||
|
</goals>
|
||||||
|
<configuration>
|
||||||
|
<executable>sbt</executable>
|
||||||
|
<arguments>
|
||||||
|
<argument>test</argument>
|
||||||
|
</arguments>
|
||||||
|
</configuration>
|
||||||
|
</execution>
|
||||||
|
</executions>
|
||||||
|
</plugin>
|
||||||
|
</plugins>
|
||||||
|
</build>
|
||||||
|
</project>
|
||||||
@@ -15,16 +15,20 @@ import org.openapitools.client.model.ApiResponse
|
|||||||
import java.io.File
|
import java.io.File
|
||||||
import org.openapitools.client.model.Pet
|
import org.openapitools.client.model.Pet
|
||||||
import org.openapitools.client.core._
|
import org.openapitools.client.core._
|
||||||
import org.openapitools.client.core.CollectionFormats._
|
import alias._
|
||||||
import org.openapitools.client.core.ApiKeyLocations._
|
import sttp.client._
|
||||||
|
import sttp.model.Method
|
||||||
|
|
||||||
object PetApi {
|
object PetApi {
|
||||||
|
|
||||||
def apply(baseUrl: String = "http://petstore.swagger.io/v2") = new PetApi(baseUrl)
|
def apply(baseUrl: String = "http://petstore.swagger.io/v2")(implicit serializer: SttpSerializer) = new PetApi(baseUrl)
|
||||||
}
|
}
|
||||||
|
|
||||||
class PetApi(baseUrl: String) {
|
class PetApi(baseUrl: String)(implicit serializer: SttpSerializer) {
|
||||||
|
|
||||||
|
import Helpers._
|
||||||
|
import serializer._
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Expected answers:
|
* Expected answers:
|
||||||
* code 200 : Pet (successful operation)
|
* code 200 : Pet (successful operation)
|
||||||
@@ -32,12 +36,12 @@ class PetApi(baseUrl: String) {
|
|||||||
*
|
*
|
||||||
* @param pet Pet object that needs to be added to the store
|
* @param pet Pet object that needs to be added to the store
|
||||||
*/
|
*/
|
||||||
def addPet(pet: Pet): ApiRequest[Pet] =
|
def addPet(pet: Pet): ApiRequestT[Pet] =
|
||||||
ApiRequest[Pet](ApiMethods.POST, baseUrl, "/pet", "application/json")
|
basicRequest
|
||||||
.withBody(pet)
|
.method(Method.POST, uri"$baseUrl/pet")
|
||||||
.withSuccessResponse[Pet](200)
|
.contentType("application/json")
|
||||||
.withErrorResponse[Unit](405)
|
.body(pet)
|
||||||
|
.response(asJson[Pet])
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Expected answers:
|
* Expected answers:
|
||||||
@@ -46,12 +50,12 @@ class PetApi(baseUrl: String) {
|
|||||||
* @param petId Pet id to delete
|
* @param petId Pet id to delete
|
||||||
* @param apiKey
|
* @param apiKey
|
||||||
*/
|
*/
|
||||||
def deletePet(petId: Long, apiKey: Option[String] = None): ApiRequest[Unit] =
|
def deletePet(petId: Long, apiKey: Option[String] = None): ApiRequestT[Unit] =
|
||||||
ApiRequest[Unit](ApiMethods.DELETE, baseUrl, "/pet/{petId}", "application/json")
|
basicRequest
|
||||||
.withPathParam("petId", petId)
|
.method(Method.DELETE, uri"$baseUrl/pet/${petId}")
|
||||||
.withHeaderParam("api_key", apiKey)
|
.contentType("application/json")
|
||||||
.withErrorResponse[Unit](400)
|
.header("api_key", apiKey)
|
||||||
|
.response(asJson[Unit])
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Multiple status values can be provided with comma separated strings
|
* Multiple status values can be provided with comma separated strings
|
||||||
@@ -62,12 +66,11 @@ class PetApi(baseUrl: String) {
|
|||||||
*
|
*
|
||||||
* @param status Status values that need to be considered for filter
|
* @param status Status values that need to be considered for filter
|
||||||
*/
|
*/
|
||||||
def findPetsByStatus(status: Seq[String]): ApiRequest[Seq[Pet]] =
|
def findPetsByStatus(status: Seq[String]): ApiRequestT[Seq[Pet]] =
|
||||||
ApiRequest[Seq[Pet]](ApiMethods.GET, baseUrl, "/pet/findByStatus", "application/json")
|
basicRequest
|
||||||
.withQueryParam("status", ArrayValues(status, CSV))
|
.method(Method.GET, uri"$baseUrl/pet/findByStatus?status=$status")
|
||||||
.withSuccessResponse[Seq[Pet]](200)
|
.contentType("application/json")
|
||||||
.withErrorResponse[Unit](400)
|
.response(asJson[Seq[Pet]])
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.
|
* Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.
|
||||||
@@ -78,12 +81,11 @@ class PetApi(baseUrl: String) {
|
|||||||
*
|
*
|
||||||
* @param tags Tags to filter by
|
* @param tags Tags to filter by
|
||||||
*/
|
*/
|
||||||
def findPetsByTags(tags: Seq[String]): ApiRequest[Seq[Pet]] =
|
def findPetsByTags(tags: Seq[String]): ApiRequestT[Seq[Pet]] =
|
||||||
ApiRequest[Seq[Pet]](ApiMethods.GET, baseUrl, "/pet/findByTags", "application/json")
|
basicRequest
|
||||||
.withQueryParam("tags", ArrayValues(tags, CSV))
|
.method(Method.GET, uri"$baseUrl/pet/findByTags?tags=$tags")
|
||||||
.withSuccessResponse[Seq[Pet]](200)
|
.contentType("application/json")
|
||||||
.withErrorResponse[Unit](400)
|
.response(asJson[Seq[Pet]])
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns a single pet
|
* Returns a single pet
|
||||||
@@ -98,14 +100,12 @@ class PetApi(baseUrl: String) {
|
|||||||
*
|
*
|
||||||
* @param petId ID of pet to return
|
* @param petId ID of pet to return
|
||||||
*/
|
*/
|
||||||
def getPetById(petId: Long)(implicit apiKey: ApiKeyValue): ApiRequest[Pet] =
|
def getPetById(petId: Long)(implicit apiKey: ApiKeyValue): ApiRequestT[Pet] =
|
||||||
ApiRequest[Pet](ApiMethods.GET, baseUrl, "/pet/{petId}", "application/json")
|
basicRequest
|
||||||
.withApiKey(apiKey, "api_key", HEADER)
|
.method(Method.GET, uri"$baseUrl/pet/${petId}")
|
||||||
.withPathParam("petId", petId)
|
.contentType("application/json")
|
||||||
.withSuccessResponse[Pet](200)
|
.header("api_key", apiKey.value)
|
||||||
.withErrorResponse[Unit](400)
|
.response(asJson[Pet])
|
||||||
.withErrorResponse[Unit](404)
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Expected answers:
|
* Expected answers:
|
||||||
@@ -116,32 +116,30 @@ class PetApi(baseUrl: String) {
|
|||||||
*
|
*
|
||||||
* @param pet Pet object that needs to be added to the store
|
* @param pet Pet object that needs to be added to the store
|
||||||
*/
|
*/
|
||||||
def updatePet(pet: Pet): ApiRequest[Pet] =
|
def updatePet(pet: Pet): ApiRequestT[Pet] =
|
||||||
ApiRequest[Pet](ApiMethods.PUT, baseUrl, "/pet", "application/json")
|
basicRequest
|
||||||
.withBody(pet)
|
.method(Method.PUT, uri"$baseUrl/pet")
|
||||||
.withSuccessResponse[Pet](200)
|
.contentType("application/json")
|
||||||
.withErrorResponse[Unit](400)
|
.body(pet)
|
||||||
.withErrorResponse[Unit](404)
|
.response(asJson[Pet])
|
||||||
.withErrorResponse[Unit](405)
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Expected answers:
|
* Expected answers:
|
||||||
* code 200 : (successful operation)
|
|
||||||
* code 405 : (Invalid input)
|
* code 405 : (Invalid input)
|
||||||
*
|
*
|
||||||
* @param petId ID of pet that needs to be updated
|
* @param petId ID of pet that needs to be updated
|
||||||
* @param name Updated name of the pet
|
* @param name Updated name of the pet
|
||||||
* @param status Updated status of the pet
|
* @param status Updated status of the pet
|
||||||
*/
|
*/
|
||||||
def updatePetWithForm(petId: Long, name: Option[String] = None, status: Option[String] = None): ApiRequest[Unit] =
|
def updatePetWithForm(petId: Long, name: Option[String] = None, status: Option[String] = None): ApiRequestT[Unit] =
|
||||||
ApiRequest[Unit](ApiMethods.POST, baseUrl, "/pet/{petId}", "application/x-www-form-urlencoded")
|
basicRequest
|
||||||
.withFormParam("name", name)
|
.method(Method.POST, uri"$baseUrl/pet/${petId}")
|
||||||
.withFormParam("status", status)
|
.contentType("application/x-www-form-urlencoded")
|
||||||
.withPathParam("petId", petId)
|
.body(Map(
|
||||||
.withSuccessResponse[Unit](200)
|
"name" -> name,
|
||||||
.withErrorResponse[Unit](405)
|
"status" -> status,
|
||||||
|
))
|
||||||
|
.response(asJson[Unit])
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Expected answers:
|
* Expected answers:
|
||||||
@@ -151,15 +149,15 @@ class PetApi(baseUrl: String) {
|
|||||||
* @param additionalMetadata Additional data to pass to server
|
* @param additionalMetadata Additional data to pass to server
|
||||||
* @param file file to upload
|
* @param file file to upload
|
||||||
*/
|
*/
|
||||||
def uploadFile(petId: Long, additionalMetadata: Option[String] = None, file: Option[File] = None): ApiRequest[ApiResponse] =
|
def uploadFile(petId: Long, additionalMetadata: Option[String] = None, file: Option[File] = None): ApiRequestT[ApiResponse] =
|
||||||
ApiRequest[ApiResponse](ApiMethods.POST, baseUrl, "/pet/{petId}/uploadImage", "multipart/form-data")
|
basicRequest
|
||||||
.withFormParam("additionalMetadata", additionalMetadata)
|
.method(Method.POST, uri"$baseUrl/pet/${petId}/uploadImage")
|
||||||
.withFormParam("file", file)
|
.contentType("multipart/form-data")
|
||||||
.withPathParam("petId", petId)
|
.body(Map(
|
||||||
.withSuccessResponse[ApiResponse](200)
|
"additionalMetadata" -> additionalMetadata,
|
||||||
|
"file" -> file,
|
||||||
|
))
|
||||||
|
.response(asJson[ApiResponse])
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -13,16 +13,20 @@ package org.openapitools.client.api
|
|||||||
|
|
||||||
import org.openapitools.client.model.Order
|
import org.openapitools.client.model.Order
|
||||||
import org.openapitools.client.core._
|
import org.openapitools.client.core._
|
||||||
import org.openapitools.client.core.CollectionFormats._
|
import alias._
|
||||||
import org.openapitools.client.core.ApiKeyLocations._
|
import sttp.client._
|
||||||
|
import sttp.model.Method
|
||||||
|
|
||||||
object StoreApi {
|
object StoreApi {
|
||||||
|
|
||||||
def apply(baseUrl: String = "http://petstore.swagger.io/v2") = new StoreApi(baseUrl)
|
def apply(baseUrl: String = "http://petstore.swagger.io/v2")(implicit serializer: SttpSerializer) = new StoreApi(baseUrl)
|
||||||
}
|
}
|
||||||
|
|
||||||
class StoreApi(baseUrl: String) {
|
class StoreApi(baseUrl: String)(implicit serializer: SttpSerializer) {
|
||||||
|
|
||||||
|
import Helpers._
|
||||||
|
import serializer._
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors
|
* For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors
|
||||||
*
|
*
|
||||||
@@ -32,12 +36,11 @@ class StoreApi(baseUrl: String) {
|
|||||||
*
|
*
|
||||||
* @param orderId ID of the order that needs to be deleted
|
* @param orderId ID of the order that needs to be deleted
|
||||||
*/
|
*/
|
||||||
def deleteOrder(orderId: String): ApiRequest[Unit] =
|
def deleteOrder(orderId: String): ApiRequestT[Unit] =
|
||||||
ApiRequest[Unit](ApiMethods.DELETE, baseUrl, "/store/order/{orderId}", "application/json")
|
basicRequest
|
||||||
.withPathParam("orderId", orderId)
|
.method(Method.DELETE, uri"$baseUrl/store/order/${orderId}")
|
||||||
.withErrorResponse[Unit](400)
|
.contentType("application/json")
|
||||||
.withErrorResponse[Unit](404)
|
.response(asJson[Unit])
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns a map of status codes to quantities
|
* Returns a map of status codes to quantities
|
||||||
@@ -48,11 +51,12 @@ class StoreApi(baseUrl: String) {
|
|||||||
* Available security schemes:
|
* Available security schemes:
|
||||||
* api_key (apiKey)
|
* api_key (apiKey)
|
||||||
*/
|
*/
|
||||||
def getInventory()(implicit apiKey: ApiKeyValue): ApiRequest[Map[String, Int]] =
|
def getInventory()(implicit apiKey: ApiKeyValue): ApiRequestT[Map[String, Int]] =
|
||||||
ApiRequest[Map[String, Int]](ApiMethods.GET, baseUrl, "/store/inventory", "application/json")
|
basicRequest
|
||||||
.withApiKey(apiKey, "api_key", HEADER)
|
.method(Method.GET, uri"$baseUrl/store/inventory")
|
||||||
.withSuccessResponse[Map[String, Int]](200)
|
.contentType("application/json")
|
||||||
|
.header("api_key", apiKey.value)
|
||||||
|
.response(asJson[Map[String, Int]])
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions
|
* For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions
|
||||||
@@ -64,13 +68,11 @@ class StoreApi(baseUrl: String) {
|
|||||||
*
|
*
|
||||||
* @param orderId ID of pet that needs to be fetched
|
* @param orderId ID of pet that needs to be fetched
|
||||||
*/
|
*/
|
||||||
def getOrderById(orderId: Long): ApiRequest[Order] =
|
def getOrderById(orderId: Long): ApiRequestT[Order] =
|
||||||
ApiRequest[Order](ApiMethods.GET, baseUrl, "/store/order/{orderId}", "application/json")
|
basicRequest
|
||||||
.withPathParam("orderId", orderId)
|
.method(Method.GET, uri"$baseUrl/store/order/${orderId}")
|
||||||
.withSuccessResponse[Order](200)
|
.contentType("application/json")
|
||||||
.withErrorResponse[Unit](400)
|
.response(asJson[Order])
|
||||||
.withErrorResponse[Unit](404)
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Expected answers:
|
* Expected answers:
|
||||||
@@ -79,14 +81,12 @@ class StoreApi(baseUrl: String) {
|
|||||||
*
|
*
|
||||||
* @param order order placed for purchasing the pet
|
* @param order order placed for purchasing the pet
|
||||||
*/
|
*/
|
||||||
def placeOrder(order: Order): ApiRequest[Order] =
|
def placeOrder(order: Order): ApiRequestT[Order] =
|
||||||
ApiRequest[Order](ApiMethods.POST, baseUrl, "/store/order", "application/json")
|
basicRequest
|
||||||
.withBody(order)
|
.method(Method.POST, uri"$baseUrl/store/order")
|
||||||
.withSuccessResponse[Order](200)
|
.contentType("application/json")
|
||||||
.withErrorResponse[Unit](400)
|
.body(order)
|
||||||
|
.response(asJson[Order])
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -0,0 +1,170 @@
|
|||||||
|
/**
|
||||||
|
* OpenAPI Petstore
|
||||||
|
* This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
|
||||||
|
*
|
||||||
|
* The version of the OpenAPI document: 1.0.0
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
||||||
|
* https://openapi-generator.tech
|
||||||
|
* Do not edit the class manually.
|
||||||
|
*/
|
||||||
|
package org.openapitools.client.api
|
||||||
|
|
||||||
|
import org.openapitools.client.model.User
|
||||||
|
import org.openapitools.client.core._
|
||||||
|
import alias._
|
||||||
|
import sttp.client._
|
||||||
|
import sttp.model.Method
|
||||||
|
|
||||||
|
object UserApi {
|
||||||
|
|
||||||
|
def apply(baseUrl: String = "http://petstore.swagger.io/v2")(implicit serializer: SttpSerializer) = new UserApi(baseUrl)
|
||||||
|
}
|
||||||
|
|
||||||
|
class UserApi(baseUrl: String)(implicit serializer: SttpSerializer) {
|
||||||
|
|
||||||
|
import Helpers._
|
||||||
|
import serializer._
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This can only be done by the logged in user.
|
||||||
|
*
|
||||||
|
* Expected answers:
|
||||||
|
* code 0 : (successful operation)
|
||||||
|
*
|
||||||
|
* Available security schemes:
|
||||||
|
* api_key (apiKey)
|
||||||
|
*
|
||||||
|
* @param user Created user object
|
||||||
|
*/
|
||||||
|
def createUser(user: User)(implicit apiKey: ApiKeyValue): ApiRequestT[Unit] =
|
||||||
|
basicRequest
|
||||||
|
.method(Method.POST, uri"$baseUrl/user")
|
||||||
|
.contentType("application/json")
|
||||||
|
.header("api_key", apiKey.value)
|
||||||
|
.body(user)
|
||||||
|
.response(asJson[Unit])
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Expected answers:
|
||||||
|
* code 0 : (successful operation)
|
||||||
|
*
|
||||||
|
* Available security schemes:
|
||||||
|
* api_key (apiKey)
|
||||||
|
*
|
||||||
|
* @param user List of user object
|
||||||
|
*/
|
||||||
|
def createUsersWithArrayInput(user: Seq[User])(implicit apiKey: ApiKeyValue): ApiRequestT[Unit] =
|
||||||
|
basicRequest
|
||||||
|
.method(Method.POST, uri"$baseUrl/user/createWithArray")
|
||||||
|
.contentType("application/json")
|
||||||
|
.header("api_key", apiKey.value)
|
||||||
|
.body(user)
|
||||||
|
.response(asJson[Unit])
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Expected answers:
|
||||||
|
* code 0 : (successful operation)
|
||||||
|
*
|
||||||
|
* Available security schemes:
|
||||||
|
* api_key (apiKey)
|
||||||
|
*
|
||||||
|
* @param user List of user object
|
||||||
|
*/
|
||||||
|
def createUsersWithListInput(user: Seq[User])(implicit apiKey: ApiKeyValue): ApiRequestT[Unit] =
|
||||||
|
basicRequest
|
||||||
|
.method(Method.POST, uri"$baseUrl/user/createWithList")
|
||||||
|
.contentType("application/json")
|
||||||
|
.header("api_key", apiKey.value)
|
||||||
|
.body(user)
|
||||||
|
.response(asJson[Unit])
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This can only be done by the logged in user.
|
||||||
|
*
|
||||||
|
* Expected answers:
|
||||||
|
* code 400 : (Invalid username supplied)
|
||||||
|
* code 404 : (User not found)
|
||||||
|
*
|
||||||
|
* Available security schemes:
|
||||||
|
* api_key (apiKey)
|
||||||
|
*
|
||||||
|
* @param username The name that needs to be deleted
|
||||||
|
*/
|
||||||
|
def deleteUser(username: String)(implicit apiKey: ApiKeyValue): ApiRequestT[Unit] =
|
||||||
|
basicRequest
|
||||||
|
.method(Method.DELETE, uri"$baseUrl/user/${username}")
|
||||||
|
.contentType("application/json")
|
||||||
|
.header("api_key", apiKey.value)
|
||||||
|
.response(asJson[Unit])
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Expected answers:
|
||||||
|
* code 200 : User (successful operation)
|
||||||
|
* code 400 : (Invalid username supplied)
|
||||||
|
* code 404 : (User not found)
|
||||||
|
*
|
||||||
|
* @param username The name that needs to be fetched. Use user1 for testing.
|
||||||
|
*/
|
||||||
|
def getUserByName(username: String): ApiRequestT[User] =
|
||||||
|
basicRequest
|
||||||
|
.method(Method.GET, uri"$baseUrl/user/${username}")
|
||||||
|
.contentType("application/json")
|
||||||
|
.response(asJson[User])
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Expected answers:
|
||||||
|
* code 200 : String (successful operation)
|
||||||
|
* Headers :
|
||||||
|
* Set-Cookie - Cookie authentication key for use with the `api_key` apiKey authentication.
|
||||||
|
* X-Rate-Limit - calls per hour allowed by the user
|
||||||
|
* X-Expires-After - date in UTC when toekn expires
|
||||||
|
* code 400 : (Invalid username/password supplied)
|
||||||
|
*
|
||||||
|
* @param username The user name for login
|
||||||
|
* @param password The password for login in clear text
|
||||||
|
*/
|
||||||
|
def loginUser(username: String, password: String): ApiRequestT[String] =
|
||||||
|
basicRequest
|
||||||
|
.method(Method.GET, uri"$baseUrl/user/login?username=$username&password=$password")
|
||||||
|
.contentType("application/json")
|
||||||
|
.response(asJson[String])
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Expected answers:
|
||||||
|
* code 0 : (successful operation)
|
||||||
|
*
|
||||||
|
* Available security schemes:
|
||||||
|
* api_key (apiKey)
|
||||||
|
*/
|
||||||
|
def logoutUser()(implicit apiKey: ApiKeyValue): ApiRequestT[Unit] =
|
||||||
|
basicRequest
|
||||||
|
.method(Method.GET, uri"$baseUrl/user/logout")
|
||||||
|
.contentType("application/json")
|
||||||
|
.header("api_key", apiKey.value)
|
||||||
|
.response(asJson[Unit])
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This can only be done by the logged in user.
|
||||||
|
*
|
||||||
|
* Expected answers:
|
||||||
|
* code 400 : (Invalid user supplied)
|
||||||
|
* code 404 : (User not found)
|
||||||
|
*
|
||||||
|
* Available security schemes:
|
||||||
|
* api_key (apiKey)
|
||||||
|
*
|
||||||
|
* @param username name that need to be deleted
|
||||||
|
* @param user Updated user object
|
||||||
|
*/
|
||||||
|
def updateUser(username: String, user: User)(implicit apiKey: ApiKeyValue): ApiRequestT[Unit] =
|
||||||
|
basicRequest
|
||||||
|
.method(Method.PUT, uri"$baseUrl/user/${username}")
|
||||||
|
.contentType("application/json")
|
||||||
|
.header("api_key", apiKey.value)
|
||||||
|
.body(user)
|
||||||
|
.response(asJson[Unit])
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
@@ -0,0 +1,60 @@
|
|||||||
|
/**
|
||||||
|
* OpenAPI Petstore
|
||||||
|
* This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
|
||||||
|
*
|
||||||
|
* The version of the OpenAPI document: 1.0.0
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
||||||
|
* https://openapi-generator.tech
|
||||||
|
* Do not edit the class manually.
|
||||||
|
*/
|
||||||
|
package org.openapitools.client.core
|
||||||
|
|
||||||
|
import org.json4s._
|
||||||
|
import sttp.client._
|
||||||
|
import sttp.model.StatusCode
|
||||||
|
import org.openapitools.client.api.EnumsSerializers
|
||||||
|
import sttp.client.json4s.SttpJson4sApi
|
||||||
|
import sttp.client.monad.MonadError
|
||||||
|
|
||||||
|
class SttpSerializer(implicit val format: Formats = DefaultFormats ++ EnumsSerializers.all ++ Serializers.all,
|
||||||
|
implicit val serialization: org.json4s.Serialization = org.json4s.jackson.Serialization) extends SttpJson4sApi
|
||||||
|
|
||||||
|
class HttpException(val statusCode: StatusCode, val statusText: String, val message: String) extends Exception(s"[$statusCode] $statusText: $message")
|
||||||
|
|
||||||
|
object Helpers {
|
||||||
|
|
||||||
|
// Helper to handle Optional header parameters
|
||||||
|
implicit class optionalParams(val request: RequestT[Identity, Either[String, String], Nothing]) extends AnyVal {
|
||||||
|
def header( header: String, optValue: Option[Any]): RequestT[Identity, Either[String, String], Nothing] = {
|
||||||
|
optValue.map( value => request.header(header, value.toString)).getOrElse(request)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
object ApiInvoker {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Allows request execution without calling apiInvoker.execute(request)
|
||||||
|
* request.result can be used to get a monad wrapped content.
|
||||||
|
*
|
||||||
|
* @param request the apiRequest to be executed
|
||||||
|
*/
|
||||||
|
implicit class ApiRequestImprovements[R[_], T](request: RequestT[Identity, Either[ResponseError[Exception], T], Nothing]) {
|
||||||
|
|
||||||
|
def result(implicit backend: SttpBackend[R, Nothing, Nothing]): R[T] = {
|
||||||
|
val responseT = request.send()
|
||||||
|
val ME: MonadError[R] = backend.responseMonad
|
||||||
|
ME.flatMap(responseT) {
|
||||||
|
response =>
|
||||||
|
response.body match {
|
||||||
|
case Left(ex) => ME.error[T](new HttpException(response.code, response.statusText, ex.body))
|
||||||
|
case Right(value) => ME.unit(value)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -2,17 +2,17 @@ package org.openapitools.client.core
|
|||||||
|
|
||||||
import java.time.{LocalDate, LocalDateTime, OffsetDateTime, ZoneId}
|
import java.time.{LocalDate, LocalDateTime, OffsetDateTime, ZoneId}
|
||||||
import java.time.format.DateTimeFormatter
|
import java.time.format.DateTimeFormatter
|
||||||
|
import scala.util.Try
|
||||||
import org.json4s.{Serializer, CustomSerializer, JNull}
|
import org.json4s.{Serializer, CustomSerializer, JNull}
|
||||||
import org.json4s.JsonAST.JString
|
import org.json4s.JsonAST.JString
|
||||||
|
|
||||||
import scala.util.Try
|
|
||||||
|
|
||||||
object Serializers {
|
object Serializers {
|
||||||
|
|
||||||
case object DateTimeSerializer extends CustomSerializer[OffsetDateTime]( _ => ( {
|
case object DateTimeSerializer extends CustomSerializer[OffsetDateTime](_ => ( {
|
||||||
case JString(s) =>
|
case JString(s) =>
|
||||||
Try(OffsetDateTime.parse(s, DateTimeFormatter.ISO_OFFSET_DATE_TIME)) orElse
|
Try(OffsetDateTime.parse(s, DateTimeFormatter.ISO_OFFSET_DATE_TIME)) orElse
|
||||||
Try(LocalDateTime.parse(s).atZone(ZoneId.systemDefault()).toOffsetDateTime) getOrElse null
|
Try(LocalDateTime.parse(s).atZone(ZoneId.systemDefault()).toOffsetDateTime) getOrElse (null)
|
||||||
|
case JNull => null
|
||||||
}, {
|
}, {
|
||||||
case d: OffsetDateTime =>
|
case d: OffsetDateTime =>
|
||||||
JString(d.format(DateTimeFormatter.ISO_OFFSET_DATE_TIME))
|
JString(d.format(DateTimeFormatter.ISO_OFFSET_DATE_TIME))
|
||||||
@@ -20,11 +20,12 @@ object Serializers {
|
|||||||
|
|
||||||
case object LocalDateSerializer extends CustomSerializer[LocalDate]( _ => ( {
|
case object LocalDateSerializer extends CustomSerializer[LocalDate]( _ => ( {
|
||||||
case JString(s) => LocalDate.parse(s)
|
case JString(s) => LocalDate.parse(s)
|
||||||
|
case JNull => null
|
||||||
}, {
|
}, {
|
||||||
case d: LocalDate =>
|
case d: LocalDate =>
|
||||||
JString(d.format(DateTimeFormatter.ISO_LOCAL_DATE))
|
JString(d.format(DateTimeFormatter.ISO_LOCAL_DATE))
|
||||||
}))
|
}))
|
||||||
|
|
||||||
def all: Seq[Serializer[_]] = Seq[Serializer[_]]() :+ DateTimeSerializer :+ LocalDateSerializer
|
def all: Seq[Serializer[_]] = Seq[Serializer[_]]() :+ LocalDateSerializer :+ DateTimeSerializer
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,58 @@
|
|||||||
|
/**
|
||||||
|
* OpenAPI Petstore
|
||||||
|
* This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
|
||||||
|
*
|
||||||
|
* The version of the OpenAPI document: 1.0.0
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
||||||
|
* https://openapi-generator.tech
|
||||||
|
* Do not edit the class manually.
|
||||||
|
*/
|
||||||
|
package org.openapitools.client.core
|
||||||
|
|
||||||
|
import sttp.client.{Identity, RequestT, ResponseError}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This trait needs to be added to any model defined by the api.
|
||||||
|
*/
|
||||||
|
trait ApiModel
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sttp type aliases
|
||||||
|
*/
|
||||||
|
object alias {
|
||||||
|
type ApiRequestT[T] = RequestT[Identity, Either[ResponseError[Exception], T], Nothing]
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Single trait defining a credential that can be transformed to a paramName / paramValue tupple
|
||||||
|
*/
|
||||||
|
sealed trait Credentials {
|
||||||
|
def asQueryParam: Option[(String, String)] = None
|
||||||
|
}
|
||||||
|
|
||||||
|
sealed case class BasicCredentials(user: String, password: String) extends Credentials
|
||||||
|
|
||||||
|
sealed case class BearerToken(token: String) extends Credentials
|
||||||
|
|
||||||
|
sealed case class ApiKeyCredentials(key: ApiKeyValue, keyName: String, location: ApiKeyLocation) extends Credentials {
|
||||||
|
override def asQueryParam: Option[(String, String)] = location match {
|
||||||
|
case ApiKeyLocations.QUERY => Some((keyName, key.value))
|
||||||
|
case _ => None
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
sealed case class ApiKeyValue(value: String)
|
||||||
|
|
||||||
|
sealed trait ApiKeyLocation
|
||||||
|
|
||||||
|
object ApiKeyLocations {
|
||||||
|
|
||||||
|
case object QUERY extends ApiKeyLocation
|
||||||
|
|
||||||
|
case object HEADER extends ApiKeyLocation
|
||||||
|
|
||||||
|
case object COOKIE extends ApiKeyLocation
|
||||||
|
|
||||||
|
}
|
||||||
@@ -13,7 +13,11 @@ package org.openapitools.client.model
|
|||||||
|
|
||||||
import org.openapitools.client.core.ApiModel
|
import org.openapitools.client.core.ApiModel
|
||||||
|
|
||||||
case class ApiResponse (
|
/**
|
||||||
|
* An uploaded response
|
||||||
|
* Describes the result of uploading an image resource
|
||||||
|
*/
|
||||||
|
case class ApiResponse(
|
||||||
code: Option[Int] = None,
|
code: Option[Int] = None,
|
||||||
`type`: Option[String] = None,
|
`type`: Option[String] = None,
|
||||||
message: Option[String] = None
|
message: Option[String] = None
|
||||||
@@ -13,7 +13,11 @@ package org.openapitools.client.model
|
|||||||
|
|
||||||
import org.openapitools.client.core.ApiModel
|
import org.openapitools.client.core.ApiModel
|
||||||
|
|
||||||
case class Category (
|
/**
|
||||||
|
* Pet category
|
||||||
|
* A category for a pet
|
||||||
|
*/
|
||||||
|
case class Category(
|
||||||
id: Option[Long] = None,
|
id: Option[Long] = None,
|
||||||
name: Option[String] = None
|
name: Option[String] = None
|
||||||
) extends ApiModel
|
) extends ApiModel
|
||||||
@@ -13,7 +13,7 @@ package org.openapitools.client.model
|
|||||||
|
|
||||||
import org.openapitools.client.core.ApiModel
|
import org.openapitools.client.core.ApiModel
|
||||||
|
|
||||||
case class InlineObject (
|
case class InlineObject(
|
||||||
/* Updated name of the pet */
|
/* Updated name of the pet */
|
||||||
name: Option[String] = None,
|
name: Option[String] = None,
|
||||||
/* Updated status of the pet */
|
/* Updated status of the pet */
|
||||||
@@ -14,7 +14,7 @@ package org.openapitools.client.model
|
|||||||
import java.io.File
|
import java.io.File
|
||||||
import org.openapitools.client.core.ApiModel
|
import org.openapitools.client.core.ApiModel
|
||||||
|
|
||||||
case class InlineObject1 (
|
case class InlineObject1(
|
||||||
/* Additional data to pass to server */
|
/* Additional data to pass to server */
|
||||||
additionalMetadata: Option[String] = None,
|
additionalMetadata: Option[String] = None,
|
||||||
/* file to upload */
|
/* file to upload */
|
||||||
@@ -14,7 +14,11 @@ package org.openapitools.client.model
|
|||||||
import java.time.OffsetDateTime
|
import java.time.OffsetDateTime
|
||||||
import org.openapitools.client.core.ApiModel
|
import org.openapitools.client.core.ApiModel
|
||||||
|
|
||||||
case class Order (
|
/**
|
||||||
|
* Pet Order
|
||||||
|
* An order for a pets from the pet store
|
||||||
|
*/
|
||||||
|
case class Order(
|
||||||
id: Option[Long] = None,
|
id: Option[Long] = None,
|
||||||
petId: Option[Long] = None,
|
petId: Option[Long] = None,
|
||||||
quantity: Option[Int] = None,
|
quantity: Option[Int] = None,
|
||||||
@@ -13,7 +13,11 @@ package org.openapitools.client.model
|
|||||||
|
|
||||||
import org.openapitools.client.core.ApiModel
|
import org.openapitools.client.core.ApiModel
|
||||||
|
|
||||||
case class Pet (
|
/**
|
||||||
|
* a Pet
|
||||||
|
* A pet for sale in the pet store
|
||||||
|
*/
|
||||||
|
case class Pet(
|
||||||
id: Option[Long] = None,
|
id: Option[Long] = None,
|
||||||
category: Option[Category] = None,
|
category: Option[Category] = None,
|
||||||
name: String,
|
name: String,
|
||||||
@@ -13,7 +13,11 @@ package org.openapitools.client.model
|
|||||||
|
|
||||||
import org.openapitools.client.core.ApiModel
|
import org.openapitools.client.core.ApiModel
|
||||||
|
|
||||||
case class Tag (
|
/**
|
||||||
|
* Pet Tag
|
||||||
|
* A tag for a pet
|
||||||
|
*/
|
||||||
|
case class Tag(
|
||||||
id: Option[Long] = None,
|
id: Option[Long] = None,
|
||||||
name: Option[String] = None
|
name: Option[String] = None
|
||||||
) extends ApiModel
|
) extends ApiModel
|
||||||
@@ -13,7 +13,11 @@ package org.openapitools.client.model
|
|||||||
|
|
||||||
import org.openapitools.client.core.ApiModel
|
import org.openapitools.client.core.ApiModel
|
||||||
|
|
||||||
case class User (
|
/**
|
||||||
|
* a User
|
||||||
|
* A User who is purchasing from the pet store
|
||||||
|
*/
|
||||||
|
case class User(
|
||||||
id: Option[Long] = None,
|
id: Option[Long] = None,
|
||||||
username: Option[String] = None,
|
username: Option[String] = None,
|
||||||
firstName: Option[String] = None,
|
firstName: Option[String] = None,
|
||||||
@@ -1 +1 @@
|
|||||||
4.3.0-SNAPSHOT
|
5.0.0-SNAPSHOT
|
||||||
@@ -4,6 +4,9 @@ import argonaut._
|
|||||||
import argonaut.EncodeJson._
|
import argonaut.EncodeJson._
|
||||||
import argonaut.DecodeJson._
|
import argonaut.DecodeJson._
|
||||||
|
|
||||||
|
import org.http4s._
|
||||||
|
import org.http4s.{EntityDecoder, EntityEncoder}
|
||||||
|
import org.http4s.argonaut._
|
||||||
import java.time.OffsetDateTime
|
import java.time.OffsetDateTime
|
||||||
|
|
||||||
object DateTimeCodecs {
|
object DateTimeCodecs {
|
||||||
|
|||||||
@@ -31,7 +31,9 @@ object PetApi {
|
|||||||
|
|
||||||
def escape(value: String): String = URLEncoder.encode(value, "utf-8").replaceAll("\\+", "%20")
|
def escape(value: String): String = URLEncoder.encode(value, "utf-8").replaceAll("\\+", "%20")
|
||||||
|
|
||||||
def addPet(host: String, body: Pet): Task[Unit] = {
|
def addPet(host: String, pet: Pet): Task[Pet] = {
|
||||||
|
implicit val returnTypeDecoder: EntityDecoder[Pet] = jsonOf[Pet]
|
||||||
|
|
||||||
val path = "/pet"
|
val path = "/pet"
|
||||||
|
|
||||||
val httpMethod = Method.POST
|
val httpMethod = Method.POST
|
||||||
@@ -44,8 +46,8 @@ object PetApi {
|
|||||||
for {
|
for {
|
||||||
uri <- Task.fromDisjunction(Uri.fromString(host + path))
|
uri <- Task.fromDisjunction(Uri.fromString(host + path))
|
||||||
uriWithParams = uri.copy(query = queryParams)
|
uriWithParams = uri.copy(query = queryParams)
|
||||||
req = Request(method = httpMethod, uri = uriWithParams, headers = headers.put(contentType)).withBody(body)
|
req = Request(method = httpMethod, uri = uriWithParams, headers = headers.put(contentType)).withBody(pet)
|
||||||
resp <- client.fetch[Unit](req)(_ => Task.now(()))
|
resp <- client.expect[Pet](req)
|
||||||
|
|
||||||
} yield resp
|
} yield resp
|
||||||
}
|
}
|
||||||
@@ -132,7 +134,9 @@ object PetApi {
|
|||||||
} yield resp
|
} yield resp
|
||||||
}
|
}
|
||||||
|
|
||||||
def updatePet(host: String, body: Pet): Task[Unit] = {
|
def updatePet(host: String, pet: Pet): Task[Pet] = {
|
||||||
|
implicit val returnTypeDecoder: EntityDecoder[Pet] = jsonOf[Pet]
|
||||||
|
|
||||||
val path = "/pet"
|
val path = "/pet"
|
||||||
|
|
||||||
val httpMethod = Method.PUT
|
val httpMethod = Method.PUT
|
||||||
@@ -145,8 +149,8 @@ object PetApi {
|
|||||||
for {
|
for {
|
||||||
uri <- Task.fromDisjunction(Uri.fromString(host + path))
|
uri <- Task.fromDisjunction(Uri.fromString(host + path))
|
||||||
uriWithParams = uri.copy(query = queryParams)
|
uriWithParams = uri.copy(query = queryParams)
|
||||||
req = Request(method = httpMethod, uri = uriWithParams, headers = headers.put(contentType)).withBody(body)
|
req = Request(method = httpMethod, uri = uriWithParams, headers = headers.put(contentType)).withBody(pet)
|
||||||
resp <- client.fetch[Unit](req)(_ => Task.now(()))
|
resp <- client.expect[Pet](req)
|
||||||
|
|
||||||
} yield resp
|
} yield resp
|
||||||
}
|
}
|
||||||
@@ -198,7 +202,9 @@ class HttpServicePetApi(service: HttpService) {
|
|||||||
|
|
||||||
def escape(value: String): String = URLEncoder.encode(value, "utf-8").replaceAll("\\+", "%20")
|
def escape(value: String): String = URLEncoder.encode(value, "utf-8").replaceAll("\\+", "%20")
|
||||||
|
|
||||||
def addPet(body: Pet): Task[Unit] = {
|
def addPet(pet: Pet): Task[Pet] = {
|
||||||
|
implicit val returnTypeDecoder: EntityDecoder[Pet] = jsonOf[Pet]
|
||||||
|
|
||||||
val path = "/pet"
|
val path = "/pet"
|
||||||
|
|
||||||
val httpMethod = Method.POST
|
val httpMethod = Method.POST
|
||||||
@@ -211,8 +217,8 @@ class HttpServicePetApi(service: HttpService) {
|
|||||||
for {
|
for {
|
||||||
uri <- Task.fromDisjunction(Uri.fromString(path))
|
uri <- Task.fromDisjunction(Uri.fromString(path))
|
||||||
uriWithParams = uri.copy(query = queryParams)
|
uriWithParams = uri.copy(query = queryParams)
|
||||||
req = Request(method = httpMethod, uri = uriWithParams, headers = headers.put(contentType)).withBody(body)
|
req = Request(method = httpMethod, uri = uriWithParams, headers = headers.put(contentType)).withBody(pet)
|
||||||
resp <- client.fetch[Unit](req)(_ => Task.now(()))
|
resp <- client.expect[Pet](req)
|
||||||
|
|
||||||
} yield resp
|
} yield resp
|
||||||
}
|
}
|
||||||
@@ -299,7 +305,9 @@ class HttpServicePetApi(service: HttpService) {
|
|||||||
} yield resp
|
} yield resp
|
||||||
}
|
}
|
||||||
|
|
||||||
def updatePet(body: Pet): Task[Unit] = {
|
def updatePet(pet: Pet): Task[Pet] = {
|
||||||
|
implicit val returnTypeDecoder: EntityDecoder[Pet] = jsonOf[Pet]
|
||||||
|
|
||||||
val path = "/pet"
|
val path = "/pet"
|
||||||
|
|
||||||
val httpMethod = Method.PUT
|
val httpMethod = Method.PUT
|
||||||
@@ -312,8 +320,8 @@ class HttpServicePetApi(service: HttpService) {
|
|||||||
for {
|
for {
|
||||||
uri <- Task.fromDisjunction(Uri.fromString(path))
|
uri <- Task.fromDisjunction(Uri.fromString(path))
|
||||||
uriWithParams = uri.copy(query = queryParams)
|
uriWithParams = uri.copy(query = queryParams)
|
||||||
req = Request(method = httpMethod, uri = uriWithParams, headers = headers.put(contentType)).withBody(body)
|
req = Request(method = httpMethod, uri = uriWithParams, headers = headers.put(contentType)).withBody(pet)
|
||||||
resp <- client.fetch[Unit](req)(_ => Task.now(()))
|
resp <- client.expect[Pet](req)
|
||||||
|
|
||||||
} yield resp
|
} yield resp
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -90,7 +90,7 @@ object StoreApi {
|
|||||||
} yield resp
|
} yield resp
|
||||||
}
|
}
|
||||||
|
|
||||||
def placeOrder(host: String, body: Order): Task[Order] = {
|
def placeOrder(host: String, order: Order): Task[Order] = {
|
||||||
implicit val returnTypeDecoder: EntityDecoder[Order] = jsonOf[Order]
|
implicit val returnTypeDecoder: EntityDecoder[Order] = jsonOf[Order]
|
||||||
|
|
||||||
val path = "/store/order"
|
val path = "/store/order"
|
||||||
@@ -105,7 +105,7 @@ object StoreApi {
|
|||||||
for {
|
for {
|
||||||
uri <- Task.fromDisjunction(Uri.fromString(host + path))
|
uri <- Task.fromDisjunction(Uri.fromString(host + path))
|
||||||
uriWithParams = uri.copy(query = queryParams)
|
uriWithParams = uri.copy(query = queryParams)
|
||||||
req = Request(method = httpMethod, uri = uriWithParams, headers = headers.put(contentType)).withBody(body)
|
req = Request(method = httpMethod, uri = uriWithParams, headers = headers.put(contentType)).withBody(order)
|
||||||
resp <- client.expect[Order](req)
|
resp <- client.expect[Order](req)
|
||||||
|
|
||||||
} yield resp
|
} yield resp
|
||||||
@@ -179,7 +179,7 @@ class HttpServiceStoreApi(service: HttpService) {
|
|||||||
} yield resp
|
} yield resp
|
||||||
}
|
}
|
||||||
|
|
||||||
def placeOrder(body: Order): Task[Order] = {
|
def placeOrder(order: Order): Task[Order] = {
|
||||||
implicit val returnTypeDecoder: EntityDecoder[Order] = jsonOf[Order]
|
implicit val returnTypeDecoder: EntityDecoder[Order] = jsonOf[Order]
|
||||||
|
|
||||||
val path = "/store/order"
|
val path = "/store/order"
|
||||||
@@ -194,7 +194,7 @@ class HttpServiceStoreApi(service: HttpService) {
|
|||||||
for {
|
for {
|
||||||
uri <- Task.fromDisjunction(Uri.fromString(path))
|
uri <- Task.fromDisjunction(Uri.fromString(path))
|
||||||
uriWithParams = uri.copy(query = queryParams)
|
uriWithParams = uri.copy(query = queryParams)
|
||||||
req = Request(method = httpMethod, uri = uriWithParams, headers = headers.put(contentType)).withBody(body)
|
req = Request(method = httpMethod, uri = uriWithParams, headers = headers.put(contentType)).withBody(order)
|
||||||
resp <- client.expect[Order](req)
|
resp <- client.expect[Order](req)
|
||||||
|
|
||||||
} yield resp
|
} yield resp
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ object UserApi {
|
|||||||
|
|
||||||
def escape(value: String): String = URLEncoder.encode(value, "utf-8").replaceAll("\\+", "%20")
|
def escape(value: String): String = URLEncoder.encode(value, "utf-8").replaceAll("\\+", "%20")
|
||||||
|
|
||||||
def createUser(host: String, body: User): Task[Unit] = {
|
def createUser(host: String, user: User): Task[Unit] = {
|
||||||
val path = "/user"
|
val path = "/user"
|
||||||
|
|
||||||
val httpMethod = Method.POST
|
val httpMethod = Method.POST
|
||||||
@@ -42,13 +42,13 @@ object UserApi {
|
|||||||
for {
|
for {
|
||||||
uri <- Task.fromDisjunction(Uri.fromString(host + path))
|
uri <- Task.fromDisjunction(Uri.fromString(host + path))
|
||||||
uriWithParams = uri.copy(query = queryParams)
|
uriWithParams = uri.copy(query = queryParams)
|
||||||
req = Request(method = httpMethod, uri = uriWithParams, headers = headers.put(contentType)).withBody(body)
|
req = Request(method = httpMethod, uri = uriWithParams, headers = headers.put(contentType)).withBody(user)
|
||||||
resp <- client.fetch[Unit](req)(_ => Task.now(()))
|
resp <- client.fetch[Unit](req)(_ => Task.now(()))
|
||||||
|
|
||||||
} yield resp
|
} yield resp
|
||||||
}
|
}
|
||||||
|
|
||||||
def createUsersWithArrayInput(host: String, body: List[User]): Task[Unit] = {
|
def createUsersWithArrayInput(host: String, user: List[User]): Task[Unit] = {
|
||||||
val path = "/user/createWithArray"
|
val path = "/user/createWithArray"
|
||||||
|
|
||||||
val httpMethod = Method.POST
|
val httpMethod = Method.POST
|
||||||
@@ -61,13 +61,13 @@ object UserApi {
|
|||||||
for {
|
for {
|
||||||
uri <- Task.fromDisjunction(Uri.fromString(host + path))
|
uri <- Task.fromDisjunction(Uri.fromString(host + path))
|
||||||
uriWithParams = uri.copy(query = queryParams)
|
uriWithParams = uri.copy(query = queryParams)
|
||||||
req = Request(method = httpMethod, uri = uriWithParams, headers = headers.put(contentType)).withBody(body)
|
req = Request(method = httpMethod, uri = uriWithParams, headers = headers.put(contentType)).withBody(user)
|
||||||
resp <- client.fetch[Unit](req)(_ => Task.now(()))
|
resp <- client.fetch[Unit](req)(_ => Task.now(()))
|
||||||
|
|
||||||
} yield resp
|
} yield resp
|
||||||
}
|
}
|
||||||
|
|
||||||
def createUsersWithListInput(host: String, body: List[User]): Task[Unit] = {
|
def createUsersWithListInput(host: String, user: List[User]): Task[Unit] = {
|
||||||
val path = "/user/createWithList"
|
val path = "/user/createWithList"
|
||||||
|
|
||||||
val httpMethod = Method.POST
|
val httpMethod = Method.POST
|
||||||
@@ -80,7 +80,7 @@ object UserApi {
|
|||||||
for {
|
for {
|
||||||
uri <- Task.fromDisjunction(Uri.fromString(host + path))
|
uri <- Task.fromDisjunction(Uri.fromString(host + path))
|
||||||
uriWithParams = uri.copy(query = queryParams)
|
uriWithParams = uri.copy(query = queryParams)
|
||||||
req = Request(method = httpMethod, uri = uriWithParams, headers = headers.put(contentType)).withBody(body)
|
req = Request(method = httpMethod, uri = uriWithParams, headers = headers.put(contentType)).withBody(user)
|
||||||
resp <- client.fetch[Unit](req)(_ => Task.now(()))
|
resp <- client.fetch[Unit](req)(_ => Task.now(()))
|
||||||
|
|
||||||
} yield resp
|
} yield resp
|
||||||
@@ -166,7 +166,7 @@ object UserApi {
|
|||||||
} yield resp
|
} yield resp
|
||||||
}
|
}
|
||||||
|
|
||||||
def updateUser(host: String, username: String, body: User): Task[Unit] = {
|
def updateUser(host: String, username: String, user: User): Task[Unit] = {
|
||||||
val path = "/user/{username}".replaceAll("\\{" + "username" + "\\}",escape(username.toString))
|
val path = "/user/{username}".replaceAll("\\{" + "username" + "\\}",escape(username.toString))
|
||||||
|
|
||||||
val httpMethod = Method.PUT
|
val httpMethod = Method.PUT
|
||||||
@@ -179,7 +179,7 @@ object UserApi {
|
|||||||
for {
|
for {
|
||||||
uri <- Task.fromDisjunction(Uri.fromString(host + path))
|
uri <- Task.fromDisjunction(Uri.fromString(host + path))
|
||||||
uriWithParams = uri.copy(query = queryParams)
|
uriWithParams = uri.copy(query = queryParams)
|
||||||
req = Request(method = httpMethod, uri = uriWithParams, headers = headers.put(contentType)).withBody(body)
|
req = Request(method = httpMethod, uri = uriWithParams, headers = headers.put(contentType)).withBody(user)
|
||||||
resp <- client.fetch[Unit](req)(_ => Task.now(()))
|
resp <- client.fetch[Unit](req)(_ => Task.now(()))
|
||||||
|
|
||||||
} yield resp
|
} yield resp
|
||||||
@@ -192,7 +192,7 @@ class HttpServiceUserApi(service: HttpService) {
|
|||||||
|
|
||||||
def escape(value: String): String = URLEncoder.encode(value, "utf-8").replaceAll("\\+", "%20")
|
def escape(value: String): String = URLEncoder.encode(value, "utf-8").replaceAll("\\+", "%20")
|
||||||
|
|
||||||
def createUser(body: User): Task[Unit] = {
|
def createUser(user: User): Task[Unit] = {
|
||||||
val path = "/user"
|
val path = "/user"
|
||||||
|
|
||||||
val httpMethod = Method.POST
|
val httpMethod = Method.POST
|
||||||
@@ -205,13 +205,13 @@ class HttpServiceUserApi(service: HttpService) {
|
|||||||
for {
|
for {
|
||||||
uri <- Task.fromDisjunction(Uri.fromString(path))
|
uri <- Task.fromDisjunction(Uri.fromString(path))
|
||||||
uriWithParams = uri.copy(query = queryParams)
|
uriWithParams = uri.copy(query = queryParams)
|
||||||
req = Request(method = httpMethod, uri = uriWithParams, headers = headers.put(contentType)).withBody(body)
|
req = Request(method = httpMethod, uri = uriWithParams, headers = headers.put(contentType)).withBody(user)
|
||||||
resp <- client.fetch[Unit](req)(_ => Task.now(()))
|
resp <- client.fetch[Unit](req)(_ => Task.now(()))
|
||||||
|
|
||||||
} yield resp
|
} yield resp
|
||||||
}
|
}
|
||||||
|
|
||||||
def createUsersWithArrayInput(body: List[User]): Task[Unit] = {
|
def createUsersWithArrayInput(user: List[User]): Task[Unit] = {
|
||||||
val path = "/user/createWithArray"
|
val path = "/user/createWithArray"
|
||||||
|
|
||||||
val httpMethod = Method.POST
|
val httpMethod = Method.POST
|
||||||
@@ -224,13 +224,13 @@ class HttpServiceUserApi(service: HttpService) {
|
|||||||
for {
|
for {
|
||||||
uri <- Task.fromDisjunction(Uri.fromString(path))
|
uri <- Task.fromDisjunction(Uri.fromString(path))
|
||||||
uriWithParams = uri.copy(query = queryParams)
|
uriWithParams = uri.copy(query = queryParams)
|
||||||
req = Request(method = httpMethod, uri = uriWithParams, headers = headers.put(contentType)).withBody(body)
|
req = Request(method = httpMethod, uri = uriWithParams, headers = headers.put(contentType)).withBody(user)
|
||||||
resp <- client.fetch[Unit](req)(_ => Task.now(()))
|
resp <- client.fetch[Unit](req)(_ => Task.now(()))
|
||||||
|
|
||||||
} yield resp
|
} yield resp
|
||||||
}
|
}
|
||||||
|
|
||||||
def createUsersWithListInput(body: List[User]): Task[Unit] = {
|
def createUsersWithListInput(user: List[User]): Task[Unit] = {
|
||||||
val path = "/user/createWithList"
|
val path = "/user/createWithList"
|
||||||
|
|
||||||
val httpMethod = Method.POST
|
val httpMethod = Method.POST
|
||||||
@@ -243,7 +243,7 @@ class HttpServiceUserApi(service: HttpService) {
|
|||||||
for {
|
for {
|
||||||
uri <- Task.fromDisjunction(Uri.fromString(path))
|
uri <- Task.fromDisjunction(Uri.fromString(path))
|
||||||
uriWithParams = uri.copy(query = queryParams)
|
uriWithParams = uri.copy(query = queryParams)
|
||||||
req = Request(method = httpMethod, uri = uriWithParams, headers = headers.put(contentType)).withBody(body)
|
req = Request(method = httpMethod, uri = uriWithParams, headers = headers.put(contentType)).withBody(user)
|
||||||
resp <- client.fetch[Unit](req)(_ => Task.now(()))
|
resp <- client.fetch[Unit](req)(_ => Task.now(()))
|
||||||
|
|
||||||
} yield resp
|
} yield resp
|
||||||
@@ -329,7 +329,7 @@ class HttpServiceUserApi(service: HttpService) {
|
|||||||
} yield resp
|
} yield resp
|
||||||
}
|
}
|
||||||
|
|
||||||
def updateUser(username: String, body: User): Task[Unit] = {
|
def updateUser(username: String, user: User): Task[Unit] = {
|
||||||
val path = "/user/{username}".replaceAll("\\{" + "username" + "\\}",escape(username.toString))
|
val path = "/user/{username}".replaceAll("\\{" + "username" + "\\}",escape(username.toString))
|
||||||
|
|
||||||
val httpMethod = Method.PUT
|
val httpMethod = Method.PUT
|
||||||
@@ -342,7 +342,7 @@ class HttpServiceUserApi(service: HttpService) {
|
|||||||
for {
|
for {
|
||||||
uri <- Task.fromDisjunction(Uri.fromString(path))
|
uri <- Task.fromDisjunction(Uri.fromString(path))
|
||||||
uriWithParams = uri.copy(query = queryParams)
|
uriWithParams = uri.copy(query = queryParams)
|
||||||
req = Request(method = httpMethod, uri = uriWithParams, headers = headers.put(contentType)).withBody(body)
|
req = Request(method = httpMethod, uri = uriWithParams, headers = headers.put(contentType)).withBody(user)
|
||||||
resp <- client.fetch[Unit](req)(_ => Task.now(()))
|
resp <- client.fetch[Unit](req)(_ => Task.now(()))
|
||||||
|
|
||||||
} yield resp
|
} yield resp
|
||||||
|
|||||||
@@ -1,27 +0,0 @@
|
|||||||
version := "1.0.0"
|
|
||||||
name := "scala-akka-petstore-client"
|
|
||||||
organization := "org.openapitools"
|
|
||||||
scalaVersion := "2.12.8"
|
|
||||||
|
|
||||||
libraryDependencies ++= Seq(
|
|
||||||
"com.typesafe" % "config" % "1.3.3",
|
|
||||||
"com.typesafe.akka" %% "akka-actor" % "2.5.21",
|
|
||||||
"com.typesafe.akka" %% "akka-stream" % "2.5.21",
|
|
||||||
"com.typesafe.akka" %% "akka-http" % "10.1.7",
|
|
||||||
"org.json4s" %% "json4s-jackson" % "3.6.5",
|
|
||||||
"org.json4s" %% "json4s-ext" % "3.6.5",
|
|
||||||
"de.heikoseeberger" %% "akka-http-json4s" % "1.25.2",
|
|
||||||
// test dependencies
|
|
||||||
"org.scalatest" %% "scalatest" % "3.0.5" % "test",
|
|
||||||
"junit" % "junit" % "4.13" % "test"
|
|
||||||
)
|
|
||||||
|
|
||||||
resolvers ++= Seq(Resolver.mavenLocal)
|
|
||||||
|
|
||||||
scalacOptions := Seq(
|
|
||||||
"-unchecked",
|
|
||||||
"-deprecation",
|
|
||||||
"-feature"
|
|
||||||
)
|
|
||||||
|
|
||||||
publishArtifact in (Compile, packageDoc) := false
|
|
||||||
@@ -1,254 +0,0 @@
|
|||||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
|
||||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
|
|
||||||
<modelVersion>4.0.0</modelVersion>
|
|
||||||
|
|
||||||
<name>scala-akka-petstore-client</name>
|
|
||||||
|
|
||||||
<groupId>org.openapitools</groupId>
|
|
||||||
<artifactId>scala-akka-petstore-client</artifactId>
|
|
||||||
<version>1.0.0</version>
|
|
||||||
|
|
||||||
<packaging>jar</packaging>
|
|
||||||
|
|
||||||
<properties>
|
|
||||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
|
||||||
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
|
|
||||||
|
|
||||||
<java.version>1.8</java.version>
|
|
||||||
<scala.version>2.12.8</scala.version>
|
|
||||||
<json4s.jackson.version>3.5.3</json4s.jackson.version>
|
|
||||||
<json4s.ext.version>3.2.11</json4s.ext.version>
|
|
||||||
<akka.version>2.5.21</akka.version>
|
|
||||||
<akka.http.version>10.1.7</akka.http.version>
|
|
||||||
<typesafeconfig.version>1.3.3</typesafeconfig.version>
|
|
||||||
<akka.http.json4s.version>1.25.2</akka.http.json4s.version>
|
|
||||||
<junit.version>4.13</junit.version>
|
|
||||||
<scala.test.version>3.0.5</scala.test.version>
|
|
||||||
|
|
||||||
<scala.maven.plugin.version>3.3.1</scala.maven.plugin.version>
|
|
||||||
</properties>
|
|
||||||
|
|
||||||
<dependencies>
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.scala-lang</groupId>
|
|
||||||
<artifactId>scala-library</artifactId>
|
|
||||||
<version>${scala.version}</version>
|
|
||||||
<scope>provided</scope>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.typesafe</groupId>
|
|
||||||
<artifactId>config</artifactId>
|
|
||||||
<version>${typesafeconfig.version}</version>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.typesafe.akka</groupId>
|
|
||||||
<artifactId>akka-actor_2.12</artifactId>
|
|
||||||
<version>${akka.version}</version>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.typesafe.akka</groupId>
|
|
||||||
<artifactId>akka-stream_2.12</artifactId>
|
|
||||||
<version>${akka.version}</version>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.typesafe.akka</groupId>
|
|
||||||
<artifactId>akka-http_2.12</artifactId>
|
|
||||||
<version>${akka.http.version}</version>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.json4s</groupId>
|
|
||||||
<artifactId>json4s-jackson_2.12</artifactId>
|
|
||||||
<version>${json4s.jackson.version}</version>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.json4s</groupId>
|
|
||||||
<artifactId>json4s-ext_2.12</artifactId>
|
|
||||||
<version>${json4s.jackson.version}</version>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>de.heikoseeberger</groupId>
|
|
||||||
<artifactId>akka-http-json4s_2.12</artifactId>
|
|
||||||
<version>${akka.http.json4s.version}</version>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<!--test dependencies-->
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.scalatest</groupId>
|
|
||||||
<artifactId>scalatest_2.12</artifactId>
|
|
||||||
<version>${scala.test.version}</version>
|
|
||||||
<scope>test</scope>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>junit</groupId>
|
|
||||||
<artifactId>junit</artifactId>
|
|
||||||
<version>${junit.version}</version>
|
|
||||||
<scope>test</scope>
|
|
||||||
</dependency>
|
|
||||||
</dependencies>
|
|
||||||
|
|
||||||
<build>
|
|
||||||
<plugins>
|
|
||||||
<plugin>
|
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
|
||||||
<artifactId>maven-deploy-plugin</artifactId>
|
|
||||||
<version>2.8.2</version>
|
|
||||||
</plugin>
|
|
||||||
<plugin>
|
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
|
||||||
<artifactId>maven-javadoc-plugin</artifactId>
|
|
||||||
<version>3.0.0</version>
|
|
||||||
</plugin>
|
|
||||||
<plugin>
|
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
|
||||||
<artifactId>maven-source-plugin</artifactId>
|
|
||||||
<version>3.0.1</version>
|
|
||||||
</plugin>
|
|
||||||
<plugin>
|
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
|
||||||
<artifactId>maven-enforcer-plugin</artifactId>
|
|
||||||
<version>3.0.0-M1</version>
|
|
||||||
<executions>
|
|
||||||
<execution>
|
|
||||||
<id>enforce-maven</id>
|
|
||||||
<goals>
|
|
||||||
<goal>enforce</goal>
|
|
||||||
</goals>
|
|
||||||
<configuration>
|
|
||||||
<rules>
|
|
||||||
<requireMavenVersion>
|
|
||||||
<version>2.2.0</version>
|
|
||||||
</requireMavenVersion>
|
|
||||||
</rules>
|
|
||||||
</configuration>
|
|
||||||
</execution>
|
|
||||||
</executions>
|
|
||||||
</plugin>
|
|
||||||
<plugin>
|
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
|
||||||
<artifactId>maven-surefire-plugin</artifactId>
|
|
||||||
<version>3.0.0-M4</version>
|
|
||||||
<configuration>
|
|
||||||
<systemProperties>
|
|
||||||
<property>
|
|
||||||
<name>loggerPath</name>
|
|
||||||
<value>conf/log4j.properties</value>
|
|
||||||
</property>
|
|
||||||
</systemProperties>
|
|
||||||
<argLine>-Xms512m -Xmx1500m</argLine>
|
|
||||||
<parallel>methods</parallel>
|
|
||||||
<threadCount>4</threadCount>
|
|
||||||
<forkMode>pertest</forkMode>
|
|
||||||
</configuration>
|
|
||||||
</plugin>
|
|
||||||
<plugin>
|
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
|
||||||
<artifactId>maven-dependency-plugin</artifactId>
|
|
||||||
<version>3.0.2</version>
|
|
||||||
<executions>
|
|
||||||
<execution>
|
|
||||||
<phase>package</phase>
|
|
||||||
<goals>
|
|
||||||
<goal>copy-dependencies</goal>
|
|
||||||
</goals>
|
|
||||||
<configuration>
|
|
||||||
<outputDirectory>${project.build.directory}/lib</outputDirectory>
|
|
||||||
</configuration>
|
|
||||||
</execution>
|
|
||||||
</executions>
|
|
||||||
</plugin>
|
|
||||||
|
|
||||||
<!-- attach test jar -->
|
|
||||||
<plugin>
|
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
|
||||||
<artifactId>maven-jar-plugin</artifactId>
|
|
||||||
<version>2.6</version>
|
|
||||||
<executions>
|
|
||||||
<execution>
|
|
||||||
<goals>
|
|
||||||
<goal>jar</goal>
|
|
||||||
<goal>test-jar</goal>
|
|
||||||
</goals>
|
|
||||||
</execution>
|
|
||||||
</executions>
|
|
||||||
<configuration>
|
|
||||||
</configuration>
|
|
||||||
</plugin>
|
|
||||||
|
|
||||||
<plugin>
|
|
||||||
<groupId>org.codehaus.mojo</groupId>
|
|
||||||
<artifactId>build-helper-maven-plugin</artifactId>
|
|
||||||
<version>3.0.0</version>
|
|
||||||
<executions>
|
|
||||||
<execution>
|
|
||||||
<id>add_sources</id>
|
|
||||||
<phase>generate-sources</phase>
|
|
||||||
<goals>
|
|
||||||
<goal>add-source</goal>
|
|
||||||
</goals>
|
|
||||||
<configuration>
|
|
||||||
<sources>
|
|
||||||
<source>
|
|
||||||
src/main/java
|
|
||||||
</source>
|
|
||||||
</sources>
|
|
||||||
</configuration>
|
|
||||||
</execution>
|
|
||||||
<execution>
|
|
||||||
<id>add_test_sources</id>
|
|
||||||
<phase>generate-test-sources</phase>
|
|
||||||
<goals>
|
|
||||||
<goal>add-test-source</goal>
|
|
||||||
</goals>
|
|
||||||
<configuration>
|
|
||||||
<sources>
|
|
||||||
<source>
|
|
||||||
src/test/java
|
|
||||||
</source>
|
|
||||||
</sources>
|
|
||||||
</configuration>
|
|
||||||
</execution>
|
|
||||||
</executions>
|
|
||||||
</plugin>
|
|
||||||
<plugin>
|
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
|
||||||
<artifactId>maven-compiler-plugin</artifactId>
|
|
||||||
<version>3.7.0</version>
|
|
||||||
<configuration>
|
|
||||||
<source>${java.version}</source>
|
|
||||||
<target>${java.version}</target>
|
|
||||||
</configuration>
|
|
||||||
</plugin>
|
|
||||||
<plugin>
|
|
||||||
<groupId>net.alchim31.maven</groupId>
|
|
||||||
<artifactId>scala-maven-plugin</artifactId>
|
|
||||||
<version>${scala.maven.plugin.version}</version>
|
|
||||||
<executions>
|
|
||||||
<execution>
|
|
||||||
<id>scala-compile-first</id>
|
|
||||||
<phase>process-resources</phase>
|
|
||||||
<goals>
|
|
||||||
<goal>add-source</goal>
|
|
||||||
<goal>compile</goal>
|
|
||||||
</goals>
|
|
||||||
</execution>
|
|
||||||
<execution>
|
|
||||||
<id>scala-test-compile</id>
|
|
||||||
<phase>process-test-resources</phase>
|
|
||||||
<goals>
|
|
||||||
<goal>testCompile</goal>
|
|
||||||
</goals>
|
|
||||||
</execution>
|
|
||||||
</executions>
|
|
||||||
<configuration>
|
|
||||||
<args>
|
|
||||||
<arg>-feature</arg>
|
|
||||||
</args>
|
|
||||||
<jvmArgs>
|
|
||||||
<jvmArg>-Xms128m</jvmArg>
|
|
||||||
<jvmArg>-Xmx1500m</jvmArg>
|
|
||||||
</jvmArgs>
|
|
||||||
</configuration>
|
|
||||||
</plugin>
|
|
||||||
</plugins>
|
|
||||||
</build>
|
|
||||||
</project>
|
|
||||||
@@ -1,24 +0,0 @@
|
|||||||
org.openapitools.client {
|
|
||||||
|
|
||||||
apiRequest {
|
|
||||||
|
|
||||||
compression {
|
|
||||||
enabled: false
|
|
||||||
size-threshold: 0
|
|
||||||
}
|
|
||||||
|
|
||||||
trust-certificates: true
|
|
||||||
|
|
||||||
connection-timeout: 5000ms
|
|
||||||
|
|
||||||
default-headers {
|
|
||||||
"userAgent": "scala-akka-petstore-client_1.0.0"
|
|
||||||
}
|
|
||||||
|
|
||||||
// let you define custom http status code, as in :
|
|
||||||
// { code: 601, reason: "some custom http status code", success: false }
|
|
||||||
custom-codes : []
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
spray.can.host-connector.max-redirects = 10
|
|
||||||
@@ -1,175 +0,0 @@
|
|||||||
/**
|
|
||||||
* OpenAPI Petstore
|
|
||||||
* This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
|
|
||||||
*
|
|
||||||
* The version of the OpenAPI document: 1.0.0
|
|
||||||
*
|
|
||||||
*
|
|
||||||
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
|
||||||
* https://openapi-generator.tech
|
|
||||||
* Do not edit the class manually.
|
|
||||||
*/
|
|
||||||
package org.openapitools.client.api
|
|
||||||
|
|
||||||
import org.openapitools.client.model.User
|
|
||||||
import org.openapitools.client.core._
|
|
||||||
import org.openapitools.client.core.CollectionFormats._
|
|
||||||
import org.openapitools.client.core.ApiKeyLocations._
|
|
||||||
|
|
||||||
object UserApi {
|
|
||||||
|
|
||||||
def apply(baseUrl: String = "http://petstore.swagger.io/v2") = new UserApi(baseUrl)
|
|
||||||
}
|
|
||||||
|
|
||||||
class UserApi(baseUrl: String) {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* This can only be done by the logged in user.
|
|
||||||
*
|
|
||||||
* Expected answers:
|
|
||||||
* code 0 : (successful operation)
|
|
||||||
*
|
|
||||||
* Available security schemes:
|
|
||||||
* auth_cookie (apiKey)
|
|
||||||
*
|
|
||||||
* @param user Created user object
|
|
||||||
*/
|
|
||||||
def createUser(user: User)(implicit apiKey: ApiKeyValue): ApiRequest[Unit] =
|
|
||||||
ApiRequest[Unit](ApiMethods.POST, baseUrl, "/user", "application/json")
|
|
||||||
.withApiKey(apiKey, "AUTH_KEY", COOKIE)
|
|
||||||
.withBody(user)
|
|
||||||
.withDefaultSuccessResponse[Unit]
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Expected answers:
|
|
||||||
* code 0 : (successful operation)
|
|
||||||
*
|
|
||||||
* Available security schemes:
|
|
||||||
* auth_cookie (apiKey)
|
|
||||||
*
|
|
||||||
* @param user List of user object
|
|
||||||
*/
|
|
||||||
def createUsersWithArrayInput(user: Seq[User])(implicit apiKey: ApiKeyValue): ApiRequest[Unit] =
|
|
||||||
ApiRequest[Unit](ApiMethods.POST, baseUrl, "/user/createWithArray", "application/json")
|
|
||||||
.withApiKey(apiKey, "AUTH_KEY", COOKIE)
|
|
||||||
.withBody(user)
|
|
||||||
.withDefaultSuccessResponse[Unit]
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Expected answers:
|
|
||||||
* code 0 : (successful operation)
|
|
||||||
*
|
|
||||||
* Available security schemes:
|
|
||||||
* auth_cookie (apiKey)
|
|
||||||
*
|
|
||||||
* @param user List of user object
|
|
||||||
*/
|
|
||||||
def createUsersWithListInput(user: Seq[User])(implicit apiKey: ApiKeyValue): ApiRequest[Unit] =
|
|
||||||
ApiRequest[Unit](ApiMethods.POST, baseUrl, "/user/createWithList", "application/json")
|
|
||||||
.withApiKey(apiKey, "AUTH_KEY", COOKIE)
|
|
||||||
.withBody(user)
|
|
||||||
.withDefaultSuccessResponse[Unit]
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* This can only be done by the logged in user.
|
|
||||||
*
|
|
||||||
* Expected answers:
|
|
||||||
* code 400 : (Invalid username supplied)
|
|
||||||
* code 404 : (User not found)
|
|
||||||
*
|
|
||||||
* Available security schemes:
|
|
||||||
* auth_cookie (apiKey)
|
|
||||||
*
|
|
||||||
* @param username The name that needs to be deleted
|
|
||||||
*/
|
|
||||||
def deleteUser(username: String)(implicit apiKey: ApiKeyValue): ApiRequest[Unit] =
|
|
||||||
ApiRequest[Unit](ApiMethods.DELETE, baseUrl, "/user/{username}", "application/json")
|
|
||||||
.withApiKey(apiKey, "AUTH_KEY", COOKIE)
|
|
||||||
.withPathParam("username", username)
|
|
||||||
.withErrorResponse[Unit](400)
|
|
||||||
.withErrorResponse[Unit](404)
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Expected answers:
|
|
||||||
* code 200 : User (successful operation)
|
|
||||||
* code 400 : (Invalid username supplied)
|
|
||||||
* code 404 : (User not found)
|
|
||||||
*
|
|
||||||
* @param username The name that needs to be fetched. Use user1 for testing.
|
|
||||||
*/
|
|
||||||
def getUserByName(username: String): ApiRequest[User] =
|
|
||||||
ApiRequest[User](ApiMethods.GET, baseUrl, "/user/{username}", "application/json")
|
|
||||||
.withPathParam("username", username)
|
|
||||||
.withSuccessResponse[User](200)
|
|
||||||
.withErrorResponse[Unit](400)
|
|
||||||
.withErrorResponse[Unit](404)
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Expected answers:
|
|
||||||
* code 200 : String (successful operation)
|
|
||||||
* Headers :
|
|
||||||
* Set-Cookie - Cookie authentication key for use with the `auth_cookie` apiKey authentication.
|
|
||||||
* X-Rate-Limit - calls per hour allowed by the user
|
|
||||||
* X-Expires-After - date in UTC when toekn expires
|
|
||||||
* code 400 : (Invalid username/password supplied)
|
|
||||||
*
|
|
||||||
* @param username The user name for login
|
|
||||||
* @param password The password for login in clear text
|
|
||||||
*/
|
|
||||||
def loginUser(username: String, password: String): ApiRequest[String] =
|
|
||||||
ApiRequest[String](ApiMethods.GET, baseUrl, "/user/login", "application/json")
|
|
||||||
.withQueryParam("username", username)
|
|
||||||
.withQueryParam("password", password)
|
|
||||||
.withSuccessResponse[String](200)
|
|
||||||
.withErrorResponse[Unit](400)
|
|
||||||
|
|
||||||
object LoginUserHeaders {
|
|
||||||
def setCookie(r: ApiReturnWithHeaders) = r.getStringHeader("Set-Cookie")
|
|
||||||
def xRateLimit(r: ApiReturnWithHeaders) = r.getIntHeader("X-Rate-Limit")
|
|
||||||
def xExpiresAfter(r: ApiReturnWithHeaders) = r.getOffsetDateTimeHeader("X-Expires-After")
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Expected answers:
|
|
||||||
* code 0 : (successful operation)
|
|
||||||
*
|
|
||||||
* Available security schemes:
|
|
||||||
* auth_cookie (apiKey)
|
|
||||||
*/
|
|
||||||
def logoutUser()(implicit apiKey: ApiKeyValue): ApiRequest[Unit] =
|
|
||||||
ApiRequest[Unit](ApiMethods.GET, baseUrl, "/user/logout", "application/json")
|
|
||||||
.withApiKey(apiKey, "AUTH_KEY", COOKIE)
|
|
||||||
.withDefaultSuccessResponse[Unit]
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* This can only be done by the logged in user.
|
|
||||||
*
|
|
||||||
* Expected answers:
|
|
||||||
* code 400 : (Invalid user supplied)
|
|
||||||
* code 404 : (User not found)
|
|
||||||
*
|
|
||||||
* Available security schemes:
|
|
||||||
* auth_cookie (apiKey)
|
|
||||||
*
|
|
||||||
* @param username name that need to be deleted
|
|
||||||
* @param user Updated user object
|
|
||||||
*/
|
|
||||||
def updateUser(username: String, user: User)(implicit apiKey: ApiKeyValue): ApiRequest[Unit] =
|
|
||||||
ApiRequest[Unit](ApiMethods.PUT, baseUrl, "/user/{username}", "application/json")
|
|
||||||
.withApiKey(apiKey, "AUTH_KEY", COOKIE)
|
|
||||||
.withBody(user)
|
|
||||||
.withPathParam("username", username)
|
|
||||||
.withErrorResponse[Unit](400)
|
|
||||||
.withErrorResponse[Unit](404)
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@@ -1,291 +0,0 @@
|
|||||||
/**
|
|
||||||
* OpenAPI Petstore
|
|
||||||
* This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
|
|
||||||
*
|
|
||||||
* The version of the OpenAPI document: 1.0.0
|
|
||||||
*
|
|
||||||
*
|
|
||||||
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
|
||||||
* https://openapi-generator.tech
|
|
||||||
* Do not edit the class manually.
|
|
||||||
*/
|
|
||||||
package org.openapitools.client.core
|
|
||||||
|
|
||||||
import java.io.File
|
|
||||||
|
|
||||||
import akka.actor.ActorSystem
|
|
||||||
import akka.http.scaladsl.Http
|
|
||||||
import akka.http.scaladsl.coding._
|
|
||||||
import akka.http.scaladsl.model.Multipart.FormData.BodyPart
|
|
||||||
import akka.http.scaladsl.model.Uri.Query
|
|
||||||
import akka.http.scaladsl.model._
|
|
||||||
import akka.http.scaladsl.model.headers._
|
|
||||||
import akka.http.scaladsl.unmarshalling.{ Unmarshal, Unmarshaller }
|
|
||||||
import akka.stream.ActorMaterializer
|
|
||||||
import akka.stream.scaladsl.Source
|
|
||||||
import akka.util.{ ByteString, Timeout }
|
|
||||||
import de.heikoseeberger.akkahttpjson4s.Json4sSupport
|
|
||||||
import org.json4s._
|
|
||||||
import org.json4s.jackson.JsonMethods._
|
|
||||||
import org.json4s.jackson.Serialization
|
|
||||||
|
|
||||||
import scala.collection.immutable
|
|
||||||
import scala.concurrent.{ ExecutionContext, ExecutionContextExecutor, Future }
|
|
||||||
import scala.reflect.ClassTag
|
|
||||||
|
|
||||||
object ApiInvoker {
|
|
||||||
|
|
||||||
def apply()(implicit system: ActorSystem): ApiInvoker =
|
|
||||||
apply(DefaultFormats ++ Serializers.all)
|
|
||||||
|
|
||||||
def apply(serializers: Iterable[Serializer[_]])(implicit system: ActorSystem): ApiInvoker =
|
|
||||||
apply(DefaultFormats ++ Serializers.all ++ serializers)
|
|
||||||
|
|
||||||
def apply(formats: Formats)(implicit system: ActorSystem): ApiInvoker = new ApiInvoker(formats)
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Allows request execution without calling apiInvoker.execute(request)
|
|
||||||
* request.response can be used to get a future of the ApiResponse generated.
|
|
||||||
* request.result can be used to get a future of the expected ApiResponse content. If content doesn't match, a
|
|
||||||
* Future will failed with a ClassCastException
|
|
||||||
*
|
|
||||||
* @param request the apiRequest to be executed
|
|
||||||
*/
|
|
||||||
implicit class ApiRequestImprovements[T: Manifest](request: ApiRequest[T]) {
|
|
||||||
|
|
||||||
def response(invoker: ApiInvoker)(implicit ec: ExecutionContext, system: ActorSystem): Future[ApiResponse[T]] =
|
|
||||||
response(ec, system, invoker)
|
|
||||||
|
|
||||||
def response(implicit ec: ExecutionContext, system: ActorSystem, invoker: ApiInvoker): Future[ApiResponse[T]] =
|
|
||||||
invoker.execute(request)
|
|
||||||
|
|
||||||
def result[U <: T](implicit c: ClassTag[U], ec: ExecutionContext, system: ActorSystem, invoker: ApiInvoker): Future[U] =
|
|
||||||
invoker.execute(request).map(_.content).mapTo[U]
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Allows transformation from ApiMethod to spray HttpMethods
|
|
||||||
*
|
|
||||||
* @param method the ApiMethod to be converted
|
|
||||||
*/
|
|
||||||
implicit class ApiMethodExtensions(val method: ApiMethod) {
|
|
||||||
def toAkkaHttpMethod: HttpMethod = HttpMethods.getForKey(method.value).getOrElse(HttpMethods.GET)
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
trait UnitJSONSupport {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
class ApiInvoker(formats: Formats)(implicit system: ActorSystem) extends CustomContentTypes with Json4sSupport {
|
|
||||||
|
|
||||||
import org.openapitools.client.core.ApiInvoker._
|
|
||||||
import org.openapitools.client.core.ParametersMap._
|
|
||||||
|
|
||||||
implicit val ec: ExecutionContextExecutor = system.dispatcher
|
|
||||||
implicit val jsonFormats: Formats = formats
|
|
||||||
|
|
||||||
protected val settings: ApiSettings = ApiSettings(system)
|
|
||||||
|
|
||||||
private implicit val materializer: ActorMaterializer = ActorMaterializer()
|
|
||||||
private implicit val serialization: Serialization = jackson.Serialization
|
|
||||||
|
|
||||||
|
|
||||||
private val http = Http()
|
|
||||||
|
|
||||||
val CompressionFilter: HttpMessage ⇒ Boolean = (msg: HttpMessage) =>
|
|
||||||
Seq(
|
|
||||||
{ _: HttpMessage => settings.compressionEnabled },
|
|
||||||
Encoder.DefaultFilter,
|
|
||||||
(message: HttpMessage) => {
|
|
||||||
val long = message.entity().getContentLengthOption()
|
|
||||||
if (long.isPresent) long.getAsLong > settings.compressionSizeThreshold else true
|
|
||||||
}
|
|
||||||
)
|
|
||||||
.map(f => f(msg))
|
|
||||||
.forall(identity)
|
|
||||||
|
|
||||||
|
|
||||||
private def addAuthentication(credentialsSeq: Seq[Credentials]) = {
|
|
||||||
request: HttpRequest =>
|
|
||||||
credentialsSeq.foldLeft(request) {
|
|
||||||
case (req, BasicCredentials(login, password)) =>
|
|
||||||
req.withHeaders(Authorization(BasicHttpCredentials(login, password)))
|
|
||||||
case (req, ApiKeyCredentials(keyValue, keyName, ApiKeyLocations.HEADER)) =>
|
|
||||||
req.withHeaders(RawHeader(keyName, keyValue.value))
|
|
||||||
case (req, BearerToken(token)) =>
|
|
||||||
req.withHeaders(RawHeader("Authorization", s"Bearer $token"))
|
|
||||||
case (req, _) => req
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private def headers(headers: Map[String, Any]): immutable.Seq[HttpHeader] =
|
|
||||||
headers.asFormattedParams
|
|
||||||
.map { case (name, value) => RawHeader(name, value.toString) }
|
|
||||||
.to[immutable.Seq]
|
|
||||||
|
|
||||||
|
|
||||||
private def bodyPart(name: String, value: Any): BodyPart = {
|
|
||||||
value match {
|
|
||||||
case f: File =>
|
|
||||||
BodyPart.fromFile(
|
|
||||||
name,
|
|
||||||
ContentType(MediaTypes.`application/octet-stream`),
|
|
||||||
f,
|
|
||||||
f.length().toInt
|
|
||||||
)
|
|
||||||
case v: String =>
|
|
||||||
BodyPart.Strict(name, v.toString)
|
|
||||||
case NumericValue(v) =>
|
|
||||||
BodyPart.Strict(name, v.toString)
|
|
||||||
case m: ApiModel =>
|
|
||||||
BodyPart.Strict(name, Serialization.write(m))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
private def formDataContent(request: ApiRequest[_]) = {
|
|
||||||
val params = request.formParams.asFormattedParams
|
|
||||||
if (params.isEmpty)
|
|
||||||
None
|
|
||||||
else
|
|
||||||
Some(
|
|
||||||
normalizedContentType(request.contentType).mediaType match {
|
|
||||||
case MediaTypes.`multipart/form-data` =>
|
|
||||||
Multipart.FormData(Source(params.toList.map { case (name, value) => bodyPart(name, value) }))
|
|
||||||
case MediaTypes.`application/x-www-form-urlencoded` =>
|
|
||||||
FormData(params.mapValues(_.toString))
|
|
||||||
case _: MediaType => // Default : application/x-www-form-urlencoded.
|
|
||||||
FormData(params.mapValues(_.toString))
|
|
||||||
}
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
private def bodyContent(request: ApiRequest[_]): Option[Any] = request
|
|
||||||
.bodyParam
|
|
||||||
.map(Extraction.decompose)
|
|
||||||
.map(compact)
|
|
||||||
|
|
||||||
private def createRequest(uri: Uri, request: ApiRequest[_]): HttpRequest = {
|
|
||||||
val httpRequest = request.method.toAkkaHttpMethod match {
|
|
||||||
case m@(HttpMethods.GET | HttpMethods.DELETE) => HttpRequest(m, uri)
|
|
||||||
case m@(HttpMethods.POST | HttpMethods.PUT | HttpMethods.PATCH) =>
|
|
||||||
formDataContent(request) orElse bodyContent(request) match {
|
|
||||||
case Some(c: FormData) =>
|
|
||||||
HttpRequest(m, uri, entity = c.toEntity)
|
|
||||||
case Some(c: Multipart.FormData) =>
|
|
||||||
HttpRequest(m, uri, entity = c.toEntity)
|
|
||||||
case Some(c: String) =>
|
|
||||||
HttpRequest(m, uri, entity = HttpEntity(normalizedContentType(request.contentType), ByteString(c)))
|
|
||||||
case _ =>
|
|
||||||
HttpRequest(m, uri, entity = HttpEntity(normalizedContentType(request.contentType), ByteString(" ")))
|
|
||||||
}
|
|
||||||
case m: HttpMethod => HttpRequest(m, uri)
|
|
||||||
}
|
|
||||||
|
|
||||||
addAuthentication(request.credentials)(
|
|
||||||
httpRequest.withHeaders(headers(request.headerParams))
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
def makeQuery(r: ApiRequest[_]): Query = {
|
|
||||||
r.credentials.foldLeft(r.queryParams) {
|
|
||||||
case (params, ApiKeyCredentials(key, keyName, ApiKeyLocations.QUERY)) =>
|
|
||||||
params + (keyName -> key.value)
|
|
||||||
case (params, _) => params
|
|
||||||
}.asFormattedParams
|
|
||||||
.mapValues(_.toString)
|
|
||||||
.foldRight[Query](Uri.Query.Empty) {
|
|
||||||
case ((name, value), acc) => acc.+:(name, value)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
def makeUri(r: ApiRequest[_]): Uri = {
|
|
||||||
val opPath = r.operationPath.replaceAll("\\{format\\}", "json")
|
|
||||||
val opPathWithParams = r.pathParams.asFormattedParams
|
|
||||||
.mapValues(_.toString)
|
|
||||||
.foldLeft(opPath) {
|
|
||||||
case (path, (name, value)) => path.replaceAll(s"\\{$name\\}", value)
|
|
||||||
}
|
|
||||||
val query = makeQuery(r)
|
|
||||||
|
|
||||||
Uri(r.basePath + opPathWithParams).withQuery(query)
|
|
||||||
}
|
|
||||||
|
|
||||||
def execute[T: Manifest](r: ApiRequest[T]): Future[ApiResponse[T]] = {
|
|
||||||
implicit val timeout: Timeout = settings.connectionTimeout
|
|
||||||
|
|
||||||
val request = createRequest(makeUri(r), r)
|
|
||||||
|
|
||||||
http
|
|
||||||
.singleRequest(request)
|
|
||||||
.map { response =>
|
|
||||||
val decoder: Coder with StreamDecoder = response.encoding match {
|
|
||||||
case HttpEncodings.gzip ⇒
|
|
||||||
Gzip
|
|
||||||
case HttpEncodings.deflate ⇒
|
|
||||||
Deflate
|
|
||||||
case HttpEncodings.identity ⇒
|
|
||||||
NoCoding
|
|
||||||
case HttpEncoding(encoding) =>
|
|
||||||
throw new IllegalArgumentException(s"Unsupported encoding: $encoding")
|
|
||||||
}
|
|
||||||
|
|
||||||
decoder.decodeMessage(response)
|
|
||||||
}
|
|
||||||
.flatMap(unmarshallApiResponse(r))
|
|
||||||
}
|
|
||||||
|
|
||||||
def unmarshallApiResponse[T: Manifest](request: ApiRequest[T])(response: HttpResponse): Future[ApiResponse[T]] = {
|
|
||||||
def responseForState[V](state: ResponseState, value: V): ApiResponse[V] = {
|
|
||||||
state match {
|
|
||||||
case ResponseState.Success =>
|
|
||||||
ApiResponse(response.status.intValue, value, response.headers.map(header => (header.name, header.value)).toMap)
|
|
||||||
case ResponseState.Error =>
|
|
||||||
throw ApiError(
|
|
||||||
response.status.intValue,
|
|
||||||
"Error response received",
|
|
||||||
Some(value),
|
|
||||||
headers = response.headers.map(header => (header.name, header.value)).toMap
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
val mf = implicitly(manifest[T])
|
|
||||||
request
|
|
||||||
.responseForCode(response.status.intValue) match {
|
|
||||||
case Some((Manifest.Unit, state: ResponseState)) =>
|
|
||||||
Future(responseForState(state, Unit).asInstanceOf[ApiResponse[T]])
|
|
||||||
case Some((manifest, state: ResponseState)) if manifest == mf =>
|
|
||||||
implicit val m: Unmarshaller[HttpEntity, T] = unmarshaller[T](mf, serialization, formats)
|
|
||||||
Unmarshal(response.entity)
|
|
||||||
.to[T]
|
|
||||||
.recoverWith {
|
|
||||||
case e ⇒ throw ApiError(response.status.intValue, s"Unable to unmarshall content to [$manifest]", Some(response.entity.toString), e)
|
|
||||||
}
|
|
||||||
.map(value => responseForState(state, value))
|
|
||||||
case None | Some(_) =>
|
|
||||||
Future.failed(ApiError(response.status.intValue, "Unexpected response code", Some(response.entity.toString)))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
sealed trait CustomContentTypes {
|
|
||||||
|
|
||||||
protected def normalizedContentType(original: String): ContentType =
|
|
||||||
ContentType(parseContentType(original).mediaType, () => HttpCharsets.`UTF-8`)
|
|
||||||
|
|
||||||
protected def parseContentType(contentType: String): ContentType = {
|
|
||||||
|
|
||||||
ContentType.parse(contentType) match {
|
|
||||||
case Right(ct: ContentType) =>
|
|
||||||
ct
|
|
||||||
case Left(error: List[ErrorInfo]) =>
|
|
||||||
throw new IllegalArgumentException(
|
|
||||||
s"Error converting '$contentType' to a ContentType header: '${error.map(_.summary).mkString(", ")}'"
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,65 +0,0 @@
|
|||||||
/**
|
|
||||||
* OpenAPI Petstore
|
|
||||||
* This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
|
|
||||||
*
|
|
||||||
* The version of the OpenAPI document: 1.0.0
|
|
||||||
*
|
|
||||||
*
|
|
||||||
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
|
||||||
* https://openapi-generator.tech
|
|
||||||
* Do not edit the class manually.
|
|
||||||
*/
|
|
||||||
package org.openapitools.client.core
|
|
||||||
|
|
||||||
sealed trait ResponseState
|
|
||||||
|
|
||||||
object ResponseState {
|
|
||||||
|
|
||||||
case object Success extends ResponseState
|
|
||||||
|
|
||||||
case object Error extends ResponseState
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
case class ApiRequest[U](
|
|
||||||
// required fields
|
|
||||||
method: ApiMethod,
|
|
||||||
basePath: String,
|
|
||||||
operationPath: String,
|
|
||||||
contentType: String,
|
|
||||||
|
|
||||||
// optional fields
|
|
||||||
responses: Map[Int, (Manifest[_], ResponseState)] = Map.empty,
|
|
||||||
bodyParam: Option[Any] = None,
|
|
||||||
formParams: Map[String, Any] = Map.empty,
|
|
||||||
pathParams: Map[String, Any] = Map.empty,
|
|
||||||
queryParams: Map[String, Any] = Map.empty,
|
|
||||||
headerParams: Map[String, Any] = Map.empty,
|
|
||||||
credentials: Seq[Credentials] = List.empty) {
|
|
||||||
|
|
||||||
def withCredentials(cred: Credentials): ApiRequest[U] = copy[U](credentials = credentials :+ cred)
|
|
||||||
|
|
||||||
def withApiKey(key: ApiKeyValue, keyName: String, location: ApiKeyLocation): ApiRequest[U] = withCredentials(ApiKeyCredentials(key, keyName, location))
|
|
||||||
|
|
||||||
def withSuccessResponse[T](code: Int)(implicit m: Manifest[T]): ApiRequest[U] = copy[U](responses = responses + (code -> (m, ResponseState.Success)))
|
|
||||||
|
|
||||||
def withErrorResponse[T](code: Int)(implicit m: Manifest[T]): ApiRequest[U] = copy[U](responses = responses + (code -> (m, ResponseState.Error)))
|
|
||||||
|
|
||||||
def withDefaultSuccessResponse[T](implicit m: Manifest[T]): ApiRequest[U] = withSuccessResponse[T](0)
|
|
||||||
|
|
||||||
def withDefaultErrorResponse[T](implicit m: Manifest[T]): ApiRequest[U] = withErrorResponse[T](0)
|
|
||||||
|
|
||||||
def responseForCode(statusCode: Int): Option[(Manifest[_], ResponseState)] = responses.get(statusCode) orElse responses.get(0)
|
|
||||||
|
|
||||||
def withoutBody(): ApiRequest[U] = copy[U](bodyParam = None)
|
|
||||||
|
|
||||||
def withBody(body: Any): ApiRequest[U] = copy[U](bodyParam = Some(body))
|
|
||||||
|
|
||||||
def withFormParam(name: String, value: Any): ApiRequest[U] = copy[U](formParams = formParams + (name -> value))
|
|
||||||
|
|
||||||
def withPathParam(name: String, value: Any): ApiRequest[U] = copy[U](pathParams = pathParams + (name -> value))
|
|
||||||
|
|
||||||
def withQueryParam(name: String, value: Any): ApiRequest[U] = copy[U](queryParams = queryParams + (name -> value))
|
|
||||||
|
|
||||||
def withHeaderParam(name: String, value: Any): ApiRequest[U] = copy[U](headerParams = headerParams + (name -> value))
|
|
||||||
}
|
|
||||||
@@ -1,45 +0,0 @@
|
|||||||
/**
|
|
||||||
* OpenAPI Petstore
|
|
||||||
* This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
|
|
||||||
*
|
|
||||||
* The version of the OpenAPI document: 1.0.0
|
|
||||||
*
|
|
||||||
*
|
|
||||||
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
|
||||||
* https://openapi-generator.tech
|
|
||||||
* Do not edit the class manually.
|
|
||||||
*/
|
|
||||||
package org.openapitools.client.core
|
|
||||||
|
|
||||||
import java.util.concurrent.TimeUnit
|
|
||||||
|
|
||||||
import akka.actor.{ ExtendedActorSystem, Extension, ExtensionKey }
|
|
||||||
import akka.http.scaladsl.model.StatusCodes.CustomStatusCode
|
|
||||||
import akka.http.scaladsl.model.headers.RawHeader
|
|
||||||
import com.typesafe.config.Config
|
|
||||||
|
|
||||||
import scala.collection.JavaConverters._
|
|
||||||
import scala.concurrent.duration.FiniteDuration
|
|
||||||
|
|
||||||
class ApiSettings(config: Config) extends Extension {
|
|
||||||
def this(system: ExtendedActorSystem) = this(system.settings.config)
|
|
||||||
|
|
||||||
private def cfg = config.getConfig("org.openapitools.client.apiRequest")
|
|
||||||
|
|
||||||
val alwaysTrustCertificates: Boolean = cfg.getBoolean("trust-certificates")
|
|
||||||
val defaultHeaders: List[RawHeader] = cfg.getConfig("default-headers").entrySet.asScala.toList.map(c => RawHeader(c.getKey, c.getValue.render))
|
|
||||||
val connectionTimeout = FiniteDuration(cfg.getDuration("connection-timeout", TimeUnit.MILLISECONDS), TimeUnit.MILLISECONDS)
|
|
||||||
val compressionEnabled: Boolean = cfg.getBoolean("compression.enabled")
|
|
||||||
val compressionSizeThreshold: Int = cfg.getBytes("compression.size-threshold").toInt
|
|
||||||
val customCodes: List[CustomStatusCode] = cfg.getConfigList("custom-codes").asScala.toList.map { c =>
|
|
||||||
CustomStatusCode(
|
|
||||||
c.getInt("code"))(
|
|
||||||
c.getString("reason"),
|
|
||||||
if (c.hasPath("defaultMessage")) c.getString("defaultMessage") else c.getString("reason"),
|
|
||||||
c.getBoolean("success"),
|
|
||||||
if (c.hasPath("allowsEntity")) c.getBoolean("allowsEntity") else true
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
object ApiSettings extends ExtensionKey[ApiSettings]
|
|
||||||
@@ -1,200 +0,0 @@
|
|||||||
/**
|
|
||||||
* OpenAPI Petstore
|
|
||||||
* This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
|
|
||||||
*
|
|
||||||
* The version of the OpenAPI document: 1.0.0
|
|
||||||
*
|
|
||||||
*
|
|
||||||
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
|
||||||
* https://openapi-generator.tech
|
|
||||||
* Do not edit the class manually.
|
|
||||||
*/
|
|
||||||
package org.openapitools.client.core
|
|
||||||
|
|
||||||
import java.io.File
|
|
||||||
import java.net.URLEncoder
|
|
||||||
import java.time.OffsetDateTime
|
|
||||||
|
|
||||||
import scala.util.Try
|
|
||||||
|
|
||||||
sealed trait ApiReturnWithHeaders {
|
|
||||||
def headers: Map[String, String]
|
|
||||||
|
|
||||||
def header(name: String): Option[String] = headers.get(name)
|
|
||||||
|
|
||||||
def getStringHeader(name: String): Option[String] = header(name)
|
|
||||||
|
|
||||||
// workaround: return date time header in string instead of datetime object
|
|
||||||
def getDateTimeHeader(name: String): Option[String] = header(name)
|
|
||||||
|
|
||||||
def getIntHeader(name: String): Option[Int] = castedHeader(name, java.lang.Integer.parseInt)
|
|
||||||
|
|
||||||
def getLongHeader(name: String): Option[Long] = castedHeader(name, java.lang.Long.parseLong)
|
|
||||||
|
|
||||||
def getFloatHeader(name: String): Option[Float] = castedHeader(name, java.lang.Float.parseFloat)
|
|
||||||
|
|
||||||
def getDoubleHeader(name: String): Option[Double] = castedHeader(name, java.lang.Double.parseDouble)
|
|
||||||
|
|
||||||
def getBooleanHeader(name: String): Option[Boolean] = castedHeader(name, java.lang.Boolean.parseBoolean)
|
|
||||||
|
|
||||||
def getOffsetDateTimeHeader(name: String): Option[OffsetDateTime] = castedHeader(name, java.time.OffsetDateTime.parse)
|
|
||||||
|
|
||||||
private def castedHeader[U](name: String, conversion: String => U): Option[U] = {
|
|
||||||
Try {
|
|
||||||
header(name).map(conversion)
|
|
||||||
}.get
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
sealed case class ApiResponse[T](code: Int, content: T, headers: Map[String, String] = Map.empty)
|
|
||||||
extends ApiReturnWithHeaders
|
|
||||||
|
|
||||||
sealed case class ApiError[T](code: Int, message: String, responseContent: Option[T], cause: Throwable = null, headers: Map[String, String] = Map.empty)
|
|
||||||
extends Throwable(s"($code) $message.${responseContent.map(s => s" Content : $s").getOrElse("")}", cause)
|
|
||||||
with ApiReturnWithHeaders
|
|
||||||
|
|
||||||
sealed case class ApiMethod(value: String)
|
|
||||||
|
|
||||||
object ApiMethods {
|
|
||||||
val CONNECT = ApiMethod("CONNECT")
|
|
||||||
val DELETE = ApiMethod("DELETE")
|
|
||||||
val GET = ApiMethod("GET")
|
|
||||||
val HEAD = ApiMethod("HEAD")
|
|
||||||
val OPTIONS = ApiMethod("OPTIONS")
|
|
||||||
val PATCH = ApiMethod("PATCH")
|
|
||||||
val POST = ApiMethod("POST")
|
|
||||||
val PUT = ApiMethod("PUT")
|
|
||||||
val TRACE = ApiMethod("TRACE")
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* This trait needs to be added to any model defined by the api.
|
|
||||||
*/
|
|
||||||
trait ApiModel
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Single trait defining a credential that can be transformed to a paramName / paramValue tupple
|
|
||||||
*/
|
|
||||||
sealed trait Credentials {
|
|
||||||
def asQueryParam: Option[(String, String)] = None
|
|
||||||
}
|
|
||||||
|
|
||||||
sealed case class BasicCredentials(user: String, password: String) extends Credentials
|
|
||||||
|
|
||||||
sealed case class BearerToken(token: String) extends Credentials
|
|
||||||
|
|
||||||
sealed case class ApiKeyCredentials(key: ApiKeyValue, keyName: String, location: ApiKeyLocation) extends Credentials {
|
|
||||||
override def asQueryParam: Option[(String, String)] = location match {
|
|
||||||
case ApiKeyLocations.QUERY => Some((keyName, key.value))
|
|
||||||
case _ => None
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
sealed case class ApiKeyValue(value: String)
|
|
||||||
|
|
||||||
sealed trait ApiKeyLocation
|
|
||||||
|
|
||||||
object ApiKeyLocations {
|
|
||||||
|
|
||||||
case object QUERY extends ApiKeyLocation
|
|
||||||
|
|
||||||
case object HEADER extends ApiKeyLocation
|
|
||||||
|
|
||||||
case object COOKIE extends ApiKeyLocation
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Case class used to unapply numeric values only in pattern matching
|
|
||||||
*
|
|
||||||
* @param value the string representation of the numeric value
|
|
||||||
*/
|
|
||||||
sealed case class NumericValue(value: String) {
|
|
||||||
override def toString: String = value
|
|
||||||
}
|
|
||||||
|
|
||||||
object NumericValue {
|
|
||||||
def unapply(n: Any): Option[NumericValue] = n match {
|
|
||||||
case (_: Int | _: Long | _: Float | _: Double | _: Boolean | _: Byte) => Some(NumericValue(String.valueOf(n)))
|
|
||||||
case _ => None
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Used for params being arrays
|
|
||||||
*/
|
|
||||||
sealed case class ArrayValues(values: Seq[Any], format: CollectionFormat = CollectionFormats.CSV)
|
|
||||||
|
|
||||||
object ArrayValues {
|
|
||||||
def apply(values: Option[Seq[Any]], format: CollectionFormat): ArrayValues =
|
|
||||||
ArrayValues(values.getOrElse(Seq.empty), format)
|
|
||||||
|
|
||||||
def apply(values: Option[Seq[Any]]): ArrayValues = ArrayValues(values, CollectionFormats.CSV)
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Defines how arrays should be rendered in query strings.
|
|
||||||
*/
|
|
||||||
sealed trait CollectionFormat
|
|
||||||
|
|
||||||
trait MergedArrayFormat extends CollectionFormat {
|
|
||||||
def separator: String
|
|
||||||
}
|
|
||||||
|
|
||||||
object CollectionFormats {
|
|
||||||
|
|
||||||
case object CSV extends MergedArrayFormat {
|
|
||||||
override val separator = ","
|
|
||||||
}
|
|
||||||
|
|
||||||
case object TSV extends MergedArrayFormat {
|
|
||||||
override val separator = "\t"
|
|
||||||
}
|
|
||||||
|
|
||||||
case object SSV extends MergedArrayFormat {
|
|
||||||
override val separator = " "
|
|
||||||
}
|
|
||||||
|
|
||||||
case object PIPES extends MergedArrayFormat {
|
|
||||||
override val separator = "|"
|
|
||||||
}
|
|
||||||
|
|
||||||
case object MULTI extends CollectionFormat
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
object ParametersMap {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Pimp parameters maps (Map[String, Any]) in order to transform them in a sequence of String -> Any tupples,
|
|
||||||
* with valid url-encoding, arrays handling, files preservation, ...
|
|
||||||
*/
|
|
||||||
implicit class ParametersMapImprovements(val m: Map[String, Any]) {
|
|
||||||
|
|
||||||
def asFormattedParamsList: List[(String, Any)] = m.toList.flatMap(formattedParams)
|
|
||||||
|
|
||||||
def asFormattedParams: Map[String, Any] = m.flatMap(formattedParams)
|
|
||||||
|
|
||||||
private def urlEncode(v: Any) = URLEncoder.encode(String.valueOf(v), "utf-8").replaceAll("\\+", "%20")
|
|
||||||
|
|
||||||
private def formattedParams(tuple: (String, Any)): Seq[(String, Any)] = formattedParams(tuple._1, tuple._2)
|
|
||||||
|
|
||||||
private def formattedParams(name: String, value: Any): Seq[(String, Any)] = value match {
|
|
||||||
case arr: ArrayValues =>
|
|
||||||
arr.format match {
|
|
||||||
case CollectionFormats.MULTI => arr.values.flatMap(formattedParams(name, _))
|
|
||||||
case format: MergedArrayFormat => Seq((name, arr.values.mkString(format.separator)))
|
|
||||||
}
|
|
||||||
case None => Seq.empty
|
|
||||||
case Some(opt) => formattedParams(name, opt)
|
|
||||||
case s: Seq[Any] => formattedParams(name, ArrayValues(s))
|
|
||||||
case v: String => Seq((name, urlEncode(v)))
|
|
||||||
case NumericValue(v) => Seq((name, urlEncode(v)))
|
|
||||||
case f: File => Seq((name, f))
|
|
||||||
case m: ApiModel => Seq((name, m))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1 +1 @@
|
|||||||
4.3.1-SNAPSHOT
|
5.0.0-SNAPSHOT
|
||||||
@@ -30,8 +30,8 @@ class PetApi(
|
|||||||
lazy val route: Route =
|
lazy val route: Route =
|
||||||
path("pet") {
|
path("pet") {
|
||||||
post {
|
post {
|
||||||
entity(as[Pet]){ body =>
|
entity(as[Pet]){ pet =>
|
||||||
petService.addPet(body = body)
|
petService.addPet(pet = pet)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} ~
|
} ~
|
||||||
@@ -63,8 +63,8 @@ class PetApi(
|
|||||||
} ~
|
} ~
|
||||||
path("pet") {
|
path("pet") {
|
||||||
put {
|
put {
|
||||||
entity(as[Pet]){ body =>
|
entity(as[Pet]){ pet =>
|
||||||
petService.updatePet(body = body)
|
petService.updatePet(pet = pet)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} ~
|
} ~
|
||||||
@@ -95,12 +95,16 @@ class PetApi(
|
|||||||
|
|
||||||
trait PetApiService {
|
trait PetApiService {
|
||||||
|
|
||||||
|
def addPet200(responsePet: Pet)(implicit toEntityMarshallerPet: ToEntityMarshaller[Pet]): Route =
|
||||||
|
complete((200, responsePet))
|
||||||
def addPet405: Route =
|
def addPet405: Route =
|
||||||
complete((405, "Invalid input"))
|
complete((405, "Invalid input"))
|
||||||
/**
|
/**
|
||||||
|
* Code: 200, Message: successful operation, DataType: Pet
|
||||||
* Code: 405, Message: Invalid input
|
* Code: 405, Message: Invalid input
|
||||||
*/
|
*/
|
||||||
def addPet(body: Pet): Route
|
def addPet(pet: Pet)
|
||||||
|
(implicit toEntityMarshallerPet: ToEntityMarshaller[Pet]): Route
|
||||||
|
|
||||||
def deletePet400: Route =
|
def deletePet400: Route =
|
||||||
complete((400, "Invalid pet value"))
|
complete((400, "Invalid pet value"))
|
||||||
@@ -145,6 +149,8 @@ trait PetApiService {
|
|||||||
def getPetById(petId: Long)
|
def getPetById(petId: Long)
|
||||||
(implicit toEntityMarshallerPet: ToEntityMarshaller[Pet]): Route
|
(implicit toEntityMarshallerPet: ToEntityMarshaller[Pet]): Route
|
||||||
|
|
||||||
|
def updatePet200(responsePet: Pet)(implicit toEntityMarshallerPet: ToEntityMarshaller[Pet]): Route =
|
||||||
|
complete((200, responsePet))
|
||||||
def updatePet400: Route =
|
def updatePet400: Route =
|
||||||
complete((400, "Invalid ID supplied"))
|
complete((400, "Invalid ID supplied"))
|
||||||
def updatePet404: Route =
|
def updatePet404: Route =
|
||||||
@@ -152,11 +158,13 @@ trait PetApiService {
|
|||||||
def updatePet405: Route =
|
def updatePet405: Route =
|
||||||
complete((405, "Validation exception"))
|
complete((405, "Validation exception"))
|
||||||
/**
|
/**
|
||||||
|
* Code: 200, Message: successful operation, DataType: Pet
|
||||||
* Code: 400, Message: Invalid ID supplied
|
* Code: 400, Message: Invalid ID supplied
|
||||||
* Code: 404, Message: Pet not found
|
* Code: 404, Message: Pet not found
|
||||||
* Code: 405, Message: Validation exception
|
* Code: 405, Message: Validation exception
|
||||||
*/
|
*/
|
||||||
def updatePet(body: Pet): Route
|
def updatePet(pet: Pet)
|
||||||
|
(implicit toEntityMarshallerPet: ToEntityMarshaller[Pet]): Route
|
||||||
|
|
||||||
def updatePetWithForm405: Route =
|
def updatePetWithForm405: Route =
|
||||||
complete((405, "Invalid input"))
|
complete((405, "Invalid input"))
|
||||||
|
|||||||
@@ -36,8 +36,8 @@ class StoreApi(
|
|||||||
} ~
|
} ~
|
||||||
path("store" / "order") {
|
path("store" / "order") {
|
||||||
post {
|
post {
|
||||||
entity(as[Order]){ body =>
|
entity(as[Order]){ order =>
|
||||||
storeService.placeOrder(body = body)
|
storeService.placeOrder(order = order)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -85,7 +85,7 @@ trait StoreApiService {
|
|||||||
* Code: 200, Message: successful operation, DataType: Order
|
* Code: 200, Message: successful operation, DataType: Order
|
||||||
* Code: 400, Message: Invalid Order
|
* Code: 400, Message: Invalid Order
|
||||||
*/
|
*/
|
||||||
def placeOrder(body: Order)
|
def placeOrder(order: Order)
|
||||||
(implicit toEntityMarshallerOrder: ToEntityMarshaller[Order]): Route
|
(implicit toEntityMarshallerOrder: ToEntityMarshaller[Order]): Route
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -21,22 +21,22 @@ class UserApi(
|
|||||||
lazy val route: Route =
|
lazy val route: Route =
|
||||||
path("user") {
|
path("user") {
|
||||||
post {
|
post {
|
||||||
entity(as[User]){ body =>
|
entity(as[User]){ user =>
|
||||||
userService.createUser(body = body)
|
userService.createUser(user = user)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} ~
|
} ~
|
||||||
path("user" / "createWithArray") {
|
path("user" / "createWithArray") {
|
||||||
post {
|
post {
|
||||||
entity(as[Seq[User]]){ body =>
|
entity(as[Seq[User]]){ user =>
|
||||||
userService.createUsersWithArrayInput(body = body)
|
userService.createUsersWithArrayInput(user = user)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} ~
|
} ~
|
||||||
path("user" / "createWithList") {
|
path("user" / "createWithList") {
|
||||||
post {
|
post {
|
||||||
entity(as[Seq[User]]){ body =>
|
entity(as[Seq[User]]){ user =>
|
||||||
userService.createUsersWithListInput(body = body)
|
userService.createUsersWithListInput(user = user)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} ~
|
} ~
|
||||||
@@ -64,8 +64,8 @@ class UserApi(
|
|||||||
} ~
|
} ~
|
||||||
path("user" / Segment) { (username) =>
|
path("user" / Segment) { (username) =>
|
||||||
put {
|
put {
|
||||||
entity(as[User]){ body =>
|
entity(as[User]){ user =>
|
||||||
userService.updateUser(username = username, body = body)
|
userService.updateUser(username = username, user = user)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -79,21 +79,21 @@ trait UserApiService {
|
|||||||
/**
|
/**
|
||||||
* Code: 0, Message: successful operation
|
* Code: 0, Message: successful operation
|
||||||
*/
|
*/
|
||||||
def createUser(body: User): Route
|
def createUser(user: User): Route
|
||||||
|
|
||||||
def createUsersWithArrayInputDefault(statusCode: Int): Route =
|
def createUsersWithArrayInputDefault(statusCode: Int): Route =
|
||||||
complete((statusCode, "successful operation"))
|
complete((statusCode, "successful operation"))
|
||||||
/**
|
/**
|
||||||
* Code: 0, Message: successful operation
|
* Code: 0, Message: successful operation
|
||||||
*/
|
*/
|
||||||
def createUsersWithArrayInput(body: Seq[User]): Route
|
def createUsersWithArrayInput(user: Seq[User]): Route
|
||||||
|
|
||||||
def createUsersWithListInputDefault(statusCode: Int): Route =
|
def createUsersWithListInputDefault(statusCode: Int): Route =
|
||||||
complete((statusCode, "successful operation"))
|
complete((statusCode, "successful operation"))
|
||||||
/**
|
/**
|
||||||
* Code: 0, Message: successful operation
|
* Code: 0, Message: successful operation
|
||||||
*/
|
*/
|
||||||
def createUsersWithListInput(body: Seq[User]): Route
|
def createUsersWithListInput(user: Seq[User]): Route
|
||||||
|
|
||||||
def deleteUser400: Route =
|
def deleteUser400: Route =
|
||||||
complete((400, "Invalid username supplied"))
|
complete((400, "Invalid username supplied"))
|
||||||
@@ -144,7 +144,7 @@ trait UserApiService {
|
|||||||
* Code: 400, Message: Invalid user supplied
|
* Code: 400, Message: Invalid user supplied
|
||||||
* Code: 404, Message: User not found
|
* Code: 404, Message: User not found
|
||||||
*/
|
*/
|
||||||
def updateUser(username: String, body: User): Route
|
def updateUser(username: String, user: User): Route
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,12 @@
|
|||||||
|
package org.openapitools.server.model
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param name Updated name of the pet for example: ''null''
|
||||||
|
* @param status Updated status of the pet for example: ''null''
|
||||||
|
*/
|
||||||
|
final case class InlineObject (
|
||||||
|
name: Option[String],
|
||||||
|
status: Option[String]
|
||||||
|
)
|
||||||
|
|
||||||
@@ -0,0 +1,13 @@
|
|||||||
|
package org.openapitools.server.model
|
||||||
|
|
||||||
|
import java.io.File
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param additionalMetadata Additional data to pass to server for example: ''null''
|
||||||
|
* @param file file to upload for example: ''null''
|
||||||
|
*/
|
||||||
|
final case class InlineObject1 (
|
||||||
|
additionalMetadata: Option[String],
|
||||||
|
file: Option[File]
|
||||||
|
)
|
||||||
|
|
||||||
18
samples/server/petstore/scala-finch/.openapi-generator/FILES
Normal file
18
samples/server/petstore/scala-finch/.openapi-generator/FILES
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
README.md
|
||||||
|
build.sbt
|
||||||
|
project/build.properties
|
||||||
|
project/plugins.sbt
|
||||||
|
sbt
|
||||||
|
src/main/scala/DataAccessor.scala
|
||||||
|
src/main/scala/Server.scala
|
||||||
|
src/main/scala/endpoint.scala
|
||||||
|
src/main/scala/errors.scala
|
||||||
|
src/main/scala/org/openapitools/apis/PetApi.scala
|
||||||
|
src/main/scala/org/openapitools/apis/StoreApi.scala
|
||||||
|
src/main/scala/org/openapitools/apis/UserApi.scala
|
||||||
|
src/main/scala/org/openapitools/models/ApiResponse.scala
|
||||||
|
src/main/scala/org/openapitools/models/Category.scala
|
||||||
|
src/main/scala/org/openapitools/models/Order.scala
|
||||||
|
src/main/scala/org/openapitools/models/Pet.scala
|
||||||
|
src/main/scala/org/openapitools/models/Tag.scala
|
||||||
|
src/main/scala/org/openapitools/models/User.scala
|
||||||
@@ -1 +1 @@
|
|||||||
4.3.0-SNAPSHOT
|
5.0.0-SNAPSHOT
|
||||||
@@ -16,9 +16,9 @@ trait DataAccessor {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @return A Unit
|
* @return A Pet
|
||||||
*/
|
*/
|
||||||
def Pet_addPet(body: Pet): Either[CommonError,Unit] = Left(TODO)
|
def Pet_addPet(pet: Pet): Either[CommonError,Pet] = Left(TODO)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
@@ -46,9 +46,9 @@ trait DataAccessor {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @return A Unit
|
* @return A Pet
|
||||||
*/
|
*/
|
||||||
def Pet_updatePet(body: Pet): Either[CommonError,Unit] = Left(TODO)
|
def Pet_updatePet(pet: Pet): Either[CommonError,Pet] = Left(TODO)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
@@ -84,31 +84,31 @@ trait DataAccessor {
|
|||||||
*
|
*
|
||||||
* @return A Order
|
* @return A Order
|
||||||
*/
|
*/
|
||||||
def Store_placeOrder(body: Order): Either[CommonError,Order] = Left(TODO)
|
def Store_placeOrder(order: Order): Either[CommonError,Order] = Left(TODO)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @return A Unit
|
* @return A Unit
|
||||||
*/
|
*/
|
||||||
def User_createUser(body: User): Either[CommonError,Unit] = Left(TODO)
|
def User_createUser(user: User, authParamapi_key: String): Either[CommonError,Unit] = Left(TODO)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @return A Unit
|
* @return A Unit
|
||||||
*/
|
*/
|
||||||
def User_createUsersWithArrayInput(body: Seq[User]): Either[CommonError,Unit] = Left(TODO)
|
def User_createUsersWithArrayInput(user: Seq[User], authParamapi_key: String): Either[CommonError,Unit] = Left(TODO)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @return A Unit
|
* @return A Unit
|
||||||
*/
|
*/
|
||||||
def User_createUsersWithListInput(body: Seq[User]): Either[CommonError,Unit] = Left(TODO)
|
def User_createUsersWithListInput(user: Seq[User], authParamapi_key: String): Either[CommonError,Unit] = Left(TODO)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @return A Unit
|
* @return A Unit
|
||||||
*/
|
*/
|
||||||
def User_deleteUser(username: String): Either[CommonError,Unit] = Left(TODO)
|
def User_deleteUser(username: String, authParamapi_key: String): Either[CommonError,Unit] = Left(TODO)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
@@ -126,12 +126,12 @@ trait DataAccessor {
|
|||||||
*
|
*
|
||||||
* @return A Unit
|
* @return A Unit
|
||||||
*/
|
*/
|
||||||
def User_logoutUser(): Either[CommonError,Unit] = Left(TODO)
|
def User_logoutUser(authParamapi_key: String): Either[CommonError,Unit] = Left(TODO)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @return A Unit
|
* @return A Unit
|
||||||
*/
|
*/
|
||||||
def User_updateUser(username: String, body: User): Either[CommonError,Unit] = Left(TODO)
|
def User_updateUser(username: String, user: User, authParamapi_key: String): Either[CommonError,Unit] = Left(TODO)
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -57,11 +57,11 @@ object PetApi {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @return An endpoint representing a Unit
|
* @return An endpoint representing a Pet
|
||||||
*/
|
*/
|
||||||
private def addPet(da: DataAccessor): Endpoint[Unit] =
|
private def addPet(da: DataAccessor): Endpoint[Pet] =
|
||||||
post("pet" :: jsonBody[Pet]) { (body: Pet) =>
|
post("pet" :: jsonBody[Pet]) { (pet: Pet) =>
|
||||||
da.Pet_addPet(body) match {
|
da.Pet_addPet(pet) match {
|
||||||
case Left(error) => checkError(error)
|
case Left(error) => checkError(error)
|
||||||
case Right(data) => Ok(data)
|
case Right(data) => Ok(data)
|
||||||
}
|
}
|
||||||
@@ -127,11 +127,11 @@ object PetApi {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @return An endpoint representing a Unit
|
* @return An endpoint representing a Pet
|
||||||
*/
|
*/
|
||||||
private def updatePet(da: DataAccessor): Endpoint[Unit] =
|
private def updatePet(da: DataAccessor): Endpoint[Pet] =
|
||||||
put("pet" :: jsonBody[Pet]) { (body: Pet) =>
|
put("pet" :: jsonBody[Pet]) { (pet: Pet) =>
|
||||||
da.Pet_updatePet(body) match {
|
da.Pet_updatePet(pet) match {
|
||||||
case Left(error) => checkError(error)
|
case Left(error) => checkError(error)
|
||||||
case Right(data) => Ok(data)
|
case Right(data) => Ok(data)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -96,8 +96,8 @@ object StoreApi {
|
|||||||
* @return An endpoint representing a Order
|
* @return An endpoint representing a Order
|
||||||
*/
|
*/
|
||||||
private def placeOrder(da: DataAccessor): Endpoint[Order] =
|
private def placeOrder(da: DataAccessor): Endpoint[Order] =
|
||||||
post("store" :: "order" :: jsonBody[Order]) { (body: Order) =>
|
post("store" :: "order" :: jsonBody[Order]) { (order: Order) =>
|
||||||
da.Store_placeOrder(body) match {
|
da.Store_placeOrder(order) match {
|
||||||
case Left(error) => checkError(error)
|
case Left(error) => checkError(error)
|
||||||
case Right(data) => Ok(data)
|
case Right(data) => Ok(data)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -59,8 +59,8 @@ object UserApi {
|
|||||||
* @return An endpoint representing a Unit
|
* @return An endpoint representing a Unit
|
||||||
*/
|
*/
|
||||||
private def createUser(da: DataAccessor): Endpoint[Unit] =
|
private def createUser(da: DataAccessor): Endpoint[Unit] =
|
||||||
post("user" :: jsonBody[User]) { (body: User) =>
|
post("user" :: jsonBody[User] :: header("api_key")) { (user: User, authParamapi_key: String) =>
|
||||||
da.User_createUser(body) match {
|
da.User_createUser(user, authParamapi_key) match {
|
||||||
case Left(error) => checkError(error)
|
case Left(error) => checkError(error)
|
||||||
case Right(data) => Ok(data)
|
case Right(data) => Ok(data)
|
||||||
}
|
}
|
||||||
@@ -73,8 +73,8 @@ object UserApi {
|
|||||||
* @return An endpoint representing a Unit
|
* @return An endpoint representing a Unit
|
||||||
*/
|
*/
|
||||||
private def createUsersWithArrayInput(da: DataAccessor): Endpoint[Unit] =
|
private def createUsersWithArrayInput(da: DataAccessor): Endpoint[Unit] =
|
||||||
post("user" :: "createWithArray" :: jsonBody[Seq[User]]) { (body: Seq[User]) =>
|
post("user" :: "createWithArray" :: jsonBody[Seq[User]] :: header("api_key")) { (user: Seq[User], authParamapi_key: String) =>
|
||||||
da.User_createUsersWithArrayInput(body) match {
|
da.User_createUsersWithArrayInput(user, authParamapi_key) match {
|
||||||
case Left(error) => checkError(error)
|
case Left(error) => checkError(error)
|
||||||
case Right(data) => Ok(data)
|
case Right(data) => Ok(data)
|
||||||
}
|
}
|
||||||
@@ -87,8 +87,8 @@ object UserApi {
|
|||||||
* @return An endpoint representing a Unit
|
* @return An endpoint representing a Unit
|
||||||
*/
|
*/
|
||||||
private def createUsersWithListInput(da: DataAccessor): Endpoint[Unit] =
|
private def createUsersWithListInput(da: DataAccessor): Endpoint[Unit] =
|
||||||
post("user" :: "createWithList" :: jsonBody[Seq[User]]) { (body: Seq[User]) =>
|
post("user" :: "createWithList" :: jsonBody[Seq[User]] :: header("api_key")) { (user: Seq[User], authParamapi_key: String) =>
|
||||||
da.User_createUsersWithListInput(body) match {
|
da.User_createUsersWithListInput(user, authParamapi_key) match {
|
||||||
case Left(error) => checkError(error)
|
case Left(error) => checkError(error)
|
||||||
case Right(data) => Ok(data)
|
case Right(data) => Ok(data)
|
||||||
}
|
}
|
||||||
@@ -101,8 +101,8 @@ object UserApi {
|
|||||||
* @return An endpoint representing a Unit
|
* @return An endpoint representing a Unit
|
||||||
*/
|
*/
|
||||||
private def deleteUser(da: DataAccessor): Endpoint[Unit] =
|
private def deleteUser(da: DataAccessor): Endpoint[Unit] =
|
||||||
delete("user" :: string) { (username: String) =>
|
delete("user" :: string :: header("api_key")) { (username: String, authParamapi_key: String) =>
|
||||||
da.User_deleteUser(username) match {
|
da.User_deleteUser(username, authParamapi_key) match {
|
||||||
case Left(error) => checkError(error)
|
case Left(error) => checkError(error)
|
||||||
case Right(data) => Ok(data)
|
case Right(data) => Ok(data)
|
||||||
}
|
}
|
||||||
@@ -143,8 +143,8 @@ object UserApi {
|
|||||||
* @return An endpoint representing a Unit
|
* @return An endpoint representing a Unit
|
||||||
*/
|
*/
|
||||||
private def logoutUser(da: DataAccessor): Endpoint[Unit] =
|
private def logoutUser(da: DataAccessor): Endpoint[Unit] =
|
||||||
get("user" :: "logout") { () =>
|
get("user" :: "logout" :: header("api_key")) { (authParamapi_key: String) =>
|
||||||
da.User_logoutUser() match {
|
da.User_logoutUser(authParamapi_key) match {
|
||||||
case Left(error) => checkError(error)
|
case Left(error) => checkError(error)
|
||||||
case Right(data) => Ok(data)
|
case Right(data) => Ok(data)
|
||||||
}
|
}
|
||||||
@@ -157,8 +157,8 @@ object UserApi {
|
|||||||
* @return An endpoint representing a Unit
|
* @return An endpoint representing a Unit
|
||||||
*/
|
*/
|
||||||
private def updateUser(da: DataAccessor): Endpoint[Unit] =
|
private def updateUser(da: DataAccessor): Endpoint[Unit] =
|
||||||
put("user" :: string :: jsonBody[User]) { (username: String, body: User) =>
|
put("user" :: string :: jsonBody[User] :: header("api_key")) { (username: String, user: User, authParamapi_key: String) =>
|
||||||
da.User_updateUser(username, body) match {
|
da.User_updateUser(username, user, authParamapi_key) match {
|
||||||
case Left(error) => checkError(error)
|
case Left(error) => checkError(error)
|
||||||
case Right(data) => Ok(data)
|
case Right(data) => Ok(data)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,14 @@
|
|||||||
|
.gitignore
|
||||||
|
README.md
|
||||||
|
build.sbt
|
||||||
|
project/build.properties
|
||||||
|
project/plugins.sbt
|
||||||
|
src/main/scala/io/swagger/client/api/PetApi.scala
|
||||||
|
src/main/scala/io/swagger/client/api/StoreApi.scala
|
||||||
|
src/main/scala/io/swagger/client/api/UserApi.scala
|
||||||
|
src/main/scala/io/swagger/client/model/ApiResponse.scala
|
||||||
|
src/main/scala/io/swagger/client/model/Category.scala
|
||||||
|
src/main/scala/io/swagger/client/model/Order.scala
|
||||||
|
src/main/scala/io/swagger/client/model/Pet.scala
|
||||||
|
src/main/scala/io/swagger/client/model/Tag.scala
|
||||||
|
src/main/scala/io/swagger/client/model/User.scala
|
||||||
@@ -1 +1 @@
|
|||||||
4.3.0-SNAPSHOT
|
5.0.0-SNAPSHOT
|
||||||
@@ -44,9 +44,9 @@ trait PetApi extends Service {
|
|||||||
* Add a new pet to the store
|
* Add a new pet to the store
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
* @return void Body Parameter Pet object that needs to be added to the store
|
* @return Pet Body Parameter Pet object that needs to be added to the store
|
||||||
*/
|
*/
|
||||||
def addPet(): ServiceCall[Pet ,Done]
|
def addPet(): ServiceCall[Pet ,Pet]
|
||||||
|
|
||||||
|
|
||||||
// apiKey:String -- not yet supported heder params
|
// apiKey:String -- not yet supported heder params
|
||||||
@@ -95,9 +95,9 @@ trait PetApi extends Service {
|
|||||||
* Update an existing pet
|
* Update an existing pet
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
* @return void Body Parameter Pet object that needs to be added to the store
|
* @return Pet Body Parameter Pet object that needs to be added to the store
|
||||||
*/
|
*/
|
||||||
def updatePet(): ServiceCall[Pet ,Done]
|
def updatePet(): ServiceCall[Pet ,Pet]
|
||||||
|
|
||||||
|
|
||||||
// name:String -- not yet supported x-www-form-urlencoded
|
// name:String -- not yet supported x-www-form-urlencoded
|
||||||
|
|||||||
@@ -1 +1 @@
|
|||||||
4.3.0-SNAPSHOT
|
5.0.0-SNAPSHOT
|
||||||
@@ -8,9 +8,9 @@ import play.api.libs.Files.TemporaryFile
|
|||||||
trait PetApi {
|
trait PetApi {
|
||||||
/**
|
/**
|
||||||
* Add a new pet to the store
|
* Add a new pet to the store
|
||||||
* @param body Pet object that needs to be added to the store
|
* @param pet Pet object that needs to be added to the store
|
||||||
*/
|
*/
|
||||||
def addPet(body: Pet): Unit
|
def addPet(pet: Pet): Pet
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Deletes a pet
|
* Deletes a pet
|
||||||
@@ -41,9 +41,9 @@ trait PetApi {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Update an existing pet
|
* Update an existing pet
|
||||||
* @param body Pet object that needs to be added to the store
|
* @param pet Pet object that needs to be added to the store
|
||||||
*/
|
*/
|
||||||
def updatePet(body: Pet): Unit
|
def updatePet(pet: Pet): Pet
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Updates a pet in the store with form data
|
* Updates a pet in the store with form data
|
||||||
|
|||||||
@@ -15,15 +15,16 @@ class PetApiController @Inject()(cc: ControllerComponents, api: PetApi) extends
|
|||||||
* POST /v2/pet
|
* POST /v2/pet
|
||||||
*/
|
*/
|
||||||
def addPet(): Action[AnyContent] = Action { request =>
|
def addPet(): Action[AnyContent] = Action { request =>
|
||||||
def executeApi(): Unit = {
|
def executeApi(): Pet = {
|
||||||
val body = request.body.asJson.map(_.as[Pet]).getOrElse {
|
val pet = request.body.asJson.map(_.as[Pet]).getOrElse {
|
||||||
throw new OpenApiExceptions.MissingRequiredParameterException("body", "body")
|
throw new OpenApiExceptions.MissingRequiredParameterException("body", "pet")
|
||||||
}
|
}
|
||||||
api.addPet(body)
|
api.addPet(pet)
|
||||||
}
|
}
|
||||||
|
|
||||||
executeApi()
|
val result = executeApi()
|
||||||
Ok
|
val json = Json.toJson(result)
|
||||||
|
Ok(json)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -95,15 +96,16 @@ class PetApiController @Inject()(cc: ControllerComponents, api: PetApi) extends
|
|||||||
* PUT /v2/pet
|
* PUT /v2/pet
|
||||||
*/
|
*/
|
||||||
def updatePet(): Action[AnyContent] = Action { request =>
|
def updatePet(): Action[AnyContent] = Action { request =>
|
||||||
def executeApi(): Unit = {
|
def executeApi(): Pet = {
|
||||||
val body = request.body.asJson.map(_.as[Pet]).getOrElse {
|
val pet = request.body.asJson.map(_.as[Pet]).getOrElse {
|
||||||
throw new OpenApiExceptions.MissingRequiredParameterException("body", "body")
|
throw new OpenApiExceptions.MissingRequiredParameterException("body", "pet")
|
||||||
}
|
}
|
||||||
api.updatePet(body)
|
api.updatePet(pet)
|
||||||
}
|
}
|
||||||
|
|
||||||
executeApi()
|
val result = executeApi()
|
||||||
Ok
|
val json = Json.toJson(result)
|
||||||
|
Ok(json)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -12,10 +12,10 @@ class PetApiImpl extends PetApi {
|
|||||||
/**
|
/**
|
||||||
* @inheritdoc
|
* @inheritdoc
|
||||||
*/
|
*/
|
||||||
override def addPet(body: Pet): Unit = {
|
override def addPet(pet: Pet): Pet = {
|
||||||
// TODO: Implement better logic
|
// TODO: Implement better logic
|
||||||
|
|
||||||
|
Pet(None, None, "", List.empty[String], None, None)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -57,10 +57,10 @@ class PetApiImpl extends PetApi {
|
|||||||
/**
|
/**
|
||||||
* @inheritdoc
|
* @inheritdoc
|
||||||
*/
|
*/
|
||||||
override def updatePet(body: Pet): Unit = {
|
override def updatePet(pet: Pet): Pet = {
|
||||||
// TODO: Implement better logic
|
// TODO: Implement better logic
|
||||||
|
|
||||||
|
Pet(None, None, "", List.empty[String], None, None)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ trait StoreApi {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Place an order for a pet
|
* Place an order for a pet
|
||||||
* @param body order placed for purchasing the pet
|
* @param order order placed for purchasing the pet
|
||||||
*/
|
*/
|
||||||
def placeOrder(body: Order): Order
|
def placeOrder(order: Order): Order
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -54,10 +54,10 @@ class StoreApiController @Inject()(cc: ControllerComponents, api: StoreApi) exte
|
|||||||
*/
|
*/
|
||||||
def placeOrder(): Action[AnyContent] = Action { request =>
|
def placeOrder(): Action[AnyContent] = Action { request =>
|
||||||
def executeApi(): Order = {
|
def executeApi(): Order = {
|
||||||
val body = request.body.asJson.map(_.as[Order]).getOrElse {
|
val order = request.body.asJson.map(_.as[Order]).getOrElse {
|
||||||
throw new OpenApiExceptions.MissingRequiredParameterException("body", "body")
|
throw new OpenApiExceptions.MissingRequiredParameterException("body", "order")
|
||||||
}
|
}
|
||||||
api.placeOrder(body)
|
api.placeOrder(order)
|
||||||
}
|
}
|
||||||
|
|
||||||
val result = executeApi()
|
val result = executeApi()
|
||||||
|
|||||||
@@ -37,7 +37,7 @@ class StoreApiImpl extends StoreApi {
|
|||||||
/**
|
/**
|
||||||
* @inheritdoc
|
* @inheritdoc
|
||||||
*/
|
*/
|
||||||
override def placeOrder(body: Order): Order = {
|
override def placeOrder(order: Order): Order = {
|
||||||
// TODO: Implement better logic
|
// TODO: Implement better logic
|
||||||
|
|
||||||
Order(None, None, None, None, None, None)
|
Order(None, None, None, None, None, None)
|
||||||
|
|||||||
@@ -7,21 +7,21 @@ trait UserApi {
|
|||||||
/**
|
/**
|
||||||
* Create user
|
* Create user
|
||||||
* This can only be done by the logged in user.
|
* This can only be done by the logged in user.
|
||||||
* @param body Created user object
|
* @param user Created user object
|
||||||
*/
|
*/
|
||||||
def createUser(body: User): Unit
|
def createUser(user: User): Unit
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates list of users with given input array
|
* Creates list of users with given input array
|
||||||
* @param body List of user object
|
* @param user List of user object
|
||||||
*/
|
*/
|
||||||
def createUsersWithArrayInput(body: List[User]): Unit
|
def createUsersWithArrayInput(user: List[User]): Unit
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates list of users with given input array
|
* Creates list of users with given input array
|
||||||
* @param body List of user object
|
* @param user List of user object
|
||||||
*/
|
*/
|
||||||
def createUsersWithListInput(body: List[User]): Unit
|
def createUsersWithListInput(user: List[User]): Unit
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Delete user
|
* Delete user
|
||||||
@@ -52,7 +52,7 @@ trait UserApi {
|
|||||||
* Updated user
|
* Updated user
|
||||||
* This can only be done by the logged in user.
|
* This can only be done by the logged in user.
|
||||||
* @param username name that need to be deleted
|
* @param username name that need to be deleted
|
||||||
* @param body Updated user object
|
* @param user Updated user object
|
||||||
*/
|
*/
|
||||||
def updateUser(username: String, body: User): Unit
|
def updateUser(username: String, user: User): Unit
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,10 +14,10 @@ class UserApiController @Inject()(cc: ControllerComponents, api: UserApi) extend
|
|||||||
*/
|
*/
|
||||||
def createUser(): Action[AnyContent] = Action { request =>
|
def createUser(): Action[AnyContent] = Action { request =>
|
||||||
def executeApi(): Unit = {
|
def executeApi(): Unit = {
|
||||||
val body = request.body.asJson.map(_.as[User]).getOrElse {
|
val user = request.body.asJson.map(_.as[User]).getOrElse {
|
||||||
throw new OpenApiExceptions.MissingRequiredParameterException("body", "body")
|
throw new OpenApiExceptions.MissingRequiredParameterException("body", "user")
|
||||||
}
|
}
|
||||||
api.createUser(body)
|
api.createUser(user)
|
||||||
}
|
}
|
||||||
|
|
||||||
executeApi()
|
executeApi()
|
||||||
@@ -29,10 +29,10 @@ class UserApiController @Inject()(cc: ControllerComponents, api: UserApi) extend
|
|||||||
*/
|
*/
|
||||||
def createUsersWithArrayInput(): Action[AnyContent] = Action { request =>
|
def createUsersWithArrayInput(): Action[AnyContent] = Action { request =>
|
||||||
def executeApi(): Unit = {
|
def executeApi(): Unit = {
|
||||||
val body = request.body.asJson.map(_.as[List[User]]).getOrElse {
|
val user = request.body.asJson.map(_.as[List[User]]).getOrElse {
|
||||||
throw new OpenApiExceptions.MissingRequiredParameterException("body", "body")
|
throw new OpenApiExceptions.MissingRequiredParameterException("body", "user")
|
||||||
}
|
}
|
||||||
api.createUsersWithArrayInput(body)
|
api.createUsersWithArrayInput(user)
|
||||||
}
|
}
|
||||||
|
|
||||||
executeApi()
|
executeApi()
|
||||||
@@ -44,10 +44,10 @@ class UserApiController @Inject()(cc: ControllerComponents, api: UserApi) extend
|
|||||||
*/
|
*/
|
||||||
def createUsersWithListInput(): Action[AnyContent] = Action { request =>
|
def createUsersWithListInput(): Action[AnyContent] = Action { request =>
|
||||||
def executeApi(): Unit = {
|
def executeApi(): Unit = {
|
||||||
val body = request.body.asJson.map(_.as[List[User]]).getOrElse {
|
val user = request.body.asJson.map(_.as[List[User]]).getOrElse {
|
||||||
throw new OpenApiExceptions.MissingRequiredParameterException("body", "body")
|
throw new OpenApiExceptions.MissingRequiredParameterException("body", "user")
|
||||||
}
|
}
|
||||||
api.createUsersWithListInput(body)
|
api.createUsersWithListInput(user)
|
||||||
}
|
}
|
||||||
|
|
||||||
executeApi()
|
executeApi()
|
||||||
@@ -120,10 +120,10 @@ class UserApiController @Inject()(cc: ControllerComponents, api: UserApi) extend
|
|||||||
*/
|
*/
|
||||||
def updateUser(username: String): Action[AnyContent] = Action { request =>
|
def updateUser(username: String): Action[AnyContent] = Action { request =>
|
||||||
def executeApi(): Unit = {
|
def executeApi(): Unit = {
|
||||||
val body = request.body.asJson.map(_.as[User]).getOrElse {
|
val user = request.body.asJson.map(_.as[User]).getOrElse {
|
||||||
throw new OpenApiExceptions.MissingRequiredParameterException("body", "body")
|
throw new OpenApiExceptions.MissingRequiredParameterException("body", "user")
|
||||||
}
|
}
|
||||||
api.updateUser(username, body)
|
api.updateUser(username, user)
|
||||||
}
|
}
|
||||||
|
|
||||||
executeApi()
|
executeApi()
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ class UserApiImpl extends UserApi {
|
|||||||
/**
|
/**
|
||||||
* @inheritdoc
|
* @inheritdoc
|
||||||
*/
|
*/
|
||||||
override def createUser(body: User): Unit = {
|
override def createUser(user: User): Unit = {
|
||||||
// TODO: Implement better logic
|
// TODO: Implement better logic
|
||||||
|
|
||||||
|
|
||||||
@@ -19,7 +19,7 @@ class UserApiImpl extends UserApi {
|
|||||||
/**
|
/**
|
||||||
* @inheritdoc
|
* @inheritdoc
|
||||||
*/
|
*/
|
||||||
override def createUsersWithArrayInput(body: List[User]): Unit = {
|
override def createUsersWithArrayInput(user: List[User]): Unit = {
|
||||||
// TODO: Implement better logic
|
// TODO: Implement better logic
|
||||||
|
|
||||||
|
|
||||||
@@ -28,7 +28,7 @@ class UserApiImpl extends UserApi {
|
|||||||
/**
|
/**
|
||||||
* @inheritdoc
|
* @inheritdoc
|
||||||
*/
|
*/
|
||||||
override def createUsersWithListInput(body: List[User]): Unit = {
|
override def createUsersWithListInput(user: List[User]): Unit = {
|
||||||
// TODO: Implement better logic
|
// TODO: Implement better logic
|
||||||
|
|
||||||
|
|
||||||
@@ -73,7 +73,7 @@ class UserApiImpl extends UserApi {
|
|||||||
/**
|
/**
|
||||||
* @inheritdoc
|
* @inheritdoc
|
||||||
*/
|
*/
|
||||||
override def updateUser(username: String, body: User): Unit = {
|
override def updateUser(username: String, user: User): Unit = {
|
||||||
// TODO: Implement better logic
|
// TODO: Implement better logic
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,19 @@
|
|||||||
|
package model
|
||||||
|
|
||||||
|
import play.api.libs.json._
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Represents the Swagger definition for inline_object.
|
||||||
|
* @param name Updated name of the pet
|
||||||
|
* @param status Updated status of the pet
|
||||||
|
*/
|
||||||
|
|
||||||
|
case class InlineObject(
|
||||||
|
name: Option[String],
|
||||||
|
status: Option[String]
|
||||||
|
)
|
||||||
|
|
||||||
|
object InlineObject {
|
||||||
|
implicit lazy val inlineObjectJsonFormat: Format[InlineObject] = Json.format[InlineObject]
|
||||||
|
}
|
||||||
|
|
||||||
@@ -0,0 +1,20 @@
|
|||||||
|
package model
|
||||||
|
|
||||||
|
import play.api.libs.json._
|
||||||
|
import play.api.libs.Files.TemporaryFile
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Represents the Swagger definition for inline_object_1.
|
||||||
|
* @param additionalMetadata Additional data to pass to server
|
||||||
|
* @param file file to upload
|
||||||
|
*/
|
||||||
|
|
||||||
|
case class InlineObject1(
|
||||||
|
additionalMetadata: Option[String],
|
||||||
|
file: Option[TemporaryFile]
|
||||||
|
)
|
||||||
|
|
||||||
|
object InlineObject1 {
|
||||||
|
// NOTE: The JSON format for InlineObject1 was not generated because it contains a file variable which cannot be encoded to JSON.
|
||||||
|
}
|
||||||
|
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
{
|
{
|
||||||
"openapi" : "3.0.1",
|
"openapi" : "3.0.0",
|
||||||
"info" : {
|
"info" : {
|
||||||
"description" : "This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.",
|
"description" : "This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.",
|
||||||
"license" : {
|
"license" : {
|
||||||
@@ -9,6 +9,10 @@
|
|||||||
"title" : "OpenAPI Petstore",
|
"title" : "OpenAPI Petstore",
|
||||||
"version" : "1.0.0"
|
"version" : "1.0.0"
|
||||||
},
|
},
|
||||||
|
"externalDocs" : {
|
||||||
|
"description" : "Find out more about Swagger",
|
||||||
|
"url" : "http://swagger.io"
|
||||||
|
},
|
||||||
"servers" : [ {
|
"servers" : [ {
|
||||||
"url" : "http://petstore.swagger.io/v2"
|
"url" : "http://petstore.swagger.io/v2"
|
||||||
} ],
|
} ],
|
||||||
@@ -27,24 +31,25 @@
|
|||||||
"post" : {
|
"post" : {
|
||||||
"operationId" : "addPet",
|
"operationId" : "addPet",
|
||||||
"requestBody" : {
|
"requestBody" : {
|
||||||
"content" : {
|
"$ref" : "#/components/requestBodies/Pet"
|
||||||
"application/json" : {
|
|
||||||
"schema" : {
|
|
||||||
"$ref" : "#/components/schemas/Pet"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"application/xml" : {
|
|
||||||
"schema" : {
|
|
||||||
"$ref" : "#/components/schemas/Pet"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"description" : "Pet object that needs to be added to the store",
|
|
||||||
"required" : true
|
|
||||||
},
|
},
|
||||||
"responses" : {
|
"responses" : {
|
||||||
|
"200" : {
|
||||||
|
"content" : {
|
||||||
|
"application/xml" : {
|
||||||
|
"schema" : {
|
||||||
|
"$ref" : "#/components/schemas/Pet"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"application/json" : {
|
||||||
|
"schema" : {
|
||||||
|
"$ref" : "#/components/schemas/Pet"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"description" : "successful operation"
|
||||||
|
},
|
||||||
"405" : {
|
"405" : {
|
||||||
"content" : { },
|
|
||||||
"description" : "Invalid input"
|
"description" : "Invalid input"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@@ -52,38 +57,36 @@
|
|||||||
"petstore_auth" : [ "write:pets", "read:pets" ]
|
"petstore_auth" : [ "write:pets", "read:pets" ]
|
||||||
} ],
|
} ],
|
||||||
"summary" : "Add a new pet to the store",
|
"summary" : "Add a new pet to the store",
|
||||||
"tags" : [ "pet" ],
|
"tags" : [ "pet" ]
|
||||||
"x-codegen-request-body-name" : "body"
|
|
||||||
},
|
},
|
||||||
"put" : {
|
"put" : {
|
||||||
"operationId" : "updatePet",
|
"operationId" : "updatePet",
|
||||||
"requestBody" : {
|
"requestBody" : {
|
||||||
"content" : {
|
"$ref" : "#/components/requestBodies/Pet"
|
||||||
"application/json" : {
|
|
||||||
"schema" : {
|
|
||||||
"$ref" : "#/components/schemas/Pet"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"application/xml" : {
|
|
||||||
"schema" : {
|
|
||||||
"$ref" : "#/components/schemas/Pet"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"description" : "Pet object that needs to be added to the store",
|
|
||||||
"required" : true
|
|
||||||
},
|
},
|
||||||
"responses" : {
|
"responses" : {
|
||||||
|
"200" : {
|
||||||
|
"content" : {
|
||||||
|
"application/xml" : {
|
||||||
|
"schema" : {
|
||||||
|
"$ref" : "#/components/schemas/Pet"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"application/json" : {
|
||||||
|
"schema" : {
|
||||||
|
"$ref" : "#/components/schemas/Pet"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"description" : "successful operation"
|
||||||
|
},
|
||||||
"400" : {
|
"400" : {
|
||||||
"content" : { },
|
|
||||||
"description" : "Invalid ID supplied"
|
"description" : "Invalid ID supplied"
|
||||||
},
|
},
|
||||||
"404" : {
|
"404" : {
|
||||||
"content" : { },
|
|
||||||
"description" : "Pet not found"
|
"description" : "Pet not found"
|
||||||
},
|
},
|
||||||
"405" : {
|
"405" : {
|
||||||
"content" : { },
|
|
||||||
"description" : "Validation exception"
|
"description" : "Validation exception"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@@ -91,8 +94,7 @@
|
|||||||
"petstore_auth" : [ "write:pets", "read:pets" ]
|
"petstore_auth" : [ "write:pets", "read:pets" ]
|
||||||
} ],
|
} ],
|
||||||
"summary" : "Update an existing pet",
|
"summary" : "Update an existing pet",
|
||||||
"tags" : [ "pet" ],
|
"tags" : [ "pet" ]
|
||||||
"x-codegen-request-body-name" : "body"
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"/pet/findByStatus" : {
|
"/pet/findByStatus" : {
|
||||||
@@ -138,12 +140,11 @@
|
|||||||
"description" : "successful operation"
|
"description" : "successful operation"
|
||||||
},
|
},
|
||||||
"400" : {
|
"400" : {
|
||||||
"content" : { },
|
|
||||||
"description" : "Invalid status value"
|
"description" : "Invalid status value"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"security" : [ {
|
"security" : [ {
|
||||||
"petstore_auth" : [ "write:pets", "read:pets" ]
|
"petstore_auth" : [ "read:pets" ]
|
||||||
} ],
|
} ],
|
||||||
"summary" : "Finds Pets by status",
|
"summary" : "Finds Pets by status",
|
||||||
"tags" : [ "pet" ]
|
"tags" : [ "pet" ]
|
||||||
@@ -191,12 +192,11 @@
|
|||||||
"description" : "successful operation"
|
"description" : "successful operation"
|
||||||
},
|
},
|
||||||
"400" : {
|
"400" : {
|
||||||
"content" : { },
|
|
||||||
"description" : "Invalid tag value"
|
"description" : "Invalid tag value"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"security" : [ {
|
"security" : [ {
|
||||||
"petstore_auth" : [ "write:pets", "read:pets" ]
|
"petstore_auth" : [ "read:pets" ]
|
||||||
} ],
|
} ],
|
||||||
"summary" : "Finds Pets by tags",
|
"summary" : "Finds Pets by tags",
|
||||||
"tags" : [ "pet" ]
|
"tags" : [ "pet" ]
|
||||||
@@ -206,24 +206,28 @@
|
|||||||
"delete" : {
|
"delete" : {
|
||||||
"operationId" : "deletePet",
|
"operationId" : "deletePet",
|
||||||
"parameters" : [ {
|
"parameters" : [ {
|
||||||
|
"explode" : false,
|
||||||
"in" : "header",
|
"in" : "header",
|
||||||
"name" : "api_key",
|
"name" : "api_key",
|
||||||
|
"required" : false,
|
||||||
"schema" : {
|
"schema" : {
|
||||||
"type" : "string"
|
"type" : "string"
|
||||||
}
|
},
|
||||||
|
"style" : "simple"
|
||||||
}, {
|
}, {
|
||||||
"description" : "Pet id to delete",
|
"description" : "Pet id to delete",
|
||||||
|
"explode" : false,
|
||||||
"in" : "path",
|
"in" : "path",
|
||||||
"name" : "petId",
|
"name" : "petId",
|
||||||
"required" : true,
|
"required" : true,
|
||||||
"schema" : {
|
"schema" : {
|
||||||
"format" : "int64",
|
"format" : "int64",
|
||||||
"type" : "integer"
|
"type" : "integer"
|
||||||
}
|
},
|
||||||
|
"style" : "simple"
|
||||||
} ],
|
} ],
|
||||||
"responses" : {
|
"responses" : {
|
||||||
"400" : {
|
"400" : {
|
||||||
"content" : { },
|
|
||||||
"description" : "Invalid pet value"
|
"description" : "Invalid pet value"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@@ -238,13 +242,15 @@
|
|||||||
"operationId" : "getPetById",
|
"operationId" : "getPetById",
|
||||||
"parameters" : [ {
|
"parameters" : [ {
|
||||||
"description" : "ID of pet to return",
|
"description" : "ID of pet to return",
|
||||||
|
"explode" : false,
|
||||||
"in" : "path",
|
"in" : "path",
|
||||||
"name" : "petId",
|
"name" : "petId",
|
||||||
"required" : true,
|
"required" : true,
|
||||||
"schema" : {
|
"schema" : {
|
||||||
"format" : "int64",
|
"format" : "int64",
|
||||||
"type" : "integer"
|
"type" : "integer"
|
||||||
}
|
},
|
||||||
|
"style" : "simple"
|
||||||
} ],
|
} ],
|
||||||
"responses" : {
|
"responses" : {
|
||||||
"200" : {
|
"200" : {
|
||||||
@@ -263,11 +269,9 @@
|
|||||||
"description" : "successful operation"
|
"description" : "successful operation"
|
||||||
},
|
},
|
||||||
"400" : {
|
"400" : {
|
||||||
"content" : { },
|
|
||||||
"description" : "Invalid ID supplied"
|
"description" : "Invalid ID supplied"
|
||||||
},
|
},
|
||||||
"404" : {
|
"404" : {
|
||||||
"content" : { },
|
|
||||||
"description" : "Pet not found"
|
"description" : "Pet not found"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@@ -281,15 +285,18 @@
|
|||||||
"operationId" : "updatePetWithForm",
|
"operationId" : "updatePetWithForm",
|
||||||
"parameters" : [ {
|
"parameters" : [ {
|
||||||
"description" : "ID of pet that needs to be updated",
|
"description" : "ID of pet that needs to be updated",
|
||||||
|
"explode" : false,
|
||||||
"in" : "path",
|
"in" : "path",
|
||||||
"name" : "petId",
|
"name" : "petId",
|
||||||
"required" : true,
|
"required" : true,
|
||||||
"schema" : {
|
"schema" : {
|
||||||
"format" : "int64",
|
"format" : "int64",
|
||||||
"type" : "integer"
|
"type" : "integer"
|
||||||
}
|
},
|
||||||
|
"style" : "simple"
|
||||||
} ],
|
} ],
|
||||||
"requestBody" : {
|
"requestBody" : {
|
||||||
|
"$ref" : "#/components/requestBodies/inline_object",
|
||||||
"content" : {
|
"content" : {
|
||||||
"application/x-www-form-urlencoded" : {
|
"application/x-www-form-urlencoded" : {
|
||||||
"schema" : {
|
"schema" : {
|
||||||
@@ -302,14 +309,14 @@
|
|||||||
"description" : "Updated status of the pet",
|
"description" : "Updated status of the pet",
|
||||||
"type" : "string"
|
"type" : "string"
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
|
"type" : "object"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"responses" : {
|
"responses" : {
|
||||||
"405" : {
|
"405" : {
|
||||||
"content" : { },
|
|
||||||
"description" : "Invalid input"
|
"description" : "Invalid input"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@@ -325,15 +332,18 @@
|
|||||||
"operationId" : "uploadFile",
|
"operationId" : "uploadFile",
|
||||||
"parameters" : [ {
|
"parameters" : [ {
|
||||||
"description" : "ID of pet to update",
|
"description" : "ID of pet to update",
|
||||||
|
"explode" : false,
|
||||||
"in" : "path",
|
"in" : "path",
|
||||||
"name" : "petId",
|
"name" : "petId",
|
||||||
"required" : true,
|
"required" : true,
|
||||||
"schema" : {
|
"schema" : {
|
||||||
"format" : "int64",
|
"format" : "int64",
|
||||||
"type" : "integer"
|
"type" : "integer"
|
||||||
}
|
},
|
||||||
|
"style" : "simple"
|
||||||
} ],
|
} ],
|
||||||
"requestBody" : {
|
"requestBody" : {
|
||||||
|
"$ref" : "#/components/requestBodies/inline_object_1",
|
||||||
"content" : {
|
"content" : {
|
||||||
"multipart/form-data" : {
|
"multipart/form-data" : {
|
||||||
"schema" : {
|
"schema" : {
|
||||||
@@ -347,7 +357,8 @@
|
|||||||
"format" : "binary",
|
"format" : "binary",
|
||||||
"type" : "string"
|
"type" : "string"
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
|
"type" : "object"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -403,7 +414,7 @@
|
|||||||
"operationId" : "placeOrder",
|
"operationId" : "placeOrder",
|
||||||
"requestBody" : {
|
"requestBody" : {
|
||||||
"content" : {
|
"content" : {
|
||||||
"*/*" : {
|
"application/json" : {
|
||||||
"schema" : {
|
"schema" : {
|
||||||
"$ref" : "#/components/schemas/Order"
|
"$ref" : "#/components/schemas/Order"
|
||||||
}
|
}
|
||||||
@@ -429,13 +440,11 @@
|
|||||||
"description" : "successful operation"
|
"description" : "successful operation"
|
||||||
},
|
},
|
||||||
"400" : {
|
"400" : {
|
||||||
"content" : { },
|
|
||||||
"description" : "Invalid Order"
|
"description" : "Invalid Order"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"summary" : "Place an order for a pet",
|
"summary" : "Place an order for a pet",
|
||||||
"tags" : [ "store" ],
|
"tags" : [ "store" ]
|
||||||
"x-codegen-request-body-name" : "body"
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"/store/order/{orderId}" : {
|
"/store/order/{orderId}" : {
|
||||||
@@ -444,20 +453,20 @@
|
|||||||
"operationId" : "deleteOrder",
|
"operationId" : "deleteOrder",
|
||||||
"parameters" : [ {
|
"parameters" : [ {
|
||||||
"description" : "ID of the order that needs to be deleted",
|
"description" : "ID of the order that needs to be deleted",
|
||||||
|
"explode" : false,
|
||||||
"in" : "path",
|
"in" : "path",
|
||||||
"name" : "orderId",
|
"name" : "orderId",
|
||||||
"required" : true,
|
"required" : true,
|
||||||
"schema" : {
|
"schema" : {
|
||||||
"type" : "string"
|
"type" : "string"
|
||||||
}
|
},
|
||||||
|
"style" : "simple"
|
||||||
} ],
|
} ],
|
||||||
"responses" : {
|
"responses" : {
|
||||||
"400" : {
|
"400" : {
|
||||||
"content" : { },
|
|
||||||
"description" : "Invalid ID supplied"
|
"description" : "Invalid ID supplied"
|
||||||
},
|
},
|
||||||
"404" : {
|
"404" : {
|
||||||
"content" : { },
|
|
||||||
"description" : "Order not found"
|
"description" : "Order not found"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@@ -469,6 +478,7 @@
|
|||||||
"operationId" : "getOrderById",
|
"operationId" : "getOrderById",
|
||||||
"parameters" : [ {
|
"parameters" : [ {
|
||||||
"description" : "ID of pet that needs to be fetched",
|
"description" : "ID of pet that needs to be fetched",
|
||||||
|
"explode" : false,
|
||||||
"in" : "path",
|
"in" : "path",
|
||||||
"name" : "orderId",
|
"name" : "orderId",
|
||||||
"required" : true,
|
"required" : true,
|
||||||
@@ -477,7 +487,8 @@
|
|||||||
"maximum" : 5,
|
"maximum" : 5,
|
||||||
"minimum" : 1,
|
"minimum" : 1,
|
||||||
"type" : "integer"
|
"type" : "integer"
|
||||||
}
|
},
|
||||||
|
"style" : "simple"
|
||||||
} ],
|
} ],
|
||||||
"responses" : {
|
"responses" : {
|
||||||
"200" : {
|
"200" : {
|
||||||
@@ -496,11 +507,9 @@
|
|||||||
"description" : "successful operation"
|
"description" : "successful operation"
|
||||||
},
|
},
|
||||||
"400" : {
|
"400" : {
|
||||||
"content" : { },
|
|
||||||
"description" : "Invalid ID supplied"
|
"description" : "Invalid ID supplied"
|
||||||
},
|
},
|
||||||
"404" : {
|
"404" : {
|
||||||
"content" : { },
|
|
||||||
"description" : "Order not found"
|
"description" : "Order not found"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@@ -514,7 +523,7 @@
|
|||||||
"operationId" : "createUser",
|
"operationId" : "createUser",
|
||||||
"requestBody" : {
|
"requestBody" : {
|
||||||
"content" : {
|
"content" : {
|
||||||
"*/*" : {
|
"application/json" : {
|
||||||
"schema" : {
|
"schema" : {
|
||||||
"$ref" : "#/components/schemas/User"
|
"$ref" : "#/components/schemas/User"
|
||||||
}
|
}
|
||||||
@@ -525,69 +534,50 @@
|
|||||||
},
|
},
|
||||||
"responses" : {
|
"responses" : {
|
||||||
"default" : {
|
"default" : {
|
||||||
"content" : { },
|
|
||||||
"description" : "successful operation"
|
"description" : "successful operation"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"security" : [ {
|
||||||
|
"api_key" : [ ]
|
||||||
|
} ],
|
||||||
"summary" : "Create user",
|
"summary" : "Create user",
|
||||||
"tags" : [ "user" ],
|
"tags" : [ "user" ]
|
||||||
"x-codegen-request-body-name" : "body"
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"/user/createWithArray" : {
|
"/user/createWithArray" : {
|
||||||
"post" : {
|
"post" : {
|
||||||
"operationId" : "createUsersWithArrayInput",
|
"operationId" : "createUsersWithArrayInput",
|
||||||
"requestBody" : {
|
"requestBody" : {
|
||||||
"content" : {
|
"$ref" : "#/components/requestBodies/UserArray"
|
||||||
"*/*" : {
|
|
||||||
"schema" : {
|
|
||||||
"items" : {
|
|
||||||
"$ref" : "#/components/schemas/User"
|
|
||||||
},
|
|
||||||
"type" : "array"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"description" : "List of user object",
|
|
||||||
"required" : true
|
|
||||||
},
|
},
|
||||||
"responses" : {
|
"responses" : {
|
||||||
"default" : {
|
"default" : {
|
||||||
"content" : { },
|
|
||||||
"description" : "successful operation"
|
"description" : "successful operation"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"security" : [ {
|
||||||
|
"api_key" : [ ]
|
||||||
|
} ],
|
||||||
"summary" : "Creates list of users with given input array",
|
"summary" : "Creates list of users with given input array",
|
||||||
"tags" : [ "user" ],
|
"tags" : [ "user" ]
|
||||||
"x-codegen-request-body-name" : "body"
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"/user/createWithList" : {
|
"/user/createWithList" : {
|
||||||
"post" : {
|
"post" : {
|
||||||
"operationId" : "createUsersWithListInput",
|
"operationId" : "createUsersWithListInput",
|
||||||
"requestBody" : {
|
"requestBody" : {
|
||||||
"content" : {
|
"$ref" : "#/components/requestBodies/UserArray"
|
||||||
"*/*" : {
|
|
||||||
"schema" : {
|
|
||||||
"items" : {
|
|
||||||
"$ref" : "#/components/schemas/User"
|
|
||||||
},
|
|
||||||
"type" : "array"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"description" : "List of user object",
|
|
||||||
"required" : true
|
|
||||||
},
|
},
|
||||||
"responses" : {
|
"responses" : {
|
||||||
"default" : {
|
"default" : {
|
||||||
"content" : { },
|
|
||||||
"description" : "successful operation"
|
"description" : "successful operation"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"security" : [ {
|
||||||
|
"api_key" : [ ]
|
||||||
|
} ],
|
||||||
"summary" : "Creates list of users with given input array",
|
"summary" : "Creates list of users with given input array",
|
||||||
"tags" : [ "user" ],
|
"tags" : [ "user" ]
|
||||||
"x-codegen-request-body-name" : "body"
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"/user/login" : {
|
"/user/login" : {
|
||||||
@@ -595,20 +585,25 @@
|
|||||||
"operationId" : "loginUser",
|
"operationId" : "loginUser",
|
||||||
"parameters" : [ {
|
"parameters" : [ {
|
||||||
"description" : "The user name for login",
|
"description" : "The user name for login",
|
||||||
|
"explode" : true,
|
||||||
"in" : "query",
|
"in" : "query",
|
||||||
"name" : "username",
|
"name" : "username",
|
||||||
"required" : true,
|
"required" : true,
|
||||||
"schema" : {
|
"schema" : {
|
||||||
|
"pattern" : "^[a-zA-Z0-9]+[a-zA-Z0-9\\.\\-_]*[a-zA-Z0-9]+$",
|
||||||
"type" : "string"
|
"type" : "string"
|
||||||
}
|
},
|
||||||
|
"style" : "form"
|
||||||
}, {
|
}, {
|
||||||
"description" : "The password for login in clear text",
|
"description" : "The password for login in clear text",
|
||||||
|
"explode" : true,
|
||||||
"in" : "query",
|
"in" : "query",
|
||||||
"name" : "password",
|
"name" : "password",
|
||||||
"required" : true,
|
"required" : true,
|
||||||
"schema" : {
|
"schema" : {
|
||||||
"type" : "string"
|
"type" : "string"
|
||||||
}
|
},
|
||||||
|
"style" : "form"
|
||||||
} ],
|
} ],
|
||||||
"responses" : {
|
"responses" : {
|
||||||
"200" : {
|
"200" : {
|
||||||
@@ -626,24 +621,36 @@
|
|||||||
},
|
},
|
||||||
"description" : "successful operation",
|
"description" : "successful operation",
|
||||||
"headers" : {
|
"headers" : {
|
||||||
|
"Set-Cookie" : {
|
||||||
|
"description" : "Cookie authentication key for use with the `api_key` apiKey authentication.",
|
||||||
|
"explode" : false,
|
||||||
|
"schema" : {
|
||||||
|
"example" : "AUTH_KEY=abcde12345; Path=/; HttpOnly",
|
||||||
|
"type" : "string"
|
||||||
|
},
|
||||||
|
"style" : "simple"
|
||||||
|
},
|
||||||
"X-Rate-Limit" : {
|
"X-Rate-Limit" : {
|
||||||
"description" : "calls per hour allowed by the user",
|
"description" : "calls per hour allowed by the user",
|
||||||
|
"explode" : false,
|
||||||
"schema" : {
|
"schema" : {
|
||||||
"format" : "int32",
|
"format" : "int32",
|
||||||
"type" : "integer"
|
"type" : "integer"
|
||||||
}
|
},
|
||||||
|
"style" : "simple"
|
||||||
},
|
},
|
||||||
"X-Expires-After" : {
|
"X-Expires-After" : {
|
||||||
"description" : "date in UTC when toekn expires",
|
"description" : "date in UTC when toekn expires",
|
||||||
|
"explode" : false,
|
||||||
"schema" : {
|
"schema" : {
|
||||||
"format" : "date-time",
|
"format" : "date-time",
|
||||||
"type" : "string"
|
"type" : "string"
|
||||||
}
|
},
|
||||||
|
"style" : "simple"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"400" : {
|
"400" : {
|
||||||
"content" : { },
|
|
||||||
"description" : "Invalid username/password supplied"
|
"description" : "Invalid username/password supplied"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@@ -656,10 +663,12 @@
|
|||||||
"operationId" : "logoutUser",
|
"operationId" : "logoutUser",
|
||||||
"responses" : {
|
"responses" : {
|
||||||
"default" : {
|
"default" : {
|
||||||
"content" : { },
|
|
||||||
"description" : "successful operation"
|
"description" : "successful operation"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"security" : [ {
|
||||||
|
"api_key" : [ ]
|
||||||
|
} ],
|
||||||
"summary" : "Logs out current logged in user session",
|
"summary" : "Logs out current logged in user session",
|
||||||
"tags" : [ "user" ]
|
"tags" : [ "user" ]
|
||||||
}
|
}
|
||||||
@@ -670,23 +679,26 @@
|
|||||||
"operationId" : "deleteUser",
|
"operationId" : "deleteUser",
|
||||||
"parameters" : [ {
|
"parameters" : [ {
|
||||||
"description" : "The name that needs to be deleted",
|
"description" : "The name that needs to be deleted",
|
||||||
|
"explode" : false,
|
||||||
"in" : "path",
|
"in" : "path",
|
||||||
"name" : "username",
|
"name" : "username",
|
||||||
"required" : true,
|
"required" : true,
|
||||||
"schema" : {
|
"schema" : {
|
||||||
"type" : "string"
|
"type" : "string"
|
||||||
}
|
},
|
||||||
|
"style" : "simple"
|
||||||
} ],
|
} ],
|
||||||
"responses" : {
|
"responses" : {
|
||||||
"400" : {
|
"400" : {
|
||||||
"content" : { },
|
|
||||||
"description" : "Invalid username supplied"
|
"description" : "Invalid username supplied"
|
||||||
},
|
},
|
||||||
"404" : {
|
"404" : {
|
||||||
"content" : { },
|
|
||||||
"description" : "User not found"
|
"description" : "User not found"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"security" : [ {
|
||||||
|
"api_key" : [ ]
|
||||||
|
} ],
|
||||||
"summary" : "Delete user",
|
"summary" : "Delete user",
|
||||||
"tags" : [ "user" ]
|
"tags" : [ "user" ]
|
||||||
},
|
},
|
||||||
@@ -694,12 +706,14 @@
|
|||||||
"operationId" : "getUserByName",
|
"operationId" : "getUserByName",
|
||||||
"parameters" : [ {
|
"parameters" : [ {
|
||||||
"description" : "The name that needs to be fetched. Use user1 for testing.",
|
"description" : "The name that needs to be fetched. Use user1 for testing.",
|
||||||
|
"explode" : false,
|
||||||
"in" : "path",
|
"in" : "path",
|
||||||
"name" : "username",
|
"name" : "username",
|
||||||
"required" : true,
|
"required" : true,
|
||||||
"schema" : {
|
"schema" : {
|
||||||
"type" : "string"
|
"type" : "string"
|
||||||
}
|
},
|
||||||
|
"style" : "simple"
|
||||||
} ],
|
} ],
|
||||||
"responses" : {
|
"responses" : {
|
||||||
"200" : {
|
"200" : {
|
||||||
@@ -718,11 +732,9 @@
|
|||||||
"description" : "successful operation"
|
"description" : "successful operation"
|
||||||
},
|
},
|
||||||
"400" : {
|
"400" : {
|
||||||
"content" : { },
|
|
||||||
"description" : "Invalid username supplied"
|
"description" : "Invalid username supplied"
|
||||||
},
|
},
|
||||||
"404" : {
|
"404" : {
|
||||||
"content" : { },
|
|
||||||
"description" : "User not found"
|
"description" : "User not found"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@@ -734,16 +746,18 @@
|
|||||||
"operationId" : "updateUser",
|
"operationId" : "updateUser",
|
||||||
"parameters" : [ {
|
"parameters" : [ {
|
||||||
"description" : "name that need to be deleted",
|
"description" : "name that need to be deleted",
|
||||||
|
"explode" : false,
|
||||||
"in" : "path",
|
"in" : "path",
|
||||||
"name" : "username",
|
"name" : "username",
|
||||||
"required" : true,
|
"required" : true,
|
||||||
"schema" : {
|
"schema" : {
|
||||||
"type" : "string"
|
"type" : "string"
|
||||||
}
|
},
|
||||||
|
"style" : "simple"
|
||||||
} ],
|
} ],
|
||||||
"requestBody" : {
|
"requestBody" : {
|
||||||
"content" : {
|
"content" : {
|
||||||
"*/*" : {
|
"application/json" : {
|
||||||
"schema" : {
|
"schema" : {
|
||||||
"$ref" : "#/components/schemas/User"
|
"$ref" : "#/components/schemas/User"
|
||||||
}
|
}
|
||||||
@@ -754,21 +768,71 @@
|
|||||||
},
|
},
|
||||||
"responses" : {
|
"responses" : {
|
||||||
"400" : {
|
"400" : {
|
||||||
"content" : { },
|
|
||||||
"description" : "Invalid user supplied"
|
"description" : "Invalid user supplied"
|
||||||
},
|
},
|
||||||
"404" : {
|
"404" : {
|
||||||
"content" : { },
|
|
||||||
"description" : "User not found"
|
"description" : "User not found"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"security" : [ {
|
||||||
|
"api_key" : [ ]
|
||||||
|
} ],
|
||||||
"summary" : "Updated user",
|
"summary" : "Updated user",
|
||||||
"tags" : [ "user" ],
|
"tags" : [ "user" ]
|
||||||
"x-codegen-request-body-name" : "body"
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"components" : {
|
"components" : {
|
||||||
|
"requestBodies" : {
|
||||||
|
"UserArray" : {
|
||||||
|
"content" : {
|
||||||
|
"application/json" : {
|
||||||
|
"schema" : {
|
||||||
|
"items" : {
|
||||||
|
"$ref" : "#/components/schemas/User"
|
||||||
|
},
|
||||||
|
"type" : "array"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"description" : "List of user object",
|
||||||
|
"required" : true
|
||||||
|
},
|
||||||
|
"Pet" : {
|
||||||
|
"content" : {
|
||||||
|
"application/json" : {
|
||||||
|
"schema" : {
|
||||||
|
"$ref" : "#/components/schemas/Pet"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"application/xml" : {
|
||||||
|
"schema" : {
|
||||||
|
"$ref" : "#/components/schemas/Pet"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"description" : "Pet object that needs to be added to the store",
|
||||||
|
"required" : true
|
||||||
|
},
|
||||||
|
"inline_object" : {
|
||||||
|
"content" : {
|
||||||
|
"application/x-www-form-urlencoded" : {
|
||||||
|
"schema" : {
|
||||||
|
"$ref" : "#/components/schemas/inline_object"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"inline_object_1" : {
|
||||||
|
"content" : {
|
||||||
|
"multipart/form-data" : {
|
||||||
|
"schema" : {
|
||||||
|
"$ref" : "#/components/schemas/inline_object_1"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
"schemas" : {
|
"schemas" : {
|
||||||
"Order" : {
|
"Order" : {
|
||||||
"description" : "An order for a pets from the pet store",
|
"description" : "An order for a pets from the pet store",
|
||||||
@@ -825,6 +889,7 @@
|
|||||||
"type" : "integer"
|
"type" : "integer"
|
||||||
},
|
},
|
||||||
"name" : {
|
"name" : {
|
||||||
|
"pattern" : "^[a-zA-Z0-9]+[a-zA-Z0-9\\.\\-_]*[a-zA-Z0-9]+$",
|
||||||
"type" : "string"
|
"type" : "string"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@@ -987,6 +1052,33 @@
|
|||||||
},
|
},
|
||||||
"title" : "An uploaded response",
|
"title" : "An uploaded response",
|
||||||
"type" : "object"
|
"type" : "object"
|
||||||
|
},
|
||||||
|
"inline_object" : {
|
||||||
|
"properties" : {
|
||||||
|
"name" : {
|
||||||
|
"description" : "Updated name of the pet",
|
||||||
|
"type" : "string"
|
||||||
|
},
|
||||||
|
"status" : {
|
||||||
|
"description" : "Updated status of the pet",
|
||||||
|
"type" : "string"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"type" : "object"
|
||||||
|
},
|
||||||
|
"inline_object_1" : {
|
||||||
|
"properties" : {
|
||||||
|
"additionalMetadata" : {
|
||||||
|
"description" : "Additional data to pass to server",
|
||||||
|
"type" : "string"
|
||||||
|
},
|
||||||
|
"file" : {
|
||||||
|
"description" : "file to upload",
|
||||||
|
"format" : "binary",
|
||||||
|
"type" : "string"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"type" : "object"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"securitySchemes" : {
|
"securitySchemes" : {
|
||||||
|
|||||||
@@ -1 +1 @@
|
|||||||
4.3.0-SNAPSHOT
|
5.0.0-SNAPSHOT
|
||||||
Reference in New Issue
Block a user