darraghoriordan / eslint-plugin-nestjs-typed

Some eslint rules for working with NestJs projects
http://www.darraghoriordan.com
171 stars 34 forks source link

Swagger, when I add `enumName` to ApiProperty options, description not display in Swagger UI #46

Closed its-monotype closed 1 year ago

its-monotype commented 1 year ago
 @ApiProperty({
    enum: BotStatusEnum,
    enumName: 'BotStatusEnum',
    name: 'status',
    description: `
    Current status of the bot:
    * '${BotStatusEnum.ComingSoon}' - Bot will be available soon (in development)
    * '${BotStatusEnum.Working}' - Bot is functional and available for use
    * '${BotStatusEnum.Updating}' - Bot is currently being updated`,
  })
  @Column({
    type: 'enum',
    enum: BotStatusEnum,
  })
  status: BotStatusEnum;

image

If I remove enumName, then I can see the description:

image

darraghoriordan commented 1 year ago

Hey, This is probably something to raise in the https://github.com/nestjs/swagger repository. I don't think this package is causing this issue

Is there something that makes you think this is caused by the eslint rule?

its-monotype commented 1 year ago

Not really, but it is strange behaviour that I do not understand because it's suggested to set enumName explicitly but If I do it the description for the enum can't be displayed

darraghoriordan commented 1 year ago

Yea ok. I'm not going to be able to change the underlying behaviour of the nest swagger library so if you need to use descriptions you can turn off this rule in your eslint configuration so you can skip setting an enumName.

   rules: {
   "@darraghor/nestjs-typed/api-enum-property-best-practices":
            "off",
   }