diff --git a/.github/workflows/deployment.yml b/.github/workflows/deployment.yml index a349f98..698be5c 100644 --- a/.github/workflows/deployment.yml +++ b/.github/workflows/deployment.yml @@ -13,23 +13,26 @@ 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: actions/cache@v1 + - uses: microsoft/playwright-github-action@v1 + - uses: actions/cache@v3 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 + run: npm install - name: Run tests run: npm test test_win: @@ -41,16 +44,14 @@ jobs: with: node-version: 16 - uses: microsoft/playwright-github-action@v1 - - uses: actions/cache@v1 + - uses: actions/cache@v3 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 + run: npm install - name: Run tests run: npm test tag: @@ -69,7 +70,7 @@ jobs: with: node-version: '16.x' registry-url: 'https://registry.npmjs.org' - - uses: actions/cache@v1 + - uses: actions/cache@v3 with: path: ~/.npm key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }} @@ -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 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..20756a6 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", @@ -90,5 +90,8 @@ "*.js": [ "eslint --fix" ] + }, + "overrides": { + "playwright": "1.25.2" } } diff --git a/src/ExampleGenerator.js b/src/ExampleGenerator.js index 4c1e55a..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) { + 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; + 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) { + if (opts.rawOnly && (rawIsNull || rawIsUndefined)) { return undefined; } if (opts.rawOnly) {