From a18641ef4ceb9623ea7c437e6f4f98d44ac293aa Mon Sep 17 00:00:00 2001 From: Alex B <17498057+alexanderjsx@users.noreply.github.com> Date: Sun, 30 Jun 2024 22:59:42 +0100 Subject: [PATCH 1/5] Update modifying-data.md - fix broken strict-mode link (#2459) --- docs/guide/modifying-data.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/guide/modifying-data.md b/docs/guide/modifying-data.md index 2705c0bedf..5b1d893bd3 100644 --- a/docs/guide/modifying-data.md +++ b/docs/guide/modifying-data.md @@ -210,7 +210,7 @@ With `useDefaults` option `default` keywords throws exception during schema comp The strict mode option can change the behaviour for these unsupported defaults (`strict: false` to ignore them, `"log"` to log a warning). -See [Strict mode](./strict-mode.md). +See [Strict mode](../strict-mode.md). ::: tip Default with discriminator keyword Defaults will be assigned in schemas inside `oneOf` in case [discriminator](../json-schema.md#discriminator) keyword is used. From 595fe58e64e8d5fb8a50fd7a58f9e7f3bcca0bac Mon Sep 17 00:00:00 2001 From: Jason Ian Green Date: Sun, 7 Jul 2024 22:35:20 +0100 Subject: [PATCH 2/5] feat: add test for encoded refs and bump fast-uri (#2449) * test: add encoded ref test * bump fast-uri * remove .only --- package.json | 2 +- spec/resolve.spec.ts | 35 +++++++++++++++++++++++++++++++++++ 2 files changed, 36 insertions(+), 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" }, diff --git a/spec/resolve.spec.ts b/spec/resolve.spec.ts index a89cccaf72..032f99ff83 100644 --- a/spec/resolve.spec.ts +++ b/spec/resolve.spec.ts @@ -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 a523784388a79ce65e42caf4d2731da36a94b386 Mon Sep 17 00:00:00 2001 From: Jason Ian Green Date: Wed, 10 Jul 2024 08:55:28 +0100 Subject: [PATCH 3/5] fix: changes for @typescript-eslint/array-type rule (#2467) --- lib/types/json-schema.ts | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/lib/types/json-schema.ts b/lib/types/json-schema.ts index 281a38bdb0..065c972e54 100644 --- a/lib/types/json-schema.ts +++ b/lib/types/json-schema.ts @@ -108,25 +108,25 @@ type UncheckedJSONSchemaType = ( : UncheckedPropertiesSchema patternProperties?: Record> propertyNames?: Omit, "type"> & {type?: "string"} - dependencies?: {[K in keyof T]?: Readonly<(keyof T)[]> | UncheckedPartialSchema} - dependentRequired?: {[K in keyof T]?: Readonly<(keyof T)[]>} + dependencies?: {[K in keyof T]?: readonly (keyof T)[] | UncheckedPartialSchema} + dependentRequired?: {[K in keyof T]?: readonly (keyof T)[]} dependentSchemas?: {[K in keyof T]?: UncheckedPartialSchema} minProperties?: number maxProperties?: number } & (IsPartial extends true // "required" is not necessary if it's a non-partial type with no required keys // are listed it only asserts that optional cannot be listed. // "required" type does not guarantee that all required properties - ? {required: Readonly<(keyof T)[]>} + ? {required: readonly (keyof T)[]} : [UncheckedRequiredMembers] extends [never] - ? {required?: Readonly[]>} - : {required: Readonly[]>}) + ? {required?: readonly UncheckedRequiredMembers[]} + : {required: readonly UncheckedRequiredMembers[]}) : T extends null ? { type: JSONType<"null", IsPartial> nullable: true } : never) & { - allOf?: Readonly[]> - anyOf?: Readonly[]> - oneOf?: Readonly[]> + allOf?: readonly UncheckedPartialSchema[] + anyOf?: readonly UncheckedPartialSchema[] + oneOf?: readonly UncheckedPartialSchema[] if?: UncheckedPartialSchema then?: UncheckedPartialSchema else?: UncheckedPartialSchema @@ -176,12 +176,12 @@ type Nullable = undefined extends T ? { nullable: true const?: null // any non-null value would fail `const: null`, `null` would fail any other value in const - enum?: Readonly<(T | null)[]> // `null` must be explicitly included in "enum" for `null` to pass + enum?: readonly (T | null)[] // `null` must be explicitly included in "enum" for `null` to pass default?: T | null } : { nullable?: false const?: T - enum?: Readonly + enum?: readonly T[] default?: T } From f7831b41c3a27064c6219f51a1e7371ffb582dfe Mon Sep 17 00:00:00 2001 From: Jason Ian Green Date: Wed, 10 Jul 2024 08:56:10 +0100 Subject: [PATCH 4/5] fixes #2217 - clarify custom keyword naming (#2457) --- docs/api.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/api.md b/docs/api.md index 5dfb0c3090..2a06807309 100644 --- a/docs/api.md +++ b/docs/api.md @@ -251,7 +251,7 @@ Add validation keyword to Ajv instance. Keyword should be different from all standard JSON Schema keywords and different from previously defined keywords. There is no way to redefine keywords or to remove keyword definition from the instance. -Keyword must start with a letter, `_` or `$`, and may continue with letters, numbers, `_`, `$`, or `-`. +Keyword must start with an ASCII letter, `_` or `$`, and may continue with ASCII letters, numbers, `_`, `$`, `-`, or `:`. It is recommended to use an application-specific prefix for keywords to avoid current and future name collisions. Example Keywords: From 9050ba1359fb87cd7c143f3c79513ea7624ea443 Mon Sep 17 00:00:00 2001 From: Jason Ian Green Date: Thu, 11 Jul 2024 18:02:58 +0100 Subject: [PATCH 5/5] bump version to 8.17.1 (#2472) --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 88effa2e87..17df7b1473 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "ajv", - "version": "8.16.0", + "version": "8.17.1", "description": "Another JSON Schema Validator", "main": "dist/ajv.js", "types": "dist/ajv.d.ts",