按照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"