You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
58 lines
1.0 KiB
58 lines
1.0 KiB
'use strict'
|
|
|
|
const { test } = require('tap')
|
|
const build = require('..')
|
|
|
|
test('should validate anyOf after allOf merge', (t) => {
|
|
t.plan(1)
|
|
|
|
const schema = {
|
|
$id: 'schema',
|
|
type: 'object',
|
|
allOf: [
|
|
{
|
|
$id: 'base',
|
|
type: 'object',
|
|
properties: {
|
|
name: {
|
|
type: 'string'
|
|
}
|
|
},
|
|
required: [
|
|
'name'
|
|
]
|
|
},
|
|
{
|
|
$id: 'inner_schema',
|
|
type: 'object',
|
|
properties: {
|
|
union: {
|
|
$id: '#id',
|
|
anyOf: [
|
|
{
|
|
|
|
$id: 'guid',
|
|
type: 'string'
|
|
},
|
|
{
|
|
|
|
$id: 'email',
|
|
type: 'string'
|
|
}
|
|
]
|
|
}
|
|
},
|
|
required: [
|
|
'union'
|
|
]
|
|
}
|
|
]
|
|
}
|
|
|
|
const stringify = build(schema)
|
|
|
|
t.equal(
|
|
stringify({ name: 'foo', union: 'a8f1cc50-5530-5c62-9109-5ba9589a6ae1' }),
|
|
'{"name":"foo","union":"a8f1cc50-5530-5c62-9109-5ba9589a6ae1"}')
|
|
})
|