docs: connectrpc-build honours extern_paths, three doc passages say it is ignored

Aperta
#335 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
3/5
Tempo stimato
1-2 giorni
Idoneità per principianti
55/100
Tipo di issue
Documentazione
Chiarezza
Abbastanza chiara
Stato di attività
Attiva
Stack tecnologico
rust

Direzione di ricerca

Start with the three doc passages named in the issue: Options::buffa and generate_files in connectrpc-codegen/src/codegen.rs, Config::encodable_impls in connectrpc-build/src/lib.rs, and the connectrpc-types crate docs. Read Options::to_buffa_config to confirm that extern_paths reaches both buffa_codegen::generate and the TypeResolver. Done means the three passages match that behaviour and a test covers the mapping on the unified path, using the build.rs and proto in the issue as a reproduction.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

Three places say that the unified generation path ignores extern_paths:

  • Options::buffa and the generate_files doc in connectrpc-codegen/src/codegen.rs ("[CodeGenConfig::extern_paths] is ignored")
  • Config::encodable_impls in connectrpc-build/src/lib.rs ("which ignores extern_paths")
  • the connectrpc-types crate docs in #332, which repeat it: "connectrpc-build does not support this mapping"

The code does the opposite. Options::to_buffa_config clones the config and only forces generate_views, so extern_paths reaches both buffa_codegen::generate and the stubs' TypeResolver.

This build.rs compiles against #332's branch, and the generated field is Vec<::connectrpc_types::google::rpc::Status>:

fn main() {
    let mut buffa = connectrpc_build::CodeGenConfig::default();
    buffa.extern_paths.push((".google.rpc".into(), "::connectrpc_types::google::rpc".into()));
    connectrpc_build::Config::new()
        .buffa_config(buffa)
        .generate_json(true)
        .files(&["proto/batch.proto"])
        .includes(&["proto/"])
        .include_file("_connectrpc.rs")
        .compile()
        .unwrap();
}
syntax = "proto3";
package batch.v1;
import "google/rpc/status.proto";
service Batch { rpc Run(Req) returns (Resp); }
message Req {}
message Resp { repeated google.rpc.Status statuses = 1; }

To do

  • Correct the three doc passages, and say what does hold: a mapped type that is also in the files to generate is still declared by buffa (the mapping changes references only).
  • Add a test for the mapping in the unified path, so that the docs stay true.
  • Consider a Config::extern_path(proto, rust) builder, which avoids the buffa_config reset of generate_json.
  • Show the connectrpc-build route in the connectrpc-types crate docs.
Lingua principale
Rust
Stelle
542
Fork
74
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di connectrpc/connect-rust

Tutte le issue di connectrpc/connect-rust

Issue simili

Altre issue su Rust

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.