How to generate API Documentation using openapi-generator?

大城市里の小女人 提交于 2021-01-18 06:40:46

问题


I'm new to the OpenAPI 3.0.0.

I have successfully created a java client library using an openapi-generator.

But OpenAPI Generator allows the generation of API client libraries (SDK generation), server stubs, documentation. So I want to know is there any commands or steps are available to generate HTML documentation and also to customize the documentation template.


回答1:


Old question, but for those still bumping into it. OpenApi Generator can do generation of html documentation from your yaml or json definition of your API.

openapi-generator generate -i PathToMyInputDefinitionFile.yaml -g html -o /PathToOutputFolder

Where html is the generator you want to use. Other generators include dynamic-html and html2. Also can emit as markdown. See https://openapi-generator.tech/docs/generators/

If using Docker, a full example would look like this:

docker run --rm -v ${PWD}:/local openapitools/openapi-generator:tagname generate -i /local/input.yaml -g html -o /local

PWD is present working directory (current directory) in the host, which you are mapping on to /local in the container. Adjust 'tagname' to suit, from https://hub.docker.com/r/openapitools/openapi-generator/tags Adjust input.yaml to be your input file yaml definition of your API.



来源:https://stackoverflow.com/questions/59727169/how-to-generate-api-documentation-using-openapi-generator

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!