-
Notifications
You must be signed in to change notification settings - Fork 29
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
Support multiple schemas in @response
?
#64
Comments
I don't consider the idea of multiple schemas a good API design practice, so I really have no direct experience (or interest) in implementing this. But marshmallow supports nesting schemas, which may give you something close to what you need. Or else you can hand modify the OpenAPI data structure in a |
@miguelgrinberg What would be the approach if I wanted to return a schema if everything goes well but some kind of failed schema if something goes wrong? |
@sgavil Your question makes me think that you think APIFairy somehow prevents you from returning an error response based on a schema. This is actually incorrect, you can return anything you want in an error handler, including a serialized Marshmallow schema. In terms documenting your error schemas, see the @other_responses decorator. |
The thing that trips me up with this is that, say you have a flask-httpauth error handler which might return a 401, 403, whatever, and you apply this flask-httpauth object to a route with |
@sersorrel You can create your own custom authentication decorator that passes all its arguments through to |
@miguelgrinberg But if I add the |
@sgavil Yes, you should return your error responses in an error handler, not in the route function. |
This is a requirement we had in our team where we have a different set of responses (thus multiple schemas) for a given endpoint. I tried marshmallow-oneofschema but that does not seem to work. Any thoughts on this?
The text was updated successfully, but these errors were encountered: