Google Cloud Endpoints - 方法不存在 - OpenAPI yaml 规范
Google Cloud Endpoints - Method does not exist - OpenAPI yaml specification
我正在尝试使用 Google Cloud Endpoints 和 Google App Engine 设置 NodeJS REST API。我从 GitHub and set up Google Cloud Endpoints using the Quickstart 克隆了官方示例项目。开箱即用,它工作正常,但我尝试在 /
为 GET 请求添加另一个 API 端点,但我在部署和发出请求后得到的响应如下:
{
"code": 5,
"message": "Method does not exist.",
"details": [
{
"@type": "type.googleapis.com/google.rpc.DebugInfo",
"stackEntries": [],
"detail": "service_control"
}
]
}
预配置的 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-ID
和 YOUR-CONFIG-ID
)
我使用 gcloud app deploy
将应用程序部署到 Google App Engine。我可以通过 Google App Engine 控制台正确查看应用 运行。
然而,/
上的 GET 方法未被识别为有效端点,我收到如上所述的响应。
我错过了什么吗?我搜索了很多有关此问题的信息,但没有遇到任何问题 useful/similar!
P.S:added,就是我在对应的GitHub cloned files
中添加的代码
编辑:
我将 API 端点从 /
更改为 /hello
,它工作正常!!无法理解为什么 /
上的相同功能在 Google 云端点上不起作用(虽然在本地工作!)
Google Cloud Endpoints 当前不支持位于“/”的根路径。这是正在调查的事情。
我正在尝试使用 Google Cloud Endpoints 和 Google App Engine 设置 NodeJS REST API。我从 GitHub and set up Google Cloud Endpoints using the Quickstart 克隆了官方示例项目。开箱即用,它工作正常,但我尝试在 /
为 GET 请求添加另一个 API 端点,但我在部署和发出请求后得到的响应如下:
{
"code": 5,
"message": "Method does not exist.",
"details": [
{
"@type": "type.googleapis.com/google.rpc.DebugInfo",
"stackEntries": [],
"detail": "service_control"
}
]
}
预配置的 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-ID
和 YOUR-CONFIG-ID
)
我使用 gcloud app deploy
将应用程序部署到 Google App Engine。我可以通过 Google App Engine 控制台正确查看应用 运行。
然而,/
上的 GET 方法未被识别为有效端点,我收到如上所述的响应。
我错过了什么吗?我搜索了很多有关此问题的信息,但没有遇到任何问题 useful/similar!
P.S:added,就是我在对应的GitHub cloned files
中添加的代码编辑:
我将 API 端点从 /
更改为 /hello
,它工作正常!!无法理解为什么 /
上的相同功能在 Google 云端点上不起作用(虽然在本地工作!)
Google Cloud Endpoints 当前不支持位于“/”的根路径。这是正在调查的事情。