Repository navigation
feat(apitest): RoundTrip checks nothing is dropped, Null checks a union's null - #8
Merged
Merged
Conversation
…on's null RoundTrip now also decodes what it encoded with a member no type declares: a strict decoder must refuse it, or keep it as additional properties, never drop it silently. Null checks that the zero of a union, holding no alternative, encodes as null and that null decodes as it, as an API sends a member it leaves unset. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_019QCb1AfnATvpBQCH3PrX7Y
This was referenced Nov 15, 2026
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.
Two checks for the round-trip tests openapi-codegen generates, part of fixing go-api-libs/notion#21:
RoundTrip: when the value encodes as an object, it now also decodes that object with an extra member no type declares. A strict decoder must refuse it, or keep it as additional properties do. Silently dropping it fails the test. This is what debug mode relies on to notice what the spec doesn't know. It also runs each union alternative's error path in the generated decoders, which no test reached before.Null[T]: checks that a union holding no alternative encodes asnull, and thatnulldecodes as a union holding none, as when an API sends"cover": null.Both are tested here: refused, kept, and dropped for
RoundTrip; and forNull, a union, a type that isn't null, a type that decodes null as a value, and errors when encoding or decoding fail.I checked these against openapi-codegen's golden tests, notion and pixellab, using local
replacedirectives: no generated type drops a member or mishandlesnull. With the matching codegen change (separate PR), notion goes from 77.8% to 83.6% as devtool measures it.Generated by Claude Code