Rules Hub
Coding Rules Library
← Back to all rules
Rule priority, scope & exceptions
Use this to align rules with the senior-level structure (P0/P1/P2, scope, exceptions/tradeoffs).
backend ruleP2stack specificStack: NestJS / Swagger
api-docsswaggererror-handlingdocumentation
Document error responses and add examples in API schemas
Endpoints should declare their error responses (e.g. ApiNotFoundResponse) with a description and example payload, not only the success case.
PR: hegnar-shareholders-ws · org-mining-hist-2026-06Created: Jun 18, 2026
Bad example
Old codetypescript
| 1 | @ApiOkResponse({ type: ProfileDto }) |
| 2 | async getProfile() {} |
Explanation (EN)
Objašnjenje (HR)
Good example
New codetypescript
| 1 | @ApiOkResponse({ type: ProfileDto }) |
| 2 | @ApiNotFoundResponse({ description: 'No profile for the provided id' }) |
| 3 | async getProfile() {} |
Explanation (EN)
Objašnjenje (HR)