feat: add swagger docs for responses

This commit is contained in:
Ahmed Bouhuolia
2025-06-16 13:50:30 +02:00
parent 88ef60ef28
commit c4668d7d22
30 changed files with 1363 additions and 64 deletions

View File

@@ -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));
}

View File

@@ -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;
}