getsling / flask-swagger

A swagger 2.0 spec extractor for flask
MIT License
457 stars 91 forks source link

Stringify `responses` to make validator happy #13

Closed svetlyak40wt closed 8 years ago

svetlyak40wt commented 8 years ago

If you will try to use jsonschema`s Draft4Validator to validate swagger.json, generated by flask-swagger, then will discover it is failing, trying to match numerical HTTP status codes from responses agains this piece of Swagger 2.0 spec:

"responses": {
  "type": "object",
  "description": "Response objects names can either be any valid
  HTTP status code or 'default'.",
  "minProperties": 1,
  "additionalProperties": false,
  "patternProperties": {
    "^([0-9]{3})$|^(default)$": {
      "$ref": "#/definitions/responseValue"
    },
    "^x-": {
      "$ref": "#/definitions/vendorExtension"
    }
  }
}

This fix just coerse responses keys to strings.

atlithorn commented 8 years ago

Thanks!

atlithorn commented 8 years ago

Upped version to 0.2.9 and pushed to pypi