Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
121 changes: 37 additions & 84 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,8 @@
"@types/stream-json": "^1.7.3",
"@types/urijs": "^1.19.26",
"@types/wordwrap": "^1.0.3",
"ajv": "^5.5.2",
"ajv": "^8.20.0",
"ajv-formats": "^3.0.1",
"deep-equal": "^2.2.3",
"esbuild": "^0.28.1",
"promise-timeout": "^1.3.0",
Expand Down
21 changes: 16 additions & 5 deletions test/fixtures.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ import { randomBytes } from "node:crypto";
import * as shell from "shelljs";

const Ajv = require("ajv");
const addFormats = require("ajv-formats");
const draft06MetaSchema = require("ajv/dist/refs/json-schema-draft-06.json");

import {
compareJsonFileToJson,
Expand Down Expand Up @@ -600,17 +602,26 @@ class JSONSchemaJSONFixture extends JSONToXToYFixture {
fs.readFileSync(this.language.output, "utf8"),
);

const ajv = new Ajv({
format: "full",
unknownFormats: ["integer", "boolean"],
});
const ajv = new Ajv();
// We generate draft-06 schemas, which Ajv 8 doesn't support out of
// the box anymore.
ajv.addMetaSchema(draft06MetaSchema);
// Ajv 8 moved the format validators into the ajv-formats package;
// its default mode is "full", like the old `format: "full"` option.
addFormats(ajv);
// Our custom schema keywords, which strict mode would reject.
ajv.addVocabulary(["qt-uri-protocols", "qt-uri-extensions"]);
// Make Ajv's date-time compatible with what we recognize. All non-standard
// JSON formats that we use for transformed type kinds must be registered here
// with a validation function.
// with a validation function. Formats registered with `true` are
// accepted without validating the string. This replaces the old
// `unknownFormats: ["integer", "boolean"]` option.
// FIXME: Unify this with what's in StringTypes.ts.
ajv.addFormat("date-time", (s: string) =>
dateTimeRecognizer.isDateTime(s),
);
ajv.addFormat("integer", true);
ajv.addFormat("boolean", true);
const valid = ajv.validate(schema, input);
if (!valid) {
failWith("Generated schema does not validate input JSON.", {
Expand Down
Loading