lucasrochagit / nest-mongo-query-parser

A MongoDB query string parser to be used in applications developed with NestJS.
Apache License 2.0
12 stars 8 forks source link

DTO validation and Query in Swagger #2

Closed shefaligoel136 closed 1 year ago

shefaligoel136 commented 2 years ago

Is it possible to do DTO Validation on filters? and also how to show query in swagger?

lucasrochagit commented 2 years ago

Hello @shefaligoel136, sorry by delay to answer you.

About the first question, in the library all fields informed in the query that are not part of the reserved words for the other types of query params (like limit, skip, page, sort, select, populate) are considered filters. Therefore, I believe that it is kind of complicated to add a DTO for filters, given the dynamics of the fields that can be used as filters. In the future, I intend to implement some advanced features, such as an allowList of filters to be used if you want to use MethodDecorator instead of ParamDecorator. But if you have any specific validation suggestions for any kind of data, please add a pull request, I'll be happy to add new features to the library. :)

On the second question, I haven't used this feature yet, but I can do some tests. I believe you can document the MongoQueryModel object as the @ApiQuery() parameter if you are using the NestJS recommended library for OpenAPI documentation, but I'm not sure.

j-vitali commented 6 months ago

hi, any updates about this??