Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(aip-136): response message name #1387

Merged
10 changes: 2 additions & 8 deletions rules/aip0136/response_message_name.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,17 +48,11 @@ var responseMessageName = &lint.MethodRule{

response := utils.GetResponseType(m)
requestResourceType := utils.GetResourceReference(m.GetInputType().FindFieldByName("name")).GetType()

// If we can't determine if this is a resource-based custom method return the
// findings from the above matching response name lint
if !utils.IsResource(response) || requestResourceType == "" {
return suffixFindings
}
responseResourceType := utils.GetResource(response).GetType()

// However, if we can determine that this is a resource-based custom method,
// the ensure that they equal
responseResourceType := utils.GetResource(response).GetType()
if responseResourceType == requestResourceType {
if utils.IsResource(response) && responseResourceType == requestResourceType {
return nil
}

Expand Down
3 changes: 2 additions & 1 deletion rules/aip0136/response_message_name_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ func TestResponseMessageName(t *testing.T) {
problems testutils.Problems
}{
{"Valid", "ArchiveBook", "ArchiveBookResponse", testutils.Problems{}},
{"Invalid", "ArchiveBook", "ArchiveBookResp", testutils.Problems{{Suggestion: "ArchiveBookResponse"}}},
{"Invalid", "ArchiveBook", "ArchiveBookResp", testutils.Problems{{
Message: "Custom methods should return a message matching the RPC name, with a `Response` suffix, or the resource being operated on, not \"ArchiveBookResp\"."}}},
liveFreeOrCode marked this conversation as resolved.
Show resolved Hide resolved
}

for _, test := range tests {
Expand Down
Loading