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

NestJS 10 is incorrectly parsing the jsdocs comments to generate swagger docs #2927

Closed
2 of 4 tasks
samaratungajs opened this issue Apr 24, 2024 · 1 comment
Closed
2 of 4 tasks

Comments

@samaratungajs
Copy link

Is there an existing issue for this?

  • I have searched the existing issues

Current behavior

We are upgrading our app from NestJS9 to NestJS10. While doing the upgrade we noticed the following. As in the Screenshot now the JSDocs comments are parsed as just literals and include @ type & @ memberof in the swagger doc this worked fine before v10 of NestJS creating swagger docs without messing up with other jsdocs attributes.

Upgraded @nestjs/swagger v 6.0.4 to 7.3.1

Screenshot 2024-04-24 at 12 26 21

cli config

{
  "collection": "@nestjs/schematics",
  "sourceRoot": "src",
  "compilerOptions": {
    "plugins": [
      {
        "name": "@nestjs/swagger",
        "options": {
          "classValidatorShim": true,
          "introspectComments": true
        }
      }
    ]
  }
}

affected jsdoc

export class UserListFilterDto extends OffsetPaginationBaseDto {
  /**
   * Filter users by firstname lastname or email
   * @example 'q'
   * @type {string}
   * @memberof UserListFilterDto
   */
  @IsOptional()
  @IsString()
  query?: string;

  /**
   * Filter by user role
   *
   * @type {Roles}
   * @memberof UserListFilterDto
   */
  @IsOptional()
  @IsEnum(Roles)
  role?: Roles;

  /**
   * Sort users, defaulted to `desc` by `created at`
   *
   * @type {SortOrder}
   * @memberof UserListFilterDto
   */
  @IsOptional()
  @IsEnum(SortOrder)
  order?: SortOrder = SortOrder.DESC;

  /**
   * Sort users
   *
   * @type {UserListSortBy}
   * @memberof UserListFilterDto
   */
  @IsOptional()
  @IsEnum(UserListSortBy)
  sortBy?: UserListSortBy = UserListSortBy.CREATED_AT;
}

Minimum reproduction code

https://gist.github.com/samaratungajs/79efceb03d722c66cf17b40e096f217a

Steps to reproduce

No response

Expected behavior

swagger docs without unnecessary literals

behavior before upgrade
Screenshot 2024-04-24 at 12 21 05
literal

Package version

7.3.1

NestJS version

10.3.7

Node.js version

20.12.2

In which operating systems have you tested?

  • macOS
  • Windows
  • Linux

Other

No response

@micalevisk
Copy link
Member

I just tested with nestjs v10 (@nestjs/swagger@7) and nestjs v9 (@nestjs/swagger@6)

image
image

So I don't think that this is a regression

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