Title: [Feature]: strict validation of additionalProperties · Issue #1080 · python-openapi/openapi-core · GitHub
Open Graph Title: [Feature]: strict validation of additionalProperties · Issue #1080 · python-openapi/openapi-core
X Title: [Feature]: strict validation of additionalProperties · Issue #1080 · python-openapi/openapi-core
Description: Suggested Behavior I would like to request a new configurable behaviour: When additionalProperties is false or undefined on an object in the schema, I would like validation to fail (with a descriptive error message) if the object in the ...
Open Graph Description: Suggested Behavior I would like to request a new configurable behaviour: When additionalProperties is false or undefined on an object in the schema, I would like validation to fail (with a descript...
X Description: Suggested Behavior I would like to request a new configurable behaviour: When additionalProperties is false or undefined on an object in the schema, I would like validation to fail (with a descript...
Opengraph URL: https://github.com/python-openapi/openapi-core/issues/1080
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"[Feature]: strict validation of additionalProperties","articleBody":"### Suggested Behavior\n\nI would like to request a new configurable behaviour:\nWhen additionalProperties is false or undefined on an object in the schema, I would like validation to fail (with a descriptive error message) if the object in the request/response contains any property not explicitly defined in the schema.\n\nExample schema:\n```\nopenapi: 3.1.0\ninfo:\n title: My API\n version: 1.0.0\nservers:\n - url: https://api.example.com/v1\npaths:\n /posts:\n post:\n summary: Create a new post\n requestBody:\n required: true\n content:\n application/json:\n schema:\n $ref: '#/components/schemas/Post'\n /comments:\n post:\n summary: Create a new comment\n requestBody:\n required: true\n content:\n application/json:\n schema:\n $ref: '#/components/schemas/Comment'\n /tags:\n post:\n summary: Create a new tag\n requestBody:\n required: true\n content:\n application/json:\n schema:\n $ref: '#/components/schemas/Tag'\ncomponents:\n schemas:\n Post:\n type: object\n required:\n - title\n - body\n properties:\n title:\n type: string\n body:\n type: string\n additionalProperties: true\n Comment:\n type: object\n required:\n - text\n properties:\n text:\n type: string\n additionalProperties: false\n Tag:\n type: object\n required:\n - name\n properties:\n name:\n type: string\n```\n\nExample POST body to `https://api.example.com/v1/tags`:\n```\n{\n \"name\": \"Tag Name\",\n \"sneaky_property\": \"this should not be allowed\"\n}\n```\n\nExample ValidationError:\n```\n\"Validation of object {'name': 'Tag Name', 'sneaky_property': 'this should not be allowed'} failed: additional properties are not allowed ('sneaky_property' was unexpected)\"\n```\n\nI have an implementation of this where I'm overrriding `ObjectCaster._cast_proparties` (sic!) and making a check there. This worked fine so far, but injecting this into `oas30_casters_dict` and friends, and then assembling the relevant classes to build a custom `V30RequestValidator` is not trivial. Also, 0.22.0 broke my implementation and so far I couldn't figure out where.\n\nI could provide my implementation, which is not guaranteed to fit the current architecture, and tests currently only exist in proprietary code.\n\n### Why is this needed?\n\nLoose third-party schemas could be made more strict, and by extension more secure, if this validation behaviour could be configured during run time.\n\n### References\n\n_No response_\n\n### Would you like to implement a feature?\n\nNone","author":{"url":"https://github.com/number492","@type":"Person","name":"number492"},"datePublished":"2025-12-23T16:44:29.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":0},"url":"https://github.com/1080/openapi-core/issues/1080"}
| 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:766aee3f-e3d2-43c2-2d75-bf3af687367a |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 9EF4:1DECF9:178A41D:1EAF3DB:696B28E7 |
| html-safe-nonce | 7d348070e76a9b86ec03510f416d8cb8a74be4ddcf2edf5ed961f7d12105148d |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI5RUY0OjFERUNGOToxNzhBNDFEOjFFQUYzREI6Njk2QjI4RTciLCJ2aXNpdG9yX2lkIjoiMjQwMzk4MjUwNjg4OTc4MzUyNyIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 6ca118226865fa6ca82d1b3b35f482db840ed4e8c88857500079e660a01fe8d1 |
| hovercard-subject-tag | issue:3757937703 |
| 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/1080/issue_layout |
| twitter:image | https://opengraph.githubassets.com/4c26a305aa116e88d32adb8074249c0dffb5e2baee108298966f9c9ba6d6d5a7/python-openapi/openapi-core/issues/1080 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/4c26a305aa116e88d32adb8074249c0dffb5e2baee108298966f9c9ba6d6d5a7/python-openapi/openapi-core/issues/1080 |
| og:image:alt | Suggested Behavior I would like to request a new configurable behaviour: When additionalProperties is false or undefined on an object in the schema, I would like validation to fail (with a descript... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | number492 |
| hostname | github.com |
| expected-hostname | github.com |
| None | 5f99f7c1d70f01da5b93e5ca90303359738944d8ab470e396496262c66e60b8d |
| 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 | 82560a55c6b2054555076f46e683151ee28a19bc |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width