Skip to content

Commit

Permalink
feat(openapi-v3): relax @api to make paths optional with {} as …
Browse files Browse the repository at this point in the history
…the default
  • Loading branch information
raymondfeng committed May 11, 2020
1 parent dfd7105 commit ef3c415
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
5 changes: 3 additions & 2 deletions packages/openapi-v3/src/decorators/api.decorator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,11 @@ import {OAI3Keys} from '../keys';
* handled by this controller
*
*/
export function api(spec: ControllerSpec) {
export function api(spec: Partial<ControllerSpec>) {
const controllerSpec: ControllerSpec = {paths: {}, ...spec};
return ClassDecoratorFactory.createDecorator<ControllerSpec>(
OAI3Keys.CLASS_KEY,
spec,
controllerSpec,
{decoratorName: '@api'},
);
}
Original file line number Diff line number Diff line change
Expand Up @@ -524,7 +524,7 @@ describe('Routing', () => {
const app = givenAnApplication();
const server = await givenAServer(app);

@api({basePath: '/my', paths: {}})
@api({basePath: '/my'})
class MyController {
@get('/greet')
greet(@param.query.string('name') name: string) {
Expand Down

0 comments on commit ef3c415

Please sign in to comment.