Skip to content

Commit df9ce00

Browse files
committed
Correctly handle escape chars in OpenAPI JSON pointer refs
1 parent 8a8cf89 commit df9ce00

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/util/json-schema.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,10 @@ function derefRef(root: any, node: Ref) {
2424
let refTarget: any = root;
2525

2626
while (refParts.length) {
27-
const nextPart = refParts.shift() as any;
27+
const nextPart = refParts.shift()!
28+
// Handle JSON pointer escape chars:
29+
.replace(/~1/g, '/')
30+
.replace(/~0/g, '~');
2831
refTarget = refTarget[nextPart];
2932
if (!refTarget) {
3033
throw new Error(`Could not follow ref ${ref}, failed at ${nextPart}`);

0 commit comments

Comments
 (0)