Skip to content

Commit 84ad82b

Browse files
authored
fix: made filter property optional in response body (#1098)
1 parent 03a1a70 commit 84ad82b

File tree

3 files changed

+501
-1
lines changed

3 files changed

+501
-1
lines changed

src/swagger/paginated-swagger.type.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,8 @@ export class PaginatedMetaDocumented<T> {
114114

115115
@ApiProperty({
116116
title: 'Filters that applied to the query',
117-
selfRequired: true,
117+
selfRequired: false,
118+
required: [],
118119
isArray: false,
119120
type: 'object',
120121
additionalProperties: false,

src/swagger/pagination-docs.spec.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ import { Test } from '@nestjs/testing'
55
import { PaginatedSwaggerDocs } from './api-paginated-swagger-docs.decorator'
66
import { ApiPaginationQuery } from './api-paginated-query.decorator'
77
import { ApiOkPaginatedResponse } from './api-ok-paginated-response.decorator'
8+
import * as fs from 'node:fs'
9+
import * as path from 'node:path'
810

911
const BASE_PAGINATION_CONFIG = {
1012
sortableColumns: ['id'],
@@ -312,4 +314,13 @@ describe('PaginatedEndpoint decorator', () => {
312314
},
313315
})
314316
})
317+
318+
it('should match a base config, snapshot test for all config', async () => {
319+
const openApiDefinition = await getSwaggerDefinitionForEndpoint(TestDto, FULL_CONFIG)
320+
const fullOpenApiDefinition = JSON.parse(
321+
fs.readFileSync(path.join(__dirname, 'resources/full-openapi-definition.json')).toString('utf-8')
322+
)
323+
324+
expect(openApiDefinition).toStrictEqual(fullOpenApiDefinition)
325+
})
315326
})

0 commit comments

Comments
 (0)