Google 云 API 带有身份验证的网关 yaml 配置文件部署错误

Google cloud API Gateway with authentication yaml config file deployment error

我是 API 网关的新手,正在尝试在我的 API 上启用安全性。我按照我在互联网上找到的一些说明进行操作: https://medium.com/swlh/manage-serverless-apis-with-api-gateway-in-gcp-b7f906efec1a

这是我的 YAML 文件:

# openapi2-functions.yaml
swagger: '2.0'
info:
  title: simple-test
  description: Sample API on API Gateway with a Google Cloud Functions backend
  version: 1.0.0
schemes:
  - https
produces:
  - application/json
paths:
  /direcciones:
    get:
      summary: get direcciones
      operationId: direcciones
      x-google-backend:
        address: http://publicIP/api/v1/app/catalogos/direcciones
        security:
        - api_key: []
      responses:
        '200':
          description: A successful response
          schema:
            type: string
securityDefinitions:
 api_key:
    type: "apiKey"
    name: "key"
    in: "query"

在 API 网关配置中部署此配置文件时,出现以下错误:

INVALID_ARGUMENT Cannot convert to service config. 'location: "evva.yaml: x-google-backend" kind: ERROR message: "Extension x-google-backend cannot be converted into proto type google.api.BackendRule. Details: Cannot find field: security in message google.api.BackendRule" location: "evva.yaml: x-google-backend" message: "Address field in extension x-google-backend is empty. In this case, the backend address must be provided to the proxy via a runtime flag." location: "evva.yaml: Operation \'get\' in path \'/direcciones\'" message: "Operation does not require an API key; callers may invoke the method without specifying an associated API-consuming project. To enable API key all the SecurityRequirement Objects (https://github.com/OAI/OpenAPI-Specification/blob/master/versions/2.0.md#security-requirement-object) inside security definition must reference at least one SecurityDefinition of type : \'apiKey\'." ' com.google.apps.framework.request.BadRequestException: Cannot convert to service config. 'location: "evva.yaml: x-google-backend" kind: ERROR message: "Extension x-google-backend cannot be converted into proto type google.api.BackendRule. Details: Cannot find field: security in message google.api.BackendRule" location: "evva.yaml: x-google-backend" message: "Address field in extension x-google-backend is empty. In this case, the backend address must be provided to the proxy via a runtime flag." location: "evva.yaml: Operation \'get\' in path \'/direcciones\'" message: "Operation does not require an API key; callers may invoke the method without specifying an associated API-consuming project. To enable API key all the SecurityRequirement Objects (https://github.com/OAI/OpenAPI-Specification/blob/master/versions/2.0.md#security-requirement-object) inside security definition must reference at least one SecurityDefinition of type : \'apiKey\'." ' 

我不明白这个错误我需要在 YAML 文件中做些什么更改才能使其在部署时可以接受。

安全条目不得位于 x-google-backend“中”,而应位于 get: 下方。像这样。

paths:
  /direcciones:
    get:
      summary: get direcciones
      operationId: direcciones
      x-google-backend:
        address: http://publicIP/api/v1/app/catalogos/direcciones
      security:
        - api_key: []