Skip to content

feat: Add support for @Params() decorator #157

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

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

adityabmv
Copy link

@adityabmv adityabmv commented May 14, 2025

In version 5.0.0, the OpenAPI generator did not parse or generate the JSONSchema defined on fields in class-validator classes used with the @Params() decorator. This caused issues when attempting to generate accurate OpenAPI specifications, as the schema for path parameters would be missing in the final output.

Basic tests have been added to verify the feature works as expected.

Example -

class ListUserParams {
  @IsMongoId()
  @IsString()
  @JSONSchema({
    description: 'ID of the user',
    example: '60d5ec49b3f1c8e4a8f8b8c1',
    type: 'string',
    format: 'Mongo ObjectId',
  })
  id: string;

  @IsString()
  @IsOptional()
  @JSONSchema({
    description: 'Name of the user',
    example: 'John Doe',
    type: 'string',
  })
  name: string;
}

Generated Spec

      {
        in: 'path',
        name: 'id',
        required: true,
        schema: {
          description: 'ID of the user',
          example: '60d5ec49b3f1c8e4a8f8b8c1',
          type: 'string',
          format: 'Mongo ObjectId',
          pattern: '^[0-9a-fA-F]{24}$',
        },
      },
      {
        in: 'path',
        name: 'name',
        required: false,
        schema: {
          description: 'Name of the user',
          example: 'John Doe',
          type: 'string',
        },
      },

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant