Not all models get loaded properly
OiCMudkips opened this issue · 1 comments
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)
.
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.