Skip to content

Commit 826976c

Browse files
committed
fix: preserve "array of" indicator in UI for ArrayShape handling
1 parent 234c755 commit 826976c

File tree

2 files changed

+5
-11
lines changed

2 files changed

+5
-11
lines changed

src/ApiTypeDocument.js

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -526,18 +526,11 @@ export class ApiTypeDocument extends PropertyDocumentMixin(LitElement) {
526526
if (Array.isArray(item)) {
527527
[item] = item;
528528
}
529+
// For array types in unions, return the array itself instead of unwrapping to items
530+
// This preserves the "array of" indicator in the UI
529531
if (this._hasType(item, this.ns.aml.vocabularies.shapes.ArrayShape)) {
530532
item = this._resolve(item);
531-
const itemsKey = this._getAmfKey(this.ns.aml.vocabularies.shapes.items);
532-
const items = this._ensureArray(item[itemsKey]);
533-
if (items && items.length === 1) {
534-
let result = items[0];
535-
if (Array.isArray(result)) {
536-
[result] = result;
537-
}
538-
result = this._resolve(result);
539-
return result;
540-
}
533+
return item;
541534
}
542535
if (Array.isArray(item)) {
543536
[item] = item;

test/api-type-document.test.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -349,10 +349,11 @@ describe('<api-type-document>', () => {
349349
element.amf = amf;
350350
key = element._getAmfKey(element.ns.aml.vocabularies.shapes.anyOf);
351351
const result = element._computeProperty(type, key, 0);
352+
// Should return ArrayShape to preserve "Array of" indicator in UI
352353
assert.isTrue(
353354
element._hasType(
354355
result,
355-
element.ns.aml.vocabularies.shapes.ScalarShape
356+
element.ns.aml.vocabularies.shapes.ArrayShape
356357
)
357358
);
358359
});

0 commit comments

Comments
 (0)