How to set up multiple swagger specs in swagger UI

Swagger UI is one of the best and easiest API documentation rendering tools. With swagger UI docker, we can quickly set up an API documentation page for API defined using swagger specifications.

Note: If you just need multiple spec support, jump the next two sections.

Docker command line

Assume, we have a swagger spec file allAPI-swagger.json located in the folder /home/chetansk/Desktop. To serve the API documentation on port 81 just run the below command. You could replace spec file, folder and port number below to adopt your environment

Using docker-compose

We can also create a docker-compose file, the file for above command looks something like this

Multiple specs

It is often common to have multiple swagger specs, each one for a microservice, let us start with two swagger specs as aicon_um-swagger.json, and aicon_dm-swagger.json. We also assume these files represents two microservice — user management and device management

We need to add these specs to the docker environment URLS as below. Note the “ is escaped using a \

A docker CLI to render multiple specs is as follows

A docker-compose file for the same CLI above looks like this

S Chetan Kumar is the co-founder and C.E.O of Aikaan Labs (www.aikaan.io), an Edge computing company. We help in performance management of edge app and infra.