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

fix(AIP-158): reference resource plural for field name #1158

Merged
merged 3 commits into from
May 27, 2023

Conversation

noahdietz
Copy link
Collaborator

As we start to require plural in google.api.resource, we should referencing it in rules that attempt to pluralize words for things like field names or collection IDs. This is a reasonable heuristic to use for the AIP-158 response-plural-first-field when that first field is a resource.

Fixes http://b/271479822

@noahdietz noahdietz requested a review from a team as a code owner May 26, 2023 21:45
if res := utils.GetResource(firstField.GetMessageType()); res != nil && res.GetPlural() != "" {
want = strcase.SnakeCase(res.GetPlural())
} else {
want = utils.ToPlural(firstField.GetName())
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this already existed of course, but I feel like pluralizing the resource singular or the type would be more robust than the field name.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is meant to support the scenario where the paginated field isn't a resource. I agree with you, but I don't know if we should change it right now. There are maybe one or two Standard List-like fields that paginate a repeated string field that I know of. This rule being in AIP-158, not AIP-132 is poignant.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Opened #1160

rules/aip0158/response_plural_first_field.go Outdated Show resolved Hide resolved
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants