通过 Google Cloud Endpoints 公开 Swagger-UI 文档

jur*_*jur 5 google-cloud-endpoints swagger-ui gcloud openapi

我正在尝试使用 Google Cloud Endpoints 在与我的 API 相同的 Nodejs 应用程序中发布我的 API 文档。

按照本指南看起来很简单: 添加 Swagger UI

棘手的部分是/docs通过 Google Cloud Endpoints 公开路径(它也使用相同的openapi.yaml)。

我尝试像这样定义/docs路径openapi.yaml

"/docs":
    get:
      description: "Swagger UI API documentation"
      operationId: "docs"
      produces:
        - "text/html"
      responses:
        200:
          description: "Swagger UI"
Run Code Online (Sandbox Code Playgroud)

HTML 页面本身已得到服务,但未swagger-ui.css找到类似的任何资产。

在我看来我做错了,因为文档不是 API 端点。但是我一直没能找到一个好的解决方案。有没有办法代理/docs路径的所有流量?

the*_*her 3

我想你会发现没有什么好的方法可以做到这一点。最好的选择是将文档发布作为部署管道中的一个单独步骤进行中断。那,还是等6个月吧。Google Cloud 正在迅速发展,他们可能已将其纳入其路线图。