Yelp/swagger_spec_validator

Validate spec failed on validating response code without quote

zhichuny opened this issue · 1 comments

I found that validate_spec will fail on validating response codes when it is not wrapped with single quote. But on swagger website, response codes are not quoted: http://editor.swagger.io/#/

On OpenAPI doc, example response codes are wrapped with quotes.

I am confused which way is the correct and valid way to write response code in spec yaml. Can you make both type of response codes pass validation? Or is response code without quote not valid?

The problem here is that JSON only allows strings as dictionary keys, and quite a bit of spec-handling code expects the response codes to be strings because of that. I've added handling of these integer response codes to bravado: https://github.com/Yelp/bravado/blob/master/bravado/swagger_model.py#L107

Unfortunately the Swagger spec does not explicitly define that response codes have to be strings, this was simply a limitation of JSON (and thus implicitly defined). With the advent of YAML spec this has changed. Note though that the YAML example within the spec does wrap the response code in quotes to make sure it's a string: http://swagger.io/specification/#responsesObject