Skip to content

Gateway does not parse oneof types correctly when using camelCase #1113

Closed
@seanlaff

Description

Enums like

message GetRolesRequest {
  oneof get {
    // roles's project
    string project_id = 4;
    // cluster roles
    bool cluster = 5;
  }
}

will not be parsed correctly through the gateway with the camelCase flag. project_id succeeds but projectId does not.

The issue looks to be here :

if op, ok := props.OneofTypes[name]; ok {
v := reflect.New(op.Type.Elem())
field := m.Field(op.Field)
if !field.IsNil() {
return reflect.Value{}, nil, fmt.Errorf("field already set for %s oneof", props.Prop[op.Field].OrigName)
}
field.Set(v)
return v.Elem().Field(0), op.Prop, nil
}

There's a map of oneofs that we loop over, however they key of the map is the name with the underscore, so given a camelCase param, it will never find it.

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions