chiuki / gce2retrofit

Google Cloud Endpoint (GCE) to Retrofit
Apache License 2.0
100 stars 14 forks source link

fix for unnamed request parameter #5

Closed krishan711 closed 9 years ago

krishan711 commented 9 years ago

My discovery doc generates a 'patch' call which isn't directly specified in the api, for the following API method:

@endpoints.method(RPC_UpdateCollectionRequest, RPC_Collection, name='update', path='update')

I get these two entries in the discover doc:

"patch": {
 "id": "app.collection.patch",
 "path": "collection/update",
 "httpMethod": "PATCH",
 "description": "This method supports patch semantics.",
 "request": {
  "$ref": "EndpointCollectionRPCUpdateCollectionRequest"
 },
 "response": {
  "$ref": "EndpointModelRpcRPCCollection"
 },
 "scopes": [
  "https://www.googleapis.com/auth/userinfo.email"
 ]
},

and

"update": {
 "id": "app.collection.update",
 "path": "collection/update",
 "httpMethod": "POST",
 "description": "",
 "request": {
  "$ref": "EndpointCollectionRPCUpdateCollectionRequest",
  "parameterName": "resource"
 },
 "response": {
  "$ref": "EndpointModelRpcRPCCollection"
 },
 "scopes": [
  "https://www.googleapis.com/auth/userinfo.email"
 ]
}

As you can see, the generated patch call doesn't have a parameterName for the request, which results in the following generated retrofit methods:

@PATCH("/collection/update")
EndpointModelRpcRPCCollection patch(@Body EndpointCollectionRPCUpdateCollectionRequest null);
@PATCH("/collection/update")
void patch(@Body EndpointCollectionRPCUpdateCollectionRequest null, Callback<EndpointModelRpcRPCCollection> cb);

which doesn't compile because of the null statements.

The proposed solution has the disadvantage that if somebody has a param actually called request (and no parameterName for the body), it will conflict with the default value here. However, I think this is unlikely because this is most likely a bug in Google's discovery doc generating tool, which I will try to report.