mirror of
https://github.com/Redocly/redoc.git
synced 2024-11-29 03:53:43 +03:00
Throw errors for incorrect or not-supported allOfs
This commit is contained in:
parent
e633c02657
commit
54461e3582
|
@ -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);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user