是否可以获取网站的草率文档的脱机版本? [英] is it possible to get an offline version of swagger documentation for a website?

查看:93
本文介绍了是否可以获取网站的草率文档的脱机版本?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

localhost/swagger正在按我的预期加载,但是remoteserver/swagger出现问题.我可以保存所生成的swagger文档的脱机副本吗?在尝试调试远程问题时,我只能将zip文件发送给几个用户.

localhost/swagger is loading as expected for me but remoteserver/swagger is having issues. Is it possible for me to save an offline copy of the swagger documentation that's generated? I can just send a zip file to a few users while I'm trying to debug the remote issue.

推荐答案

如果由于某种原因您自己无法托管Swagger UI,则有很多方法可以向用户提供API文档.所有建议均假定您具有OpenAPI(Swagger)定义,即YAML/JSON文件.如果您不知道YAML/JSON文件的位置,则可以从Swagger UI网页进行推断.

There are lots of ways to provide API docs to your users if you for some reason cannot host Swagger UI yourself. All suggestions assume you have an OpenAPI (Swagger) definition, that is the YAML/JSON file. If you don't know the location of the YAML/JSON file, you can infer it from the Swagger UI web page.

无特定顺序:

  1. 将YAML/JSON文件发送给您的用户,并告诉他们将其加载到 http://editor.swagger中.io 以便预览API文档.

  1. Send the YAML/JSON file to your users and tell them to load it in http://editor.swagger.io in order to preview the API docs.

将您的OpenAPI定义文件导入 SwaggerHub 并在其中托管您的API文档.
披露:SwaggerHub由我工作的公司制造.

Import your OpenAPI definition file into SwaggerHub and host your API docs there.
Disclosure: SwaggerHub is made by the company I work for.

将您的OpenAPI定义文件放在任何公共Web服务器上,例如在GitHub上创建要点.然后,您可以通过将API文档加载到Swagger UI公共演示中来呈现API文档,如下所示:

Put your OpenAPI definition file on any public web server, e.g. create a gist on GitHub. Then you can render API docs by loading it into Swagger UI public demo, like so:

http://petstore.swagger.io?url=YOUR_YAML_or_JSON_URL

如果使用要点,请确保指定原始要点链接( https://gist.githubusercontent.com/... ).如果使用其他托管,请确保托管服务器支持 CORS .

If using a gist, make sure to specify a raw gist link (https://gist.githubusercontent.com/...). If using another hosting, make sure the hosting server supports CORS.

将Swagger UI和您的OpenAPI定义打包到单个无依赖项文件中,如在此说明,,并将结果文件发送给您的用户.

"Pack" Swagger UI and your OpenAPI definition into a single dependency-less file as explained here, and send the resulting file to your users.

生成静态HTML文档(不是Swagger UI,而是一个没有尝试"的静态HTML页面):将您的OpenAPI定义加载到 http://editor.swagger.io ,然后选择菜单项 Generate Client> html html2 dynamic-html .

Generate static HTML docs (not Swagger UI, but a static HTML page without "try it out"): load your OpenAPI definition into http://editor.swagger.io, then select the menu item Generate Client > html or html2 or dynamic-html.

生成客户端"功能使用 Swagger Codegen ,因此您也可以使用CLI版本的Codegen以生成所需的输出.

The "Generate Client" feature uses Swagger Codegen, so you can also use the CLI version of the Codegen to generate the desired output.

是否需要PDF?可以将OpenAPI定义转换为PDF .

Want a PDF? It's possible to convert OpenAPI definitions to PDF.

另请参阅:

  • Generate static docs with Swagger
  • Converting Swagger specification JSON to HTML documentation

这篇关于是否可以获取网站的草率文档的脱机版本?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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