【发布时间】:2019-10-21 07:15:04
【问题描述】:
我正在尝试将两个 API 版本部署到 Google Cloud Endpoints,但最终在部署过程中遇到了配置问题。
API 定义api-1.yaml 如下所示:
swagger: "2.0"
info:
description: "API"
title: "API"
version: "1.0.0"
host: "api.endpoints.GCP_PROJECT.cloud.goog"
basePath: "/v1"
x-google-api-name: v1
x-google-endpoints:
- name: "api.endpoints.GCP_PROJECT.cloud.goog"
target: "IP_ADDRESS"
...
如果单独部署,这很好用。但是,如果添加了api-2.yaml:
swagger: "2.0"
info:
description: "API"
title: "API"
version: "2.0.0"
host: "api.endpoints.GCP_PROJECT.cloud.goog"
basePath: "/v2"
x-google-api-name: v2
x-google-endpoints:
- name: "api.endpoints.GCP_PROJECT.cloud.goog"
target: "IP_ADDRESS"
...
这会导致部署错误:OpenAPI spec is invalid. Multiple endpoint entries are defined in the extension \'x-google-endpoints\'. At most one entry is allowed.
从一个yaml 文件中删除x-google-endpoints 扩展名有效,但它会使另一个yaml 文件不完整,因此不是最佳解决方案。
在部署期间合并/验证 yaml 文件是否存在问题? x-google-endpoints 扩展可以用来为版本化 API 定义 .cloud.goog 域吗?
【问题讨论】:
标签: google-cloud-endpoints openapi