Skip to content

Commit

Permalink
Merge pull request #24 from yahoo/client_function_name
Browse files Browse the repository at this point in the history
make client function name recognize resource name
  • Loading branch information
chinkong83 authored Mar 16, 2017
2 parents 2340f46 + 5916ae7 commit c47ad5b
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 10 deletions.
9 changes: 7 additions & 2 deletions cmd/rdl-gen-parsec-java-client/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -394,7 +394,8 @@ func javaMethodName(reg rdl.TypeRegistry, r *rdl.Resource, needParamWithType boo
var params []string
bodyType := string(safeTypeVarName(r.Type))
for _, v := range r.Inputs {
if v.Context != "" { //ignore these legacy things
if v.Context != "" {
//ignore these legacy things
log.Println("Warning: v1 style context param ignored:", v.Name, v.Context)
continue
}
Expand All @@ -409,7 +410,11 @@ func javaMethodName(reg rdl.TypeRegistry, r *rdl.Resource, needParamWithType boo
params = append(params, javaName(k))
}
}
return strings.ToLower(string(r.Method)) + string(bodyType), params
if r.Name != "" {
return utils.Uncapitalize(string(r.Name)), params
} else {
return strings.ToLower(string(r.Method)) + string(bodyType), params
}
}

// todo: duplicate with java-server.go
Expand Down
12 changes: 6 additions & 6 deletions testdata/Sample2ClientImpl.txt
Original file line number Diff line number Diff line change
Expand Up @@ -128,12 +128,12 @@ public class SampleClientImpl implements SampleClient {
}

@Override
public CompletableFuture<User> getUser(int id) throws ResourceException {
return getUser(null, id);
public CompletableFuture<User> getUserId(int id) throws ResourceException {
return getUserId(null, id);
}

@Override
public CompletableFuture<User> getUser(Map<String, List<String>> headers, int id) throws ResourceException {
public CompletableFuture<User> getUserId(Map<String, List<String>> headers, int id) throws ResourceException {
String path = "/user/{id}";
String body = null;

Expand All @@ -152,12 +152,12 @@ public class SampleClientImpl implements SampleClient {
}

@Override
public CompletableFuture<User> postUser() throws ResourceException {
return postUser(null);
public CompletableFuture<User> fetchWssid() throws ResourceException {
return fetchWssid(null);
}

@Override
public CompletableFuture<User> postUser(Map<String, List<String>> headers) throws ResourceException {
public CompletableFuture<User> fetchWssid(Map<String, List<String>> headers) throws ResourceException {
String path = "/wssid";
String body = null;

Expand Down
6 changes: 4 additions & 2 deletions testdata/sample2.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,8 @@
"UNAUTHORIZED": {
"type": "ResourceError"
}
}
},
"name" : "getUserId"
},
{
"type": "User",
Expand All @@ -71,7 +72,8 @@
"UNAUTHORIZED": {
"type": "ResourceError"
}
}
},
"name" : "fetchWssid"
}
]
}

0 comments on commit c47ad5b

Please sign in to comment.