如何生成离线 Swagger API 文档?

我有一个 Spring Boot MVC Java Web 应用程序.我已经能够为 API 文档集成 Springfox.当服务器启动并运行时,我可以直观地看到所有 API.

I have a spring boot MVC java Web app. I've been able to integrate Springfox for API documentation. I can visually see all of the APIs when server is up and running.

如何生成 OFFLINE swagger API 文档?注意:我不想使用 asciidoc 或 markdown 文档,但我想在 html 文件中使用相同的 swagger API 用户界面.我希望链接相对于本地目录而不是本地主机服务器链接.谢谢

How can I generate OFFLINE swagger API documentation? Note: I would not like to use asciidoc or markdown documentation, but I'd like the same swagger API user interface in html files. I'd like so that the links are relative to local directory instead of local host server links. Thanks

推荐答案

Springfox 允许您基于 Spring 注释轻松创建 Swagger 测试器/API 文档.

Springfox allows you to easily create a Swagger tester/API docs based on your Spring annotations.

Swagger 本身有一些工具可让您生成离线/静态文档:

Swagger itself has some tools to allow you to generate offline/static documentation:

  • Swagger 编辑器有多种生成文档的方法,列在生成客户端 菜单
  • Swagger Codegen 模块允许您生成静态和动态 HTML 文档
  • The Swagger Editor has several ways of generating documentation listed in the Generate Client menu
  • The Swagger Codegen module allows you to generate a static and dynamic HTML document

它们都需要 Swagger YAML 或 JSON 文件.如果您因为使用 Springfox 而在 YAML/JSON 中没有 Swagger 定义,则可以使用生成的用于 Swagger UI 的文件 (/v2/api-docs?group=<group name>).

Both of them require a Swagger YAML or JSON file. In case you don't have a Swagger definition in YAML/JSON because you're using Springfox, you can use the generated file used for Swagger UI (/v2/api-docs?group=<group name>).

相关文章