Limit Nested Sub Resources
limit-nested-sub-resources
info
experience: usabilityexperience: consistency
spec: paths
The hierarchy of nested resources SHOULD NOT contain more than 8 resource names in the path.
The hierarchy of nested resources SHOULD NOT contain more than 8 resource names in the path.
Rule definition
The full Spotlight rule — drop it into a ruleset (.spotlight.yaml / .spectral.yaml) and run it with any Spotlight tool.
limit-nested-sub-resources:
title: Limit Nested Sub Resources
reference: https://spotlight-rules.com/spec/rules/openapi/limit-nested-sub-resources/
description: The hierarchy of nested resources SHOULD NOT contain more than 8
resource names in the path.
message: The hierarchy of nested resources SHOULD NOT contain more than 8
resource names in the path.
severity: info
given: $.paths.*~
then:
function: pattern
functionOptions:
notMatch: ^([^/]*/){9,}
tags:
- format:openapi
- spec:paths
- experience:usability
- experience:consistency
prompt: "You are editing an OpenAPI document to satisfy the Spotlight API
governance rule 'limit-nested-sub-resources' (Limit Nested Sub Resources).
Requirement: The hierarchy of nested resources SHOULD NOT contain more than
8 resource names in the path. To fix: Ensure the targeted value does NOT
match the regular expression `^([^/]*/){9,}`; rename or rewrite any value
that does. This rule is evaluated at the JSONPath `$.paths.*~` — inspect
every location it matches and correct only what violates the rule. Make the
smallest change that satisfies the rule, leave all unrelated content, key
order, comments, and formatting unchanged, and keep the document valid
OpenAPI. Return only the complete corrected document, with no commentary."
AI fix prompt — send this to Claude, Gemini, or ChatGPT with your artifact to auto-fix this rule
You are editing an OpenAPI document to satisfy the Spotlight API governance rule 'limit-nested-sub-resources' (Limit Nested Sub Resources). Requirement: The hierarchy of nested resources SHOULD NOT contain more than 8 resource names in the path. To fix: Ensure the targeted value does NOT match the regular expression `^([^/]*/){9,}`; rename or rewrite any value that does. This rule is evaluated at the JSONPath `$.paths.*~` — inspect every location it matches and correct only what violates the rule. Make the smallest change that satisfies the rule, leave all unrelated content, key order, comments, and formatting unchanged, and keep the document valid OpenAPI. Return only the complete corrected document, with no commentary.
| Artifact | OpenAPI |
|---|---|
| Applies at (given) | $.paths.*~ |
| Severity | info — educational by default; raise to warn/error to enforce |
| Reference | https://spotlight-rules.com/spec/rules/openapi/limit-nested-sub-resources/ |