diff --git a/.spectral-required.yml b/.spectral-required.yml index e2ba4b4..e9b7dec 100644 --- a/.spectral-required.yml +++ b/.spectral-required.yml @@ -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 @@ -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 @@ -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