Skip to content

Commit 83abf19

Browse files
committed
docs: Update API documentation for clarity and formatting improvements
1 parent 8753a48 commit 83abf19

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

services/backend/API_DOCUMENTATION.md

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,41 +13,51 @@ The DeployStack Backend uses Fastify with Swagger plugins to automatically gener
1313
## Available Commands
1414

1515
### 1. Generate Complete API Specification
16+
1617
```bash
1718
npm run api:spec
1819
```
20+
1921
This command:
22+
2023
- Starts a temporary server
2124
- Generates both JSON and YAML specifications
2225
- Saves files to `api-spec.json` and `api-spec.yaml`
2326
- Provides URLs for interactive documentation
2427
- Automatically shuts down the server
2528

2629
**Output:**
30+
2731
- `api-spec.json` - OpenAPI JSON specification (for Postman import)
2832
- `api-spec.yaml` - OpenAPI YAML specification
2933

3034
### 2. Generate JSON Specification (requires running server)
35+
3136
```bash
3237
npm run api:spec:json
3338
```
39+
3440
Requires the development server to be running (`npm run dev`).
3541

3642
### 3. Generate YAML Specification (requires running server)
43+
3744
```bash
3845
npm run api:spec:yaml
3946
```
47+
4048
Requires the development server to be running (`npm run dev`).
4149

4250
## Usage Examples
4351

4452
### Complete Generation (Recommended)
53+
4554
```bash
4655
cd services/backend
4756
npm run api:spec
4857
```
4958

5059
### Manual Generation with Running Server
60+
5161
```bash
5262
# Terminal 1: Start the server
5363
cd services/backend
@@ -70,7 +80,7 @@ When the server is running (`npm run dev`), you can access:
7080

7181
1. Run `npm run api:spec` to generate the specification
7282
2. Open Postman
73-
3. Click "Import"
83+
3. Click "Import"
7484
4. Select the generated `api-spec.json` file
7585
5. All API endpoints will be imported with proper documentation
7686

@@ -171,12 +181,15 @@ await server.register(fastifySwagger, {
171181
## Troubleshooting
172182

173183
### "Route already declared" Error
184+
174185
This happens when trying to manually add routes that Swagger UI already provides. The `/documentation/json` and `/documentation/yaml` endpoints are automatically created.
175186

176187
### "Failed to fetch API spec" Error
188+
177189
Ensure the server is fully started before trying to fetch the specification. The generation script includes a 2-second delay to allow for complete initialization.
178190

179191
### Missing Route Documentation
192+
180193
Routes without schema definitions will appear in the specification but with minimal documentation. Add schema objects to routes for complete documentation.
181194

182195
## Next Steps

0 commit comments

Comments
 (0)