Google Cloud Endpoints - Method does not exist - OpenAPI yaml specification

烈酒焚心 提交于 2019-12-14 02:20:16

问题


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!)


回答1:


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



来源:https://stackoverflow.com/questions/43097453/google-cloud-endpoints-method-does-not-exist-openapi-yaml-specification

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!