Repository navigation
Bind a peek against a stated type, and check a body's own schema - #27
Merged
Merged
Conversation
tson-java's object reader now continues a peek against a stated type -- readAs(TsonDocumentPeek, String, Class) -- which closes UPSTREAM.md #1. TsonHttpCodec gains readObjectAs(peek, ...), and TsonSchemaVersions.Routed reads a TSON body through it, so one naming its version only in the TSON-Schema header is read against that version's schema rather than schemaless. The same change answers #3 by decision: readAs lets a stated schema override the document's own !!schema and leaves the comparison to the caller. So the codec makes it. readObjectAs and readTreeAs peek a TSON body and answer a !!schema disagreeing with the stated one by canonical identity 400 conflicting-schema, where it was read against the stated schema in silence. Both items come out of UPSTREAM.md; the override stays pinned in UpstreamGapsTest so the codec's copy of the rule is noticed if upstream starts refusing, and the new reader entry point is pinned beside it. Co-Authored-By: Claude Opus 5.5 (1M context) <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.
tson-java implemented
UPSTREAM.md#1:TsonObjectReader.readAs(TsonDocumentPeek, String, Class)(litterat/ltr8-io-tson-java#592). This PR adopts it, and closes #3, which the same change answered.Adopting #1
TsonHttpCodec.readObjectAs(TsonDocumentPeek, …): binds against a stated type after the header has been read, with the body read once.TsonSchemaVersions.Routed.readObjectAsreads a TSON body through it. So a TSON body naming its version only in theTSON-Schemaheader is now read against that version's schema. It used to be read with no schema at all, because bind mode couldn't continue the peek.Closing #3 by decision, and the behaviour change
Upstream keeps
readAs's override of a document's own!!schemadeliberately. Its Javadoc leaves the comparison to the caller, and that comparison was only blocked by #1. So the codec makes it now:readObjectAs/readTreeAsread the start of a TSON body and compare its!!schemawith the stated one by canonical identity, so scheme and pin don't count.conflicting-schema(the same typeTsonSchemaHeaderuses). Before, it was silently read against the stated schema.Tests
TsonHttpCodecTest:!!schemais a 400 in bind and tree mode;TsonSchemaVersionsTest: a header-only TSON body is judged by its version's schema.UpstreamGapsTest:Docs
UPSTREAM.mddrops Route a gap by its code, and adopt the schema source upstream lifted #1 and Move to spec Revision 34, and take the two codes it added #3, leaving one item (JSON in-band binding, renumbered to Route a gap by its code, and adopt the schema source upstream lifted #1).readAsdirectly on a client's body../gradlew build javadocand./gradlew build -Ptson.published=true(after a freshpublishToMavenLocal) pass.🤖 Generated with Claude Code