@@ -464,6 +464,15 @@ func fieldName(r *registry.Registry) func(name string) string {
464
464
}
465
465
}
466
466
467
+ func renderParts (fieldName string , fieldNameFn func (name string ) string ) string {
468
+ fieldNameParts := strings .Split (fieldName , "." )
469
+ renderedParts := make ([]string , 0 , len (fieldNameParts ))
470
+ for _ , part := range fieldNameParts {
471
+ renderedParts = append (renderedParts , fmt .Sprintf (`["%s"]` , fieldNameFn (part )))
472
+ }
473
+ return fmt .Sprintf ("${req%s}" , strings .Join (renderedParts , "" ))
474
+ }
475
+
467
476
func renderURL (r * registry.Registry ) func (method data.Method ) string {
468
477
fieldNameFn := fieldName (r )
469
478
return func (method data.Method ) string {
@@ -475,10 +484,11 @@ func renderURL(r *registry.Registry) func(method data.Method) string {
475
484
log .Debugf ("url matches %v" , matches )
476
485
for _ , m := range matches {
477
486
expToReplace := m [0 ]
478
- fieldName := fieldNameFn (m [1 ])
479
- part := fmt .Sprintf (`${req["%s"]}` , fieldName )
487
+ // cleanup m[1] if the pattern is {fieldname=resources/*}
488
+ cleanedFieldName := strings .Split (m [1 ], "=" )[0 ]
489
+ part := renderParts (cleanedFieldName , fieldNameFn )
480
490
methodURL = strings .ReplaceAll (methodURL , expToReplace , part )
481
- fieldsInPath = append (fieldsInPath , fmt .Sprintf (`"%s"` , fieldName ))
491
+ fieldsInPath = append (fieldsInPath , fmt .Sprintf (`"%s"` , cleanedFieldName ))
482
492
}
483
493
}
484
494
urlPathParams := fmt .Sprintf ("[%s]" , strings .Join (fieldsInPath , ", " ))
0 commit comments