Skip to content

Commit

Permalink
add test for "considering explicit config over auto-detected schema"
Browse files Browse the repository at this point in the history
  • Loading branch information
tiholic committed Sep 7, 2021
1 parent 966ba34 commit 12d1ad9
Showing 1 changed file with 39 additions and 0 deletions.
39 changes: 39 additions & 0 deletions test/explorer/swagger-explorer.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<FooController>,
new ApplicationConfig(),
'path'
);

expect(routes[0].root.responses).toEqual(responsesObject);
});
});
});

0 comments on commit 12d1ad9

Please sign in to comment.