Skip to content

Commit 398c707

Browse files
authored
Merge pull request #88 from advanced-rest-client/W-20075703/Fails-to-Render-Array-Type-Indicator-When-Used-in-a-Union
@W-20075703 fix: preserve "array of" indicator in UI for ArrayShape handling
2 parents 234c755 + c49f58d commit 398c707

File tree

3 files changed

+16
-24
lines changed

3 files changed

+16
-24
lines changed

.github/workflows/deployment.yml

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -12,21 +12,20 @@ on:
1212
- master
1313
- main
1414
jobs:
15-
test_linux:
15+
tests:
1616
name: ${{ matrix.os }}
1717
strategy:
1818
fail-fast: false
1919
matrix:
20-
os: [ubuntu-20.04]
21-
# os: [ubuntu-18.04, ubuntu-20.04]
20+
os: [ubuntu-22.04, windows-2022]
2221
runs-on: ${{ matrix.os }}
2322
steps:
2423
- uses: actions/checkout@v2
2524
- uses: actions/setup-node@v1
2625
with:
27-
node-version: 16
26+
node-version: 18
2827
- uses: microsoft/playwright-github-action@v1
29-
- uses: actions/cache@v1
28+
- uses: actions/cache@v3
3029
with:
3130
path: ~/.npm
3231
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
@@ -38,27 +37,26 @@ jobs:
3837
run: npm test
3938
tag:
4039
name: "Publishing release"
41-
if: github.ref == 'refs/heads/main' || github.ref == 'refs/heads/master'
42-
needs:
43-
- test_linux
44-
# - test_win
45-
runs-on: ubuntu-latest
40+
if: github.event_name != 'pull_request'
41+
needs:
42+
- tests
43+
runs-on: mulesoft-ubuntu
4644
steps:
4745
- name: Checkout code
4846
uses: actions/checkout@v2
4947
with:
5048
fetch-depth: 0
5149
- uses: actions/setup-node@v2
5250
with:
53-
node-version: '16.x'
51+
node-version: '18.x'
5452
registry-url: 'https://registry.npmjs.org'
55-
- uses: actions/cache@v1
53+
- uses: actions/cache@v3
5654
with:
5755
path: ~/.npm
5856
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
5957
restore-keys: |
6058
${{ runner.os }}-node-
61-
- run: npm install
59+
- run: npm ci
6260
- name: Read version from package.json
6361
uses: culshaw/read-package-node-version-actions@v1
6462
id: package-node-version

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)