Repository navigation
Conversation
… request views
A type whose request view differs gets a separate `{Name}Input` only when
its response view is also used. When request bodies reach `{Name}Input`
but nothing outside the request side reaches `{Name}`, the request view
takes over `{Name}` and every `$ref` follows (generic `Tree_i32.Input`
alike), so request-only DTOs keep their names and no orphan response view
is emitted.
Fields read by a custom serde function (`deserialize_with` / `with`) are
documented from their Rust type (or `value_type`) in request views instead
of an untyped `{}`; a `deserialize_with` alone no longer splits the views.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…-expression .Input scan Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…izing fields
serde always writes an Option field (null for None), so the response view
requires it with a nullable type; only skip_serializing_if leaves a key out.
A skip_serializing field is never written, so it is absent from the
response view instead of an optional writeOnly property. Request views keep
Option fields optional, so a type with Option fields read and returned gets
a {Name}Input.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… Option rule Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A None is sent as null (required, nullable), a skip_serializing_if None is left out (not required), a skip_serializing field is never sent. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…esponses serde never writes null for a field with skip_serializing_if = "Option::is_none" (serde_with's #[skip_serializing_none] adds exactly that), so the response view documents the Some value: optional and not nullable. Option<Option<T>> keeps the inner null (Some(None) is written as null); other predicates keep the nullable type. Request views still accept null. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
An Option skipped by Option::is_none now differs between views, so the fixture that exercises dropping an identical input uses a plain field. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…-naming # Conflicts: # examples/axum-example/tests/snapshots/integration_test__openapi.snap
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.
Summary
Two owner-decided changes to the 0.8 FastAPI-style request views (
{Name}Input):Request-only types keep their name. A type whose request view differs gets
{Name}+{Name}Inputonly when a response reaches its response view too (directly or through another type). When only request bodies reach it, the request view is emitted under{Name}, request bodies reference{Name}, and no orphan response view is left behind. Response-only types and types used on both sides behave as before. The collision naming ({Name}Input2, …) is unchanged.component_schemas::collapse_request_only_inputs) after the paths are built. The response side is every$refa path reaches outside its request parameters / bodies, plus every component the request side does not reach (an unused documented type keeps the response views it references). The{Name}views being replaced are excluded from those roots, so the transitive request-only case (CreateOrder { items: Vec<LineItem> }) collapses both types. Generic instances (Tree_i32.Input→Tree_i32) are handled the same way.Codec fields are typed in request views. A field read by a custom serde function (
deserialize_with/with) is documented from its Rust type (or#[schema(value_type)]) in the request view, instead of an untyped{}.Option<Option<T>>becomes a nullableT, and#[serde(default)]still makes the field optional. Adeserialize_withalone no longer splits the views. Fields written bywith/serialize_withstill document{}in responses.Response views follow what serde writes. An
Option<T>field isrequiredin the response view with a nullable type (serde writesnullforNone); onlyskip_serializing_ifleaves it optional. Askip_serializingfield is absent from the response view, where it used to be an optionalwriteOnlyproperty. Request views keepOption<T>optional, so a type withOptionfields that is read and returned now gets a{Name}Input(in axum-example:CreateUserWithMetaInput,GardeProfileInput,InternallyTaggedMessageInput,JsonPayloadsInput). Generated clients change frombio?: string | nulltobio: string | nullfor responses. AnOptionwithskip_serializing_if = "Option::is_none"(what serde_with's#[skip_serializing_none]adds) is never written asnull, so its response property is optional and not nullable (email?: string);Option<Option<T>>keeps the innernull, other predicates keep the nullable type, request views still acceptnull. Verified at runtime inaxum-example/tests/integration_schema.rs(response_schema_matches_the_serialized_body: real axumJsonbody vsschema!).Before / after: a request-only
PortfolioUpdateRequestBefore (0.8.0): the request body references
PortfolioUpdateRequestInput, andPortfolioUpdateRequestis an orphan:After: the request body references
PortfolioUpdateRequest, and it is the only component:Intentionally changed existing tests / snapshots
tests_accuracy::identical_or_unused_request_views_emit_nothing:Holder/Optare request-only, so they are now emitted asHolder/Opt(request views) rather thanHolder,HolderInput,Opt,OptInput. The test now also checks the request-body$refand thatOpt.xis optional.request_view::tests::direct_differences::with_both_sideschangesfalse→true:withhides the response shape while the request view is typed. New cases coverdeserialize_withalone and tupledeserialize_with(bothfalse).Snapshots where a
deserialize_with/withfield (named, tuple position, path / query parameter) was{}in the request view now show its Rust type:wire_override_field_deserialize_with_on_deserialize,wire_override_field_with_unknown,wire_override_transparent_with,struct_views_tuple_codecs,enum_views_tuple_variant_fields,enum_views_variant_codec_untagged(field positions only; variant-level codecs are unchanged),path_wire_override_fields,query_wire_override_fields,request_shapes_custom_deserializer_option.examples/axum-example:openapi.json/integration_test__openapi.snapdrop five request-only*Inputcomponents (AdvancedSearchRequest,CreateUuidItemRequest,Pagination,UpdateConfigRequest,UserListRequest). Incodecs_component_EventTimesInput,checksum(with = "hex") is now documented as its Rust type in the request view.Item 3:
struct_schema/tests.rs(Optionrequired in responses;skip_serializingdropped),schema_macro/codegen.rs(same, viaschema!),request_view/tests.rs(plainsplit intoplain/option/option_skip_if),tests_accuracy(theSamefixture gainsskip_serializing_ifso it stays identical in both views),crates/vespera/tests/schema_round5.rsandaxum-example/tests/integration_schema.rs(schema!is the response view), 17 macro snapshots + example snapshots, ande2e/devup-api/src/calls.ts(the request type is nowGardeProfileInput).Option::is_nonerule:serde_attrs/codec.rs(skips_none_on_outputcases),struct_schema/tests_option_output.rs(new),request_view/tests.rs(skip_serializing_if_optionnow differs), 2 enum snapshots,SkipResponse.email4in the exampleopenapi.json.Trade-offs worth a look
with = "ts_seconds"/with = "hex"field withoutvalue_typeis now documented in requests as the Rust type, not its real wire shape (date-timestring instead of an integer; a byte array instead of a hex string). This follows the owner's "document from the Rust type" rule;value_typeremains the fix. Awithfield on a type used on both sides now also produces a{Name}Input, because the response is{}and the request is typed.vespera!(merge = [...])merges components first-wins. If a child app usesFooonly as a request body while the parent returnsFoo, both now name their componentFoo, and one of the two views is dropped. Before, they wereFooInputandFoo.New tests:
openapi_generator/tests_request_only.rscovers a request-only type with no orphan, a response-only type, a type used on both sides, the transitiveCreateOrder/LineItemcases (request-only,LineItemalso returned, both returned), an unused type keeping a referenced response view,UserInput2collision naming on both sides vs. request-only, the request-only recursive generic instance, and theOption<Option<NaiveDate>>+deserialize_withschema.Checks run locally (Windows)
cargo test --workspace --no-fail-fast✅bun run lint(both clippy sets with-D warnings,cargo fmt --check, oxlint) ✅RUSTDOCFLAGS=-D warnings cargo doc --workspace --no-deps --all-features✅,cargo test --workspace --doc✅bun test✅,bun scripts/check-version-alignment.ts✅cargo tarpaulin -p vespera_macro --engine llvmwith CI's rustfmt layout: every changed line covered. Four untouched pre-existing loop-body lines show as uncovered only in this Windows run. CI's Linux workspace-wide gate is the authority.🤖 Generated with Claude Code