Skip to content

APIMGMT-1888: Add new rule to validate versionDetailsMap keys against versionEnd#69

Merged
victor-mancera-sp merged 3 commits into
mainfrom
vmancera/APIMGMT-1888
Apr 8, 2026
Merged

APIMGMT-1888: Add new rule to validate versionDetailsMap keys against versionEnd#69
victor-mancera-sp merged 3 commits into
mainfrom
vmancera/APIMGMT-1888

Conversation

@victor-mancera-sp

@victor-mancera-sp victor-mancera-sp commented Apr 6, 2026

Copy link
Copy Markdown
Contributor

Adds a Spectral rule for gateway route specs so that versionDetailsMap does not contain yearly API version keys (v20XX) above versionEnd. Entries whose version is greater than versionEnd are ignored by sp-gateway, so this catches silent misconfiguration in sp-gateway-routes.yaml (and related files) at lint time.

spectral lint on a gateway YAML using gateway-ruleset.yaml completes successfully against the current sp-gateway-routes.yaml in consuming repos (no new violations for valid configs). Then, I modified the test YAML file to include an entry that would result in a violation, obtaining the following result:

victor.mancera@vmancera-09DKQ9N api-linter % cd /Users/victor.mancera/code/api-linter
npx @stoplight/spectral-cli lint packages/test-files/sp-gateway-routes.yaml --ruleset packages/gateway-rulesets/gateway-ruleset.yaml
'fs' is imported by packages/gateway-rulesets/functions/check-path-documentation.js, but could not be resolved – treating it as an external dependency
'path' is imported by packages/gateway-rulesets/functions/check-path-documentation.js, but could not be resolved – treating it as an external dependency

/Users/victor.mancera/code/api-linter/packages/test-files/sp-gateway-routes.yaml
 37:7  error  gateway-route-version-details-map-keys-must-not-exceed-version-end  versionDetailsMap key "v2028" (API version 2028) cannot be greater than versionEnd (2026); that entry is ignored by sp-gateway.  sp-gateway.routes[2]

@github-actions

github-actions Bot commented Apr 6, 2026

Copy link
Copy Markdown

Linting Report

Last updated: 4/7/2026, 2:42:17 PM

Found 12 total issues:

  • ❌ Error: 12

OpenAPI Specs

❌ Invalid Ref (8)
  • File: /packages/test-files/sailpoint-api.OpenAPI.yaml (7)

    • Line 86: #/ é, à, ö,/schemas/Pet does not exist
    • Line 100: #/components/schemas/ é, à, ö, does not exist
    • Line 138: #/components/ é, à, ö,/Pet does not exist
    • Line 314: #/components/ é, à, ö,/ApiResponse does not exist
    • Line 349: #/Test/schemas/Order does not exist
    • Line 352: #/components/Test/Order does not exist
    • Line 355: #/components/schemas/Test does not exist
  • File: /packages/test-files/v2024/paths/account.yaml (1)

    • Line 32: ENOENT: no such file or directory, open /home/runner/work/api-linter/api-linter/packages/test-files/v2024/responses/InvalidReference.yaml
❌ Paths Must Not Reference Documents Outside Of Their Version (2)
❌ Root Tags Must Be In Alphabetical Order (1)

Gateway

❌ Gateway Route Version Details Map Keys Must Not Exceed Version End (1)
  • File: /packages/test-files/sp-gateway-routes.yaml (1)

    • Line 37: versionDetailsMap key "v2028" (API version 2028) cannot be greater than versionEnd (2026); that entry is ignored by sp-gateway.

const year = yearFromVersionDetailsKey(key);
if (year !== null && year > endVersion) {
results.push({
message: `versionDetailsMap key "${key}" (API version ${year}) cannot be greater than versionEnd (${endVersion}); that entry is ignored by sp-gateway.`,

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So, will this message include the variables from the route? Will this appear in the linter report?
Or will the user only see generic message "versionDetailsMap keys for yearly API versions (v20XX) must not be greater than versionEnd, or sp-gateway will ignore them"?

I think specific message is better, but I don't see that in your pr example.

@victor-mancera-sp victor-mancera-sp merged commit 097427b into main Apr 8, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants