Fails on parsing builtin error
Closed this issue · 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"
}