Open wiless opened 9 years ago
The documentation specifies that the returned value needs to be a pointer to struct.
If you need to return a map you should return define some type:
type Response struct {
M map[int]string
}
And then define your method as returning that response:
func (s *Svc) SomeMethod(c context.Context, r *Request) (*Response, error) { ... }
The return object was a structure but it had a field of Kind map
.
Please provide code that causes the problem.
I tested it on the helloworld.go
replaced
// GreetingsList is the response type for GreetingService.List.
type GreetingsList struct {
Items []*Greeting `json:"items"`
}
with
// GreetingsList is the response type for GreetingService.List.
type GreetingsList struct {
Items []*Greeting `json:"items"`
Dummy map[int]string
}
and if you visit http://localhost:8080/_ah/api/discovery/v1/apis
return this error
{"error": {"message": "BackendService.getApiConfigs Error"}}
I probably think it is because of the inability of json
to Marshal/Unmarshal map
types.
It's actually a problem with the discovery api generation. In apiconfig.go, line 269, Alex's TODO needs to be fixed. Currently the code spits out an invalid API schema that consumers cannot parse. I would be willing to help, but I can't find documentation on the expected schema.
The endpoint discovery fails, if the return type of a method has structure with fields of type
map
. Even if is of basic typemap[int]string
. Would be better to have better error messages.