From 06ea727497e14494f9632d28138d4f2f347b42b3 Mon Sep 17 00:00:00 2001 From: alexperez Date: Thu, 13 Mar 2025 15:36:13 -0300 Subject: [PATCH 01/13] fix: update raw value checks in ExampleGenerator to handle null and undefined cases --- src/ExampleGenerator.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/ExampleGenerator.js b/src/ExampleGenerator.js index 4c1e55a..a31d06a 100644 --- a/src/ExampleGenerator.js +++ b/src/ExampleGenerator.js @@ -641,7 +641,7 @@ export class ExampleGenerator extends AmfHelperMixin(Object) { example, this.ns.aml.vocabularies.document.raw )); - if (!raw) { + if (raw === null || raw === undefined) { raw = /** @type {string} */ (this._getValue( example, this.ns.w3.shacl.raw @@ -707,7 +707,7 @@ export class ExampleGenerator extends AmfHelperMixin(Object) { example, this.ns.aml.vocabularies.core.description )); - const hasRaw = !!raw; + const hasRaw = raw !== null && raw !== undefined; const result = {}; result.hasTitle = !!title; result.hasUnion = false; @@ -717,7 +717,7 @@ export class ExampleGenerator extends AmfHelperMixin(Object) { if (result.hasTitle) { result.title = title; } - if (opts.rawOnly && !raw) { + if (opts.rawOnly && (raw !== null || raw !== undefined)) { return undefined; } if (opts.rawOnly) { From cba7d902e6d4d61af1174917b0b0a6ed1065feaa Mon Sep 17 00:00:00 2001 From: alexperez Date: Thu, 13 Mar 2025 15:36:25 -0300 Subject: [PATCH 02/13] 4.4.32 --- package-lock.json | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/package-lock.json b/package-lock.json index a7a89da..60d2425 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@api-components/api-example-generator", - "version": "4.4.31", + "version": "4.4.32", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@api-components/api-example-generator", - "version": "4.4.31", + "version": "4.4.32", "license": "Apache-2.0", "dependencies": { "@api-components/amf-helper-mixin": "^4.5.24", diff --git a/package.json b/package.json index dc452f0..d722a7d 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "@api-components/api-example-generator", "description": "Examples generator from AMF model", - "version": "4.4.31", + "version": "4.4.32", "license": "Apache-2.0", "main": "index.js", "module": "index.js", From 5b82fceab73c2012fa84a8a6d54a816fdc55bf24 Mon Sep 17 00:00:00 2001 From: alexperez Date: Thu, 13 Mar 2025 16:32:42 -0300 Subject: [PATCH 03/13] fix: correct raw value check logic in ExampleGenerator to handle null and undefined cases --- src/ExampleGenerator.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ExampleGenerator.js b/src/ExampleGenerator.js index a31d06a..fa88f04 100644 --- a/src/ExampleGenerator.js +++ b/src/ExampleGenerator.js @@ -717,7 +717,7 @@ export class ExampleGenerator extends AmfHelperMixin(Object) { if (result.hasTitle) { result.title = title; } - if (opts.rawOnly && (raw !== null || raw !== undefined)) { + if (opts.rawOnly && (raw === null || raw === undefined)) { return undefined; } if (opts.rawOnly) { From a065fafcaf7ab2f697a75c9407e007240f4abc37 Mon Sep 17 00:00:00 2001 From: alexperez Date: Thu, 13 Mar 2025 16:49:25 -0300 Subject: [PATCH 04/13] fix: update GitHub Actions workflow to use matrix strategy for OS and streamline Playwright installation --- .github/workflows/deployment.yml | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/.github/workflows/deployment.yml b/.github/workflows/deployment.yml index a349f98..f32dea6 100644 --- a/.github/workflows/deployment.yml +++ b/.github/workflows/deployment.yml @@ -13,21 +13,24 @@ on: - main jobs: test_linux: - name: Ubuntu - runs-on: ubuntu-latest + name: ${{ matrix.os }} + strategy: + fail-fast: false + matrix: + os: [ubuntu-20.04] + runs-on: ${{ matrix.os }} steps: - uses: actions/checkout@v2 - uses: actions/setup-node@v1 with: node-version: 16 + - uses: microsoft/playwright-github-action@v1 - uses: actions/cache@v1 with: path: ~/.npm key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }} restore-keys: | ${{ runner.os }}-node- - - name: Install Playwright dependencies - run: npx playwright install --with-deps - name: Install dependencies run: npm ci - name: Run tests @@ -47,8 +50,6 @@ jobs: key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }} restore-keys: | ${{ runner.os }}-node- - - name: Install Playwright dependencies - run: npx playwright install --with-deps - name: Install dependencies run: npm ci - name: Run tests @@ -96,4 +97,4 @@ jobs: prerelease: false - run: npm publish --access public env: - NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} + NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} \ No newline at end of file From 16be083d73712048d6c1b7c9ec87af65cf7a97b7 Mon Sep 17 00:00:00 2001 From: alexperez Date: Thu, 13 Mar 2025 16:54:47 -0300 Subject: [PATCH 05/13] fix: update GitHub Actions cache action to version 2 --- .github/workflows/deployment.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/deployment.yml b/.github/workflows/deployment.yml index f32dea6..b26676b 100644 --- a/.github/workflows/deployment.yml +++ b/.github/workflows/deployment.yml @@ -70,7 +70,7 @@ jobs: with: node-version: '16.x' registry-url: 'https://registry.npmjs.org' - - uses: actions/cache@v1 + - uses: actions/cache@v2 with: path: ~/.npm key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }} From 700a4be6b295c7dc7c9bf02d72610dac1fe656f1 Mon Sep 17 00:00:00 2001 From: alexperez Date: Thu, 13 Mar 2025 17:27:46 -0300 Subject: [PATCH 06/13] fix: update GitHub Actions workflow to support multiple OS and streamline dependency installation --- .github/workflows/deployment.yml | 44 ++++++++++---------------------- 1 file changed, 14 insertions(+), 30 deletions(-) diff --git a/.github/workflows/deployment.yml b/.github/workflows/deployment.yml index b26676b..205f355 100644 --- a/.github/workflows/deployment.yml +++ b/.github/workflows/deployment.yml @@ -7,42 +7,26 @@ on: - master - main - develop + - stage + - support/* pull_request: branches: - - master - main + - develop + jobs: - test_linux: + tests: name: ${{ matrix.os }} strategy: fail-fast: false matrix: - os: [ubuntu-20.04] + os: [ubuntu-20.04, windows-2019] runs-on: ${{ matrix.os }} steps: - uses: actions/checkout@v2 - uses: actions/setup-node@v1 with: - node-version: 16 - - uses: microsoft/playwright-github-action@v1 - - uses: actions/cache@v1 - with: - path: ~/.npm - key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }} - restore-keys: | - ${{ runner.os }}-node- - - name: Install dependencies - run: npm ci - - name: Run tests - run: npm test - test_win: - name: "Windows" - runs-on: windows-latest - steps: - - uses: actions/checkout@v2 - - uses: actions/setup-node@v1 - with: - node-version: 16 + node-version: 18 - uses: microsoft/playwright-github-action@v1 - uses: actions/cache@v1 with: @@ -54,13 +38,13 @@ jobs: run: npm ci - name: Run tests run: npm test + tag: name: "Publishing release" - if: github.ref == 'refs/heads/main' || github.ref == 'refs/heads/master' + if: github.event_name != 'pull_request' && github.ref == 'refs/heads/main' needs: - - test_linux - - test_win - runs-on: ubuntu-latest + - tests + runs-on: self-hosted steps: - name: Checkout code uses: actions/checkout@v2 @@ -68,15 +52,15 @@ jobs: fetch-depth: 0 - uses: actions/setup-node@v2 with: - node-version: '16.x' + node-version: '18.x' registry-url: 'https://registry.npmjs.org' - - uses: actions/cache@v2 + - uses: actions/cache@v1 with: path: ~/.npm key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }} restore-keys: | ${{ runner.os }}-node- - - run: npm install + - run: npm ci - name: Read version from package.json uses: culshaw/read-package-node-version-actions@v1 id: package-node-version From d9b37ae98589bfca1bfcb19345716c770066e8c9 Mon Sep 17 00:00:00 2001 From: alexperez Date: Thu, 13 Mar 2025 17:32:17 -0300 Subject: [PATCH 07/13] fix: update GitHub Actions workflow to support Linux and Windows testing with Node.js 16 --- .github/workflows/deployment.yml | 40 ++++++++++++++++++++++---------- 1 file changed, 28 insertions(+), 12 deletions(-) diff --git a/.github/workflows/deployment.yml b/.github/workflows/deployment.yml index 205f355..f75a48b 100644 --- a/.github/workflows/deployment.yml +++ b/.github/workflows/deployment.yml @@ -7,20 +7,17 @@ on: - master - main - develop - - stage - - support/* pull_request: branches: + - master - main - - develop - jobs: - tests: + test_linux: name: ${{ matrix.os }} strategy: fail-fast: false matrix: - os: [ubuntu-20.04, windows-2019] + os: [ubuntu-20.04] runs-on: ${{ matrix.os }} steps: - uses: actions/checkout@v2 @@ -28,7 +25,26 @@ jobs: with: node-version: 18 - uses: microsoft/playwright-github-action@v1 - - uses: actions/cache@v1 + - uses: actions/cache@v2 + with: + path: ~/.npm + key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }} + restore-keys: | + ${{ runner.os }}-node- + - name: Install dependencies + run: npm ci + - name: Run tests + run: npm test + test_win: + name: "Windows" + runs-on: windows-latest + steps: + - uses: actions/checkout@v2 + - uses: actions/setup-node@v1 + with: + node-version: 18 + - uses: microsoft/playwright-github-action@v1 + - uses: actions/cache@v2 with: path: ~/.npm key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }} @@ -38,13 +54,13 @@ jobs: run: npm ci - name: Run tests run: npm test - tag: name: "Publishing release" - if: github.event_name != 'pull_request' && github.ref == 'refs/heads/main' + if: github.ref == 'refs/heads/main' || github.ref == 'refs/heads/master' needs: - - tests - runs-on: self-hosted + - test_linux + - test_win + runs-on: ubuntu-latest steps: - name: Checkout code uses: actions/checkout@v2 @@ -54,7 +70,7 @@ jobs: with: node-version: '18.x' registry-url: 'https://registry.npmjs.org' - - uses: actions/cache@v1 + - uses: actions/cache@v2 with: path: ~/.npm key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }} From 7defa057a076f231d6850830be693082ad097d3e Mon Sep 17 00:00:00 2001 From: alexperez Date: Thu, 13 Mar 2025 17:35:25 -0300 Subject: [PATCH 08/13] fix: update GitHub Actions cache action to version 3 --- .github/workflows/deployment.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/deployment.yml b/.github/workflows/deployment.yml index f75a48b..2e6775a 100644 --- a/.github/workflows/deployment.yml +++ b/.github/workflows/deployment.yml @@ -25,7 +25,7 @@ jobs: with: node-version: 18 - uses: microsoft/playwright-github-action@v1 - - uses: actions/cache@v2 + - uses: actions/cache@v3 with: path: ~/.npm key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }} @@ -44,7 +44,7 @@ jobs: with: node-version: 18 - uses: microsoft/playwright-github-action@v1 - - uses: actions/cache@v2 + - uses: actions/cache@v3 with: path: ~/.npm key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }} @@ -70,7 +70,7 @@ jobs: with: node-version: '18.x' registry-url: 'https://registry.npmjs.org' - - uses: actions/cache@v2 + - uses: actions/cache@v3 with: path: ~/.npm key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }} From f46aa9bb67fce4ae46af81c90cdbbd9e885c4e4c Mon Sep 17 00:00:00 2001 From: alexperez Date: Thu, 13 Mar 2025 17:38:06 -0300 Subject: [PATCH 09/13] fix: update Node.js version in deployment workflow to 16 and change npm ci to npm install --- .github/workflows/deployment.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/deployment.yml b/.github/workflows/deployment.yml index 2e6775a..4da461c 100644 --- a/.github/workflows/deployment.yml +++ b/.github/workflows/deployment.yml @@ -23,7 +23,7 @@ jobs: - uses: actions/checkout@v2 - uses: actions/setup-node@v1 with: - node-version: 18 + node-version: 16 - uses: microsoft/playwright-github-action@v1 - uses: actions/cache@v3 with: @@ -42,7 +42,7 @@ jobs: - uses: actions/checkout@v2 - uses: actions/setup-node@v1 with: - node-version: 18 + node-version: 16 - uses: microsoft/playwright-github-action@v1 - uses: actions/cache@v3 with: @@ -68,7 +68,7 @@ jobs: fetch-depth: 0 - uses: actions/setup-node@v2 with: - node-version: '18.x' + node-version: '16.x' registry-url: 'https://registry.npmjs.org' - uses: actions/cache@v3 with: @@ -76,7 +76,7 @@ jobs: key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }} restore-keys: | ${{ runner.os }}-node- - - run: npm ci + - run: npm install - name: Read version from package.json uses: culshaw/read-package-node-version-actions@v1 id: package-node-version From e265062cedefa152210d7678618b9220e09f865e Mon Sep 17 00:00:00 2001 From: alexperez Date: Thu, 13 Mar 2025 17:41:25 -0300 Subject: [PATCH 10/13] fix: add overrides for Playwright version to 1.25.2 in package.json --- package.json | 3 +++ 1 file changed, 3 insertions(+) diff --git a/package.json b/package.json index d722a7d..20756a6 100644 --- a/package.json +++ b/package.json @@ -90,5 +90,8 @@ "*.js": [ "eslint --fix" ] + }, + "overrides": { + "playwright": "1.25.2" } } From 693d077f7430f2d62ba41c4926f791e91981cf8d Mon Sep 17 00:00:00 2001 From: alexperez Date: Thu, 13 Mar 2025 17:43:47 -0300 Subject: [PATCH 11/13] fix: change npm ci to npm install in deployment workflow --- .github/workflows/deployment.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/deployment.yml b/.github/workflows/deployment.yml index 4da461c..da65d1d 100644 --- a/.github/workflows/deployment.yml +++ b/.github/workflows/deployment.yml @@ -32,7 +32,7 @@ jobs: restore-keys: | ${{ runner.os }}-node- - name: Install dependencies - run: npm ci + run: npm install - name: Run tests run: npm test test_win: From 33b07ef21b0927989e01967e6607c0a8c18a5a41 Mon Sep 17 00:00:00 2001 From: alexperez Date: Thu, 13 Mar 2025 17:49:25 -0300 Subject: [PATCH 12/13] fix: change npm ci to npm install in deployment workflow --- .github/workflows/deployment.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/deployment.yml b/.github/workflows/deployment.yml index da65d1d..698be5c 100644 --- a/.github/workflows/deployment.yml +++ b/.github/workflows/deployment.yml @@ -51,7 +51,7 @@ jobs: restore-keys: | ${{ runner.os }}-node- - name: Install dependencies - run: npm ci + run: npm install - name: Run tests run: npm test tag: From 60443238aa3ac7599fbd839c0fd11cb750f48dba Mon Sep 17 00:00:00 2001 From: alexperez Date: Fri, 14 Mar 2025 09:27:05 -0300 Subject: [PATCH 13/13] fix: simplify null and undefined checks for raw variable in ExampleGenerator --- src/ExampleGenerator.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/ExampleGenerator.js b/src/ExampleGenerator.js index fa88f04..3aac66c 100644 --- a/src/ExampleGenerator.js +++ b/src/ExampleGenerator.js @@ -641,7 +641,9 @@ export class ExampleGenerator extends AmfHelperMixin(Object) { example, this.ns.aml.vocabularies.document.raw )); - if (raw === null || raw === undefined) { + const rawIsNull = raw === null; + const rawIsUndefined = raw === undefined; + if (rawIsNull || rawIsUndefined) { raw = /** @type {string} */ (this._getValue( example, this.ns.w3.shacl.raw @@ -707,7 +709,7 @@ export class ExampleGenerator extends AmfHelperMixin(Object) { example, this.ns.aml.vocabularies.core.description )); - const hasRaw = raw !== null && raw !== undefined; + const hasRaw = !rawIsNull && !rawIsUndefined; const result = {}; result.hasTitle = !!title; result.hasUnion = false; @@ -717,7 +719,7 @@ export class ExampleGenerator extends AmfHelperMixin(Object) { if (result.hasTitle) { result.title = title; } - if (opts.rawOnly && (raw === null || raw === undefined)) { + if (opts.rawOnly && (rawIsNull || rawIsUndefined)) { return undefined; } if (opts.rawOnly) {