Skip to content

Commit

Permalink
fix(): fix api header and headers decorators
Browse files Browse the repository at this point in the history
  • Loading branch information
kamilmysliwiec committed Jun 29, 2020
1 parent e94ef7f commit 395c612
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
8 changes: 8 additions & 0 deletions e2e/api-spec.json
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@
"$ref": "#/components/schemas/LettersEnum"
},
"enumArr": {
"type": "array",
"items": {
"$ref": "#/components/schemas/LettersEnum"
}
Expand Down Expand Up @@ -247,6 +248,7 @@
"description": "Test",
"required": false,
"schema": {
"default": "test",
"type": "string"
}
}
Expand Down Expand Up @@ -298,6 +300,7 @@
"description": "Test",
"required": false,
"schema": {
"default": "test",
"type": "string"
}
},
Expand Down Expand Up @@ -384,6 +387,7 @@
"description": "Test",
"required": false,
"schema": {
"default": "test",
"type": "string"
}
},
Expand Down Expand Up @@ -431,6 +435,7 @@
"description": "Test",
"required": false,
"schema": {
"default": "test",
"type": "string"
}
}
Expand Down Expand Up @@ -461,6 +466,7 @@
"description": "Test",
"required": false,
"schema": {
"default": "test",
"type": "string"
}
}
Expand Down Expand Up @@ -507,6 +513,7 @@
"description": "Test",
"required": false,
"schema": {
"default": "test",
"type": "string"
}
}
Expand Down Expand Up @@ -559,6 +566,7 @@
"description": "Test",
"required": false,
"schema": {
"default": "test",
"type": "string"
}
}
Expand Down
8 changes: 6 additions & 2 deletions lib/decorators/api-header.decorator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@ const defaultHeaderOptions: Partial<ApiHeaderOptions> = {
name: ''
};

export function ApiHeader(options: ApiHeaderOptions): any {
export function ApiHeader(
options: ApiHeaderOptions
): MethodDecorator & ClassDecorator {
const param = pickBy<ApiHeaderOptions & { in: ParameterLocation }>(
{
name: isNil(options.name) ? defaultHeaderOptions.name : options.name,
Expand Down Expand Up @@ -57,7 +59,9 @@ export function ApiHeader(options: ApiHeaderOptions): any {
};
}

export const ApiHeaders = (headers: ApiHeaderOptions[]): MethodDecorator => {
export const ApiHeaders = (
headers: ApiHeaderOptions[]
): MethodDecorator & ClassDecorator => {
return (
target: object | Function,
key?: string | symbol,
Expand Down

0 comments on commit 395c612

Please sign in to comment.