发布用于Google云终端的swagger doc的问题

时间:2018-03-04 07:25:32

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

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

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

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

3,)根据步骤3,项目名称应为FQDN。我在openapi.yaml中拥有的项目名称是>主持人:"示例项目 - ****** .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

1 个答案:

答案 0 :(得分:0)

关于添加“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