From 749499269ef077fd2363e372e1f27312c3804f96 Mon Sep 17 00:00:00 2001 From: Jason Green Date: Wed, 12 Jun 2024 22:53:32 +0100 Subject: [PATCH 1/3] test: add encoded ref test --- lib/compile/codegen/code.ts | 1 + spec/resolve.spec.ts | 37 ++++++++++++++++++++++++++++++++++++- 2 files changed, 37 insertions(+), 1 deletion(-) diff --git a/lib/compile/codegen/code.ts b/lib/compile/codegen/code.ts index b17701973e..9d4de6149f 100644 --- a/lib/compile/codegen/code.ts +++ b/lib/compile/codegen/code.ts @@ -1,3 +1,4 @@ +// eslint-disable-next-line @typescript-eslint/no-extraneous-class export abstract class _CodeOrName { abstract readonly str: string abstract readonly names: UsedNames diff --git a/spec/resolve.spec.ts b/spec/resolve.spec.ts index a89cccaf72..35a5a0ad2e 100644 --- a/spec/resolve.spec.ts +++ b/spec/resolve.spec.ts @@ -16,7 +16,7 @@ uriResolvers.forEach((resolver) => { } else { describeTitle = "fast-uri resolver" } - describe(describeTitle, () => { + describe.only(describeTitle, () => { describe("resolve", () => { let instances: AjvCore[] @@ -180,6 +180,41 @@ uriResolvers.forEach((resolver) => { }) }) + describe("URIs with encoded characters (issue #2447)", () => { + it("should resolve the ref", () => { + const schema = { + $ref: "#/definitions/Record%3Cstring%2CPerson%3E", + $schema: "http://json-schema.org/draft-07/schema#", + definitions: { + Person: { + type: "object", + properties: { + firstName: { + type: "string", + description: "The person's first name.", + }, + }, + }, + "Record": { + type: "object", + additionalProperties: { + $ref: "#/definitions/Person", + }, + }, + }, + } + const data = { + joe: { + firstName: "Joe", + }, + } + instances.forEach((ajv) => { + const validate = ajv.compile(schema) + validate(data).should.equal(true) + }) + }) + }) + describe("missing schema error", function () { this.timeout(4000) From cb1a649bc0ad3834eaec384464d5464c6a5650b6 Mon Sep 17 00:00:00 2001 From: Jason Green Date: Sun, 30 Jun 2024 23:04:47 +0100 Subject: [PATCH 2/3] bump fast-uri --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 5198552a1c..88effa2e87 100644 --- a/package.json +++ b/package.json @@ -59,7 +59,7 @@ "runkitExampleFilename": ".runkit_example.js", "dependencies": { "fast-deep-equal": "^3.1.3", - "fast-uri": "^2.4.0", + "fast-uri": "^3.0.1", "json-schema-traverse": "^1.0.0", "require-from-string": "^2.0.2" }, From 16a6fc0d3b229a8273ef8408e2b33421d73d0e2d Mon Sep 17 00:00:00 2001 From: Jason Green Date: Sun, 30 Jun 2024 23:05:25 +0100 Subject: [PATCH 3/3] remove .only --- spec/resolve.spec.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/resolve.spec.ts b/spec/resolve.spec.ts index 35a5a0ad2e..032f99ff83 100644 --- a/spec/resolve.spec.ts +++ b/spec/resolve.spec.ts @@ -16,7 +16,7 @@ uriResolvers.forEach((resolver) => { } else { describeTitle = "fast-uri resolver" } - describe.only(describeTitle, () => { + describe(describeTitle, () => { describe("resolve", () => { let instances: AjvCore[]