Skip to content

Commit

Permalink
Merge pull request #715 from andreoav/fix/api-extension
Browse files Browse the repository at this point in the history
fix(api-extension): add support for string extensions
  • Loading branch information
kamilmysliwiec committed May 4, 2020
2 parents 990aeda + f40cb0f commit cc3273e
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 3 deletions.
1 change: 1 addition & 0 deletions e2e/api-spec.json
Original file line number Diff line number Diff line change
Expand Up @@ -345,6 +345,7 @@
"/api/cats/{id}": {
"get": {
"operationId": "CatsController_findOne",
"x-auth-type": "NONE",
"parameters": [
{
"name": "id",
Expand Down
1 change: 1 addition & 0 deletions e2e/src/cats/cats.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ export class CatsController {
description: 'The found record',
type: Cat
})
@ApiExtension('x-auth-type', 'NONE')
findOne(@Param('id') id: string): Cat {
return this.catsService.findOne(+id);
}
Expand Down
7 changes: 4 additions & 3 deletions lib/decorators/api-extension.decorator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,10 @@ export function ApiExtension(extensionKey: string, extensionProperties: any) {
}

const extensionObject = {
[extensionKey]: {
...extensionProperties
}
[extensionKey]:
typeof extensionProperties !== 'string'
? { ...extensionProperties }
: extensionProperties
};

return createMixedDecorator(DECORATORS.API_EXTENSION, extensionObject);
Expand Down

0 comments on commit cc3273e

Please sign in to comment.