There appears to be a regression bug. The instructions provided in the readme work on 3.1.1 but do not work on version 5.0.0
// eslint-disable-next-line max-classes-per-file
import { Type } from 'class-transformer';
import { IsString, ValidateNested } from 'class-validator';
import { validationMetadatasToSchemas } from 'class-validator-jsonschema';
const { defaultMetadataStorage } = require('class-transformer/cjs/storage');
class BlogPost {
@IsString()
public words: string;
}
class User {
@ValidateNested({ each: true })
@Type(() => BlogPost)
public blogPosts: BlogPost[];
}
const schemas = validationMetadatasToSchemas({
classTransformerMetadataStorage: defaultMetadataStorage,
});
TypeError: Cannot read properties of undefined (reading 'map')
17 | }
18 |
> 19 | const schemas = validationMetadatasToSchemas({
| ^
20 | classTransformerMetadataStorage: defaultMetadataStorage,
21 | });
22 |
at populateMetadatasWithConstraints (../../common/temp/node_modules/.pnpm/class-validator-jsonschema@5.0.0_e6kgdsnyya5caxg3ysdyxrqm7a/node_modules/class-validator-jsonschema/src/index.ts:146:20)
at getMetadatasFromStorage (../../common/temp/node_modules/.pnpm/class-validator-jsonschema@5.0.0_e6kgdsnyya5caxg3ysdyxrqm7a/node_modules/class-validator-jsonschema/src/index.ts:137:23)
at validationMetadatasToSchemas (../../common/temp/node_modules/.pnpm/class-validator-jsonschema@5.0.0_e6kgdsnyya5caxg3ysdyxrqm7a/node_modules/class-validator-jsonschema/src/index.ts:29:21)
at Object.<anonymous> (src/__tests__/te.test.ts:19:45)
When using version 5.0.0 the only way to call validationMetadatasToSchemas appears to be without any "()" or "({}".
There appears to be a regression bug. The instructions provided in the readme work on 3.1.1 but do not work on version 5.0.0
When using version 5.0.0 the only way to call validationMetadatasToSchemas appears to be without any "()" or "({}".