feat: 优化swagger的生成设置
parent
c89a732209
commit
1a32173fc7
Binary file not shown.
|
|
@ -14,7 +14,7 @@ export class PaginationDto {
|
|||
@IsNumber()
|
||||
@Min(1)
|
||||
@Transform(({ value }) => Number(value))
|
||||
page: number;
|
||||
page?: number;
|
||||
|
||||
/**
|
||||
* 每页条数
|
||||
|
|
@ -24,5 +24,5 @@ export class PaginationDto {
|
|||
@IsNumber()
|
||||
@Min(1)
|
||||
@Transform(({ value }) => Number(value))
|
||||
size: number;
|
||||
size?: number;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -37,7 +37,6 @@ export function addResponseWrapper(doc: OpenAPIObject) {
|
|||
},
|
||||
{
|
||||
type: 'object',
|
||||
description: '返回数据',
|
||||
properties: {
|
||||
data: schema,
|
||||
},
|
||||
|
|
|
|||
|
|
@ -9,5 +9,5 @@ export class FindUserDto extends IntersectionType(PaginationDto) {
|
|||
*/
|
||||
@IsOptional()
|
||||
@IsString()
|
||||
nickname: string;
|
||||
nickname?: string;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -61,6 +61,7 @@ export class User extends BaseEntity {
|
|||
/**
|
||||
* 用户角色
|
||||
*/
|
||||
@ApiHideProperty()
|
||||
@ManyToMany(() => Role, (role) => role.user)
|
||||
@JoinTable()
|
||||
roles: Role[];
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ export class UserController extends BaseController {
|
|||
}
|
||||
|
||||
@Post()
|
||||
@ApiOperation({ summary: '创建用户', operationId: 'addUser' })
|
||||
@ApiOperation({ description: '创建用户', operationId: 'addUser' })
|
||||
create(@Body() createUserDto: CreateUserDto) {
|
||||
return this.userService.create(createUserDto);
|
||||
}
|
||||
|
|
@ -24,26 +24,26 @@ export class UserController extends BaseController {
|
|||
@Get()
|
||||
@Respond(Respond.PAGINATION)
|
||||
@ApiOkResponse({ isArray: true, type: User })
|
||||
@ApiOperation({ summary: '批量查询用户', operationId: 'getUsers' })
|
||||
@ApiOperation({ description: '批量查询用户', operationId: 'getUsers' })
|
||||
async findMany(@Query() query: FindUserDto) {
|
||||
return this.userService.findMany(query);
|
||||
}
|
||||
|
||||
@Get(':id')
|
||||
@Version('2')
|
||||
@ApiOperation({ summary: '查询用户', operationId: 'getUserv2' })
|
||||
@ApiOperation({ description: '查询用户', operationId: 'getUserv2' })
|
||||
findOne(@Param('id') id: number) {
|
||||
return this.userService.findOne(+id);
|
||||
}
|
||||
|
||||
@Patch(':id')
|
||||
@ApiOperation({ summary: '更新用户', operationId: 'updateUser' })
|
||||
@ApiOperation({ description: '更新用户', operationId: 'updateUser' })
|
||||
update(@Param('id') id: number, @Body() updateUserDto: UpdateUserDto) {
|
||||
return this.userService.update(+id, updateUserDto);
|
||||
}
|
||||
|
||||
@Delete(':id')
|
||||
@ApiOperation({ summary: '删除用户', operationId: 'deleteUser' })
|
||||
@ApiOperation({ description: '删除用户', operationId: 'deleteUser' })
|
||||
remove(@Param('id') id: number) {
|
||||
return this.userService.remove(+id);
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue