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

Fields aren't named in the same manner as golang/protobuf #84

Closed
tmc opened this issue Jan 6, 2016 · 0 comments
Closed

Fields aren't named in the same manner as golang/protobuf #84

tmc opened this issue Jan 6, 2016 · 0 comments

Comments

@tmc
Copy link
Collaborator

tmc commented Jan 6, 2016

For example:

diff --git a/examples/examplepb/echo_service.proto b/examples/examplepb/echo_service.proto
index 5e44b28..f39e711 100644
--- a/examples/examplepb/echo_service.proto
+++ b/examples/examplepb/echo_service.proto
@@ -5,13 +5,13 @@ package gengo.grpc.gateway.examples.examplepb;
 import "google/api/annotations.proto";

 message SimpleMessage {
-       string id = 1;
+       string ID = 1;
 }

 service EchoService {
        rpc Echo(SimpleMessage) returns (SimpleMessage) {
                option (google.api.http) = {
-                       post: "/v1/example/echo/{id}"
+                       post: "/v1/example/echo/{ID}"
                };
        }
        rpc EchoBody(SimpleMessage) returns (SimpleMessage) {

Will fail with

# github.com/gengo/grpc-gateway/examples/examplepb
examples/examplepb/echo_service.pb.gw.go:47: protoReq.Id undefined (type SimpleMessage has no field or method Id, but does have ID)

Simply using the exported CamelCase function fixes this:

package utilities

import "github.com/gogo/protobuf/protoc-gen-gogo/generator"

// PascalFromSnake converts an identifier in snake_case into PascalCase.
func PascalFromSnake(str string) string {
    return generator.CamelCase(str)
}
@yugui yugui closed this as completed in #85 Jan 6, 2016
yugui added a commit that referenced this issue Jan 28, 2016
Use the metadata proto.GetProperty returns instead.

Since the conversion rule is getting complicated, it is hard to emulate
the rule. c.f. #84
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant