From 0a38b670bb7f2b31f04f77689e5fec719393e25e Mon Sep 17 00:00:00 2001 From: Frank Kilcommins Date: Tue, 16 Apr 2024 14:22:04 +0100 Subject: [PATCH] update JSON Schema for Problem Details (#23) --- README.md | 147 +++++++++++++++++++++++++++++------------------------- 1 file changed, 80 insertions(+), 67 deletions(-) diff --git a/README.md b/README.md index 8220464..4284841 100644 --- a/README.md +++ b/README.md @@ -25,71 +25,84 @@ When necessary, a Problem Detail response _MAY_ include additional detail on the ```json { - "$schema": "https://json-schema.org/draft/2019-09/schema", - "type": "object", - "properties": { - "type": { - "type": "string", - "description": "a string containing a URI reference that identifies the problem type. When this member is not present, its value is assumed to be `about:blank`." - }, - "status": { - "type": "number", - "description": "a number indicating the HTTP status code." - }, - "title": { - "type": "string", - "description": "a string containing a short, human-readable summary of the problem type." - }, - "detail": { - "type": "string", - "description": "a string containing a human-readable explanation specific to this occurrence of the problem." - }, - "instance": { - "type": "string", - "description": "a string containing a URI reference that identifies the specific occurrence of the problem." - }, - "code": { - "type": "string", - "description": "a string containing additional provider specific codes to identify the error context." - }, - "errors": { - "type": "array", - "description": "an array of error details to accompany a problem details response", - "items": [ - { - "type": "object", - "description": "an error object to provide explicit details on a problem towards an API consumer", - "properties": { - "detail": { - "type": "string", - "description": "a granular description on the specific error related to a body property, query parameter, path parameters, and/or header" - }, - "pointer": { - "type": "string", - "description": "a JSON Pointer to a specific request body property that is the source of error" - }, - "parameter": { - "type": "string", - "description": "a string containing the name of the query or path parameter that is the source of error" - }, - "header": { - "type": "string", - "description": "a string containing the name of the header that is the source of error" - }, - "code": { - "type": "string", - "description": "a string containing additional provider specific codes to identify the error context." - } - }, - "required": [ - "detail" - ] - } - ] - } - }, - "required": [ - "title" - ] -} + "$schema": "https://json-schema.org/draft/2019-09/schema", + "type": "object", + "properties": { + "type": { + "type": "string", + "description": "A URI reference that identifies the problem type.", + "format": "uri", + "maxLength": 1024 + }, + "status": { + "type": "integer", + "description": "The HTTP status code generated by the origin server for this occurrence of the problem.", + "format": "int32", + "minimum": 100, + "maximum": 599 + }, + "title": { + "type": "string", + "description": "A short, human-readable summary of the problem type. It should not change from occurrence to occurrence of the problem, except for purposes of localization.", + "maxLength": 1024 + }, + "detail": { + "type": "string", + "description": "A human-readable explanation specific to this occurrence of the problem.", + "maxLength": 4096 + }, + "instance": { + "type": "string", + "description": "A URI reference that identifies the specific occurrence of the problem. It may or may not yield further information if dereferenced.", + "maxLength": 1024 + }, + "code": { + "type": "string", + "description": "An API specific error code aiding the provider team understand the error based on their own potential taxonomy or registry.", + "maxLength": 50 + }, + "errors": { + "type": "array", + "description": "An array of error details to accompany a problem details response.", + "maxItems": 1000, + "items": { + "type": "object", + "description": "An object to provide explicit details on a problem towards an API consumer.", + "properties": { + "detail": { + "type": "string", + "description": "A granular description on the specific error related to a body property, query parameter, path parameters, and/or header.", + "maxLength": 4096 + }, + "pointer": { + "type": "string", + "description": "A JSON Pointer to a specific request body property that is the source of error.", + "maxLength": 1024 + }, + "parameter": { + "type": "string", + "description": "The name of the query or path parameter that is the source of error.", + "maxLength": 1024 + }, + "header": { + "type": "string", + "description": "The name of the header that is the source of error.", + "maxLength": 1024 + }, + "code": { + "type": "string", + "description": "A string containing additional provider specific codes to identify the error context.", + "maxLength": 50 + } + }, + "required": [ + "detail" + ] + } + } + }, + "required": [ + "detail" + ] + } ```