types: add Api, Type, and SourceContext well-known types - #394
Conversation
Fixes anthropics#382. Codegen auto-maps `.google.protobuf` onto buffa-types, so compiling googleapis (or any schema that imports api.proto / type.proto / source_context.proto) failed to resolve Api / TypeView / EnumView. Those three files are the rest of the official well-known set; they are now vendored and generated next to Timestamp/Any, with binary and view round-trips. They use the standard proto3 JSON object mapping, so they register for textproto Any-expansion only. Same-module AIP-192 rustdoc links (`[Mixin][]`) now emit `[Mixin]` rather than a redundant explicit target, which `rustdoc::redundant_explicit_links` rejects under `-D warnings`.
|
All contributors have signed the CLA ✍️ ✅ |
|
I have read the CLA Document and I hereby sign the CLA |
…links; docs and tests - .github/workflows/ci.yml: the check-generated-code job's proto list gains api/source_context/type.proto, matching the Taskfile - comments.rs: a keyword-named type keeps the escaped explicit link target (a bare [type] label would not resolve), with a test - docs: state that Api/Type/Enum/SourceContext and their parts have no serde impls and what a json=true consumer sees; list the new types; drop the stale "JSON-mappable WKTs" descriptions of buffa-types - tests: TypeView and Enum round-trips, Type/Option text-registry round-trips (Option nests an Any), Catalog.enum_type populated - changelog: (anthropics#394); the rustdoc-link change moved to its own Changed fragment
|
[claude code] Reviewed. The vendored protos are byte-identical to protobuf v33.5, the codegen config matches the existing WKTs, and the |
Fixes #382.
What this does
buffa-typesonly shipped the JSON-mappable well-known types. Codegen still auto-maps the entire.google.protobufpackage there, so compiling googleapis (or any schema that importsapi.proto/type.proto/source_context.proto) failed withcannot find type Api/TypeView/EnumView.This vendors those three remaining official well-known files (protobuf v33.5, matching the existing
any.protopin and the tools image) and generates them next to Timestamp/Any:buffa-typesregister_wkt_typestextproto Any-expansion for the new messageswkt_api.protofixture sobuffa-testcompiles aCatalogwithApi/Type/Enum/SourceContextfields::buffa_types::google::protobuf::{Api,Type,Enum,SourceContext}and the matching viewsJSON serde is intentionally not generated. These types use the standard proto3 object mapping (no special encoding), and turning
generate_jsonon for all WKTs would also derive serde for Timestamp/Any and duplicate the hand-written impls.wkt_usage.protois left unchanged so thejson=truecompile fixture stays green.Shipping
api.protoalso made[Mixin][]resolve in-crate. The generated[Mixin](crate::google::protobuf::Mixin)is arustdoc::redundant_explicit_linksfailure under this repo's-D warnings. Same-module AIP-192 refs now emit[Mixin]; FQ display names (google.protobuf.Type) and cross-module destinations still get an explicitcrate::path.Testing
All passed. Targeted extras:
cargo test -p buffa-types --all-features(includingtext_registry_roundtrip_source_context),codegen_wkt_api_auto_mapping, andbuffa-testtest_wkt_api_types_round_trip.Conformance (
task conformance) was not run locally; this change does not touch the codec wire path the suite exercises.