-
-
Notifications
You must be signed in to change notification settings - Fork 240
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: teach rulesets to accept exceptions
- Loading branch information
Showing
30 changed files
with
923 additions
and
10 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import { RulesetExceptionCollection } from './src/types/ruleset'; | ||
|
||
export const buildRulesetExceptionCollectionFrom = ( | ||
loc: string, | ||
rules: string[] = ['a'], | ||
): RulesetExceptionCollection => { | ||
const source = {}; | ||
source[loc] = rules; | ||
return source; | ||
}; |
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
%YAML 1.2 | ||
--- | ||
openapi: 3.0.2 | ||
info: | ||
title: Random title | ||
description: Random description | ||
version: 0.0.1 | ||
contact: | ||
email: [email protected] | ||
paths: {} | ||
servers: | ||
- url: https://www.random.com | ||
components: | ||
schemas: | ||
TheRemoteType: | ||
description: A strongly typed string | ||
type: string |
34 changes: 34 additions & 0 deletions
34
src/__tests__/__fixtures__/exceptions.resolving.ruleset.json
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
{ | ||
"extends": [["spectral:oas", "off"]], | ||
"rules": { | ||
"no-yaml-remote-reference": { | ||
"formats": ["oas2", "oas3"], | ||
"message": "$ref must not point at yaml files", | ||
"given": "$..$ref", | ||
"recommended": true, | ||
"resolved": false, | ||
"then": { | ||
"function": "pattern", | ||
"functionOptions": { | ||
"notMatch": "\\.yaml(#.*)$" | ||
} | ||
} | ||
}, | ||
"strings-maxLength": { | ||
"formats": ["oas2", "oas3"], | ||
"message": "String typed properties MUST be further described using 'maxLength'. Error: {{error}}", | ||
"given": "$..*[?(@.type === 'string')]", | ||
"recommended": true, | ||
"then": { | ||
"field": "maxLength", | ||
"function": "truthy" | ||
} | ||
}, | ||
"oas3-schema": "error" | ||
}, | ||
"except": { | ||
"./exceptions.remote.oas3.yaml#/components/schemas/TheRemoteType": ["strings-maxLength"], | ||
"../foo.json#/components/schemas/TheLocalType/$ref": [ "no-yaml-remote-reference"], | ||
"another.yaml#": ["dummy-rule", "info-contact"] | ||
} | ||
} |
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Oops, something went wrong.