Swagger-dev-server streamlines the development process for users working with Swagger API Documentation (specially in NestJS). It seamlessly integrates with your backend development server to provide:
- Seamless Live Updates: Experience lightning-fast updates to your API documentation whenever you make changes to the source files. No more manual refreshes or delays!
- Effortless Integration: Works seamlessly with your existing Swagger setup, eliminating the need for additional configuration or infrastructure.
- Enhanced Productivity: Focus on code improvements and iteration rather than wasting time on manual doc updates. Hot reloading keeps your documentation in sync, streamlining your workflow.
- Improved Developer Experience: Say goodbye to tedious manual refreshes and enjoy a smoother, more efficient development experience.
-
Install the package:
npm install --save-dev swagger-dev-server or yarn add -D swagger-dev-server
-
Create a
.env
file:Create a
.env
file (if not already present) in your project's root directory and define the following environment variables:API_SYNC_FILES=./src/**/*.ts RELOAD_DELAY=5000 API_DOCUMENTATION_PORT=3081 # Documentation will run on this port PORT=3000 # Server port API_PATH= # Optional path prefix for the API documentation URL.
-
Add a start command in your package.json script to run it:
"start:swagger": "node ./node_modules/swagger-dev-server"
-
After running the backend server, execute the below command in a separate terminal:
npm run start:swagger or yarn start:swagger
Enjoy instant updates to your Swagger documentation and focus on what matters most - building amazing APIs!
- Ensure your backend development server is running and serving the API documentation at the specified port.
- Customize the environment variables as needed to match your project's configuration.
By leveraging swagger-dev-server, Swagger users can significantly enhance their development efficiency and experience a more streamlined workflow. Say goodbye to manual refreshes and hello to a more productive and enjoyable development process!
- Author: Dhrubo