Observed since 20 Oct, 22:33 UTC
No superseded metadata states collected. Unchanged observations do not create new revisions.
Nest - modern, fast, powerful node.js web framework (@swagger)
A progressive Node.js framework for building efficient and scalable server-side applications.
OpenAPI (Swagger) module for Nest.
tl;dr see https://github.com/nestjs/swagger/issues/723
The fork is 1:1 to the original project, but it adds a single feature: ApiModel({ name: string }) decorator to allow renaming of Swagger schemas.
This is useful for namespacing purposes, and as an escape hatch (when you simply can't avoid naming collisions between your classes, for any reason).
For example, you may prefer to use TypeScript namespaces to organize your typings and DTOs:
export namespace EntityV1HttpNS {
export namespace FooMethod {
export namespace Response {
export class Body {
@ApiProperty()
status: number;
}
}
}
}
export namespace ThingV1HttpNS {
export namespace BarMethod {
export namespace Response {
export class Body {
@ApiProperty()
message: string;
}
}
}
}
If you use both Body classes as a return type for your controller methods, @nestjs/swagger will generate an invalid Swagger spec due to a schema pathing collision.
And since TypeScript namespaces are a compile-time feature, it is not possible (or even preferable) for @nestjs/swagger to use namespace names to construct schema names during runtime.
@ApiModel() allows you to rename Body in a generated Swagger spec:
export namespace EntityV1HttpNS {
export namespace FooMethod {
export namespace Response {
@ApiModel({ name: 'EntityV1HttpNS.FooMethod.Response.Body' })
export class Body {
@ApiProperty()
status: number;
}
}
}
}
export namespace ThingV1HttpNS {
export namespace BarMethod {
export namespace Response {
@ApiModel({ name: 'ThingV1HttpNS.BarMethod.Response.Body' })
export class Body {
@ApiProperty()
message: string;
}
}
}
}
Now, @nestjs/swagger will generate two Swagger schemas EntityV1HttpNS.FooMethod.Response.Body and ThingV1HttpNS.BarMethod.Response.Body.
$ npm i --save @0x0c/nestjs-swagger
If you're currently using @nestjs/swagger@3.*, note the following breaking/API changes in version 4.0.
The following decorators have been changed/renamed:
@ApiModelProperty is now @ApiProperty@ApiModelPropertyOptional is now @ApiPropertyOptional@ApiResponseModelProperty is now @ApiResponseProperty@ApiImplicitQuery is now @ApiQuery@ApiImplicitParam is now @ApiParam@ApiImplicitBody is now @ApiBody@ApiImplicitHeader is now @ApiHeader@ApiOperation({ title: 'test' }) is now @ApiOperation({ summary: 'test' })@ApiUseTags is now @ApiTagsDocumentBuilder breaking changes (updated method signatures):
addTagaddBearerAuthaddOAuth2setContactEmail is now setContactsetHost has been removedsetSchemes has been removed (use the addServer instead, e.g., addServer('http://'))The following methods have been added:
addServeraddApiKeyaddBasicAuthaddSecurityaddSecurityRequirementsNest is an MIT-licensed open source project. It can grow thanks to the sponsors and support by the amazing backers. If you'd like to join them, please read more here.
Nest is MIT licensed.
Download counts and popularity will appear here as the collector receives them.
This describes our collected data; it is not a security assessment.
Observed since 20 Oct, 22:33 UTC
No superseded metadata states collected. Unchanged observations do not create new revisions.
package:63c534c983520a9062b6c26e39a168674bdb80cccdddad36cf81e737c88c7e5f