From cbca648be0830c3fe4641e6eb97f4a0398885b57 Mon Sep 17 00:00:00 2001 From: Ocasta Date: Mon, 8 May 2023 13:29:06 -0700 Subject: [PATCH] add swagger annotations to error models --- httperror/http_error.go | 2 ++ validator/validator.go | 2 ++ 2 files changed, 4 insertions(+) diff --git a/httperror/http_error.go b/httperror/http_error.go index 228ae17..8a0fd5f 100644 --- a/httperror/http_error.go +++ b/httperror/http_error.go @@ -8,12 +8,14 @@ import ( "github.com/labstack/echo/v4" ) +// swagger:model JSONError type JSONError struct { Code string `json:"code"` Message string `json:"message"` Details *Details `json:"details,omitempty"` } +// swagger:model JSONErrorDetails type Details struct { Params *validator.InvalidParams `json:"invalidParams,omitempty"` } diff --git a/validator/validator.go b/validator/validator.go index eaec5db..0b4f4c5 100644 --- a/validator/validator.go +++ b/validator/validator.go @@ -17,6 +17,7 @@ var tagsMessage = map[string]string{ "numeric": "must be a valid numeric value", } +// swagger:model InvalidParamError type InvalidParamError struct { Param string `json:"param"` Value any `json:"value"` @@ -24,6 +25,7 @@ type InvalidParamError struct { Message string `json:"message"` } +// swagger:model InvalidParams type InvalidParams []InvalidParamError type Validator struct {