diff --git a/protoc-gen-openapiv2/internal/genopenapi/template.go b/protoc-gen-openapiv2/internal/genopenapi/template.go index 3515dedcb8e..3298dc4652e 100644 --- a/protoc-gen-openapiv2/internal/genopenapi/template.go +++ b/protoc-gen-openapiv2/internal/genopenapi/template.go @@ -962,8 +962,7 @@ func templateToParts(path string, reg *descriptor.Registry, fields []*descriptor depth := 0 buffer := "" jsonBuffer := "" -pathLoop: - for i, char := range path { + for _, char := range path { switch char { case '{': // Push on the stack @@ -997,13 +996,6 @@ pathLoop: buffer += string(char) jsonBuffer += string(char) case ':': - if depth == 0 { - // As soon as we find a ":" outside a variable, - // everything following is a verb - parts = append(parts, buffer) - buffer = path[i:] - break pathLoop - } buffer += string(char) jsonBuffer += string(char) default: diff --git a/protoc-gen-openapiv2/internal/genopenapi/template_test.go b/protoc-gen-openapiv2/internal/genopenapi/template_test.go index 80c4e48d214..7c6df9d10d1 100644 --- a/protoc-gen-openapiv2/internal/genopenapi/template_test.go +++ b/protoc-gen-openapiv2/internal/genopenapi/template_test.go @@ -3858,6 +3858,7 @@ func TestTemplateWithJsonCamelCase(t *testing.T) { {"test/{ab_c}", "test/{abC}"}, {"test/{json_name}", "test/{jsonNAME}"}, {"test/{field_abc.field_newName}", "test/{fieldAbc.RESERVEDJSONNAME}"}, + {"/item/search:items/{item_no_query}", "/item/search:items/{itemNoQuery}"}, } reg := descriptor.NewRegistry() reg.SetUseJSONNamesForFields(true)