From 32038981f6bd88466581a5a04ec122aafdef9598 Mon Sep 17 00:00:00 2001 From: Vojtech Mares Date: Sat, 27 Apr 2024 21:15:49 +0200 Subject: [PATCH] refactor(api): replace Error schema with ProblemDetails (RFC 7807) --- api/v1/openapi.yaml | 83 +++++++++++++++++++++++++++------------------ 1 file changed, 50 insertions(+), 33 deletions(-) diff --git a/api/v1/openapi.yaml b/api/v1/openapi.yaml index 90acc09..dd1fed9 100644 --- a/api/v1/openapi.yaml +++ b/api/v1/openapi.yaml @@ -36,7 +36,7 @@ paths: content: application/json: schema: - $ref: "#/components/schemas/Error" + $ref: "#/components/schemas/ProblemDetails" post: summary: Create a new training operationId: createTraining @@ -60,13 +60,13 @@ paths: content: application/json: schema: - $ref: "#/components/schemas/Error" + $ref: "#/components/schemas/ProblemDetails" default: description: Unexpected error content: application/json: schema: - $ref: "#/components/schemas/Error" + $ref: "#/components/schemas/ProblemDetails" /trainings/{trainingID}: get: summary: Get a training by ID @@ -95,13 +95,13 @@ paths: content: application/json: schema: - $ref: "#/components/schemas/Error" + $ref: "#/components/schemas/ProblemDetails" default: description: Unexpected error content: application/json: schema: - $ref: "#/components/schemas/Error" + $ref: "#/components/schemas/ProblemDetails" put: summary: Update a training by ID operationId: updateTraining @@ -135,19 +135,19 @@ paths: content: application/json: schema: - $ref: "#/components/schemas/Error" + $ref: "#/components/schemas/ProblemDetails" "400": description: Invalid input content: application/json: schema: - $ref: "#/components/schemas/Error" + $ref: "#/components/schemas/ProblemDetails" default: description: Unexpected error content: application/json: schema: - $ref: "#/components/schemas/Error" + $ref: "#/components/schemas/ProblemDetails" delete: summary: Delete a training by ID @@ -172,13 +172,13 @@ paths: content: application/json: schema: - $ref: "#/components/schemas/Error" + $ref: "#/components/schemas/ProblemDetails" default: description: Unexpected error content: application/json: schema: - $ref: "#/components/schemas/Error" + $ref: "#/components/schemas/ProblemDetails" /trainings/{trainingID}/dates: get: @@ -210,7 +210,7 @@ paths: content: application/json: schema: - $ref: "#/components/schemas/Error" + $ref: "#/components/schemas/ProblemDetails" post: summary: Create a new date for a training @@ -245,13 +245,13 @@ paths: content: application/json: schema: - $ref: "#/components/schemas/Error" + $ref: "#/components/schemas/ProblemDetails" default: description: Unexpected error content: application/json: schema: - $ref: "#/components/schemas/Error" + $ref: "#/components/schemas/ProblemDetails" /trainings/{trainingID}/dates/{dateID}: delete: @@ -286,13 +286,13 @@ paths: content: application/json: schema: - $ref: "#/components/schemas/Error" + $ref: "#/components/schemas/ProblemDetails" default: description: Unexpected error content: application/json: schema: - $ref: "#/components/schemas/Error" + $ref: "#/components/schemas/ProblemDetails" put: summary: Update a date of a training operationId: updateTrainingDate @@ -335,19 +335,19 @@ paths: content: application/json: schema: - $ref: "#/components/schemas/Error" + $ref: "#/components/schemas/ProblemDetails" "400": description: Invalid input content: application/json: schema: - $ref: "#/components/schemas/Error" + $ref: "#/components/schemas/ProblemDetails" default: description: Unexpected error content: application/json: schema: - $ref: "#/components/schemas/Error" + $ref: "#/components/schemas/ProblemDetails" /trainings/{trainingID}/dates/{dateID}/attendees: get: @@ -388,7 +388,7 @@ paths: content: application/json: schema: - $ref: "#/components/schemas/Error" + $ref: "#/components/schemas/ProblemDetails" post: summary: Add an attendee to a date of a training @@ -426,13 +426,13 @@ paths: content: application/json: schema: - $ref: "#/components/schemas/Error" + $ref: "#/components/schemas/ProblemDetails" default: description: Unexpected error content: application/json: schema: - $ref: "#/components/schemas/Error" + $ref: "#/components/schemas/ProblemDetails" /trainings/{trainingID}/dates/{dateID}/attendees/{attendeeID}: delete: @@ -476,13 +476,13 @@ paths: content: application/json: schema: - $ref: "#/components/schemas/Error" + $ref: "#/components/schemas/ProblemDetails" default: description: Unexpected error content: application/json: schema: - $ref: "#/components/schemas/Error" + $ref: "#/components/schemas/ProblemDetails" /trainings/{trainingID}/dates/{dateID}/attendees/{attendeeID}/feedback: post: @@ -536,13 +536,13 @@ paths: content: application/json: schema: - $ref: "#/components/schemas/Error" + $ref: "#/components/schemas/ProblemDetails" default: description: Unexpected error content: application/json: schema: - $ref: "#/components/schemas/Error" + $ref: "#/components/schemas/ProblemDetails" /trainings/{trainingID}/dates/{dateID}/feedback: get: @@ -583,7 +583,7 @@ paths: content: application/json: schema: - $ref: "#/components/schemas/Error" + $ref: "#/components/schemas/ProblemDetails" /trainings/{trainingID}/feedback: get: @@ -615,7 +615,7 @@ paths: content: application/json: schema: - $ref: "#/components/schemas/Error" + $ref: "#/components/schemas/ProblemDetails" /trainings/upcoming-dates: get: @@ -662,7 +662,7 @@ paths: content: application/json: schema: - $ref: "#/components/schemas/Error" + $ref: "#/components/schemas/ProblemDetails" components: schemas: NewTraining: @@ -812,13 +812,30 @@ components: format: float minimum: 0 - Error: + ProblemDetails: type: object + description: > + Schema that carries the details of an error in an HTTP response. + See https://datatracker.ietf.org/doc/html/rfc7807 for more information. properties: - code: + type: type: string - message: + description: A URI reference that identifies the problem type. + title: type: string + description: A human-readable summary of the problem type. + status: + type: integer + description: The HTTP status code generated by the origin server for this occurrence of the problem. + detail: + type: string + description: A human-readable explanation specific to this occurrence of the problem. + instance: + type: string + description: A URI reference that identifies the specific occurrence of the problem. required: - - code - - message + - type + - title + - status + - detail + - instance