From 4b7f279bcc3a84781f7be751d42ed6a450d47356 Mon Sep 17 00:00:00 2001 From: Hayden <64056131+hay-kot@users.noreply.github.com> Date: Sat, 29 Oct 2022 12:25:49 -0800 Subject: [PATCH] update and generate code --- .../handlers/v1/v1_ctrl_items_attachments.go | 2 +- backend/app/api/static/docs/docs.go | 30 +++++++++---------- backend/app/api/static/docs/swagger.json | 30 +++++++++---------- backend/app/api/static/docs/swagger.yaml | 20 ++++++------- frontend/lib/api/types/data-contracts.ts | 10 +++---- 5 files changed, 46 insertions(+), 46 deletions(-) diff --git a/backend/app/api/handlers/v1/v1_ctrl_items_attachments.go b/backend/app/api/handlers/v1/v1_ctrl_items_attachments.go index 327b013..5d90157 100644 --- a/backend/app/api/handlers/v1/v1_ctrl_items_attachments.go +++ b/backend/app/api/handlers/v1/v1_ctrl_items_attachments.go @@ -28,7 +28,7 @@ type ( // @Param type formData string true "Type of file" // @Param name formData string true "name of the file including extension" // @Success 200 {object} repo.ItemOut -// @Failure 422 {object} []server.ValidationError +// @Failure 422 {object} server.ErrorResponse // @Router /v1/items/{id}/attachments [POST] // @Security Bearer func (ctrl *V1Controller) HandleItemAttachmentCreate() server.HandlerFunc { diff --git a/backend/app/api/static/docs/docs.go b/backend/app/api/static/docs/docs.go index 2bd7e41..7cad594 100644 --- a/backend/app/api/static/docs/docs.go +++ b/backend/app/api/static/docs/docs.go @@ -395,10 +395,7 @@ const docTemplate = `{ "422": { "description": "Unprocessable Entity", "schema": { - "type": "array", - "items": { - "$ref": "#/definitions/server.ValidationError" - } + "$ref": "#/definitions/server.ErrorResponse" } } } @@ -1735,6 +1732,20 @@ const docTemplate = `{ } } }, + "server.ErrorResponse": { + "type": "object", + "properties": { + "error": { + "type": "string" + }, + "fields": { + "type": "object", + "additionalProperties": { + "type": "string" + } + } + } + }, "server.Result": { "type": "object", "properties": { @@ -1754,17 +1765,6 @@ const docTemplate = `{ "items": {} } }, - "server.ValidationError": { - "type": "object", - "properties": { - "field": { - "type": "string" - }, - "reason": { - "type": "string" - } - } - }, "services.UserRegistration": { "type": "object", "properties": { diff --git a/backend/app/api/static/docs/swagger.json b/backend/app/api/static/docs/swagger.json index 139990c..b5e97e8 100644 --- a/backend/app/api/static/docs/swagger.json +++ b/backend/app/api/static/docs/swagger.json @@ -387,10 +387,7 @@ "422": { "description": "Unprocessable Entity", "schema": { - "type": "array", - "items": { - "$ref": "#/definitions/server.ValidationError" - } + "$ref": "#/definitions/server.ErrorResponse" } } } @@ -1727,6 +1724,20 @@ } } }, + "server.ErrorResponse": { + "type": "object", + "properties": { + "error": { + "type": "string" + }, + "fields": { + "type": "object", + "additionalProperties": { + "type": "string" + } + } + } + }, "server.Result": { "type": "object", "properties": { @@ -1746,17 +1757,6 @@ "items": {} } }, - "server.ValidationError": { - "type": "object", - "properties": { - "field": { - "type": "string" - }, - "reason": { - "type": "string" - } - } - }, "services.UserRegistration": { "type": "object", "properties": { diff --git a/backend/app/api/static/docs/swagger.yaml b/backend/app/api/static/docs/swagger.yaml index bda3d97..d2cf02a 100644 --- a/backend/app/api/static/docs/swagger.yaml +++ b/backend/app/api/static/docs/swagger.yaml @@ -394,6 +394,15 @@ definitions: name: type: string type: object + server.ErrorResponse: + properties: + error: + type: string + fields: + additionalProperties: + type: string + type: object + type: object server.Result: properties: details: {} @@ -407,13 +416,6 @@ definitions: properties: items: {} type: object - server.ValidationError: - properties: - field: - type: string - reason: - type: string - type: object services.UserRegistration: properties: email: @@ -708,9 +710,7 @@ paths: "422": description: Unprocessable Entity schema: - items: - $ref: '#/definitions/server.ValidationError' - type: array + $ref: '#/definitions/server.ErrorResponse' security: - Bearer: [] summary: imports items into the database diff --git a/frontend/lib/api/types/data-contracts.ts b/frontend/lib/api/types/data-contracts.ts index 8d5fef1..e1bc8dd 100644 --- a/frontend/lib/api/types/data-contracts.ts +++ b/frontend/lib/api/types/data-contracts.ts @@ -247,6 +247,11 @@ export interface UserUpdate { name: string; } +export interface ServerErrorResponse { + error: string; + fields: Record; +} + export interface ServerResult { details: any; error: boolean; @@ -258,11 +263,6 @@ export interface ServerResults { items: any; } -export interface ServerValidationError { - field: string; - reason: string; -} - export interface UserRegistration { email: string; name: string;