Repository navigation
Conversation
The OpenAPI document reads the app's versioning config when it builds its paths, so generating it before enableVersioning left the version prefix out of every documented path (e.g. /things instead of /v1/things). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Swagger's class-based reflection cannot handle controller parameters typed as Zod schemas: bodies produced an empty $ref that crashed Redoc, and unnamed query/path/header parameters crashed the app at startup. The new generator resolves routes the same way the Nest router does and documents parameters from their Zod schemas via z.toJSONSchema, emitting an OpenAPI 3.1 document. Redoc is pinned to v2.5.4. BREAKING CHANGE: API docs are generated from the Zod schemas that controller parameters are typed with. @nestjs/swagger decorators are no longer read, and @ValidationSchema is deprecated. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Lets route handlers set the summary, description, and deprecation status of their operation in the generated OpenAPI document. The options mirror the ones from @nestjs/swagger, so existing usages only need a new import. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #79 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 62 64 +2
Lines 739 838 +99
Branches 125 147 +22
=========================================
+ Hits 739 838 +99 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
|
🎉 This PR is included in version 9.0.0 🎉 The release is available on: Your semantic-release bot 📦🚀 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
API docs were broken for any app that types controller parameters as Zod schemas, the pattern where a type and a schema share a name, e.g.
@Body() data: $CreateCatData. SWC's decorator metadata emits the schema instance itself as the parameter type, and@nestjs/swaggerassumes every parameter type is a class:$ref: "#/components/schemas/", which made Redoc fail with "Invalid reference token". This is why/docsin the example app was broken.@Query()/@Param()/@Headers(), such as Clinivance's@SearchParams(), crashed the app at startup withCannot read properties of undefined (reading 'constructor').What changed
fix(app)).configureDocsnow runs afterenableVersioning, so documented paths include the version prefix (/v1/...).feat(docs), breaking). It replaces@nestjs/swagger:PathsExplorerandRoutePathFactory. That covers versioning, the global prefix andRouterModulepaths.@Body()becomes the request body. Unnamed Zod query, path and header parameters become one parameter per property. Named parameters are documented from their Zod schema or primitive type. Any other type is documented as unknown.z.toJSONSchema, so enums, nullables, defaults and descriptions are kept. Dates are documented asdate-timestrings. Schemas with.meta({ id })become shared components, and recursive schemas get unique names.styles.csslink is gone.@ValidationSchemais deprecated. Classes using it are documented as unknown.ApiOperationdecorator (feat(docs)). It sets an operation'ssummary,descriptionanddeprecatedflag. The options mirror@nestjs/swagger's, so existing usages only need a new import.Breaking changes
@nestjs/swaggerdecorators (@ApiProperty,@ApiTags, swagger's@ApiOperation) no longer affect the docs.@ValidationSchemais deprecated. It still validates, but its classes are documented as unknown.Not included
@nestjs/swaggerdependency is still inpackage.json. No code imports it any more. Removing it should be a follow-up commit, run outside the Claude Code sandbox: inside it, pnpm can't read~/.npmrcand rewrites the whole lockfile.Promise, so they would need an explicit decorator. That will be a separate issue.Testing
RouterModule, records every route Fastify registers, and asserts the spec lists exactly those method and path pairs. This guards the Nest internals the generator relies on./docspage renders in Redoc with no errors.🤖 Generated with Claude Code