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 start
to 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/users
from 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.js
import 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
.