Yelp / bravado-core

Other
109 stars 98 forks source link

Cannot Produce File: generate a validation error #114

Open heralight opened 8 years ago

heralight commented 8 years ago

Hi, Thank you for validator, we have some trouble with it on type file, perhaps have you an idea. When a method return a file,

app_1    |   File "/usr/lib/python3.5/site-packages/bottle_swagger.py", line 43, in __init__
app_1    |     self.swagger = Spec.from_dict(swagger_def)
app_1    |   File "/usr/lib/python3.5/site-packages/bravado_core/spec.py", line 152, in from_dict
app_1    |     spec.build()
app_1    |   File "/usr/lib/python3.5/site-packages/bravado_core/spec.py", line 159, in build
app_1    |     http_handlers=build_http_handlers(self.http_client))
app_1    |   File "/usr/lib/python3.5/site-packages/swagger_spec_validator/validator20.py", line 82, in validate_spec
app_1    |     http_handlers=http_handlers)
app_1    |   File "/usr/lib/python3.5/site-packages/swagger_spec_validator/common.py", line 22, in wrapper
app_1    |     sys.exc_info()[2])
app_1    |   File "/usr/lib/python3.5/site-packages/six.py", line 685, in reraise
app_1    |     raise value.with_traceback(tb)
app_1    |   File "/usr/lib/python3.5/site-packages/swagger_spec_validator/common.py", line 17, in wrapper
app_1    |     return method(*args, **kwargs)
app_1    |   File "/usr/lib/python3.5/site-packages/swagger_spec_validator/validator20.py", line 125, in validate_json
app_1    |     cls=Draft4Validator)
app_1    |   File "/usr/lib/python3.5/site-packages/swagger_spec_validator/ref_validators.py", line 34, in validate
app_1    |     instance_cls(schema, *args, **kwargs).validate(instance)
app_1    |   File "/usr/lib/python3.5/site-packages/jsonschema/validators.py", line 123, in validate
app_1    |     raise error
app_1    | swagger_spec_validator.common.SwaggerValidationError: {'schema': {'type': 'file'}, 'description': 'Returns the pet photo'} is not valid under any of the given schemas
app_1    | 
app_1    | Failed validating 'oneOf' in schema['properties']['paths']['patternProperties']['^/']['properties']['get']['properties']['responses']['patternProperties']['^([0-9]{3})$|^(default)$']:
app_1    |     {'oneOf': [{'$ref': '#/definitions/response'},
app_1    |                {'$ref': '#/definitions/jsonReference'}]}
app_1    | 
app_1    | On instance['paths']['/pets/{petName}/photos/{id}']['get']['responses']['default']:
app_1    |     {'description': 'Returns the pet photo', 'schema': {'type': 'file'}

This example come from : https://raw.githubusercontent.com/BigstickCarpet/swagger-express-middleware/master/samples/PetStore.yaml

this yaml is correctly validated by http://bigstickcarpet.com/swagger-parser/www/index.html

Thank you,

Alexandre

gamaanderson commented 8 years ago

I'm also facing the same issue.

jlumpe commented 8 years ago

See this issue for the swagger-spec-validator package. It is apparently fixed in the master branch but has not made it to release yet.

ocallagj commented 7 years ago

I'm facing the same issue. I can work around by configuring Bravado to "'validate_swagger_spec': False" but when I then try to use the API that returns a file type I get an error from Bravado because the return type is not JSON compliant. "simplejson.scanner.JSONDecodeError: Expecting value: line 1 column 1" Thanks John