Skip to content

fix(prompt): respect JsonClassDiscriminator in JSON schemas - #2237

Open
Shanto Islam (shanthropic) wants to merge 1 commit into
JetBrains:developfrom
shanthropic:fix/2105-json-class-discriminator
Open

Shanto Islam (shanthropic) wants to merge 1 commit into
JetBrains:developfrom
shanthropic:fix/2105-json-class-discriminator

Conversation

@shanthropic

Copy link
Copy Markdown

StandardJsonSchemaGenerator always used the discriminator from the Json configuration, even when the polymorphic base type had a @JsonClassDiscriminator annotation. This could produce a schema that did not match the JSON generated by Kotlin serialization.

Use the discriminator declared on the polymorphic descriptor when present, while retaining the configured discriminator as the fallback.

Add regression tests covering annotated sealed and open hierarchies, unannotated types, ALL_JSON_OBJECTS, and disabled class discriminators.

Tested with:

  • :prompt:prompt-structure:jvmTest
  • :prompt:prompt-structure:jsTest
  • :prompt:prompt-structure:build
  • :prompt:prompt-structure:ktlintCheck

closes #2105

Resolve the discriminator from the polymorphic base descriptor before falling back to the Json configuration. Add regression coverage for sealed and open hierarchies, configured fallback, and discriminator modes.

Refs JetBrains#2105

This branch has not been deployed

No deployments
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.

StandardJsonSchemaGenerator generates incorrect schema for classes annotated with JsonClassDiscriminator

1 participant