diff --git a/test/explorer/swagger-explorer.spec.ts b/test/explorer/swagger-explorer.spec.ts index 6313a4b8f..6abde5670 100644 --- a/test/explorer/swagger-explorer.spec.ts +++ b/test/explorer/swagger-explorer.spec.ts @@ -1179,4 +1179,43 @@ describe('SwaggerExplorer', () => { expect(routes).toHaveLength(0); }); }); + + describe('should consider explicit config over auto-detected schema', () => { + const responsesObject = { + '201': { + description: 'binary file for download', + content: { + 'application/pdf': { + schema: { type: 'string', format: 'binary' } + }, + 'image/jpeg': { schema: { type: 'string', format: 'binary' } } + } + } + }; + @Controller() + class FooController { + @Get() + @ApiOperation({ + description: 'download file', + responses: responsesObject + }) + download() { + // handles file download + } + } + + it('when responses is passed in ApiOperation ', () => { + const explorer = new SwaggerExplorer(schemaObjectFactory); + const routes = explorer.exploreController( + { + instance: new FooController(), + metatype: FooController + } as InstanceWrapper, + new ApplicationConfig(), + 'path' + ); + + expect(routes[0].root.responses).toEqual(responsesObject); + }); + }); });