mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-16 21:00:31 +00:00
feat: endpoints swagger document
This commit is contained in:
@@ -8,7 +8,7 @@ import {
|
||||
Put,
|
||||
Query,
|
||||
} from '@nestjs/common';
|
||||
import { ApiOperation, ApiTags } from '@nestjs/swagger';
|
||||
import { ApiOperation, ApiTags, ApiResponse } from '@nestjs/swagger';
|
||||
import { UsersApplication } from './Users.application';
|
||||
import { EditUserDto } from './dtos/EditUser.dto';
|
||||
|
||||
@@ -22,6 +22,13 @@ export class UsersController {
|
||||
*/
|
||||
@Post(':id')
|
||||
@ApiOperation({ summary: 'Edit details of the given user.' })
|
||||
@ApiResponse({
|
||||
status: 200,
|
||||
description: 'The user has been edited successfully.',
|
||||
schema: {
|
||||
example: { id: 1, message: 'The user has been edited successfully.' },
|
||||
},
|
||||
})
|
||||
async editUser(
|
||||
@Param('id') userId: number,
|
||||
@Body() editUserDTO: EditUserDto,
|
||||
@@ -39,6 +46,13 @@ export class UsersController {
|
||||
*/
|
||||
@Delete(':id')
|
||||
@ApiOperation({ summary: 'Soft deleting the given user.' })
|
||||
@ApiResponse({
|
||||
status: 200,
|
||||
description: 'The user has been deleted successfully.',
|
||||
schema: {
|
||||
example: { id: 1, message: 'The user has been deleted successfully.' },
|
||||
},
|
||||
})
|
||||
async deleteUser(@Param('id') userId: number) {
|
||||
await this.usersApplication.deleteUser(userId);
|
||||
|
||||
@@ -53,6 +67,10 @@ export class UsersController {
|
||||
*/
|
||||
@Get(':id')
|
||||
@ApiOperation({ summary: 'Retrieve user details of the given user id.' })
|
||||
@ApiResponse({
|
||||
status: 200,
|
||||
description: 'User details retrieved successfully.',
|
||||
})
|
||||
async getUser(@Param('id') userId: number) {
|
||||
return this.usersApplication.getUser(userId);
|
||||
}
|
||||
@@ -62,6 +80,10 @@ export class UsersController {
|
||||
*/
|
||||
@Get()
|
||||
@ApiOperation({ summary: 'Retrieve the list of users.' })
|
||||
@ApiResponse({
|
||||
status: 200,
|
||||
description: 'List of users retrieved successfully.',
|
||||
})
|
||||
async listUsers(
|
||||
@Query('page_size') pageSize?: number,
|
||||
@Query('page') page?: number,
|
||||
@@ -74,6 +96,13 @@ export class UsersController {
|
||||
*/
|
||||
@Put(':id/activate')
|
||||
@ApiOperation({ summary: 'Activate the given user.' })
|
||||
@ApiResponse({
|
||||
status: 200,
|
||||
description: 'The user has been activated successfully.',
|
||||
schema: {
|
||||
example: { id: 1, message: 'The user has been activated successfully.' },
|
||||
},
|
||||
})
|
||||
async activateUser(@Param('id') userId: number) {
|
||||
await this.usersApplication.activateUser(userId);
|
||||
|
||||
@@ -88,6 +117,16 @@ export class UsersController {
|
||||
*/
|
||||
@Put(':id/inactivate')
|
||||
@ApiOperation({ summary: 'Inactivate the given user.' })
|
||||
@ApiResponse({
|
||||
status: 200,
|
||||
description: 'The user has been inactivated successfully.',
|
||||
schema: {
|
||||
example: {
|
||||
id: 1,
|
||||
message: 'The user has been inactivated successfully.',
|
||||
},
|
||||
},
|
||||
})
|
||||
async inactivateUser(@Param('id') userId: number) {
|
||||
await this.usersApplication.inactivateUser(userId);
|
||||
|
||||
@@ -96,5 +135,4 @@ export class UsersController {
|
||||
message: 'The user has been inactivated successfully.',
|
||||
};
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user