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); }