Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
seanlaff opened this issue Jan 18, 2020 · 1 comment · Fixed by #1114
Closed

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

seanlaff opened this issue Jan 18, 2020 · 1 comment · Fixed by #1114

Comments

@seanlaff
Copy link
Contributor

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.

@johanbrandhorst
Copy link
Collaborator

Nice find. Have you looked at implementing a fix? I would be happy to review it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants