From 729771db271057262bf6b09af104f55a4272bf3c Mon Sep 17 00:00:00 2001 From: Eivind Grimstad Date: Fri, 28 Aug 2026 08:05:52 +0200 Subject: [PATCH 1/2] fix: Use new xEnturPermissions function in spectral-required --- .spectral-required.yml | 46 ++++-------------------------------------- 1 file changed, 4 insertions(+), 42 deletions(-) diff --git a/.spectral-required.yml b/.spectral-required.yml index e2ba4b4..6e21a50 100644 --- a/.spectral-required.yml +++ b/.spectral-required.yml @@ -4,6 +4,9 @@ # OpenAPI Specification version 3.x extends: [spectral:oas] +functions: + - xEnturPermissions + rules: no-$ref-siblings: "off" # These generate too many false positives @@ -15,52 +18,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 From e51cf291139a88105214fec68684739302bcdd41 Mon Sep 17 00:00:00 2001 From: Eivind Grimstad Date: Fri, 28 Aug 2026 08:06:09 +0200 Subject: [PATCH 2/2] fix: Add lifecycle format rules to spectral-required We want to make sure that all these custom fields have good values before publishing to developer-portal --- .spectral-required.yml | 49 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) diff --git a/.spectral-required.yml b/.spectral-required.yml index 6e21a50..e9b7dec 100644 --- a/.spectral-required.yml +++ b/.spectral-required.yml @@ -5,6 +5,7 @@ extends: [spectral:oas] functions: + - date - xEnturPermissions rules: @@ -95,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