Skip to content

Commit 595fe58

Browse files
feat: add test for encoded refs and bump fast-uri (#2449)
* test: add encoded ref test * bump fast-uri * remove .only
1 parent a18641e commit 595fe58

File tree

2 files changed

+36
-1
lines changed

2 files changed

+36
-1
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@
5959
"runkitExampleFilename": ".runkit_example.js",
6060
"dependencies": {
6161
"fast-deep-equal": "^3.1.3",
62-
"fast-uri": "^2.4.0",
62+
"fast-uri": "^3.0.1",
6363
"json-schema-traverse": "^1.0.0",
6464
"require-from-string": "^2.0.2"
6565
},

spec/resolve.spec.ts

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,41 @@ uriResolvers.forEach((resolver) => {
180180
})
181181
})
182182

183+
describe("URIs with encoded characters (issue #2447)", () => {
184+
it("should resolve the ref", () => {
185+
const schema = {
186+
$ref: "#/definitions/Record%3Cstring%2CPerson%3E",
187+
$schema: "http://json-schema.org/draft-07/schema#",
188+
definitions: {
189+
Person: {
190+
type: "object",
191+
properties: {
192+
firstName: {
193+
type: "string",
194+
description: "The person's first name.",
195+
},
196+
},
197+
},
198+
"Record<string,Person>": {
199+
type: "object",
200+
additionalProperties: {
201+
$ref: "#/definitions/Person",
202+
},
203+
},
204+
},
205+
}
206+
const data = {
207+
joe: {
208+
firstName: "Joe",
209+
},
210+
}
211+
instances.forEach((ajv) => {
212+
const validate = ajv.compile(schema)
213+
validate(data).should.equal(true)
214+
})
215+
})
216+
})
217+
183218
describe("missing schema error", function () {
184219
this.timeout(4000)
185220

0 commit comments

Comments
 (0)