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
Error loading Swagger docs when transforming a flat object to a nested structure #756
Comments
I think you need to use nested fields |
If I use nested fields, like:
The Swagger docs work, but the result is not correct:
As far as I understood, nested fields would be to marshall an object with already a nested structure. Am I wrong? |
Would it work as supposed if you write following? @ns.route("/")
class GetUser(Resource):
@ns.marshal_with(user)
def get(self):
return {"id": 1, "phone": {"cell":123456}} |
@kovalevfm |
Seconded, I just stumbled on this an came to the exact same conclusion. |
The object you're trying to marshal is: But the model you define when you write
expects an object of the form: Hence the doc is good but the object cannot be marshalled correctly, I think it's what @kovalevfm meant in his answer. |
@Tulkas46
and it's marshalling correct. However, the swagger page breaks. That's the issue |
Sorry but the link you provide shows uses of simple I did elaborate on your example to show some possibilities to readers:
@jlongo-daitan I'm afraid you have to use something like |
@Tulkas46 I fixed that issue by transforming the object before marshalling. Anyway, the doc was making me think that would be possible |
This definitely seems like a bug with the swagger docs generation. Yes its possible to work around it by decoupling the response marshalling and documentation generation, but that kind of defeats the purpose of using the |
Description
I could marshall a flat object to a nested structure using the example from https://flask-restplus.readthedocs.io/en/stable/marshalling.html#complex-structures :
into
However, the Swagger docs stop working.
Code
app.py
requirements.txt (from pip install Flask and pip install flask-restplus)
Repro Steps (if applicable)
Expected Behavior
Swagger UI should render correctly
Actual Behavior
You'll see the message: "No API definition provided"
Error Messages/Stack Trace
Environment
The text was updated successfully, but these errors were encountered: