Skip to content

Commit a24be8c

Browse files
committed
fix api doc app
1 parent aad8b51 commit a24be8c

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed

service/src/_dto/app.dto.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import { ApiProperty } from '@nestjs/swagger'
2+
3+
export class AppInfoDto {
4+
@ApiProperty()
5+
public name: string
6+
7+
@ApiProperty()
8+
public version: string
9+
}

service/src/app.controller.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@ import { AppService } from './app.service'
44
import { Response } from 'express'
55
import { Public } from './_common/decorators/public.decorator'
66
import { ShutdownService } from '~/shutdown.service'
7+
import { ApiOkResponse } from '@nestjs/swagger/dist/decorators/api-response.decorator'
8+
import { ApiExtraModels, ApiHideProperty, getSchemaPath } from '@nestjs/swagger'
9+
import { AppInfoDto } from '~/_dto/app.dto'
710

811
@Public()
912
@Controller()
@@ -13,6 +16,13 @@ export class AppController extends AbstractController {
1316
}
1417

1518
@Get()
19+
@ApiExtraModels(AppInfoDto)
20+
@ApiOkResponse({
21+
description: 'Returns the infos of the application',
22+
schema: {
23+
$ref: getSchemaPath(AppInfoDto),
24+
},
25+
})
1626
public root(@Res() res: Response): Response {
1727
return res.json(this._service.getInfos())
1828
}

0 commit comments

Comments
 (0)