From 54461e35828c4eb0957ac4675e35345fd3f5c885 Mon Sep 17 00:00:00 2001 From: Roman Hotsiy Date: Mon, 14 Dec 2015 10:18:15 +0200 Subject: [PATCH] Throw errors for incorrect or not-supported allOfs --- lib/components/base.js | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/lib/components/base.js b/lib/components/base.js index 7f930eb6..5b39c0a2 100644 --- a/lib/components/base.js +++ b/lib/components/base.js @@ -106,17 +106,24 @@ export class BaseComponent { var self = this; function merge(into, schemas) { if (into.required || into.properties) { - console.warn('WARN: properties or required field set on the same level as allOf'); + let errMessage = `Can\'t merge allOf: properties or required fields are specified on the same level as allOf + ${into}`; + throw new Error(errMessage); } into.required = []; into.properties = {}; for (let subSchema of schemas) { + + // TODO: add support for merge array schemas if (typeof subSchema !== 'object' || subSchema.type !== 'object') { - console.warn('WARN: incorrect allOf element skipped\nObject: ', subSchema); + let errMessage = `Can\'t merge allOf: only subschemas with type: object can be merged + ${subSchema}`; + throw new Error(errMessage); } self.joinAllOf(subSchema); + // TODO: add check if can be merged correctly (no different properties with the same name) if (subSchema.properties) { Object.assign(into.properties, subSchema.properties); }