You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
For a flask app, the openapi decorator is failing to provide a response to the flask decorator. Running the following minimum reproducible example, basically taken directly from the documentation:
openapi: 3.1.0info:
title: OSS IRI rewritedescription: This api will specify the different ways to call the IRI toolversion: 0.1.0paths:
/home:
get:
responses:
"200":
content:
text/html:
schema:
type: string
by running the command:
flask --app application run
then curling:
curl localhost:5000/home
produces the following error:
[2023-01-25 14:54:26,776] ERROR in app: Exception on /home [GET]
Traceback (most recent call last):
File "/home/connor/.local/lib/python3.10/site-packages/flask/app.py", line 2525, in wsgi_app
response = self.full_dispatch_request()
File "/home/connor/.local/lib/python3.10/site-packages/flask/app.py", line 1822, in full_dispatch_request
rv = self.handle_user_exception(e)
File "/home/connor/.local/lib/python3.10/site-packages/flask/app.py", line 1820, in full_dispatch_request
rv = self.dispatch_request()
File "/home/connor/.local/lib/python3.10/site-packages/flask/app.py", line 1796, in dispatch_request
return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)
File "/home/connor/.local/lib/python3.10/site-packages/openapi_core/contrib/flask/decorators.py", line 57, in decorated
response_result = self.process_response(
File "/home/connor/.local/lib/python3.10/site-packages/openapi_core/validation/processors.py", line 28, in process_response
return self.response_validator.validate(spec, request, response)
File "/home/connor/.local/lib/python3.10/site-packages/openapi_core/validation/response/proxies.py", line 38, in validate
return validator.validate(spec, request, response, base_url=base_url)
File "/home/connor/.local/lib/python3.10/site-packages/openapi_core/validation/response/validators.py", line 234, in validate
operation_response = self._find_operation_response(
File "/home/connor/.local/lib/python3.10/site-packages/openapi_core/validation/response/validators.py", line 63, in _find_operation_response
return self._get_operation_response(operation, response)
File "/home/connor/.local/lib/python3.10/site-packages/openapi_core/validation/response/validators.py", line 71, in _get_operation_response
return finder.find(str(response.status_code))
File "/home/connor/.local/lib/python3.10/site-packages/openapi_core/contrib/werkzeug/responses.py", line 16, in status_code
return self.response._status_code
AttributeError: 'NoneType' object has no attribute '_status_code'
It seems that combining the openapi decorator with the flask decorator (exactly as shown in the docs) causes the flask decorator to only get the output of the routing function, rather than a response object which wraps that output.
The text was updated successfully, but these errors were encountered:
it's not the OpenAPI decorator issue. Your home view function is invalid. Remove the OpenAPI decorator and run your request again and you will get flask error
TypeError: The view function for 'home' did not return a valid response. The function either returned None or ended without a return statement.
But it's a good point that decorator/integration should check request type at the beginning.
EDIT: Next issue can be not handling str, bytes, dict, list and tuple return values from decorated function.
For a flask app, the openapi decorator is failing to provide a response to the flask decorator. Running the following minimum reproducible example, basically taken directly from the documentation:
application/__init__.py
:openapi_alt.yml
:by running the command:
then curling:
produces the following error:
It seems that combining the openapi decorator with the flask decorator (exactly as shown in the docs) causes the flask decorator to only get the output of the routing function, rather than a response object which wraps that output.
The text was updated successfully, but these errors were encountered: