From e2657988c3a0a6d1b990c11461a606578cd95dc1 Mon Sep 17 00:00:00 2001 From: Kapil Verma Date: Thu, 8 Aug 2024 16:40:05 +0530 Subject: [PATCH 1/3] EDGPATRON-144: updated API doc for external_patron as per new modified error scenario --- ramls/edge-patron.raml | 28 ++++++++++----- .../external_patron_error_get_404.schema | 26 ++++++++++++++ .../external_patron_error_get_422.schema | 26 ++++++++++++++ ... => external_patron_error_post_422.schema} | 12 ------- .../external_patron_error_put_404.schema | 26 ++++++++++++++ .../external_patron_error_put_422.schema | 34 +++++++++++++++++++ 6 files changed, 132 insertions(+), 20 deletions(-) create mode 100644 ramls/schemas/external_patron_error_get_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_404.schema 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..e261138 100644 --- a/ramls/edge-patron.raml +++ b/ramls/edge-patron.raml @@ -22,7 +22,11 @@ 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_get_404: !include schemas/external_patron_error_get_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_404: !include schemas/external_patron_error_put_404.schema + external_patron_error_put_422: !include schemas/external_patron_error_put_422.schema /patron: displayName: Patron Services @@ -72,7 +76,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 +158,15 @@ types: 404: description: Item with a given EMAIL not found body: - text/plain: - example: account not found + application/json: + type: external_patron_error_get_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: @@ -188,7 +199,7 @@ types: description: Bad request body: application/json: - type: external_patron_error + type: external_patron_error_put example: !include examples/external_patron_error.json 401: description: Not authorized to perform requested action @@ -199,7 +210,7 @@ types: description: Item with a given ID not found body: application/json: - type: external_patron_error + type: external_patron_error_put_404 example: !include examples/external_patron_error.json 403: description: Access Denied @@ -214,8 +225,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_get_404.schema b/ramls/schemas/external_patron_error_get_404.schema new file mode 100644 index 0000000..2495de0 --- /dev/null +++ b/ramls/schemas/external_patron_error_get_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_404.schema b/ramls/schemas/external_patron_error_put_404.schema new file mode 100644 index 0000000..2495de0 --- /dev/null +++ b/ramls/schemas/external_patron_error_put_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_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" + ] +} From 2e5dff0ca0bc779e7e5896ea14981f99df67280d Mon Sep 17 00:00:00 2001 From: Kapil Verma Date: Thu, 8 Aug 2024 16:44:20 +0530 Subject: [PATCH 2/3] EDGPATRON-144: updated API doc for external_patron as per new modified error scenario --- ramls/edge-patron.raml | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/ramls/edge-patron.raml b/ramls/edge-patron.raml index e261138..f74570a 100644 --- a/ramls/edge-patron.raml +++ b/ramls/edge-patron.raml @@ -198,9 +198,8 @@ types: 400: description: Bad request body: - application/json: - type: external_patron_error_put - example: !include examples/external_patron_error.json + text/plain: + example: unable to process request 401: description: Not authorized to perform requested action body: From c8203e159c99accfb542c14c1309cecc43a8723f Mon Sep 17 00:00:00 2001 From: Kapil Verma Date: Thu, 8 Aug 2024 17:32:37 +0530 Subject: [PATCH 3/3] EDGPATRON-144: merged 404 schema's into single --- ramls/edge-patron.raml | 7 +++-- ...chema => external_patron_error_404.schema} | 0 .../external_patron_error_put_404.schema | 26 ------------------- 3 files changed, 3 insertions(+), 30 deletions(-) rename ramls/schemas/{external_patron_error_get_404.schema => external_patron_error_404.schema} (100%) delete mode 100644 ramls/schemas/external_patron_error_put_404.schema diff --git a/ramls/edge-patron.raml b/ramls/edge-patron.raml index f74570a..728959d 100644 --- a/ramls/edge-patron.raml +++ b/ramls/edge-patron.raml @@ -22,10 +22,9 @@ types: allowedServicePoints: !include allowed-service-points-response.json hold-cancellation: !include hold-cancellation.json errors: !include raml-util/schemas/errors.schema - external_patron_error_get_404: !include schemas/external_patron_error_get_404.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_404: !include schemas/external_patron_error_put_404.schema external_patron_error_put_422: !include schemas/external_patron_error_put_422.schema /patron: @@ -159,7 +158,7 @@ types: description: Item with a given EMAIL not found body: application/json: - type: external_patron_error_get_404 + type: external_patron_error_404 example: !include examples/external_patron_error.json 422: description: Validation error @@ -209,7 +208,7 @@ types: description: Item with a given ID not found body: application/json: - type: external_patron_error_put_404 + type: external_patron_error_404 example: !include examples/external_patron_error.json 403: description: Access Denied diff --git a/ramls/schemas/external_patron_error_get_404.schema b/ramls/schemas/external_patron_error_404.schema similarity index 100% rename from ramls/schemas/external_patron_error_get_404.schema rename to ramls/schemas/external_patron_error_404.schema diff --git a/ramls/schemas/external_patron_error_put_404.schema b/ramls/schemas/external_patron_error_put_404.schema deleted file mode 100644 index 2495de0..0000000 --- a/ramls/schemas/external_patron_error_put_404.schema +++ /dev/null @@ -1,26 +0,0 @@ -{ - "$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" - ] -}