From 4700768aed837be1f9ec7a0864fa48cda253b9c0 Mon Sep 17 00:00:00 2001 From: Evgeniy Alekseev Date: Mon, 11 Nov 2019 10:03:07 +0300 Subject: [PATCH] report errors --- .../ffxivbis/http/api/v1/BiSEndpoint.scala | 33 ++++++++++------ .../ffxivbis/http/api/v1/LootEndpoint.scala | 33 ++++++++++------ .../ffxivbis/http/api/v1/PlayerEndpoint.scala | 21 ++++++---- .../ffxivbis/http/api/v1/UserEndpoint.scala | 39 ++++++++++++------- .../me/arcanis/ffxivbis/models/Job.scala | 2 +- 5 files changed, 85 insertions(+), 43 deletions(-) diff --git a/src/main/scala/me/arcanis/ffxivbis/http/api/v1/BiSEndpoint.scala b/src/main/scala/me/arcanis/ffxivbis/http/api/v1/BiSEndpoint.scala index 0a86d01..6bb4dc4 100644 --- a/src/main/scala/me/arcanis/ffxivbis/http/api/v1/BiSEndpoint.scala +++ b/src/main/scala/me/arcanis/ffxivbis/http/api/v1/BiSEndpoint.scala @@ -43,10 +43,14 @@ class BiSEndpoint(override val storage: ActorRef, ariyala: ActorRef)(implicit ti content = Array(new Content(schema = new Schema(implementation = classOf[PlayerBiSLinkResponse])))), responses = Array( new ApiResponse(responseCode = "201", description = "Best in slot set has been created"), - new ApiResponse(responseCode = "400", description = "Invalid parameters were supplied"), - new ApiResponse(responseCode = "401", description = "Supplied authorization is invalid"), - new ApiResponse(responseCode = "403", description = "Access is forbidden"), - new ApiResponse(responseCode = "500", description = "Internal server error"), + new ApiResponse(responseCode = "400", description = "Invalid parameters were supplied", + content = Array(new Content(schema = new Schema(implementation = classOf[ErrorResponse])))), + new ApiResponse(responseCode = "401", description = "Supplied authorization is invalid", + content = Array(new Content(schema = new Schema(implementation = classOf[ErrorResponse])))), + new ApiResponse(responseCode = "403", description = "Access is forbidden", + content = Array(new Content(schema = new Schema(implementation = classOf[ErrorResponse])))), + new ApiResponse(responseCode = "500", description = "Internal server error", + content = Array(new Content(schema = new Schema(implementation = classOf[ErrorResponse])))), ), security = Array(new SecurityRequirement(name = "basic auth", scopes = Array("post"))), tags = Array("best in slot"), @@ -82,9 +86,12 @@ class BiSEndpoint(override val storage: ActorRef, ariyala: ActorRef)(implicit ti content = Array(new Content( array = new ArraySchema(schema = new Schema(implementation = classOf[PlayerResponse])) ))), - new ApiResponse(responseCode = "401", description = "Supplied authorization is invalid"), - new ApiResponse(responseCode = "403", description = "Access is forbidden"), - new ApiResponse(responseCode = "500", description = "Internal server error"), + new ApiResponse(responseCode = "401", description = "Supplied authorization is invalid", + content = Array(new Content(schema = new Schema(implementation = classOf[ErrorResponse])))), + new ApiResponse(responseCode = "403", description = "Access is forbidden", + content = Array(new Content(schema = new Schema(implementation = classOf[ErrorResponse])))), + new ApiResponse(responseCode = "500", description = "Internal server error", + content = Array(new Content(schema = new Schema(implementation = classOf[ErrorResponse])))), ), security = Array(new SecurityRequirement(name = "basic auth", scopes = Array("get"))), tags = Array("best in slot"), @@ -118,10 +125,14 @@ class BiSEndpoint(override val storage: ActorRef, ariyala: ActorRef)(implicit ti content = Array(new Content(schema = new Schema(implementation = classOf[PieceActionResponse])))), responses = Array( new ApiResponse(responseCode = "202", description = "Best in slot set has been modified"), - new ApiResponse(responseCode = "400", description = "Invalid parameters were supplied"), - new ApiResponse(responseCode = "401", description = "Supplied authorization is invalid"), - new ApiResponse(responseCode = "403", description = "Access is forbidden"), - new ApiResponse(responseCode = "500", description = "Internal server error"), + new ApiResponse(responseCode = "400", description = "Invalid parameters were supplied", + content = Array(new Content(schema = new Schema(implementation = classOf[ErrorResponse])))), + new ApiResponse(responseCode = "401", description = "Supplied authorization is invalid", + content = Array(new Content(schema = new Schema(implementation = classOf[ErrorResponse])))), + new ApiResponse(responseCode = "403", description = "Access is forbidden", + content = Array(new Content(schema = new Schema(implementation = classOf[ErrorResponse])))), + new ApiResponse(responseCode = "500", description = "Internal server error", + content = Array(new Content(schema = new Schema(implementation = classOf[ErrorResponse])))), ), security = Array(new SecurityRequirement(name = "basic auth", scopes = Array("post"))), tags = Array("best in slot"), diff --git a/src/main/scala/me/arcanis/ffxivbis/http/api/v1/LootEndpoint.scala b/src/main/scala/me/arcanis/ffxivbis/http/api/v1/LootEndpoint.scala index 53c8092..95f1935 100644 --- a/src/main/scala/me/arcanis/ffxivbis/http/api/v1/LootEndpoint.scala +++ b/src/main/scala/me/arcanis/ffxivbis/http/api/v1/LootEndpoint.scala @@ -46,9 +46,12 @@ class LootEndpoint(override val storage: ActorRef)(implicit timeout: Timeout) content = Array(new Content( array = new ArraySchema(schema = new Schema(implementation = classOf[PlayerResponse])) ))), - new ApiResponse(responseCode = "401", description = "Supplied authorization is invalid"), - new ApiResponse(responseCode = "403", description = "Access is forbidden"), - new ApiResponse(responseCode = "500", description = "Internal server error"), + new ApiResponse(responseCode = "401", description = "Supplied authorization is invalid", + content = Array(new Content(schema = new Schema(implementation = classOf[ErrorResponse])))), + new ApiResponse(responseCode = "403", description = "Access is forbidden", + content = Array(new Content(schema = new Schema(implementation = classOf[ErrorResponse])))), + new ApiResponse(responseCode = "500", description = "Internal server error", + content = Array(new Content(schema = new Schema(implementation = classOf[ErrorResponse])))), ), security = Array(new SecurityRequirement(name = "basic auth", scopes = Array("get"))), tags = Array("loot"), @@ -81,10 +84,14 @@ class LootEndpoint(override val storage: ActorRef)(implicit timeout: Timeout) content = Array(new Content(schema = new Schema(implementation = classOf[PieceActionResponse])))), responses = Array( new ApiResponse(responseCode = "202", description = "Loot list has been modified"), - new ApiResponse(responseCode = "400", description = "Invalid parameters were supplied"), - new ApiResponse(responseCode = "401", description = "Supplied authorization is invalid"), - new ApiResponse(responseCode = "403", description = "Access is forbidden"), - new ApiResponse(responseCode = "500", description = "Internal server error"), + new ApiResponse(responseCode = "400", description = "Invalid parameters were supplied", + content = Array(new Content(schema = new Schema(implementation = classOf[ErrorResponse])))), + new ApiResponse(responseCode = "401", description = "Supplied authorization is invalid", + content = Array(new Content(schema = new Schema(implementation = classOf[ErrorResponse])))), + new ApiResponse(responseCode = "403", description = "Access is forbidden", + content = Array(new Content(schema = new Schema(implementation = classOf[ErrorResponse])))), + new ApiResponse(responseCode = "500", description = "Internal server error", + content = Array(new Content(schema = new Schema(implementation = classOf[ErrorResponse])))), ), security = Array(new SecurityRequirement(name = "basic auth", scopes = Array("post"))), tags = Array("loot"), @@ -121,10 +128,14 @@ class LootEndpoint(override val storage: ActorRef)(implicit timeout: Timeout) content = Array(new Content( array = new ArraySchema(schema = new Schema(implementation = classOf[PlayerIdWithCountersResponse])), ))), - new ApiResponse(responseCode = "400", description = "Invalid parameters were supplied"), - new ApiResponse(responseCode = "401", description = "Supplied authorization is invalid"), - new ApiResponse(responseCode = "403", description = "Access is forbidden"), - new ApiResponse(responseCode = "500", description = "Internal server error"), + new ApiResponse(responseCode = "400", description = "Invalid parameters were supplied", + content = Array(new Content(schema = new Schema(implementation = classOf[ErrorResponse])))), + new ApiResponse(responseCode = "401", description = "Supplied authorization is invalid", + content = Array(new Content(schema = new Schema(implementation = classOf[ErrorResponse])))), + new ApiResponse(responseCode = "403", description = "Access is forbidden", + content = Array(new Content(schema = new Schema(implementation = classOf[ErrorResponse])))), + new ApiResponse(responseCode = "500", description = "Internal server error", + content = Array(new Content(schema = new Schema(implementation = classOf[ErrorResponse])))), ), security = Array(new SecurityRequirement(name = "basic auth", scopes = Array("get"))), tags = Array("loot"), diff --git a/src/main/scala/me/arcanis/ffxivbis/http/api/v1/PlayerEndpoint.scala b/src/main/scala/me/arcanis/ffxivbis/http/api/v1/PlayerEndpoint.scala index c2dc7ef..26ae757 100644 --- a/src/main/scala/me/arcanis/ffxivbis/http/api/v1/PlayerEndpoint.scala +++ b/src/main/scala/me/arcanis/ffxivbis/http/api/v1/PlayerEndpoint.scala @@ -46,9 +46,12 @@ class PlayerEndpoint(override val storage: ActorRef, ariyala: ActorRef)(implicit content = Array(new Content( array = new ArraySchema(schema = new Schema(implementation = classOf[PlayerResponse])), ))), - new ApiResponse(responseCode = "401", description = "Supplied authorization is invalid"), - new ApiResponse(responseCode = "403", description = "Access is forbidden"), - new ApiResponse(responseCode = "500", description = "Internal server error"), + new ApiResponse(responseCode = "401", description = "Supplied authorization is invalid", + content = Array(new Content(schema = new Schema(implementation = classOf[ErrorResponse])))), + new ApiResponse(responseCode = "403", description = "Access is forbidden", + content = Array(new Content(schema = new Schema(implementation = classOf[ErrorResponse])))), + new ApiResponse(responseCode = "500", description = "Internal server error", + content = Array(new Content(schema = new Schema(implementation = classOf[ErrorResponse])))), ), security = Array(new SecurityRequirement(name = "basic auth", scopes = Array("get"))), tags = Array("party"), @@ -81,10 +84,14 @@ class PlayerEndpoint(override val storage: ActorRef, ariyala: ActorRef)(implicit content = Array(new Content(schema = new Schema(implementation = classOf[PlayerActionResponse])))), responses = Array( new ApiResponse(responseCode = "202", description = "Party has been modified"), - new ApiResponse(responseCode = "400", description = "Invalid parameters were supplied"), - new ApiResponse(responseCode = "401", description = "Supplied authorization is invalid"), - new ApiResponse(responseCode = "403", description = "Access is forbidden"), - new ApiResponse(responseCode = "500", description = "Internal server error"), + new ApiResponse(responseCode = "400", description = "Invalid parameters were supplied", + content = Array(new Content(schema = new Schema(implementation = classOf[ErrorResponse])))), + new ApiResponse(responseCode = "401", description = "Supplied authorization is invalid", + content = Array(new Content(schema = new Schema(implementation = classOf[ErrorResponse])))), + new ApiResponse(responseCode = "403", description = "Access is forbidden", + content = Array(new Content(schema = new Schema(implementation = classOf[ErrorResponse])))), + new ApiResponse(responseCode = "500", description = "Internal server error", + content = Array(new Content(schema = new Schema(implementation = classOf[ErrorResponse])))), ), security = Array(new SecurityRequirement(name = "basic auth", scopes = Array("post"))), tags = Array("party"), diff --git a/src/main/scala/me/arcanis/ffxivbis/http/api/v1/UserEndpoint.scala b/src/main/scala/me/arcanis/ffxivbis/http/api/v1/UserEndpoint.scala index aed51fc..3df05a4 100644 --- a/src/main/scala/me/arcanis/ffxivbis/http/api/v1/UserEndpoint.scala +++ b/src/main/scala/me/arcanis/ffxivbis/http/api/v1/UserEndpoint.scala @@ -40,9 +40,12 @@ class UserEndpoint(override val storage: ActorRef)(implicit timeout: Timeout) content = Array(new Content(schema = new Schema(implementation = classOf[UserResponse])))), responses = Array( new ApiResponse(responseCode = "200", description = "Party has been created"), - new ApiResponse(responseCode = "400", description = "Invalid parameters were supplied"), - new ApiResponse(responseCode = "406", description = "Party with the specified ID already exists"), - new ApiResponse(responseCode = "500", description = "Internal server error"), + new ApiResponse(responseCode = "400", description = "Invalid parameters were supplied", + content = Array(new Content(schema = new Schema(implementation = classOf[ErrorResponse])))), + new ApiResponse(responseCode = "406", description = "Party with the specified ID already exists", + content = Array(new Content(schema = new Schema(implementation = classOf[ErrorResponse])))), + new ApiResponse(responseCode = "500", description = "Internal server error", + content = Array(new Content(schema = new Schema(implementation = classOf[ErrorResponse])))), ), tags = Array("party"), ) @@ -76,10 +79,14 @@ class UserEndpoint(override val storage: ActorRef)(implicit timeout: Timeout) content = Array(new Content(schema = new Schema(implementation = classOf[UserResponse])))), responses = Array( new ApiResponse(responseCode = "201", description = "User has been created"), - new ApiResponse(responseCode = "400", description = "Invalid parameters were supplied"), - new ApiResponse(responseCode = "401", description = "Supplied authorization is invalid"), - new ApiResponse(responseCode = "403", description = "Access is forbidden"), - new ApiResponse(responseCode = "500", description = "Internal server error"), + new ApiResponse(responseCode = "400", description = "Invalid parameters were supplied", + content = Array(new Content(schema = new Schema(implementation = classOf[ErrorResponse])))), + new ApiResponse(responseCode = "401", description = "Supplied authorization is invalid", + content = Array(new Content(schema = new Schema(implementation = classOf[ErrorResponse])))), + new ApiResponse(responseCode = "403", description = "Access is forbidden", + content = Array(new Content(schema = new Schema(implementation = classOf[ErrorResponse])))), + new ApiResponse(responseCode = "500", description = "Internal server error", + content = Array(new Content(schema = new Schema(implementation = classOf[ErrorResponse])))), ), security = Array(new SecurityRequirement(name = "basic auth", scopes = Array("admin"))), tags = Array("users"), @@ -110,9 +117,12 @@ class UserEndpoint(override val storage: ActorRef)(implicit timeout: Timeout) ), responses = Array( new ApiResponse(responseCode = "202", description = "User has been removed"), - new ApiResponse(responseCode = "401", description = "Supplied authorization is invalid"), - new ApiResponse(responseCode = "403", description = "Access is forbidden"), - new ApiResponse(responseCode = "500", description = "Internal server error"), + new ApiResponse(responseCode = "401", description = "Supplied authorization is invalid", + content = Array(new Content(schema = new Schema(implementation = classOf[ErrorResponse])))), + new ApiResponse(responseCode = "403", description = "Access is forbidden", + content = Array(new Content(schema = new Schema(implementation = classOf[ErrorResponse])))), + new ApiResponse(responseCode = "500", description = "Internal server error", + content = Array(new Content(schema = new Schema(implementation = classOf[ErrorResponse])))), ), security = Array(new SecurityRequirement(name = "basic auth", scopes = Array("admin"))), tags = Array("users"), @@ -143,9 +153,12 @@ class UserEndpoint(override val storage: ActorRef)(implicit timeout: Timeout) content = Array(new Content( array = new ArraySchema(schema = new Schema(implementation = classOf[UserResponse])), ))), - new ApiResponse(responseCode = "401", description = "Supplied authorization is invalid"), - new ApiResponse(responseCode = "403", description = "Access is forbidden"), - new ApiResponse(responseCode = "500", description = "Internal server error"), + new ApiResponse(responseCode = "401", description = "Supplied authorization is invalid", + content = Array(new Content(schema = new Schema(implementation = classOf[ErrorResponse])))), + new ApiResponse(responseCode = "403", description = "Access is forbidden", + content = Array(new Content(schema = new Schema(implementation = classOf[ErrorResponse])))), + new ApiResponse(responseCode = "500", description = "Internal server error", + content = Array(new Content(schema = new Schema(implementation = classOf[ErrorResponse])))), ), security = Array(new SecurityRequirement(name = "basic auth", scopes = Array("admin"))), tags = Array("users"), diff --git a/src/main/scala/me/arcanis/ffxivbis/models/Job.scala b/src/main/scala/me/arcanis/ffxivbis/models/Job.scala index beaae30..33fd907 100644 --- a/src/main/scala/me/arcanis/ffxivbis/models/Job.scala +++ b/src/main/scala/me/arcanis/ffxivbis/models/Job.scala @@ -35,7 +35,7 @@ object Job { def equality(objRepr: String): Boolean = objRepr match { case _ if objRepr == AnyJob.toString => true case _ if this.toString == AnyJob.toString => true - case _ => this.toString == obj.toString + case _ => this.toString == objRepr } canEqual(obj) && equality(obj.toString)