Support alloy open + discriminated unions (un-exclude conformance cases) - #35
Merged
Merged
Conversation
Implement alloy's @Discriminated and @jsonUnknown (open union) wire encodings in SerdeGenerator.writeUnion: - @Discriminated("key") unions serialize the engaged member's fields inline with the discriminator spliced into the same object ({"key": "smol", ...fields}) instead of a single-key tagged wrapper, and deserialize by switching on the discriminator value. - A @jsonUnknown member retains the entire wire object when the tag or discriminator value matches no known member, for both tagged and discriminated unions; closed unions keep the strict exactly-one-member behavior byte-for-byte. Un-exclude the three PizzaAdminService conformance cases (OpenUnionsUnknownTaggedUnionCase, OpenUnionsKnownDiscriminatedUnionCase, OpenUnionsUnknownDiscriminatedUnionCase) and regenerate the simplerestjson suite: 12 new conformance tests (client+server, request+response) plus a smoke round-trip, all green. Closes #27 Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01SyQAo21Pv6GYhHrkbQj8xQ
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.
What
Implements alloy's
@discriminatedand@jsonUnknown(open union) wire encodings in the union serde, closing #27.SerdeGenerator.writeUnionnow branches on the alloy traits:@discriminated("key")unions serialize the engaged member's fields inline with the discriminator spliced into the same object ({"key": "smol", "content": "..."}), not a single-key tagged wrapper; deserialization switches on the discriminator value and parses the same object as the member's structure.@jsonUnknownmember retains the entire wire object when the tag (tagged unions) or discriminator value (discriminated unions) matches no known member, in both directions.examples/goldens regenerate with no diff), including the strict exactly-one-member guard the malformed-request suite pins.alloy.test#PizzaAdminServicecases are removed fromprotocol-test-exclusions.txt(the list only shrank):OpenUnionsUnknownTaggedUnionCase,OpenUnionsKnownDiscriminatedUnionCase,OpenUnionsUnknownDiscriminatedUnionCase.protocol-tests/simplerestjson/generatedoutput is committed: new serde forOpenTaggedUnion/OpenDiscriminatedUnionand 12 new conformance tests (the 3 cases × client request/response + server request/response), plus a smoke round-trip.docs/generated-types.md(Serde section).Testing
bazel test //protocol-tests/simplerestjson/generated/tests:all— 5/5 targets green; all fourOpenUnions*cases now execute in each of the four suites (verified in the gtest XML).bazel test //...(excluding//benchmarks/...and the Beast targets, which cannot fetch Boost/BoringSSL behind this environment's proxy — the exclusion documented indocs/development.md) — 63/63 tests pass.(cd codegen && gradle build spotlessCheck)— green.gradle generateFixtures generateProtocolTests— regenerated output committed; onlyprotocol-tests/simplerestjsonchanged,examples/goldens byte-identical.Checklist
bazel test //...and(cd codegen && gradle build spotlessCheck)pass locally (Beast/benchmark targets excluded per docs — proxy blocks their archive fetches)🤖 Generated with Claude Code
https://claude.ai/code/session_01SyQAo21Pv6GYhHrkbQj8xQ
Generated by Claude Code