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

Fix #613 #614

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ Basic structure is
ADD LINK (..) _section-VERSION
VERSION
-------
ADD LINK (..) _bug_fixes-VERSION OR _enhancments-VERSION
ADD LINK (..) _bug_fixes-VERSION OR _enhancements-VERSION
Bug Fixes or Enchancements
~~~~~~~~~~~~~~~~~~~~~~~~~~
* Message (TICKET) [CONTRIBUTOR]
Expand All @@ -35,7 +35,7 @@ Bug Fixes
::

* Add python version requirement on setup.py (#586) [jason-the-j]

* Register models nested inside response fields (#613) [panda-byte]

.. _section-1.3.0:
1.3.0
Expand Down
7 changes: 7 additions & 0 deletions flask_restx/swagger.py
Original file line number Diff line number Diff line change
Expand Up @@ -680,6 +680,7 @@ def serialize_schema(self, model):
return self.serialize_schema(model())

elif isinstance(model, fields.Raw):
self.register_field(model)
return model.__schema__

elif isinstance(model, (type, type(None))) and model in PY_TYPES:
Expand All @@ -704,6 +705,12 @@ def register_model(self, model):
return ref(model)

def register_field(self, field):
"""
Traverse a "container" field (`Nested`, `List`, `Wildcard`,
and `Polymorph`) and register any nested models. Used for
models nested inside other models or responses using fields
for definition.
"""
if isinstance(field, fields.Polymorph):
for model in field.mapping.values():
self.register_model(model)
Expand Down