Skip to content

Commit

Permalink
add params and queries to routes
Browse files Browse the repository at this point in the history
  • Loading branch information
Artur Kraft committed Mar 9, 2024
1 parent 2ee9b7c commit 16d1ea9
Showing 1 changed file with 28 additions and 28 deletions.
56 changes: 28 additions & 28 deletions test/explorer/swagger-explorer.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -938,7 +938,7 @@ describe('SwaggerExplorer', () => {
})
@ApiQuery({ name: 'order', enum: QueryEnum })
@ApiQuery({ name: 'page', enum: ['d', 'e', 'f'], isArray: true })
find(): Promise<Foo[]> {
find(@Param('objectId') objectId: ParamEnum): Promise<Foo[]> {
return Promise.resolve([]);
}
}
Expand All @@ -952,7 +952,7 @@ describe('SwaggerExplorer', () => {
})
@ApiQuery({ name: 'order', enum: QueryEnum })
@ApiQuery({ name: 'page', enum: ['d', 'e', 'f'] })
find(): Promise<Foo[]> {
find(@Param('objectId') objectId: ParamEnum, @Query('order') order: QueryEnum, @Query('page') page: 'd' | 'e' | 'f'): Promise<Foo[]> {
return Promise.resolve([]);
}
}
Expand All @@ -972,7 +972,7 @@ describe('SwaggerExplorer', () => {
enumName: 'QueryEnum',
isArray: true
})
findBar(): Promise<Foo> {
findBar(@Param('objectId') objectId: ParamEnum, @Query('order') order: QueryEnum, @Query('page') page: QueryEnum[]): Promise<Foo> {
return Promise.resolve(null);
}
}
Expand All @@ -985,7 +985,7 @@ describe('SwaggerExplorer', () => {
enum: [1, 2, 3],
enumName: 'NumberEnum'
})
findBar(): Promise<Foo> {
findBar(@Param('objectId') objectId: number): Promise<Foo> {
return Promise.resolve(null);
}
}
Expand All @@ -1010,6 +1010,15 @@ describe('SwaggerExplorer', () => {
'/globalPrefix/v3/modulePath/foos/{objectId}'
);
expect(routes[0].root!.parameters).toEqual([
{
in: 'path',
name: 'objectId',
required: true,
schema: {
type: 'string',
enum: ['a', 'b', 'c']
}
},
{
in: 'query',
name: 'page',
Expand All @@ -1030,15 +1039,6 @@ describe('SwaggerExplorer', () => {
type: 'number',
enum: [1, 2, 3]
}
},
{
in: 'path',
name: 'objectId',
required: true,
schema: {
type: 'string',
enum: ['a', 'b', 'c']
}
}
]);
});
Expand All @@ -1056,12 +1056,12 @@ describe('SwaggerExplorer', () => {

expect(routes[0].root!.parameters).toEqual([
{
in: 'query',
name: 'page',
in: 'path',
name: 'objectId',
required: true,
schema: {
type: 'string',
enum: ['d', 'e', 'f']
enum: ['a', 'b', 'c']
}
},
{
Expand All @@ -1074,12 +1074,12 @@ describe('SwaggerExplorer', () => {
}
},
{
in: 'path',
name: 'objectId',
in: 'query',
name: 'page',
required: true,
schema: {
type: 'string',
enum: ['a', 'b', 'c']
enum: ['d', 'e', 'f']
}
}
]);
Expand All @@ -1099,14 +1099,11 @@ describe('SwaggerExplorer', () => {

expect(routes[0].root!.parameters).toEqual([
{
in: 'query',
name: 'page',
in: 'path',
name: 'objectId',
required: true,
schema: {
type: 'array',
items: {
$ref: '#/components/schemas/QueryEnum'
}
$ref: '#/components/schemas/ParamEnum'
}
},
{
Expand All @@ -1118,11 +1115,14 @@ describe('SwaggerExplorer', () => {
}
},
{
in: 'path',
name: 'objectId',
in: 'query',
name: 'page',
required: true,
schema: {
$ref: '#/components/schemas/ParamEnum'
type: 'array',
items: {
$ref: '#/components/schemas/QueryEnum'
}
}
}
]);
Expand Down

0 comments on commit 16d1ea9

Please sign in to comment.