feat: Add sortBy
columns to swagger (#800)
This commit is contained in:
parent
bf27699683
commit
7a937b19b7
@ -20,9 +20,14 @@ export function SortBy(paginationConfig: PaginateConfig<any>) {
|
||||
? paginationConfig.defaultSortBy.map(([col, order]) => `${col}:${order}`).join(',')
|
||||
: 'No default sorting specified, the result order is not guaranteed'
|
||||
|
||||
const sortBy = paginationConfig.sortableColumns.reduce((prev, curr) => {
|
||||
return [...prev, `${curr}:ASC`, `${curr}:DESC`]
|
||||
}, [])
|
||||
|
||||
return ApiQuery({
|
||||
name: 'sortBy',
|
||||
isArray: true,
|
||||
enum: sortBy,
|
||||
description: `Parameter to sort by.
|
||||
<p>To sort by multiple fields, just provide query param multiple types. The order in url defines an order of sorting</p>
|
||||
${p('Format', 'fieldName:DIRECTION')}
|
||||
|
@ -97,6 +97,7 @@ describe('PaginatedEndpoint decorator', () => {
|
||||
type: 'array',
|
||||
items: {
|
||||
type: 'string',
|
||||
enum: ['id:ASC', 'id:DESC'],
|
||||
},
|
||||
},
|
||||
},
|
||||
@ -204,6 +205,7 @@ describe('PaginatedEndpoint decorator', () => {
|
||||
type: 'array',
|
||||
items: {
|
||||
type: 'string',
|
||||
enum: ['id:ASC', 'id:DESC'],
|
||||
},
|
||||
},
|
||||
},
|
||||
|
Loading…
Reference in New Issue
Block a user