goa icon indicating copy to clipboard operation
goa copied to clipboard

CLI not generating correct examples for gRPC

Open nitinmohan87 opened this issue 4 years ago • 1 comments

If an attribute has nested type (e.g. MapOf(String, ArrayOf(String)) CLI should print out the correct examples to pass in the params

CLI should also print any unmarshal errors for easier debugging

nitinmohan87 avatar Jun 11 '20 02:06 nitinmohan87

there also seems to be a problem for CLI parsing MapOf(String, ArrayOf(String)) passed in a message argument. for example:

my_service-cli --url "localhost:8080" my action --message '{"headers": {"Foo": ["bar"]}}'
invalid JSON for message, example of valid JSON:
'{
  "headers": {
	 "key": [
		"value"
	 ]
  },
}'
run 'my_service-cli --help' for detailed usage.

stepping through the cli code in the debugger, the JSON parser is trying to unmarshal headers as map[string]*ArrayOfString where ArrayOfString is defined in the my.pb.go file as:

type ArrayOfString struct {
	state         protoimpl.MessageState
	sizeCache     protoimpl.SizeCache
	unknownFields protoimpl.UnknownFields

	Field []string `protobuf:"bytes,1,rep,name=field,proto3" json:"field,omitempty"`
}

this is odd because it seems protobuf should not be involved in the initial unmarshaling of the JSON message passed to CLI.

smessier avatar Jul 21 '20 22:07 smessier