0

Does the NestJS OpenAPI/Swagger implementation support reuse of common parameters?

This would save me from having to litter my endpoint with identical @ApiImplicitQuery decorators.

1 Answer 1

2

You could just create your own reusable decorator:

const ApiRoleQuery = ApiImplicitQuery({
  name: 'role',
  enum: ['Admin', 'Moderator', 'User'],
});

and then use it in your controller:

@ApiRoleQuery
@Get()
async filterByRole(@Query('role') role) {
  // ...
}
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.