使用 swagger 生成静态文档 [英] Generate static docs with swagger

查看:53
本文介绍了使用 swagger 生成静态文档的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否有为 swagger 2.0 创建静态文档的方法?也许就像 editor.swagger.io 上的预览"一样.

Is there a method for creating static documentation for swagger 2.0? Perhaps like the 'preview' on editor.swagger.io.

我需要获取静态 html 文件,以便我可以将它们包含在一些静态文档中.

I need to get static html files so I can include them in some static documents.

到目前为止,我还没有找到一种方法来做到这一点.我看到有 swagger-codegens static-docs但这仅适用于 swagger <= 1.2.

So far I've not found a way to do this. I see there is swagger-codegens static-docs but this only works for swagger <= 1.2.

推荐答案

使用 swagger-codegen:

swagger-codegen generate -i <path to your swagger file> -l html2 -o <path to output location>

如果您决定自定义 HTML 模板:

  1. github
  2. 克隆 swagger-codegen 项目
  3. modules/swagger-codegen/src/main/resources/htmlDocs2文件夹复制到另一个地方,例如:cp -R modules/swagger-codegen/src/main/resources/htmlDocs2 ~/templates
  4. 修改 ~/templates 中的 .mustache 模板以满足您的要求.
  5. 运行:swagger-codegen generate -i <你的swagger文件的路径>-l html2 -o <输出位置的路径>-t <templates path> 对于 应该是 ~/templates 在上面的例子中.
  1. Clone the swagger-codegen project from github
  2. Copy modules/swagger-codegen/src/main/resources/htmlDocs2 folder to another place, for example: cp -R modules/swagger-codegen/src/main/resources/htmlDocs2 ~/templates
  3. Modify the .mustache templates in ~/templates to fit your requirements.
  4. Run: swagger-codegen generate -i <path to your swagger file> -l html2 -o <path to output location> -t <templates path> for <templates path> should be ~/templates in the example above.

这篇关于使用 swagger 生成静态文档的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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