Skip to content

Commit 31eb40f

Browse files
test: add e2e test to ensure proper enum schema generation #2179
1 parent 882c0d4 commit 31eb40f

3 files changed

Lines changed: 27 additions & 0 deletions

File tree

e2e/api-spec.json

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -442,6 +442,22 @@
442442
"type": "object"
443443
}
444444
},
445+
{
446+
"name": "catBreeds",
447+
"required": true,
448+
"in": "query",
449+
"schema": {
450+
"type": "array",
451+
"items": {
452+
"type": "string",
453+
"enum": [
454+
"persian",
455+
"siamese",
456+
"maine-coon"
457+
]
458+
}
459+
}
460+
},
445461
{
446462
"name": "x-tenant-id",
447463
"in": "header",

e2e/src/cats/cats.controller.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import { CatsService } from './cats.service';
1818
import { Cat } from './classes/cat.class';
1919
import { CreateCatDto } from './dto/create-cat.dto';
2020
import { LettersEnum, PaginationQuery } from './dto/pagination-query.dto';
21+
import { CatBreed } from './enums/cat-breed.enum';
2122

2223
@ApiSecurity('basic')
2324
@ApiBearerAuth()
@@ -104,6 +105,11 @@ export class CatsController {
104105
{ lang: 'JavaScript', source: "console.log('Hello World');" }
105106
])
106107
@ApiExtension('x-multiple', { test: 'test' })
108+
@ApiQuery({
109+
name: 'catBreeds',
110+
enum: CatBreed,
111+
isArray: true
112+
})
107113
@ApiTags('tag1')
108114
@ApiTags('tag2')
109115
findAll(@Query() paginationQuery: PaginationQuery) {}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
export enum CatBreed {
2+
Persian = 'persian',
3+
Siamese = 'siamese',
4+
MaineCoon = 'maine-coon'
5+
}

0 commit comments

Comments
 (0)