Skip to content

fix: respect discriminator mapping in response body mappers#143

Merged
zedorg merged 2 commits into
DoclerLabs:masterfrom
zsolt-petrik-byborg:bugfix/discriminator-mapping
Jun 17, 2026
Merged

fix: respect discriminator mapping in response body mappers#143
zedorg merged 2 commits into
DoclerLabs:masterfrom
zsolt-petrik-byborg:bugfix/discriminator-mapping

Conversation

@zsolt-petrik-byborg

@zsolt-petrik-byborg zsolt-petrik-byborg commented Jun 17, 2026

Copy link
Copy Markdown
Contributor

The generated toSchema() derived the setter and mapper-property names purely from the runtime discriminator value (set.ucfirst(value) and value.'Mapper'), which only worked when the value happened to match its schema name. When a discriminator mapping maps a value to a differently named schema (e.g. animal -> AnimalResponse), the generated setter and mapper property did not exist.

Generate an explicit switch from the discriminator mapping, resolving each mapping value to its oneOf/anyOf child field and emitting that child's real setter and mapper property. The default arm keeps the previous value-based dispatch as the implicit-naming fallback for discriminators without a mapping.

The generated toSchema() derived the setter and mapper-property names
purely from the runtime discriminator value (set.ucfirst(value) and
value.'Mapper'), which only worked when the value happened to match its
schema name. When a discriminator mapping maps a value to a differently
named schema (e.g. interaction -> InteractionRecommendation), the
generated setter and mapper property did not exist.

Generate an explicit switch from the discriminator mapping, resolving
each mapping value to its oneOf/anyOf child field and emitting that
child's real setter and mapper property. The default arm keeps the
previous value-based dispatch as the implicit-naming fallback for
discriminators without a mapping.
@zedorg zedorg requested review from vsouz4 and zedorg June 17, 2026 13:27
@zedorg zedorg merged commit 008c58c into DoclerLabs:master Jun 17, 2026
1 check passed
@zsolt-petrik-byborg zsolt-petrik-byborg deleted the bugfix/discriminator-mapping branch June 17, 2026 13:42
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.

3 participants