【问题标题】:Google Cloud Endpoints - Method does not exist - OpenAPI yaml specificationGoogle Cloud Endpoints - 方法不存在 - OpenAPI yaml 规范
【发布时间】:2017-08-23 04:10:18
【问题描述】:

我正在尝试使用 Google Cloud Endpoints 和 Google App Engine 设置 NodeJS REST API。我从GitHub 克隆了官方示例项目,并使用Quickstart 设置了Google Cloud Endpoints。开箱即用,它工作正常,但我尝试在/ 为 GET 请求添加另一个 API 端点,但我在部署并发出请求后得到的响应如下:

{
 "code": 5,
 "message": "Method does not exist.",
 "details": [
  {
   "@type": "type.googleapis.com/google.rpc.DebugInfo",
   "stackEntries": [],
   "detail": "service_control"
  }
 ]
}

预配置的 API 可以正常工作,但只有我添加的新 API 无法正常工作。

我已经在我的 NodeJS 应用程序中正确配置了新端点(它在本地运行良好)。我添加的对应代码是:

app.get('/', function (req, res) {
  res.status(200).json({ message: 'Hello, world!' });
});

我已将以下内容添加到我的 openapi.yaml 文件中:

paths:
  "/":
    get:
      description: "Returns the message \"Hello, World\""
      operationId: "root"
      produces:
      - "application/json"
      responses:
        200:
          description: "Hello"
          schema:
            $ref: "#/definitions/helloMessage"
definitions:
  helloMessage:
    properties:
      message:
        type: "string"

在终端运行 gcloud service-management deploy openapi.yaml 以部署和配置 Google Cloud Endpoints 后,我得到了服务名称和服务配置 ID,我已将其替换为 app.yaml,采用快速入门指定的格式

endpoints_api_service:
  name: echo-api.endpoints.[YOUR-PROJECT-ID].cloud.goog
  config_id: YOUR-CONFIG-ID

(就是这样的格式,我把YOUR-PROJECT-IDYOUR-CONFIG-ID换成了正确的)

我使用 gcloud app deploy 将应用程序部署到 Google App Engine。通过 Google App Engine 控制台,我可以看到应用程序正常运行。

然而,/ 上的 GET 方法未被识别为有效端点,我得到了上述响应。

我错过了什么吗?我对这个问题进行了很多搜索,但没有发现任何有用/类似的东西!

P.S:添加,我的意思是,这是我添加到相应GitHub cloned files

的代码

编辑: 我将 API 端点从 / 更改为 /hello,它工作正常!!无法理解为什么 / 上的相同功能无法在 Google Cloud Endpoints 上运行(但在本地运行!)

【问题讨论】:

  • 我正在尝试为 Node api 设置相同的设置,但在部署后我无法访问端点。我遵循了here 提到的所有集合我遵循了THIS 入门指南,但仍然无法这样做。我可以看到我的服务正在创建,但是当我尝试使用它时不起作用

标签: node.js google-app-engine swagger google-cloud-endpoints openapi


【解决方案1】:

Google Cloud Endpoints 目前不支持“/”处的根路径。这是正在调查的事情。

【讨论】:

  • 关于此的任何文档/官方消息?
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2020-05-29
  • 2023-03-14
  • 2018-06-03
  • 1970-01-01
  • 2018-12-18
  • 1970-01-01
相关资源
最近更新 更多