如何生成离线 Swagger API 文档? [英] How to generate offline Swagger API docs?

查看:74
本文介绍了如何生成离线 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:

  • 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>).

这篇关于如何生成离线 Swagger API 文档?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆