【问题标题】:Issue in publishing swagger doc for google cloud endpoints为谷歌云端点发布 swagger 文档的问题
【发布时间】:2018-03-04 07:25:32
【问题描述】:

我正在尝试为我的云端点发布 Swagger 文档。我的应用程序是用 Python 编写的。根据文档 [1]:

1.) 我从 https://github.com/swagger-api/swagger-ui.git 下载了存储库。

2.) 从下载的存储库中复制 dist 目录并放入我项目中的 docs 文件夹中。我创建了一个名为 docs 的新文件夹。

3,) 按照步骤 3,项目名称应为 FQDN。我在 openapi.yaml 中的项目名称是-> host: "sample-project-******.appspot.com"

4.) 如文档中第 4 步所述,我在 app.yaml 中添加了以下内容

handlers:
  - url: /docs
    static_files: docs/index.html
    upload: docs/index.html
  - url: /docs/(.*)
    static_files: docs/\1
    upload: docs/.

5.) 将 docs/index.html 中的 URL 条目更新为:

url = "../api-docs";

6.) 在 openapi.yaml 中添加以下内容

"/docs":
    get:
      description: "Documentation"
      operationId: "docs"
      produces:
      - "application/json"
      responses:
        200:
          description: "Documentation"

问题:

  • 第5步添加url = "../api-docs"有什么意义?

  • 当我点击 /docs 时,我得到 404。

[1]https://cloud.google.com/endpoints/docs/openapi/adding-swagger

【问题讨论】:

  • 对于404问题,你修改openapi.yaml后,是否做了“gcloud endpoints services deploy openapi.yaml”,然后更新app.yaml中的配置ID?

标签: google-cloud-endpoints swagger-ui gcloud openapi


【解决方案1】:

关于添加“url”,来自https://cloud.google.com/endpoints/docs/openapi/adding-swagger的文档:

这会指示 Swagger UI 从该 URL 检索您的 OpenApi 规范。为此路径添加一个处理程序,该处理程序读取您的 openapi.yaml 并将其作为 json 提供。

此外,为了公开 Swagger 文档,您可能需要考虑 Endpoints 正在开发开发者门户功能并寻找用户:https://cloudplatform.googleblog.com/2018/03/now-you-can-automatically-document-your-API-with-Cloud-Endpoints.html

【讨论】:

    猜你喜欢
    • 2017-03-02
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-04-16
    • 2015-10-27
    相关资源
    最近更新 更多