Not sure if this a problem with go-swagger or the swagger spec I'm trying to use.
2018/02/09 20:37:57 rendering 1 templates for model AddLabel
2018/02/09 20:37:57 name field AddLabel
2018/02/09 20:37:57 package field models
2018/02/09 20:28:57 creating generated file "add_label.go" in "models" as definition
failed rendering template data for definition: template execution failed for template definition: template: schemavalidator:421:65: executing "schemavalidator" at <.>: wrong type for value; expected string; got interface {}
https://quay.io/api/v1/discovery
swagger generate client -f swagger.json -A client -c quay -a quay
swagger version: dev
go version: go version go1.9.3 linux/amd64
OS: VoidLinux
I am seeing this error locally when the types in an enum field don't match the declared type.
The log in the report above shows add_label just before the error. This is the stanza from the quay.io source:
"AddLabel": {
"required": [
"key",
"value",
"media_type"
],
"type": "object",
"description": "Adds a label to a manifest",
"properties": {
"media_type": {
"enum": [
"text/plain",
"application/json",
null
],
"type": [
"string",
"null"
],
"description": "The media type for this label"
},
"value": {
"type": "string",
"description": "The value for the label"
},
"key": {
"type": "string",
"description": "The key for the label"
}
}
}
I think in this case, the error could be caused by the combined string and null types?
My swagger has ints trying to go in to a string field, so it's more clearly a problem with the input.
I made a patch to handle null in enum (this another issue involving quay.io).
The current issue I test too with this patch and works.
This patch is still under development, since fixing this particular issue is just a by-product of another feature.
Hey I left a message on slack about this, but figured I should put it here to. We are running into the same issue when it is trying to parse a definition with a null in option in an enum like this:
installs:
type: array
items:
properties:
id:
type: string
format: uuid
example: 123456789-abcd-4321-dcba-123456789ab
environment:
type: string
x-nullable: true
enum:
- production
- staging
- development
- null
YAML has a list of "magic" words that have types that aren't strings, and null is one of those. You need to put it in quotes to make it a string: - "null". The same thing happens with yes,no,on,off,true,false which are booleans.