From 7365c9e8cd54d49dcd0197bccecf6fefe77aaada Mon Sep 17 00:00:00 2001 From: Kapil Verma <85541312+kapil-epam@users.noreply.github.com> Date: Thu, 8 Aug 2024 17:35:56 +0530 Subject: [PATCH] EDGPATRON-144: Updated API doc for external_patron as per new modified error scenario (#127) * EDGPATRON-144: updated API doc for external_patron as per new modified error scenario --------- Co-authored-by: Kapil Verma --- ramls/edge-patron.raml | 30 ++++++++++------ .../schemas/external_patron_error_404.schema | 26 ++++++++++++++ .../external_patron_error_get_422.schema | 26 ++++++++++++++ ... => external_patron_error_post_422.schema} | 12 ------- .../external_patron_error_put_422.schema | 34 +++++++++++++++++++ 5 files changed, 106 insertions(+), 22 deletions(-) create mode 100644 ramls/schemas/external_patron_error_404.schema create mode 100644 ramls/schemas/external_patron_error_get_422.schema rename ramls/schemas/{external_patron_error.schema => external_patron_error_post_422.schema} (70%) create mode 100644 ramls/schemas/external_patron_error_put_422.schema diff --git a/ramls/edge-patron.raml b/ramls/edge-patron.raml index cf6de22..728959d 100644 --- a/ramls/edge-patron.raml +++ b/ramls/edge-patron.raml @@ -22,7 +22,10 @@ types: allowedServicePoints: !include allowed-service-points-response.json hold-cancellation: !include hold-cancellation.json errors: !include raml-util/schemas/errors.schema - external_patron_error: !include schemas/external_patron_error.schema + external_patron_error_404: !include schemas/external_patron_error_404.schema + external_patron_error_get_422: !include schemas/external_patron_error_get_422.schema + external_patron_error_post_422: !include schemas/external_patron_error_post_422.schema + external_patron_error_put_422: !include schemas/external_patron_error_put_422.schema /patron: displayName: Patron Services @@ -72,7 +75,7 @@ types: description: Validation error body: application/json: - type: external_patron_error + type: external_patron_error_post_422 example: !include examples/external_patron_error.json 500: description: | @@ -154,8 +157,15 @@ types: 404: description: Item with a given EMAIL not found body: - text/plain: - example: account not found + application/json: + type: external_patron_error_404 + example: !include examples/external_patron_error.json + 422: + description: Validation error + body: + application/json: + type: external_patron_error_get_422 + example: !include examples/external_patron_error.json 403: description: Access Denied body: @@ -187,9 +197,8 @@ types: 400: description: Bad request body: - application/json: - type: external_patron_error - example: !include examples/external_patron_error.json + text/plain: + example: unable to process request 401: description: Not authorized to perform requested action body: @@ -199,7 +208,7 @@ types: description: Item with a given ID not found body: application/json: - type: external_patron_error + type: external_patron_error_404 example: !include examples/external_patron_error.json 403: description: Access Denied @@ -214,8 +223,9 @@ types: 422: description: Validation error body: - text/plain: - example: Validation error + application/json: + type: external_patron_error_put_422 + example: !include examples/external_patron_error.json 500: description: | Internal server error, e.g. due to misconfiguration diff --git a/ramls/schemas/external_patron_error_404.schema b/ramls/schemas/external_patron_error_404.schema new file mode 100644 index 0000000..2495de0 --- /dev/null +++ b/ramls/schemas/external_patron_error_404.schema @@ -0,0 +1,26 @@ +{ + "$schema": "http://json-schema.org/draft-04/schema#", + "id": "external_patron_error.schema", + "description": "An external_patron user error", + "type": "object", + "properties": { + "code": { + "type": "integer", + "description": "Error code" + }, + "errorMessage": { + "type": "string", + "description": "Error message text", + "examples": [ + { + "value": "USER_NOT_FOUND", + "description": "User does not exist" + } + ] + } + }, + "required": [ + "code", + "errorMessage" + ] +} diff --git a/ramls/schemas/external_patron_error_get_422.schema b/ramls/schemas/external_patron_error_get_422.schema new file mode 100644 index 0000000..a6f5a45 --- /dev/null +++ b/ramls/schemas/external_patron_error_get_422.schema @@ -0,0 +1,26 @@ +{ + "$schema": "http://json-schema.org/draft-04/schema#", + "id": "external_patron_error.schema", + "description": "An external_patron user error", + "type": "object", + "properties": { + "code": { + "type": "integer", + "description": "Error code" + }, + "errorMessage": { + "type": "string", + "description": "Error message text", + "examples": [ + { + "value": "MULTIPLE_USER_WITH_EMAIL", + "description": "Multiple users found with the same email" + } + ] + } + }, + "required": [ + "code", + "errorMessage" + ] +} diff --git a/ramls/schemas/external_patron_error.schema b/ramls/schemas/external_patron_error_post_422.schema similarity index 70% rename from ramls/schemas/external_patron_error.schema rename to ramls/schemas/external_patron_error_post_422.schema index 7a2d630..e26bd6a 100644 --- a/ramls/schemas/external_patron_error.schema +++ b/ramls/schemas/external_patron_error_post_422.schema @@ -24,21 +24,9 @@ "value": "USER_ALREADY_EXIST", "description": "User already exists" }, - { - "value": "USER_NOT_FOUND", - "description": "User does not exist" - }, - { - "value": "EMAIL_ALREADY_EXIST", - "description": "User already exists with email provided in payload" - }, { "value": "INVALID_PATRON_GROUP", "description": "User does not belong to the required patron group" - }, - { - "value": "PATRON_GROUP_NOT_APPLICABLE", - "description": "Required Patron group not applicable for user" } ] } diff --git a/ramls/schemas/external_patron_error_put_422.schema b/ramls/schemas/external_patron_error_put_422.schema new file mode 100644 index 0000000..7bc0ca6 --- /dev/null +++ b/ramls/schemas/external_patron_error_put_422.schema @@ -0,0 +1,34 @@ +{ + "$schema": "http://json-schema.org/draft-04/schema#", + "id": "external_patron_error.schema", + "description": "An external_patron user error", + "type": "object", + "properties": { + "code": { + "type": "integer", + "description": "Error code" + }, + "errorMessage": { + "type": "string", + "description": "Error message text", + "examples": [ + { + "value": "EMAIL_ALREADY_EXIST", + "description": "User already exists with email provided in payload" + }, + { + "value": "PATRON_GROUP_NOT_APPLICABLE", + "description": "Required Patron group not applicable for user" + }, + { + "value": "MULTIPLE_USER_WITH_EMAIL", + "description": "Multiple users found with the same email" + } + ] + } + }, + "required": [ + "code", + "errorMessage" + ] +}