Member-only story

Your NodeJS TypeScript API is Nothing Without Swagger-UI

Sean Bradley
2 min readApr 14, 2019

Well, lets fix it then.

I have an existing NodeJS API and I want to add Swagger-UI to it. This makes the API look much more professional very quickly.

Before you continue, you may want to view a working copy of this Swagger UI I've built in this article at https://seans-typescript-nodejs-crud.herokuapp.com/swagger/

Lets Start Coding

  1. Install swagger-ui-express in your project.

npm -i swagger-ui-express --save

Your projects package.json should now contain a reference to swagger-ui-express and since I used the --save option, it will also be available when started with production settings. Use --save-dev if you prefer it to be only available when you run it in development mode.

2. Open your app.ts or whatever you called your main NodeJS API script and add import swaggerUi from ‘swagger-ui-express’ to the top.

3. Create a new file called swagger.json and paste some default text into it.

--

--

Sean Bradley
Sean Bradley

Written by Sean Bradley

Developer of real time, low latency, high availability, asynchronous, multi threaded, remotely managed, fully automated and monitored solutions.

Responses (1)