Issue
I have an APIFlask app and a GET endpoint. Everything works fine and I have the API spec api.yaml
. I can see the responses -
There are some error responses. But I am looking for some 500
response that I raised in the code -
if not identity:
abort(403)
Is there any configuration to have those manual error responses?
Solution
It can't detect the error code you returned in your view function. It does add some status code for your endpoint automatically (401, 422, 404) based on the decorator you used. For other error responses, you have to use the doc
decorator to add manually:
@app.get('/')
@app.doc(responses=[403])
def hello():
abort(403)
Refer to the docs for more details: https://apiflask.com/openapi/#alternative-operation-responses
Answered By - Grey Li
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.