@@ -2,18 +2,15 @@ import express from "express";
22import bodyParser from "body-parser" ;
33import userRouter from "./users/views" ;
44import customerRouter from "./customers/views" ;
5- import expressOasGenerator from "express-oas-generator" ;
5+ import swaggerUI from "swagger-ui-express" ;
6+ import spec from "../api-spec.json" ;
67import { dbConnect } from "./database" ;
78
89const app = express ( ) ;
9- expressOasGenerator . handleResponses ( app , {
10- specOutputPath : "swagger.json" ,
11- specOutputFileBehavior : "merge" ,
12- swaggerDocumentOptions : undefined ,
13- } ) ;
1410
1511// Middleware to parse json request bodies
1612app . use ( bodyParser . json ( ) ) ;
13+ app . use ( "/api-docs" , swaggerUI . serve , swaggerUI . setup ( spec ) ) ;
1714
1815/**
1916 * Sub-routers for our main router, we should have one sub-router per "entity" in the application
@@ -32,8 +29,6 @@ app.post("/", (req, res) => {
3229 res . send ( req . body ) ;
3330} ) ;
3431
35- expressOasGenerator . handleRequests ( ) ;
36-
3732app . listen ( process . env . PORT || 3000 , async ( ) => {
3833 console . log ( "✅ Server is up and running" ) ;
3934 await dbConnect ( ) ;
0 commit comments