From 0c6ded776a5dc1286507eab33a34507f43788d6c Mon Sep 17 00:00:00 2001 From: Roman Hotsiy Date: Sun, 13 Dec 2015 00:04:27 +0200 Subject: [PATCH] Add extra testcase to base.dereference test suite --- lib/components/base.spec.js | 20 +++++++++++++++++++ tests/schemas/base-component-dereference.json | 10 ++++++++++ 2 files changed, 30 insertions(+) diff --git a/lib/components/base.spec.js b/lib/components/base.spec.js index 926ee4cf..8eed2d85 100644 --- a/lib/components/base.spec.js +++ b/lib/components/base.spec.js @@ -84,9 +84,29 @@ describe('BaseComponent', () => { it('should resolve nested schema', () => { expect(paramWithRef.properties.subschema.$ref).to.not.exist; + paramWithRef._pointer.should.be.equal('#/definitions/Nested'); paramWithRef.properties.subschema._pointer.should.be.equal('#/definitions/Simple'); paramWithRef.properties.subschema.type.should.be.equal('object'); }); }); + + describe('array schema dereference', () => { + let paramWithRef; + before(() => { + component.pointer = '/paths/test3/get'; + component.onInit(); + component.dereference(); + paramWithRef = component.componentSchema.parameters[0]; + }); + + it('should resolve array schema', () => { + expect(paramWithRef.$ref).to.not.exist; + expect(paramWithRef.items.schema.$ref).to.not.exist; + paramWithRef.type.should.be.equal('array'); + paramWithRef._pointer.should.be.equal('#/definitions/ArrayOfSimple'); + paramWithRef.items.schema._pointer.should.be.equal('#/definitions/Simple'); + paramWithRef.items.schema.type.should.be.equal('object'); + }); + }); }); }); diff --git a/tests/schemas/base-component-dereference.json b/tests/schemas/base-component-dereference.json index c48f1c61..bd721a15 100644 --- a/tests/schemas/base-component-dereference.json +++ b/tests/schemas/base-component-dereference.json @@ -53,6 +53,16 @@ } ] } + }, + "test3": { + "get": { + "summary": "test get", + "parameters": [ + { + "$ref": "#/definitions/ArrayOfSimple" + } + ] + } } } }