feat: more response docs

This commit is contained in:
Ahmed Bouhuolia
2025-06-19 00:49:43 +02:00
parent 437bcb8854
commit 26c1f118c1
8 changed files with 405 additions and 41 deletions

View File

@@ -13,6 +13,7 @@ import { CreateAccountDTO } from './CreateAccount.dto';
import { EditAccountDTO } from './EditAccount.dto';
import { IAccountsFilter, IAccountsTransactionsFilter } from './Accounts.types';
import {
ApiExtraModels,
ApiOperation,
ApiParam,
ApiResponse,
@@ -20,9 +21,12 @@ import {
getSchemaPath,
} from '@nestjs/swagger';
import { AccountResponseDto } from './dtos/AccountResponse.dto';
import { AccountTypeResponseDto } from './dtos/AccountTypeResponse.dto';
@Controller('accounts')
@ApiTags('Accounts')
@ApiExtraModels(AccountResponseDto)
@ApiExtraModels(AccountTypeResponseDto)
export class AccountsController {
constructor(private readonly accountsApplication: AccountsApplication) {}
@@ -112,6 +116,9 @@ export class AccountsController {
@ApiResponse({
status: 200,
description: 'The account types have been successfully retrieved.',
schema: {
$ref: getSchemaPath(AccountTypeResponseDto),
},
})
async getAccountTypes() {
return this.accountsApplication.getAccountTypes();

View File

@@ -0,0 +1,51 @@
import { ApiProperty, ApiExtraModels } from '@nestjs/swagger';
export class AccountTypeResponseDto {
@ApiProperty({
description: 'The display label for the account type',
example: 'Cash',
})
label: string;
@ApiProperty({
description: 'The unique key for the account type',
example: 'cash',
})
key: string;
@ApiProperty({
description: 'The normal balance type for the account',
example: 'debit',
})
normal: string;
@ApiProperty({
description: 'The parent type of the account',
example: 'current-asset',
})
parentType: string;
@ApiProperty({
description: 'The root type of the account',
example: 'asset',
})
rootType: string;
@ApiProperty({
description: 'Whether the account type supports multiple currencies',
example: true,
})
multiCurrency: boolean;
@ApiProperty({
description: 'Whether the account type appears on the balance sheet',
example: true,
})
balanceSheet: boolean;
@ApiProperty({
description: 'Whether the account type appears on the income sheet',
example: false,
})
incomeSheet: boolean;
}