Closed dfrechdev closed 5 years ago
Found that the reason is that multi
is currently hard-coded in https://github.com/nestjs/swagger/blob/master/lib/decorators/api-implicit-query.decorator.ts at line 43. Is there a reason for this? If not, I can fix this and create a PR if you want.
@dfrechdev I wasn't so sure when I submitted that PR for ApiImplicitQuery. I thought mainly because it had something to do with swagger-ui-express
at the time regarding collectionFormat
being multi
.
I can confirm this issue. @dfrechdev, could you open a PR with your fix?
Fixed in 3.1.0
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.
I'm submitting a...
Current behavior
When you use the ApiImplicitQuery decorator and set
enum
andisArray
to true, the attributecollectionFormat
is by default set tomulti
and cannot be overwritten. When used withoutenum
andisArray
only, the attributecollectionFormat
is respected.This
for example results in
?role=Admin,Moderator
.In contrast, this
results in
?role=Admin&role=Moderator
.Expected behavior
The attribute
collectionFormat
is respected when set for enum arrays.Minimal reproduction of the problem with instructions
See above examples
What is the motivation / use case for changing the behavior?
The collection format should also be selectable when enums are used. This has also been asked on stack overflow at https://stackoverflow.com/questions/55767782/nestjs-swagger-how-to-declare-multiselect-enum-field.
Environment
"@nestjs/common": "^6.1.1", "@nestjs/core": "^6.1.1", "@nestjs/platform-express": "^6.1.1", "@nestjs/swagger": "^3.0.2", "swagger-ui-express": "^4.0.2"