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

Incorrect enum type always 'array' #2615

Closed
2 of 4 tasks
alexandrulesi opened this issue Sep 14, 2023 · 3 comments
Closed
2 of 4 tasks

Incorrect enum type always 'array' #2615

alexandrulesi opened this issue Sep 14, 2023 · 3 comments

Comments

@alexandrulesi
Copy link

alexandrulesi commented Sep 14, 2023

Is there an existing issue for this?

  • I have searched the existing issues

Current behavior

When specifying ApiPropertyOptions enum the OAS now always now specifies the type to be 'array' instead of what it actually is. Seems to be happening when there is an @ApiProperty({ isArray: true }) referencing it.

This was introduced in version 7.1.8, it was working fine before

Minimum reproduction code

https://github.com/alexandrulesi/nestjs-bug-repro

Steps to reproduce

  1. npm i
  2. npm start
  3. check console log with faulty type
  4. change nestjs/swagger version to 7.1.8
  5. npm i
  6. check console log with correct type

Expected behavior

Enum types should be what it is, in this case string, and not array

You can also check the json dumps for comparison

Package version

7.1.11

NestJS version

No response

Node.js version

No response

In which operating systems have you tested?

  • macOS
  • Windows
  • Linux

Other

No response

@kamilmysliwiec
Copy link
Member

Would you like to create a PR for this issue?

@alexandrulesi
Copy link
Author

I'm afraid I'm not sure I'll find the time at the moment

@IodizedGabe
Copy link
Contributor

This appears to have been introduced by this change:
#2592

Previously, this would always assume that the enum was a string. Now that it takes into account the declared type, it can erroneously be set as an array.

IodizedGabe added a commit to IodizedGabe/swagger that referenced this issue Oct 3, 2023
If an enum property is decorated with `isArray: true`, its type should be derived
from the type of the enum item, rather than as an `array`.
kamilmysliwiec added a commit that referenced this issue Oct 4, 2023
…sed-enum

fix(): Derive enum types correctly when defined as an array #2615
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants