Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add test for encoded refs and bump fast-uri #2449

Merged
merged 4 commits into from
Jul 7, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
test: add encoded ref test
  • Loading branch information
jasoniangreen committed Jun 12, 2024
commit 749499269ef077fd2363e372e1f27312c3804f96
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
Loading