mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-16 12:50:38 +00:00
feat: swagger document endpoints
This commit is contained in:
@@ -1,16 +1,25 @@
|
||||
import { ApiTags, ApiOperation, ApiResponse } from '@nestjs/swagger';
|
||||
import {
|
||||
ApiTags,
|
||||
ApiOperation,
|
||||
ApiResponse,
|
||||
getSchemaPath,
|
||||
ApiExtraModels,
|
||||
} from '@nestjs/swagger';
|
||||
import { Controller, Get } from '@nestjs/common';
|
||||
import { DashboardService } from './Dashboard.service';
|
||||
import { GetDashboardBootMetaResponseDto } from './dtos/GetDashboardBootMetaResponse.dto';
|
||||
|
||||
@ApiTags('Dashboard')
|
||||
@Controller('dashboard')
|
||||
@ApiExtraModels(GetDashboardBootMetaResponseDto)
|
||||
export class DashboardController {
|
||||
constructor(private readonly dashboardService: DashboardService) {}
|
||||
|
||||
@ApiOperation({ summary: 'Get dashboard boot metadata' })
|
||||
@ApiResponse({
|
||||
status: 200,
|
||||
description: 'Returns dashboard boot metadata including abilities, features, and cloud status',
|
||||
description: 'The dashboard details have been successfully retrieved.',
|
||||
schema: { $ref: getSchemaPath(GetDashboardBootMetaResponseDto) },
|
||||
})
|
||||
@Get('boot')
|
||||
getBootMeta() {
|
||||
|
||||
@@ -0,0 +1,64 @@
|
||||
import { ApiExtraModels, ApiProperty } from '@nestjs/swagger';
|
||||
|
||||
class RoleAbilityResponseDto {
|
||||
@ApiProperty({
|
||||
description: 'The subject of the ability',
|
||||
example: 'all',
|
||||
})
|
||||
subject: string;
|
||||
|
||||
@ApiProperty({
|
||||
description: 'The action permitted for the subject',
|
||||
example: 'manage',
|
||||
})
|
||||
action: string;
|
||||
}
|
||||
|
||||
class DashboardFeatureResponseDto {
|
||||
@ApiProperty({
|
||||
description: 'The name of the feature',
|
||||
example: 'warehouses',
|
||||
})
|
||||
name: string;
|
||||
|
||||
@ApiProperty({
|
||||
description: 'Whether the feature is accessible for the tenant',
|
||||
example: true,
|
||||
})
|
||||
isAccessible: boolean;
|
||||
|
||||
@ApiProperty({
|
||||
description: 'The default accessibility of the feature',
|
||||
example: false,
|
||||
})
|
||||
defaultAccessible: boolean;
|
||||
}
|
||||
|
||||
@ApiExtraModels(RoleAbilityResponseDto, DashboardFeatureResponseDto)
|
||||
export class GetDashboardBootMetaResponseDto {
|
||||
@ApiProperty({
|
||||
description: 'List of abilities for the current user',
|
||||
type: [RoleAbilityResponseDto],
|
||||
example: [
|
||||
{ subject: 'all', action: 'manage' },
|
||||
{ subject: 'invoices', action: 'read' },
|
||||
],
|
||||
})
|
||||
abilities: RoleAbilityResponseDto[];
|
||||
|
||||
@ApiProperty({
|
||||
description: 'List of features and their accessibility',
|
||||
type: [DashboardFeatureResponseDto],
|
||||
example: [
|
||||
{ name: 'warehouses', isAccessible: true, defaultAccessible: false },
|
||||
{ name: 'branches', isAccessible: false, defaultAccessible: false },
|
||||
],
|
||||
})
|
||||
features: DashboardFeatureResponseDto[];
|
||||
|
||||
@ApiProperty({
|
||||
description: 'Whether the app is running on Bigcapital Cloud',
|
||||
example: true,
|
||||
})
|
||||
isBigcapitalCloud: boolean;
|
||||
}
|
||||
Reference in New Issue
Block a user