To enable the Swagger documentation, we need the swagger-ui-express package, and also need to load the JSON version of the YAML specs, so you'll need a couple of lines of code. First, install the package with the usual npm install swagger-ui-express --save, and then add the following lines to your server:
const swaggerUi = require("swagger-ui-express");
const swaggerDocument = require("../swagger.json");
In the server, we must also add a line for enabling the new route, at the beginning, after other app.use() statements. We are adding Swagger to our RESTful API, and without a token: you might prefer to set up a different server, only providing access to the API, and possibly also enabling authorization, but both changes will be easy to accomplish. So, let's go with the simpler version here:
app.use(cors());
app.use(bodyParser.urlencoded({ extended: false }));
app.use("/api-docs", swaggerUi.serve, swaggerUi.setup(swaggerDocument));
You're all set! After you rebuild the project and start the server, the new route will be available, providing online documentation for your server.