我正在尝试将一些openapi 3.0 json解析为有效的Joi模型。我在转换allOf
模式方面遇到问题。
上下文:
Joi.alternatives([schema1,schema1]).match('all')
See commit Joi测试代码: See repo
...
it('matches all', () => {
const schema = Joi.alternatives([
Joi.number(),
Joi.string()
])
.match('all');
Helper.validate(schema, [
['2', true, '2'],
['x', false, {
message: '"value" does not match all of the required types',
path: [],
type: 'alternatives.all',
context: { label: 'value', value: 'x' }
}],
[2, false, {
message: '"value" does not match all of the required types',
path: [],
type: 'alternatives.all',
context: { label: 'value', value: 2 }
}],
[true, false, {
message: '"value" does not match any of the allowed types',
path: [],
type: 'alternatives.any',
context: { label: 'value', value: true }
}]
]);
});
...
'2'
或2
。正确吗?string
和number
?