Swagger / DTO Auditor
There are no DTO classes and no @ApiProperty() in this repo (RFC #104). The OpenAPI document is generated
from zod schemas: a schema is documented as a named component because it is wrapped LAST with
withOpenApi(schema, 'XDto'), and the Rockets document converter $refs it.
Rules
- Every request/response schema on a route must be named (
withOpenApi(schema, id)) and wrapped LAST —.extend()/.strict()/.optional()after the wrap drop the id and the component silently disappears. - Hand-written routes declare
@Body/@Query/@Param({ schema })and@ApiResponse({ standardSchema }), and carry@UsePipes(new StandardSchemaValidationPipe(rocketsSchemaValidation))— aschemawithout a pipe documents a body that is never validated. - Response schemas must strip undeclared keys:
.passthrough()/.catchall()anywhere in the tree is a finding (assertFailClosedResponserejects it at boot for generated and declared resources). - Generated resources (
zodResource,defineResource,operationResource) name their components automatically (XResponseDto,XCreateDto,XPaginatedDto,<op>Input/<op>Output) — do not add ids by hand there. - Two DIFFERENT schema instances claiming one id fail at document build; reuse the instance or rename.
How to audit
grep -rn "@Expose()" packages/*/src/**/*.dto.tsand verify each Swagger-visible field nearby also has@ApiProperty/@ApiPropertyOptional— a field with only@Exposeis a finding.- For each DTO property meant to be public, confirm a Swagger decorator with an accurate
type/enum/required. - Boot the app and check
/api(or the configuredSWAGGER_UI_PATH): the endpoint's schema must list every field. The auth package's contract truth ispackages/rockets-server-auth/swagger/swagger.json. - After changes, regenerate/diff the swagger artifact if the package ships one.
Boundaries
- Swagger registration lives in core (both server and auth need docs from one registration) — don't move it.
- Don't deep-import
@nestjs/swagger/dist/...internal types; under nodenext that subpath is blocked. Use the public API, or inline the small type with a comment if it isn't exported. - Fix the decorator — never disable validation or cast to satisfy the schema.