Skip to content

Commit 51bed95

Browse files
feat: Add Swagger and Postman support (#5)
This commit introduces Swagger UI for interactive API documentation and a Postman collection for easy API testing. - Adds `swagger-ui-express` and `swagger-jsdoc` to handle documentation generation and serving. - Implements JSDoc comments across all API routes in `src/routes/api.js` to define the API specification. - Creates a new endpoint, `/api-docs`, to serve the interactive Swagger UI. The UI is pre-configured to use the master API key for immediate testing. - Generates a `whatsapp_api_collection.json` file in the root directory. The collection includes all endpoints and a pre-request script to manage the `X-MASTER-KEY` header automatically. - Updates `README.md` with a new "API Documentation" section, explaining how to access the Swagger UI and import the Postman collection. Co-authored-by: google-labs-jules[bot] <161369871+google-labs-jules[bot]@users.noreply.github.com>
1 parent 0bee942 commit 51bed95

8 files changed

Lines changed: 728 additions & 4 deletions

File tree

‎README.md‎

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,28 @@ If you prefer not to use Docker Compose, you can build and run the container man
142142
143143
## 📖 API Documentation
144144
145+
This project includes interactive API documentation powered by Swagger UI and a pre-configured Postman collection to make testing and integration as easy as possible.
146+
147+
### **Swagger UI**
148+
149+
Once the server is running, you can access the interactive Swagger UI in your browser. This interface allows you to view all available endpoints, see their parameters, and test them live.
150+
151+
- **URL**: [http://localhost:3000/api-docs](http://localhost:3000/api-docs)
152+
153+
When you open the Swagger UI, the `X-MASTER-KEY` will be pre-authorized with the default value (`SUPER_SECRET_KEY` or the value from your `.env` file), so you can start making requests to the protected endpoints immediately.
154+
155+
### **Postman Collection**
156+
157+
A Postman collection is included in the root of this project to help you get started quickly.
158+
159+
1. **Import the Collection**:
160+
- Find the `whatsapp_api_collection.json` file in the project's root directory.
161+
- In Postman, click **Import** and upload the file.
162+
163+
2. **Configure Environment (Optional)**:
164+
- The collection comes with a pre-request script that automatically adds the `X-MASTER-KEY` header to every request.
165+
- By default, it uses `SUPER_SECRET_KEY`. To use your own key, create a new Postman Environment, add a variable named `MASTER_API_KEY`, and set its value to your key from the `.env` file.
166+
145167
All endpoints are prefixed with `/api`.
146168
147169
### **Authentication**

0 commit comments

Comments
 (0)