11import { InternalException , PolicyEngine } from '#helpers' ;
2- import { Examples , ExternalDocumentDTO , InternalServerErrorDTO , ResponseDTOWithSyncEvents } from '#middlewares' ;
2+ import { Examples , ExternalDocumentDTO , InternalServerErrorDTO , ObjectExamples , ResponseDTOWithSyncEvents } from '#middlewares' ;
33import { PinoLogger } from '@guardian/common' ;
44import { Body , Controller , DefaultValuePipe , HttpCode , HttpStatus , Param , ParseBoolPipe , Post , Query } from '@nestjs/common' ;
5- import { ApiBody , ApiExtraModels , ApiInternalServerErrorResponse , ApiOkResponse , ApiOperation , ApiParam , ApiQuery , ApiTags } from '@nestjs/swagger' ;
5+ import { ApiBody , ApiInternalServerErrorResponse , ApiOkResponse , ApiOperation , ApiParam , ApiQuery , ApiTags } from '@nestjs/swagger' ;
66
77@Controller ( 'external' )
88@ApiTags ( 'external' )
@@ -20,7 +20,12 @@ export class ExternalApi {
2020 } )
2121 @ApiBody ( {
2222 description : 'Object that contains a VC Document.' ,
23- type : ExternalDocumentDTO
23+ type : ExternalDocumentDTO ,
24+ examples : {
25+ 'Request Body' : {
26+ value : ObjectExamples . EXTERNAL_REQUEST_BODY_EXAMPLE
27+ }
28+ }
2429 } )
2530 @ApiParam ( {
2631 name : 'policyId' ,
@@ -46,7 +51,6 @@ export class ExternalApi {
4651 type : InternalServerErrorDTO ,
4752 example : { code : 500 , message : 'Error message' }
4853 } )
49- @ApiExtraModels ( ExternalDocumentDTO , InternalServerErrorDTO )
5054 @HttpCode ( HttpStatus . OK )
5155 async receiveExternalDataCustom (
5256 @Param ( 'policyId' ) policyId : string ,
@@ -71,7 +75,12 @@ export class ExternalApi {
7175 } )
7276 @ApiBody ( {
7377 description : 'Object that contains a VC Document.' ,
74- type : ExternalDocumentDTO
78+ type : ExternalDocumentDTO ,
79+ examples : {
80+ 'Request Body' : {
81+ value : ObjectExamples . EXTERNAL_REQUEST_BODY_EXAMPLE
82+ }
83+ }
7584 } )
7685 @ApiOkResponse ( {
7786 description : 'Successful operation.' ,
@@ -83,7 +92,6 @@ export class ExternalApi {
8392 type : InternalServerErrorDTO ,
8493 example : { code : 500 , message : 'Error message' }
8594 } )
86- @ApiExtraModels ( ExternalDocumentDTO , InternalServerErrorDTO )
8795 @HttpCode ( HttpStatus . OK )
8896 async receiveExternalData (
8997 @Body ( ) document : ExternalDocumentDTO
@@ -106,7 +114,12 @@ export class ExternalApi {
106114 } )
107115 @ApiBody ( {
108116 description : 'Object that contains a VC Document.' ,
109- type : ExternalDocumentDTO
117+ type : ExternalDocumentDTO ,
118+ examples : {
119+ 'Request Body' : {
120+ value : ObjectExamples . EXTERNAL_REQUEST_BODY_EXAMPLE
121+ }
122+ }
110123 } )
111124 @ApiQuery ( {
112125 name : 'history' ,
@@ -132,14 +145,13 @@ export class ExternalApi {
132145 @ApiOkResponse ( {
133146 description : 'Successful operation.' ,
134147 type : ResponseDTOWithSyncEvents ,
135- example : { result : 'ok' }
148+ example : ObjectExamples . EXTERNAL_SYNC_EVENTS_RESPONSE_EXAMPLE
136149 } )
137150 @ApiInternalServerErrorResponse ( {
138151 description : 'Internal server error.' ,
139152 type : InternalServerErrorDTO ,
140153 example : { code : 500 , message : 'Error message' }
141154 } )
142- @ApiExtraModels ( ExternalDocumentDTO , ResponseDTOWithSyncEvents , InternalServerErrorDTO )
143155 @HttpCode ( HttpStatus . OK )
144156 async receiveExternalDataCustomWithSyncEvents (
145157 @Param ( 'policyId' ) policyId : string ,
@@ -165,7 +177,12 @@ export class ExternalApi {
165177 } )
166178 @ApiBody ( {
167179 description : 'Object that contains a VC Document.' ,
168- type : ExternalDocumentDTO
180+ type : ExternalDocumentDTO ,
181+ examples : {
182+ 'Request Body' : {
183+ value : ObjectExamples . EXTERNAL_REQUEST_BODY_EXAMPLE
184+ }
185+ }
169186 } )
170187 @ApiQuery ( {
171188 name : 'history' ,
@@ -177,14 +194,13 @@ export class ExternalApi {
177194 @ApiOkResponse ( {
178195 description : 'Successful operation.' ,
179196 type : ResponseDTOWithSyncEvents ,
180- example : { result : 'ok' }
197+ example : ObjectExamples . EXTERNAL_SYNC_EVENTS_RESPONSE_EXAMPLE
181198 } )
182199 @ApiInternalServerErrorResponse ( {
183200 description : 'Internal server error.' ,
184201 type : InternalServerErrorDTO ,
185202 example : { code : 500 , message : 'Error message' }
186203 } )
187- @ApiExtraModels ( ExternalDocumentDTO , ResponseDTOWithSyncEvents , InternalServerErrorDTO )
188204 @HttpCode ( HttpStatus . OK )
189205 async receiveExternalDataWithSyncEvents (
190206 @Query ( 'history' , new DefaultValuePipe ( false ) , ParseBoolPipe ) history : boolean ,
0 commit comments