【问题标题】:CDN for Google Cloud Functions - Configuring Endpoints with openapi-functions.yamlGoogle Cloud Functions 的 CDN - 使用 openapi-functions.yaml 配置端点
【发布时间】:2020-05-10 07:32:47
【问题描述】:

按照 https://cloud.google.com/endpoints/docs/openapi/get-started-cloud-functions 的入门指南将我的云功能置于 CDN 后面。将 ESPv2 Beta 部署到 Cloud Run 并获得预配置的 CloudRun 服务 URL。现在我的openapi-functions.yaml 文件碰壁了。当我运行命令时:

gcloud endpoints services deploy openapi-functions.yaml \
    --project ESP_PROJECT_ID

我收到错误响应:

ERROR: (gcloud.endpoints.services.deploy) INVALID_ARGUMENT: Cannot convert to service config.
'location: "openapi-functions.yaml: x-google-backend"
kind: ERROR
message: "Extension x-google-backend cannot be converted into proto type google.api.BackendRule. Details: Cannot find field: produces in message google.api.BackendRule"

 location: "openapi-functions.yaml: x-google-backend"
kind: ERROR
message: "Address field in extension x-google-backend is not a valid URL"

我使用的openapi-functions.yaml 似乎与教程中的示例几乎相同,并且此错误似乎表明 Cloud Functions 端点不是 CloudRun 的有效 URL!我在这里做错了什么?提前感谢您的帮助。

openapi-functions.yaml:

swagger: '2.0'
info:
  title: "My API"
  description: "Returns something"
  version: 1.0.0
host: "SERVICENAME-IDENTIFIER-uc.a.run.app"
schemes:
  - "https"
produces:
  - application/json
paths:
  "/foo":
    get:
      summary: "Returns thing"
      operationId: "foo"
      x-google-backend:
        address: "https://us-central1-my-project-name.cloudfunctions.net/bar"
        produces:
          - "application/json"
      responses:
        '200':
          description: "OK"
          schema:
            type: "string"
        '404':
          description: "Error"
          schema:
             type: "string"
        '403':
          description: "Forbidden"
          schema:
            type: "string"

【问题讨论】:

  • 在操作内部,produces 过度缩进。它应该与responses 处于同一级别,而不是在x-google-backend 内。

标签: google-cloud-platform google-cloud-functions openapi google-cloud-run google-cloud-cdn


【解决方案1】:

注释掉produces: 语句并且它有效。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2020-03-07
    • 1970-01-01
    • 2020-04-05
    • 2020-01-08
    • 1970-01-01
    • 2020-03-15
    • 1970-01-01
    • 2021-12-26
    相关资源
    最近更新 更多