mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-15 20:30:33 +00:00
feat: add swagger docs for responses
This commit is contained in:
@@ -1,4 +1,10 @@
|
||||
import { ApiOperation, ApiTags } from '@nestjs/swagger';
|
||||
import {
|
||||
ApiOperation,
|
||||
ApiTags,
|
||||
ApiResponse,
|
||||
getSchemaPath,
|
||||
ApiExtraModels,
|
||||
} from '@nestjs/swagger';
|
||||
import {
|
||||
Body,
|
||||
Controller,
|
||||
@@ -9,20 +15,28 @@ import {
|
||||
Put,
|
||||
} from '@nestjs/common';
|
||||
import { BankRulesApplication } from './BankRulesApplication';
|
||||
import { BankRule } from './models/BankRule';
|
||||
import { CreateBankRuleDto } from './dtos/BankRule.dto';
|
||||
import { EditBankRuleDto } from './dtos/BankRule.dto';
|
||||
import { BankRuleResponseDto } from './dtos/BankRuleResponse.dto';
|
||||
|
||||
@Controller('banking/rules')
|
||||
@ApiTags('Bank Rules')
|
||||
@ApiExtraModels(BankRuleResponseDto)
|
||||
export class BankRulesController {
|
||||
constructor(private readonly bankRulesApplication: BankRulesApplication) {}
|
||||
|
||||
@Post()
|
||||
@ApiOperation({ summary: 'Create a new bank rule.' })
|
||||
@ApiResponse({
|
||||
status: 201,
|
||||
description: 'The bank rule has been successfully created.',
|
||||
schema: {
|
||||
$ref: getSchemaPath(BankRuleResponseDto),
|
||||
},
|
||||
})
|
||||
async createBankRule(
|
||||
@Body() createRuleDTO: CreateBankRuleDto,
|
||||
): Promise<BankRule> {
|
||||
): Promise<BankRuleResponseDto> {
|
||||
return this.bankRulesApplication.createBankRule(createRuleDTO);
|
||||
}
|
||||
|
||||
@@ -37,19 +51,36 @@ export class BankRulesController {
|
||||
|
||||
@Delete(':id')
|
||||
@ApiOperation({ summary: 'Delete the given bank rule.' })
|
||||
@ApiResponse({
|
||||
status: 200,
|
||||
description: 'The bank rule has been successfully deleted.',
|
||||
})
|
||||
async deleteBankRule(@Param('id') ruleId: number): Promise<void> {
|
||||
return this.bankRulesApplication.deleteBankRule(ruleId);
|
||||
}
|
||||
|
||||
@Get(':id')
|
||||
@ApiOperation({ summary: 'Retrieves the bank rule details.' })
|
||||
async getBankRule(@Param('id') ruleId: number): Promise<any> {
|
||||
@ApiResponse({
|
||||
status: 200,
|
||||
description: 'The bank rule details have been successfully retrieved.',
|
||||
schema: { $ref: getSchemaPath(BankRuleResponseDto) },
|
||||
})
|
||||
async getBankRule(@Param('id') ruleId: number): Promise<BankRuleResponseDto> {
|
||||
return this.bankRulesApplication.getBankRule(ruleId);
|
||||
}
|
||||
|
||||
@Get()
|
||||
@ApiOperation({ summary: 'Retrieves the bank rules.' })
|
||||
async getBankRules(): Promise<any> {
|
||||
@ApiResponse({
|
||||
status: 200,
|
||||
description: 'The bank rules have been successfully retrieved.',
|
||||
schema: {
|
||||
type: 'array',
|
||||
items: { $ref: getSchemaPath(BankRuleResponseDto) },
|
||||
},
|
||||
})
|
||||
async getBankRules(): Promise<BankRuleResponseDto[]> {
|
||||
return this.bankRulesApplication.getBankRules();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user