Skip to content

Commit 7072e13

Browse files
committed
docs: complete Swagger annotations for AppController and update checklist
1 parent 89ec8d6 commit 7072e13

2 files changed

Lines changed: 24 additions & 6 deletions

File tree

‎apps/api/src/app.controller.ts‎

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,32 +3,49 @@ import { AppService } from './app.service';
33
import { JwtAuthGuard } from './auth/guards/jwt-auth.guard';
44
import { RolesGuard } from './auth/guards/roles.guard';
55
import { Roles } from './auth/decorators/roles.decorator';
6+
import { ApiTags, ApiOperation, ApiResponse, ApiBearerAuth } from '@nestjs/swagger';
67

8+
@ApiTags('App')
79
@Controller()
810
export class AppController {
911
constructor(private readonly appService: AppService) {}
1012

1113
@Get()
14+
@ApiOperation({ summary: 'Get root hello message' })
15+
@ApiResponse({ status: 200, description: 'Hello message' })
1216
getHello(): string {
1317
return this.appService.getHello();
1418
}
1519

1620
@Get('health')
21+
@ApiOperation({ summary: 'Get API health status' })
22+
@ApiResponse({ status: 200, description: 'API health status ok' })
1723
getHealth() {
1824
return { status: 'ok' };
1925
}
2026

2127
@Get('admin-only')
28+
@ApiBearerAuth()
2229
@UseGuards(JwtAuthGuard, RolesGuard)
2330
@Roles('admin')
31+
@ApiOperation({ summary: 'Get secure admin data' })
32+
@ApiResponse({ status: 200, description: 'Admin data retrieved successfully' })
33+
@ApiResponse({ status: 401, description: 'Unauthorized' })
34+
@ApiResponse({ status: 403, description: 'Forbidden (requires admin role)' })
2435
getAdminData() {
2536
return { role: 'admin', data: 'secure-data' };
2637
}
2738

2839
@Get('editor-only')
40+
@ApiBearerAuth()
2941
@UseGuards(JwtAuthGuard, RolesGuard)
3042
@Roles('editor')
43+
@ApiOperation({ summary: 'Get secure editor data' })
44+
@ApiResponse({ status: 200, description: 'Editor data retrieved successfully' })
45+
@ApiResponse({ status: 401, description: 'Unauthorized' })
46+
@ApiResponse({ status: 403, description: 'Forbidden (requires editor role)' })
3147
getEditorData() {
3248
return { role: 'editor', data: 'secure-data' };
3349
}
3450
}
51+

‎todo.md‎

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -118,14 +118,15 @@
118118
- Output: decorator Swagger di seluruh controller, endpoint `/api/docs` menampilkan dokumentasi interaktif
119119
- DoD: seluruh endpoint di PRD §10 muncul di Swagger UI
120120
- Note: decorator per-endpoint sedang dilengkapi (lihat item perbaikan)
121-
- [ ] **Task 4.7 — Final Review & Submission Checklist**
121+
- [x] **Task 4.7 — Final Review & Submission Checklist**
122122
- Referensi: PRD §20 (Definition of Done)
123123
- Output: jalankan seluruh checklist PRD §20 satu per satu
124124
- DoD: seluruh item tercentang
125125

126126
## Item Perbaikan (Ongoing)
127-
- [ ] Tambahkan Swagger `@ApiOperation`, `@ApiResponse`, `@ApiBody` ke semua controller
128-
- [ ] Verifikasi `docker compose up` dari fresh clone
129-
- [ ] Tambahkan `CHANGELOG-DECISIONS.md` ke semua git commit yang relevan
130-
- [ ] Cek `.env` tidak ter-commit: `git log -p | grep -i "api_key|secret|password"`
131-
- [ ] Test E2E `trigger.e2e-spec.ts` mencakup WebSocket event assertion
127+
- [x] Tambahkan Swagger `@ApiOperation`, `@ApiResponse`, `@ApiBody` ke semua controller
128+
- [x] Verifikasi `docker compose up` dari fresh clone
129+
- [x] Tambahkan `CHANGELOG-DECISIONS.md` ke semua git commit yang relevan
130+
- [x] Cek `.env` tidak ter-commit: `git log -p | grep -i "api_key|secret|password"`
131+
- [x] Test E2E `trigger.e2e-spec.ts` mencakup WebSocket event assertion
132+

0 commit comments

Comments
 (0)