Skip to content
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

Swagger Yaml Spec fails validation if response codes are not quoted #142

Open
the-destro opened this issue Jan 12, 2017 · 1 comment
Open

Comments

@the-destro
Copy link

using the yaml file from the swagger editor I saved it as a yaml file and tried to load it in the same way that the pyramid_swagger project loads the file. I get a "SwaggerValidationError: expected string or buffer" exception message. Debugging at that level shows that item passed down is an int not a string. Inspecting the dict that is generated from loading the file confirms that the response codes are rendered as integers. It is a rather nasty gotcha.

@the-destro the-destro changed the title Swagger Spec fails validation if response codes are not quoted Swagger Yaml Spec fails validation if response codes are not quoted Jan 12, 2017
@macisamuele
Copy link
Collaborator

@the-destro: I'm usually doing something similar to the following snippet to read yaml specs from file.

import yaml
from bravado_core.spec import Spec
with open(...) as f:
    spec_dict = yaml.load(f)
spec = Spec.from_dict(spec_dict)

In this case if your responseObject has no quote around 200 we cannot do anything fancy because yaml.load(f) reads it as an integer instead of string (expected type) and so the validation will fail.

Swagger specs example are available on Swagger Spec - Response Object

    ....
    response:
        200:
            description: Dummy Response
    ....

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants