Skip to content

AllOf : Only stop when merging schemas with multiple discriminators#667

Merged
mromaszewicz merged 3 commits into
oapi-codegen:mainfrom
LelouBil:allof-slightly-better-discriminators
Mar 4, 2026
Merged

AllOf : Only stop when merging schemas with multiple discriminators#667
mromaszewicz merged 3 commits into
oapi-codegen:mainfrom
LelouBil:allof-slightly-better-discriminators

Conversation

@LelouBil

@LelouBil LelouBil commented Jul 7, 2022

Copy link
Copy Markdown
Contributor

This is a fix for #666.

It seems to work fine, based on OAI/OpenAPI-Specification#2165 discriminators should be inherited with AllOf, and it can safely be done when only one parent has one.

@furkankavukcu

Copy link
Copy Markdown

What happened to this pr?

@LelouBil

Copy link
Copy Markdown
Contributor Author

Well I did this PR because I was working on a projet that required it. Now I'm doing other stuff.

I'm leaving it open because it might be useful but the maintainers didn't seem to notice it.

@jeffmay

jeffmay commented Jan 25, 2024

Copy link
Copy Markdown

@jamietanna would it be possible to get this one merged? It seems like it would be more permissive, rather than restrictive, so it shouldn't negatively affect existing users.

@jamietanna jamietanna added this to the v2.2.0 milestone Jan 25, 2024
@jamietanna jamietanna modified the milestones: v2.2.0, v2.3.0 Jun 3, 2024
@jamietanna jamietanna modified the milestones: v2.4.0, v2.5.0 Sep 20, 2024
@jamietanna jamietanna modified the milestones: v2.5.0, v2.6.0 May 11, 2025
mromaszewicz and others added 2 commits March 4, 2026 14:21
Combines upstream's allOf guard with PR oapi-codegen#667's discriminator propagation:
- Non-allOf merges reject any discriminator (upstream behavior)
- AllOf merges reject only when both schemas have discriminators (PR oapi-codegen#667)
- Single discriminator is propagated to the merged result (PR oapi-codegen#667)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Covers all discriminator merge scenarios:
- allOf: single discriminator propagated from either schema
- allOf: both schemas having discriminators errors
- allOf: no discriminators succeeds
- non-allOf: any discriminator errors

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@mromaszewicz mromaszewicz requested a review from a team as a code owner March 4, 2026 22:26
@mromaszewicz mromaszewicz merged commit 05503de into oapi-codegen:main Mar 4, 2026
17 checks passed
@mromaszewicz mromaszewicz added the bug Something isn't working label Apr 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants