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
Crash when response code is integer #5
Comments
Thanks! Actually, that's not precisely bug - unfortunately, I might say. I've come across this before, and you may come across this when using AWS in particular. The thing is, OpenAPI specs are a little vague in some edge cases, and this is one of them. OpenAPI specs generally provide examples as YAML files, but crucially include the mandate that specs must validate given an appropriate JSON schema. Which means the YAML you can use must be the subset of YAML that also works in JSON. And JSON does not allow any keys that are not strings (YAML allows any object, though the notation for that is horrendous). So for a strict validation, an integer I have wondered about a lenient mode to prance that would stringify keys before trying to validate, but I'm not sure that might not have unintended side effects. Would that be helpful, or are you happy to change to string |
Mind you, the location of that error might be weird. I'm going to look into it one way or another :) |
No, the error location is exactly what I suspected: the JSON validator requires string keys and finds non-string keys. I've added a non-strict mode as outlined that stringifies keys. I hope that's in your interest :) |
Fixed in v0.6.0 |
Hi!
First of thank you for this project - it is exactly what I need!
However, I discovered a bug that occurred when the response code of a method in the Swagger file is interpreted as an integer.
The error is
expected string or bytes-like object
.Example:
If I use
"200"
instead, it works.I discovered that the bug actually happens in
jsonschema._utils
, where a regex fails to run over the integer. Strangely, other packages that I previously used to interpret Swagger (like connexion) also depend on thejsonschema
package and they work fine.I tested this on Python 3.6.1 on OS X 10.11.6. The version of
jsonschema
is 2.6.0 and ofprance
0.5.1I would really appreciate it, if you could investigate this bug!
The text was updated successfully, but these errors were encountered: