I am checking json schema validation on the mongo layer using $jsonSchema. I need define a multilingual object. I use $ref. But I receive the error - $jsonSchema keyword 'definitions' is not currently supported According to the documentation it has to have a common json-schema behavior.
async install(): Promise<void> {
let db = await this.dbContainer.getDb();
let properties = _.fromPairs(this.config.languages.map((language) => {
return [language, {$ref: '#/definitions/post'}]
}));
await db.createCollection(
this.collectionName,
{
validator: {
$jsonSchema: {
bsonType: 'object',
required: ['title', 'summary', 'link'],
definitions: {
post: {
title: {
bsonType: 'string',
description: 'Title is required'
},
summary: {
bsonType: 'string',
description: 'Summary is required'
},
href: {
bsonType: 'string',
description: 'Summary is required'
},
},
},
properties,
}
}
}
);
Does anybody has any suggestions? Should I use json-schema as a separated library?