Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ testRule('xgen-IPA-102-collection-identifier-camelCase', [
{
code: 'xgen-IPA-102-collection-identifier-camelCase',
message:
"Collection identifiers must be in camelCase. Path segment 'Resources' in path '/Resources' is not in camelCase. http://go/ipa/102",
"Collection identifiers must be in camelCase. Path segment 'Resources' in path '/Resources' is not in camelCase. http://go/ipa-spectral#IPA-102",
path: ['paths', '/Resources'],
severity: DiagnosticSeverity.Warning,
},
Expand All @@ -62,7 +62,7 @@ testRule('xgen-IPA-102-collection-identifier-camelCase', [
{
code: 'xgen-IPA-102-collection-identifier-camelCase',
message:
"Collection identifiers must be in camelCase. Path segment 'resource_groups' in path '/resource_groups' is not in camelCase. http://go/ipa/102",
"Collection identifiers must be in camelCase. Path segment 'resource_groups' in path '/resource_groups' is not in camelCase. http://go/ipa-spectral#IPA-102",
path: ['paths', '/resource_groups'],
severity: DiagnosticSeverity.Warning,
},
Expand All @@ -79,7 +79,7 @@ testRule('xgen-IPA-102-collection-identifier-camelCase', [
{
code: 'xgen-IPA-102-collection-identifier-camelCase',
message:
"Collection identifiers must be in camelCase. Path segment 'resource-groups' in path '/resource-groups' is not in camelCase. http://go/ipa/102",
"Collection identifiers must be in camelCase. Path segment 'resource-groups' in path '/resource-groups' is not in camelCase. http://go/ipa-spectral#IPA-102",
path: ['paths', '/resource-groups'],
severity: DiagnosticSeverity.Warning,
},
Expand All @@ -96,7 +96,7 @@ testRule('xgen-IPA-102-collection-identifier-camelCase', [
{
code: 'xgen-IPA-102-collection-identifier-camelCase',
message:
"Collection identifiers must be in camelCase. Path segment 'Resources' in path '/Resources:createResource' is not in camelCase. http://go/ipa/102",
"Collection identifiers must be in camelCase. Path segment 'Resources' in path '/Resources:createResource' is not in camelCase. http://go/ipa-spectral#IPA-102",
path: ['paths', '/Resources:createResource'],
severity: DiagnosticSeverity.Warning,
},
Expand All @@ -113,7 +113,7 @@ testRule('xgen-IPA-102-collection-identifier-camelCase', [
{
code: 'xgen-IPA-102-collection-identifier-camelCase',
message:
"Collection identifiers must be in camelCase. Path segment 'resourcesAPI' in path '/resourcesAPI' is not in camelCase. http://go/ipa/102",
"Collection identifiers must be in camelCase. Path segment 'resourcesAPI' in path '/resourcesAPI' is not in camelCase. http://go/ipa-spectral#IPA-102",
path: ['paths', '/resourcesAPI'],
severity: DiagnosticSeverity.Warning,
},
Expand Down Expand Up @@ -145,21 +145,21 @@ testRule('xgen-IPA-102-collection-identifier-camelCase', [
{
code: 'xgen-IPA-102-collection-identifier-camelCase',
message:
"Collection identifiers must be in camelCase. Path '/api//users' contains double slashes (//) which is not allowed. http://go/ipa/102",
"Collection identifiers must be in camelCase. Path '/api//users' contains double slashes (//) which is not allowed. http://go/ipa-spectral#IPA-102",
path: ['paths', '/api//users'],
severity: DiagnosticSeverity.Warning,
},
{
code: 'xgen-IPA-102-collection-identifier-camelCase',
message:
"Collection identifiers must be in camelCase. Path '/resources///{resourceId}' contains double slashes (//) which is not allowed. http://go/ipa/102",
"Collection identifiers must be in camelCase. Path '/resources///{resourceId}' contains double slashes (//) which is not allowed. http://go/ipa-spectral#IPA-102",
path: ['paths', '/resources///{resourceId}'],
severity: DiagnosticSeverity.Warning,
},
{
code: 'xgen-IPA-102-collection-identifier-camelCase',
message:
"Collection identifiers must be in camelCase. Path '//doubleSlashAtStart' contains double slashes (//) which is not allowed. http://go/ipa/102",
"Collection identifiers must be in camelCase. Path '//doubleSlashAtStart' contains double slashes (//) which is not allowed. http://go/ipa-spectral#IPA-102",
path: ['paths', '//doubleSlashAtStart'],
severity: DiagnosticSeverity.Warning,
},
Expand All @@ -186,21 +186,21 @@ testRule('xgen-IPA-102-collection-identifier-camelCase', [
{
code: 'xgen-IPA-102-collection-identifier-camelCase',
message:
"Collection identifiers must be in camelCase. Path segment 'API' in path '/API/Resource_groups/{userId}/User-profiles' is not in camelCase. http://go/ipa/102",
"Collection identifiers must be in camelCase. Path segment 'API' in path '/API/Resource_groups/{userId}/User-profiles' is not in camelCase. http://go/ipa-spectral#IPA-102",
path: ['paths', '/API/Resource_groups/{userId}/User-profiles'],
severity: DiagnosticSeverity.Warning,
},
{
code: 'xgen-IPA-102-collection-identifier-camelCase',
message:
"Collection identifiers must be in camelCase. Path segment 'Resource_groups' in path '/API/Resource_groups/{userId}/User-profiles' is not in camelCase. http://go/ipa/102",
"Collection identifiers must be in camelCase. Path segment 'Resource_groups' in path '/API/Resource_groups/{userId}/User-profiles' is not in camelCase. http://go/ipa-spectral#IPA-102",
path: ['paths', '/API/Resource_groups/{userId}/User-profiles'],
severity: DiagnosticSeverity.Warning,
},
{
code: 'xgen-IPA-102-collection-identifier-camelCase',
message:
"Collection identifiers must be in camelCase. Path segment 'User-profiles' in path '/API/Resource_groups/{userId}/User-profiles' is not in camelCase. http://go/ipa/102",
"Collection identifiers must be in camelCase. Path segment 'User-profiles' in path '/API/Resource_groups/{userId}/User-profiles' is not in camelCase. http://go/ipa-spectral#IPA-102",
path: ['paths', '/API/Resource_groups/{userId}/User-profiles'],
severity: DiagnosticSeverity.Warning,
},
Expand All @@ -217,14 +217,14 @@ testRule('xgen-IPA-102-collection-identifier-camelCase', [
{
code: 'xgen-IPA-102-collection-identifier-camelCase',
message:
"Collection identifiers must be in camelCase. Path segment 'Valid' in path '/api/Valid/Invalid_resource/{id}:validCustomMethod' is not in camelCase. http://go/ipa/102",
"Collection identifiers must be in camelCase. Path segment 'Valid' in path '/api/Valid/Invalid_resource/{id}:validCustomMethod' is not in camelCase. http://go/ipa-spectral#IPA-102",
path: ['paths', '/api/Valid/Invalid_resource/{id}:validCustomMethod'],
severity: DiagnosticSeverity.Warning,
},
{
code: 'xgen-IPA-102-collection-identifier-camelCase',
message:
"Collection identifiers must be in camelCase. Path segment 'Invalid_resource' in path '/api/Valid/Invalid_resource/{id}:validCustomMethod' is not in camelCase. http://go/ipa/102",
"Collection identifiers must be in camelCase. Path segment 'Invalid_resource' in path '/api/Valid/Invalid_resource/{id}:validCustomMethod' is not in camelCase. http://go/ipa-spectral#IPA-102",
path: ['paths', '/api/Valid/Invalid_resource/{id}:validCustomMethod'],
severity: DiagnosticSeverity.Warning,
},
Expand All @@ -241,14 +241,14 @@ testRule('xgen-IPA-102-collection-identifier-camelCase', [
{
code: 'xgen-IPA-102-collection-identifier-camelCase',
message:
"Collection identifiers must be in camelCase. Path '/api//Invalid_segment//resources' contains double slashes (//) which is not allowed. http://go/ipa/102",
"Collection identifiers must be in camelCase. Path '/api//Invalid_segment//resources' contains double slashes (//) which is not allowed. http://go/ipa-spectral#IPA-102",
path: ['paths', '/api//Invalid_segment//resources'],
severity: DiagnosticSeverity.Warning,
},
{
code: 'xgen-IPA-102-collection-identifier-camelCase',
message:
"Collection identifiers must be in camelCase. Path segment 'Invalid_segment' in path '/api//Invalid_segment//resources' is not in camelCase. http://go/ipa/102",
"Collection identifiers must be in camelCase. Path segment 'Invalid_segment' in path '/api//Invalid_segment//resources' is not in camelCase. http://go/ipa-spectral#IPA-102",
path: ['paths', '/api//Invalid_segment//resources'],
severity: DiagnosticSeverity.Warning,
},
Expand Down
26 changes: 15 additions & 11 deletions tools/spectral/ipa/rulesets/IPA-102.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,21 @@

rules:
xgen-IPA-102-collection-identifier-camelCase:
description: >-
Collection identifiers must be in camelCase. Logic includes:<br/>
- All path segments that are not path parameters<br/>
- Only the resource identifier part before any colon in custom method paths (e.g., `resource` in `/resource:customMethod`)<br/>
- Path parameters should also follow camelCase naming<br/>
- Certain values can be exempted via the ignoredValues configuration (e.g., 'v1', 'v2') that can be supplied as `ignoredValues`
argument to the rule<br/>
- Paths with `x-xgen-IPA-exception` for this rule are excluded from validation<br/>
- Double slashes (//) are not allowed in paths<br/>
http://go/ipa/102
message: '{{error}} http://go/ipa/102'
description: |
Collection identifiers must be in camelCase.

##### Implementation details
Rule checks for the following conditions:

- All path segments that are not path parameters
- Only the resource identifier part before any colon in custom method paths (e.g., `resource` in `/resource:customMethod`)
- Path parameters should also follow camelCase naming
- Certain values can be exempted via the ignoredValues configuration that can be supplied as `ignoredValues`
argument to the rule
- Paths with `x-xgen-IPA-exception` for this rule are excluded from validation
- Double slashes (//) are not allowed in paths

message: '{{error}} http://go/ipa-spectral#IPA-102'
severity: warn
given: $.paths
then:
Expand Down
Loading
Loading