【发布时间】: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