connectrpc / vanguard-go

Support REST, gRPC, gRPC-Web, and Connect clients with one server.
https://pkg.go.dev/connectrpc.com/vanguard
Apache License 2.0
197 stars 13 forks source link

Query parameters are deserialized from `snake_case`, but convention seems to be `camelCase` #131

Closed ucarion closed 3 weeks ago

ucarion commented 1 month ago

When an RPC expects a query parameter, that query parameter is expected to be provided over HTTP in its proto name:

// assume this is the input to an http GET-bound RPC
message ExampleRequest {
  string thing_id = 1; // expected to be ?thing_id=...
}

This doesn't contradict google.api.http, which is silent on the question. All examples given in http.proto are single-word. But it does disagree with the implementation produced by https://github.com/google/gnostic, whose default behavior is to "JSON-ify" all names in all locations, be they in a body or a query parameter. I have not gotten a chance to test other gRPC->HTTP code generators.

Reading the inscrutable Google tea-leaves, this seems to suggest the intended convention is that query parameters are meant to be taken as camel-case.

c.f. https://bufbuild.slack.com/archives/CRZ680FUH/p1723577480591239

emcfarlane commented 3 weeks ago

@ucarion fix has gone in! I'll create a release on Monday when we can merge the other CI changes. Thanks for reporting the issue!

oxisto commented 3 weeks ago

@ucarion fix has gone in! I'll create a release on Monday when we can merge the other CI changes. Thanks for reporting the issue!

Cool! This was also blocking me a little bit in fully embracing vanguard in one of my projects.