Why is Google Cloud Endpoints reordering my settings?

I have the following endpoint method:

public class PlayerEndpoint {
  private static final String PLAYER_NAME = "player_name";
  private static final String PLAYER_UUID = "player_uuid";

  @ApiMethod(name = "register", httpMethod = ApiMethod.HttpMethod.POST, path="register")
  public Player register(@Named(PLAYER_UUID) String uuid,
                         @Named(PLAYER_NAME) String playerName) {
  log.info(String.format("Registering user uuid: %s name: %s", uuid, playerName));
  ...
  }
}

      

When I call this from my Android client:

String uuid = "test_uuid";
String name = "test_name";
playerEndpoint.register(uuid, name).execute();

      

Backend Logs:

Registering user uuid: test_name name: test_uuid

      

What's going on here?

+3


source to share


1 answer


I understood that. The endpoints seem to sort your methods alphabetically.

The method parameters in the generated client library are in alphabetical order , regardless of the original order in the backend method. As a result, you must be careful when editing your methods, especially if there are multiple parameters of the same type. The compiler will not be able to catch parameter ordering errors.



https://cloud.google.com/developers/articles/google-cloud-endpoints-for-android/

+2


source







All Articles