@@ -410,10 +410,8 @@ function merger(rootSchema, options, totalSchemas) {
410410 resolvers : defaultResolvers
411411 } )
412412
413- function mergeSchemas ( schemas , base ) {
413+ function mergeSchemas ( schemas ) {
414414 schemas = cloneDeep ( schemas . filter ( notUndefined ) )
415- var merged = isPlainObject ( base )
416- ? base : { }
417415
418416 // return undefined, an empty schema
419417 if ( ! schemas . length ) {
@@ -431,6 +429,7 @@ function merger(rootSchema, options, totalSchemas) {
431429 // there are no false and we don't need the true ones as they accept everything
432430 schemas = schemas . filter ( isPlainObject )
433431
432+ var merged = schemas [ 0 ]
434433 var allKeys = allUniqueKeys ( schemas )
435434
436435 if ( contains ( allKeys , 'allOf' ) ) {
@@ -455,7 +454,7 @@ function merger(rootSchema, options, totalSchemas) {
455454 // allOf is treated differently alltogether
456455 if ( compacted . length === 1 && contains ( schemaArrays , key ) ) {
457456 merged [ key ] = compacted [ 0 ] . map ( function ( schema ) {
458- return mergeSchemas ( [ schema ] , schema )
457+ return mergeSchemas ( [ schema ] )
459458 } )
460459 // prop groups must always be resolved
461460 } else if ( compacted . length === 1 && ! contains ( schemaGroupProps , key ) && ! contains ( schemaProps , key ) ) {
@@ -488,9 +487,9 @@ function merger(rootSchema, options, totalSchemas) {
488487 return merged
489488 }
490489
491- var allSchemas = flattenDeep ( getAllOf ( rootSchema ) )
492- var merged = mergeSchemas ( allSchemas , rootSchema )
493-
490+ var copy = cloneDeep ( rootSchema )
491+ var allSchemas = flattenDeep ( getAllOf ( copy ) )
492+ var merged = mergeSchemas ( allSchemas )
494493 return merged
495494}
496495
0 commit comments