A Node Express skeleton that comes with openapi/swagger already configured including routing with the help of the swagger-routes-express package.
- Clone the project by running from your command line git clone https://github.com/ReubenFrimpong/node-express-open-api-skeleton.git
- Navigate to the folder where you cloned the project and run
npm install
- Use
npm run startto start your server - Access the Swagger UI from
http://localhost:3000/api-docs/ - Access the defualt endpoint by making a GET request to
http://localhost:3000/v1/usersfrom Postman or any API testing tool of your choice.
- First add the name of the function you want to use as the value for operationId in your paths section of your OpenAPI file.
Example here - Add the controller file inside
./api/controllers - Define the function and export it
Example here - Inside
./api/index.jsimport the function you just added in the previous step and add it to the export listExample here
For more details into this project checkout my article here.