Skip to content

Commit

Permalink
Fix snake_case for plural resource name (#569)
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelbausor authored Jun 19, 2020
1 parent cf5dd14 commit 3cf71fe
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
4 changes: 2 additions & 2 deletions rules/aip0136/http_parent_variable.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ var httpParentVariable = &lint.MethodRule{
if _, ok := vars["parent"]; ok {
// Determine the resource.
segs := strings.Split(strings.Split(http.GetPlainURI(), ":")[0], "/")
plural := segs[len(segs)-1]
singular := strcase.SnakeCase(p.Singular(plural))
plural := strcase.SnakeCase(segs[len(segs)-1])
singular := p.Singular(plural)

// Does the RPC name end in the singular or plural name of the resource?
// If not, complain.
Expand Down
1 change: 1 addition & 0 deletions rules/aip0136/http_parent_variable_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ func TestHTTPParentVariable(t *testing.T) {
{"ValidBookVar", "WritePage", "/v1/{book=publishers/*/books/*}:writePage", testutils.Problems{}},
{"ValidBatchGet", "BatchGetBooks", "/v1/{parent=publishers/*}/books:batchGet", testutils.Problems{}},
{"ValidBatchCreate", "BatchCreateBooks", "/v1/{parent=publishers/*}/books:batchCreate", testutils.Problems{}},
{"ValidTwoWordNounBatch", "BatchUpdateAudioBooks", "/v1/{parent=publishers/*}/audioBooks:batchUpdate", testutils.Problems{}},
} {
t.Run(test.name, func(t *testing.T) {
f := testutils.ParseProto3Tmpl(t, `
Expand Down

0 comments on commit 3cf71fe

Please sign in to comment.