1

我使用 Cloud Endpoint 的版本控制功能(即gcloud service-management deploy openapi_v1.yaml openapi_v2.yaml)将 2 个版本的 openapi.yaml 文件部署到 Google Cloud Endpoint。yaml 文件的每个版本都包含一个版本号和不同的基本路径,一个使用 api-key 身份验证的端点,以及 api-key 身份验证标签的定义。部署到 Endpoint 后,配置显示两个 yaml 文件,但是使用此配置将 api 部署到 GAE 只会为较新版本打开 api-key 身份验证。

有谁知道这是否是一个已知的错误,或者我需要做些什么来为所有版本启用身份验证?

.yaml 文件如下所示。我用来测试的两个版本是相同的,除了版本和浴路径:

swagger: "2.0"
info:
  description: "This API is used to connect 3rd-party ids to a common user identity"
  version: "0.0.1"
  title: "****"
host: "uie-dot-user-id-exchange.appspot.com"
basePath: "/v0"

...

- "https"
x-google-allow: all

paths:

  ...

  /ids/search:
    get:
      operationId: "id_search"
      produces:
      - "application/json"
      security:
      - api_key: []
      tags:
      - "Ids"
      summary: "Privileged endpoint. Provide any id (3rd party or otherwise) and get a hash of all ids associated with it."
      parameters:
      - in: "query"
        name: "id_type"
        description: "Type of id to search"
        required: true
        type: string
      - in: "query"
        name: "id_value"
        description: "Value of id to search"
        required: true
        type: string
      responses:
        200:
          description: "AssociatedIdsHash"
          schema:
            $ref: '#/definitions/AssociatedIdsHash'
        400:
          description: "Bad request. Requires both id_type and id_value query parameters."
        401:
          description: "Unauthorized. Please provide a valid api-key in the \"api-key\" header."
        404:
          description: "Not found - no entry found for key provided"

...

################ SECURITY DEFINITIONS ################
securityDefinitions:
  # This section configures basic authentication with an API key.
  api_key:
    type: "apiKey"
    name: "key"
    in: "query"
4

1 回答 1

0

我可以复制这个问题,它似乎是一个错误。

起作用的是在两个版本的全局级别而不是在每个路径级别添加 API 密钥限制。也许这种解决方法足以满足您的用例。

...
security:
- api_key: []
path:
...
于 2017-09-06T23:41:40.853 回答