-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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
Passing ENUM value as URL parameter throws error #166
Comments
I guess I didn't read far enough into the README before posting this. Any general guidance for someone who might try to dive in and implement the solution? |
You'd want to add a method that accepts an enum def to the runtime package in convert.go https://github.com/gengo/grpc-gateway/blob/master/runtime/convert.go and add it to the proto3ConvertFuncs (& proto2) map https://github.com/gengo/grpc-gateway/blob/master/protoc-gen-grpc-gateway/descriptor/types.go#L293 which gets used by Parameter.ConvertFuncExpr() https://github.com/gengo/grpc-gateway/blob/master/protoc-gen-grpc-gateway/descriptor/types.go#L190 and is eventually rendered here in the template https://github.com/gengo/grpc-gateway/blob/master/protoc-gen-grpc-gateway/gengateway/template.go#L210 |
The below change at least enables /v0/tickets?priority=3, though there's no range checking. I'll submit a PR if it's an acceptable interim solution until someone really fixes it.
|
- parses enumeration strings and integer values - range checks both the string and integer form Fixes grpc-ecosystem#166
I'm having issues passing an ENUM values as a URL parameter.
For example, this works just fine:
/v0/tickets?id=1
But I have if I have an enum
Priority
like this:Neither
/v0/tickets?priority=HIGH
or/v0/tickets?priority=3
work for me.The former returns:
And the latter crashes my gateway server with this stacktrace:
The text was updated successfully, but these errors were encountered: