Skip to content

Conversation

@jvatic
Copy link
Contributor

@jvatic jvatic commented May 25, 2025

  • explicit discriminator mapping when >1 key/type
  • explicit discriminator mapping in anyOf
  • fixes JSON encoding for non-explicit mappings when explicit mappings are present (see regression test)

NOTE: This also results in a change in ordering of some variants for the generated encode/decode methods. Logic for each variant is now defined in the same order as the consts. The only downside I see is the unnecessary diffs which seems an acceptable trade-off to adding more complexity to preserve the original ordering.

Fixes #980
Refs #491

jvatic added 3 commits May 25, 2025 10:33
This also adds support for explicit discriminator mapping in anyOf
and fixes JSON encoding for non-explicit mappings when explicit
mappings are present.
@jvatic jvatic force-pushed the discriminator_mapping branch from 0419fd3 to cdb3dd4 Compare May 25, 2025 14:33
@ernado ernado requested a review from a user May 26, 2025 14:48
@ghost ghost merged commit f794c2d into ogen-go:main May 26, 2025
15 checks passed
@jvatic jvatic deleted the discriminator_mapping branch May 27, 2025 13:59
This pull request was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ogen generates non-compilable code when discriminator mapping has duplicate values

1 participant