Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cover parameters in decorator created with createParamDecorator #960

Closed
dragoscirjan opened this issue Sep 14, 2020 · 1 comment
Closed

Comments

@dragoscirjan
Copy link

dragoscirjan commented Sep 14, 2020

I'm submitting a...


[ ] Regression 
[ ] Bug report
[x ] Feature request
[ ] Documentation issue or request
[ ] Support request => Please do not submit support request here, instead post your question on Stack Overflow.

Hi guys,

I have the following case:

const ParamsFromHeaders = createParamDecorator((data: unknown, ctx: ExecutionContext) => {
  const request = ctx.switchToHttp().getRequest<Request>();
  return {
    param1: request.headers['nonce'],
    param2: request.headers['uid'],
  };
});

export class ParamsFromHeadersDto {
  @ApiProperty({...})
  param1: string;

  @ApiProperty({...})
  param2: string;
}

@Controller('/path')
export class Controller {
  @Get('/subpath')
  async workWithHeaders(
    @ParamsFromHeaders () headers: ParamsFromHeadersDto
  ): Promise<void> {
    // ...
  }
}

Current behavior

So far, from what I've read, swagger does not support a custom param decorator so the described properties will not be indexed.

If, instead @FaramsFromHeaders() headers: ... I would use @Headers() headers: ... the properties would be indexed and documented.

Expected behavior

There should be a way to add the custom decorators that swagger will "look into" and index those properties.

If there is a way already, please let me know, if not, could we implement one?

@kamilmysliwiec
Copy link
Member

Duplicate #32

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants