Skip to content
2 changes: 1 addition & 1 deletion .github/workflows/required-spec-validations.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ jobs:
id: spectral-validation
env:
SPECTRAL_VERSION: ${{ inputs.spectral_version }}
run: npx -- @stoplight/spectral-cli@"${SPECTRAL_VERSION}" lint openapi-foas.yaml --ruleset=.spectral.yaml # we will update this to lint the FOAS in CLOUDP-263186
run: npx -- @stoplight/spectral-cli@"${SPECTRAL_VERSION}" lint openapi-foas.yaml --ruleset=tools/spectral/.spectral.yaml # we will update this to lint the FOAS in CLOUDP-263186
- name: Install Go
uses: actions/setup-go@0a12ed9d6a96ab950c8f026ed9f722fe0da7ef32
with:
Expand Down
24 changes: 24 additions & 0 deletions .github/workflows/spectral-lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: Spectral Lint Commited OpenAPI Spec

# Trigger the workflow on pull requests and pushes to the main branch
on:
pull_request:
push:
branches:
- main

jobs:
spectral-lint:
runs-on: ubuntu-latest

steps:
# Checkout the code
- name: Checkout repository
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332

- name: Run
id: spectral-validation
env:
SPECTRAL_VERSION: ${{ vars.SPECTRAL_VERSION }}
run: npx -- @stoplight/spectral-cli@"${SPECTRAL_VERSION}" lint openapi/v2.yaml --ruleset=tools/spectral/.spectral.yaml # we will update this to lint the FOAS in CLOUDP-263186

31 changes: 30 additions & 1 deletion .spectral.yaml → tools/spectral/.spectral.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,36 @@ rules:
function: pattern
functionOptions:
match: "^(dev|qa|stage|prod)(,(dev|qa|stage|prod))*$"


x-xgen-soa-migration-extension:
description: "Ensure the x-xgen-soa-migration extension is valid."
message: "The x-xgen-soa-migration extension must include 'service_name', 'allow_diff', and 'source_service' should only be present when 'allow_diff' is true."
formats: ["oas3"]
given: "$.paths[*][*].x-xgen-soa-migration"
severity: error
then:
- field: service_name
function: truthy
message: "'service_name' must be provided."
- field: allow_diff
function: pattern
functionOptions:
match: "^(true|false)$"
message: "'allow_diff' must be true or false."
- function: falsy
field: source_service
functionOptions:
type: "truthy"
message: "'source_service' should only exist when 'allow_diff' is true."
when:
field: allow_diff
pattern: "^false$"
- function: truthy
field: source_service
message: "'source_service' must be provided when 'allow_diff' is true."
when:
field: allow_diff
pattern: "^true$"
overrides:
- files: # load sample data has an issue with different path param names for different VERBS
- "*.yaml#/paths/~1api~1atlas~1v1.0~1groups~1%7BgroupId%7D~1sampleDatasetLoad~1%7BsampleDatasetId%7D"
Expand Down
Loading