Skip to content

Commit

Permalink
Refactor error response schema to simplify structure and remove unnec…
Browse files Browse the repository at this point in the history
…essary fields
  • Loading branch information
scruti committed Nov 29, 2024
1 parent 9a7969f commit 2e0cacb
Showing 1 changed file with 14 additions and 61 deletions.
75 changes: 14 additions & 61 deletions spec/swagger_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -208,96 +208,49 @@
bad_request_error: {
type: "object",
properties: {
errors: {
type: "array",
items: {
type: "object",
properties: {
error: { type: "string", example: "Bad request" },
message: { type: "string", example: "Request body could not be read properly" },
},
required: %w[error message],
},
},
error: { type: "string", example: "Request body could not be read properly" },
},
required: %w[error],
},
unauthorized_error: {
type: "object",
properties: {
errors: {
type: "array",
items: {
type: "object",
properties: {
error: { type: "string", example: "Unauthorized" },
message: { type: "string", example: "Invalid API key" },
},
required: %w[error message],
},
},
error: { type: "string", example: "Invalid API key" },
},
required: %w[error],
},
not_found_error: {
type: "object",
properties: {
errors: {
type: "array",
items: {
type: "object",
properties: {
error: { type: "string", example: "Not found" },
message: { type: "string", example: "The given ID does not match any vacancy for your ATS" },
},
required: %w[error message],
},
},
error: { type: "string", example: "The given ID does not match any vacancy for your ATS" },
},
required: %w[error],
},
internal_server_error: {
type: "object",
properties: {
errors: {
type: "array",
items: {
type: "object",
properties: {
error: { type: "string", example: "Internal server error" },
message: { type: "string", example: "There was an internal error processing this request" },
},
required: %w[error message],
},
},
error: { type: "string", example: "There was an internal error processing this request" },
},
required: %w[error],
},
validation_error: {
conflict_error: {
type: "object",
properties: {
errors: {
type: "array",
items: {
type: "object",
properties: {
error: { type: "string", example: "Validation error" },
field: { type: "string", example: "job_title" },
message: { type: "string", example: "can't be blank" },
},
required: %w[error field message],
},
},
error: { type: "string", example: "A vacancy with the provided external reference already exists" },
},
required: %w[error],
},
conflict_error: {
validation_error: {
type: "object",
properties: {
errors: {
type: "array",
items: {
type: "object",
properties: {
error: { type: "string", example: "Conflict error" },
message: { type: "string", example: "A vacancy with the provided external reference already exists" },
error: { type: "string", example: "job_title: can't be blank" },
},
required: %w[error message],
required: %w[error],
},
},
},
Expand Down

0 comments on commit 2e0cacb

Please sign in to comment.