File tree Expand file tree Collapse file tree 3 files changed +15
-2
lines changed Expand file tree Collapse file tree 3 files changed +15
-2
lines changed Original file line number Diff line number Diff line change @@ -43,13 +43,15 @@ JSON Pointers have a different syntax than JSON Paths used in the `given` compon
43
43
In JSON Pointers, path components are prefixed with a `/` and then concatenated to form the pointer.
44
44
45
45
Since `/` has a special meaning in JSON pointer, it must be encoded as `~1` when it appears in a component, and `~` must be encoded as `~0`.
46
+ JSON Pointer must be percent-encoded for use within a URI as specified by the [spec](https://datatracker.ietf.org/doc/html/rfc6901#section-6)
46
47
47
48
You can test JSON Pointer expressions in the [JSON Query online evaluator](https://www.jsonquerytool.com/) by choosing "JSONPointer" as the Transform.
49
+ Bear in mind the tool above expects plain JSON Pointer, thus you need to decode any previously percent-encoded characters.
48
50
49
51
` ` ` yaml
50
52
overrides:
51
53
- files:
52
- - "legacy/**/*.oas.json#/paths/~1Pets~1{petId} /get/parameters/0"
54
+ - "legacy/**/*.oas.json#/paths/~1Pets~1%7BpetId%7D /get/parameters/0"
53
55
rules:
54
56
some-inherited-rule: "off"
55
57
` ` `
Original file line number Diff line number Diff line change @@ -1571,6 +1571,9 @@ responses:: !!foo
1571
1571
bar : {
1572
1572
type : 'number' ,
1573
1573
} ,
1574
+ bars : {
1575
+ type : 'number' ,
1576
+ } ,
1574
1577
} ) ,
1575
1578
Parsers . Json ,
1576
1579
documentUri ,
@@ -1583,6 +1586,11 @@ responses:: !!foo
1583
1586
path : [ 'bar' , 'type' ] ,
1584
1587
severity : DiagnosticSeverity . Hint ,
1585
1588
} ) ,
1589
+ expect . objectContaining ( {
1590
+ code : 'valid-type' ,
1591
+ path : [ 'bars' , 'type' ] ,
1592
+ severity : DiagnosticSeverity . Error ,
1593
+ } ) ,
1586
1594
] ) ;
1587
1595
} ) ;
1588
1596
} ) ;
Original file line number Diff line number Diff line change @@ -103,7 +103,10 @@ export class Rule implements IRule {
103
103
104
104
for ( const relevantOverride of relevantOverrides ) {
105
105
for ( const [ overridePath , overrideSeverity ] of relevantOverride . entries ( ) ) {
106
- if ( overridePath . length >= closestPointer . length && pointer . startsWith ( overridePath ) ) {
106
+ if (
107
+ overridePath . length >= closestPointer . length &&
108
+ ( pointer === overridePath || pointer . startsWith ( `${ overridePath } /` ) )
109
+ ) {
107
110
closestPointer = overridePath ;
108
111
severity = overrideSeverity ;
109
112
}
You can’t perform that action at this time.
0 commit comments