Created
October 3, 2025 12:51
-
-
Save Ryandaydev/5a4f69aec236af82c641783faa3d1b41 to your computer and use it in GitHub Desktop.
Examples of standardized RFC 9457 error codes in JSON and YML
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| { | |
| "openapi":"3.1.1", | |
| "info": { | |
| "title":"Financial metrics API", | |
| "version":"1.0" | |
| }, | |
| "servers": [ | |
| {"url":"https://api.example.com/v1"} | |
| ], | |
| "components": { | |
| "schemas": { | |
| "Month": { | |
| "type": "string", | |
| "title": "Month", | |
| "description": "Calendar month in YYYY-MM format", | |
| "pattern": "^\\d{4}-(0[1-9]|1[0-2])$", | |
| "examples": ["2025-09"] | |
| }, | |
| "Metric": { | |
| "type": "object", | |
| "properties": { | |
| "Month": { "$ref": "#/components/schemas/Month" } | |
| }, | |
| "required": ["Month"], | |
| "additionalProperties": false | |
| }, | |
| "ProblemDetails": { | |
| "type": "object", | |
| "properties": { | |
| "type": { | |
| "type": "string", | |
| "format": "uri-reference", | |
| "description": "URI reference identifying the problem type." | |
| }, | |
| "title": { | |
| "type": "string", | |
| "description": "A short, human-readable summary of the problem type." | |
| }, | |
| "status": { | |
| "type": "integer", | |
| "description": "HTTP status code for this error occurrence." | |
| }, | |
| "detail": { | |
| "type": "string", | |
| "description": "Explanation specific to this occurrence of the problem." | |
| }, | |
| "instance": { | |
| "type": "string", | |
| "format": "uri-reference", | |
| "description": "URI reference identifying the specific occurrence of the problem." | |
| } | |
| }, | |
| "required": ["title", "status"] | |
| } | |
| }, | |
| "responses": { | |
| "ProblemDetails": { | |
| "description": "Problem Details using RFC 9457", | |
| "content": { | |
| "application/json": { | |
| "schema": { "$ref": "#/components/schemas/ProblemDetails" } | |
| } | |
| } | |
| } | |
| } | |
| }, | |
| "paths": { | |
| "/metrics": { | |
| "get": { | |
| "description": "Get metrics information", | |
| "parameters": [ | |
| { | |
| "name": "Month", | |
| "in": "query", | |
| "required": false, | |
| "schema": { "$ref": "#/components/schemas/Month" } | |
| } | |
| ], | |
| "responses": { | |
| "200": { | |
| "description": "List of financial metrics", | |
| "content": { | |
| "application/json": { | |
| "schema": { | |
| "type": "array", | |
| "items": { | |
| "$ref": "#/components/schemas/Metric" | |
| }, | |
| "title": "Response GET metrics" | |
| } | |
| } | |
| } | |
| }, | |
| "422": { "$ref": "#/components/responses/ProblemDetails" }, | |
| "500": { "$ref": "#/components/responses/ProblemDetails" } | |
| } | |
| } | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| openapi: 3.1.1 | |
| info: | |
| title: Financial metrics API | |
| version: "1.0" | |
| servers: | |
| - url: https://api.example.com/v1 | |
| components: | |
| schemas: | |
| Month: | |
| type: string | |
| title: Month | |
| description: Calendar month in YYYY-MM format | |
| pattern: '^\d{4}-(0[1-9]|1[0-2])$' | |
| examples: | |
| - "2025-09" | |
| Metric: | |
| type: object | |
| properties: | |
| Month: | |
| $ref: "#/components/schemas/Month" | |
| required: | |
| - Month | |
| additionalProperties: false | |
| ProblemDetails: | |
| type: object | |
| properties: | |
| type: | |
| type: string | |
| format: uri-reference | |
| description: URI reference identifying the problem type. | |
| title: | |
| type: string | |
| description: A short, human-readable summary of the problem type. | |
| status: | |
| type: integer | |
| description: HTTP status code for this error occurrence. | |
| detail: | |
| type: string | |
| description: Explanation specific to this occurrence of the problem. | |
| instance: | |
| type: string | |
| format: uri-reference | |
| description: URI reference identifying the specific occurrence of the problem. | |
| required: | |
| - title | |
| - status | |
| responses: | |
| ProblemDetails: | |
| description: Problem Details using RFC 9457 | |
| content: | |
| application/json: | |
| schema: | |
| $ref: "#/components/schemas/ProblemDetails" | |
| paths: | |
| /metrics: | |
| get: | |
| description: Get metrics information | |
| parameters: | |
| - name: Month | |
| in: query | |
| required: false | |
| schema: | |
| $ref: "#/components/schemas/Month" | |
| responses: | |
| "200": | |
| description: List of financial metrics | |
| content: | |
| application/json: | |
| schema: | |
| type: array | |
| items: | |
| $ref: "#/components/schemas/Metric" | |
| title: Response GET metrics | |
| "422": | |
| $ref: "#/components/responses/ProblemDetails" | |
| "500": | |
| $ref: "#/components/responses/ProblemDetails" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment