Skip to content

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