0

In my GCP endpoints v2 project i have created a service that returns Collection of POJOS. I noticed that when returning a List or a CollectionResponse the @ApiMethod(name = ) does not work.

Below an example:

@ApiMethod(name = "getCountryList",
    httpMethod = ApiMethod.HttpMethod.GET)
public CollectionResponse<Country> getCountryList() {

List<Country> countryList = null;
Connection con = null;

try{
    con = DbUtils.getConnection();
    countryList = CountryApi.getAll(con);

    return CollectionResponse.<Country> builder().setItems(countryList).build(); 
      //......

I except to have my method exposed with the name getCountryList, whereas it gets exposed with this name "collectionresponse_country"
also here is the openapi.json file which is consistent

enter image description here

Elio Khattar
  • 280
  • 1
  • 2
  • 14

1 Answers1

0

I have found the answer and it was a mistake from my part (and a documentation not read in details :-( ) I had to use the @ApiMethod path attribute as below:

@ApiMethod(name = "getCountryList",
            httpMethod = ApiMethod.HttpMethod.GET,
            path = "getCountryList")
    public CollectionResponse<Country> getCountryList() 
Elio Khattar
  • 280
  • 1
  • 2
  • 14