Title: Merge properties when combining schemas with `allOf` · Issue #2107 · oapi-codegen/oapi-codegen · GitHub
Open Graph Title: Merge properties when combining schemas with `allOf` · Issue #2107 · oapi-codegen/oapi-codegen
X Title: Merge properties when combining schemas with `allOf` · Issue #2107 · oapi-codegen/oapi-codegen
Description: Currently oapi-codegen doesn't merge property definitions when combining schemas with allOf and instead takes the complete property from the last one it sees: oapi-codegen/pkg/codegen/merge_schemas.go Line 203 in 0d94f2f // TODO: detect ...
Open Graph Description: Currently oapi-codegen doesn't merge property definitions when combining schemas with allOf and instead takes the complete property from the last one it sees: oapi-codegen/pkg/codegen/merge_schemas...
X Description: Currently oapi-codegen doesn't merge property definitions when combining schemas with allOf and instead takes the complete property from the last one it sees: oapi-codegen/pkg/codegen/merge_sch...
Opengraph URL: https://github.com/oapi-codegen/oapi-codegen/issues/2107
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Merge properties when combining schemas with `allOf`","articleBody":"Currently oapi-codegen doesn't merge property definitions when combining schemas with `allOf` and instead takes the complete property from the last one it sees: https://github.com/oapi-codegen/oapi-codegen/blob/0d94f2f2015e5fec2cd66273eeb8eff7d1f86bc1/pkg/codegen/merge_schemas.go#L203\n\nThis means we can't create a schema for a JSON Merge Patch endpoint that inherits types and everything else from a base schema and just makes some of them nullable (as sending `null` is how one clears a value in RFC 7396). This approach is described here: https://blog.stoplight.io/reuse-openapi-descriptions Instead we have to maintain redundant types/formats/descriptions/etc. for the properties.\n\nFrom this doc in the spec it does seem like properties are expected to be inherited: https://swagger.io/docs/specification/v3_0/data-models/inheritance-and-polymorphism/\n\nAnd other implementations seem to merge them: https://github.com/Redocly/redoc/blob/34623575ce4741280df4c960f926c3751022b026/src/services/OpenAPIParser.ts#L276\n\nUnderstandably a full merge would be an undertaking, reflection is not ideal, and something like [mergo](https://github.com/darccio/mergo) would be a somewhat heavy extra dep. However, even a shallow merge of a subset of `Schema` properties would enable this PATCH use case and presumably many others.","author":{"url":"https://github.com/skomorokh","@type":"Person","name":"skomorokh"},"datePublished":"2025-10-17T20:39:29Z","url":"https://github.com/oapi-codegen/oapi-codegen/issues/2107"}
| 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:8b309911-6aef-ca7d-925e-aaf6c7520344 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | DE42:381FD0:2360ED:30FBEC:6AF9C9E7 |
| html-safe-nonce | 04997c6625f1831e977e42357dbb7a3e32bc20616bedef6beac99b0a82711f86 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJERTQyOjM4MUZEMDoyMzYwRUQ6MzBGQkVDOjZBRjlDOUU3IiwidmlzaXRvcl9pZCI6IjI3Mjk3MzczNTk0OTc3NDI4MjMiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | febebeac3cd71956954bbac93032aaf12061c4078601cc94f5db58ec9fba32b3 |
| hovercard-subject-tag | issue:3527484183 |
| 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/oapi-codegen/oapi-codegen/2107/issue_layout |
| twitter:image | https://opengraph.githubassets.com/fa35251f178e3edc1d8021c99bb56fa2382a98861757617e794cf43b3a45e052/oapi-codegen/oapi-codegen/issues/2107 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/fa35251f178e3edc1d8021c99bb56fa2382a98861757617e794cf43b3a45e052/oapi-codegen/oapi-codegen/issues/2107 |
| og:image:alt | Currently oapi-codegen doesn't merge property definitions when combining schemas with allOf and instead takes the complete property from the last one it sees: oapi-codegen/pkg/codegen/merge_schemas... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | skomorokh |
| hostname | github.com |
| expected-hostname | github.com |
| None | 612d3e6ffd693e7ea8d9fcf452370995872baef31d825b1fedef704cd3d24ac7 |
| turbo-cache-control | no-preview |
| go-import | github.com/oapi-codegen/oapi-codegen git https://github.com/oapi-codegen/oapi-codegen.git |
| octolytics-dimension-user_id | 142752710 |
| octolytics-dimension-user_login | oapi-codegen |
| octolytics-dimension-repository_id | 173009358 |
| octolytics-dimension-repository_nwo | oapi-codegen/oapi-codegen |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 173009358 |
| octolytics-dimension-repository_network_root_nwo | oapi-codegen/oapi-codegen |
| 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