Title: Allow "required" list to have undefined properties · Issue #97 · python-openapi/openapi-spec-validator · GitHub
Open Graph Title: Allow "required" list to have undefined properties · Issue #97 · python-openapi/openapi-spec-validator
X Title: Allow "required" list to have undefined properties · Issue #97 · python-openapi/openapi-spec-validator
Description: I think requiring property names listed in required to be defined in properties is too strict. I also couldn't find this requirement in the JSON Schema or OpenAPI specs. JSON Schema validators and the Swagger Editor are fine with propert...
Open Graph Description: I think requiring property names listed in required to be defined in properties is too strict. I also couldn't find this requirement in the JSON Schema or OpenAPI specs. JSON Schema validators and ...
X Description: I think requiring property names listed in required to be defined in properties is too strict. I also couldn't find this requirement in the JSON Schema or OpenAPI specs. JSON Schema validators ...
Opengraph URL: https://github.com/python-openapi/openapi-spec-validator/issues/97
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Allow \"required\" list to have undefined properties","articleBody":"I think requiring property names listed in `required` to be defined in `properties` is too strict. I also couldn't find this requirement in the JSON Schema or OpenAPI specs. JSON Schema validators and the Swagger Editor are fine with property names listed in `required` that are not defined in `properties`.\r\n\r\nIt makes sense to list required properties without defining them in `properties` when using `allOf` where one sub-schema requires some properties but does not specify them while another sub-schema only provides the specifications of the properties (possibly even without stating which ones are required and which ones aren't). This is especially useful when referencing and merging schema definitions or when expressing discriminated unions with some properties that are common to all union members.\r\n\r\nI suggest to remove the following code block\r\n\r\nhttps://github.com/p1c2u/openapi-spec-validator/blob/3f53e957812a9c545d71226e3a4d696240e2cee6/openapi_spec_validator/validators.py#L134-L142\r\n\r\nand the `require_properties` argument:\r\n\r\nhttps://github.com/p1c2u/openapi-spec-validator/blob/3f53e957812a9c545d71226e3a4d696240e2cee6/openapi_spec_validator/validators.py#L123\r\n\r\nI have seen the test case\r\n\r\nhttps://github.com/p1c2u/openapi-spec-validator/blob/3f53e957812a9c545d71226e3a4d696240e2cee6/tests/integration/test_validators.py#L83-L115\r\n\r\nbut it also seems to be valid to express this schema like this:\r\n\r\n```python\r\n{\r\n 'Credit': {\r\n 'type': 'object',\r\n 'properties': {\r\n 'clientId': {'type': 'string'},\r\n }\r\n },\r\n 'CreditCreate': {\r\n 'type': 'object',\r\n 'required': ['clientId'],\r\n 'allOf': [\r\n {\r\n '$ref': '#/components/schemas/Credit'\r\n },\r\n # possibly more schemas to merge ...\r\n ]\r\n }\r\n}\r\n```\r\n\r\nOr did I miss this rule somewhere in the spec?","author":{"url":"https://github.com/sisp","@type":"Person","name":"sisp"},"datePublished":"2020-08-03T16:34:09.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":4},"url":"https://github.com/97/openapi-spec-validator/issues/97"}
| 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:62ce4e6f-cd99-0b9d-b1a8-ebac6720ae82 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | AC82:87E17:22D43BD:2E0C9C2:696B0E1A |
| html-safe-nonce | cacde168b7bafbe8cdb3f39bdbfafb084abf04441728c3025da9154cf579814d |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBQzgyOjg3RTE3OjIyRDQzQkQ6MkUwQzlDMjo2OTZCMEUxQSIsInZpc2l0b3JfaWQiOiI0MzgzNDI3MDU0MDgyMzk1Njc0IiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | 5ea7f97b048fb804b3f56f18ce2c2229b357c5b9e054d588052e3f7fa7bd7fbe |
| hovercard-subject-tag | issue:672199386 |
| 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-spec-validator/97/issue_layout |
| twitter:image | https://opengraph.githubassets.com/f88cc3ee16ab567ce7ecd80f55221e4685ffad83fba424a686d50872cd9443c6/python-openapi/openapi-spec-validator/issues/97 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/f88cc3ee16ab567ce7ecd80f55221e4685ffad83fba424a686d50872cd9443c6/python-openapi/openapi-spec-validator/issues/97 |
| og:image:alt | I think requiring property names listed in required to be defined in properties is too strict. I also couldn't find this requirement in the JSON Schema or OpenAPI specs. JSON Schema validators and ... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | sisp |
| hostname | github.com |
| expected-hostname | github.com |
| None | 5f99f7c1d70f01da5b93e5ca90303359738944d8ab470e396496262c66e60b8d |
| turbo-cache-control | no-preview |
| go-import | github.com/python-openapi/openapi-spec-validator git https://github.com/python-openapi/openapi-spec-validator.git |
| octolytics-dimension-user_id | 126442889 |
| octolytics-dimension-user_login | python-openapi |
| octolytics-dimension-repository_id | 102581313 |
| octolytics-dimension-repository_nwo | python-openapi/openapi-spec-validator |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 102581313 |
| octolytics-dimension-repository_network_root_nwo | python-openapi/openapi-spec-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 | 82560a55c6b2054555076f46e683151ee28a19bc |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width