Title: Nullable `allOf`s with default `null` values fail validation · Issue #418 · python-openapi/openapi-spec-validator · GitHub
Open Graph Title: Nullable `allOf`s with default `null` values fail validation · Issue #418 · python-openapi/openapi-spec-validator
X Title: Nullable `allOf`s with default `null` values fail validation · Issue #418 · python-openapi/openapi-spec-validator
Description: Hi, In OpenAPI 3.0 it's a common pattern to represent a reference that can be null as an allOf with nullable: true. However, if you set the default to null, openapi-spec-validator attempts to validate null against the referenced schema, ...
Open Graph Description: Hi, In OpenAPI 3.0 it's a common pattern to represent a reference that can be null as an allOf with nullable: true. However, if you set the default to null, openapi-spec-validator attempts to valid...
X Description: Hi, In OpenAPI 3.0 it's a common pattern to represent a reference that can be null as an allOf with nullable: true. However, if you set the default to null, openapi-spec-validator attempts to v...
Opengraph URL: https://github.com/python-openapi/openapi-spec-validator/issues/418
X: @github
Domain: patch-diff.githubusercontent.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Nullable `allOf`s with default `null` values fail validation","articleBody":"Hi,\n\nIn OpenAPI 3.0 it's a common pattern to represent a reference that can be null as an `allOf` with `nullable: true`. \n\nHowever, if you set the `default` to `null`, `openapi-spec-validator` attempts to validate `null` against the referenced schema, and returns an error. The default should take into account the nullability of the schema that it's part of, not just the referenced `allOf`.\n\n```\n{\n \"info\": {\n \"title\": \"Example\",\n \"version\": \"v1\",\n },\n \"openapi\": \"3.0.2\",\n \"components\": {\n \"schemas\": {\n \"FooSchema\": {\n \"title\": \"FooSchema\",\n \"type\": \"object\"\n },\n \"BarSchema\": {\n \"allOf\": [\n {\n \"$ref\": \"#/components/schemas/FooSchema\"\n }\n ],\n \"nullable\": true,\n \"default\": null\n }\n }\n },\n \"paths\": {}\n}\n```\n\n```\nFailed validating 'type' in schema['allOf'][0]:\n {'title': 'FooSchema', 'type': 'object'}\n\nOn instance:\n None\n```","author":{"url":"https://github.com/pranjalv123","@type":"Person","name":"pranjalv123"},"datePublished":"2025-07-01T13:33:20.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":0},"url":"https://github.com/418/openapi-spec-validator/issues/418"}
| 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:4154049a-a828-096b-c378-1e1cab3737da |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | CA9C:F5DBC:2CD901A:3E40974:6977BCD1 |
| html-safe-nonce | 42fef404f78f9a6ac3cbecaceb518d3361f2f6025242b1d96894e89fadb0ff58 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJDQTlDOkY1REJDOjJDRDkwMUE6M0U0MDk3NDo2OTc3QkNEMSIsInZpc2l0b3JfaWQiOiIzMzk4Nzc2OTkwODM0NjA1MjY1IiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | aa6d08cc84b73188ae1c2106b6dbe81e2465e0a38b60e1054c20ed048683b0d7 |
| hovercard-subject-tag | issue:3192521300 |
| 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/418/issue_layout |
| twitter:image | https://opengraph.githubassets.com/588d28c5c844650cc6cf0f5860d835fc0c7db9cd8d8dabad76e45e49d163a297/python-openapi/openapi-spec-validator/issues/418 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/588d28c5c844650cc6cf0f5860d835fc0c7db9cd8d8dabad76e45e49d163a297/python-openapi/openapi-spec-validator/issues/418 |
| og:image:alt | Hi, In OpenAPI 3.0 it's a common pattern to represent a reference that can be null as an allOf with nullable: true. However, if you set the default to null, openapi-spec-validator attempts to valid... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | pranjalv123 |
| hostname | github.com |
| expected-hostname | github.com |
| None | 831218810e1b66a41a0626c8c15f7f47625846d9a7516c7f43cfc2c61effad83 |
| 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 | b37ffa89d073c0d4a6f07ff42d59120741a74955 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width