Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -46,16 +46,12 @@ class {{classname}}Routes(service : {{classname}}Service) extends cask.Routes {

result match {
case Left(error) => cask.Response(error, 500)
{{#vendorExtensions.x-has-response-types}}
{{#responses}}
{{#dataType}}
case Right(value : {{dataType}}) => cask.Response(data = write(value), {{code}}, headers = Seq("Content-Type" -> "application/json"))
{{/dataType}}
{{/responses}}
{{/vendorExtensions.x-has-response-types}}
{{^vendorExtensions.x-has-response-types}}
case Right(_) => cask.Response("", 200)
{{/vendorExtensions.x-has-response-types}}
{{#responses}}
{{#dataType}}
case Right(value : {{dataType}}) => cask.Response(data = write(value), {{code}}, headers = Seq("Content-Type" -> "application/json"))
{{/dataType}}
{{/responses}}
case Right(other) => cask.Response(s"$other", 200)
}
}
{{/operation}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,8 @@ class PetRoutes(service : PetService) extends cask.Routes {

result match {
case Left(error) => cask.Response(error, 500)
case Right(_) => cask.Response("", 200)
case Right(value : Pet) => cask.Response(data = write(value), 200, headers = Seq("Content-Type" -> "application/json"))
case Right(other) => cask.Response(s"$other", 200)
}
}
/** Deletes a pet
Expand All @@ -87,7 +88,7 @@ class PetRoutes(service : PetService) extends cask.Routes {

result match {
case Left(error) => cask.Response(error, 500)
case Right(_) => cask.Response("", 200)
case Right(other) => cask.Response(s"$other", 200)
}
}
/** Finds Pets by status
Expand All @@ -105,7 +106,8 @@ class PetRoutes(service : PetService) extends cask.Routes {

result match {
case Left(error) => cask.Response(error, 500)
case Right(_) => cask.Response("", 200)
case Right(value : List[Pet]) => cask.Response(data = write(value), 200, headers = Seq("Content-Type" -> "application/json"))
case Right(other) => cask.Response(s"$other", 200)
}
}
/** Finds Pets by tags
Expand All @@ -123,7 +125,8 @@ class PetRoutes(service : PetService) extends cask.Routes {

result match {
case Left(error) => cask.Response(error, 500)
case Right(_) => cask.Response("", 200)
case Right(value : List[Pet]) => cask.Response(data = write(value), 200, headers = Seq("Content-Type" -> "application/json"))
case Right(other) => cask.Response(s"$other", 200)
}
}
/** Find pet by ID
Expand All @@ -142,7 +145,8 @@ class PetRoutes(service : PetService) extends cask.Routes {

result match {
case Left(error) => cask.Response(error, 500)
case Right(_) => cask.Response("", 200)
case Right(value : Pet) => cask.Response(data = write(value), 200, headers = Seq("Content-Type" -> "application/json"))
case Right(other) => cask.Response(s"$other", 200)
}
}
/** Update an existing pet
Expand All @@ -162,7 +166,8 @@ class PetRoutes(service : PetService) extends cask.Routes {

result match {
case Left(error) => cask.Response(error, 500)
case Right(_) => cask.Response("", 200)
case Right(value : Pet) => cask.Response(data = write(value), 200, headers = Seq("Content-Type" -> "application/json"))
case Right(other) => cask.Response(s"$other", 200)
}
}
/** Updates a pet in the store with form data
Expand All @@ -183,7 +188,7 @@ class PetRoutes(service : PetService) extends cask.Routes {

result match {
case Left(error) => cask.Response(error, 500)
case Right(_) => cask.Response("", 200)
case Right(other) => cask.Response(s"$other", 200)
}
}
/** uploads an image
Expand All @@ -204,7 +209,8 @@ class PetRoutes(service : PetService) extends cask.Routes {

result match {
case Left(error) => cask.Response(error, 500)
case Right(_) => cask.Response("", 200)
case Right(value : ApiResponse) => cask.Response(data = write(value), 200, headers = Seq("Content-Type" -> "application/json"))
case Right(other) => cask.Response(s"$other", 200)
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ class StoreRoutes(service : StoreService) extends cask.Routes {

result match {
case Left(error) => cask.Response(error, 500)
case Right(_) => cask.Response("", 200)
case Right(other) => cask.Response(s"$other", 200)
}
}
/** Returns pet inventories by status
Expand All @@ -61,7 +61,8 @@ class StoreRoutes(service : StoreService) extends cask.Routes {

result match {
case Left(error) => cask.Response(error, 500)
case Right(_) => cask.Response("", 200)
case Right(value : Map[String, Int]) => cask.Response(data = write(value), 200, headers = Seq("Content-Type" -> "application/json"))
case Right(other) => cask.Response(s"$other", 200)
}
}
/** Find purchase order by ID
Expand All @@ -79,7 +80,8 @@ class StoreRoutes(service : StoreService) extends cask.Routes {

result match {
case Left(error) => cask.Response(error, 500)
case Right(_) => cask.Response("", 200)
case Right(value : Order) => cask.Response(data = write(value), 200, headers = Seq("Content-Type" -> "application/json"))
case Right(other) => cask.Response(s"$other", 200)
}
}
/** Place an order for a pet
Expand All @@ -98,7 +100,8 @@ class StoreRoutes(service : StoreService) extends cask.Routes {

result match {
case Left(error) => cask.Response(error, 500)
case Right(_) => cask.Response("", 200)
case Right(value : Order) => cask.Response(data = write(value), 200, headers = Seq("Content-Type" -> "application/json"))
case Right(other) => cask.Response(s"$other", 200)
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ class UserRoutes(service : UserService) extends cask.Routes {

result match {
case Left(error) => cask.Response(error, 500)
case Right(_) => cask.Response("", 200)
case Right(other) => cask.Response(s"$other", 200)
}
}
/** Creates list of users with given input array
Expand All @@ -75,7 +75,7 @@ class UserRoutes(service : UserService) extends cask.Routes {

result match {
case Left(error) => cask.Response(error, 500)
case Right(_) => cask.Response("", 200)
case Right(other) => cask.Response(s"$other", 200)
}
}
/** Creates list of users with given input array
Expand All @@ -94,7 +94,7 @@ class UserRoutes(service : UserService) extends cask.Routes {

result match {
case Left(error) => cask.Response(error, 500)
case Right(_) => cask.Response("", 200)
case Right(other) => cask.Response(s"$other", 200)
}
}
/** Delete user
Expand All @@ -113,7 +113,7 @@ class UserRoutes(service : UserService) extends cask.Routes {

result match {
case Left(error) => cask.Response(error, 500)
case Right(_) => cask.Response("", 200)
case Right(other) => cask.Response(s"$other", 200)
}
}
/** Get user by user name
Expand All @@ -131,7 +131,8 @@ class UserRoutes(service : UserService) extends cask.Routes {

result match {
case Left(error) => cask.Response(error, 500)
case Right(_) => cask.Response("", 200)
case Right(value : User) => cask.Response(data = write(value), 200, headers = Seq("Content-Type" -> "application/json"))
case Right(other) => cask.Response(s"$other", 200)
}
}
/** Logs user into the system
Expand All @@ -148,7 +149,8 @@ class UserRoutes(service : UserService) extends cask.Routes {

result match {
case Left(error) => cask.Response(error, 500)
case Right(_) => cask.Response("", 200)
case Right(value : String) => cask.Response(data = write(value), 200, headers = Seq("Content-Type" -> "application/json"))
case Right(other) => cask.Response(s"$other", 200)
}
}
/** Logs out current logged in user session
Expand All @@ -166,7 +168,7 @@ class UserRoutes(service : UserService) extends cask.Routes {

result match {
case Left(error) => cask.Response(error, 500)
case Right(_) => cask.Response("", 200)
case Right(other) => cask.Response(s"$other", 200)
}
}
/** Updated user
Expand All @@ -187,7 +189,7 @@ class UserRoutes(service : UserService) extends cask.Routes {

result match {
case Left(error) => cask.Response(error, 500)
case Right(_) => cask.Response("", 200)
case Right(other) => cask.Response(s"$other", 200)
}
}

Expand Down