swagger
swagger copied to clipboard
How @Success annotation gets parsed
I'm running into some odd behavior (at least in relation to what I'm interpreting from the documentation).
I have the following structure and annotation using it for my handler.
type serviceMetrics struct {
Id string `json:"Id"`
ResponseTime []map[string]string `json:"ResponseTime"`
StatusInfo []map[string]string `json:"StatusInfo"`
AvailabilityInfo []map[string]string `json:"AvailabilityInfo"`
ThroughputInfo []map[string]string `json:"ThroughputInfo"`
}
@Success 200 {object} serviceMetrics
The struct is in the same .go
file as the handler for which I have the @Success
annotation.
I added the json
definition to try to fix the problem but it didn't seem to do anything and I still get the following error when running swagger with or without the definitions.
Can not find definition of []string model. Current package packagename
There is no array of strings present in the struct. What I actually return from the handler is a map[string]serviecMetrics
but writing it like that doesn't seem to work since it doesn't recognize map
.