mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-18 13:50:31 +00:00
feat: add swagger docs for responses
This commit is contained in:
@@ -8,11 +8,19 @@ import {
|
||||
Put,
|
||||
} from '@nestjs/common';
|
||||
import { WarehousesApplication } from './WarehousesApplication.service';
|
||||
import { ApiOperation, ApiTags } from '@nestjs/swagger';
|
||||
import {
|
||||
ApiExtraModels,
|
||||
ApiOperation,
|
||||
ApiResponse,
|
||||
ApiTags,
|
||||
getSchemaPath,
|
||||
} from '@nestjs/swagger';
|
||||
import { CreateWarehouseDto, EditWarehouseDto } from './dtos/Warehouse.dto';
|
||||
import { WarehouseResponseDto } from './dtos/WarehouseResponse.dto';
|
||||
|
||||
@Controller('warehouses')
|
||||
@ApiTags('Warehouses')
|
||||
@ApiExtraModels(WarehouseResponseDto)
|
||||
export class WarehousesController {
|
||||
constructor(private warehousesApplication: WarehousesApplication) {}
|
||||
|
||||
@@ -41,6 +49,11 @@ export class WarehousesController {
|
||||
|
||||
@Get(':id')
|
||||
@ApiOperation({ summary: 'Get a warehouse' })
|
||||
@ApiResponse({
|
||||
status: 200,
|
||||
description: 'The warehouse details have been successfully retrieved.',
|
||||
schema: { $ref: getSchemaPath(WarehouseResponseDto) },
|
||||
})
|
||||
getWarehouse(@Param('id') warehouseId: string) {
|
||||
return this.warehousesApplication.getWarehouse(Number(warehouseId));
|
||||
}
|
||||
|
||||
@@ -0,0 +1,39 @@
|
||||
import { ApiProperty } from '@nestjs/swagger';
|
||||
|
||||
export class WarehouseResponseDto {
|
||||
@ApiProperty({
|
||||
description: 'The name of the warehouse',
|
||||
example: 'Main Warehouse',
|
||||
})
|
||||
name!: string;
|
||||
|
||||
@ApiProperty({
|
||||
description: 'The unique code identifier for the warehouse',
|
||||
example: 'WH-001',
|
||||
})
|
||||
code!: string;
|
||||
|
||||
@ApiProperty({
|
||||
description: 'The city where the warehouse is located',
|
||||
example: 'New York',
|
||||
})
|
||||
city!: string;
|
||||
|
||||
@ApiProperty({
|
||||
description: 'The country where the warehouse is located',
|
||||
example: 'United States',
|
||||
})
|
||||
country!: string;
|
||||
|
||||
@ApiProperty({
|
||||
description: 'The full address of the warehouse',
|
||||
example: '123 Warehouse Street, New York, NY 10001',
|
||||
})
|
||||
address!: string;
|
||||
|
||||
@ApiProperty({
|
||||
description: 'Indicates if this is the primary warehouse',
|
||||
example: true,
|
||||
})
|
||||
primary!: boolean;
|
||||
}
|
||||
Reference in New Issue
Block a user