diff --git a/flask_restx/swagger.py b/flask_restx/swagger.py index ec0a1975..53d44803 100644 --- a/flask_restx/swagger.py +++ b/flask_restx/swagger.py @@ -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: @@ -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)