谷歌clould端点Api方法生成没有所需的参数 [英] Google clould endpoint Api method generated without the required parameter

查看:83
本文介绍了谷歌clould端点Api方法生成没有所需的参数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想部署我的谷歌端点API的v2。在这个版本2中,我添加了一个带参数的ApiMethod

  / ** 
*我们是一个端点类公开
* /
@Api(
name =myApi,
version =v2,
namespace = @ApiNamespace(
ownerDomain = awesome.me.com,
ownerName =awesome.me.com,
packagePath =api / v2


public class MyEndpointV2 extends MyEndpoint {


@ApiMethod(name =getContact)
public Charges getContact(ContactRequest request){
return ContactHandler.getContact(request);






$ b

正如你所看到的,我的V2扩展了我的V1 Api所以我可以访问我所有的V1方法。问题在于,我的新方法是在不带参数 ContactRequest 的情况下生成的。这是当我尝试调用我的应用程序模块中的方法,它显示如下

  myapi.getContact()

可能是什么问题?
我试图清理构建我的项目,但没有任何反应。



编辑
这里是MyEndPoint类

  @Api(
name =myApi,
version =v1,
namespace = @ApiNamespace (
ownerDomain =awesome.me.com,
ownerName =awesome.me.com,
packagePath =


public class MyEndpoint {


@ApiMethod(name =getPeriod)
public Period getPeriod(@Named(days)long days){
return Handler.getPeriod(天);
}
//其他api方法
}


解决方案

这个错误可能是由你的继承造成的。请阅读以下文档



https://cloud.google.com/appengine/docs/java/endpoints/multiclass



它表示您必须使用相同的值为您的注释。您试图覆盖版本和软件包的值。这可能导致未定义的行为

I want to deploy v2 of my google endpoint API. in this version 2, i have added an ApiMethod with a parameter

 /**
 * An endpoint class we are exposing
 */
@Api(
  name = "myApi",
  version = "v2",
  namespace = @ApiNamespace(
    ownerDomain = "awesome.me.com",
    ownerName = "awesome.me.com",
    packagePath = "api/v2"
  )
)
public class MyEndpointV2 extends MyEndpoint{


  @ApiMethod(name = "getContact")
  public Charges getContact(ContactRequest request){
    return ContactHandler.getContact(request);
  }
}

As you can see, my V2 extends my V1 Api so i can access all my V1 methods. the issue is that,my new method is generated without parameter ContactRequest. that is when i try to call the method in my app module, it appears as follows

myapi.getContact()

What could be the problem? I have tried to clean build my project but nothing happens

EDIT Here's MyEndPoint class

 @Api(
      name = "myApi",
      version = "v1",
      namespace = @ApiNamespace(
        ownerDomain = "awesome.me.com",
        ownerName = "awesome.me.com",
        packagePath = ""
      )
    )
    public class MyEndpoint{


     @ApiMethod(name = "getPeriod")
  public Period getPeriod(@Named("days")long days) {
    return Handler.getPeriod(days);
  }
  //other api methods
    }

解决方案

This error may caused by your inheritance. Please read the following documentation

https://cloud.google.com/appengine/docs/java/endpoints/multiclass

It says that you have to use the same values for your annotations. You tried to override the values for Version and package. This can lead to undefined behaviour

这篇关于谷歌clould端点Api方法生成没有所需的参数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆