Skip to content

Support unions with multiple mappings pointing to a single underlying type#2071

Merged
mromaszewicz merged 2 commits intooapi-codegen:mainfrom
tobio:multi-mapping
Feb 16, 2026
Merged

Support unions with multiple mappings pointing to a single underlying type#2071
mromaszewicz merged 2 commits intooapi-codegen:mainfrom
tobio:multi-mapping

Conversation

@tobio
Copy link
Contributor

@tobio tobio commented Sep 2, 2025

Fixes #1530
Fixes #1664

This PR:

  • Correctly generates the ValueByDiscriminator function when multiple discriminator values map to a single type
  • Prevents From*/Merge* functions from setting an arbitrary discriminator in the case where there isn't a 1:1 mapping between type and discriminator value

@tobio tobio requested a review from a team as a code owner September 2, 2025 12:57
@kusari-inspector
Copy link

Kusari Inspector

Kusari Analysis Results:

Proceed with these changes

✅ No Flagged Issues Detected
All values appear to be within acceptable risk parameters.

No pinned version dependency changes, code issues or exposed secrets detected!

@kusari-inspector rerun - Trigger a re-analysis of this PR
@kusari-inspector feedback [your message] - Send feedback to our AI and team
See Kusari's documentation for setup and configuration.
Commit: 71958af, performed at: 2025-09-02T12:57:33Z

Found this helpful? Give it a 👍 or 👎 reaction!

@tobio
Copy link
Contributor Author

tobio commented Sep 23, 2025

@jamietanna are you able to take a look at this one?

@tobio
Copy link
Contributor Author

tobio commented Feb 16, 2026

@mromaszewicz are you able to take a look at this?

@mromaszewicz
Copy link
Member

This looks good, I had to think about it for a while, since this code path is so fragile. Thanks for doing this!

@mromaszewicz mromaszewicz added this to the v2.6.0 milestone Feb 16, 2026
@mromaszewicz mromaszewicz merged commit b658fcf into oapi-codegen:main Feb 16, 2026
26 checks passed
@jamietanna jamietanna added the enhancement New feature or request label Feb 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Polymorphism & Discriminator Use discriminator with several mappings for one schema

3 participants