Skip to content

Commit 4c4ffa4

Browse files
committed
Add detail for gRPC/HTTP transcoding
- Define which fields are mapped to query parameters (and how) - Specify behavior (and limitations) for fields represented in both the body and the URI
1 parent 83c133c commit 4c4ffa4

1 file changed

Lines changed: 14 additions & 1 deletion

File tree

aip/general/0127.md

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ message CreateBookRequest {
6868
- RPCs **should** use the prescribed HTTP verb for custom methods, as
6969
discussed in [AIP-136][].
7070
- RPCs **should not** use `put` or `custom`.
71-
- The corresponding value represents the URI.
71+
- The corresponding value represents the path in the URI.
7272
- URIs **must** use the `{foo=bar/*}` syntax to represent a variable that
7373
should be populated in the request proto. When extracting a [resource
7474
name][aip-122], the variable **must** include the entire resource name, not
@@ -92,6 +92,17 @@ message CreateBookRequest {
9292
- The `body` **must not** be a `repeated` field.
9393
- Fields **should not** use the `json_name` annotation to alter the field
9494
name in JSON, unless doing so for backwards-compatibility reasons.
95+
- In any given HTTP request, if a field is represented in both the body
96+
and the URI, the values **must** be identical. The server behavior when
97+
this constraint is violated is unspecified.
98+
- Eligible fields which are not represented in the URI path or the body are mapped
99+
to URI query parameters.
100+
- Only singular primitive, repeated primitive, and singular message type fields
101+
are eligible to be represented as query parameters.
102+
- Repeated primitive fields are represented as repeated query parameters,
103+
e.g. `...?param=A&param=B`.
104+
- For message type fields, each eligible leaf field is represented as a
105+
separate query parameter, e.g. `...?foo.a=A&foo.b=B&foo.c=C`.
95106

96107
**Note:** Bi-directional streaming RPCs should not include a `google.api.http`
97108
annotation at all. If feasible, the service **should** provide non-streaming
@@ -127,6 +138,8 @@ rpc CreateBook(CreateBookRequest) returns (Book) {
127138

128139
## Changelog
129140

141+
- **2022-07-21**: Added clarification around field duplication between the
142+
body and URI, and added query parameter mapping.
130143
- **2021-01-06**: Added clarification around `body` and nested fields.
131144
- **2019-09-23**: Added a statement about request body encoding, and guidance
132145
discouraging `json_name`.

0 commit comments

Comments
 (0)