googleapis / googleapis/api-linter
Verify that a multi-parent child resource uses the correct pattern(s) in google.api.http annotation
- Dominant language
- Go
- Stars
- 765
- Forks
- 181
- Avg merge
- 2d 12h
- Merged PRs (30d)
- 3
Description
This is an extension of #972 covering the case where a child resource has multiple parents. Take for example:
```proto
rpc ListBooks(ListBooksRequest) returns (ListBooksResponse) {
option (google.api.http) = {
get: "/v1/{parent=shelves/*}/books",
additional_bindings {
get: "/v1/{parent=bins/*}/books"
},
};
}
// Request message for ListBooks.
message ListBooksRequest {
// The parent to list books from.
// Format:
// - shelves/{shelf_id}
// - bins/{bin_id}
string parent = 1 [
(google.api.field_behavior) = REQUIRED,
(google.api.resource_reference) = {
child_type: "library.googleapis.com/Book"
}];
}
message Book {
option (google.api.resource) = {
type: "library.googleapis.com/Book"
pattern: "shelves/{shelf}/books/{book}"
pattern: "bins/{bin}/books/{book}"
};
// Name of the book.
// Format is `shelves/{shelf}/books/{book}` or `bins/{bin}/books/{book}`.
string name = 1;
}
```
Here the resource `"library.googleapis.com/Book"` (i.e., `Book`) has multiple parents: messages `Shelf` and `Bin` (not depicted above). The API linter should try to ensure that the patterns in the `google.api.http` annotation match one of the patterns for the parent resources.
Contributor guide
Assessment
This issue has not been assessed yet.