11import { applyDecorators , HttpStatus , Type } from '@nestjs/common' ;
2- import { ApiBadRequestResponse , ApiExtraModels , ApiNotFoundResponse , getSchemaPath } from '@nestjs/swagger' ;
2+ import { ApiBadRequestResponse , ApiExtraModels , ApiNotFoundResponse , ApiOperation , ApiOperationOptions , getSchemaPath } from '@nestjs/swagger' ;
33import { ApiOkResponse , ApiResponseOptions } from '@nestjs/swagger/dist/decorators/api-response.decorator' ;
44import { ErrorSchemaDto } from '~/_common/dto/error-schema.dto' ;
55import { NotFoundDto } from '~/_common/dto/not-found.dto' ;
66
77export const ApiUpdatedResponseDecorator = < TModel extends Type < NonNullable < unknown > > > (
88 model : TModel ,
9- responseOptions ?: ApiResponseOptions | null | undefined ,
10- badRequestOptions ?: ApiResponseOptions | null | undefined ,
11- notFoundOptions ?: ApiResponseOptions | null | undefined ,
9+ options ?: {
10+ responseOptions ?: ApiResponseOptions | null | undefined ,
11+ badRequestOptions ?: ApiResponseOptions | null | undefined ,
12+ notFoundOptions ?: ApiResponseOptions | null | undefined ,
13+ operationOptions ?: ApiOperationOptions | null | undefined ,
14+ } ,
1215) => {
1316 return applyDecorators (
1417 ApiExtraModels ( model ) ,
@@ -26,21 +29,22 @@ export const ApiUpdatedResponseDecorator = <TModel extends Type<NonNullable<unkn
2629 } ,
2730 } ,
2831 } ,
29- ...responseOptions ,
32+ ...options ?. responseOptions ,
3033 } ) ,
3134 ApiBadRequestResponse ( {
3235 description : 'Schema validation failed' ,
3336 schema : {
3437 $ref : getSchemaPath ( ErrorSchemaDto ) ,
3538 } ,
36- ...badRequestOptions ,
39+ ...options ?. badRequestOptions ,
3740 } ) ,
3841 ApiNotFoundResponse ( {
3942 description : 'Item not found' ,
4043 schema : {
4144 $ref : getSchemaPath ( NotFoundDto ) ,
4245 } ,
43- ...notFoundOptions ,
46+ ...options ?. notFoundOptions ,
4447 } ) ,
48+ ApiOperation ( { summary : `Mise à jour d'une entrée <${ model . name . replace ( / D t o $ / , '' ) } >` , ...options ?. operationOptions } ) ,
4549 ) ;
4650} ;
0 commit comments