Skip to content

Commit 1c6205c

Browse files
authored
feat(AIP-123): require singular and plural (#1091)
Requiring singular and plural annotations on resources can enable new use cases in code generation and documentation, and prevents incorrect inferences about these values from the resource type. See googleapis/api-linter#722 for additional discussion around the usage of singular and plural.
1 parent ad4f78f commit 1c6205c

1 file changed

Lines changed: 20 additions & 2 deletions

File tree

aip/general/0123.md

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,8 @@ message Topic {
6363
option (google.api.resource) = {
6464
type: "pubsub.googleapis.com/Topic"
6565
pattern: "projects/{project}/topics/{topic}"
66+
singular: "topic"
67+
plural: "topics"
6668
};
6769
6870
// The resource name of the topic.
@@ -75,9 +77,13 @@ message Topic {
7577
- Patterns **must** correspond to the [resource name][aip-122].
7678
- Pattern variables (the segments within braces) **must** use `snake_case`, and
7779
**must not** use an `_id` suffix.
78-
- Pattern variables **must** be the singular form of the resource type e.g. the
79-
pattern variable representing a `Topic` resource ID is named `{topic}`.
8080
- Pattern variables **must** conform to the format `[a-z][_a-z0-9]*[a-z0-9]`.
81+
- Singular **must** be the lower camel case of the type.
82+
- Pattern variables **must** be the singular form of the resource type e.g.
83+
a pattern variable representing a `Topic` resource ID is named `{topic}`.
84+
- Plural **must** be the lower camel case plural of the singular.
85+
- Pattern collection identifier segments **must** match the plural of the
86+
resources, except in the case of [nested collections][].
8187

8288
#### Pattern uniqueness
8389

@@ -92,16 +98,28 @@ resource:
9298
- `user/{user}`
9399
- `user/{user_part_1}~{user_part_2}`
94100

101+
## Rationale
102+
103+
### Singular and Plural
104+
105+
Well-defined singular and plurals of a resource enable clients to determine the
106+
proper name to use in code and documentation.
107+
108+
lowerCamelCase can be translated into other common forms of a resource name
109+
such as UpperCamelCase and snake_case.
110+
95111
<!-- prettier-ignore-start -->
96112
[aip-122]: ./0122.md
97113
[API Group]: https://kubernetes.io/docs/concepts/overview/kubernetes-api/#api-groups
114+
[nested collections]: ./0122.md#collection-identifiers
98115
[Object]: https://github.com/kubernetes/community/blob/master/contributors/devel/sig-architecture/api-conventions.md#types-kinds
99116
[resource]: https://github.com/googleapis/googleapis/blob/master/google/api/resource.proto
100117
[service configuration]: https://github.com/googleapis/googleapis/blob/master/google/api/service.proto
101118
<!-- prettier-ignore-end -->
102119

103120
## Changelog
104121

122+
- **2023-05-06**: Adding requirement of singular and plural.
105123
- **2023-01-28**: Clarifying guidance for the resource type name.
106124
- **2022-10-28**: Added pattern variable format guidance.
107125
- **2020-05-14**: Added pattern uniqueness.

0 commit comments

Comments
 (0)