Repository navigation
Conversation
There was a problem hiding this comment.
Claude Code Review
This repository is configured for manual code reviews. Comment @claude review for a one-time review, or @claude review always to subscribe this PR to a review on every future push.
Tip: disable this comment in your organization's Code Review settings.
This branch has not been deployed
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.
Steps 2 to 5 of the schema holds data, reflectapi holds meaning.
reflectapi-schemakeeps only the data that describes an API; what that data means moves back intoreflectapi, split by who needs it. Step 1, diff asreflectapi::diff, follows once #256 is rebased onto this.Changes
wireback inreflectapi, split in two#263 moved
wireintoreflectapi-schemaso diff could reach it. This moves it back, and splits it along the line its users already follow:reflectapi::wire:shape,key,layout,headers#[serde(flatten)]adds, the headers a headers type readsbuilderorcodegen(anddiff)reflectapi::contract:presence,nullability,formatnullis allowed, what a primitive's string iscodegen(anddiff)contractbuilds onwire, and nothing inwireusescontract.wire. The server reads a route's headers withwire::headers, so it reads exactly the headers clients send.contractisn't compiled withoutcodegen.wirestays#[doc(hidden)] pub. Withbuilderalone, the parts oflayoutonly codegen uses would otherwise warn as unused.contractispub(crate).Breaking:
Primitive::formatremovedA primitive's format always followed from its name, since
uuid::Uuidis a UUID. The generators already fell back to a table keyed by name, which is now the only source.Primitive::format,Primitive::with_format, and the formats theuuid,chrono,urlandrust_decimalimpls set.formatkeys are ignored, and a 0.26 reader derives formats from names, as it did for a schema without them.SCHEMA_FORMAT_VERSION's doc records the exception. A test reads a 0.26 primitive with"format": "uuid"."format"keys.contract::formatanswers per serialization formatwire_form(name, SerializationMode)returnsString { format }orBytes { length }. Auuid::Uuidis auuidstring in JSON and 16 bytes in MessagePack, because itsSerializechecksis_human_readable().string_formatis the JSON shortcut that OpenAPI and TypeScript use.No tool asks for the MessagePack form yet. Compatibility is still judged on types, whatever the format.
On the Wire gains a note for servers that accept MessagePack:
uuid'sDeserializetakes only bytes there, so read such a field with adeserialize_withthat takes a string or 16 bytes. The example is a book doctest that checks both forms with rmp-serde.Const arguments documented
TypeReference::argumentsnow says a const generic's value is written as the reference's name:[u8; 3]isstd::array::Array<u8, "3">. A reader that doesn't know the type follows its fallback.Book
mermaidblock can tag nodesaccent,crateorplanned. The book's CSS draws them in its palette, the reflectapi orange for the subject and frames, in light and dark themes. Elsewhere the tags are ignored.Not in this PR
reflectapi::diff(step 1). A stacked branch,andrey/schema-holds-data-diff, has reflectapi diff: report schema changes that break clients #256's commit rebased onto this one, with Angel as author, plus a commit that moves it behind adifffeature and reads formats fromcontract. It'll be offered as reflectapi diff: report schema changes that break clients #256's new base once this merges.Bounded, which comes back in its own PR, as the proposal describes.Checks
cargo fmt, andcargo clippy --workspace --all-targets --all-features -D warnings.CI=1 cargo test --workspace --all-features: 526 passed, generated TypeScript and Rust type-checked.reflectapiwithout default features and withbuilder,codegen,json,builder,jsonandbuilderplus the type features: no warnings.