Skip to content

Commit bd75d0a

Browse files
committedAug 4, 2024·
feat: Add schema support for "example" annotations
1 parent 02e0341 commit bd75d0a

File tree

4 files changed

+20
-5
lines changed

4 files changed

+20
-5
lines changed
 

‎e2e/api-spec.json

+10
Original file line numberDiff line numberDiff line change
@@ -293,6 +293,7 @@
293293
"title": "Page",
294294
"format": "int32",
295295
"default": 0,
296+
"example": 123,
296297
"type": "number"
297298
}
298299
},
@@ -302,6 +303,10 @@
302303
"in": "query",
303304
"schema": {
304305
"nullable": true,
306+
"example": [
307+
"sort1",
308+
"sort2"
309+
],
305310
"type": "array",
306311
"items": {
307312
"type": "string"
@@ -490,6 +495,7 @@
490495
"title": "Page",
491496
"format": "int32",
492497
"default": 0,
498+
"example": 123,
493499
"type": "number"
494500
}
495501
},
@@ -499,6 +505,10 @@
499505
"required": true,
500506
"schema": {
501507
"nullable": true,
508+
"example": [
509+
"sort1",
510+
"sort2"
511+
],
502512
"type": "array",
503513
"items": {
504514
"type": "string"

‎e2e/src/cats/dto/pagination-query.dto.ts

+4-2
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,15 @@ export class PaginationQuery {
1414
exclusiveMaximum: true,
1515
exclusiveMinimum: true,
1616
format: 'int32',
17-
default: 0
17+
default: 0,
18+
example: 123
1819
})
1920
page: number;
2021

2122
@ApiProperty({
2223
name: '_sortBy',
23-
nullable: true
24+
nullable: true,
25+
example: ['sort1', 'sort2']
2426
})
2527
sortBy: string[];
2628

‎lib/services/swagger-types-mapper.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,8 @@ export class SwaggerTypesMapper {
157157
'format',
158158
'pattern',
159159
'nullable',
160-
'default'
160+
'default',
161+
'example'
161162
];
162163
}
163164
}

‎test/plugin/fixtures/project/cats/dto/pagination-query.dto.ts

+4-2
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,15 @@ export class PaginationQuery {
1414
exclusiveMaximum: true,
1515
exclusiveMinimum: true,
1616
format: 'int32',
17-
default: 0
17+
default: 0,
18+
example: 123
1819
})
1920
page: number;
2021

2122
@ApiProperty({
2223
name: '_sortBy',
23-
nullable: true
24+
nullable: true,
25+
example: ['sort1', 'sort2']
2426
})
2527
sortBy: string[];
2628

0 commit comments

Comments
 (0)
Please sign in to comment.