forked from loafle/openapi-generator-original
Update Scalaz petstore with OAS2, OAS3 (#163)
* update scalaz petstore with oas2 * update scalaz oas3 petstore (no diff)
This commit is contained in:
parent
e4b1613d1e
commit
3e0f959215
31
bin/openapi3/scalaz-petstore.sh
Executable file
31
bin/openapi3/scalaz-petstore.sh
Executable file
@ -0,0 +1,31 @@
|
||||
#!/bin/sh
|
||||
|
||||
SCRIPT="$0"
|
||||
|
||||
while [ -h "$SCRIPT" ] ; do
|
||||
ls=`ls -ld "$SCRIPT"`
|
||||
link=`expr "$ls" : '.*-> \(.*\)$'`
|
||||
if expr "$link" : '/.*' > /dev/null; then
|
||||
SCRIPT="$link"
|
||||
else
|
||||
SCRIPT=`dirname "$SCRIPT"`/"$link"
|
||||
fi
|
||||
done
|
||||
|
||||
if [ ! -d "${APP_DIR}" ]; then
|
||||
APP_DIR=`dirname "$SCRIPT"`/..
|
||||
APP_DIR=`cd "${APP_DIR}"; pwd`
|
||||
fi
|
||||
|
||||
executable="./modules/openapi-generator-cli/target/openapi-generator-cli.jar"
|
||||
|
||||
if [ ! -f "$executable" ]
|
||||
then
|
||||
mvn clean package
|
||||
fi
|
||||
|
||||
# if you've executed sbt assembly previously it will use that instead.
|
||||
export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties"
|
||||
ags="$@ generate -t modules/openapi-generator/src/main/resources/scalaz -i modules/openapi-generator/src/test/resources/2_0/petstore.yaml -l scalaz -o samples/client/petstore/scalaz"
|
||||
|
||||
java $JAVA_OPTS -jar $executable $ags
|
@ -1 +1 @@
|
||||
2.3.0-SNAPSHOT
|
||||
3.0.0-SNAPSHOT
|
@ -11,7 +11,7 @@ import ApiResponse._
|
||||
|
||||
case class ApiResponse (
|
||||
code: Option[Integer],
|
||||
_type: Option[String],
|
||||
`type`: Option[String],
|
||||
message: Option[String])
|
||||
|
||||
object ApiResponse {
|
||||
|
@ -27,7 +27,7 @@ object PetApi {
|
||||
|
||||
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[Unit] = {
|
||||
val path = "/pet"
|
||||
|
||||
val httpMethod = Method.POST
|
||||
@ -40,7 +40,7 @@ object PetApi {
|
||||
for {
|
||||
uri <- Task.fromDisjunction(Uri.fromString(host + path))
|
||||
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(()))
|
||||
|
||||
} yield resp
|
||||
@ -128,7 +128,7 @@ object PetApi {
|
||||
} yield resp
|
||||
}
|
||||
|
||||
def updatePet(host: String, body: Pet): Task[Unit] = {
|
||||
def updatePet(host: String, pet: Pet): Task[Unit] = {
|
||||
val path = "/pet"
|
||||
|
||||
val httpMethod = Method.PUT
|
||||
@ -141,7 +141,7 @@ object PetApi {
|
||||
for {
|
||||
uri <- Task.fromDisjunction(Uri.fromString(host + path))
|
||||
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(()))
|
||||
|
||||
} yield resp
|
||||
@ -194,7 +194,7 @@ class HttpServicePetApi(service: HttpService) {
|
||||
|
||||
def escape(value: String): String = URLEncoder.encode(value, "utf-8").replaceAll("\\+", "%20")
|
||||
|
||||
def addPet(body: Pet): Task[Unit] = {
|
||||
def addPet(pet: Pet): Task[Unit] = {
|
||||
val path = "/pet"
|
||||
|
||||
val httpMethod = Method.POST
|
||||
@ -207,7 +207,7 @@ class HttpServicePetApi(service: HttpService) {
|
||||
for {
|
||||
uri <- Task.fromDisjunction(Uri.fromString(path))
|
||||
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(()))
|
||||
|
||||
} yield resp
|
||||
@ -295,7 +295,7 @@ class HttpServicePetApi(service: HttpService) {
|
||||
} yield resp
|
||||
}
|
||||
|
||||
def updatePet(body: Pet): Task[Unit] = {
|
||||
def updatePet(pet: Pet): Task[Unit] = {
|
||||
val path = "/pet"
|
||||
|
||||
val httpMethod = Method.PUT
|
||||
@ -308,7 +308,7 @@ class HttpServicePetApi(service: HttpService) {
|
||||
for {
|
||||
uri <- Task.fromDisjunction(Uri.fromString(path))
|
||||
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(()))
|
||||
|
||||
} yield resp
|
||||
|
@ -88,7 +88,7 @@ object StoreApi {
|
||||
} 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]
|
||||
|
||||
val path = "/store/order"
|
||||
@ -103,7 +103,7 @@ object StoreApi {
|
||||
for {
|
||||
uri <- Task.fromDisjunction(Uri.fromString(host + path))
|
||||
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)
|
||||
|
||||
} yield resp
|
||||
@ -177,7 +177,7 @@ class HttpServiceStoreApi(service: HttpService) {
|
||||
} yield resp
|
||||
}
|
||||
|
||||
def placeOrder(body: Order): Task[Order] = {
|
||||
def placeOrder(order: Order): Task[Order] = {
|
||||
implicit val returnTypeDecoder: EntityDecoder[Order] = jsonOf[Order]
|
||||
|
||||
val path = "/store/order"
|
||||
@ -192,7 +192,7 @@ class HttpServiceStoreApi(service: HttpService) {
|
||||
for {
|
||||
uri <- Task.fromDisjunction(Uri.fromString(path))
|
||||
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)
|
||||
|
||||
} yield resp
|
||||
|
@ -27,7 +27,7 @@ object UserApi {
|
||||
|
||||
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 httpMethod = Method.POST
|
||||
@ -40,13 +40,13 @@ object UserApi {
|
||||
for {
|
||||
uri <- Task.fromDisjunction(Uri.fromString(host + path))
|
||||
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(()))
|
||||
|
||||
} 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 httpMethod = Method.POST
|
||||
@ -59,13 +59,13 @@ object UserApi {
|
||||
for {
|
||||
uri <- Task.fromDisjunction(Uri.fromString(host + path))
|
||||
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(()))
|
||||
|
||||
} 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 httpMethod = Method.POST
|
||||
@ -78,7 +78,7 @@ object UserApi {
|
||||
for {
|
||||
uri <- Task.fromDisjunction(Uri.fromString(host + path))
|
||||
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(()))
|
||||
|
||||
} yield resp
|
||||
@ -164,7 +164,7 @@ object UserApi {
|
||||
} 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 httpMethod = Method.PUT
|
||||
@ -177,7 +177,7 @@ object UserApi {
|
||||
for {
|
||||
uri <- Task.fromDisjunction(Uri.fromString(host + path))
|
||||
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(()))
|
||||
|
||||
} yield resp
|
||||
@ -190,7 +190,7 @@ class HttpServiceUserApi(service: HttpService) {
|
||||
|
||||
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 httpMethod = Method.POST
|
||||
@ -203,13 +203,13 @@ class HttpServiceUserApi(service: HttpService) {
|
||||
for {
|
||||
uri <- Task.fromDisjunction(Uri.fromString(path))
|
||||
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(()))
|
||||
|
||||
} yield resp
|
||||
}
|
||||
|
||||
def createUsersWithArrayInput(body: List[User]): Task[Unit] = {
|
||||
def createUsersWithArrayInput(user: List[User]): Task[Unit] = {
|
||||
val path = "/user/createWithArray"
|
||||
|
||||
val httpMethod = Method.POST
|
||||
@ -222,13 +222,13 @@ class HttpServiceUserApi(service: HttpService) {
|
||||
for {
|
||||
uri <- Task.fromDisjunction(Uri.fromString(path))
|
||||
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(()))
|
||||
|
||||
} yield resp
|
||||
}
|
||||
|
||||
def createUsersWithListInput(body: List[User]): Task[Unit] = {
|
||||
def createUsersWithListInput(user: List[User]): Task[Unit] = {
|
||||
val path = "/user/createWithList"
|
||||
|
||||
val httpMethod = Method.POST
|
||||
@ -241,7 +241,7 @@ class HttpServiceUserApi(service: HttpService) {
|
||||
for {
|
||||
uri <- Task.fromDisjunction(Uri.fromString(path))
|
||||
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(()))
|
||||
|
||||
} yield resp
|
||||
@ -327,7 +327,7 @@ class HttpServiceUserApi(service: HttpService) {
|
||||
} 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 httpMethod = Method.PUT
|
||||
@ -340,7 +340,7 @@ class HttpServiceUserApi(service: HttpService) {
|
||||
for {
|
||||
uri <- Task.fromDisjunction(Uri.fromString(path))
|
||||
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(()))
|
||||
|
||||
} yield resp
|
||||
|
Loading…
x
Reference in New Issue
Block a user