-
-
Notifications
You must be signed in to change notification settings - Fork 565
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Wrong type detect for Example of a String field in YAML #2450
Comments
Clarification: the bug is somewhere near YAML generation, because JSON looks ok: "definitions": {
"ServiceTestMainRequestBody": {
"title": "ServiceTestMainRequestBody",
"type": "object",
"properties": {
"field1": {
"type": "string",
"example": "0xffff"
},
"field2": {
"type": "string",
"example": "\"0xffff\""
},
"field3": {
"type": "string",
"example": "0xf47261b0000000000000000000000000e41d2489571d322189246dafa5ebde1f4699f498"
},
"field4": {
"type": "string",
"example": "\"0xf47261b0000000000000000000000000e41d2489571d322189246dafa5ebde1f4699f498\""
}
},
"example": {
"field1": "0xffff",
"field2": "\"0xffff\"",
"field3": "0xf47261b0000000000000000000000000e41d2489571d322189246dafa5ebde1f4699f498",
"field4": "\"0xf47261b0000000000000000000000000e41d2489571d322189246dafa5ebde1f4699f498\""
}
}
} |
Thank you for the report! Goa does not do any type inference. This looks like some weirdness in the YAML package that Goa uses (or Goa not using it correctly). |
@raphael actually since YAML accepts strings only, we can actually put the |
@saniales if that works then sounds good! I believe the issue is that sometimes the YAML package will add these quotes and sometimes it won't which means that if we always add them it might double escape them? |
Well not only strings - |
@saniales I agree, that might be the approach |
@saniales give it a shot, I suspect that the result is going to be that they are all strings but that "sometimes" the string will be quoted which may or may not be an issue for OpenAPI spec examples. |
will give it a shot in the coming days |
I confirm that this can be solved by using single quotes only with string values And I also confirm that JSON generated openapi is not affected by this, only YAML |
Would you care to make a PR that adds the quote? |
Hello! I'm trying to generate API spec for a design like this:
The problem is that the generated Swagger spec looks like this:
As you can see, for some reason
field3
is treated as a number! Which will affect the generated documentation later. And for some reasonfield1
is treated correctly.So that's clearly a bug, I'm not sure why Goa tries to dynamically detect type if it is declared as
String
already in the spec. @raphael I need your help at this point :)The text was updated successfully, but these errors were encountered: