Add resource path segment classifier and validation rules#342
Open
mo-alras wants to merge 3 commits intocommercetools:mainfrom
Open
Add resource path segment classifier and validation rules#342mo-alras wants to merge 3 commits intocommercetools:mainfrom
mo-alras wants to merge 3 commits intocommercetools:mainfrom
Conversation
ResourceAllowedCharactersRule validates that resource path segments only contain lowercase letters, digits, and hyphens ([a-z0-9-]). ResourceNoFileExtensionRule validates that resource path segments do not contain file extensions (e.g. .json, .xml, .csv). Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…ng order rules Introduces ResourceClassifier that classifies RAML resources into 8 categories (COLLECTION, IDENTIFIED_OBJECT, SCOPING_PREFIX, ACTION_ENDPOINT, MATCHING_ENDPOINT, IDENTIFIER_LOOKUP, SINGLETON, UNKNOWN) using structural signals. This enables ResourcePluralRule to automatically skip non-collection segments instead of relying on manual exclusion lists. Also adds ResourceSingularRule for singleton validation, ScopingOrderRule for prefix composition order, and an externalized action verb whitelist (default-action-verbs.txt) extensible via ruleset.xml. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
jenschude
reviewed
Apr 9, 2026
| result.validationResults.size() == 17 | ||
| } | ||
|
|
||
| def "property min max abbreviation rule"() { |
Contributor
There was a problem hiding this comment.
This prompt should be re-run as it deleted older test cases
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
ResourceClassifierthat classifies RAML resource path segments into 8 categories (COLLECTION, IDENTIFIED_OBJECT, SCOPING_PREFIX, ACTION_ENDPOINT, MATCHING_ENDPOINT, IDENTIFIER_LOOKUP, SINGLETON, UNKNOWN) using structural signals from the RAML model (resource type annotations, URI patterns, HTTP methods, child resources).ResourcePluralRulewith classifier guard so it only checks COLLECTION resources, eliminating the need for most manual exclusions inruleset.xml(the HTTP API currently has 29 exclusions, History API has 21).ResourceSingularRuleto validate that singleton resources use singular names.ScopingOrderRuleto validate that scoping prefixes (as-*→in-*→me) appear in the correct composition order.ResourceAllowedCharactersRuleto validate path segments only contain lowercase letters, digits, and hyphens.ResourceNoFileExtensionRuleto validate path segments do not contain file extensions.default-action-verbs.txt(13 verbs), extensible per-API via<option type="action-verb">inruleset.xml.ACTION_VERBtoRuleOptionTypeenum.ResourcePluralRule.defaultExcludesfrom 6 entries to 2 ("","inventory") — the classifier now auto-handleslogin,me,import,in-store.Classification logic (first match wins)
=→ IDENTIFIER_LOOKUP/{variable}→ IDENTIFIED_OBJECTas-/in-or equalsme→ SCOPING_PREFIXmatching-→ MATCHING_ENDPOINTbaseDomain→ COLLECTIONbaseResource→ IDENTIFIED_OBJECT/{var}or/key={key}→ COLLECTIONFollow-up: commercetools-docs cleanup
After this PR is merged and released, a follow-up PR in
commercetools/commercetools-docsshould:api-specs/*/package.jsonruleset.xmlexclusion lists — mostResourcePluralRuleexclusions become unnecessary:api-specs/api: 29 → ~1-2 (keepinventory, verifypassword)api-specs/history: 21 → ~1api-specs/connect: 1 → 0api-specs/checkout: 2 → 0-1api-specs/insights: 1 → 0ruleset.xml:Test plan
./gradlew :ctp-validators:test)🤖 Generated with Claude Code