Google Cloud Endpoints - 方法不存在 - OpenAPI yaml规范 [英] Google Cloud Endpoints - Method does not exist - OpenAPI yaml specification

查看:235
本文介绍了Google Cloud Endpoints - 方法不存在 - OpenAPI yaml规范的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正尝试使用Google Cloud Endpoints和Google App Engine设置NodeJS REST API。我已经克隆了 GitHub < a>并使用快速入门设置Google Cloud Endpoints。开箱即用,但它工作正常,但我尝试在 / 中为GET请求添加另一个API端点,但在部署并发出请求后得到的响应为如下:

  {
code:5,
message:方法不存在。,
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 file:

 路径:
/:
获得:
描述:返回消息\Hello,World \
operationId:root
产生:
- application / json
响应:
200:
描述:Hello
模式:
$ ref:#/ definitions / helloMessage
定义:
helloMessage:
属性:
消息:
类型:字符串

从终端运行 gcloud服务管理部署openapi.yaml 以部署和配置Google Cloud Endpoints后,我获得了服务名称和服务配置标识,在 app.yaml 中,以快速入门指定的格式

  endpoints_api_service :
名称:echo-api.endpoints。[YOUR-PR OJECT-ID] .cloud.goog
config_id:YOUR-CONFIG-ID

格式,我用正确的格式取代了 YOUR-PROJECT-ID YOUR-CONFIG-ID / p>

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



然而, / 没有被确定为有效的终点,我得到了上述的答复。



我错过了什么吗?我搜索了很多关于这个问题,但没有遇到任何有用/相似的东西!



PS:按添加,我的意思是,它是我添加到相应的 GitHub的代码克隆文件









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

解决方案

Google Cloud Endpoints目前不支持/处的根路径。这是正在研究的东西。


I'm trying to setup a NodeJS REST API using Google Cloud Endpoints and Google App Engine. I've cloned the offical sample project from GitHub and set up Google Cloud Endpoints using the Quickstart. Out of the box, it works fine,but I tried adding another API endpoint for a GET request at /, but the response I get after I deploy and make the request is as follows:

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

The APIs which came pre-configured works fine, but only new ones which I add aren't working.

I've configured the new endpoint properly in my NodeJS app (it works fine locally). The corresponding code I've added is:

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

I've added the following to my openapi.yaml file:

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"

After running gcloud service-management deploy openapi.yaml from a terminal to deploy and configure Google Cloud Endpoints, I got the service name and the service configuration ID, which I've replaced in app.yaml, in the format specified by the QuickStart

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

(That's the format, I've replaced YOUR-PROJECT-ID and YOUR-CONFIG-ID with the right ones)

I deployed the app to Google App Engine using gcloud app deploy. I can see the app running properly, via the Google App Engine console.

Yet, the GET method on / is not being identified as a valid endpoint and I get the response as stated above.

Am I missing something? I searched a lot about this problem, but didn't come across anything useful/similar!

P.S: By added, I mean, it is the code which I've added to the corresponding GitHub cloned files



EDIT: I changed the API endpoint from / to /hello and it works fine!! Unable to understand why the same functionality on / is not working on Google Cloud Endpoints (works locally though!)

解决方案

Google Cloud Endpoints does not currently support the root path at "/". This is something that is being looked into.

这篇关于Google Cloud Endpoints - 方法不存在 - OpenAPI yaml规范的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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