mirror of
https://github.com/discord/discord-api-spec.git
synced 2025-09-03 14:32:39 -04:00
Added spectral github action
This commit is contained in:
parent
cbf25fa34d
commit
29bd8893c6
2 changed files with 83 additions and 0 deletions
52
.github/workflows/spectral-lint.yml
vendored
Normal file
52
.github/workflows/spectral-lint.yml
vendored
Normal file
|
@ -0,0 +1,52 @@
|
|||
name: API Spec Linting
|
||||
|
||||
on:
|
||||
push:
|
||||
paths:
|
||||
- 'specs/**'
|
||||
- '.spectral.yml'
|
||||
pull_request:
|
||||
paths:
|
||||
- 'specs/**'
|
||||
- '.spectral.yml'
|
||||
workflow_dispatch:
|
||||
|
||||
jobs:
|
||||
spectral-lint:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Setup Node.js
|
||||
uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: '18'
|
||||
|
||||
- name: Install Spectral CLI
|
||||
run: npm install -g @stoplight/spectral-cli
|
||||
|
||||
- name: Lint OpenAPI specs
|
||||
run: |
|
||||
echo "Linting OpenAPI specifications with Spectral..."
|
||||
echo "Using configuration: .spectral.yml"
|
||||
|
||||
echo "::group::Linting openapi.json"
|
||||
spectral lint specs/openapi.json --format stylish --verbose
|
||||
echo "::endgroup::"
|
||||
|
||||
echo "::group::Linting openapi_preview.json"
|
||||
spectral lint specs/openapi_preview.json --format stylish --verbose
|
||||
echo "::endgroup::"
|
||||
|
||||
echo "✅ All specs linted successfully!"
|
||||
|
||||
- name: Upload lint results
|
||||
if: failure()
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: spectral-lint-results
|
||||
path: |
|
||||
specs/
|
||||
retention-days: 7
|
31
.spectral.yml
Normal file
31
.spectral.yml
Normal file
|
@ -0,0 +1,31 @@
|
|||
extends: ["spectral:oas"]
|
||||
|
||||
rules:
|
||||
# OpenAPI-specific rules
|
||||
openapi-tags: true
|
||||
operation-description: true
|
||||
operation-operationId: true
|
||||
operation-operationId-unique: true
|
||||
operation-operationId-valid-in-url: true
|
||||
operation-parameters: true
|
||||
operation-success-response: true
|
||||
operation-tag-defined: true
|
||||
path-keys-no-trailing-slash: true
|
||||
path-not-include-query: true
|
||||
|
||||
# Schema rules
|
||||
typed-enum: true
|
||||
no-$ref-siblings: true
|
||||
|
||||
# Info rules
|
||||
# info-contact: true
|
||||
# info-description: true
|
||||
# info-license: true
|
||||
|
||||
# require-example-for-schemas:
|
||||
# description: "All schemas should have examples"
|
||||
# given: "$.components.schemas[*]"
|
||||
# then:
|
||||
# field: example
|
||||
# function: truthy
|
||||
# severity: warn
|
Loading…
Reference in a new issue