Skip to content

Commit c4f2a30

Browse files
committed
fix: ignore path covered fields in query parameters
This was the intention in the first place, but was forgotten about.
1 parent b5384b4 commit c4f2a30

File tree

3 files changed

+6
-36
lines changed

3 files changed

+6
-36
lines changed

examples/proto/gen/typescript/einride/example/freight/v1/index.ts

Lines changed: 0 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -373,9 +373,6 @@ export function createFreightServiceClient(
373373
const path = `v1/${request.name}`; // eslint-disable-line quotes
374374
const body = null;
375375
const queryParams: string[] = [];
376-
if (request.name) {
377-
queryParams.push("name=" + encodeURIComponent(request.name.toString()));
378-
}
379376
let uri = path;
380377
if (queryParams.length > 0) {
381378
uri += "?" + queryParams.join("&");
@@ -447,9 +444,6 @@ export function createFreightServiceClient(
447444
const path = `v1/${request.name}`; // eslint-disable-line quotes
448445
const body = null;
449446
const queryParams: string[] = [];
450-
if (request.name) {
451-
queryParams.push("name=" + encodeURIComponent(request.name.toString()));
452-
}
453447
let uri = path;
454448
if (queryParams.length > 0) {
455449
uri += "?" + queryParams.join("&");
@@ -467,9 +461,6 @@ export function createFreightServiceClient(
467461
const path = `v1/${request.name}`; // eslint-disable-line quotes
468462
const body = null;
469463
const queryParams: string[] = [];
470-
if (request.name) {
471-
queryParams.push("name=" + encodeURIComponent(request.name.toString()));
472-
}
473464
let uri = path;
474465
if (queryParams.length > 0) {
475466
uri += "?" + queryParams.join("&");
@@ -487,9 +478,6 @@ export function createFreightServiceClient(
487478
const path = `v1/${request.parent}/sites`; // eslint-disable-line quotes
488479
const body = null;
489480
const queryParams: string[] = [];
490-
if (request.parent) {
491-
queryParams.push("parent=" + encodeURIComponent(request.parent.toString()));
492-
}
493481
if (request.pageSize) {
494482
queryParams.push("pageSize=" + encodeURIComponent(request.pageSize.toString()));
495483
}
@@ -513,9 +501,6 @@ export function createFreightServiceClient(
513501
const path = `v1/${request.parent}/sites`; // eslint-disable-line quotes
514502
const body = JSON.stringify(request?.site ?? {});
515503
const queryParams: string[] = [];
516-
if (request.parent) {
517-
queryParams.push("parent=" + encodeURIComponent(request.parent.toString()));
518-
}
519504
let uri = path;
520505
if (queryParams.length > 0) {
521506
uri += "?" + queryParams.join("&");
@@ -553,9 +538,6 @@ export function createFreightServiceClient(
553538
const path = `v1/${request.name}`; // eslint-disable-line quotes
554539
const body = null;
555540
const queryParams: string[] = [];
556-
if (request.name) {
557-
queryParams.push("name=" + encodeURIComponent(request.name.toString()));
558-
}
559541
let uri = path;
560542
if (queryParams.length > 0) {
561543
uri += "?" + queryParams.join("&");
@@ -573,9 +555,6 @@ export function createFreightServiceClient(
573555
const path = `v1/${request.name}`; // eslint-disable-line quotes
574556
const body = null;
575557
const queryParams: string[] = [];
576-
if (request.name) {
577-
queryParams.push("name=" + encodeURIComponent(request.name.toString()));
578-
}
579558
let uri = path;
580559
if (queryParams.length > 0) {
581560
uri += "?" + queryParams.join("&");
@@ -593,9 +572,6 @@ export function createFreightServiceClient(
593572
const path = `v1/${request.parent}/shipments`; // eslint-disable-line quotes
594573
const body = null;
595574
const queryParams: string[] = [];
596-
if (request.parent) {
597-
queryParams.push("parent=" + encodeURIComponent(request.parent.toString()));
598-
}
599575
if (request.pageSize) {
600576
queryParams.push("pageSize=" + encodeURIComponent(request.pageSize.toString()));
601577
}
@@ -619,9 +595,6 @@ export function createFreightServiceClient(
619595
const path = `v1/${request.parent}/shipments`; // eslint-disable-line quotes
620596
const body = JSON.stringify(request?.shipment ?? {});
621597
const queryParams: string[] = [];
622-
if (request.parent) {
623-
queryParams.push("parent=" + encodeURIComponent(request.parent.toString()));
624-
}
625598
let uri = path;
626599
if (queryParams.length > 0) {
627600
uri += "?" + queryParams.join("&");
@@ -659,9 +632,6 @@ export function createFreightServiceClient(
659632
const path = `v1/${request.name}`; // eslint-disable-line quotes
660633
const body = null;
661634
const queryParams: string[] = [];
662-
if (request.name) {
663-
queryParams.push("name=" + encodeURIComponent(request.name.toString()));
664-
}
665635
let uri = path;
666636
if (queryParams.length > 0) {
667637
uri += "?" + queryParams.join("&");

examples/proto/gen/typescript/einride/example/syntax/v1/index.ts

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -358,9 +358,6 @@ export function createSyntaxServiceClient(
358358
const path = `v1/${request.string}:path`; // eslint-disable-line quotes
359359
const body = null;
360360
const queryParams: string[] = [];
361-
if (request.string) {
362-
queryParams.push("string=" + encodeURIComponent(request.string.toString()));
363-
}
364361
if (request.repeatedString) {
365362
for (const x of request.repeatedString) {
366363
queryParams.push("repeatedString=" + encodeURIComponent(x.toString()));
@@ -386,9 +383,6 @@ export function createSyntaxServiceClient(
386383
const path = `v1/${request.string}:pathBody`; // eslint-disable-line quotes
387384
const body = JSON.stringify(request?.nested ?? {});
388385
const queryParams: string[] = [];
389-
if (request.string) {
390-
queryParams.push("string=" + encodeURIComponent(request.string.toString()));
391-
}
392386
if (request.repeatedString) {
393387
for (const x of request.repeatedString) {
394388
queryParams.push("repeatedString=" + encodeURIComponent(x.toString()));

internal/plugin/servicegen.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,12 @@ func (s serviceGenerator) generateMethodQuery(
183183
}
184184
// fields covered by path
185185
pathCovered := make(map[string]struct{})
186+
for _, segment := range rule.Template.Segments {
187+
if segment.Kind != httprule.SegmentKindVariable {
188+
continue
189+
}
190+
pathCovered[segment.Variable.FieldPath.String()] = struct{}{}
191+
}
186192
walkJSONLeafFields(input, func(path httprule.FieldPath, field protoreflect.FieldDescriptor) {
187193
if _, ok := pathCovered[path.String()]; ok {
188194
return

0 commit comments

Comments
 (0)