How to use Redocly tool for API specification generation

In this blog, we are going to see how to use Redocly in our day-to-day life. Redocly is the best tool to visualize and understand the Open API specification files

Few command line utilities you must know

Prerequisites to use Redocly

You must install npx from the node use the below command to install npx

npm install -g npx

Redocly CLI commands

Build HTML document from Open API specification

to build the document use the following command

npx @redocly/cli build-docs <open_api_file>

This command will create a document for a given Open API specification file. The redoc-static.html file will be generated as an output on the same directory.

For example,

npx @redocly/cli build-docs spring-crud.yaml

you can also specify --output=your_custome_file_name.html to create a document with your document name. For more options check here.

Check errors in the open API specification

check if the API specification is correctly formed and if it has any errors

npx @redocly/cli lint <open_api_file>

Combine the spec files into one

npx @redocly/cli bundle <rootfileName> -o output_fileName.yml

Leave a Comment