Skip to content

Commit

Permalink
chore: Add custom linting
Browse files Browse the repository at this point in the history
  • Loading branch information
robincher committed Mar 26, 2024
1 parent f7f1566 commit 2f9cc8f
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@ license
kong-plugin-mocking

*.out
.local/*
40 changes: 40 additions & 0 deletions .spectral.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
extends:
- "spectral:oas"
rules:
# ---------------------------------------------------------------------------
# Schema rules
# ---------------------------------------------------------------------------
info-version-semver:
severity: error
recommended: true
message: Specs should follow semantic versioning. {{value}} is not a valid version.
given: $.info.version
then:
function: pattern
functionOptions:
match: "^([0-9]+.[0-9]+.[0-9]+)$"
# ---------------------------------------------------------------------------
# API Rules
# ---------------------------------------------------------------------------
server-url-must-contain-version:
description: Global API version must be present in the path
severity: error
recommended: true
message: "Unversioned server URL detected: {{value}}"
given: "$.servers[*].url"
then:
function: pattern
functionOptions:
match: "\/v[1-9]+\/"
paths-kebab-case:
description: Paths should be kebab-case.
message: "{{property}} should be kebab-case (lower-case and separated with hyphens)"
severity: warn
given: $.paths[*]~
then:
function: pattern
functionOptions:
match: "^(\/|[a-z0-9-.]+|{[a-zA-Z0-9_]+})+$"

0 comments on commit 2f9cc8f

Please sign in to comment.