Example values on map keys instead of "AdditionalProp"
I got a model like that
//swagger:model
type User struct {
...
Exam map[string]ExamResult `json:"exam"`
...
}
When I generate the json, I get
...
"exam": {
"type": "object",
"additionalProperties": {
"$ref": "#/definitions/ExamResult"
},
"x-go-name": "Exam"
},
...
and the "Example Value" on swagger-ui is
"exam": {
"additionalProp1": {
...
},
"additionalProp2": {
...
},
"additionalProp3": {
...
}
},
From the documentation I cannot get how can I customize the keyset of the map. I want, if it's possible, to choose how many keys are shown in the example, and specify which keys to use, cause "additionalProp1-3" is quite misleading.
Is it possible?
Thank you for the great work
Environment
swagger version: 0.13 go version: 1.10 OS: OSX 10.13.3
Any updates on this?
Here is a workaround that I use.
Say I have a map[string]bool which three possible keys: "escalated", "acknowledged" and "taken", and I annotate it with an example comment like below.
// example: { "escalated": true, "acknowledged": false, "taken": false }
The idea here is that, in OpenAPI, a map basically is treated as an object. So you can provide an example JSON to demo your map.