You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Is your feature request related to a problem? Please describe.
It would be really use-full if templates are able to iterate over fields used as path variables.
Describe the solution you'd like
Here is a sample snippet that better describes the intention. By adding this function as helper the template
will be able to list only fields used as variables and may reduce the generated code.
funcurlVariableFields(pathstring, d*ggdescriptor.Message) []*descriptor.FieldDescriptorProto {
vars:= []*descriptor.FieldDescriptorProto{}
for_, field:=ranged.Field {
if!isFieldMessage(field) {
ifstrings.Contains(path, fmt.Sprintf("{%s}", *field.Name)) {
vars=append(vars, field)
continue
}
// JSON name field is checked as fallback. The value set by the protocol compiler.// If the user has set a "json_name" option on a field, that option's value// will be used in this check. By default value in this property will be field name in// camelCase format.ifstrings.Contains(path, fmt.Sprintf("{%s}", *field.JsonName)) {
vars=append(vars, field)
}
}
}
returnvars
}
The text was updated successfully, but these errors were encountered:
Is your feature request related to a problem? Please describe.
It would be really use-full if templates are able to iterate over fields used as path variables.
Describe the solution you'd like
Here is a sample snippet that better describes the intention. By adding this function as helper the template
will be able to list only fields used as variables and may reduce the generated code.
The text was updated successfully, but these errors were encountered: