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: TypeScript / NestJS
swaggeropenapidocumentationhttp
Keep API response decorators in sync with the statuses actually returned
OpenAPI response decorators are documentation; if the handler throws 502/500/404 the decorators must declare those, not a stale 400. Mismatched docs mislead consumers.
PR: hegnar-user-ws · org-mining-hist-2026-06Created: Jun 18, 2026
Bad example
Old codetypescript
| 1 | @ApiBadRequestResponse({ description: 'Failed to fetch external data' }) |
| 2 | async getMainWatchlist() { throw new BadGatewayException(); } |
Explanation (EN)
Objašnjenje (HR)
Good example
New codetypescript
| 1 | @ApiResponse({ status: 502, description: 'Failed to fetch external data' }) |
| 2 | @ApiNotFoundResponse({ description: 'Watchlist not found' }) |
| 3 | async getMainWatchlist() { throw new BadGatewayException(); } |
Explanation (EN)
Objašnjenje (HR)