From 2e0cacb2cba640ef310ffbf2b39d7d0757d540bd Mon Sep 17 00:00:00 2001 From: Marc Sardon Date: Fri, 29 Nov 2024 10:43:04 +0000 Subject: [PATCH] Refactor error response schema to simplify structure and remove unnecessary fields --- spec/swagger_helper.rb | 75 ++++++++---------------------------------- 1 file changed, 14 insertions(+), 61 deletions(-) diff --git a/spec/swagger_helper.rb b/spec/swagger_helper.rb index a7aa57875e1..694ad5a8f32 100644 --- a/spec/swagger_helper.rb +++ b/spec/swagger_helper.rb @@ -208,85 +208,39 @@ 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: { @@ -294,10 +248,9 @@ 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], }, }, },