Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion .github/workflows/dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,10 @@ jobs:
run: |
export PATH=/root/.local/bin:$PATH
sudo apt install -y nodejs npm
sudo npm install -g @stoplight/spectral-cli@6.14.2
sudo npm install -g \
@stoplight/spectral-cli@6.14.2 \
@stoplight/spectral-rulesets@1.22.2
test "$(node -p "require('/usr/local/lib/node_modules/@stoplight/spectral-rulesets/package.json').version")" = "1.22.2"
cd microservices/csitOasValidationApi
poetry env use python3.14
poetry install --no-root
Expand Down
12 changes: 10 additions & 2 deletions microservices/csitOasValidationApi/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,16 @@

RUN python -m pip install --upgrade pip

# Install Spectral CLI (required for validation)
RUN npm install -g @stoplight/spectral-cli@6.14.2
# Install Spectral CLI (required for validation). Pin the rulesets package
# separately because spectral-cli declares it as ">=1" and newer transitive
# releases can change validation behaviour without changing the CLI version.
ARG SPECTRAL_CLI_VERSION=6.14.2
ARG SPECTRAL_RULESETS_VERSION=1.22.2
RUN npm install -g \

Check warning on line 16 in microservices/csitOasValidationApi/Dockerfile

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Omitting "--ignore-scripts" allows lifecycle scripts to run during package installation.

See more on https://sonarcloud.io/project/issues?id=bcgov_gwa-api&issues=AZ-ugp73IYAx-wTGV36j&open=AZ-ugp73IYAx-wTGV36j&pullRequest=284

Check warning

Code scanning / SonarCloud

JavaScript package manager scripts should not be executed during installation Medium

Omitting "--ignore-scripts" allows lifecycle scripts to run during package installation. See more on SonarQube Cloud
"@stoplight/spectral-cli@${SPECTRAL_CLI_VERSION}" \
"@stoplight/spectral-rulesets@${SPECTRAL_RULESETS_VERSION}" && \
test "$(node -p "require('/usr/local/lib/node_modules/@stoplight/spectral-rulesets/package.json').version")" = \
"${SPECTRAL_RULESETS_VERSION}"

# Install Poetry
RUN cd /tmp && \
Expand Down
6 changes: 4 additions & 2 deletions microservices/csitOasValidationApi/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,9 @@ sudo apt install nodejs npm
Install Stoplight Spectral
Requires 6.0.0 or greater
```bash
sudo npm install -g @stoplight/spectral-cli@6.14.2
sudo npm install -g \
@stoplight/spectral-cli@6.14.2 \
@stoplight/spectral-rulesets@1.22.2
spectral --version
```

Expand Down Expand Up @@ -153,4 +155,4 @@ curl -X POST http://localhost:8080/versions/v0.1.0-test/rulesets/basic-ruleset/v
}
}' \
| jq .
```
```
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
"""Regression tests for the external Spectral runtime."""

import subprocess
import textwrap
from pathlib import Path


def test_null_example_does_not_crash_spectral():
"""duplicated-entry-in-enum must not dereference enum on null nodes."""

ruleset = (
Path(__file__).parent
/ "resources"
/ "github-cache"
/ "tags"
/ "ruleset-v1.1.0"
/ "spectral"
/ "sdx"
/ "ruleset.yaml"
)
openapi_content = textwrap.dedent("""\
openapi: 3.0.3
info:
title: Nullable example regression
version: 1.0.0
paths:
/widgets:
get:
operationId: listWidgets
responses:
'200':
description: Widget list
content:
application/json:
example:
nextCursor: null
""")

result = subprocess.run(
["spectral", "lint", "--ruleset", str(ruleset), "-"],
input=openapi_content,
capture_output=True,
text=True,
timeout=30,
check=False,
)

assert result.returncode != 2, result.stderr
Loading