Documenting an existing API
Adopt nestjs-docfy incrementally in a Nest project that already has Swagger set up.
Steps
- Install the package (see Installation).
- Register
DocfyModule.forRoot()in yourAppModule. - Add
@WithDocs()to an existing controller. - Run
npx nestjs-docfy generate(or--dry-runfirst, to preview what would be written) to generate the*.controller.docs.tsfile alongside the controller, already pre-filled with summaries and responses inferred viadocs(), without touching the controller's logic. - Edit the generated file to fill in anything specific to your domain.
- Run
npx nestjs-docfy coverageto measure progress and iterate. - Once you're satisfied, enable
DocfyModule.forRoot({ strict: true })so that any controller marked without a docs file fails at startup.