diff --git a/test/api.js b/test/api.js index 7d81b55c04..e4c28cfcef 100644 --- a/test/api.js +++ b/test/api.js @@ -117,7 +117,7 @@ describe('API', async () => { }], }); meta.config.allowTopicsThumbnail = 1; - meta.config.termsOfUse = 'I, for one, welcome our new test-drive overlords'; + meta.config.termsOfUse = 'I, for one, welcome our new test-driven overlords'; // Create a category const testCategory = await categories.create({ name: 'test' }); @@ -446,12 +446,20 @@ describe('API', async () => { let required = []; const additionalProperties = schema.hasOwnProperty('additionalProperties'); - if (schema.allOf) { - schema = schema.allOf.reduce((memo, obj) => { - required = required.concat(obj.required ? obj.required : Object.keys(obj.properties)); - memo = { ...memo, ...obj.properties }; - return memo; + function flattenAllOf(obj) { + return obj.reduce((memo, obj) => { + if (obj.allOf) { + obj = { properties: flattenAllOf(obj.allOf) }; + } else { + required = required.concat(obj.required ? obj.required : Object.keys(obj.properties)); + } + + return { ...memo, ...obj.properties }; }, {}); + } + + if (schema.allOf) { + schema = flattenAllOf(schema.allOf); } else if (schema.properties) { required = schema.required || Object.keys(schema.properties); schema = schema.properties;