Skip to content

Commit

Permalink
test: add encoded ref test
Browse files Browse the repository at this point in the history
  • Loading branch information
jasoniangreen committed Jun 12, 2024
1 parent 80c014f commit 7494992
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 1 deletion.
1 change: 1 addition & 0 deletions lib/compile/codegen/code.ts
Original file line number Diff line number Diff line change
@@ -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
Expand Down
37 changes: 36 additions & 1 deletion spec/resolve.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ uriResolvers.forEach((resolver) => {
} else {
describeTitle = "fast-uri resolver"
}
describe(describeTitle, () => {
describe.only(describeTitle, () => {
describe("resolve", () => {
let instances: AjvCore[]

Expand Down Expand Up @@ -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<string,Person>": {
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)

Expand Down

0 comments on commit 7494992

Please sign in to comment.