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

Not all models get loaded properly #416

Closed
OiCMudkips opened this issue May 7, 2019 · 1 comment
Closed

Not all models get loaded properly #416

OiCMudkips opened this issue May 7, 2019 · 1 comment
Assignees
Labels

Comments

@OiCMudkips
Copy link

Loading this example spec from OpenAPI into bravado doesn't load all of the the models for some reason:

Python 3.7.1 (default, Oct 20 2018, 21:59:34) 
[GCC 5.4.0 20160609] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from bravado.client import SwaggerClient
>>> client = SwaggerClient.from_url("https://raw.githubusercontent.com/OAI/OpenAPI-Specification/master/examples/v2.0/yaml/petstore-expanded.yaml")
>>> client.get_model("Pet")
<class 'abc.Pet'>
>>> client.get_model("Error")
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/nail/home/vzhou/pg/fuzz_lightyear/venv/lib/python3.7/site-packages/bravado/client.py", line 139, in get_model
    return self.swagger_spec.definitions[model_name]
KeyError: 'Error'
>>> client.get_model("NewPet")
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/nail/home/vzhou/pg/fuzz_lightyear/venv/lib/python3.7/site-packages/bravado/client.py", line 139, in get_model
    return self.swagger_spec.definitions[model_name]
KeyError: 'NewPet'

Here are my (I think relevant) versions:

bravado==10.3.2
bravado-core==5.12.0

This is reproducible with (python3.7.1, bravado==10.3.2, bravado-core==5.12.0) (the REPL environment), (python3.7.1, bravado==10.4.0, bravado-core==5.12.1) and (python3.6.0, bravado==10.4.0, bravado-core==5.12.1).

@sjaensch
Copy link
Contributor

This is a bug with the YAML version of the example spec. Note that the JSON version of the spec contains the crucial type property. It was added four years ago, but looks like this was never done for the YAML specs.

I've created OAI/OpenAPI-Specification#1923 to fix the issue in the specs, in the meantime things should work if you use the JSON version of the specs.

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

No branches or pull requests

2 participants