I had no problems using the abort method as a way to stop the flow of an application and display a message, for example abort(401, message='Your entry is not authorized')
but what I am not achieving is getting it documented correctly in Swagger UI. I was able to get it to appear as a possible response using @blp.alt_response(401)
but I am not getting the schema to be passed (and therefore the example error being generated). What should happen in these cases is the Default Error Schema being used, but I'm confused. Could someone help me?
Note: I tried passing the Api.Error_Schema schema as an argument in the abort method but I don't know if it is the correct way and in fact it generates a different schema reference than the one generated in the documentation for the DEFAULT ERROR.
The only thing I can think of to do is generate a CustomErrorSchema and use it and document all my functions that include an abort with it, but I don't know if it's the right way. A guide to resolve this issue would be very helpful. What I don't want is to simply launch an abort and have this not be documented anywhere.
Try passing the schema of the error like this:
from flask_smorest import error_handler
...
@blp.alt_response(401, schema=error_handler.ErrorSchema)
Here is some extra information from a GitHub issue.