|
|
@ -160,16 +160,22 @@ func buildMethodDesc(g *protogen.GeneratedFile, m *protogen.Method, method, path |
|
|
|
vars := buildPathVars(m, path) |
|
|
|
vars := buildPathVars(m, path) |
|
|
|
fields := m.Input.Desc.Fields() |
|
|
|
fields := m.Input.Desc.Fields() |
|
|
|
for _, v := range vars { |
|
|
|
for _, v := range vars { |
|
|
|
fd := fields.ByName(protoreflect.Name(v)) |
|
|
|
for _, field := range strings.Split(v, ".") { |
|
|
|
if fd == nil { |
|
|
|
if strings.TrimSpace(field) == "" { |
|
|
|
fmt.Fprintf(os.Stderr, "\u001B[31mERROR\u001B[m: The corresponding field '%s' declaration in message could not be found in '%s'\n", v, path) |
|
|
|
continue |
|
|
|
os.Exit(2) |
|
|
|
} |
|
|
|
} |
|
|
|
fd := fields.ByName(protoreflect.Name(field)) |
|
|
|
if fd.IsMap() { |
|
|
|
if fd == nil { |
|
|
|
fmt.Fprintf(os.Stderr, "\u001B[31mWARN\u001B[m: The field in path:'%s' shouldn't be a map.\n", v) |
|
|
|
fmt.Fprintf(os.Stderr, "\u001B[31mERROR\u001B[m: The corresponding field '%s' declaration in message could not be found in '%s'\n", v, path) |
|
|
|
} |
|
|
|
os.Exit(2) |
|
|
|
if fd.IsList() { |
|
|
|
} |
|
|
|
fmt.Fprintf(os.Stderr, "\u001B[31mWARN\u001B[m: The field in path:'%s' shouldn't be a list.\n", v) |
|
|
|
if fd.IsMap() { |
|
|
|
|
|
|
|
fmt.Fprintf(os.Stderr, "\u001B[31mWARN\u001B[m: The field in path:'%s' shouldn't be a map.\n", v) |
|
|
|
|
|
|
|
} else if fd.IsList() { |
|
|
|
|
|
|
|
fmt.Fprintf(os.Stderr, "\u001B[31mWARN\u001B[m: The field in path:'%s' shouldn't be a list.\n", v) |
|
|
|
|
|
|
|
} else if fd.Kind() == protoreflect.MessageKind || fd.Kind() == protoreflect.GroupKind { |
|
|
|
|
|
|
|
fields = fd.Message().Fields() |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
return &methodDesc{ |
|
|
|
return &methodDesc{ |
|
|
|