@@ -4126,8 +4126,16 @@ func getParameters(names []string) []descriptor.Parameter {
41264126 Target : & descriptor.Field {
41274127 FieldDescriptorProto : & descriptorpb.FieldDescriptorProto {
41284128 Name : proto .String (name ),
4129+ Type : descriptorpb .FieldDescriptorProto_TYPE_STRING .Enum (),
4130+ },
4131+ Message : & descriptor.Message {
4132+ File : & descriptor.File {
4133+ FileDescriptorProto : & descriptorpb.FileDescriptorProto {},
4134+ },
4135+ DescriptorProto : & descriptorpb.DescriptorProto {
4136+ Name : proto .String ("" ),
4137+ },
41294138 },
4130- Message : & descriptor.Message {},
41314139 FieldMessage : nil ,
41324140 ForcePrefixedName : false ,
41334141 },
@@ -4170,7 +4178,31 @@ func TestTemplateToOpenAPIPathExpandSlashed(t *testing.T) {
41704178 if ! reflect .DeepEqual (data .expectedPathParams , pathParamsNames ) {
41714179 t .Errorf ("Expected mutated path params in templateToOpenAPIPath(%v) = %v, actual: %v" , data .input , data .expectedPathParams , data .pathParams )
41724180 }
4181+ }
4182+ }
41734183
4184+ func TestExpandedPathParametersStringType (t * testing.T ) {
4185+ var tests = []struct {
4186+ input string
4187+ }{
4188+ {"/test/{name=test_cases/*}/" }, {"/v1/{name=projects/*/documents/*}:exportResults" },
4189+ }
4190+ reg := descriptor .NewRegistry ()
4191+ reg .SetExpandSlashedPathPatterns (true )
4192+ expectedParamType := openapiSchemaObject {
4193+ schemaCore : schemaCore {
4194+ Type : "string" ,
4195+ },
4196+ }
4197+ for _ , data := range tests {
4198+ _ , actualParams := templateToExpandedPath (data .input , reg , generateFieldsForJSONReservedName (), generateMsgsForJSONReservedName (), getParameters ([]string {"name" }))
4199+ for _ , param := range actualParams {
4200+ refs := make (refMap )
4201+ actualParamType := schemaOfField (param .Target , reg , refs )
4202+ if ! reflect .DeepEqual (actualParamType , expectedParamType ) {
4203+ t .Errorf ("Expected all path parameters to be type of 'string', actual: %#+v" , actualParamType )
4204+ }
4205+ }
41744206 }
41754207}
41764208
0 commit comments