GCP端点v2:@ApiMethod(name =)返回集合时不起作用

问题描述:

在我的GCP端点v2项目中,我创建了一个返回POJOS集合的服务。 我注意到,当返回一个List或一个CollectionResponse @ApiMethod(name =)不起作用。GCP端点v2:@ApiMethod(name =)返回集合时不起作用

下面的例子:

@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(); 
     //...... 

我除了有暴露名为getCountryList我的方法,而它被这个名为“collectionresponse_country”暴露
也在这里是openapi.json文件,该文件是一致的

enter image description here

我已经找到了答案,这是从我犯的一个错误(和文档不再详细阅读:-() 我必须使用@ApiMethod路径属性,如下所示:

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