class-validator-jsonschema
Advanced tools
Comparing version 1.3.1 to 2.0.0-rc1
@@ -41,3 +41,3 @@ // tslint:disable:no-submodule-imports | ||
const metadata = getFromContainer(MetadataStorage).validationMetadatas | ||
const schemas = validationMetadatasToSchemas(metadata, {}) | ||
const schemas = validationMetadatasToSchemas() | ||
@@ -71,3 +71,3 @@ expect(schemas.ValidationErrorModel).toEqual({ | ||
const metadata = getFromContainer(MetadataStorage).validationMetadatas | ||
const schemas = validationMetadatasToSchemas(metadata, { | ||
const schemas = validationMetadatasToSchemas({ | ||
classTransformerMetadataStorage: defaultMetadataStorage | ||
@@ -74,0 +74,0 @@ }) |
import { | ||
getFromContainer, | ||
MetadataStorage, | ||
getMetadataStorage, | ||
Validate, | ||
@@ -36,7 +35,7 @@ ValidationArguments, | ||
const metadata = _.get(getFromContainer(MetadataStorage), 'validationMetadatas') | ||
describe('custom validation classes', () => { | ||
it('uses property type if no additional converter is supplied', () => { | ||
const schemas = validationMetadatasToSchemas(metadata) | ||
const schemas = validationMetadatasToSchemas({ | ||
classValidatorMetadataStorage: getMetadataStorage() | ||
}) | ||
expect(schemas.Post).toEqual({ | ||
@@ -61,14 +60,9 @@ properties: { | ||
it('uses additionalConverter to generate schema when supplied', () => { | ||
const schemas = validationMetadatasToSchemas(metadata, { | ||
const schemas = validationMetadatasToSchemas({ | ||
additionalConverters: { | ||
customValidation: meta => { | ||
if (meta.constraintCls === CustomTextLength) { | ||
return { | ||
maxLength: meta.constraints[1] - 1, | ||
minLength: meta.constraints[0] + 1, | ||
type: 'string' | ||
} | ||
} | ||
return {} | ||
} | ||
CustomTextLength: meta => ({ | ||
maxLength: meta.constraints[1] - 1, | ||
minLength: meta.constraints[0] + 1, | ||
type: 'string' | ||
}) | ||
} | ||
@@ -75,0 +69,0 @@ }) |
@@ -104,3 +104,3 @@ // tslint:disable:object-literal-sort-keys | ||
@validator.IsLowercase() isLowerCase: string | ||
@validator.IsMobilePhone('en') isMobilePhone: string | ||
@validator.IsMobilePhone('en-GB') isMobilePhone: string | ||
@validator.IsMongoId() isMongoId: string | ||
@@ -107,0 +107,0 @@ @validator.IsMultibyte() isMultibyte: string |
@@ -5,3 +5,2 @@ // tslint:disable:no-submodule-imports | ||
ArrayNotContains, | ||
getFromContainer, | ||
IsBoolean, | ||
@@ -13,7 +12,6 @@ IsEmpty, | ||
MaxLength, | ||
MetadataStorage, | ||
MinLength, | ||
ValidateNested | ||
} from 'class-validator' | ||
import { ValidationMetadata } from 'class-validator/metadata/ValidationMetadata' | ||
import { ValidationMetadata } from 'class-validator/types/metadata/ValidationMetadata' | ||
import * as _ from 'lodash' | ||
@@ -55,6 +53,15 @@ | ||
it('handles empty metadata', () => { | ||
expect(validationMetadatasToSchemas([])).toEqual({}) | ||
const emptyStorage: any = { | ||
constraintMetadatas: [], | ||
validationMetadatas: [] | ||
} | ||
expect( | ||
validationMetadatasToSchemas({ | ||
classValidatorMetadataStorage: emptyStorage | ||
}) | ||
).toEqual({}) | ||
}) | ||
it('returns empty schema object when no converter found', () => { | ||
it('derives schema from property type when no converter is found', () => { | ||
const customMetadata: ValidationMetadata = { | ||
@@ -72,13 +79,15 @@ always: false, | ||
} | ||
const storage: any = { | ||
constraintMetadatas: [], | ||
validationMetadatas: [customMetadata] | ||
} | ||
const schemas = validationMetadatasToSchemas([customMetadata]) | ||
expect(schemas.User.properties!.id).toEqual({}) | ||
const schemas = validationMetadatasToSchemas({ | ||
classValidatorMetadataStorage: storage | ||
}) | ||
expect(schemas.User.properties!.id).toEqual({ type: 'string' }) | ||
}) | ||
it('combines converted class-validator metadata into JSON Schemas', () => { | ||
const metadata = _.get( | ||
getFromContainer(MetadataStorage), | ||
'validationMetadatas' | ||
) | ||
const schemas = validationMetadatasToSchemas(metadata) | ||
const schemas = validationMetadatasToSchemas() | ||
@@ -85,0 +94,0 @@ expect(schemas).toEqual({ |
@@ -39,3 +39,3 @@ // tslint:disable:no-submodule-imports | ||
@IsDefined() | ||
@IsMobilePhone('fi') | ||
@IsMobilePhone('fi-FI') | ||
phone: string | ||
@@ -135,3 +135,3 @@ } | ||
it('handles inherited IsDefined decorators when skipMissingProperties is enabled', () => { | ||
const schemas = validationMetadatasToSchemas(metadatas, { | ||
const schemas = validationMetadatasToSchemas({ | ||
skipMissingProperties: true | ||
@@ -138,0 +138,0 @@ }) |
import { | ||
getFromContainer, | ||
IS_STRING, | ||
IsDefined, | ||
@@ -7,6 +8,6 @@ IsEmail, | ||
IsString, | ||
MAX_LENGTH, | ||
MaxLength, | ||
MetadataStorage, | ||
ValidateNested, | ||
ValidationTypes | ||
ValidateNested | ||
} from 'class-validator' | ||
@@ -47,3 +48,3 @@ import * as _ from 'lodash' | ||
it('handles refPointerPrefix option', () => { | ||
const schemas = validationMetadatasToSchemas(metadata, { | ||
const schemas = validationMetadatasToSchemas({ | ||
refPointerPrefix: '#/components/schema/' | ||
@@ -67,9 +68,9 @@ }) | ||
const schemas = validationMetadatasToSchemas(metadata, { | ||
const schemas = validationMetadatasToSchemas({ | ||
additionalConverters: { | ||
[ValidationTypes.IS_STRING]: { | ||
[IS_STRING]: { | ||
description: 'A string value', | ||
type: 'string' | ||
}, | ||
[ValidationTypes.MAX_LENGTH]: meta => ({ | ||
[MAX_LENGTH]: meta => ({ | ||
exclusiveMaximum: true, | ||
@@ -96,3 +97,3 @@ maxLength: meta.constraints[0] + 1, | ||
const schemas = validationMetadatasToSchemas(metadata, { | ||
const schemas = validationMetadatasToSchemas({ | ||
skipMissingProperties: true | ||
@@ -99,0 +100,0 @@ }) |
@@ -1,2 +0,2 @@ | ||
import { ValidationMetadata } from 'class-validator/metadata/ValidationMetadata'; | ||
import { ValidationMetadata } from 'class-validator/types/metadata/ValidationMetadata'; | ||
import { SchemaObject } from 'openapi3-ts'; | ||
@@ -3,0 +3,0 @@ import 'reflect-metadata'; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const class_validator_1 = require("class-validator"); | ||
const cv = require("class-validator"); | ||
const _ = require("lodash"); | ||
require("reflect-metadata"); | ||
exports.defaultConverters = { | ||
[class_validator_1.ValidationTypes.CUSTOM_VALIDATION]: (meta, options) => { | ||
[cv.ValidationTypes.CUSTOM_VALIDATION]: (meta, options) => { | ||
if (_.isFunction(meta.target)) { | ||
@@ -13,3 +13,3 @@ const type = getPropType(meta.target.prototype, meta.propertyName); | ||
}, | ||
[class_validator_1.ValidationTypes.NESTED_VALIDATION]: (meta, options) => { | ||
[cv.ValidationTypes.NESTED_VALIDATION]: (meta, options) => { | ||
if (_.isFunction(meta.target)) { | ||
@@ -25,17 +25,17 @@ const typeMeta = options.classTransformerMetadataStorage | ||
}, | ||
[class_validator_1.ValidationTypes.CONDITIONAL_VALIDATION]: {}, | ||
[class_validator_1.ValidationTypes.IS_DEFINED]: {}, | ||
[class_validator_1.ValidationTypes.EQUALS]: meta => { | ||
[cv.ValidationTypes.CONDITIONAL_VALIDATION]: {}, | ||
[cv.ValidationTypes.IS_DEFINED]: {}, | ||
[cv.EQUALS]: (meta) => { | ||
const schema = constraintToSchema(meta.constraints[0]); | ||
if (schema) { | ||
return Object.assign({}, schema, { enum: [meta.constraints[0]] }); | ||
return Object.assign(Object.assign({}, schema), { enum: [meta.constraints[0]] }); | ||
} | ||
}, | ||
[class_validator_1.ValidationTypes.NOT_EQUALS]: meta => { | ||
[cv.NOT_EQUALS]: (meta) => { | ||
const schema = constraintToSchema(meta.constraints[0]); | ||
if (schema) { | ||
return { not: Object.assign({}, schema, { enum: [meta.constraints[0]] }) }; | ||
return { not: Object.assign(Object.assign({}, schema), { enum: [meta.constraints[0]] }) }; | ||
} | ||
}, | ||
[class_validator_1.ValidationTypes.IS_EMPTY]: { | ||
[cv.IS_EMPTY]: { | ||
anyOf: [ | ||
@@ -51,213 +51,213 @@ { type: 'string', enum: [''] }, | ||
{ type: 'array' }, | ||
{ type: 'object' } | ||
] | ||
{ type: 'object' }, | ||
], | ||
}, | ||
nullable: true | ||
} | ||
] | ||
nullable: true, | ||
}, | ||
], | ||
}, | ||
[class_validator_1.ValidationTypes.IS_NOT_EMPTY]: { | ||
[cv.IS_NOT_EMPTY]: { | ||
minLength: 1, | ||
type: 'string' | ||
type: 'string', | ||
}, | ||
[class_validator_1.ValidationTypes.IS_IN]: meta => { | ||
[cv.IS_IN]: (meta) => { | ||
const [head, ...rest] = meta.constraints[0].map(constraintToSchema); | ||
if (head && _.every(rest, { type: head.type })) { | ||
return Object.assign({}, head, { enum: meta.constraints[0] }); | ||
return Object.assign(Object.assign({}, head), { enum: meta.constraints[0] }); | ||
} | ||
}, | ||
[class_validator_1.ValidationTypes.IS_NOT_IN]: meta => { | ||
[cv.IS_NOT_IN]: (meta) => { | ||
const [head, ...rest] = meta.constraints[0].map(constraintToSchema); | ||
if (head && _.every(rest, { type: head.type })) { | ||
return { not: Object.assign({}, head, { enum: meta.constraints[0] }) }; | ||
return { not: Object.assign(Object.assign({}, head), { enum: meta.constraints[0] }) }; | ||
} | ||
}, | ||
[class_validator_1.ValidationTypes.IS_BOOLEAN]: { | ||
type: 'boolean' | ||
[cv.IS_BOOLEAN]: { | ||
type: 'boolean', | ||
}, | ||
[class_validator_1.ValidationTypes.IS_DATE]: { | ||
[cv.IS_DATE]: { | ||
oneOf: [ | ||
{ format: 'date', type: 'string' }, | ||
{ format: 'date-time', type: 'string' } | ||
] | ||
{ format: 'date-time', type: 'string' }, | ||
], | ||
}, | ||
[class_validator_1.ValidationTypes.IS_NUMBER]: { | ||
type: 'number' | ||
[cv.IS_NUMBER]: { | ||
type: 'number', | ||
}, | ||
[class_validator_1.ValidationTypes.IS_STRING]: { | ||
type: 'string' | ||
[cv.IS_STRING]: { | ||
type: 'string', | ||
}, | ||
[class_validator_1.ValidationTypes.IS_DATE_STRING]: { | ||
[cv.IS_DATE_STRING]: { | ||
pattern: 'd{4}-[01]d-[0-3]dT[0-2]d:[0-5]d:[0-5]d.d+Z?', | ||
type: 'string' | ||
type: 'string', | ||
}, | ||
[class_validator_1.ValidationTypes.IS_ARRAY]: { | ||
[cv.IS_ARRAY]: { | ||
items: {}, | ||
type: 'array' | ||
type: 'array', | ||
}, | ||
[class_validator_1.ValidationTypes.IS_INT]: { | ||
type: 'integer' | ||
[cv.IS_INT]: { | ||
type: 'integer', | ||
}, | ||
[class_validator_1.ValidationTypes.IS_ENUM]: meta => { | ||
[cv.IS_ENUM]: (meta) => { | ||
return { | ||
enum: Object.values(meta.constraints[0]), | ||
type: 'string' | ||
type: 'string', | ||
}; | ||
}, | ||
[class_validator_1.ValidationTypes.IS_DIVISIBLE_BY]: meta => ({ | ||
[cv.IS_DIVISIBLE_BY]: (meta) => ({ | ||
multipleOf: meta.constraints[0], | ||
type: 'number' | ||
type: 'number', | ||
}), | ||
[class_validator_1.ValidationTypes.IS_POSITIVE]: { | ||
[cv.IS_POSITIVE]: { | ||
exclusiveMinimum: true, | ||
minimum: 0, | ||
type: 'number' | ||
type: 'number', | ||
}, | ||
[class_validator_1.ValidationTypes.IS_NEGATIVE]: { | ||
[cv.IS_NEGATIVE]: { | ||
exclusiveMaximum: true, | ||
maximum: 0, | ||
type: 'number' | ||
type: 'number', | ||
}, | ||
[class_validator_1.ValidationTypes.MIN]: meta => ({ | ||
[cv.MIN]: (meta) => ({ | ||
minimum: meta.constraints[0], | ||
type: 'number' | ||
type: 'number', | ||
}), | ||
[class_validator_1.ValidationTypes.MAX]: meta => ({ | ||
[cv.MAX]: (meta) => ({ | ||
maximum: meta.constraints[0], | ||
type: 'number' | ||
type: 'number', | ||
}), | ||
[class_validator_1.ValidationTypes.MIN_DATE]: meta => ({ | ||
[cv.MIN_DATE]: (meta) => ({ | ||
description: `After ${meta.constraints[0].toJSON()}`, | ||
oneOf: [ | ||
{ format: 'date', type: 'string' }, | ||
{ format: 'date-time', type: 'string' } | ||
] | ||
{ format: 'date-time', type: 'string' }, | ||
], | ||
}), | ||
[class_validator_1.ValidationTypes.MAX_DATE]: meta => ({ | ||
[cv.MAX_DATE]: (meta) => ({ | ||
description: `Before ${meta.constraints[0].toJSON()}`, | ||
oneOf: [ | ||
{ format: 'date', type: 'string' }, | ||
{ format: 'date-time', type: 'string' } | ||
] | ||
{ format: 'date-time', type: 'string' }, | ||
], | ||
}), | ||
[class_validator_1.ValidationTypes.IS_BOOLEAN_STRING]: { | ||
[cv.IS_BOOLEAN_STRING]: { | ||
enum: ['true', 'false'], | ||
type: 'string' | ||
type: 'string', | ||
}, | ||
[class_validator_1.ValidationTypes.IS_NUMBER_STRING]: { | ||
[cv.IS_NUMBER_STRING]: { | ||
pattern: '^[-+]?[0-9]+$', | ||
type: 'string' | ||
type: 'string', | ||
}, | ||
[class_validator_1.ValidationTypes.CONTAINS]: meta => ({ | ||
[cv.CONTAINS]: (meta) => ({ | ||
pattern: meta.constraints[0], | ||
type: 'string' | ||
type: 'string', | ||
}), | ||
[class_validator_1.ValidationTypes.NOT_CONTAINS]: meta => ({ | ||
[cv.NOT_CONTAINS]: (meta) => ({ | ||
not: { pattern: meta.constraints[0] }, | ||
type: 'string' | ||
type: 'string', | ||
}), | ||
[class_validator_1.ValidationTypes.IS_ALPHA]: { | ||
[cv.IS_ALPHA]: { | ||
pattern: '^[a-zA-Z]+$', | ||
type: 'string' | ||
type: 'string', | ||
}, | ||
[class_validator_1.ValidationTypes.IS_ALPHANUMERIC]: { | ||
[cv.IS_ALPHANUMERIC]: { | ||
pattern: '^[0-9a-zA-Z]+$', | ||
type: 'string' | ||
type: 'string', | ||
}, | ||
[class_validator_1.ValidationTypes.IS_ASCII]: { | ||
[cv.IS_ASCII]: { | ||
pattern: '^[\\x00-\\x7F]+$', | ||
type: 'string' | ||
type: 'string', | ||
}, | ||
[class_validator_1.ValidationTypes.IS_BASE64]: { | ||
[cv.IS_BASE64]: { | ||
format: 'base64', | ||
type: 'string' | ||
type: 'string', | ||
}, | ||
[class_validator_1.ValidationTypes.IS_BYTE_LENGTH]: { | ||
type: 'string' | ||
[cv.IS_BYTE_LENGTH]: { | ||
type: 'string', | ||
}, | ||
[class_validator_1.ValidationTypes.IS_CREDIT_CARD]: { | ||
[cv.IS_CREDIT_CARD]: { | ||
format: 'credit-card', | ||
type: 'string' | ||
type: 'string', | ||
}, | ||
[class_validator_1.ValidationTypes.IS_CURRENCY]: { | ||
[cv.IS_CURRENCY]: { | ||
format: 'currency', | ||
type: 'string' | ||
type: 'string', | ||
}, | ||
[class_validator_1.ValidationTypes.IS_EMAIL]: { | ||
[cv.IS_EMAIL]: { | ||
format: 'email', | ||
type: 'string' | ||
type: 'string', | ||
}, | ||
[class_validator_1.ValidationTypes.IS_FQDN]: { | ||
[cv.IS_FQDN]: { | ||
format: 'hostname', | ||
type: 'string' | ||
type: 'string', | ||
}, | ||
[class_validator_1.ValidationTypes.IS_FULL_WIDTH]: { | ||
[cv.IS_FULL_WIDTH]: { | ||
pattern: '[^\\u0020-\\u007E\\uFF61-\\uFF9F\\uFFA0-\\uFFDC\\uFFE8-\\uFFEE0-9a-zA-Z]', | ||
type: 'string' | ||
type: 'string', | ||
}, | ||
[class_validator_1.ValidationTypes.IS_HALF_WIDTH]: { | ||
[cv.IS_HALF_WIDTH]: { | ||
pattern: '[\\u0020-\\u007E\\uFF61-\\uFF9F\\uFFA0-\\uFFDC\\uFFE8-\\uFFEE0-9a-zA-Z]', | ||
type: 'string' | ||
type: 'string', | ||
}, | ||
[class_validator_1.ValidationTypes.IS_VARIABLE_WIDTH]: { | ||
type: 'string' | ||
[cv.IS_VARIABLE_WIDTH]: { | ||
type: 'string', | ||
}, | ||
[class_validator_1.ValidationTypes.IS_HEX_COLOR]: { | ||
[cv.IS_HEX_COLOR]: { | ||
pattern: '^#?([0-9a-fA-F]{3}|[0-9a-fA-F]{6})$', | ||
type: 'string' | ||
type: 'string', | ||
}, | ||
[class_validator_1.ValidationTypes.IS_HEXADECIMAL]: { | ||
[cv.IS_HEXADECIMAL]: { | ||
pattern: '^[0-9a-fA-F]+$', | ||
type: 'string' | ||
type: 'string', | ||
}, | ||
[class_validator_1.ValidationTypes.IS_IP]: meta => ({ | ||
[cv.IS_IP]: (meta) => ({ | ||
format: 'ipv' + (meta.constraints[0] === '6' ? 6 : 4), | ||
type: 'string' | ||
type: 'string', | ||
}), | ||
[class_validator_1.ValidationTypes.IS_ISBN]: { | ||
[cv.IS_ISBN]: { | ||
format: 'isbn', | ||
type: 'string' | ||
type: 'string', | ||
}, | ||
[class_validator_1.ValidationTypes.IS_ISIN]: { | ||
[cv.IS_ISIN]: { | ||
format: 'isin', | ||
type: 'string' | ||
type: 'string', | ||
}, | ||
[class_validator_1.ValidationTypes.IS_ISO8601]: { | ||
[cv.IS_ISO8601]: { | ||
oneOf: [ | ||
{ format: 'date', type: 'string' }, | ||
{ format: 'date-time', type: 'string' } | ||
] | ||
{ format: 'date-time', type: 'string' }, | ||
], | ||
}, | ||
[class_validator_1.ValidationTypes.IS_JSON]: { | ||
[cv.IS_JSON]: { | ||
format: 'json', | ||
type: 'string' | ||
type: 'string', | ||
}, | ||
[class_validator_1.ValidationTypes.IS_LOWERCASE]: { | ||
type: 'string' | ||
[cv.IS_LOWERCASE]: { | ||
type: 'string', | ||
}, | ||
[class_validator_1.ValidationTypes.IS_MOBILE_PHONE]: { | ||
[cv.IS_MOBILE_PHONE]: { | ||
format: 'mobile-phone', | ||
type: 'string' | ||
type: 'string', | ||
}, | ||
[class_validator_1.ValidationTypes.IS_MONGO_ID]: { | ||
[cv.IS_MONGO_ID]: { | ||
pattern: '^[0-9a-fA-F]{24}$', | ||
type: 'string' | ||
type: 'string', | ||
}, | ||
[class_validator_1.ValidationTypes.IS_MULTIBYTE]: { | ||
[cv.IS_MULTIBYTE]: { | ||
pattern: '[^\\x00-\\x7F]', | ||
type: 'string' | ||
type: 'string', | ||
}, | ||
[class_validator_1.ValidationTypes.IS_SURROGATE_PAIR]: { | ||
[cv.IS_SURROGATE_PAIR]: { | ||
pattern: '[\\uD800-\\uDBFF][\\uDC00-\\uDFFF]', | ||
type: 'string' | ||
type: 'string', | ||
}, | ||
[class_validator_1.ValidationTypes.IS_URL]: { | ||
[cv.IS_URL]: { | ||
format: 'url', | ||
type: 'string' | ||
type: 'string', | ||
}, | ||
[class_validator_1.ValidationTypes.IS_UUID]: { | ||
[cv.IS_UUID]: { | ||
format: 'uuid', | ||
type: 'string' | ||
type: 'string', | ||
}, | ||
[class_validator_1.ValidationTypes.LENGTH]: meta => { | ||
[cv.LENGTH]: (meta) => { | ||
const [minLength, maxLength] = meta.constraints; | ||
@@ -269,22 +269,22 @@ if (maxLength || maxLength === 0) { | ||
}, | ||
[class_validator_1.ValidationTypes.IS_UPPERCASE]: { | ||
type: 'string' | ||
[cv.IS_UPPERCASE]: { | ||
type: 'string', | ||
}, | ||
[class_validator_1.ValidationTypes.MIN_LENGTH]: meta => ({ | ||
[cv.MIN_LENGTH]: (meta) => ({ | ||
minLength: meta.constraints[0], | ||
type: 'string' | ||
type: 'string', | ||
}), | ||
[class_validator_1.ValidationTypes.MAX_LENGTH]: meta => ({ | ||
[cv.MAX_LENGTH]: (meta) => ({ | ||
maxLength: meta.constraints[0], | ||
type: 'string' | ||
type: 'string', | ||
}), | ||
[class_validator_1.ValidationTypes.MATCHES]: meta => ({ | ||
[cv.MATCHES]: (meta) => ({ | ||
pattern: meta.constraints[0].source, | ||
type: 'string' | ||
type: 'string', | ||
}), | ||
[class_validator_1.ValidationTypes.IS_MILITARY_TIME]: { | ||
[cv.IS_MILITARY_TIME]: { | ||
pattern: '^([01]\\d|2[0-3]):?([0-5]\\d)$', | ||
type: 'string' | ||
type: 'string', | ||
}, | ||
[class_validator_1.ValidationTypes.ARRAY_CONTAINS]: meta => { | ||
[cv.ARRAY_CONTAINS]: (meta) => { | ||
const schemas = meta.constraints[0].map(constraintToSchema); | ||
@@ -296,7 +296,7 @@ if (schemas.length > 0 && _.every(schemas, 'type')) { | ||
items: { | ||
not: Object.assign({}, d, { enum: [meta.constraints[0][i]] }) | ||
} | ||
})) | ||
not: Object.assign(Object.assign({}, d), { enum: [meta.constraints[0][i]] }), | ||
}, | ||
})), | ||
}, | ||
type: 'array' | ||
type: 'array', | ||
}; | ||
@@ -306,3 +306,3 @@ } | ||
}, | ||
[class_validator_1.ValidationTypes.ARRAY_NOT_CONTAINS]: meta => { | ||
[cv.ARRAY_NOT_CONTAINS]: (meta) => { | ||
const schemas = meta.constraints[0].map(constraintToSchema); | ||
@@ -313,6 +313,6 @@ if (schemas.length > 0 && _.every(schemas, 'type')) { | ||
not: { | ||
anyOf: _.map(schemas, (d, i) => (Object.assign({}, d, { enum: [meta.constraints[0][i]] }))) | ||
} | ||
anyOf: _.map(schemas, (d, i) => (Object.assign(Object.assign({}, d), { enum: [meta.constraints[0][i]] }))), | ||
}, | ||
}, | ||
type: 'array' | ||
type: 'array', | ||
}; | ||
@@ -322,22 +322,22 @@ } | ||
}, | ||
[class_validator_1.ValidationTypes.ARRAY_NOT_EMPTY]: { | ||
[cv.ARRAY_NOT_EMPTY]: { | ||
items: {}, | ||
minItems: 1, | ||
type: 'array' | ||
type: 'array', | ||
}, | ||
[class_validator_1.ValidationTypes.ARRAY_MIN_SIZE]: meta => ({ | ||
[cv.ARRAY_MIN_SIZE]: (meta) => ({ | ||
items: {}, | ||
minItems: meta.constraints[0], | ||
type: 'array' | ||
type: 'array', | ||
}), | ||
[class_validator_1.ValidationTypes.ARRAY_MAX_SIZE]: meta => ({ | ||
[cv.ARRAY_MAX_SIZE]: (meta) => ({ | ||
items: {}, | ||
maxItems: meta.constraints[0], | ||
type: 'array' | ||
type: 'array', | ||
}), | ||
[class_validator_1.ValidationTypes.ARRAY_UNIQUE]: { | ||
[cv.ARRAY_UNIQUE]: { | ||
items: {}, | ||
type: 'array', | ||
uniqueItems: true | ||
} | ||
uniqueItems: true, | ||
}, | ||
}; | ||
@@ -368,2 +368,2 @@ function getPropType(target, property) { | ||
} | ||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZGVmYXVsdENvbnZlcnRlcnMuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi9zcmMvZGVmYXVsdENvbnZlcnRl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UE7SUFDN0IsSUFBSSxDQUFDLENBQUMsUUFBUSxDQUFDLFVBQVUsRUFBRSxJQUFJLENBQUMsRUFBRTtRQUNoQyxPQUFPLEVBQUUsSUFBSSxFQUFFLENBQUE7S0FDaEI7QUFDSCxDQUFDO0FBRUQsU0FBUyxjQUFjLENBQUMsSUFBUyxFQUFFLE9BQWlCO0lBQ2xELElBQUksQ0FBQyxDQUFDLFVBQVUsQ0FBQyxJQUFJLENBQUMsRUFBRTtRQUN0QixJQUFJLENBQUMsQ0FBQyxRQUFRLENBQUMsSUFBSSxDQUFDLFNBQVMsQ0FBQyxJQUFJLENBQUMsQ0FBQyxRQUFRLENBQUMsSUFBSSxDQUFDLFNBQVMsQ0FBQyxFQUFFO1lBQzVELE9BQU8sRUFBRSxJQUFJLEVBQUUsUUFBUSxFQUFFLENBQUE7U0FDMUI7YUFBTSxJQUFJLENBQUMsQ0FBQyxRQUFRLENBQUMsSUFBSSxDQUFDLFNBQVMsQ0FBQyxFQUFFO1lBQ3JDLE9BQU8sRUFBRSxJQUFJLEVBQUUsUUFBUSxFQUFFLENBQUE7U0FDMUI7YUFBTSxJQUFJLENBQUMsQ0FBQyxTQUFTLENBQUMsSUFBSSxDQUFDLFNBQVMsQ0FBQyxFQUFFO1lBQ3RDLE9BQU8sRUFBRSxJQUFJLEVBQUUsU0FBUyxFQUFFLENBQUE7U0FDM0I7UUFFRCxPQUFPLEVBQUUsSUFBSSxFQUFFLE9BQU8sQ0FBQyxnQkFBZ0IsR0FBRyxJQUFJLENBQUMsSUFBSSxFQUFFLENBQUE7S0FDdEQ7QUFDSCxDQUFDIn0= |
@@ -1,7 +0,6 @@ | ||
import { ValidationMetadata } from 'class-validator/metadata/ValidationMetadata'; | ||
import { SchemaObject } from 'openapi3-ts'; | ||
import { IOptions } from './options'; | ||
export { JSONSchema } from './decorators'; | ||
export declare function validationMetadatasToSchemas(metadatas: ValidationMetadata[], userOptions?: Partial<IOptions>): { | ||
export declare function validationMetadatasToSchemas(userOptions?: Partial<IOptions>): { | ||
[key: string]: SchemaObject; | ||
}; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const class_validator_1 = require("class-validator"); | ||
const cv = require("class-validator"); | ||
const _ = require("lodash"); | ||
const debug = require('debug')('routing-controllers-openapi'); | ||
const decorators_1 = require("./decorators"); | ||
@@ -11,7 +10,8 @@ const defaultConverters_1 = require("./defaultConverters"); | ||
exports.JSONSchema = decorators_2.JSONSchema; | ||
function validationMetadatasToSchemas(metadatas, userOptions) { | ||
const options = Object.assign({}, options_1.defaultOptions, userOptions); | ||
function validationMetadatasToSchemas(userOptions) { | ||
const options = Object.assign(Object.assign({}, options_1.defaultOptions), userOptions); | ||
const metadatas = getMetadatasFromStorage(options.classValidatorMetadataStorage); | ||
const schemas = _(metadatas) | ||
.groupBy('target.name') | ||
.mapValues(ownMetas => { | ||
.mapValues((ownMetas) => { | ||
const target = ownMetas[0].target; | ||
@@ -28,3 +28,3 @@ const metas = ownMetas.concat(getInheritedMetadatas(target, metadatas)); | ||
properties, | ||
type: 'object' | ||
type: 'object', | ||
}; | ||
@@ -41,4 +41,17 @@ const required = getRequiredPropNames(target, metas, options); | ||
exports.validationMetadatasToSchemas = validationMetadatasToSchemas; | ||
function getMetadatasFromStorage(storage) { | ||
const metadatas = _.get(storage, 'validationMetadatas'); | ||
const constraints = _.get(storage, 'constraintMetadatas'); | ||
for (const meta of metadatas) { | ||
if (meta.constraintCls) { | ||
const constraint = constraints.find((c) => c.target === meta.constraintCls); | ||
if (constraint) { | ||
meta.type = constraint.name; | ||
} | ||
} | ||
} | ||
return metadatas; | ||
} | ||
function getInheritedMetadatas(target, metadatas) { | ||
return metadatas.filter(d => d.target instanceof Function && | ||
return metadatas.filter((d) => d.target instanceof Function && | ||
target.prototype instanceof d.target && | ||
@@ -48,13 +61,9 @@ !_.find(metadatas, { | ||
target, | ||
type: d.type | ||
type: d.type, | ||
})); | ||
} | ||
function applyConverters(propertyMetadatas, options) { | ||
const converters = Object.assign({}, defaultConverters_1.defaultConverters, options.additionalConverters); | ||
const converters = Object.assign(Object.assign({}, defaultConverters_1.defaultConverters), options.additionalConverters); | ||
const convert = (meta) => { | ||
const converter = converters[meta.type]; | ||
if (!converter) { | ||
debug('No schema converter found for validation metadata', meta); | ||
return {}; | ||
} | ||
const converter = converters[meta.type] || converters[cv.ValidationTypes.CUSTOM_VALIDATION]; | ||
const items = _.isFunction(converter) ? converter(meta, options) : converter; | ||
@@ -73,11 +82,11 @@ return meta.each ? { items, type: 'array' } : items; | ||
function isDefined(metas) { | ||
return _.some(metas, { type: class_validator_1.ValidationTypes.IS_DEFINED }); | ||
return _.some(metas, { type: cv.ValidationTypes.IS_DEFINED }); | ||
} | ||
function isOptional(metas) { | ||
return _.some(metas, ({ type }) => _.includes([class_validator_1.ValidationTypes.CONDITIONAL_VALIDATION, class_validator_1.ValidationTypes.IS_EMPTY], type)); | ||
return _.some(metas, ({ type }) => _.includes([cv.ValidationTypes.CONDITIONAL_VALIDATION, cv.IS_EMPTY], type)); | ||
} | ||
return _(metadatas) | ||
.groupBy('propertyName') | ||
.pickBy(metas => { | ||
const [own, inherited] = _.partition(metas, d => d.target === target); | ||
.pickBy((metas) => { | ||
const [own, inherited] = _.partition(metas, (d) => d.target === target); | ||
return options.skipMissingProperties | ||
@@ -90,2 +99,2 @@ ? isDefined(own) || (!isOptional(own) && isDefined(inherited)) | ||
} | ||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi9zcmMvaW5kZXgudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7QUFDQSxxREFBaUQ7QUFFakQsNEJBQTJCO0FBRTNCLE1BQU0sS0FBSyxHQUFHLE9BQU8sQ0FBQyxPQUFPLENBQUMsQ0FBQyw2QkFBNkIsQ0FBQyxDQUFBO0FBRTdELDZDQUFnRDtBQUNoRCwyREFBd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; | ||
import { ValidatorOptions } from 'class-validator'; | ||
import { MetadataStorage as ClassTransformerMetadataStorage } from 'class-transformer/metadata/MetadataStorage'; | ||
import { MetadataStorage, ValidatorOptions } from 'class-validator'; | ||
import { ISchemaConverters } from './defaultConverters'; | ||
export interface IOptions extends ValidatorOptions { | ||
additionalConverters: ISchemaConverters; | ||
classTransformerMetadataStorage?: MetadataStorage; | ||
classTransformerMetadataStorage?: ClassTransformerMetadataStorage; | ||
classValidatorMetadataStorage: MetadataStorage; | ||
refPointerPrefix: string; | ||
} | ||
export declare const defaultOptions: IOptions; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const class_validator_1 = require("class-validator"); | ||
exports.defaultOptions = { | ||
additionalConverters: {}, | ||
refPointerPrefix: '#/definitions/' | ||
classValidatorMetadataStorage: class_validator_1.getMetadataStorage(), | ||
refPointerPrefix: '#/definitions/', | ||
}; | ||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoib3B0aW9ucy5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uL3NyYy9vcHRpb25zLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7O0FBMkJhLFFBQUEsY0FBYyxHQUFhO0lBQ3RDLG9CQUFvQixFQUFFLEVBQUU7SUFDeEIsZ0JBQWdCLEVBQUUsZ0JBQWdCO0NBQ25DLENBQUEifQ== | ||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoib3B0aW9ucy5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uL3NyYy9vcHRpb25zLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7O0FBQ0EscURBSXdCO0FBaUNYLFFBQUEsY0FBYyxHQUFhO0lBQ3RDLG9CQUFvQixFQUFFLEVBQUU7SUFDeEIsNkJBQTZCLEVBQUUsb0NBQWtCLEVBQUU7SUFDbkQsZ0JBQWdCLEVBQUUsZ0JBQWdCO0NBQ25DLENBQUEifQ== |
@@ -9,2 +9,28 @@ # Changelog | ||
## [2.0.0-rc1] - 2020-05-01 | ||
### Changed | ||
- Bump `class-validator` peer dependency to `^0.12.0` - meaning we're no longer compatible with pre-0.12 versions of `class-validator`! | ||
- `validationMetadatasToSchemas` no longer takes a `validationMetadatas` object as first argument. Instead the library now automatically grabs `validationMetadatas` from `getMetadataStorage()` under the hood. | ||
This simplifies library usage from | ||
```typescript | ||
const metadatas = (getFromContainer(MetadataStorage) as any).validationMetadatas | ||
const schemas = validationMetadatasToSchemas(metadatas) | ||
``` | ||
into plain | ||
```typescript | ||
const schemas = validationMetadatasToSchemas() | ||
``` | ||
You can still choose to override the default metadata storage using the optional options argument: | ||
```typescript | ||
const schemas = validationMetadatasToSchemas({ | ||
classValidatorMetadataStorage: myCustomMetadataStorage | ||
}) | ||
``` | ||
## [1.3.1] - 2019-12-05 | ||
@@ -11,0 +37,0 @@ ### Fixed |
{ | ||
"name": "class-validator-jsonschema", | ||
"version": "1.3.1", | ||
"version": "2.0.0-rc1", | ||
"description": "Convert class-validator-decorated classes into JSON schema", | ||
@@ -20,4 +20,5 @@ "keywords": [ | ||
"format": "prettier --write {src,test}/**/*.ts", | ||
"test:format": "prettier --check {src,test}/**/*.ts", | ||
"lint": "tslint --project . src/**/*.ts", | ||
"prepare": "install-self-peers -- --ignore-scripts && yarn build", | ||
"prepare": "install-self-peers -- --frozen-lockfile --ignore-scripts && yarn build", | ||
"send-coverage": "codecov -f coverage/*.json", | ||
@@ -32,31 +33,30 @@ "test": "jest --coverage", | ||
"dependencies": { | ||
"debug": "^4.1.1", | ||
"lodash": "^4.17.11", | ||
"lodash": "^4.17.15", | ||
"openapi3-ts": "^1.3.0", | ||
"reflect-metadata": "^0.1.13", | ||
"tslib": "^1.10.0" | ||
"tslib": "^1.11.1" | ||
}, | ||
"devDependencies": { | ||
"@team-griffin/install-self-peers": "^1.1.1", | ||
"@types/debug": "^4.1.4", | ||
"@types/jest": "^24.0.15", | ||
"@types/lodash": "^4.14.134", | ||
"@types/prettier": "^1.16.4", | ||
"@types/jest": "^25.2.1", | ||
"@types/lodash": "^4.14.150", | ||
"@types/node": "^13.13.4", | ||
"@types/prettier": "^2.0.0", | ||
"@types/reflect-metadata": "^0.1.0", | ||
"@types/rimraf": "^2.0.2", | ||
"@types/rimraf": "^3.0.0", | ||
"codecov": "^3.5.0", | ||
"jest": "^24.8.0", | ||
"prettier": "^1.18.2", | ||
"rimraf": "^2.6.3", | ||
"ts-jest": "^24.0.2", | ||
"tslint": "^5.18.0", | ||
"jest": "^25.5.3", | ||
"prettier": "^2.0.5", | ||
"rimraf": "^3.0.2", | ||
"ts-jest": "^25.4.0", | ||
"tslint": "^6.1.2", | ||
"tslint-config-prettier": "^1.18.0", | ||
"tslint-config-standard": "^8.0.1", | ||
"tsutils": "^3.14.0", | ||
"typescript": "^3.5.2" | ||
"tslint-config-standard": "^9.0.0", | ||
"tsutils": "^3.17.1", | ||
"typescript": "^3.8.3" | ||
}, | ||
"peerDependencies": { | ||
"class-transformer": "^0.2.3", | ||
"class-validator": "^0.9.1" | ||
"class-validator": "^0.12.0" | ||
} | ||
} |
# class-validator-jsonschema | ||
[![Build Status](https://travis-ci.org/epiphone/class-validator-jsonschema.svg?branch=master)](https://travis-ci.org/epiphone/class-validator-jsonschema) [![codecov](https://codecov.io/gh/epiphone/class-validator-jsonschema/branch/master/graph/badge.svg)](https://codecov.io/gh/epiphone/class-validator-jsonschema) [![npm version](https://badge.fury.io/js/class-validator-jsonschema.svg)](https://badge.fury.io/js/class-validator-jsonschema) | ||
@@ -10,6 +11,10 @@ | ||
Note that the library is **only compatible with `class-validator` versions 0.12 or higher**! | ||
Try installing `class-validator-jsonschema@1.3.1` in case you're stuck with an older `class-validator` version. | ||
## Usage | ||
```typescript | ||
import { getFromContainer, IsOptional, IsString, MaxLength, MetadataStorage } from 'class-validator' | ||
import { IsOptional, IsString, MaxLength } from 'class-validator' | ||
import { validationMetadatasToSchemas } from 'class-validator-jsonschema' | ||
@@ -25,4 +30,3 @@ | ||
const metadatas = (getFromContainer(MetadataStorage) as any).validationMetadatas | ||
const schemas = validationMetadatasToSchemas(metadatas) | ||
const schemas = validationMetadatasToSchemas() | ||
console.log(schemas) | ||
@@ -48,5 +52,3 @@ ``` | ||
}, | ||
"required": [ | ||
"id" | ||
], | ||
"required": ["id"], | ||
"type": "object" | ||
@@ -57,3 +59,3 @@ } | ||
`validationMetadatasToSchemas` takes an `options` object as an optional second parameter. Check available configuration objects and defaults at [`options.ts`](src/options.ts). | ||
`validationMetadatasToSchemas` takes an `options` object as an optional parameter. Check available configuration objects and defaults at [`options.ts`](src/options.ts). | ||
@@ -69,3 +71,3 @@ ### Adding and overriding default converters | ||
const schemas = validationMetadatasToSchemas(metadatas, { | ||
const schemas = validationMetadatasToSchemas({ | ||
additionalConverters: { | ||
@@ -89,3 +91,3 @@ [ValidationTypes.IS_STRING]: { | ||
"type": "string" | ||
}, | ||
} | ||
// ... | ||
@@ -100,3 +102,6 @@ } | ||
```typescript | ||
type SchemaConverter = (meta: ValidationMetadata, options: IOptions) => SchemaObject | void | ||
type SchemaConverter = ( | ||
meta: ValidationMetadata, | ||
options: IOptions | ||
) => SchemaObject | void | ||
``` | ||
@@ -109,3 +114,8 @@ | ||
```typescript | ||
import { Validate, ValidationArguments, ValidatorConstraint, ValidatorConstraintInterface } from 'class-validator' | ||
import { | ||
Validate, | ||
ValidationArguments, | ||
ValidatorConstraint, | ||
ValidatorConstraintInterface | ||
} from 'class-validator' | ||
@@ -130,21 +140,14 @@ // Implementing the validator: | ||
Now to handle your custom validator's JSON Schema conversion include a `customValidation` converter in `options.additionalConverters`: | ||
Now to handle your custom validator's JSON Schema conversion include a `CustomTextLength` converter in `options.additionalConverters`: | ||
```typescript | ||
const schemas = validationMetadatasToSchemas( | ||
validationMetadatas, | ||
{ | ||
additionalConverters: { | ||
[ValidationTypes.CUSTOM_VALIDATION]: meta => { | ||
if (meta.constraintCls === CustomTextLength) { | ||
return { | ||
maxLength: meta.constraints[1], | ||
minLength: meta.constraints[0], | ||
type: 'string' | ||
} | ||
} | ||
} | ||
} | ||
const schemas = validationMetadatasToSchemas({ | ||
additionalConverters: { | ||
CustomTextLength: meta => ({ | ||
maxLength: meta.constraints[1], | ||
minLength: meta.constraints[0], | ||
type: 'string' | ||
}) | ||
} | ||
) | ||
}) | ||
``` | ||
@@ -227,7 +230,7 @@ | ||
@ValidateNested({ each: true }) | ||
@Type(() => BlogPost) // 1) Explicitly define the nested property type | ||
@Type(() => BlogPost) // 1) Explicitly define the nested property type | ||
blogPosts: BlogPost[] | ||
} | ||
const schemas = validationMetadatasToSchemas(metadatas, { | ||
const schemas = validationMetadatasToSchemas({ | ||
classTransformerMetadataStorage: defaultMetadataStorage // 2) Define class-transformer metadata in options | ||
@@ -239,3 +242,12 @@ }) | ||
### Using a custom validation metadataStorage | ||
Under the hood we grab validation metadata from the default storage returned by `class-validator`'s `getMetadataStorage()`. In case of a version clash or something you might want to manually pass in the storage: | ||
```typescript | ||
const schemas = validationMetadatasToSchemas({ | ||
classValidatorMetadataStorage: myCustomMetadataStorage | ||
}) | ||
``` | ||
## Limitations | ||
@@ -242,0 +254,0 @@ |
// tslint:disable:no-submodule-imports | ||
import { ValidationTypes } from 'class-validator' | ||
import { ValidationMetadata } from 'class-validator/metadata/ValidationMetadata' | ||
import * as cv from 'class-validator' | ||
import { ValidationMetadata } from 'class-validator/types/metadata/ValidationMetadata' | ||
import * as _ from 'lodash' | ||
@@ -20,3 +20,3 @@ import { SchemaObject } from 'openapi3-ts' | ||
export const defaultConverters: ISchemaConverters = { | ||
[ValidationTypes.CUSTOM_VALIDATION]: (meta, options) => { | ||
[cv.ValidationTypes.CUSTOM_VALIDATION]: (meta, options) => { | ||
if (_.isFunction(meta.target)) { | ||
@@ -27,3 +27,3 @@ const type = getPropType(meta.target.prototype, meta.propertyName) | ||
}, | ||
[ValidationTypes.NESTED_VALIDATION]: (meta, options) => { | ||
[cv.ValidationTypes.NESTED_VALIDATION]: (meta, options) => { | ||
if (_.isFunction(meta.target)) { | ||
@@ -42,5 +42,5 @@ const typeMeta = options.classTransformerMetadataStorage | ||
}, | ||
[ValidationTypes.CONDITIONAL_VALIDATION]: {}, | ||
[ValidationTypes.IS_DEFINED]: {}, | ||
[ValidationTypes.EQUALS]: meta => { | ||
[cv.ValidationTypes.CONDITIONAL_VALIDATION]: {}, | ||
[cv.ValidationTypes.IS_DEFINED]: {}, | ||
[cv.EQUALS]: (meta) => { | ||
const schema = constraintToSchema(meta.constraints[0]) | ||
@@ -51,3 +51,3 @@ if (schema) { | ||
}, | ||
[ValidationTypes.NOT_EQUALS]: meta => { | ||
[cv.NOT_EQUALS]: (meta) => { | ||
const schema = constraintToSchema(meta.constraints[0]) | ||
@@ -58,3 +58,3 @@ if (schema) { | ||
}, | ||
[ValidationTypes.IS_EMPTY]: { | ||
[cv.IS_EMPTY]: { | ||
anyOf: [ | ||
@@ -70,14 +70,14 @@ { type: 'string', enum: [''] }, | ||
{ type: 'array' }, | ||
{ type: 'object' } | ||
] | ||
{ type: 'object' }, | ||
], | ||
}, | ||
nullable: true | ||
} | ||
] | ||
nullable: true, | ||
}, | ||
], | ||
}, | ||
[ValidationTypes.IS_NOT_EMPTY]: { | ||
[cv.IS_NOT_EMPTY]: { | ||
minLength: 1, | ||
type: 'string' | ||
type: 'string', | ||
}, | ||
[ValidationTypes.IS_IN]: meta => { | ||
[cv.IS_IN]: (meta) => { | ||
const [head, ...rest] = meta.constraints[0].map(constraintToSchema) | ||
@@ -88,3 +88,3 @@ if (head && _.every(rest, { type: head.type })) { | ||
}, | ||
[ValidationTypes.IS_NOT_IN]: meta => { | ||
[cv.IS_NOT_IN]: (meta) => { | ||
const [head, ...rest] = meta.constraints[0].map(constraintToSchema) | ||
@@ -95,192 +95,192 @@ if (head && _.every(rest, { type: head.type })) { | ||
}, | ||
[ValidationTypes.IS_BOOLEAN]: { | ||
type: 'boolean' | ||
[cv.IS_BOOLEAN]: { | ||
type: 'boolean', | ||
}, | ||
[ValidationTypes.IS_DATE]: { | ||
[cv.IS_DATE]: { | ||
oneOf: [ | ||
{ format: 'date', type: 'string' }, | ||
{ format: 'date-time', type: 'string' } | ||
] | ||
{ format: 'date-time', type: 'string' }, | ||
], | ||
}, | ||
[ValidationTypes.IS_NUMBER]: { | ||
type: 'number' | ||
[cv.IS_NUMBER]: { | ||
type: 'number', | ||
}, | ||
[ValidationTypes.IS_STRING]: { | ||
type: 'string' | ||
[cv.IS_STRING]: { | ||
type: 'string', | ||
}, | ||
[ValidationTypes.IS_DATE_STRING]: { | ||
[cv.IS_DATE_STRING]: { | ||
pattern: 'd{4}-[01]d-[0-3]dT[0-2]d:[0-5]d:[0-5]d.d+Z?', | ||
type: 'string' | ||
type: 'string', | ||
}, | ||
[ValidationTypes.IS_ARRAY]: { | ||
[cv.IS_ARRAY]: { | ||
items: {}, | ||
type: 'array' | ||
type: 'array', | ||
}, | ||
[ValidationTypes.IS_INT]: { | ||
type: 'integer' | ||
[cv.IS_INT]: { | ||
type: 'integer', | ||
}, | ||
[ValidationTypes.IS_ENUM]: meta => { | ||
[cv.IS_ENUM]: (meta) => { | ||
return { | ||
enum: Object.values(meta.constraints[0]), | ||
type: 'string' | ||
type: 'string', | ||
} | ||
}, | ||
[ValidationTypes.IS_DIVISIBLE_BY]: meta => ({ | ||
[cv.IS_DIVISIBLE_BY]: (meta) => ({ | ||
multipleOf: meta.constraints[0], | ||
type: 'number' | ||
type: 'number', | ||
}), | ||
[ValidationTypes.IS_POSITIVE]: { | ||
[cv.IS_POSITIVE]: { | ||
exclusiveMinimum: true, | ||
minimum: 0, | ||
type: 'number' | ||
type: 'number', | ||
}, | ||
[ValidationTypes.IS_NEGATIVE]: { | ||
[cv.IS_NEGATIVE]: { | ||
exclusiveMaximum: true, | ||
maximum: 0, | ||
type: 'number' | ||
type: 'number', | ||
}, | ||
[ValidationTypes.MIN]: meta => ({ | ||
[cv.MIN]: (meta) => ({ | ||
minimum: meta.constraints[0], | ||
type: 'number' | ||
type: 'number', | ||
}), | ||
[ValidationTypes.MAX]: meta => ({ | ||
[cv.MAX]: (meta) => ({ | ||
maximum: meta.constraints[0], | ||
type: 'number' | ||
type: 'number', | ||
}), | ||
[ValidationTypes.MIN_DATE]: meta => ({ | ||
[cv.MIN_DATE]: (meta) => ({ | ||
description: `After ${meta.constraints[0].toJSON()}`, | ||
oneOf: [ | ||
{ format: 'date', type: 'string' }, | ||
{ format: 'date-time', type: 'string' } | ||
] | ||
{ format: 'date-time', type: 'string' }, | ||
], | ||
}), | ||
[ValidationTypes.MAX_DATE]: meta => ({ | ||
[cv.MAX_DATE]: (meta) => ({ | ||
description: `Before ${meta.constraints[0].toJSON()}`, | ||
oneOf: [ | ||
{ format: 'date', type: 'string' }, | ||
{ format: 'date-time', type: 'string' } | ||
] | ||
{ format: 'date-time', type: 'string' }, | ||
], | ||
}), | ||
[ValidationTypes.IS_BOOLEAN_STRING]: { | ||
[cv.IS_BOOLEAN_STRING]: { | ||
enum: ['true', 'false'], | ||
type: 'string' | ||
type: 'string', | ||
}, | ||
[ValidationTypes.IS_NUMBER_STRING]: { | ||
[cv.IS_NUMBER_STRING]: { | ||
pattern: '^[-+]?[0-9]+$', | ||
type: 'string' | ||
type: 'string', | ||
}, | ||
[ValidationTypes.CONTAINS]: meta => ({ | ||
[cv.CONTAINS]: (meta) => ({ | ||
pattern: meta.constraints[0], | ||
type: 'string' | ||
type: 'string', | ||
}), | ||
[ValidationTypes.NOT_CONTAINS]: meta => ({ | ||
[cv.NOT_CONTAINS]: (meta) => ({ | ||
not: { pattern: meta.constraints[0] }, | ||
type: 'string' | ||
type: 'string', | ||
}), | ||
[ValidationTypes.IS_ALPHA]: { | ||
[cv.IS_ALPHA]: { | ||
pattern: '^[a-zA-Z]+$', | ||
type: 'string' | ||
type: 'string', | ||
}, | ||
[ValidationTypes.IS_ALPHANUMERIC]: { | ||
[cv.IS_ALPHANUMERIC]: { | ||
pattern: '^[0-9a-zA-Z]+$', | ||
type: 'string' | ||
type: 'string', | ||
}, | ||
[ValidationTypes.IS_ASCII]: { | ||
[cv.IS_ASCII]: { | ||
pattern: '^[\\x00-\\x7F]+$', | ||
type: 'string' | ||
type: 'string', | ||
}, | ||
[ValidationTypes.IS_BASE64]: { | ||
[cv.IS_BASE64]: { | ||
format: 'base64', | ||
type: 'string' | ||
type: 'string', | ||
}, | ||
[ValidationTypes.IS_BYTE_LENGTH]: { | ||
type: 'string' | ||
[cv.IS_BYTE_LENGTH]: { | ||
type: 'string', | ||
}, | ||
[ValidationTypes.IS_CREDIT_CARD]: { | ||
[cv.IS_CREDIT_CARD]: { | ||
format: 'credit-card', | ||
type: 'string' | ||
type: 'string', | ||
}, | ||
[ValidationTypes.IS_CURRENCY]: { | ||
[cv.IS_CURRENCY]: { | ||
format: 'currency', | ||
type: 'string' | ||
type: 'string', | ||
}, | ||
[ValidationTypes.IS_EMAIL]: { | ||
[cv.IS_EMAIL]: { | ||
format: 'email', | ||
type: 'string' | ||
type: 'string', | ||
}, | ||
[ValidationTypes.IS_FQDN]: { | ||
[cv.IS_FQDN]: { | ||
format: 'hostname', | ||
type: 'string' | ||
type: 'string', | ||
}, | ||
[ValidationTypes.IS_FULL_WIDTH]: { | ||
[cv.IS_FULL_WIDTH]: { | ||
pattern: | ||
'[^\\u0020-\\u007E\\uFF61-\\uFF9F\\uFFA0-\\uFFDC\\uFFE8-\\uFFEE0-9a-zA-Z]', | ||
type: 'string' | ||
type: 'string', | ||
}, | ||
[ValidationTypes.IS_HALF_WIDTH]: { | ||
[cv.IS_HALF_WIDTH]: { | ||
pattern: | ||
'[\\u0020-\\u007E\\uFF61-\\uFF9F\\uFFA0-\\uFFDC\\uFFE8-\\uFFEE0-9a-zA-Z]', | ||
type: 'string' | ||
type: 'string', | ||
}, | ||
[ValidationTypes.IS_VARIABLE_WIDTH]: { | ||
type: 'string' | ||
[cv.IS_VARIABLE_WIDTH]: { | ||
type: 'string', | ||
}, | ||
[ValidationTypes.IS_HEX_COLOR]: { | ||
[cv.IS_HEX_COLOR]: { | ||
pattern: '^#?([0-9a-fA-F]{3}|[0-9a-fA-F]{6})$', | ||
type: 'string' | ||
type: 'string', | ||
}, | ||
[ValidationTypes.IS_HEXADECIMAL]: { | ||
[cv.IS_HEXADECIMAL]: { | ||
pattern: '^[0-9a-fA-F]+$', | ||
type: 'string' | ||
type: 'string', | ||
}, | ||
[ValidationTypes.IS_IP]: meta => ({ | ||
[cv.IS_IP]: (meta) => ({ | ||
format: 'ipv' + (meta.constraints[0] === '6' ? 6 : 4), | ||
type: 'string' | ||
type: 'string', | ||
}), | ||
[ValidationTypes.IS_ISBN]: { | ||
[cv.IS_ISBN]: { | ||
format: 'isbn', | ||
type: 'string' | ||
type: 'string', | ||
}, | ||
[ValidationTypes.IS_ISIN]: { | ||
[cv.IS_ISIN]: { | ||
format: 'isin', | ||
type: 'string' | ||
type: 'string', | ||
}, | ||
[ValidationTypes.IS_ISO8601]: { | ||
[cv.IS_ISO8601]: { | ||
oneOf: [ | ||
{ format: 'date', type: 'string' }, | ||
{ format: 'date-time', type: 'string' } | ||
] | ||
{ format: 'date-time', type: 'string' }, | ||
], | ||
}, | ||
[ValidationTypes.IS_JSON]: { | ||
[cv.IS_JSON]: { | ||
format: 'json', | ||
type: 'string' | ||
type: 'string', | ||
}, | ||
[ValidationTypes.IS_LOWERCASE]: { | ||
type: 'string' | ||
[cv.IS_LOWERCASE]: { | ||
type: 'string', | ||
}, | ||
[ValidationTypes.IS_MOBILE_PHONE]: { | ||
[cv.IS_MOBILE_PHONE]: { | ||
format: 'mobile-phone', | ||
type: 'string' | ||
type: 'string', | ||
}, | ||
[ValidationTypes.IS_MONGO_ID]: { | ||
[cv.IS_MONGO_ID]: { | ||
pattern: '^[0-9a-fA-F]{24}$', | ||
type: 'string' | ||
type: 'string', | ||
}, | ||
[ValidationTypes.IS_MULTIBYTE]: { | ||
[cv.IS_MULTIBYTE]: { | ||
pattern: '[^\\x00-\\x7F]', | ||
type: 'string' | ||
type: 'string', | ||
}, | ||
[ValidationTypes.IS_SURROGATE_PAIR]: { | ||
[cv.IS_SURROGATE_PAIR]: { | ||
pattern: '[\\uD800-\\uDBFF][\\uDC00-\\uDFFF]', | ||
type: 'string' | ||
type: 'string', | ||
}, | ||
[ValidationTypes.IS_URL]: { | ||
[cv.IS_URL]: { | ||
format: 'url', | ||
type: 'string' | ||
type: 'string', | ||
}, | ||
[ValidationTypes.IS_UUID]: { | ||
[cv.IS_UUID]: { | ||
format: 'uuid', | ||
type: 'string' | ||
type: 'string', | ||
}, | ||
[ValidationTypes.LENGTH]: meta => { | ||
[cv.LENGTH]: (meta) => { | ||
const [minLength, maxLength] = meta.constraints | ||
@@ -292,22 +292,22 @@ if (maxLength || maxLength === 0) { | ||
}, | ||
[ValidationTypes.IS_UPPERCASE]: { | ||
type: 'string' | ||
[cv.IS_UPPERCASE]: { | ||
type: 'string', | ||
}, | ||
[ValidationTypes.MIN_LENGTH]: meta => ({ | ||
[cv.MIN_LENGTH]: (meta) => ({ | ||
minLength: meta.constraints[0], | ||
type: 'string' | ||
type: 'string', | ||
}), | ||
[ValidationTypes.MAX_LENGTH]: meta => ({ | ||
[cv.MAX_LENGTH]: (meta) => ({ | ||
maxLength: meta.constraints[0], | ||
type: 'string' | ||
type: 'string', | ||
}), | ||
[ValidationTypes.MATCHES]: meta => ({ | ||
[cv.MATCHES]: (meta) => ({ | ||
pattern: meta.constraints[0].source, | ||
type: 'string' | ||
type: 'string', | ||
}), | ||
[ValidationTypes.IS_MILITARY_TIME]: { | ||
[cv.IS_MILITARY_TIME]: { | ||
pattern: '^([01]\\d|2[0-3]):?([0-5]\\d)$', | ||
type: 'string' | ||
type: 'string', | ||
}, | ||
[ValidationTypes.ARRAY_CONTAINS]: meta => { | ||
[cv.ARRAY_CONTAINS]: (meta) => { | ||
const schemas = meta.constraints[0].map(constraintToSchema) | ||
@@ -321,8 +321,8 @@ if (schemas.length > 0 && _.every(schemas, 'type')) { | ||
...d, | ||
enum: [meta.constraints[0][i]] | ||
} | ||
} | ||
})) | ||
enum: [meta.constraints[0][i]], | ||
}, | ||
}, | ||
})), | ||
}, | ||
type: 'array' | ||
type: 'array', | ||
} | ||
@@ -332,3 +332,3 @@ } | ||
}, | ||
[ValidationTypes.ARRAY_NOT_CONTAINS]: meta => { | ||
[cv.ARRAY_NOT_CONTAINS]: (meta) => { | ||
const schemas = meta.constraints[0].map(constraintToSchema) | ||
@@ -341,7 +341,7 @@ if (schemas.length > 0 && _.every(schemas, 'type')) { | ||
...d, | ||
enum: [meta.constraints[0][i]] | ||
})) | ||
} | ||
enum: [meta.constraints[0][i]], | ||
})), | ||
}, | ||
}, | ||
type: 'array' | ||
type: 'array', | ||
} | ||
@@ -351,22 +351,22 @@ } | ||
}, | ||
[ValidationTypes.ARRAY_NOT_EMPTY]: { | ||
[cv.ARRAY_NOT_EMPTY]: { | ||
items: {}, | ||
minItems: 1, | ||
type: 'array' | ||
type: 'array', | ||
}, | ||
[ValidationTypes.ARRAY_MIN_SIZE]: meta => ({ | ||
[cv.ARRAY_MIN_SIZE]: (meta) => ({ | ||
items: {}, | ||
minItems: meta.constraints[0], | ||
type: 'array' | ||
type: 'array', | ||
}), | ||
[ValidationTypes.ARRAY_MAX_SIZE]: meta => ({ | ||
[cv.ARRAY_MAX_SIZE]: (meta) => ({ | ||
items: {}, | ||
maxItems: meta.constraints[0], | ||
type: 'array' | ||
type: 'array', | ||
}), | ||
[ValidationTypes.ARRAY_UNIQUE]: { | ||
[cv.ARRAY_UNIQUE]: { | ||
items: {}, | ||
type: 'array', | ||
uniqueItems: true | ||
} | ||
uniqueItems: true, | ||
}, | ||
} | ||
@@ -373,0 +373,0 @@ |
// tslint:disable:no-submodule-imports ban-types | ||
import { ValidationTypes } from 'class-validator' | ||
import { ValidationMetadata } from 'class-validator/metadata/ValidationMetadata' | ||
import * as cv from 'class-validator' | ||
import { ConstraintMetadata } from 'class-validator/types/metadata/ConstraintMetadata' | ||
import { ValidationMetadata } from 'class-validator/types/metadata/ValidationMetadata' | ||
import * as _ from 'lodash' | ||
import { SchemaObject } from 'openapi3-ts' | ||
const debug = require('debug')('routing-controllers-openapi') | ||
@@ -15,17 +15,17 @@ import { getMetadataSchema } from './decorators' | ||
/** | ||
* Convert class-validator metadata objects into JSON Schema definitions. | ||
* @param metadatas All class-validator metadata objects. | ||
* Convert class-validator metadata into JSON Schema definitions. | ||
*/ | ||
export function validationMetadatasToSchemas( | ||
metadatas: ValidationMetadata[], | ||
userOptions?: Partial<IOptions> | ||
) { | ||
export function validationMetadatasToSchemas(userOptions?: Partial<IOptions>) { | ||
const options: IOptions = { | ||
...defaultOptions, | ||
...userOptions | ||
...userOptions, | ||
} | ||
const metadatas = getMetadatasFromStorage( | ||
options.classValidatorMetadataStorage | ||
) | ||
const schemas: { [key: string]: SchemaObject } = _(metadatas) | ||
.groupBy('target.name') | ||
.mapValues(ownMetas => { | ||
.mapValues((ownMetas) => { | ||
const target = ownMetas[0].target as Function | ||
@@ -44,3 +44,3 @@ const metas = ownMetas.concat(getInheritedMetadatas(target, metadatas)) | ||
properties, | ||
type: 'object' | ||
type: 'object', | ||
} | ||
@@ -61,2 +61,28 @@ | ||
/** | ||
* Return `storage.validationMetadatas` populated with `constraintMetadatas`. | ||
*/ | ||
function getMetadatasFromStorage( | ||
storage: cv.MetadataStorage | ||
): ValidationMetadata[] { | ||
const metadatas: ValidationMetadata[] = _.get(storage, 'validationMetadatas') | ||
const constraints: ConstraintMetadata[] = _.get( | ||
storage, | ||
'constraintMetadatas' | ||
) | ||
for (const meta of metadatas) { | ||
if (meta.constraintCls) { | ||
const constraint = constraints.find( | ||
(c) => c.target === meta.constraintCls | ||
) | ||
if (constraint) { | ||
meta.type = constraint.name | ||
} | ||
} | ||
} | ||
return metadatas | ||
} | ||
/** | ||
* Return target class' inherited validation metadatas, with original metadatas | ||
@@ -75,3 +101,3 @@ * given precedence over inherited ones in case of duplicates. | ||
return metadatas.filter( | ||
d => | ||
(d) => | ||
d.target instanceof Function && | ||
@@ -82,3 +108,3 @@ target.prototype instanceof d.target && | ||
target, | ||
type: d.type | ||
type: d.type, | ||
}) | ||
@@ -97,7 +123,4 @@ ) | ||
const convert = (meta: ValidationMetadata) => { | ||
const converter = converters[meta.type] | ||
if (!converter) { | ||
debug('No schema converter found for validation metadata', meta) | ||
return {} | ||
} | ||
const converter = | ||
converters[meta.type] || converters[cv.ValidationTypes.CUSTOM_VALIDATION] | ||
@@ -140,10 +163,7 @@ const items = _.isFunction(converter) ? converter(meta, options) : converter | ||
function isDefined(metas: ValidationMetadata[]) { | ||
return _.some(metas, { type: ValidationTypes.IS_DEFINED }) | ||
return _.some(metas, { type: cv.ValidationTypes.IS_DEFINED }) | ||
} | ||
function isOptional(metas: ValidationMetadata[]) { | ||
return _.some(metas, ({ type }) => | ||
_.includes( | ||
[ValidationTypes.CONDITIONAL_VALIDATION, ValidationTypes.IS_EMPTY], | ||
type | ||
) | ||
_.includes([cv.ValidationTypes.CONDITIONAL_VALIDATION, cv.IS_EMPTY], type) | ||
) | ||
@@ -154,4 +174,4 @@ } | ||
.groupBy('propertyName') | ||
.pickBy(metas => { | ||
const [own, inherited] = _.partition(metas, d => d.target === target) | ||
.pickBy((metas) => { | ||
const [own, inherited] = _.partition(metas, (d) => d.target === target) | ||
return options.skipMissingProperties | ||
@@ -158,0 +178,0 @@ ? isDefined(own) || (!isOptional(own) && isDefined(inherited)) |
@@ -1,3 +0,7 @@ | ||
import { MetadataStorage } from 'class-transformer/metadata/MetadataStorage' // tslint:disable-line:no-submodule-imports | ||
import { ValidatorOptions } from 'class-validator' | ||
import { MetadataStorage as ClassTransformerMetadataStorage } from 'class-transformer/metadata/MetadataStorage' // tslint:disable-line:no-submodule-imports | ||
import { | ||
getMetadataStorage, | ||
MetadataStorage, | ||
ValidatorOptions, | ||
} from 'class-validator' | ||
@@ -19,5 +23,12 @@ import { ISchemaConverters } from './defaultConverters' | ||
*/ | ||
classTransformerMetadataStorage?: MetadataStorage | ||
classTransformerMetadataStorage?: ClassTransformerMetadataStorage | ||
/** | ||
* Metadata storage instance of class-validator. This value can be | ||
* optionally defined in order to override the default storage used | ||
* to parse decorator metadata. | ||
*/ | ||
classValidatorMetadataStorage: MetadataStorage | ||
/** | ||
* A prefix added to all `$ref` JSON pointers referencing other schemas. | ||
@@ -31,3 +42,4 @@ * Defaults to '#/definitions/'. | ||
additionalConverters: {}, | ||
refPointerPrefix: '#/definitions/' | ||
classValidatorMetadataStorage: getMetadataStorage(), | ||
refPointerPrefix: '#/definitions/', | ||
} |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
99183
6
2098
268
2
+ Added@types/validator@13.0.0(transitive)
+ Addedclass-validator@0.12.2(transitive)
+ Addedvalidator@13.0.0(transitive)
- Removeddebug@^4.1.1
- Removedclass-validator@0.9.1(transitive)
- Removeddebug@4.3.7(transitive)
- Removedms@2.1.3(transitive)
- Removedvalidator@10.4.0(transitive)
Updatedlodash@^4.17.15
Updatedtslib@^1.11.1