Skip to content

Commit 24b4b94

Browse files
committed
Updates to fix path-translator tests
1 parent b100515 commit 24b4b94

File tree

3 files changed

+9
-6
lines changed

3 files changed

+9
-6
lines changed

src/plugins/validation/path-translator.js

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,14 @@ export function transformPathToArray(property, jsSpec) {
88
}
99

1010
var pathArr = []
11-
var strArr = str.match(/(.*)\["(.*)"\]/) // split for paths with "."s in the keys
1211

13-
if ( strArr == null ) {
14-
strArr = str.split(".")
15-
}
12+
// replace '.', '["', '"]' separators with pipes
13+
str = str.replace(/\.(?![^["]*"\])|(\[\")|(\"\]\.?)/g, "|")
14+
15+
// split on our new delimiter, pipe
16+
str = str.split("|")
1617

17-
strArr
18+
str
1819
.map(item => {
1920
// "key[0]" becomes ["key", "0"]
2021
if(item.includes("[")) {

src/plugins/validation/structural-validation/validator.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ export function validate({ jsSpec, specStr, settings = {} }) {
1212
settings.schemas.forEach(schema => validator.addSchema(schema))
1313
return validator.validate(jsSpec, settings.testSchema || {})
1414
.errors.map(err => {
15+
console.log("validation error", err)
1516
return {
1617
level: "error",
1718
line: getLineNumberForPath(specStr, transformPathToArray(err.property, jsSpec) || []),

test/path-translator.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,8 @@ describe("validation plugin - path translator", function(){
7070
let jsSpec = {
7171
definitions: {
7272
"One.Two": {
73-
a: "1"
73+
a: "1",
74+
abc123: "1"
7475
}
7576
}
7677
}

0 commit comments

Comments
 (0)