Skip to content

Commit d579dd7

Browse files
authored
fix(sidekick): missing IDs in discovery doc fields (#2386)
1 parent 2e230f3 commit d579dd7

File tree

6 files changed

+21
-0
lines changed

6 files changed

+21
-0
lines changed

internal/sidekick/internal/parser/disco_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,7 @@ func TestDisco_ParsePagination(t *testing.T) {
101101
wantPagination := &api.Field{
102102
Name: "pageToken",
103103
JSONName: "pageToken",
104+
ID: "..zones.listRequest.pageToken",
104105
Typez: api.STRING_TYPE,
105106
TypezID: "string",
106107
Optional: true,

internal/sidekick/internal/parser/discovery/discovery_test.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,13 +142,15 @@ func TestMessage(t *testing.T) {
142142
{
143143
Name: "backendService",
144144
JSONName: "backendService",
145+
ID: "..WeightedBackendService.backendService",
145146
Documentation: "The full or partial URL to the default BackendService resource. Before forwarding the request to backendService, the load balancer applies any relevant headerActions specified as part of this backendServiceWeight.",
146147
Typez: api.STRING_TYPE,
147148
TypezID: "string",
148149
},
149150
{
150151
Name: "headerAction",
151152
JSONName: "headerAction",
153+
ID: "..WeightedBackendService.headerAction",
152154
Documentation: "Specifies changes to request and response headers that need to take effect for the selected backendService. headerAction specified here take effect before headerAction in the enclosing HttpRouteRule, PathMatcher and UrlMap. headerAction is not supported for load balancers that have their loadBalancingScheme set to EXTERNAL. Not supported when the URL map is bound to a target gRPC proxy that has validateForProxyless field set to true.",
153155
Typez: api.MESSAGE_TYPE,
154156
TypezID: "..HttpHeaderAction",
@@ -157,6 +159,7 @@ func TestMessage(t *testing.T) {
157159
{
158160
Name: "weight",
159161
JSONName: "weight",
162+
ID: "..WeightedBackendService.weight",
160163
Documentation: "Specifies the fraction of traffic sent to a backend service, computed as weight / (sum of all weightedBackendService weights in routeAction) . The selection of a backend service is determined only for new traffic. Once a user's request has been directed to a backend service, subsequent requests are sent to the same backend service as determined by the backend service's session affinity policy. Don't configure session affinity if you're using weighted traffic splitting. If you do, the weighted traffic splitting configuration takes precedence. The value must be from 0 to 1000.",
161164
Typez: api.UINT32_TYPE,
162165
TypezID: "uint32",

internal/sidekick/internal/parser/discovery/enum_field_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,7 @@ func TestMakeEnumFields(t *testing.T) {
106106
{
107107
Name: "networkTier",
108108
JSONName: "networkTier",
109+
ID: ".package.Message.networkTier",
109110
Documentation: "The networking tier.",
110111
Typez: api.ENUM_TYPE,
111112
TypezID: ".package.Message.networkTier",

internal/sidekick/internal/parser/discovery/message_fields.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ func makeScalarField(model *api.API, message *api.Message, name string, schema *
7474
return &api.Field{
7575
Name: name,
7676
JSONName: name, // OpenAPI field names are always camelCase
77+
ID: fmt.Sprintf("%s.%s", message.ID, name),
7778
Documentation: schema.Description,
7879
Typez: typez,
7980
TypezID: typezID,

internal/sidekick/internal/parser/discovery/message_fields_test.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,20 +78,23 @@ func TestMakeMessageFields(t *testing.T) {
7878
{
7979
Name: "intField",
8080
JSONName: "intField",
81+
ID: ".package.Message.intField",
8182
Documentation: "The field description.",
8283
Typez: api.INT32_TYPE,
8384
TypezID: "int32",
8485
},
8586
{
8687
Name: "longField",
8788
JSONName: "longField",
89+
ID: ".package.Message.longField",
8890
Documentation: "The field description.",
8991
Typez: api.UINT64_TYPE,
9092
TypezID: "uint64",
9193
},
9294
{
9395
Name: "arrayFieldString",
9496
JSONName: "arrayFieldString",
97+
ID: ".package.Message.arrayFieldString",
9598
Documentation: "The field description.",
9699
Typez: api.STRING_TYPE,
97100
TypezID: "string",
@@ -100,6 +103,7 @@ func TestMakeMessageFields(t *testing.T) {
100103
{
101104
Name: "arrayFieldObject",
102105
JSONName: "arrayFieldObject",
106+
ID: ".package.Message.arrayFieldObject",
103107
Documentation: "The field description.",
104108
Typez: api.MESSAGE_TYPE,
105109
TypezID: ".package.AnotherMessage",

internal/sidekick/internal/parser/discovery/methods_test.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,13 +74,15 @@ func TestMethodEmptyBody(t *testing.T) {
7474
{
7575
Name: "project",
7676
JSONName: "project",
77+
ID: "..zones.getRequest.project",
7778
Documentation: "Project ID for this request.",
7879
Typez: api.STRING_TYPE,
7980
TypezID: "string",
8081
},
8182
{
8283
Name: "zone",
8384
JSONName: "zone",
85+
ID: "..zones.getRequest.zone",
8486
Documentation: "Name of the zone resource to return.",
8587
Typez: api.STRING_TYPE,
8688
TypezID: "string",
@@ -117,6 +119,7 @@ func TestMethodWithQueryParameters(t *testing.T) {
117119
{
118120
Name: "filter",
119121
JSONName: "filter",
122+
ID: "..zones.listRequest.filter",
120123
Documentation: "A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. These two types of filter expressions cannot be mixed in one request. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = \"Intel Skylake\") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = \"Intel Skylake\") OR (cpuPlatform = \"Intel Broadwell\") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq \"double quoted literal\"` `(fieldname1 eq literal) (fieldname2 ne \"literal\")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name \"instance\", you would use `name ne .*instance`. You cannot combine constraints on multiple fields using regular expressions.",
121124
Typez: api.STRING_TYPE,
122125
TypezID: "string",
@@ -125,6 +128,7 @@ func TestMethodWithQueryParameters(t *testing.T) {
125128
{
126129
Name: "maxResults",
127130
JSONName: "maxResults",
131+
ID: "..zones.listRequest.maxResults",
128132
Documentation: "The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`)",
129133
Typez: api.UINT32_TYPE,
130134
TypezID: "uint32",
@@ -133,6 +137,7 @@ func TestMethodWithQueryParameters(t *testing.T) {
133137
{
134138
Name: "orderBy",
135139
JSONName: "orderBy",
140+
ID: "..zones.listRequest.orderBy",
136141
Documentation: "Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy=\"creationTimestamp desc\"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported.",
137142
Typez: api.STRING_TYPE,
138143
TypezID: "string",
@@ -141,6 +146,7 @@ func TestMethodWithQueryParameters(t *testing.T) {
141146
{
142147
Name: "pageToken",
143148
JSONName: "pageToken",
149+
ID: "..zones.listRequest.pageToken",
144150
Documentation: "Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results.",
145151
Typez: api.STRING_TYPE,
146152
TypezID: "string",
@@ -149,13 +155,15 @@ func TestMethodWithQueryParameters(t *testing.T) {
149155
{
150156
Name: "project",
151157
JSONName: "project",
158+
ID: "..zones.listRequest.project",
152159
Documentation: "Project ID for this request.",
153160
Typez: api.STRING_TYPE,
154161
TypezID: "string",
155162
},
156163
{
157164
Name: "returnPartialSuccess",
158165
JSONName: "returnPartialSuccess",
166+
ID: "..zones.listRequest.returnPartialSuccess",
159167
Documentation: "Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. For example, when partial success behavior is enabled, aggregatedList for a single zone scope either returns all resources in the zone or no resources, with an error code.",
160168
Typez: api.BOOL_TYPE,
161169
TypezID: "bool",
@@ -193,20 +201,23 @@ func TestMethodWithBody(t *testing.T) {
193201
{
194202
Name: "project",
195203
JSONName: "project",
204+
ID: "..addresses.insertRequest.project",
196205
Documentation: "Project ID for this request.",
197206
Typez: api.STRING_TYPE,
198207
TypezID: "string",
199208
},
200209
{
201210
Name: "region",
202211
JSONName: "region",
212+
ID: "..addresses.insertRequest.region",
203213
Documentation: "Name of the region for this request.",
204214
Typez: api.STRING_TYPE,
205215
TypezID: "string",
206216
},
207217
{
208218
Name: "requestId",
209219
JSONName: "requestId",
220+
ID: "..addresses.insertRequest.requestId",
210221
Documentation: "An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000).",
211222
Typez: api.STRING_TYPE,
212223
TypezID: "string",

0 commit comments

Comments
 (0)