Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to generate API Documentation using openapi-generator?

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.

like image 205
Arun Avatar asked Jan 14 '20 03:01

Arun


People also ask

Does OpenAPI generate code?

As the name suggests, the OpenAPI Generator generates code from an OpenAPI specification. It can create code for client libraries, server stubs, documentation and configuration. It supports various languages and frameworks.

How do I create API document in Swagger?

Head over to Swagger Inspector, and insert the end point of the resource you want to have documented. You can then navigate to the right panel from the History section of Swagger Inspector, and click "Create API definition" to create the OAS definition.

How does OpenAPI generator work?

OpenAPI Generator is a tool designed to create API client libraries, server stubs, configurations, and documentation from OpenAPI 2.0 and 3. x documents. It boasts a wide range of functions and is used by a wide range of users, some of whom are also maintainers.


1 Answers

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.

like image 173
Jinlye Avatar answered Oct 29 '22 04:10

Jinlye