Skip to content

Commit 3cb1501

Browse files
authored
Merge pull request #2 from mailtrap/add-github-automation-openapi-linters
Add GitHub automation openapi linters
2 parents 09e18d5 + a67ad4c commit 3cb1501

2 files changed

Lines changed: 42 additions & 0 deletions

File tree

.github/workflows/openapi-lint.yml

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
name: Lint OpenAPI Specs
2+
3+
on:
4+
push:
5+
branches: [ main, master ]
6+
paths:
7+
- 'specs/**'
8+
- '.github/workflows/openapi-lint.yml'
9+
- '.spectral.yaml'
10+
pull_request:
11+
branches: [ main, master ]
12+
paths:
13+
- 'specs/**'
14+
- '.github/workflows/openapi-lint.yml'
15+
- '.spectral.yaml'
16+
17+
jobs:
18+
lint:
19+
name: Lint OpenAPI files with Spectral
20+
runs-on: ubuntu-latest
21+
steps:
22+
- name: Checkout repository
23+
uses: actions/checkout@v4
24+
25+
- name: Setup Node.js
26+
uses: actions/setup-node@v4
27+
with:
28+
node-version: '20'
29+
30+
- name: Install Spectral
31+
run: npm install -g @stoplight/spectral-cli
32+
33+
- name: Lint OpenAPI Specs
34+
run: spectral lint "specs/*.openapi.yml" --verbose
35+

.spectral.yaml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
extends: spectral:oas
2+
3+
rules:
4+
# Disable validation of examples for non-JSON media types (like jsonl)
5+
# because Spectral tries to parse them as JSON and fails on multi-line/concatenated JSON
6+
oas3-valid-media-example: off
7+

0 commit comments

Comments
 (0)