From 6ce9245c0a66d41ceb247088eb5607ca0caff9a4 Mon Sep 17 00:00:00 2001 From: Roman Hotsiy Date: Mon, 26 Feb 2018 15:40:35 +0200 Subject: [PATCH] fix: missing properties when using complex allOf (regression) fixes #422 --- lib/services/schema-normalizer.service.spec.ts | 9 +++++++++ lib/services/schema-normalizer.service.ts | 5 ++--- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/lib/services/schema-normalizer.service.spec.ts b/lib/services/schema-normalizer.service.spec.ts index a67666e4f4..9f4781675f 100644 --- a/lib/services/schema-normalizer.service.spec.ts +++ b/lib/services/schema-normalizer.service.spec.ts @@ -248,6 +248,15 @@ describe('Spec Helper', () => { Object.keys(joined.properties).should.be.deepEqual(['prop1', 'prop2', 'prop3', 'prop4']); 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', () => { diff --git a/lib/services/schema-normalizer.service.ts b/lib/services/schema-normalizer.service.ts index ad08a6de86..ca602308e2 100644 --- a/lib/services/schema-normalizer.service.ts +++ b/lib/services/schema-normalizer.service.ts @@ -55,8 +55,8 @@ class SchemaWalker { } if (obj['x-redoc-visited']) { - const res = visitor(obj, pointer); obj['x-redoc-visited'] = false; + const res = visitor(obj, pointer); // circular, return only title and description return { title: res.title, description: res.description }; } @@ -92,9 +92,8 @@ class SchemaWalker { } } - const res = visitor(obj, pointer); obj['x-redoc-visited'] = false; - return res; + return visitor(obj, pointer); } private static walkEach(obj:Object, pointer:string, visitor:Function) {