Skip to content
Merged
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
95 changes: 53 additions & 42 deletions .spectral-required.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@
# OpenAPI Specification version 3.x
extends: [spectral:oas]

functions:
- date
- xEnturPermissions

rules:
no-$ref-siblings: "off"
# These generate too many false positives
Expand All @@ -15,52 +19,11 @@ rules:
# -------------------------------------------------------------------------

entur-permissions:
message: "x-entur-permissions must match the schema"
documentationUrl: "https://github.com/entur/api-guidelines/blob/main/guidelines.md#233-documenting-permissions-for-partner-endpoints"
severity: error
given: $.paths.*[get,post,put,patch,delete,options,head,trace].x-entur-permissions
then:
function: schema
functionOptions:
schema:
type: object
required:
- value
properties:
description:
type: string
value:
$ref: "#/$defs/permission-node"
$defs:
permission-node:
oneOf:
- $ref: "#/$defs/permission-leaf"
- $ref: "#/$defs/permission-all"
- $ref: "#/$defs/permission-any"

permission-leaf:
type: string
pattern: "^[0-9a-zA-ZæøåØÆÅ][0-9a-zA-ZæøåØÆÅ.\\-]{0,99}:(les|opprett|endre|slett)$"

permission-all:
type: object
required:
- all
properties:
all:
type: array
items:
- $ref: "#/$defs/permission-node"

permission-any:
type: object
required:
- any
properties:
any:
type: array
items:
- $ref: "#/$defs/permission-node"
function: xEnturPermissions

# -------------------------------------------------------------------------
# 2.4 Entur Metadata
Expand Down Expand Up @@ -133,3 +96,51 @@ rules:
function: pattern
functionOptions:
match: ^[a-z0-9]+(-[a-z0-9]+)*$

# -------------------------------------------------------------------------
# 2.5 Lifecycle
# -------------------------------------------------------------------------

## On API level
entur-stability-level-api:
documentationUrl: "https://github.com/entur/api-guidelines/blob/main/guidelines.md#25-lifecycle"
severity: error
given: $.info.x-stability-level
then:
function: enumeration
functionOptions:
values: [draft, beta, stable]

entur-deprecation-api:
documentationUrl: "https://github.com/entur/api-guidelines/blob/main/guidelines.md#254-deprecation"
severity: error
given: $.info.x-deprecated
then:
function: schema
functionOptions:
schema:
type: boolean

entur-sunset-format-api:
documentationUrl: "https://github.com/entur/api-guidelines/blob/main/guidelines.md#254-deprecation"
severity: error
given: $.info.x-sunset
then:
function: date

# On individual operation level
entur-stability-level-operation:
documentationUrl: "https://github.com/entur/api-guidelines/blob/main/guidelines.md#25-lifecycle"
severity: error
given: $.paths.*[get,post,put,patch,delete,options,head,trace].x-stability-level
then:
function: enumeration
functionOptions:
values: [draft, beta, stable]

entur-sunset-format-operation:
documentationUrl: "https://github.com/entur/api-guidelines/blob/main/guidelines.md#254-deprecation"
severity: error
given: $.paths.*[get,post,put,patch,delete,options,head,trace].x-sunset
then:
function: date
Loading