feat: 优化swagger的生成设置

master
luoer 2023-08-02 20:16:26 +08:00
parent c89a732209
commit 1a32173fc7
6 changed files with 9 additions and 9 deletions

Binary file not shown.

View File

@ -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;
}

View File

@ -37,7 +37,6 @@ export function addResponseWrapper(doc: OpenAPIObject) {
},
{
type: 'object',
description: '返回数据',
properties: {
data: schema,
},

View File

@ -9,5 +9,5 @@ export class FindUserDto extends IntersectionType(PaginationDto) {
*/
@IsOptional()
@IsString()
nickname: string;
nickname?: string;
}

View File

@ -61,6 +61,7 @@ export class User extends BaseEntity {
/**
*
*/
@ApiHideProperty()
@ManyToMany(() => Role, (role) => role.user)
@JoinTable()
roles: Role[];

View File

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