Title: Failure to correctly validate required in allOf · Issue #15 · python-openapi/openapi-schema-validator · GitHub
Open Graph Title: Failure to correctly validate required in allOf · Issue #15 · python-openapi/openapi-schema-validator
X Title: Failure to correctly validate required in allOf · Issue #15 · python-openapi/openapi-schema-validator
Description: Having one spec with optional properties and creating a derived spec using allOf that makes a property required fails. This should be supported according to json schema itself (e.g. here) To reproduce (with 0.1.5): from openapi_schema_va...
Open Graph Description: Having one spec with optional properties and creating a derived spec using allOf that makes a property required fails. This should be supported according to json schema itself (e.g. here) To reprod...
X Description: Having one spec with optional properties and creating a derived spec using allOf that makes a property required fails. This should be supported according to json schema itself (e.g. here) To reprod...
Opengraph URL: https://github.com/python-openapi/openapi-schema-validator/issues/15
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Failure to correctly validate required in allOf","articleBody":"Having one spec with optional properties and creating a derived spec using `allOf` that makes a property required fails. This should be supported according to json schema itself (e.g. [here](https://github.com/OAI/OpenAPI-Specification/issues/1870#issuecomment-478653692))\r\n\r\nTo reproduce (with 0.1.5):\r\n\r\n```python\r\nfrom openapi_schema_validator import validate\r\n\r\n\r\nschema = {\r\n \"allOf\": [\r\n {\"type\": \"object\", \"properties\": {\"some_prop\": {\"type\": \"string\"}}},\r\n {\"type\": \"object\", \"required\": [\"some_prop\"]},\r\n ]\r\n}\r\n\r\nvalidate({\"another_prop\": \"bla\"}, schema)\r\n```\r\n\r\nExpected behaviour: an error that the required property `some_prop` is missing. The code actually correctly figures that out, but when it tries to check whether it is ok to have that property missing because it is e.g. a `readOnly` missing in a write operation a \"runtime\" error is produced instead of a validation exception:\r\n\r\n```python\r\n~/venvs/py39/lib/python3.9/site-packages/openapi_schema_validator/_validators.py in required(validator, required, instance, schema)\r\n 41 for property in required:\r\n 42 if property not in instance:\r\n---> 43 prop_schema = schema['properties'][property]\r\n 44 read_only = prop_schema.get('readOnly', False)\r\n 45 write_only = prop_schema.get('writeOnly', False)\r\n\r\nKeyError: 'properties'\r\n```\r\n\r\nThe problem is that here `schema` is only the second schema with the `required` - but the property can come from any schema in the `allOf`.","author":{"url":"https://github.com/sebastianmika","@type":"Person","name":"sebastianmika"},"datePublished":"2021-06-24T16:39:06Z","url":"https://github.com/python-openapi/openapi-schema-validator/issues/15"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react-reconciler,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@d5750093facf |
| 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:23e2f03b-08bc-a7ff-cdc9-15b7e09ba9bd |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 97A4:387B0D:6B0DF7:952140:6AF9C60C |
| html-safe-nonce | 7f89bc4b7a5ff834d53fd88bdb06ffcf3e9a4b254b7f8e7cd18b521b491320e5 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI5N0E0OjM4N0IwRDo2QjBERjc6OTUyMTQwOjZBRjlDNjBDIiwidmlzaXRvcl9pZCI6Ijg4NzI5NjY1ODYzNDQ1MjMyNzYiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | db9a72aec9c190b8cd8a00da035eb9b472b10378243c6c6a2da11d52e0b807ba |
| hovercard-subject-tag | issue:929416948 |
| 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-schema-validator/15/issue_layout |
| twitter:image | https://opengraph.githubassets.com/04b140246a84b9ee1faffdbba24b4e63559de255ede1fcef92487633efe25df1/python-openapi/openapi-schema-validator/issues/15 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/04b140246a84b9ee1faffdbba24b4e63559de255ede1fcef92487633efe25df1/python-openapi/openapi-schema-validator/issues/15 |
| og:image:alt | Having one spec with optional properties and creating a derived spec using allOf that makes a property required fails. This should be supported according to json schema itself (e.g. here) To reprod... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | sebastianmika |
| hostname | github.com |
| expected-hostname | github.com |
| None | 612d3e6ffd693e7ea8d9fcf452370995872baef31d825b1fedef704cd3d24ac7 |
| turbo-cache-control | no-preview |
| go-import | github.com/python-openapi/openapi-schema-validator git https://github.com/python-openapi/openapi-schema-validator.git |
| octolytics-dimension-user_id | 126442889 |
| octolytics-dimension-user_login | python-openapi |
| octolytics-dimension-repository_id | 245119225 |
| octolytics-dimension-repository_nwo | python-openapi/openapi-schema-validator |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 245119225 |
| octolytics-dimension-repository_network_root_nwo | python-openapi/openapi-schema-validator |
| 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 | 072e34035c13c31543fba9f025cbbbda4210dae4 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width