Title: Spec now validates three times · Issue #714 · python-openapi/openapi-core · GitHub
Open Graph Title: Spec now validates three times · Issue #714 · python-openapi/openapi-core
X Title: Spec now validates three times · Issue #714 · python-openapi/openapi-core
Description: This seems wasteful since `Spec.from_dict` has already validated the spec. This now validates the spec three times, once in `Spec.from_dict`, once in `validate_request`, and once in `validate_response`: from openapi_core import Spec, val...
Open Graph Description: This seems wasteful since `Spec.from_dict` has already validated the spec. This now validates the spec three times, once in `Spec.from_dict`, once in `validate_request`, and once in `validate_respo...
X Description: This seems wasteful since `Spec.from_dict` has already validated the spec. This now validates the spec three times, once in `Spec.from_dict`, once in `validate_request`, and once in `validate_respo...
Opengraph URL: https://github.com/python-openapi/openapi-core/issues/714
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Spec now validates three times","articleBody":" This seems wasteful since `Spec.from_dict` has already validated the spec. This now validates the spec three times, once in `Spec.from_dict`, once in `validate_request`, and once in `validate_response`:\r\n\r\n```python\r\nfrom openapi_core import Spec, validate_request, validate_response\r\nfrom openapi_core.testing import MockRequest, MockResponse\r\n\r\nspec = Spec.from_dict(\r\n {\r\n \"openapi\": \"3.1.0\",\r\n \"info\": {\"title\": \"Test\", \"version\": \"1.0.0\"},\r\n \"paths\": {\"/\": {\"get\": {\"responses\": {\"200\": {\"description\": \"OK\"}}}}},\r\n },\r\n)\r\nrequest = MockRequest(\"http://localhost\", \"get\", \"/\")\r\nvalidate_request(request, spec=spec)\r\nresponse = MockResponse(\"\")\r\nvalidate_response(request, response, spec=spec)\r\n```\r\n\r\nThis adds a very expensive per-request and per-response overhead when the spec is large.\r\n\r\nMoreover, the documented workaround doesn’t work; this still validates the spec (as can be seen by misspelling `title`, say):\r\n\r\n```python\r\nfrom openapi_core import Spec, validate_request, validate_response\r\nfrom openapi_core.testing import MockRequest, MockResponse\r\n\r\nspec = Spec.from_dict(\r\n {\r\n \"openapi\": \"3.1.0\",\r\n \"info\": {\"titel\": \"Test\", \"version\": \"1.0.0\"},\r\n \"paths\": {\"/\": {\"get\": {\"responses\": {\"200\": {\"description\": \"OK\"}}}}},\r\n },\r\n validator=None,\r\n)\r\nrequest = MockRequest(\"http://localhost\", \"get\", \"/\")\r\nvalidate_request(request, spec=spec, spec_validator_cls=None)\r\nresponse = MockResponse(\"\")\r\nvalidate_response(request, response, spec=spec, spec_validator_cls=None)\r\n```\r\n\r\n_Originally posted by @andersk in https://github.com/python-openapi/openapi-core/issues/686#issuecomment-1769685666_\r\n ","author":{"url":"https://github.com/p1c2u","@type":"Person","name":"p1c2u"},"datePublished":"2023-11-03T20:46:15.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":0},"url":"https://github.com/714/openapi-core/issues/714"}
| 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:4f377793-8a90-4f22-aab4-77ed41320ab0 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | B0B2:2C62EA:2927C7:390310:69774993 |
| html-safe-nonce | a92693f3a0a4f2eea3128504e240e5037bc3170f7f903cfba49fa2d4b9edafbe |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJCMEIyOjJDNjJFQToyOTI3Qzc6MzkwMzEwOjY5Nzc0OTkzIiwidmlzaXRvcl9pZCI6IjczNTEyMzExOTc3MTMyMjIwMzUiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 35f1aaa96998d399d384a74626fa1189489077bcda7ca395666fffbbe7909afd |
| hovercard-subject-tag | issue:1976908732 |
| 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/714/issue_layout |
| twitter:image | https://opengraph.githubassets.com/297b955dc115c5a2b02454dacdfa5ec533a632d7b8d79133ce5a0b44b43daac7/python-openapi/openapi-core/issues/714 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/297b955dc115c5a2b02454dacdfa5ec533a632d7b8d79133ce5a0b44b43daac7/python-openapi/openapi-core/issues/714 |
| og:image:alt | This seems wasteful since `Spec.from_dict` has already validated the spec. This now validates the spec three times, once in `Spec.from_dict`, once in `validate_request`, and once in `validate_respo... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | p1c2u |
| hostname | github.com |
| expected-hostname | github.com |
| None | 01d198479908d09a841b2febe8eb105a81af2af7d81830960fe0971e1f4adc09 |
| 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 | d37e99eca9fba24ee37da98481d573461cc1ab7d |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width