Skip to content
Snippets Groups Projects
Commit 3e33ec42 authored by Alvaro Cabrera Durán's avatar Alvaro Cabrera Durán
Browse files

Handle oneOf.required props; fixes #529

parent 7a162312
No related branches found
No related tags found
No related merge requests found
......@@ -203,13 +203,17 @@ function run(refs, schema, container) {
thunk() {
const copy = utils.omitProps(sub, ['anyOf', 'oneOf']);
const fixed = random.pick(mix);
utils.merge(copy, fixed);
if (sub.oneOf && copy.properties) {
mix.forEach(omit => {
if (omit !== fixed && omit.required) {
omit.required.forEach(key => {
delete copy.properties[key];
// remove additional properties from merged schemas
if (!copy.required.includes(key)) {
delete copy.properties[key];
}
});
}
});
......
......@@ -5,6 +5,7 @@
{
"description": "should resolve the schema (without $refs)",
"timeout": 30000,
"online": true,
"schema": {
"$schema": "http://redfish.dmtf.org/schemas/v1/redfish-schema.v1_2_0.json",
"title": "#AccountService.v1_2_1.AccountService",
......
{
"description": "...",
"description": "repeated properties between oneOf sub schemas",
"tests": [
{
"description": "should ...",
"description": "should not skip required properties",
"schema": {
"$schema": "http://json-schema.org/draft-06/schema#",
"type": "object",
"required": [
"filters"
......@@ -23,7 +24,6 @@
}
}
},
"$schema": "http://json-schema.org/draft-06/schema#",
"definitions": {
"FilterAgc": {
"type": "object",
......@@ -77,7 +77,6 @@
}
}
},
"skip": true,
"valid": true
}
]
......
......@@ -17,6 +17,8 @@ function seed() {
(only.length ? only : all).forEach(suite => {
describe(`${suite.description} (${suite.file.replace(`${process.cwd()}/`, '')})`, () => {
suite.tests.forEach(test => {
if (!process.env.CI && test.online) return;
it(test.description, () => {
jsf.option(jsf.option.getDefaults());
......
......@@ -72,7 +72,7 @@ export function checkSchema(sample, schema, refs) {
// z-schema
const validator = new ZSchema({
ignoreUnresolvableReferences: false,
ignoreUnresolvableReferences: true,
});
Object.keys(fixed).forEach(k => {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment