Add fixture coverage for Kotlin kotlinx-serialization#2950
Merged
Conversation
The kotlinx framework of the Kotlin renderer had no end-to-end fixture coverage at all — only klaxon (kotlin/schema-kotlin) and jackson (kotlin-jackson/schema-kotlin-jackson) were tested. This adds kotlinx and schema-kotlinx fixtures: - test/fixtures/kotlinx/: driver that round-trips JSON through the generated @serializable types with kotlinx-serialization-json (runtime jars vendored like the klaxon/jackson jars; the compiler plugin ships with the Kotlin distribution). - KotlinXLanguage entry in test/languages.ts with skips for what the kotlinx renderer genuinely cannot do yet, all verified by compiling and round-tripping every input locally: - unions render as sealed classes with no serializer wiring (documented TODO in KotlinXRenderer.ts), so union inputs are skipped and the "union" feature is not claimed; - top-level arrays render as `typealias TopLevel = JsonArray<T>`, which does not compile; - astral-plane characters in property names are emitted as 5-hex-digit \u escapes in @SerialName, which Kotlin misparses. - CI matrix entry kotlinx,schema-kotlinx on the 16-core runner. Compared to the klaxon fixtures this also enables inputs klaxon cannot handle: simple-identifiers.json, no-classes.json, bug427.json, and the any, uuid, keyword-enum, top-level-enum, top-level-primitive, nested-intersection-union, and go-schema-pattern-properties schemas. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
schani
added a commit
to nikhilunni/quicktype
that referenced
this pull request
Jul 19, 2026
…erence Merging master brought in the kotlinx fixture coverage from glideapps#2950, whose skip lists were tuned against master, where Kotlin had no date-time support. With this branch's date/time mapping: - Declare the "date-time" feature for KotlinXLanguage. date-time.schema itself stays skipped because its union-array properties hit the kotlinx sealed-class union limitation; the emitted KSerializers are exercised by JSON inputs with inferred date-times instead. - Skip the misc JSON inputs whose date-times carry trailing zeros in the fractional seconds, which java.time doesn't re-serialize identically — the same set already skipped for klaxon and jackson. - Skip date-time-or-string.schema: its string|date-time property was a plain string before and now becomes a union. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
The Kotlin renderer's kotlinx-serialization framework (
--framework kotlinx) had zero end-to-end fixture coverage — only klaxon (kotlin/schema-kotlin) and jackson (kotlin-jackson/schema-kotlin-jackson) were tested. Any change toKotlinXRenderer.tsshipped unvalidated. In particular, this unblocks #2845: once that PR rebases onto this, its kotlinx serializer changes get validated by CI.What
test/fixtures/kotlinx/— driver mirroring the klaxon/jackson fixtures:main.ktround-trips JSON through the generated@Serializabletypes usingkotlinx-serialization-json(withexplicitNulls = falseso nulls are omitted on encode, matching the other Kotlin fixtures'allowMissingNullbehavior). The runtime jars (1.7.3) are vendored like the klaxon/jackson jars; the compiler plugin ships inside the Kotlin distribution (lib/kotlinx-serialization-compiler-plugin.jar), whichbuild.shlocates relative tokotlinc.KotlinXLanguageintest/languages.ts, fixtureskotlinx/schema-kotlinxintest/fixtures.ts.kotlinx,schema-kotlinxmatrix entry on the 16-core runner (the existingcontains(matrix.fixture, 'kotlin')conditions install Java + Kotlin for it).Covered vs skipped
Every JSON input (priority, samples, misc) and every schema was compiled and round-tripped locally with kotlinc 2.1.20 to build the skip lists; each skip is a verified, pre-existing kotlinx renderer limitation, not a guess:
KotlinXRenderer.ts; deserialization fails at runtime. Theunionfeature is not claimed, so.fail.union.jsonsamples don't run. feat(kotlin): Support for date and datetime from JSON schema #2845 fixes this; these skips can then be lifted.union.schema): rendered astypealias TopLevel = JsonArray<T>, which doesn't compile (kotlinx'sJsonArraytakes no type arguments) — also a documented TODO.blns-object.json,identifiers.json:stringEscapeemits astral-plane characters as 5-hex-digit\uescapes in@SerialName, which Kotlin misparses (4 digits only), so keys don't match.keyword-unions.schema: unions, plus the synthesized serializer constructor exceeds the JVM 255-parameter limit.Everything else runs — 149 of 211 JSON inputs and 46 of 67 schemas, including inputs the klaxon fixtures skip:
simple-identifiers.json,no-classes.json,bug427.json, and theany,uuid,keyword-enum,top-level-enum,top-level-primitive,nested-intersection-union, andgo-schema-pattern-propertiesschemas.Local verification
FIXTURE=schema-kotlinx script/test: green (all 67 schemas, exit 0), with kotlinc 2.1.20 + Java 21.FIXTURE=kotlinx script/test(full, including misc): every input was verified individually via generate→compile→run→compare with the harness's comparison semantics; the full harness run was still in progress when this PR was opened, so CI is the final gate there. The two miscskipDiffViaSchemaentries (34702.json,76ae1.json) mirror the klaxon list; diff-via-schema for priority/samples was verified to match klaxon's behavior exactly (onlybug427.json/keywords.jsondiffer). Misc inputs don't run in CI (QUICKTEST=true).🤖 Generated with Claude Code