mirror of
https://github.com/Redocly/redoc.git
synced 2025-08-09 06:34:53 +03:00
Add test for new allOf circular detection case
This commit is contained in:
parent
561f146803
commit
b9c93c7061
|
@ -12,5 +12,13 @@ describe('Models', () => {
|
||||||
parser = new OpenAPIParser(spec, undefined, opts);
|
parser = new OpenAPIParser(spec, undefined, opts);
|
||||||
expect(parser.mergeAllOf(spec.components.schemas.test)).toMatchSnapshot();
|
expect(parser.mergeAllOf(spec.components.schemas.test)).toMatchSnapshot();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('should not mark as circular when multiple schemas in allOf use the same ref', () => {
|
||||||
|
const spec = require('./fixtures/allOfCircular.json');
|
||||||
|
parser = new OpenAPIParser(spec, undefined, opts);
|
||||||
|
expect(
|
||||||
|
parser.mergeAllOf(spec.components.schemas.test).properties.object['x-circular-ref'],
|
||||||
|
).toEqual(undefined);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
51
src/services/__tests__/fixtures/allOfCircular.json
Normal file
51
src/services/__tests__/fixtures/allOfCircular.json
Normal file
|
@ -0,0 +1,51 @@
|
||||||
|
{
|
||||||
|
"openapi": "3.0.0",
|
||||||
|
"info": {
|
||||||
|
"version": "1.0",
|
||||||
|
"title": "Foo"
|
||||||
|
},
|
||||||
|
"components": {
|
||||||
|
"schemas": {
|
||||||
|
"BaseObj": {
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"test": {
|
||||||
|
"type": "string"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"ExtendedObj": {
|
||||||
|
"allOf": [
|
||||||
|
{
|
||||||
|
"$ref": "#/components/schemas/BaseObj"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"description": "Extended"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"Base": {
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"object": {
|
||||||
|
"$ref": "#/components/schemas/BaseObj"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"test": {
|
||||||
|
"allOf": [
|
||||||
|
{
|
||||||
|
"$ref": "#/components/schemas/Base"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"properties": {
|
||||||
|
"object": {
|
||||||
|
"$ref": "#/components/schemas/ExtendedObj"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user