Open Vladirien opened 3 years ago
Hi,
Using a $ref in a anyOf or an affOf in a schema triggers the following error: RangeError: Maximum call stack size exceeded
$ref
anyOf
affOf
RangeError: Maximum call stack size exceeded
const Enjoi = require('enjoi'); const jsonSchema = { allOf: [ { $ref: "#/components/schemas/TestObject" }, { type: 'object', properties: { info: { type: 'string' } } } ] }; const subSchemas = { components:{ schemas: { TestObject:{ additionalProperties: false, type: 'object', properties:{ id: { type: 'number' }, name:{ type: 'string' }, subobject:{ $ref: "#/components/schemas/TestSubObject" }, type:{ type: 'string', enum: [ 'AUDIENCE', 'CAMPAIGN' ] } } }, TestSubObject:{ additionalProperties: false, type: 'object', properties:{ id:{ type: 'number' }, name:{ type: 'string' } } } } } }; const schema = Enjoi.schema(jsonSchema, { subSchemas }); const options = { allowUnknown: false, abortEarly: false, stripUnknown: false }; const result = schema.validate({ id: 7, name: 'test', type: 'AUDIENCE', info: 'good' }, options); console.log('res', result);
The validation should be able to handle $refs in anyOf or allOf
$refs
allOf
Thanks in advance!
Hi,
Using a
$ref
in aanyOf
or anaffOf
in a schema triggers the following error:RangeError: Maximum call stack size exceeded
Code to reproduce
Expected result
The validation should be able to handle
$refs
inanyOf
orallOf
Thanks in advance!