fix: missing properties when using complex allOf (regression)

fixes #422
This commit is contained in:
Roman Hotsiy 2018-02-26 15:40:35 +02:00
parent 92ed914701
commit 6ce9245c0a
No known key found for this signature in database
GPG Key ID: 5CB7B3ACABA57CB0
2 changed files with 11 additions and 3 deletions

View File

@ -248,6 +248,15 @@ describe('Spec Helper', () => {
Object.keys(joined.properties).should.be.deepEqual(['prop1', 'prop2', 'prop3', 'prop4']); Object.keys(joined.properties).should.be.deepEqual(['prop1', 'prop2', 'prop3', 'prop4']);
joined.required.should.be.deepEqual(['prop1', 'prop3']); joined.required.should.be.deepEqual(['prop1', 'prop3']);
}); });
it('should handle nested allOf if already cached', () => {
let pointer = '/definitions/NestedAllOf';
let joined;
(() => joined = normalizer.normalize(specMgr.byPointer(pointer), pointer)).should.not.throw();
Object.keys(joined.properties).length.should.be.equal(4);
Object.keys(joined.properties).should.be.deepEqual(['prop1', 'prop2', 'prop3', 'prop4']);
joined.required.should.be.deepEqual(['prop1', 'prop3']);
});
}); });
xdescribe('Merge array allOf', () => { xdescribe('Merge array allOf', () => {

View File

@ -55,8 +55,8 @@ class SchemaWalker {
} }
if (obj['x-redoc-visited']) { if (obj['x-redoc-visited']) {
const res = visitor(obj, pointer);
obj['x-redoc-visited'] = false; obj['x-redoc-visited'] = false;
const res = visitor(obj, pointer);
// circular, return only title and description // circular, return only title and description
return { title: res.title, description: res.description }; return { title: res.title, description: res.description };
} }
@ -92,9 +92,8 @@ class SchemaWalker {
} }
} }
const res = visitor(obj, pointer);
obj['x-redoc-visited'] = false; obj['x-redoc-visited'] = false;
return res; return visitor(obj, pointer);
} }
private static walkEach(obj:Object, pointer:string, visitor:Function) { private static walkEach(obj:Object, pointer:string, visitor:Function) {