Title: Flask Integation decorator failing · Issue #488 · python-openapi/openapi-core · GitHub
Open Graph Title: Flask Integation decorator failing · Issue #488 · python-openapi/openapi-core
X Title: Flask Integation decorator failing · Issue #488 · python-openapi/openapi-core
Description: 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: from flask impo...
Open Graph Description: 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: ...
X Description: 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: ...
Opengraph URL: https://github.com/python-openapi/openapi-core/issues/488
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Flask Integation decorator failing","articleBody":"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:\r\n\r\n`application/__init__.py`:\r\n```python\r\nfrom flask import Flask\r\nfrom openapi_core import Spec\r\nfrom openapi_core.contrib.flask.decorators import FlaskOpenAPIViewDecorator\r\n\r\napp = Flask(__name__)\r\nspec = Spec.from_file_path(\"openapi_alt.yml\")\r\nopenapi = FlaskOpenAPIViewDecorator.from_spec(spec)\r\n\r\n@app.route('/home')\r\n@openapi\r\ndef home():\r\n pass\r\n```\r\n\r\n`openapi_alt.yml`:\r\n```yml\r\nopenapi: 3.1.0\r\ninfo:\r\n title: OSS IRI rewrite\r\n description: This api will specify the different ways to call the IRI tool\r\n version: 0.1.0\r\npaths:\r\n /home:\r\n get:\r\n responses:\r\n \"200\":\r\n content:\r\n text/html:\r\n schema:\r\n type: string\r\n```\r\nby running the command:\r\n\r\n```bash\r\nflask --app application run\r\n```\r\nthen curling:\r\n```bash\r\ncurl localhost:5000/home\r\n```\r\nproduces the following error:\r\n```\r\n[2023-01-25 14:54:26,776] ERROR in app: Exception on /home [GET]\r\nTraceback (most recent call last):\r\n File \"/home/connor/.local/lib/python3.10/site-packages/flask/app.py\", line 2525, in wsgi_app\r\n response = self.full_dispatch_request()\r\n File \"/home/connor/.local/lib/python3.10/site-packages/flask/app.py\", line 1822, in full_dispatch_request\r\n rv = self.handle_user_exception(e)\r\n File \"/home/connor/.local/lib/python3.10/site-packages/flask/app.py\", line 1820, in full_dispatch_request\r\n rv = self.dispatch_request()\r\n File \"/home/connor/.local/lib/python3.10/site-packages/flask/app.py\", line 1796, in dispatch_request\r\n return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)\r\n File \"/home/connor/.local/lib/python3.10/site-packages/openapi_core/contrib/flask/decorators.py\", line 57, in decorated\r\n response_result = self.process_response(\r\n File \"/home/connor/.local/lib/python3.10/site-packages/openapi_core/validation/processors.py\", line 28, in process_response\r\n return self.response_validator.validate(spec, request, response)\r\n File \"/home/connor/.local/lib/python3.10/site-packages/openapi_core/validation/response/proxies.py\", line 38, in validate\r\n return validator.validate(spec, request, response, base_url=base_url)\r\n File \"/home/connor/.local/lib/python3.10/site-packages/openapi_core/validation/response/validators.py\", line 234, in validate\r\n operation_response = self._find_operation_response(\r\n File \"/home/connor/.local/lib/python3.10/site-packages/openapi_core/validation/response/validators.py\", line 63, in _find_operation_response\r\n return self._get_operation_response(operation, response)\r\n File \"/home/connor/.local/lib/python3.10/site-packages/openapi_core/validation/response/validators.py\", line 71, in _get_operation_response\r\n return finder.find(str(response.status_code))\r\n File \"/home/connor/.local/lib/python3.10/site-packages/openapi_core/contrib/werkzeug/responses.py\", line 16, in status_code\r\n return self.response._status_code\r\nAttributeError: 'NoneType' object has no attribute '_status_code'\r\n```\r\n\r\nIt 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.","author":{"url":"https://github.com/rconnorjohnstone","@type":"Person","name":"rconnorjohnstone"},"datePublished":"2023-01-25T21:56:09.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":1},"url":"https://github.com/488/openapi-core/issues/488"}
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:cd24f4cd-cac0-0a34-36bf-35a6408d974c |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | D808:11A8B3:4B8DBD:69FAAC:6978A604 |
| html-safe-nonce | 530a71f9bf8b36f20282f3eac87057f93fd92049cbac5db3cdbafd0aaae4bdd2 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJEODA4OjExQThCMzo0QjhEQkQ6NjlGQUFDOjY5NzhBNjA0IiwidmlzaXRvcl9pZCI6IjQyMjI4NzUxODA3ODQ0NjEzMTYiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 615b51babeea0a3395a49c567bb900d6e0275c8d27670dd11207a63d36d2b051 |
| hovercard-subject-tag | issue:1557327649 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/python-openapi/openapi-core/488/issue_layout |
| twitter:image | https://opengraph.githubassets.com/b18a63cfda70ff44d464e348d33ca7dbf7851f649561cf14d5aca80d06d61a4a/python-openapi/openapi-core/issues/488 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/b18a63cfda70ff44d464e348d33ca7dbf7851f649561cf14d5aca80d06d61a4a/python-openapi/openapi-core/issues/488 |
| og:image:alt | 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: ... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | rconnorjohnstone |
| hostname | github.com |
| expected-hostname | github.com |
| None | 2981c597c945c1d90ac6fa355ce7929b2f413dfe7872ca5c435ee53a24a1de50 |
| turbo-cache-control | no-preview |
| go-import | github.com/python-openapi/openapi-core git https://github.com/python-openapi/openapi-core.git |
| octolytics-dimension-user_id | 126442889 |
| octolytics-dimension-user_login | python-openapi |
| octolytics-dimension-repository_id | 104200746 |
| octolytics-dimension-repository_nwo | python-openapi/openapi-core |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 104200746 |
| octolytics-dimension-repository_network_root_nwo | python-openapi/openapi-core |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | f8aa86d87c47054170094daaf9699b27a28a8448 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width