Open miszczu opened 8 years ago
Just in case someone is looking for a quick fix.
I follow @miszczu suggestion and patch the swagger.py
. I didn't test it properly but so far it works for me.
--- venv/lib/python2.7/site-packages/flask_restplus/swagger.py 2016-12-15 04:43:48.177600793 +0000
+++ patched_flask_restplus_swagger2.py 2016-12-15 04:43:21.864703858 +0000
@@ -452,6 +452,8 @@
if name not in self.api.models:
raise ValueError('Model {0} not registered'.format(name))
specs = self.api.models[name]
+ if name in self._registered_models:
+ return ref(model)
self._registered_models[name] = specs
if isinstance(specs, Model):
for parent in specs.__parents__:
I have defined following circular model in my API:
Marshalling such model with api.marshal_with works ok, but app crashes when I try to open swagger documentation:
Swagger 2.0 accepts circular (recursive) models, so I think this library should handle such cases. Quick fix could be to just check if model is already registered in Swagger.register_model method.
I am using 0.9.2 version