-
Notifications
You must be signed in to change notification settings - Fork 514
Open
Labels
Description
Is there an existing issue for this?
- I have searched the existing issues
Current behavior
export enum XEnumTest {
APPROVED = 1,
PENDING,
REJECTED
}
export class Cat {
@ApiProperty({
description: 'The x-enumNames test',
enum: XEnumTest,
enumName: 'XEnumTest',
'x-enumNames': ['APPROVED', 'PENDING', 'REJECTED']
})
xEnumTest: XEnumTest;
}
@Controller()
export class AppController {
constructor(private readonly appService: AppService) {}
@ApiResponse({
description: 'The record has been successfully created.',
type: () => Cat
})
@Get()
getHello(): string {
return this.appService.getHello();
}
}
creates JSON schema:
"schemas": {
"XEnumTest": {
"type": "number",
"enum": [
1,
2,
3
]
},
"Cat": {
"type": "object",
"properties": {
"xEnumTest": {
"description": "The x-enumNames test",
"x-enumNames": [
"APPROVED",
"PENDING",
"REJECTED"
],
"allOf": [
{
"$ref": "#/components/schemas/XEnumTest"
}
]
}
},
"required": [
"xEnumTest"
]
}
}
x-enumNames
is in CreateCatDto
Minimum reproduction code
https://stackblitz.com/edit/nestjs-typescript-starter-lmhdf2fg
Steps to reproduce
- npm i
- npm start
- open /api-docs-json
Expected behavior
"schemas": {
"XEnumTest": {
"type": "number",
"enum": [
1,
2,
3
],
"x-enumNames": [
"APPROVED",
"PENDING",
"REJECTED"
]
},
"Cat": {
"type": "object",
"properties": {
"xEnumTest": {
"description": "The x-enumNames test",
"allOf": [
{
"$ref": "#/components/schemas/XEnumTest"
}
]
}
},
"required": [
"xEnumTest"
]
}
}
x-enumNames
array must be in XEnumTest
Package version
8.1.1
NestJS version
10.4.15
Node.js version
22.10.0
In which operating systems have you tested?
- macOS
- Windows
- Linux
Other
No response