为什么我的API没有出现在部署中?

时间:2013-03-27 18:04:14

标签: google-app-engine google-cloud-endpoints

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

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

重现的步骤:

  1. 更改Endpoints类中的方法名称,方法的API名称或参数列表。
  2. 运行endpoints.sh脚本以生成API文件。
  3. 在本地检查API文件并查看其中的更改。到目前为止一切顺利。
  4. 在服务器上部署到应用程序的默认版本。
  5. 检查日志以获取对/_ah/spi/BackendService.getApiConfigs的调用。没有错误!
  6. 转到API资源管理器并清除浏览器缓存。检查API。这种变化不存在。
  7. 直接在浏览器中请求API文件,例如。 https:// [app-id] .appspot.com / _ah / api / discovery / v1 / apis / [api-name] / v1 / rpc更改不存在。
  8. 对上述内容感到沮丧,我决定从头开始全新的应用ID。我仍然在API资源管理器中看不到API,并在上面的第7步中获取了网址上的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);
    
            return 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",
        "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"
            }
          }
        }
      }
    }
    

    此网址为我提供了404我期望看到我的API JSON:

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

    这是在杀我!

    编辑:

    这是我在App Engine 1.7.5和1.7.6生成的.api文件之间发现的差异。不确定URL为何发生了变化。

    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"
          }
          ...
    

1 个答案:

答案 0 :(得分:2)

正如您已经指出的那样,这是由于SDK 1.7.6中的一个奇怪的问题,它在.api文件中的端点根URL的开头添加了1. ...

我尝试了新的 SDK 1.7.7 ,似乎已经解决了......