merge

fun merge(source: Schema<*>, schemasToMerge: List<Schema<*>>, depth: Int, visitedRefs: MutableSet<String>, resolve: (Schema<*>) -> Schema<*>): Schema<*>

Merges multiple schemas into a single target schema by combining their constraints.

Constraints are combined using "meet" semantics:

  • Numeric bounds: tighter bounds win (max of minimums, min of maximums)

  • Enums: intersection of allowed values

  • Required fields: union

  • Properties: merged recursively via allOf when conflicting

Return

new schema with all constraints merged

Parameters

source

the base schema providing structure and initial constraints

schemasToMerge

list of schemas whose constraints should be merged

depth

current recursion depth for cycle protection

visitedRefs

mutable set tracking visited $ref pointers

resolve

function to dereference $ref schemas