为什么我的API没有在部署中显示? [英] Why is my API not showing up on deployment?

查看:94
本文介绍了为什么我的API没有在部署中显示?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我怀疑这是由端点中的以下错误引起的(如果有效),但我也确定在某处有一个解决方法。

https://code.google.com/p/googleappengine/issues/detail?id=9050&can=4&colspec=ID%20Type%20Component%20Status%20Stars%20Summary%20Language%20Priority%20Owner%20Log



重现步骤:


  1. 更改方法名称,
  2. 运行endpoints.sh脚本来生成API文件。

  3. 检查方法的API名称或Endpoints类中的参数列表。 API文件在本地并见证正在发生的变化。至此如此好。

  4. 在服务器上部署到应用程序的默认版本。

  5. 检查日志以查看/ _ah / spi /BackendService.getApiConfigs。没有错误!

  6. 转到API Explorer并清除浏览器缓存。检查API。更改不存在。

  7. 直接在浏览器中请求API文件,例如。 https:// [app-id] .appspot.com / _ah / api / discovery / v1 / apis / [api-name] / v1 / rpc更改不存在。

对于上述情况感到沮丧,我决定从头开始全新的应用ID。我仍然在API Explorer中看不到任何API,并在上面的步骤7中的URL上获得404!



这是我的端点类:

  @Api(name =ditto,version =v1)
public class CategoryEndpoint extends BaseEndpoint {

@SuppressWarnings (unused)
private static final Logger log = Logger.getLogger(CategoryEndpoint.class.getName());

@ApiMethod(name =category.list)
public WireCategory list(){
Category root = categoryDao.getRoot();
WireCategory wireRootCategory = new WireCategory(root);

返回wireRootCategory;
}

}

以下是生成的.api文件:

  {
extends:thirdParty.api,
abstract:false,
root:https://1.eliot-dev-uk-ditto-do.appspot.com/_ah/api,
name:ditto,
version:v1,
defaultVersion:false,
adapter:{
bns:https://1.eliot-dev-uk-ditto- do.appspot.com/_ah/spi,
截止日期:10.0,
type:lily
},
auth:{
allowCookieAuth:false
},
frontendLimits:{
unregisteredUserQps:-1,
unregisteredQps:-1,
unregisteredDaily :-1,
rules:[]
},
cacheControl:{
type:no-cache,
maxAge :0
},
methods:{
ditto.category.list:{
path:list,
httpMethod: GET,
scopes:[],
audiences:[],
clientIds:[],
rosyMethod:ditto.api.CategoryEndpoint.list,
request:{
body:empty
} ,
response:{
body:autoTemplate(backendResponse)
}
}
},
descriptor:{
schemas:{
WireCategory:{
id:WireCategory,
type:object,
properties:{
webSafePath:{
type:string
},
prettyPath:{
type:string
},
children:{
type:array,
items:{
$ ref:WireCategory
}
},
path:{
type:array,
items:{
type:string
}
},
name:{
type: string
},
id:{
type:string,
format:int64
}
} {
}
},
methods:{
ditto.api.CategoryEndpoint.list:{
response:{
$ ref:WireCategory
}
}
}
}
}

这个URL给了我一个404,我期望看到我的API JSON: b
$ b

https://eliot-dev-uk-ditto-do.appspot。 com / _ah / api / discovery / v1 / apis / ditto / v1

编辑:

这里是我刚刚发现的由App Engine 1.7.5和1.7.6生成的.api文件之间的差异。

  1.7.6中的ditto-v1.api:

{
extends:thirdParty.api,
abstract:false,
root:https://1.eliot-dev-uk-ditto-do。 appbot.com/_ah/api,
name:ditto,
version:v1,
defaultVersion:false,
adapter :{
bns:https://1.eliot-dev-uk-ditto-do.appspot.com/_ah/spi,
截止日期:10.0,
type:lily
}
...

从1.7.5开始的ditto-v1.api:

{
extends:thirdParty.api,
abstract:false,
root:https://eliot-dev-uk-ditto-do.appspot.com/_ah/api ,
name:ditto,
version:v1,
defaultVersion:false,
adapter:{
bns:http://eliot-dev-uk-ditto-do.appspot.com/_ah/spi,
截止日期:10.0,
type:lily
}
...


解决方案

指出,这是由于SDK 1.7.6中的一个奇怪问题,它在.api文件中的端点根url的开头添加了 1。 ...



我尝试了新的 SDK 1.7.7 ,它似乎解决了问题...


I suspect this is caused by the following bug in Endpoints (if valid) but I'm also sure there's a workaround somewhere.

https://code.google.com/p/googleappengine/issues/detail?id=9050&can=4&colspec=ID%20Type%20Component%20Status%20Stars%20Summary%20Language%20Priority%20Owner%20Log

Steps to reproduce:

  1. Change a method name, API name of a method, or parameter list in an Endpoints class.
  2. Run the endpoints.sh script to generate the API files.
  3. Inspect the API files locally and witness the changes being there. So far so good.
  4. Deploy to the default version of the app on the server.
  5. Check the logs for the call to /_ah/spi/BackendService.getApiConfigs. There are no errors!
  6. Go to API Explorer and clear the browser cache. Inspect the API. The change is not there.
  7. Request the API file directly in the browser, eg. https://[app-id].appspot.com/_ah/api/discovery/v1/apis/[api-name]/v1/rpc The change is not there.

Frustrated with the above, I decided to start completely from scratch on a new app ID. I still see no API in the API Explorer and get a 404 on the URL in step 7 above!

Here's my endpoint class:

@Api(name = "ditto", version = "v1")
public class CategoryEndpoint extends BaseEndpoint {

    @SuppressWarnings("unused")
    private static final Logger log = Logger.getLogger(CategoryEndpoint.class.getName());

    @ApiMethod(name = "category.list")
    public WireCategory list() {
        Category root = categoryDao.getRoot();
        WireCategory wireRootCategory = new WireCategory(root);

        return wireRootCategory;
    }

}

And here's the generated .api file:

{
  "extends" : "thirdParty.api",
  "abstract" : false,
  "root" : "https://1.eliot-dev-uk-ditto-do.appspot.com/_ah/api",
  "name" : "ditto",
  "version" : "v1",
  "defaultVersion" : false,
  "adapter" : {
    "bns" : "https://1.eliot-dev-uk-ditto-do.appspot.com/_ah/spi",
    "deadline" : 10.0,
    "type" : "lily"
  },
  "auth" : {
    "allowCookieAuth" : false
  },
  "frontendLimits" : {
    "unregisteredUserQps" : -1,
    "unregisteredQps" : -1,
    "unregisteredDaily" : -1,
    "rules" : [ ]
  },
  "cacheControl" : {
    "type" : "no-cache",
    "maxAge" : 0
  },
  "methods" : {
    "ditto.category.list" : {
      "path" : "list",
      "httpMethod" : "GET",
      "scopes" : [ ],
      "audiences" : [ ],
      "clientIds" : [ ],
      "rosyMethod" : "ditto.api.CategoryEndpoint.list",
      "request" : {
        "body" : "empty"
      },
      "response" : {
        "body" : "autoTemplate(backendResponse)"
      }
    }
  },
  "descriptor" : {
    "schemas" : {
      "WireCategory" : {
        "id" : "WireCategory",
        "type" : "object",
        "properties" : {
          "webSafePath" : {
            "type" : "string"
          },
          "prettyPath" : {
            "type" : "string"
          },
          "children" : {
            "type" : "array",
            "items" : {
              "$ref" : "WireCategory"
            }
          },
          "path" : {
            "type" : "array",
            "items" : {
              "type" : "string"
            }
          },
          "name" : {
            "type" : "string"
          },
          "id" : {
            "type" : "string",
            "format" : "int64"
          }
        }
      }
    },
    "methods" : {
      "ditto.api.CategoryEndpoint.list" : {
        "response" : {
          "$ref" : "WireCategory"
        }
      }
    }
  }
}

This URL gives me a 404 where I expect to see my API JSON:

https://eliot-dev-uk-ditto-do.appspot.com/_ah/api/discovery/v1/apis/ditto/v1

This is killing me!

EDIT:

Here's a diff I just spotted between the .api file generated by App Engine 1.7.5 and 1.7.6. Not sure why the URLs have changed.

ditto-v1.api from 1.7.6:

    {
      "extends" : "thirdParty.api",
      "abstract" : false,
      "root" : "https://1.eliot-dev-uk-ditto-do.appspot.com/_ah/api",
      "name" : "ditto",
      "version" : "v1",
      "defaultVersion" : false,
      "adapter" : {
        "bns" : "https://1.eliot-dev-uk-ditto-do.appspot.com/_ah/spi",
        "deadline" : 10.0,
        "type" : "lily"
      }
      ...

    ditto-v1.api from 1.7.5:

     {
      "extends" : "thirdParty.api",
      "abstract" : false,
      "root" : "https://eliot-dev-uk-ditto-do.appspot.com/_ah/api",
      "name" : "ditto",
      "version" : "v1",
      "defaultVersion" : false,
      "adapter" : {
        "bns" : "http://eliot-dev-uk-ditto-do.appspot.com/_ah/spi",
        "deadline" : 10.0,
        "type" : "lily"
      }
      ...

解决方案

As you already pointed out, it was due to an weird issue in SDK 1.7.6, which adds that 1. at the beginning of the endpoint root url in the .api files...

I've tried the new SDK 1.7.7 and it seems to be solved...

这篇关于为什么我的API没有在部署中显示?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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