简体   繁体   English

如何使用swagger-js生成静态HTML文档?

[英]How to generate static HTML documentation with swagger-js?

I have a RESTful API with Swagger integrated in it, so can now use a browser to point at that server and see the Swagger UI documenting that API. 我有一个集成了Swagger的RESTful API,因此现在可以使用浏览器指向该服务器,并查看Swagger UI记录了该API。 I want to use the swagger-js project to generate a client side SDK in Javascript from the Swagger data on the server. 我想使用swagger-js项目从服务器上的Swagger数据以Javascript生成客户端SDK。

It appears to work to generate this client side SDK, and I can explore the SDK object by object and function by function in Chrome Developer Tools. 似乎可以生成此客户端SDK,并且我可以在Chrome开发者工具中按对象和按功能浏览SDK对象。 However, I'd like to somehow generate documentation for this client side SDK so users can read it to find the calls they want to make without having to explore laboriously in their browser development environment. 但是,我想以某种方式为该客户端SDK生成文档,以便用户可以阅读它来查找他们要进行的调用,而无需在浏览器开发环境中进行繁琐的探索。

For example, if my client side SDK has been generated from the Swagger data and has these methods: 例如,如果我的客户端SDK是从Swagger数据生成的,并且具有以下方法:

PetStore.addPet(petData)
PetStore.updatePet(petId, petData)
PetStore.deletePet(petId)

I'd like to have static documentation that users can read to know about these. 我想拥有可供用户阅读以了解这些内容的静态文档。 Is this possible? 这可能吗?

Swagger-codegen project has a switch to generate static HTML documentation when making an SDK in a given language, but strangely it does not support Javascript and instead leaves that to the swagger-js project which seems to have no way to make static documentation. Swagger-codegen项目可以切换为以给定语言制作SDK时生成静态HTML文档,但是奇怪的是,它不支持Javascript,而是将其留给了swagger-js项目,后者似乎无法制作静态文档。

Take a look at [1] jsdoc to generate the documentation for the auto-generated javascript client SDK. 看看[1] jsdoc可以为自动生成的javascript客户端SDK生成文档。 The quality of this documentation depends on the code comments in the javascript code so it will most likely not be good quality documentation. 本文档的质量取决于javascript代码中的代码注释,因此很有可能不是高质量的文档。 But try it out. 但是尝试一下。

[1] http://usejsdoc.org/ [1] http://usejsdoc.org/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM