-
Notifications
You must be signed in to change notification settings - Fork 34
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
Problem with arrays #27
Comments
Nevermind, just missed it in the docs:
|
I'm having a similar issue. Even though I set up metadata storage it still returns Here's the code: import { validationMetadatasToSchemas } from 'class-validator-jsonschema';
import { defaultMetadataStorage } from 'class-transformer/storage';
const schemas = validationMetadatasToSchemas({
classTransformerMetadataStorage: defaultMetadataStorage,
}); import { ValidateNested } from 'class-validator';
import { Type } from 'class-transformer';
class Child {
name: string;
}
class BadRequestValidationError {
@ValidateNested({each: true})
@Type(() => Child)
children!: Child[];
@ValidateNested()
@Type(() => Child)
child!: Child;
} The above definitions generated the following {
"properties": {
"children": {
"items": {
"$ref": "#/definitions/Child"
},
"type": "array"
},
"child": {
"$ref": "#/definitions/Child"
}
},
"type": "object",
"required": [
"children",
"child"
]
} Logging MetadataStorage {
_typeMetadatas: Map(1) {
[Function: BadRequestValidationError] => Map(2) { 'children' => [TypeMetadata], 'child' => [TypeMetadata] }
},
_transformMetadatas: Map(0) {},
_exposeMetadatas: Map(0) {},
_excludeMetadatas: Map(0) {},
_ancestorsMap: Map(0) {}
} Maybe there has been some breaking changes to |
Couple of things:
I've updated the sample project to demonstrate nested validation, please check out epiphone/routing-controllers-openapi@bea6f3d. |
Hi, thanks a lot for this great package !
I've got one issue with arrays: I always get type
$ref: "#/definitions/Array"
. I can reproduce with the following test (just add it and runjest ./__tests__/arrays.test.ts
):Which prints:
Any clue ?
The text was updated successfully, but these errors were encountered: