-
Notifications
You must be signed in to change notification settings - Fork 515
Closed
Labels
Description
Is there an existing issue for this?
- I have searched the existing issues
Current behavior
To transfer the __caslSubjectType__ between Backend and Frontend we use this approach in our base entity, which all other CASL relevant entities inherit from:
@ApiProperty({
enum: SubjectEnum,
enumName: 'Subject',
})
readonly __caslSubjectType__: SubjectEnum = this.constructor.name as SubjectEnum;This results in the following OpenAPI definition:
"__caslSubjectType__": {
"default": "Function",
"allOf": [
{
"$ref": "#/components/schemas/Subject"
}
]
},Minimum reproduction code
Steps to reproduce
This DTO is enough to trigger the behavior in conjunction with the @nestjs/swagger CLI plugin enabled.
import { ApiExtraModels, ApiProperty } from '@nestjs/swagger';
enum SubjectEnum {
SomeDto = 'SomeDto',
}
export class SomeDto {
@ApiProperty({ enum: SubjectEnum, enumName: 'Subject' })
readonly __caslSubjectType__: SubjectEnum = this.constructor
.name as SubjectEnum;
}Expected behavior
There should be no default. Also there seems no way to override/remove this default. Only this works setting it to null:
@ApiProperty({
enum: SubjectEnum,
enumName: 'Subject',
default: null,
})Package version
11.0.6
NestJS version
11.0.11
Node.js version
22.14.0
In which operating systems have you tested?
- macOS
- Windows
- Linux
Other
No response