npm / @nestjs/swagger
@nestjs/swagger
What changed in @nestjs/swagger 6 to 12, from its official release notes, upgrade guides and advisories. Sources checked 2026-11-26.
26 breaking1 deprecations29 new APIs and options14 behavior and defaults1 tooling129 fixes and other
See which of these apply to your code, ranked, in your agent:
npx @unstale/cli init@nestjs/swagger 12102 changes
Breaking changes 18
Controllers without a documented endpoint no longer register their class-level models.
Metadata for a class's re-declared inherited property takes precedence over inferred parent metadata; decorator options still apply.
With a whitelisting ValidationPipe, documented properties without validators are stripped or rejected.
With a whitelisting ValidationPipe, documented properties without validators are stripped or rejected.
When the setup path ends in a route parameter, the aliases for the init script and static assets are no longer registered.
Static assets no longer serve directory index files.
swagger-ui-init.js ignores the docs page's url query parameter; use swaggerUrl or swaggerOptions.url / urls instead.
Schema-only keywords are moved from parameters into the schema.
The CLI plugin now detects esmCompatible per source file from package.json type and the module setting when the option is unset; an explicit nest-cli.json value still wins.
lodash is no longer a runtime dependency; this affects projects that relied on it arriving transitively.
The peer dependency range is now ^12.0.0, so projects using @nestjs/swagger must align with Nest 12.
The package moves to 12.0.0 and its mapped-type helpers come from an ESM build aligned with the Nest 12 line.
Version 12 requires TypeScript 6 as a peer dependency, so projects using TypeScript 5 must update TypeScript when upgrading the schematics package.
The package is published as pure ESM with an exports map; import from the package root or @nestjs/swagger/plugin, because deep imports into build internals are no longer resolvable.
The package requires Node ^20.19.0 or >=22.12.0, where require(esm) is available without a flag.
For OpenAPI 3.1.0 and later, nullable schemas are normalized without the nullable keyword: typed schemas use a type union, enums gain null, and references and composites use anyOf.
For OpenAPI 3.0.x, nullable responses use the nullable keyword again, with the allOf wrapper for references, instead of oneOf with a null schema.
Optional markers are no longer inherited when a subclass redeclares its constructor; in 12.0.x, a subclass without its own constructor also drops the markers. Missing dependencies can therefore throw UnknownDependenciesException instead of resolving to undefined.
New APIs and options 4
Support is added for the HTTP QUERY method (RFC 10008).
With introspectComments enabled, JSDoc @param tags matched by route-parameter name set descriptions on generated @ApiQuery or @ApiParam decorators; existing explicit decorators are untouched.
Route parameter decorator schemas compatible with Standard Schema can also feed OpenAPI generation.
This new document option converts Standard Schema values into OpenAPI schemas, can register extra components, and falls back to the DTO-derived schema when it returns undefined.
Behavior and default changes 7
Global parameters apply only to documents created from that builder's config.
Global responses apply only to documents created from that builder's config.
Each call returns a new copy.
The swagger-ui-dist license file is never served.
Mapped type names are resolved when they are read.
Routes sharing a path and method document the union of their security requirements.
Strips the example depth limit from parameters.
Fixes and other changes 73
Dynamic defaults are stripped from additional properties.
Inferred additional properties are dropped beside a combinator.
Re-declaring a property preserves its inherited type.
Numeric constraints on arrays are moved to their items.
Explicit items and type are preserved on array properties with combinators.
Callback request body schemas are registered.
Class-level params are documented on inherited routes.
An enum member is imported through its enum's specifier.
A trailing slash is stripped from the global prefix during setup.
Inferred success responses remain next to error decorators.
Transformers no longer stack when using IntersectionType.
Inferred types are kept out of mapped explicit options.
Plugin metadata is read before nested default keys are selected.
Required keys are preserved for nested object literal properties.
Object typed query properties are kept inline.
Comment metadata is merged into explicit operation decorators.
Metadata for classes missing from the loaded module is skipped.
Enum component types are inferred from query DTO properties.
Single enum member types emit an enum array.
Method shorthand options are serialized into valid JavaScript.
Falsy example values are preserved.
API links use the operation id set with @ApiOperation.
Explicit items specified for array parameters are preserved.
Length constraints for array parameters are moved to the items.
Arrays of bigint properties are documented as arrays.
Headers declared on both a controller and a method are merged.
Global response types and descriptions are normalized.
Example values remain strings for optional string properties.
Numeric exclusive bounds are emitted correctly in OpenAPI 3.1 documents.
OpenAPI 3.1 keywords for parameters are moved into the schema.
Dynamic defaults are stripped from operation schemas.
An explicitly declared type is preserved when a schema combinator is declared.
Array types written as a tuple are documented correctly.
Hides properties inherited from a parent class, and takes precedence when a property also has ApiProperty.
ApiIncludeEndpoint(false) counts as not decorated under onlyIncludeDecoratedEndpoints.
A default holding a model lists only the properties that model documents.
The plugin reads @example values written on the line after the tag and preserves apostrophes in double-quoted values.
Function enums are resolved when the document is generated.
The swagger-ui-dist demo page is never served.
Nullable is moved into the schema of schema and standard schema responses.
OmitType and PickType now match numeric keys.
Inline schema names spell only documented keys, and numeric keys are matched.
Inline schema names spell only documented keys, and numeric keys are matched.
Re-declaring an inherited property resets its required status.
Links to operations absent from the document are removed.
Function-valued standard schemas are read.
The plugin preserves the type of unions containing both null and undefined.
For OpenAPI versions below 3.1, a webhook sharing a route's path and method is left out with a warning instead of replacing the route.
Keeps every @ApiOperation argument when adding comments, preventing operation metadata from being lost.
Preserves explicit global imports during deep scans.
Preserves the summary and every @throws entry in readonly metadata.
Fixes resolution of UI assets for index.html and requests with query strings.
Method-level consumes and produces settings no longer leak across methods.
A custom Swagger UI path is served correctly under nested routes.
Date and bigint response and body types map to scalar schemas.
DeepPartialType is cached separately for each skipNullProperties setting.
Nested DeepPartial types receive distinct schema names.
Default responses are converted in OpenAPI 3.1 documents.
The plugin gives a node_modules subpath its extension under ESM.
Non-standard HTTP methods are kept off path item fields.
Constraints from parameters and schemas are merged into allOf.
Parameter schema options such as example are kept when a schema is set.
Parameter allOf, $ref siblings, enum, and required are handled consistently.
The plugin strips the resolution-mode attribute in CommonJS output.
The plugin preserves false defaults in synthetic identifiers.
Standard schema query parameters are merged with @ApiQuery.
The package is resolved through a bundler-visible dynamic import.
A standard-schema description is promoted to the parameter object.
The plugin treats single literal types as enums.
The generated file preserves $ characters when it is built.
TypeScript is declared as an optional peer dependency.
The plugin keeps the source package specifier for workspace imports.
Fixes hoisting of static imports in ESM.
@nestjs/swagger 1178 changes
Breaking changes 2
The pet store definition is no longer served on api/api.
This version is only compatible with @nestjs/core, @nestjs/common, @nestjs/platform-express, @nestjs/platform-fastify, and related packages at v11 or higher.
Deprecations 1
Warns when @ApiTags receives hierarchy fields.
New APIs and options 17
Support custom OpenAPI extensions in API header definitions.
Generate object examples from @example doc tags.
Export full OpenAPI object-model types in the public API.
@ApiQuery supports custom OpenAPI extensions.
Adds a summary field to the OpenAPI Tag Object for OpenAPI 3.2.
Adds ApiIncludeEndpoint.
The plugin auto-generates enum metadata for string and number literal union types.
The plugin supports boolean literal types and boolean enum values.
Adds support for OpenAPI 3.2 hierarchical tags.
The ApiBody decorator supports encoding.
The ApiHeader decorator accepts an example property.
The plugin option suppresses duplicate enum schemas.
A mapped-type helper provides recursive optional properties.
This option strips runtime-evaluated schema defaults.
The generateSchema utility is exposed for programmatic schema access.
Supports adding custom fields to entries in servers[*].
The schema object metadata interface now accepts the file type.
Behavior and default changes 5
The plugin infers the ApiParam enum from literal-union types used with @Param.
The pattern option accepts RegExp instances.
Descriptions are merged when multiple decorators share the same HTTP status code.
The patchDocumentOnRequest hook supports asynchronous implementations.
Generated require() is ESM compatible.
Tooling 1
Adds a type definition for the format option in the @ApiProperty decorator.
Fixes and other changes 52
Preserve inferred responses for enum error statuses.
Apply deep partial substitution to plugin metadata.
The plugin handles decorators with property access expressions when resolving identifiers.
Rebase readonly import paths onto the output directory.
Nested DTO arrays retain their array-ness when using DeepPartialType.
Objects are cloned per mimetype to avoid shared references.
Inline PickType schemas no longer collide.
The response object now includes the missing summary type.
The plugin now generates additionalProperties for Record and index-signature types.
Types the Tag Object kind as a free-form string.
Fixes an issue involving top-level nullable schemas with a discriminator.
Replies from async route handlers are now returned.
Const enum query parameters are now supported.
Preserves example and examples for built-in scalar response types.
Places multipleOf inside the parameter schema.
Keeps the auto-inferred default response when only error Api*Response decorators are present.
Handles IsIn enum inference when the type falls back to Object.
Fixes duplicate keys when @ApiOperation is auto-generated.
@ApiHeader now forwards all OpenAPI parameter fields.
Circular dependency errors include the class name chain to help identify the dependency path.
Example metadata is preserved for non-body parameters with named types.
The plugin strips regex delimiters and flags from @Matches patterns.
The document builder accepts OpenAPI version strings with multi-digit segments.
The plugin automatically marks optional @Query parameters as required: false.
The plugin emits @throws descriptions as proper string literals.
The plugin remaps import paths within rootDir to outDir.
Supports enumName with oneOf and anyOf combinators.
Prioritizes oneOf, anyOf, and allOf over inferred type resolution when generating schemas.
Adjusts plugin relative import paths for tsconfig outDir depth, fixing generated imports when output directories are nested.
When an inherited property is redeclared, the child class type is used.
Nullable fields are now supported in the ApiResponse decorator.
An enum issue is fixed.
Plugin metadata properties are eagerly applied in mapped type helpers.
Workspace package import paths are normalized in the metadata generator.
Schemas include a type field when nullable is used with allOf.
Same-file type references are handled in SWC readonly metadata generation.
The plugin skips the auto-generated response decorator when an Api*Response decorator is already present.
Schema generation handles const enum objects from SWC compiler metadata.
The decorators no longer crash on a Controller getter.
Enum schemas are no longer mutated across multiple document generations.
operationIdFactory receives the version for all versioning types.
The plugin handles non-ASCII characters in project paths.
The plugin supports TypeScript project references in ReadonlyVisitor.
Adds string literal types to ApiQueryOptions for autocomplete.
The plugin's debug option is respected for all debug log messages.
Static asset loading is resolved when the path has a trailing slash.
Preserves the items schema when metadata.items is already defined.
The plugin no longer adds an async modifier when a reference is an await import statement.
The plugin adds the async modifier when a reference is an await import statement.
When used on a controller, @ApiExtension applies to all methods.
Fixes missing ApiProperty enum undefined handling for arrays.
Corrects plugin handling of enum values combined with nullable types such as Enum | null.
@nestjs/swagger 816 changes
Breaking changes 5
API tags now default to the controller name.
Specific ApiResponse decorator option types now omit status.
Moves modifier properties to the items object on array types.
The transformer now prefers explicit configuration over an auto-detected schema.
Swagger module methods are now protected.
New APIs and options 7
Adds a decorator for defining API callbacks.
Supports multiple response body examples in the ApiResponse annotation.
Adds a decorator for specifying the schema type name.
Adds a merge-options condition for dtoFileNameSuffix to the CLI plugin.
Introduces an enum schema attribute.
Adds support for OpenAPI link objects.
Adds a document-builder method for setting the OpenAPI version.
Behavior and default changes 1
Extends support for validation property assignments.
Fixes and other changes 3
Fixes plugin metadata so enum arrays are marked as arrays.
Fixes importing external enums.
Fixes handling of arrays and objects located at the first level of @Query().
@nestjs/swagger 73 changes
Breaking changes 1
Support for TypeScript versions below 4.8 is dropped, so projects must use TypeScript 4.8 or newer.
New APIs and options 1
The document can be initialized lazily.
Fixes and other changes 1
@nestjs/swagger adds support for NestJS v10.
@nestjs/swagger 61 changes
Behavior and default changes 1
Swagger routing is no longer tied to a specific platform, allowing it to work across platform adapters.