feat: Add sortBy columns to swagger (#800)

This commit is contained in:
vaidas-dutrys 2023-11-07 10:34:28 +02:00 committed by GitHub
parent bf27699683
commit 7a937b19b7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 0 deletions

View File

@ -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')}

View File

@ -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'],
},
},
},