Skip to content

Commit

Permalink
fix: Permit two-word top-level collections in the URI suffix. (#642)
Browse files Browse the repository at this point in the history
Another tweak to the perpetually-difficult `http-uri-suffix` rule
from AIP-136.

Fixes #622.
  • Loading branch information
Luke Sneeringer authored Oct 5, 2020
1 parent c50d6c1 commit b9364d8
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 1 deletion.
2 changes: 1 addition & 1 deletion rules/aip0136/http_uri_suffix.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ var uriSuffix = &lint.MethodRule{
plainURI := httpRule.GetPlainURI()
segs := strings.Split(strings.Split(plainURI, ":")[0], "/")
segment := segs[len(segs)-1]
if len(want) == 0 && strings.HasSuffix(strings.ToLower(n), segment) {
if len(want) == 0 && strings.HasSuffix(strings.ToLower(n), strings.ToLower(segment)) {
want = segment + ":" + strings.Split(strcase.SnakeCase(n), "_")[0]
}

Expand Down
1 change: 1 addition & 0 deletions rules/aip0136/http_uri_suffix_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ func TestURISuffix(t *testing.T) {
URI string
problems testutils.Problems
}{
{"ValidTwoWordNoParent", "SearchAudioBooks", "/v1/audioBooks:search", nil},
{"ValidVerb", "ArchiveBook", "/v1/{name=publishers/*/books}:archive", testutils.Problems{}},
{"ValidVerbNested", "ArchiveBook", "/v1/{book.name=publishers/*/books}:archive", testutils.Problems{}},
{"ValidVerbParent", "ImportBooks", "/v1/{parent=publishers/*}/books:import", testutils.Problems{}},
Expand Down

0 comments on commit b9364d8

Please sign in to comment.