Skip to content

Commit

Permalink
test: add e2e test to ensure proper enum schema generation #2179
Browse files Browse the repository at this point in the history
  • Loading branch information
kamilmysliwiec committed Oct 28, 2024
1 parent 882c0d4 commit 31eb40f
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 0 deletions.
16 changes: 16 additions & 0 deletions e2e/api-spec.json
Original file line number Diff line number Diff line change
Expand Up @@ -442,6 +442,22 @@
"type": "object"
}
},
{
"name": "catBreeds",
"required": true,
"in": "query",
"schema": {
"type": "array",
"items": {
"type": "string",
"enum": [
"persian",
"siamese",
"maine-coon"
]
}
}
},
{
"name": "x-tenant-id",
"in": "header",
Expand Down
6 changes: 6 additions & 0 deletions e2e/src/cats/cats.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import { CatsService } from './cats.service';
import { Cat } from './classes/cat.class';
import { CreateCatDto } from './dto/create-cat.dto';
import { LettersEnum, PaginationQuery } from './dto/pagination-query.dto';
import { CatBreed } from './enums/cat-breed.enum';

@ApiSecurity('basic')
@ApiBearerAuth()
Expand Down Expand Up @@ -104,6 +105,11 @@ export class CatsController {
{ lang: 'JavaScript', source: "console.log('Hello World');" }
])
@ApiExtension('x-multiple', { test: 'test' })
@ApiQuery({
name: 'catBreeds',
enum: CatBreed,
isArray: true
})
@ApiTags('tag1')
@ApiTags('tag2')
findAll(@Query() paginationQuery: PaginationQuery) {}
Expand Down
5 changes: 5 additions & 0 deletions e2e/src/cats/enums/cat-breed.enum.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
export enum CatBreed {
Persian = 'persian',
Siamese = 'siamese',
MaineCoon = 'maine-coon'
}

0 comments on commit 31eb40f

Please sign in to comment.