简体   繁体   中英

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. I want to use the swagger-js project to generate a client side SDK in Javascript from the Swagger data on the server.

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

For example, if my client side SDK has been generated from the Swagger data and has these methods:

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.

Take a look at [1] jsdoc to generate the documentation for the auto-generated javascript client 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. But try it out.

[1] http://usejsdoc.org/

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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