From 869cd93e94741f2b715165155405c5fec50043cf Mon Sep 17 00:00:00 2001 From: Yury Date: Sat, 21 Aug 2021 18:11:38 +0300 Subject: [PATCH 1/2] fix: Display scalar array as array inside union --- src/ApiTypeDocument.js | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) diff --git a/src/ApiTypeDocument.js b/src/ApiTypeDocument.js index 19acae4..ed70be0 100644 --- a/src/ApiTypeDocument.js +++ b/src/ApiTypeDocument.js @@ -502,17 +502,7 @@ export class ApiTypeDocument extends PropertyDocumentMixin(LitElement) { [item] = item; } if (this._hasType(item, this.ns.aml.vocabularies.shapes.ArrayShape)) { - item = this._resolve(item); - const itemsKey = this._getAmfKey(this.ns.aml.vocabularies.shapes.items); - const items = this._ensureArray(item[itemsKey]); - if (items && items.length === 1) { - let result = items[0]; - if (Array.isArray(result)) { - [result] = result; - } - result = this._resolve(result); - return result; - } + return this._resolve(item); } if (Array.isArray(item)) { [item] = item; From 57d3b453f19795fc4ebede5fb848102609e1d14a Mon Sep 17 00:00:00 2001 From: Yury Date: Sat, 21 Aug 2021 18:12:09 +0300 Subject: [PATCH 2/2] test: Expect ArrayShape instead of ScalarShape --- test/api-type-document.test.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/api-type-document.test.js b/test/api-type-document.test.js index b80a0d4..d41a651 100644 --- a/test/api-type-document.test.js +++ b/test/api-type-document.test.js @@ -341,7 +341,7 @@ describe('', () => { assert.isUndefined(result); }); - it('Computes union type for an array item', async () => { + it('Computes union type for an array', async () => { const [amf, type] = await AmfLoader.loadType('UnionArray', item[1]); element.amf = amf; key = element._getAmfKey(element.ns.aml.vocabularies.shapes.anyOf); @@ -349,7 +349,7 @@ describe('', () => { assert.isTrue( element._hasType( result, - element.ns.aml.vocabularies.shapes.ScalarShape + element.ns.aml.vocabularies.shapes.ArrayShape ) ); });