revert revert c74f28caa7

revert one
This commit is contained in:
2025-09-20 13:29:29 +00:00
parent a2271529a8
commit fffd15b241
2539 changed files with 365006 additions and 0 deletions

View File

@@ -0,0 +1,75 @@
'use strict'
const assert = require('node:assert/strict')
const { test } = require('node:test')
const { mergeSchemas } = require('../index')
const { defaultResolver } = require('./utils')
test('should merge empty schema and dependentRequired keyword', () => {
const schema1 = {}
const schema2 = {
type: 'object',
properties: {
foo: { type: 'string' },
bar: { type: 'string' }
},
dependentRequired: {
foo: ['bar']
}
}
const mergedSchema = mergeSchemas([schema1, schema2], { defaultResolver })
assert.deepStrictEqual(mergedSchema, {
type: 'object',
properties: {
foo: { type: 'string' },
bar: { type: 'string' }
},
dependentRequired: {
foo: ['bar']
}
})
})
test('should merge two dependentRequired keyword schemas', () => {
const schema1 = {
type: 'object',
properties: {
foo: { type: 'string' },
bar: { type: 'string' },
que: { type: 'string' }
},
dependentRequired: {
foo: ['bar', 'que'],
bar: ['que']
}
}
const schema2 = {
type: 'object',
properties: {
foo: { type: 'string' },
bar: { type: 'string' },
baz: { type: 'string' }
},
dependentRequired: {
foo: ['baz'],
baz: ['foo']
}
}
const mergedSchema = mergeSchemas([schema1, schema2], { defaultResolver })
assert.deepStrictEqual(mergedSchema, {
type: 'object',
properties: {
foo: { type: 'string' },
bar: { type: 'string' },
que: { type: 'string' },
baz: { type: 'string' }
},
dependentRequired: {
foo: ['bar', 'que', 'baz'],
bar: ['que'],
baz: ['foo']
}
})
})