go-swagger3 icon indicating copy to clipboard operation
go-swagger3 copied to clipboard

Fails on parsing builtin error

Open baggito opened this issue 9 months ago • 0 comments

Hi, I can't find an example of error response in documentation, so I'm wondering does it also support errors, because it fails on the bellow example.

Example:

package pog

// @Title Get Planograms. // @Description Returns planogram based on query params. // @Param id query string true "Use as filter.id! Planogram dbKey [comma separated list]" // @Param locationId query string true "Use as filter.locationId! Location ID" // @Param include query string false "Includes. Can be: position, fixture, liveFlrFixture" // @Param commodity query string false "Use as filter.commodity! Commodity" // @Param commodityGroup query string false "Use as filter.commodityGroup! Commodity Group" // @Param isDigitalScreen query string false "Use as filter.isDigitalScreen! IsDigitalScreen. Can be: true, false" // @Success 200 {object} GetPogsResponse // @Failure 400 {object} types.ValidationError // @Failure 404 {object} types.ErrResponse // @Failure 500 {object} types.ErrResponse // @Route assortment/planogram [get] func (h *Handler) GetPogs(ctx *krogo.Context) (interface{}, error) { ....

package types

type ValidationError struct { StatusCode int json:"statusCode" xml:"statusCode" Errors []error json:"errors" xml:"errors" }

Error: FATA[0014] Can not find definition of error ast.TypeSpec. Current package types

Update: It works with such trick, if instead of []error just use new typetype errors []error. But of course this is not the greatest solution, I guess there should be simple way to use []error

type errors []error

// swagger:model ValidationErrorResponse type ValidationErrorResponse struct { StatusCode int json:"statusCode" xml:"statusCode" Errors errors json:"errors" xml:"errors" }

baggito avatar Sep 18 '23 08:09 baggito