├── .gitignore ├── .gitmodules ├── .src ├── README.md ├── build.ts ├── checksums.json ├── draft │ ├── 07 │ │ └── definition.ts │ ├── 2019_09 │ │ └── definition.ts │ └── 2020_12 │ │ └── definition.ts ├── file_templates │ ├── LICENSE.template.md │ ├── README.deno.template.md │ └── README.node.template.md ├── mod.test.ts ├── mod_template.ts ├── spec.ts ├── types.ts ├── utils │ ├── assert_definition_is_sorted.ts │ ├── checksum.ts │ ├── format_definition_descriptions.ts │ ├── format_markdown.test.ts │ ├── format_markdown.ts │ └── source_code.ts └── version.ts ├── .vscode ├── extensions.json └── settings.json ├── LICENSE.md ├── README.md ├── cspell.json ├── deno.jsonc ├── dist ├── deno │ ├── LICENSE.md │ ├── README.md │ ├── draft_07.ts │ ├── draft_2019_09.ts │ ├── draft_2020_12.ts │ ├── draft_latest.ts │ └── version.ts ├── node │ ├── LICENSE.md │ ├── README.md │ ├── draft-07.js │ ├── draft-07.js.map │ ├── draft-07.ts │ ├── draft-2019-09.js │ ├── draft-2019-09.js.map │ ├── draft-2019-09.ts │ ├── draft-2020-12.js │ ├── draft-2020-12.js.map │ ├── draft-2020-12.ts │ └── package.json └── spec_definitions │ ├── LICENSE.md │ ├── README.md │ ├── draft_07.json │ ├── draft_2019_09.json │ └── draft_2020_12.json └── import_map.json /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | /node_modules/ 3 | /.src/release_notes.md -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule ".src/draft/07/spec"] 2 | path = .src/draft/07/spec 3 | url = git@github.com:json-schema-org/json-schema-spec.git 4 | branch = draft-07 5 | [submodule ".src/draft/2019_09/spec"] 6 | path = .src/draft/2019_09/spec 7 | url = git@github.com:json-schema-org/json-schema-spec.git 8 | branch = 2019-09 9 | [submodule ".src/draft/2020_12/spec"] 10 | path = .src/draft/2020_12/spec 11 | url = git@github.com:json-schema-org/json-schema-spec.git 12 | branch = 2020-12 13 | [submodule ".src/draft/next/spec"] 14 | path = .src/draft/next/spec 15 | url = git@github.com:json-schema-org/json-schema-spec.git 16 | branch = draft-next 17 | -------------------------------------------------------------------------------- /.src/README.md: -------------------------------------------------------------------------------- 1 | # ⚠️⚠️⚠️ WARNING ⚠️⚠️⚠️ 2 | 3 | The entire contents of the `.src` directory are unstable and could change at any 4 | moment. 5 | 6 | ## Preparing a new release 7 | 8 | - Manually bump the version number in `.src/version.ts`. 9 | - Run the build script, the new version will be included in the output. 10 | 11 | ## Building 12 | 13 | ```sh 14 | deno run -A --import-map=import_map.json --unstable ./.src/build.ts 15 | ``` 16 | 17 | By default, the build script will skip building drafts that have no 18 | modifications to their `definition.ts` file. If you need to force a rebuild, add 19 | `--force` onto the end of the build command: 20 | 21 | ```sh 22 | deno run -A --import-map=import_map.json --unstable ./.src/build.ts --force 23 | ``` 24 | 25 | ## Adding a new draft 26 | 27 | - Add the spec branch as a submodule: 28 | 29 | ```sh 30 | git submodule add -b 2020-12 git@github.com:json-schema-org/json-schema-spec.git ./.src/draft/2020_12/spec 31 | ``` 32 | -------------------------------------------------------------------------------- /.src/build.ts: -------------------------------------------------------------------------------- 1 | import * as fs from "std/fs/mod.ts"; 2 | import * as path from "std/path/mod.ts"; 3 | import type * as types from "./types.ts"; 4 | import { expandSourcePlaceholders } from "./utils/source_code.ts"; 5 | import { formatMarkdown } from "./utils/format_markdown.ts"; 6 | import { formatDefinitionDescriptions } from "./utils/format_definition_descriptions.ts"; 7 | import { fileChecksum } from "./utils/checksum.ts"; 8 | import checksums from "./checksums.json" assert { type: "json" }; 9 | import { VERSION } from "./version.ts"; 10 | import packageJson from "../dist/node/package.json" assert { type: "json" }; 11 | 12 | // ----------------------------------------------------------------------------- 13 | 14 | const FORCE_REFRESH = Deno.args.includes("--force"); 15 | const CWD = Deno.cwd(); 16 | const SRC_DIR = path.join(CWD, ".src"); 17 | const FILE_TEMPLATES_DIR = path.join(SRC_DIR, "file_templates"); 18 | const DIST_DIR = path.join(CWD, "dist"); 19 | const DENO_DIR = path.join(DIST_DIR, "deno"); 20 | const NODE_DIR = path.join(DIST_DIR, "node"); 21 | const SPEC_DEFS_DIR = path.join(DIST_DIR, "spec_definitions"); 22 | const ALL_DIST_DIRS = [DENO_DIR, SPEC_DEFS_DIR, NODE_DIR]; 23 | 24 | // ----------------------------------------------------------------------------- 25 | 26 | const licenseCopyrights: Array< 27 | { draft: string; year: number; credits: string[] } 28 | > = []; 29 | 30 | const modTemplateFilename = path.join(SRC_DIR, `mod_template.ts`); 31 | const modTemplateCode = await Deno.readTextFile(modTemplateFilename); 32 | 33 | // ----------------------------------------------------------------------------- 34 | 35 | // Collect all drafts 36 | 37 | export const drafts: string[] = []; 38 | 39 | for await ( 40 | const entry of fs.expandGlob("./.src/draft/*/definition.ts") 41 | ) { 42 | const draftId = path.basename(path.dirname(entry.path)); 43 | drafts.push(draftId); 44 | } 45 | 46 | drafts.sort((a, b) => a.localeCompare(b)); 47 | 48 | // ----------------------------------------------------------------------------- 49 | 50 | // Process each draft 51 | 52 | for (const draftId of drafts) { 53 | const nodeDraftId = draftId.replaceAll("_", "-"); 54 | const draftDir = path.join(SRC_DIR, "draft", draftId); 55 | const draftDefFilename = path.join(draftDir, "definition.ts"); 56 | const draftDefChecksum = await fileChecksum(draftDefFilename); 57 | const draftDefRelativeFilename = path.relative(CWD, draftDefFilename).split( 58 | path.sep, 59 | ).join("/"); 60 | 61 | const rawDraftSpec = (await import(draftDefFilename)) 62 | .default as types.ValidationSpecDefinition; 63 | 64 | licenseCopyrights.push({ 65 | ...rawDraftSpec.$copyright, 66 | draft: rawDraftSpec.$draft, 67 | }); 68 | 69 | // Skip processing if the draft definition hasn't been updated 70 | if ( 71 | // @ts-expect-error checksums.json is a plain record 72 | draftDefChecksum === checksums[draftDefRelativeFilename] && 73 | FORCE_REFRESH === false 74 | ) { 75 | console.log(`Skipping draft-${draftId}: no changes`); 76 | continue; 77 | } 78 | 79 | // Update the draft definition checksum 80 | // @ts-expect-error this is valid 81 | checksums[draftDefRelativeFilename] = draftDefChecksum; 82 | 83 | const draftSpec = await formatDefinitionDescriptions(rawDraftSpec, { 84 | lineWidth: 75, 85 | }); 86 | 87 | draftSpec.$license = (await formatMarkdown(draftSpec.$license, { 88 | lineWidth: 76, 89 | })).trim(); 90 | 91 | { 92 | const jsonDef = await formatDefinitionDescriptions(rawDraftSpec, { 93 | lineWidth: 100_000, 94 | }); 95 | 96 | await Deno.writeTextFile( 97 | path.join(SPEC_DEFS_DIR, `draft_${draftId}.json`), 98 | JSON.stringify(jsonDef, undefined, 2), 99 | ); 100 | } 101 | 102 | const modCode = expandSourcePlaceholders( 103 | modTemplateFilename, 104 | modTemplateCode, 105 | draftSpec as unknown as types.ValidationSpecDefinition, 106 | ); 107 | 108 | const outputFilename = path.join(NODE_DIR, `draft-${nodeDraftId}.ts`); 109 | await Deno.writeTextFile( 110 | outputFilename, 111 | [ 112 | "// @generated", 113 | "// This code is automatically generated. Manual editing is not recommended.", 114 | "", 115 | modCode, 116 | ].join("\n"), 117 | ); 118 | await Deno.run({ cmd: ["deno", "fmt", "--quiet", outputFilename] }).status(); 119 | 120 | // Copy to the deno directory 121 | await fs.copy( 122 | outputFilename, 123 | path.join(DENO_DIR, `draft_${draftId}.ts`), 124 | { overwrite: true }, 125 | ); 126 | 127 | // ------------------------------------------------------------------------- 128 | // Compile to JS 129 | // ------------------------------------------------------------------------- 130 | const { files } = await Deno.emit(outputFilename, { 131 | bundle: "module", 132 | compilerOptions: { target: "es6" }, 133 | }); 134 | 135 | const js = files["deno:///bundle.js"]; 136 | const map = files["deno:///bundle.js.map"]; 137 | 138 | // Write to the node directory 139 | const mapJson = JSON.parse(map) as { sources: string[] }; 140 | mapJson.sources = mapJson.sources.map((source) => path.basename(source)); 141 | 142 | await Deno.writeTextFile( 143 | path.join(NODE_DIR, `draft-${nodeDraftId}.js`), 144 | [ 145 | `/// `, 146 | "// @generated", 147 | js, 148 | `//# sourceMappingURL=draft-${nodeDraftId}.js.map`, 149 | ].join("\n"), 150 | ); 151 | 152 | await Deno.writeTextFile( 153 | path.join(NODE_DIR, `draft-${nodeDraftId}.js.map`), 154 | JSON.stringify(mapJson), 155 | ); 156 | 157 | console.log(`draft_${draftId}: complete`); 158 | } 159 | 160 | // ----------------------------------------------------------------------------- 161 | // Update checksums.json 162 | // ----------------------------------------------------------------------------- 163 | await Deno.writeTextFile( 164 | path.join(SRC_DIR, "checksums.json"), 165 | JSON.stringify( 166 | Object.fromEntries( 167 | Object.entries(checksums).sort(([aKey], [bKey]) => 168 | aKey.localeCompare(bKey) 169 | ), 170 | ), 171 | undefined, 172 | 2, 173 | ), 174 | ); 175 | 176 | // ----------------------------------------------------------------------------- 177 | // Latest draft 178 | // ----------------------------------------------------------------------------- 179 | 180 | const latestDraft = [...drafts].filter((draftId) => { 181 | return Number.isInteger(parseInt(draftId.split("-")[0], 10)); 182 | }).pop(); 183 | 184 | if (latestDraft === undefined) { 185 | throw new Error("TODO"); 186 | } 187 | 188 | const nodeLatestDraft = latestDraft.replaceAll("_", "-"); 189 | 190 | await Deno.writeTextFile( 191 | path.join(DENO_DIR, "draft_latest.ts"), 192 | `export * from "./draft_${latestDraft}.ts";`, 193 | ); 194 | 195 | // ----------------------------------------------------------------------------- 196 | // Update README files 197 | // ----------------------------------------------------------------------------- 198 | 199 | const readmeFilenames: Array<{ template: string; output: string }> = [ 200 | { 201 | template: path.join(FILE_TEMPLATES_DIR, "README.deno.template.md"), 202 | output: path.join(DENO_DIR, "README.md"), 203 | }, 204 | { 205 | template: path.join(FILE_TEMPLATES_DIR, "README.node.template.md"), 206 | output: path.join(NODE_DIR, "README.md"), 207 | }, 208 | ]; 209 | 210 | for (const readmeFilename of readmeFilenames) { 211 | const templateSource = await Deno.readTextFile(readmeFilename.template); 212 | await Deno.writeTextFile( 213 | readmeFilename.output, 214 | templateSource 215 | .replaceAll("{DRAFT_TOTAL}", drafts.length.toLocaleString("en")) 216 | .replaceAll("{NODE_LATEST_DRAFT}", latestDraft.replaceAll("_", "-")) 217 | .replace("{NODE_DRAFT_LIST}", () => { 218 | return drafts.map((draft) => `\`draft-${draft.replaceAll("_", "-")}\``) 219 | .join("\n- "); 220 | }) 221 | .replace("{DENO_DRAFT_LIST}", () => { 222 | return drafts.map((draft) => `\`draft_${draft}.ts\``) 223 | .join("\n - "); 224 | }) 225 | .replaceAll("{LATEST_DRAFT}", latestDraft), 226 | ); 227 | const p = Deno.run({ 228 | cmd: ["deno", "fmt", "--quiet", readmeFilename.output], 229 | }); 230 | await p.status(); 231 | p.close(); 232 | } 233 | 234 | // ----------------------------------------------------------------------------- 235 | // Update LICENSE files 236 | // ----------------------------------------------------------------------------- 237 | 238 | const licenseFilename = path.join(CWD, "LICENSE.md"); 239 | 240 | await Deno.writeTextFile( 241 | licenseFilename, 242 | await formatMarkdown( 243 | (await Deno.readTextFile( 244 | path.join(FILE_TEMPLATES_DIR, "LICENSE.template.md"), 245 | )) 246 | .replace("{YEAR}", new Date().getFullYear().toString()) 247 | .replace( 248 | "{COPYRIGHT}", 249 | licenseCopyrights.sort((a, b) => { 250 | if (a.year !== b.year) { 251 | return a.year - b.year; 252 | } 253 | return a.draft.localeCompare(b.draft); 254 | }).map( 255 | ({ draft, year, credits }) => { 256 | const initialCredits = credits.slice(0, -1); 257 | const lastCredit = credits.slice(-1); 258 | 259 | return `${year} [draft-${draft}] ${ 260 | initialCredits.join(", ") 261 | }, and ${lastCredit}.`; 262 | }, 263 | ).join("\n\n"), 264 | ), 265 | ), 266 | ); 267 | 268 | for (const dir of ALL_DIST_DIRS) { 269 | await fs.copy(licenseFilename, path.join(dir, "LICENSE.md"), { 270 | overwrite: true, 271 | }); 272 | } 273 | 274 | // ----------------------------------------------------------------------------- 275 | // Update json-schema-typed package.json 276 | // ----------------------------------------------------------------------------- 277 | { 278 | packageJson.version = VERSION; 279 | packageJson.main = `./draft-${nodeLatestDraft}.js`; 280 | // @ts-expect-error this is valid 281 | packageJson.exports = { 282 | ".": `./draft-${nodeLatestDraft}.js`, 283 | ...Object.fromEntries( 284 | drafts.map(( 285 | draftId, 286 | ) => { 287 | const nodeDraftId = draftId.replaceAll("_", "-"); 288 | return [`./draft-${nodeDraftId}`, `./draft-${nodeDraftId}.js`]; 289 | }), 290 | ), 291 | }; 292 | 293 | await Deno.writeTextFile( 294 | path.join(NODE_DIR, "package.json"), 295 | JSON.stringify(packageJson, undefined, 2) + "\n", 296 | ); 297 | } 298 | 299 | // ----------------------------------------------------------------------------- 300 | // Update deno version.ts 301 | // ----------------------------------------------------------------------------- 302 | { 303 | await Deno.writeTextFile( 304 | path.join(DENO_DIR, "version.ts"), 305 | `export const VERSION = "${VERSION}";`, 306 | ); 307 | } 308 | -------------------------------------------------------------------------------- /.src/checksums.json: -------------------------------------------------------------------------------- 1 | { 2 | ".src/draft/07/definition.ts": "f9abbf1e963facbffd302160ba076127", 3 | ".src/draft/2019_09/definition.ts": "63ddc37ac2fcf4b2220fab9b3a231584", 4 | ".src/draft/2020_12/definition.ts": "fd800676a7d588f15154e6fe120a04f2" 5 | } -------------------------------------------------------------------------------- /.src/file_templates/LICENSE.template.md: -------------------------------------------------------------------------------- 1 | BSD 2-Clause License 2 | 3 | Original source code is copyright (c) 2019-{YEAR} Jeremy Rylan 4 | 5 | 6 | All JSON Schema documentation and descriptions are copyright (c): 7 | 8 | 2009 [draft-0] IETF Trust , Kris Zyp , 9 | and SitePen (USA) . 10 | 11 | 2009 [draft-1] IETF Trust , Kris Zyp , 12 | and SitePen (USA) . 13 | 14 | 2010 [draft-2] IETF Trust , Kris Zyp , 15 | and SitePen (USA) . 16 | 17 | 2010 [draft-3] IETF Trust , Kris Zyp , 18 | Gary Court , and SitePen (USA) . 19 | 20 | 2013 [draft-4] IETF Trust ), Francis Galiegue 21 | , Kris Zyp , Gary Court 22 | , and SitePen (USA) . 23 | 24 | {COPYRIGHT} 25 | 26 | All rights reserved. 27 | 28 | Redistribution and use in source and binary forms, with or without modification, 29 | are permitted provided that the following conditions are met: 30 | 31 | 1. Redistributions of source code must retain the above copyright notice, this 32 | list of conditions and the following disclaimer. 33 | 34 | 2. Redistributions in binary form must reproduce the above copyright notice, 35 | this list of conditions and the following disclaimer in the documentation 36 | and/or other materials provided with the distribution. 37 | 38 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 39 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 40 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 41 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 42 | ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 43 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 44 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 45 | ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 46 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 47 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 48 | -------------------------------------------------------------------------------- /.src/file_templates/README.deno.template.md: -------------------------------------------------------------------------------- 1 | # JSON Schema Typed 2 | 3 | JSON Schema TypeScript definitions with complete inline documentation. 4 | 5 | **NOTE:** This library only supports defining schemas. You will need a separate 6 | library for data validation. 7 | 8 | ## Usage 9 | 10 | 1. Chose which JSON Schema draft you'd like to import: 11 | 12 | - {DENO_DRAFT_LIST} 13 | - `draft_latest.ts` - this always re-exports the latest supported stable 14 | draft, currently `draft_{LATEST_DRAFT}.ts`. Future releases that re-export 15 | a new draft will always incur a bump to the major semantic version. 16 | 17 | 2. Define a schema 18 | 19 | ```ts 20 | import { 21 | Format, 22 | type JSONSchema, 23 | } from "https://deno.land/x/json_schema_typed/draft_latest.ts"; 24 | 25 | const schema: JSONSchema = { 26 | properties: { 27 | email: { 28 | format: Format.Email, 29 | type: "string", 30 | }, 31 | }, 32 | type: "object", 33 | }; 34 | 35 | // The JSONSchema namespace also provides type-specific narrowed interfaces 36 | const stringSchema: JSONSchema.String = { 37 | // Only { type: "string" } and common keywords are allowed 38 | maxLength: 100, 39 | type: "string", 40 | }; 41 | ``` 42 | 43 | ## Exports supported in each draft module 44 | 45 | | Name | Type | Purpose | 46 | | ----------------- | --------------- | ------------------------------------------------------------------ | 47 | | `$schema` | `string` | Draft meta schema URL that can be used with the `$schema` keyword. | 48 | | `ContentEncoding` | Enum object | String content encoding strategies. | 49 | | `draft` | `string` | Draft version. | 50 | | `Format` | Enum object | String formats. | 51 | | `JSONSchema` | TypeScript Type | Used to define a JSON Schema. | 52 | | `keywords` | `string[]` | All the keywords for the imported draft. | 53 | | `TypeName` | Enum object | Simple type names for the `type` keyword. | 54 | 55 | ## Versioning 56 | 57 | This library follows [semantic versioning](https://semver.org). 58 | 59 | --- 60 | 61 | ## Maintainers 62 | 63 | - [Jeremy Rylan](https://github.com/jrylan) 64 | 65 | ## License 66 | 67 | [BSD-2-Clause](https://github.com/jrylan/json-schema-typed/blob/main/dist/deno/LICENSE.md) 68 | -------------------------------------------------------------------------------- /.src/file_templates/README.node.template.md: -------------------------------------------------------------------------------- 1 | [![npm](https://img.shields.io/npm/v/json-schema-typed.svg?style=flat-square)](https://npmjs.org/package/json-schema-typed) 2 | [![downloads-per-month](https://img.shields.io/npm/dm/json-schema-typed.svg?style=flat-square&label=npm%20downloads)](https://npmjs.org/package/json-schema-typed) 3 | [![License](https://img.shields.io/badge/license-BSD--2--Clause-blue.svg?style=flat-square)][license] 4 | 5 | # JSON Schema Typed 6 | 7 | JSON Schema TypeScript definitions with complete inline documentation. 8 | 9 | **NOTE:** This library only supports defining schemas. You will need a separate 10 | library for data validation. 11 | 12 | There are {DRAFT_TOTAL} JSON Schema drafts included in this package: 13 | 14 | - {NODE_DRAFT_LIST} 15 | 16 | ## Install 17 | 18 | ```sh 19 | npm install json-schema-typed 20 | ``` 21 | 22 | ## Usage 23 | 24 | 1. Chose which draft you'd like to import. 25 | 26 | - The main package export points to the latest supported stable draft, currently 27 | `draft-{NODE_LATEST_DRAFT}`. Future releases that point the main package 28 | export to a new draft will always incur a bump to the major semantic version. 29 | 30 | ```ts 31 | import { type JSONSchema } from "json-schema-typed"; 32 | ``` 33 | 34 | - Or you can specify the exact draft you need. 35 | ```ts 36 | import { type JSONSchema } from "json-schema-typed/draft-{NODE_LATEST_DRAFT}"; 37 | ``` 38 | 39 | 2. Define a schema 40 | 41 | ```ts 42 | import { Format, type JSONSchema } from "json-schema-typed"; 43 | 44 | const schema: JSONSchema = { 45 | properties: { 46 | email: { 47 | format: Format.Email, 48 | type: "string", 49 | }, 50 | }, 51 | type: "object", 52 | }; 53 | 54 | // The JSONSchema namespace also provides type-specific narrowed interfaces 55 | const stringSchema: JSONSchema.String = { 56 | // Only { type: "string" } and common keywords are allowed 57 | maxLength: 100, 58 | type: "string", 59 | }; 60 | ``` 61 | 62 | ## Upgrading 63 | 64 | Version `8.0.0` has breaking changes from the previous release. 65 | 66 | - Now a 67 | [pure ESM package](https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c). 68 | - Many exports were renamed. The table below reflects the new export names. 69 | These are considered final and unlikely to change in future releases. 70 | - The `JSONSchema` type was changed from an `interface` to a `type` which is a 71 | mixed union that allows `boolean` values in order to properly align with the 72 | JSON Schema spec. If you were previously extending the `JSONSchema` interface, 73 | you can access the `interface` directly with `JSONSchema.Interface`. 74 | - The previous main package export pointed to Draft 7. Import it directly if you 75 | need to continue using it: 76 | ```ts 77 | import { type JSONSchema } from "json-schema-typed/draft-07"; 78 | ``` 79 | 80 | ## Exports supported in each draft module 81 | 82 | | Name | Type | Purpose | 83 | | ----------------- | --------------- | ------------------------------------------------------------------ | 84 | | `$schema` | `string` | Draft meta schema URL that can be used with the `$schema` keyword. | 85 | | `ContentEncoding` | Enum object | String content encoding strategies. | 86 | | `draft` | `string` | Draft version. | 87 | | `Format` | Enum object | String formats. | 88 | | `JSONSchema` | TypeScript Type | Used to define a JSON Schema. | 89 | | `keywords` | `string[]` | All the keywords for the imported draft. | 90 | | `TypeName` | Enum object | Simple type names for the `type` keyword. | 91 | 92 | ## Versioning 93 | 94 | This library follows [semantic versioning](https://semver.org). 95 | 96 | --- 97 | 98 | ## Maintainers 99 | 100 | - [Jeremy Rylan](https://github.com/jrylan) 101 | 102 | ## License 103 | 104 | [BSD-2-Clause][license] 105 | 106 | [license]: https://github.com/jrylan/json-schema-typed/blob/main/dist/node/LICENSE.md 107 | -------------------------------------------------------------------------------- /.src/mod.test.ts: -------------------------------------------------------------------------------- 1 | import { 2 | ContentEncoding, 3 | type JSONSchema, 4 | TypeName, 5 | } from "../dist/deno/draft_2019_09.ts"; 6 | 7 | export const schema1: JSONSchema.Array = { 8 | type: "array", 9 | }; 10 | 11 | export const schema2: JSONSchema = true; 12 | 13 | export const schema3: JSONSchema = { 14 | contentEncoding: ContentEncoding.Base64, 15 | type: "string", 16 | }; 17 | 18 | export const schema4: JSONSchema.String = { 19 | type: "string", 20 | }; 21 | 22 | export const schema5: JSONSchema = { 23 | oneOf: [{ 24 | type: "object", 25 | properties: { 26 | hello: { type: "number" }, 27 | }, 28 | required: ["hello"], 29 | }, { 30 | type: "object", 31 | properties: { 32 | hello2: { type: "string" }, 33 | }, 34 | required: ["hello2"], 35 | }], 36 | definitions: { 37 | foo: { 38 | type: "boolean", 39 | }, 40 | yup: { 41 | if: true, 42 | then: { enum: [5, 7, 9] }, 43 | else: { const: 6 }, 44 | }, 45 | }, 46 | properties: { 47 | foobar: { 48 | enum: ["test", "what"], 49 | }, 50 | foobar2: { 51 | const: "yo", 52 | }, 53 | num: { 54 | maximum: 5, 55 | minimum: 2, 56 | }, 57 | enabled: { 58 | $ref: "#/definitions/foo", 59 | }, 60 | test: { 61 | type: "object", 62 | properties: { 63 | what: { type: "string" }, 64 | yo: { enum: ["foo", "bar"] }, 65 | foo: { 66 | $ref: "#/definitions/foo", 67 | }, 68 | }, 69 | required: ["yo"], 70 | }, 71 | what: { 72 | $ref: "#/definitions/yup", 73 | }, 74 | testing: { 75 | type: [TypeName.String, TypeName.Number], 76 | }, 77 | }, 78 | required: ["num"], 79 | }; 80 | -------------------------------------------------------------------------------- /.src/mod_template.ts: -------------------------------------------------------------------------------- 1 | // deno-fmt-ignore-file 2 | // deno-lint-ignore-file 3 | 4 | // __BEGIN__ 5 | // __PLACEHOLDER:LICENSE__ 6 | 7 | export const draft = "__PLACEHOLDER:DRAFT__" as const; 8 | export const $schema = "__PLACEHOLDER:SCHEMA_URL__" as const; 9 | 10 | type MaybeReadonlyArray = Array | ReadonlyArray; 11 | type ValueOf = T[keyof T]; 12 | 13 | /** 14 | * JSON Schema [Draft __PLACEHOLDER:DRAFT__](__PLACEHOLDER:DOCS_URL__) 15 | */ 16 | export type JSONSchema< 17 | Value = any, 18 | SchemaType = Value extends boolean ? "boolean" 19 | : Value extends null ? "null" 20 | : Value extends number ? "number" | "integer" 21 | : Value extends string ? "string" 22 | : Value extends unknown[] ? "array" 23 | : Value extends Record ? "object" 24 | : JSONSchema.TypeValue, 25 | > = boolean | { 26 | __PLACEHOLDER__: true; // KEYWORDS_INTERFACE 27 | }; 28 | 29 | // ----------------------------------------------------------------------------- 30 | 31 | export namespace JSONSchema { 32 | export type TypeValue = ( 33 | // @ts-expect-error 34 | | ValueOf 35 | // @ts-expect-error 36 | | TypeName 37 | // @ts-expect-error 38 | | Array | TypeName> 39 | // @ts-expect-error 40 | | ReadonlyArray | TypeName> 41 | ); 42 | 43 | /** 44 | * JSON Schema interface 45 | */ 46 | export type Interface< 47 | Value = any, 48 | SchemaType extends TypeValue = 49 | TypeValue, 50 | > = Exclude< 51 | JSONSchema, 52 | boolean 53 | >; 54 | 55 | export type Array = Pick< 56 | Interface, 57 | // @ts-expect-error 58 | KeywordByType.Any | KeywordByType.Array 59 | >; 60 | 61 | export type Boolean = Pick< 62 | Interface, 63 | // @ts-expect-error 64 | KeywordByType.Any 65 | >; 66 | 67 | export type Integer = Pick< 68 | Interface, 69 | // @ts-expect-error 70 | KeywordByType.Any | KeywordByType.Number 71 | >; 72 | 73 | export type Number = Pick< 74 | Interface, 75 | // @ts-expect-error 76 | KeywordByType.Any | KeywordByType.Number 77 | >; 78 | 79 | export type Null = Pick< 80 | Interface, 81 | // @ts-expect-error 82 | KeywordByType.Any 83 | >; 84 | 85 | export type Object = Pick< 86 | Interface, 87 | // @ts-expect-error 88 | KeywordByType.Any | KeywordByType.Object 89 | >; 90 | 91 | export type String = Pick< 92 | Interface, 93 | // @ts-expect-error 94 | KeywordByType.Any | KeywordByType.String 95 | >; 96 | } 97 | 98 | namespace KeywordByType { 99 | // __PLACEHOLDER:KEYWORD_TYPES__ 100 | } 101 | 102 | // ----------------------------------------------------------------------------- 103 | 104 | // __PLACEHOLDER:ENUMS__ 105 | 106 | // ----------------------------------------------------------------------------- 107 | // Keywords 108 | // ----------------------------------------------------------------------------- 109 | 110 | // __PLACEHOLDER:KEYWORDS__ 111 | -------------------------------------------------------------------------------- /.src/spec.ts: -------------------------------------------------------------------------------- 1 | import type * as types from "./types.ts"; 2 | import { assertDefinitionIsSorted } from "./utils/assert_definition_is_sorted.ts"; 3 | export * from "./types.ts"; 4 | 5 | export function desc( 6 | input: TemplateStringsArray | string, 7 | ): string { 8 | const text = Array.isArray(input) ? input.join("") : input as string; 9 | const lines = text 10 | .split("\n") 11 | .map((line) => line.trim().length === 0 ? "" : line) 12 | .filter((line, index, lines) => { 13 | if (line !== "") { 14 | return true; 15 | } 16 | return index !== 0 && index !== lines.length - 1; 17 | }); 18 | 19 | const [firstLine] = lines; 20 | const indent = firstLine.length - firstLine.trimStart().length; 21 | const indentRegex = new RegExp(`^\\s{${indent}}`); 22 | 23 | const newText = lines 24 | .map((line) => line.replace(indentRegex, "").trimEnd()) 25 | .join("\n"); 26 | 27 | return newText; 28 | } 29 | 30 | export const defineValidationSpec = < 31 | Keywords extends Record, 32 | >( 33 | spec: { 34 | $license: string; 35 | $copyright: types.Copyright; 36 | $docsUrl: string; 37 | $draft: string; 38 | $schemaUrl: string; 39 | enums: Record; 40 | keywords: Keywords; 41 | keywordsByType: { 42 | array: types.KeywordKind; 43 | number: types.KeywordKind; 44 | object: types.KeywordKind; 45 | string: types.KeywordKind; 46 | }; 47 | }, 48 | ): typeof spec => { 49 | assertDefinitionIsSorted(spec); 50 | 51 | const keys = Object.keys(spec.keywords); 52 | const tk = spec.keywordsByType; 53 | const allKeywordByTypes: Array = [ 54 | ...tk.array.values, 55 | ...tk.number.values, 56 | ...tk.object.values, 57 | ...tk.string.values, 58 | ]; 59 | 60 | spec.keywordsByType = { 61 | // @ts-expect-error this is valid 62 | any: { 63 | title: "Any", 64 | values: keys.filter( 65 | (key) => { 66 | return allKeywordByTypes.includes(key) === false; 67 | }, 68 | ).sort((a, b) => a.localeCompare(b)), 69 | }, 70 | ...spec.keywordsByType, 71 | }; 72 | 73 | const credits = spec.$copyright.credits.slice(0, -1); 74 | const lastCredit = spec.$copyright.credits.slice(-1); 75 | 76 | spec.$license = spec.$license.replace("{COPYRIGHT}", () => { 77 | return [ 78 | `Documentation and keyword descriptions are copyright (c) ${spec.$copyright.year}`, 79 | `${credits.join(", ")}, and ${lastCredit}. All rights reserved.`, 80 | ].join(" "); 81 | }); 82 | 83 | return spec; 84 | }; 85 | -------------------------------------------------------------------------------- /.src/types.ts: -------------------------------------------------------------------------------- 1 | export type Copyright = { 2 | credits: string[]; 3 | year: number; 4 | }; 5 | 6 | export type EnumSchema = { 7 | description?: string; 8 | values: Record; 9 | title: string; 10 | }; 11 | 12 | export type KeywordSchema = 13 | | { 14 | deprecated?: string; 15 | description?: string; 16 | type: "array"; 17 | items: 18 | | KeywordSchema 19 | | Array; 20 | minItems?: number; 21 | } 22 | | { 23 | const?: false; 24 | deprecated?: string; 25 | description?: string; 26 | type: "boolean"; 27 | default?: boolean; 28 | } 29 | | { 30 | default?: number; 31 | deprecated?: string; 32 | description?: string; 33 | exclusiveMinimum?: number; 34 | minimum?: number; 35 | type: 36 | | "integer" 37 | | "number"; 38 | } 39 | | { 40 | deprecated?: string; 41 | description?: string; 42 | type: "null"; 43 | } 44 | | { 45 | deprecated?: string; 46 | description?: string; 47 | type: "object"; 48 | additionalProperties: KeywordSchema; 49 | } 50 | | { 51 | deprecated?: string; 52 | description?: string; 53 | enum?: string[]; 54 | format?: 55 | | "uri" 56 | | "uri-reference" 57 | | "regex"; 58 | type: "string"; 59 | } 60 | | { 61 | deprecated?: string; 62 | description?: string; 63 | type: 64 | | "JSONSchema" 65 | | "JSONSchema" 66 | | "Value"; 67 | } 68 | | { 69 | deprecated?: string; 70 | description?: string; 71 | oneOf: Array; 72 | } 73 | | { 74 | deprecated?: string; 75 | description?: string; 76 | anyOf: Array; 77 | }; 78 | 79 | export type KeywordKind< 80 | Keyword extends string | number | symbol, 81 | Title extends string, 82 | > = { 83 | description?: string; 84 | title: Title; 85 | values: Keyword[]; 86 | }; 87 | 88 | export type ValidationSpecDefinition = { 89 | $license: string; 90 | $copyright: Copyright; 91 | $docsUrl: string; 92 | $draft: string; 93 | $schemaUrl: string; 94 | enums: Record; 95 | keywords: Record; 96 | keywordsByType: { 97 | array: KeywordKind; 98 | number: KeywordKind; 99 | object: KeywordKind; 100 | string: KeywordKind; 101 | }; 102 | }; 103 | -------------------------------------------------------------------------------- /.src/utils/assert_definition_is_sorted.ts: -------------------------------------------------------------------------------- 1 | const stringifySort = (a: unknown, b: unknown): number => { 2 | const aStr = typeof a === "string" ? a : JSON.stringify(a); 3 | const bStr = typeof b === "string" ? b : JSON.stringify(b); 4 | return aStr.localeCompare(bStr); 5 | }; 6 | 7 | const sortByFirstObjectEntriesKey = ( 8 | entryA: [key: string, value: unknown], 9 | entryB: [key: string, value: unknown], 10 | ): number => entryA[0].localeCompare(entryB[0]); 11 | 12 | const deepSort = (target: unknown): unknown => { 13 | if (Array.isArray(target)) { 14 | return target.map(deepSort).sort(stringifySort); 15 | } 16 | if (typeof target === "object" && target !== null) { 17 | return Object.fromEntries( 18 | Object.entries(target).map(([key, value]) => { 19 | return [key, deepSort(value)] as [key: string, value: unknown]; 20 | }).sort(sortByFirstObjectEntriesKey), 21 | ); 22 | } 23 | return target; 24 | }; 25 | 26 | const assertObjectIsSorted = (obj: unknown): void => { 27 | const objStr = JSON.stringify(obj, undefined, 2); 28 | const objSortedStr = JSON.stringify(deepSort(obj), undefined, 2); 29 | 30 | // Deno.writeTextFileSync(new URL("./_debug.json", import.meta.url), objStr); 31 | // Deno.writeTextFileSync( 32 | // new URL("./_debug.sorted.json", import.meta.url), 33 | // objSortedStr, 34 | // ); 35 | 36 | objStr.split("").forEach((val, i) => { 37 | if (val !== objSortedStr.charAt(i)) { 38 | console.log( 39 | `Object is not deeply sorted starting at:\n${ 40 | objStr.slice(i).slice(0, 500) 41 | }`, 42 | ); 43 | console.log(""); 44 | console.log("---"); 45 | console.log(""); 46 | console.log( 47 | `Expected\n${objSortedStr.slice(i).slice(0, 500)}`, 48 | ); 49 | console.log(""); 50 | 51 | throw new Error("Object is not deeply sorted"); 52 | } 53 | }); 54 | }; 55 | 56 | export const assertDefinitionIsSorted = (spec: Record) => { 57 | // deno-lint-ignore no-unused-vars 58 | const { $copyright, ...other } = spec; 59 | assertObjectIsSorted(other); 60 | }; 61 | -------------------------------------------------------------------------------- /.src/utils/checksum.ts: -------------------------------------------------------------------------------- 1 | import { crypto } from "std/crypto/mod.ts"; 2 | import { iterateReader } from "std/streams/conversion.ts"; 3 | 4 | export const algorithm = "MD5" as const; 5 | 6 | export const fileChecksum = async ( 7 | file: URL | string | Deno.FsFile, 8 | ): Promise => { 9 | const f = file instanceof Deno.FsFile ? file : await Deno.open(file); 10 | const arrayBuffer = await crypto.subtle.digest(algorithm, iterateReader(f)); 11 | 12 | f.close(); 13 | return toHexString(arrayBuffer); 14 | }; 15 | 16 | const toHexString = (bytes: ArrayBuffer): string => 17 | new Uint8Array(bytes).reduce( 18 | (str, byte) => str + byte.toString(16).padStart(2, "0"), 19 | "", 20 | ); 21 | -------------------------------------------------------------------------------- /.src/utils/format_definition_descriptions.ts: -------------------------------------------------------------------------------- 1 | import { 2 | formatMarkdown, 3 | type FormatMarkdownOptions, 4 | } from "./format_markdown.ts"; 5 | import type * as types from "../types.ts"; 6 | 7 | export const formatDefinitionDescriptions = async ( 8 | def: types.ValidationSpecDefinition, 9 | options: FormatMarkdownOptions, 10 | ): Promise => { 11 | const defClone = structuredClone(def) as types.ValidationSpecDefinition; 12 | 13 | for (const enumDef of Object.values(defClone.enums)) { 14 | if (enumDef.description !== undefined) { 15 | enumDef.description = await formatMarkdown( 16 | enumDef.description, 17 | options, 18 | ); 19 | } 20 | for (const enumValue of Object.values(enumDef.values)) { 21 | if (enumValue.description !== undefined) { 22 | enumValue.description = await formatMarkdown( 23 | enumValue.description, 24 | options, 25 | ); 26 | } 27 | } 28 | } 29 | 30 | for (const keywordEntry of Object.values(def.keywords)) { 31 | if (keywordEntry.description) { 32 | keywordEntry.description = await formatMarkdown( 33 | keywordEntry.description, 34 | options, 35 | ); 36 | } 37 | } 38 | 39 | return defClone; 40 | }; 41 | -------------------------------------------------------------------------------- /.src/utils/format_markdown.test.ts: -------------------------------------------------------------------------------- 1 | import { formatMarkdown } from "./format_markdown.ts"; 2 | 3 | const { test } = Deno; 4 | 5 | test("Format markdown", async () => { 6 | console.log( 7 | await formatMarkdown(await Deno.readTextFile("./LICENSE.md"), { 8 | lineWidth: 100_000, 9 | }), 10 | ); 11 | }); 12 | -------------------------------------------------------------------------------- /.src/utils/format_markdown.ts: -------------------------------------------------------------------------------- 1 | export type FormatMarkdownOptions = { 2 | lineWidth?: number; 3 | }; 4 | 5 | export const formatMarkdown = async ( 6 | sourceCode: string, 7 | options: FormatMarkdownOptions = {}, 8 | ): Promise => { 9 | const { lineWidth = 80 } = options; 10 | let tempFilename: string | undefined; 11 | 12 | try { 13 | tempFilename = await Deno.makeTempFile({ suffix: ".md" }); 14 | await Deno.writeTextFile(tempFilename, sourceCode); 15 | const p = Deno.run({ 16 | cmd: [ 17 | "deno", 18 | "fmt", 19 | `--options-line-width=${lineWidth}`, 20 | "--quiet", 21 | tempFilename, 22 | ], 23 | }); 24 | await p.status(); 25 | p.close(); 26 | return (await Deno.readTextFile(tempFilename)).trimEnd(); 27 | } catch (err) { 28 | throw err; 29 | } finally { 30 | if (tempFilename !== undefined) { 31 | Deno.remove(tempFilename); 32 | } 33 | } 34 | }; 35 | -------------------------------------------------------------------------------- /.src/utils/source_code.ts: -------------------------------------------------------------------------------- 1 | import type * as types from "../types.ts"; 2 | 3 | const LETTERS = "ABCDEFGHIJKLMNOPQRSTUVWXYZ".split(""); 4 | 5 | /** 6 | * Split line breaks 7 | * 8 | * @param text 9 | * @returns 10 | */ 11 | export const splitLines = (text: string): string[] => text.split("\n"); 12 | 13 | /** 14 | * Format a block description line 15 | * 16 | * @param line 17 | * @param indent 18 | * @returns 19 | */ 20 | export const formatBlockCommentLine = (line: string, indent = 0) => 21 | `${" ".repeat(indent > 0 ? indent : 0)}* ${line}`; 22 | 23 | /** 24 | * Make a block description 25 | * 26 | * @param text 27 | * @param indent 28 | * @returns 29 | */ 30 | export const makeBlockComment = (text: string, indent = 0): string => { 31 | return `${"".repeat(indent > 1 ? indent - 1 : 0)}/**\n${ 32 | splitLines(text).map((line) => formatBlockCommentLine(line, indent + 1)) 33 | .join("\n") 34 | }\n${" ".repeat(indent + 1)}*/`; 35 | }; 36 | 37 | export const formatKeywordComment = ( 38 | keyword: types.KeywordSchema, 39 | ): string | undefined => { 40 | const comment: string[] = []; 41 | const tags: string[] = []; 42 | 43 | if (keyword.description !== undefined) { 44 | comment.push(keyword.description); 45 | } 46 | 47 | // `default` is the only one out of alphabetical order since editors like 48 | // VS Code display it differently. 49 | if ("default" in keyword && keyword.default !== undefined) { 50 | const { default: def } = keyword; 51 | tags.push( 52 | `@default ${typeof def === "string" ? `"${def}"` : def.toString()}`, 53 | ); 54 | } 55 | 56 | if ("const" in keyword && keyword.const !== undefined) { 57 | const { const: value } = keyword; 58 | 59 | tags.push( 60 | `@const ${typeof value === "string" ? `"${value}"` : value.toString()}`, 61 | ); 62 | } 63 | 64 | if ("deprecated" in keyword && keyword.deprecated !== undefined) { 65 | tags.push( 66 | `@deprecated ${keyword.deprecated.toString()}`, 67 | ); 68 | } 69 | 70 | // `enum` is not needed -- the values will display as a TypeScript union 71 | 72 | if ("exclusiveMinimum" in keyword && keyword.exclusiveMinimum !== undefined) { 73 | tags.push( 74 | `@exclusiveMinimum ${keyword.exclusiveMinimum.toString()}`, 75 | ); 76 | } 77 | 78 | if ("format" in keyword && keyword.format !== undefined) { 79 | tags.push( 80 | `@format "${keyword.format.toString()}"`, 81 | ); 82 | } 83 | 84 | if ("minimum" in keyword && keyword.minimum !== undefined) { 85 | tags.push( 86 | `@minimum ${keyword.minimum.toString()}`, 87 | ); 88 | } 89 | 90 | if (tags.length > 0) { 91 | comment.push("\n\n", ...tags); 92 | } 93 | 94 | if (comment.length === 0) { 95 | return; 96 | } 97 | 98 | return comment.join("\n"); 99 | }; 100 | 101 | export const stringifyKeyword = (keyword: types.KeywordSchema): string => { 102 | if ("type" in keyword) { 103 | switch (keyword.type) { 104 | case "string": { 105 | if (keyword.enum !== undefined) { 106 | return stringifyArrayToUnion(keyword.enum); 107 | } 108 | return "string"; 109 | } 110 | 111 | case "JSONSchema": 112 | return "JSONSchema"; 113 | 114 | case "JSONSchema": 115 | return "JSONSchema"; 116 | 117 | case "Value": 118 | return "Value"; 119 | 120 | case "array": 121 | return `MaybeReadonlyArray<${ 122 | Array.isArray(keyword.items) 123 | ? keyword.items.map((item) => stringifyKeyword(item)) 124 | : stringifyKeyword(keyword.items) 125 | }>`; 126 | 127 | case "object": { 128 | if (keyword.additionalProperties !== undefined) { 129 | return `Record`; 132 | } 133 | throw new TypeError("Unexpected object without `additionalProperties`"); 134 | } 135 | 136 | case "boolean": 137 | case "null": 138 | return keyword.type; 139 | 140 | case "integer": 141 | case "number": 142 | return "number"; 143 | 144 | default: 145 | console.log(keyword); 146 | throw new TypeError("Unexpected keyword schema"); 147 | } 148 | } 149 | 150 | if ("oneOf" in keyword) { 151 | return keyword.oneOf.map(stringifyKeyword).join(" | "); 152 | } 153 | 154 | if ("anyOf" in keyword) { 155 | return keyword.anyOf.map(stringifyKeyword).join(" | "); 156 | } 157 | 158 | throw new TypeError("Unexpected keyword schema"); 159 | }; 160 | 161 | export const stringifyArray = ( 162 | values: readonly string[], 163 | ): string => { 164 | return `\n${values.map((value) => `"${value}",`).join("\n")}`; 165 | }; 166 | 167 | export const stringifyArrayToUnion = ( 168 | values: readonly string[], 169 | indent = 0, 170 | ): string => { 171 | return `\n${ 172 | values.map((value) => `${" ".repeat(indent)}| "${value}"`).join("\n") 173 | }`; 174 | }; 175 | 176 | export const assertCodeDoesNotHavePlaceholder = ( 177 | filename: string, 178 | sourceCode: string, 179 | ): void => { 180 | if (sourceCode.includes("PLACEHOLDER") === false) { 181 | return; 182 | } 183 | 184 | console.error( 185 | `Placeholder is still present when generating "${filename}".`, 186 | "Refusing to proceed.", 187 | ); 188 | const placeHolderIndex = sourceCode.indexOf("PLACEHOLDER"); 189 | const indexStart = placeHolderIndex - 250; 190 | console.log( 191 | sourceCode.slice(indexStart > 0 ? indexStart : 0, indexStart + 500), 192 | ); 193 | Deno.exit(); 194 | }; 195 | 196 | export const expandSourcePlaceholders = ( 197 | filename: string, 198 | rawSourceCode: string, 199 | draftSpec: types.ValidationSpecDefinition, 200 | ) => { 201 | const sourceCode = rawSourceCode.includes("// __BEGIN__") 202 | ? rawSourceCode.split("// __BEGIN__")[1] 203 | : rawSourceCode; 204 | const draftIdNoLeadingZero = draftSpec.$draft.replace(/^0/, ""); 205 | 206 | const typeNames = Object.values(draftSpec.enums.typeName.values).map(( 207 | value, 208 | ) => value.value); 209 | const newCode = splitLines(sourceCode.trim()) 210 | .filter((line) => { 211 | const trimmedLine = line.trim(); 212 | return trimmedLine.includes("// @ts-expect-error") === false; 213 | }) 214 | .map((line) => { 215 | if (line.includes("* __PLACEHOLDER:KEYWORD_COMMENT:")) { 216 | const indent = line.length - line.trimStart().length; 217 | const keyword = line.split(`* __PLACEHOLDER:KEYWORD_COMMENT:`)[1] 218 | .trim().slice(0, -2) as keyof typeof draftSpec.keywords; 219 | if (keyword in draftSpec.keywords) { 220 | const keywordSchema = draftSpec.keywords[keyword]; 221 | const keywordComment = formatKeywordComment( 222 | keywordSchema as types.KeywordSchema, 223 | ); 224 | if (keywordComment !== undefined) { 225 | return splitLines(keywordComment).map(( 226 | descriptionLine, 227 | ) => formatBlockCommentLine(descriptionLine, indent)).join("\n"); 228 | } 229 | // throw new TypeError("TODO") 230 | return ""; 231 | } 232 | } 233 | return line; 234 | }) 235 | .join("\n") 236 | .replace( 237 | "// __PLACEHOLDER:LICENSE__", 238 | makeBlockComment( 239 | draftSpec.$license, 240 | ).replace("/**", "/*"), 241 | ) 242 | .replace( 243 | `// __PLACEHOLDER:TYPES_IMPORT__`, 244 | `import { type JSONSchema } from "./types.ts";`, 245 | ) 246 | .replaceAll(/(__|\*\*)PLACEHOLDER\:DRAFT(__|\*\*)/g, draftSpec.$draft) 247 | .replaceAll( 248 | /(__|\*\*)PLACEHOLDER\:DRAFT(__|\*\*)/g, 249 | draftIdNoLeadingZero, 250 | ) 251 | .replaceAll( 252 | /(__|\*\*)PLACEHOLDER\:DRAFT_LEFT_PADDED(__|\*\*)/g, 253 | draftSpec.$draft.padStart(2, "0"), 254 | ) 255 | .replaceAll("__PLACEHOLDER:SCHEMA_URL__", draftSpec.$schemaUrl) 256 | .replaceAll("__PLACEHOLDER:DOCS_URL__", draftSpec.$docsUrl) 257 | .replace( 258 | `__PLACEHOLDER__: true; // KEYWORDS_INTERFACE`, 259 | Object.entries(draftSpec.keywords).map(([keyword, keywordSchema]) => { 260 | const entry: string[] = []; 261 | const comment = formatKeywordComment(keywordSchema); 262 | 263 | if (comment !== undefined) { 264 | entry.push(makeBlockComment(comment)); 265 | } 266 | 267 | entry.push( 268 | ` ${keyword}?: ${ 269 | keyword === "type" 270 | ? "SchemaType" 271 | : stringifyKeyword(keywordSchema as types.KeywordSchema) 272 | };`, 273 | ); 274 | 275 | return entry.join("\n"); 276 | }).join("\n\n"), 277 | ) 278 | .replace(`// __PLACEHOLDER:KEYWORD_TYPES__`, () => { 279 | const code: string[] = []; 280 | 281 | for ( 282 | const entry of Object.values( 283 | draftSpec.keywordsByType, 284 | ) as types.KeywordKind[] 285 | ) { 286 | code.push( 287 | ` export type ${entry.title} = ${ 288 | stringifyArrayToUnion(entry.values) 289 | }`, 290 | ); 291 | } 292 | return code.join("\n\n"); 293 | }) 294 | .replace(`// __PLACEHOLDER:TYPE_NAMES_TYPE__`, () => { 295 | const typeEnum = draftSpec.enums.typeName; 296 | 297 | return ` export type TypeName = ${ 298 | stringifyArrayToUnion( 299 | Object.values(typeEnum.values).map((entry) => entry.value), 300 | 2, 301 | ) 302 | }`; 303 | }) 304 | .replace(`// __PLACEHOLDER:ENUMS__`, () => { 305 | const code: string[] = []; 306 | 307 | for ( 308 | const enumSchema of Object.values( 309 | draftSpec.enums, 310 | ) as types.EnumSchema[] 311 | ) { 312 | if (enumSchema.description !== undefined) { 313 | code.push( 314 | makeBlockComment(enumSchema.description, 0), 315 | ); 316 | } 317 | 318 | code.push( 319 | `export enum ${enumSchema.title} {${ 320 | Object.entries(enumSchema.values).map( 321 | ([valueKey, valueSchema]) => { 322 | const value: string[] = []; 323 | 324 | if (valueSchema.description !== undefined) { 325 | value.push( 326 | "\n\n", 327 | makeBlockComment(valueSchema.description, 2), 328 | "\n", 329 | ); 330 | } 331 | 332 | value.push( 333 | `${" ".repeat(4)}${ 334 | Number.isInteger(parseInt(valueKey.charAt(0), 10)) 335 | ? `"${valueKey}"` 336 | : valueKey 337 | } = "${valueSchema.value}",`, 338 | ); 339 | 340 | return value.join(""); 341 | }, 342 | ).join("") 343 | }}\n`, 344 | ); 345 | } 346 | 347 | return code.join("\n"); 348 | }) 349 | .replace(`// __PLACEHOLDER:KEYWORDS__`, () => { 350 | return `export const keywords = [${ 351 | stringifyArray(Object.keys(draftSpec.keywords)) 352 | }] as const;`; 353 | }) 354 | .replace( 355 | `"__PLACEHOLDER:TYPE_UNION__"`, 356 | stringifyArrayToUnion(typeNames, 2), 357 | ).replace("// __PLACEHOLDER:EXTRACT_ARRAY_ITEMS_TUPLE__", () => { 358 | return [ 359 | "// deno-fmt-ignore-start", 360 | ...LETTERS.map((_letter, index) => { 361 | const chars = LETTERS.slice(0, index + 1); 362 | return `: Schema extends { items: readonly [${ 363 | chars.map((char) => `infer ${char}`).join(", ") 364 | }] } | { items: [${ 365 | chars.map((char) => `infer ${char}`).join(", ") 366 | }]} ? [${ 367 | chars.map((char) => `JSONSchemaToValueType<${char}, RootSchema>`) 368 | .join(", ") 369 | }]`; 370 | }), 371 | // ...LETTERS.map((_letter, index) => { 372 | // const chars = LETTERS.slice(0, index + 1); 373 | // return `: Schema extends { items: [${ 374 | // chars.map((char) => `infer ${char}`).join(", ") 375 | // }] } ? [${ 376 | // chars.map((char) => `JSONSchemaToValueType<${char}, RootSchema>`) 377 | // .join(", ") 378 | // }]`; 379 | // }), 380 | "// deno-fmt-ignore-end", 381 | , 382 | ].join("\n"); 383 | }); 384 | 385 | assertCodeDoesNotHavePlaceholder(filename, newCode); 386 | return newCode; 387 | }; 388 | -------------------------------------------------------------------------------- /.src/version.ts: -------------------------------------------------------------------------------- 1 | export const VERSION = "8.0.1"; 2 | -------------------------------------------------------------------------------- /.vscode/extensions.json: -------------------------------------------------------------------------------- 1 | { 2 | "recommendations": [ 3 | "denoland.vscode-deno", 4 | "streetsidesoftware.code-spell-checker" 5 | ] 6 | } 7 | -------------------------------------------------------------------------------- /.vscode/settings.json: -------------------------------------------------------------------------------- 1 | { 2 | "[html]": { 3 | "editor.formatOnSave": true 4 | }, 5 | "[javascript]": { 6 | "editor.defaultFormatter": "denoland.vscode-deno", 7 | "editor.formatOnSave": true 8 | }, 9 | "[json]": { 10 | "editor.defaultFormatter": "denoland.vscode-deno", 11 | "editor.formatOnSave": true 12 | }, 13 | "[jsonc]": { 14 | "editor.defaultFormatter": "denoland.vscode-deno", 15 | "editor.formatOnSave": true 16 | }, 17 | "[typescript]": { 18 | "editor.defaultFormatter": "denoland.vscode-deno", 19 | "editor.formatOnSave": true 20 | }, 21 | "deno.codeLens.testArgs": [ 22 | "--no-check", 23 | "--allow-env", 24 | "--allow-net", 25 | "--allow-read", 26 | "--allow-run=deno", 27 | "--allow-write" 28 | ], 29 | "deno.config": "./deno.jsonc", 30 | "deno.enable": true, 31 | "deno.importMap": "./import_map.json", 32 | "deno.lint": true, 33 | "deno.suggest.imports.hosts": { 34 | "https://deno.land": true 35 | }, 36 | "deno.unstable": true 37 | } 38 | -------------------------------------------------------------------------------- /LICENSE.md: -------------------------------------------------------------------------------- 1 | BSD 2-Clause License 2 | 3 | Original source code is copyright (c) 2019-2022 Jeremy Rylan 4 | 5 | 6 | All JSON Schema documentation and descriptions are copyright (c): 7 | 8 | 2009 [draft-0] IETF Trust , Kris Zyp , 9 | and SitePen (USA) . 10 | 11 | 2009 [draft-1] IETF Trust , Kris Zyp , 12 | and SitePen (USA) . 13 | 14 | 2010 [draft-2] IETF Trust , Kris Zyp , 15 | and SitePen (USA) . 16 | 17 | 2010 [draft-3] IETF Trust , Kris Zyp , 18 | Gary Court , and SitePen (USA) . 19 | 20 | 2013 [draft-4] IETF Trust ), Francis Galiegue 21 | , Kris Zyp , Gary Court 22 | , and SitePen (USA) . 23 | 24 | 2018 [draft-7] IETF Trust , Austin Wright , 25 | Henry Andrews , Geraint Luff , and 26 | Cloudflare, Inc. . 27 | 28 | 2019 [draft-2019-09] IETF Trust , Austin Wright 29 | , Henry Andrews , Ben Hutton 30 | , and Greg Dennis . 31 | 32 | 2020 [draft-2020-12] IETF Trust , Austin Wright 33 | , Henry Andrews , Ben Hutton 34 | , and Greg Dennis . 35 | 36 | All rights reserved. 37 | 38 | Redistribution and use in source and binary forms, with or without modification, 39 | are permitted provided that the following conditions are met: 40 | 41 | 1. Redistributions of source code must retain the above copyright notice, this 42 | list of conditions and the following disclaimer. 43 | 44 | 2. Redistributions in binary form must reproduce the above copyright notice, 45 | this list of conditions and the following disclaimer in the documentation 46 | and/or other materials provided with the distribution. 47 | 48 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 49 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 50 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 51 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 52 | ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 53 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 54 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 55 | ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 56 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 57 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | [![downloads-per-month](https://img.shields.io/npm/dm/json-schema-typed.svg?style=flat-square&label=npm%20downloads)](https://npmjs.org/package/json-schema-typed) 2 | 3 | # JSON Schema Typed 4 | 5 | JSON Schema TypeScript definitions with complete inline documentation. 6 | 7 | ## Distributions 8 | 9 | - [Deno](https://github.com/jrylan/json-schema-typed/tree/main/dist/deno) 10 | - [Node.js](https://github.com/jrylan/json-schema-typed/tree/main/dist/node) 11 | - [Spec Definitions](https://github.com/jrylan/json-schema-typed/tree/main/dist/spec_definitions) - 12 | Consistent JSON definitions to help library authors implement JSON Schema 13 | validators with bundled documentation. 14 | 15 | --- 16 | 17 | ## Maintainers 18 | 19 | - [Jeremy Rylan](https://github.com/jrylan) 20 | 21 | ## License 22 | 23 | [BSD-2-Clause](https://github.com/jrylan/json-schema-typed/blob/main/LICENSE.md) 24 | -------------------------------------------------------------------------------- /cspell.json: -------------------------------------------------------------------------------- 1 | { 2 | "language": "en", 3 | "words": [ 4 | "bzfx", 5 | "cloudflare", 6 | "deno", 7 | "denoland", 8 | "galiegue", 9 | "geraint", 10 | "handrews", 11 | "jrylan", 12 | "luffgd", 13 | "microformat", 14 | "millisec", 15 | "rylan", 16 | "subschema", 17 | "subschemas", 18 | "subschema's" 19 | ] 20 | } 21 | -------------------------------------------------------------------------------- /deno.jsonc: -------------------------------------------------------------------------------- 1 | { 2 | "lint": { 3 | "files": { 4 | "exclude": ["dist/"] 5 | } 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /dist/deno/LICENSE.md: -------------------------------------------------------------------------------- 1 | BSD 2-Clause License 2 | 3 | Original source code is copyright (c) 2019-2022 Jeremy Rylan 4 | 5 | 6 | All JSON Schema documentation and descriptions are copyright (c): 7 | 8 | 2009 [draft-0] IETF Trust , Kris Zyp , 9 | and SitePen (USA) . 10 | 11 | 2009 [draft-1] IETF Trust , Kris Zyp , 12 | and SitePen (USA) . 13 | 14 | 2010 [draft-2] IETF Trust , Kris Zyp , 15 | and SitePen (USA) . 16 | 17 | 2010 [draft-3] IETF Trust , Kris Zyp , 18 | Gary Court , and SitePen (USA) . 19 | 20 | 2013 [draft-4] IETF Trust ), Francis Galiegue 21 | , Kris Zyp , Gary Court 22 | , and SitePen (USA) . 23 | 24 | 2018 [draft-7] IETF Trust , Austin Wright , 25 | Henry Andrews , Geraint Luff , and 26 | Cloudflare, Inc. . 27 | 28 | 2019 [draft-2019-09] IETF Trust , Austin Wright 29 | , Henry Andrews , Ben Hutton 30 | , and Greg Dennis . 31 | 32 | 2020 [draft-2020-12] IETF Trust , Austin Wright 33 | , Henry Andrews , Ben Hutton 34 | , and Greg Dennis . 35 | 36 | All rights reserved. 37 | 38 | Redistribution and use in source and binary forms, with or without modification, 39 | are permitted provided that the following conditions are met: 40 | 41 | 1. Redistributions of source code must retain the above copyright notice, this 42 | list of conditions and the following disclaimer. 43 | 44 | 2. Redistributions in binary form must reproduce the above copyright notice, 45 | this list of conditions and the following disclaimer in the documentation 46 | and/or other materials provided with the distribution. 47 | 48 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 49 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 50 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 51 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 52 | ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 53 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 54 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 55 | ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 56 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 57 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -------------------------------------------------------------------------------- /dist/deno/README.md: -------------------------------------------------------------------------------- 1 | # JSON Schema Typed 2 | 3 | JSON Schema TypeScript definitions with complete inline documentation. 4 | 5 | **NOTE:** This library only supports defining schemas. You will need a separate 6 | library for data validation. 7 | 8 | ## Usage 9 | 10 | 1. Chose which JSON Schema draft you'd like to import: 11 | 12 | - `draft_07.ts` 13 | - `draft_2019_09.ts` 14 | - `draft_2020_12.ts` 15 | - `draft_latest.ts` - this always re-exports the latest supported stable 16 | draft, currently `draft_2020_12.ts`. Future releases that re-export a new 17 | draft will always incur a bump to the major semantic version. 18 | 19 | 2. Define a schema 20 | 21 | ```ts 22 | import { 23 | Format, 24 | type JSONSchema, 25 | } from "https://deno.land/x/json_schema_typed/draft_latest.ts"; 26 | 27 | const schema: JSONSchema = { 28 | properties: { 29 | email: { 30 | format: Format.Email, 31 | type: "string", 32 | }, 33 | }, 34 | type: "object", 35 | }; 36 | 37 | // The JSONSchema namespace also provides type-specific narrowed interfaces 38 | const stringSchema: JSONSchema.String = { 39 | // Only { type: "string" } and common keywords are allowed 40 | maxLength: 100, 41 | type: "string", 42 | }; 43 | ``` 44 | 45 | ## Exports supported in each draft module 46 | 47 | | Name | Type | Purpose | 48 | | ----------------- | --------------- | ------------------------------------------------------------------ | 49 | | `$schema` | `string` | Draft meta schema URL that can be used with the `$schema` keyword. | 50 | | `ContentEncoding` | Enum object | String content encoding strategies. | 51 | | `draft` | `string` | Draft version. | 52 | | `Format` | Enum object | String formats. | 53 | | `JSONSchema` | TypeScript Type | Used to define a JSON Schema. | 54 | | `keywords` | `string[]` | All the keywords for the imported draft. | 55 | | `TypeName` | Enum object | Simple type names for the `type` keyword. | 56 | 57 | ## Versioning 58 | 59 | This library follows [semantic versioning](https://semver.org). 60 | 61 | --- 62 | 63 | ## Maintainers 64 | 65 | - [Jeremy Rylan](https://github.com/jrylan) 66 | 67 | ## License 68 | 69 | [BSD-2-Clause](https://github.com/jrylan/json-schema-typed/blob/main/dist/deno/LICENSE.md) 70 | -------------------------------------------------------------------------------- /dist/deno/draft_07.ts: -------------------------------------------------------------------------------- 1 | // @generated 2 | // This code is automatically generated. Manual editing is not recommended. 3 | 4 | /* 5 | * BSD-2-Clause License 6 | * 7 | * Original source code is copyright (c) 2019-2022 Jeremy Rylan 8 | * 9 | * 10 | * Documentation and keyword descriptions are copyright (c) 2018 IETF Trust 11 | * , Austin Wright , Henry Andrews 12 | * , Geraint Luff , and Cloudflare, 13 | * Inc. . All rights reserved. 14 | * 15 | * Redistribution and use in source and binary forms, with or without 16 | * modification, are permitted provided that the following conditions are met: 17 | * 18 | * 1. Redistributions of source code must retain the above copyright notice, 19 | * this list of conditions and the following disclaimer. 20 | * 21 | * 2. Redistributions in binary form must reproduce the above copyright notice, 22 | * this list of conditions and the following disclaimer in the documentation 23 | * and/or other materials provided with the distribution. 24 | * 25 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 26 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 27 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 28 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 29 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 30 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 31 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 32 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 33 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 34 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 35 | * POSSIBILITY OF SUCH DAMAGE. 36 | */ 37 | 38 | export const draft = "7" as const; 39 | export const $schema = "https://json-schema.org/draft-07/schema" as const; 40 | 41 | type MaybeReadonlyArray = Array | ReadonlyArray; 42 | type ValueOf = T[keyof T]; 43 | 44 | /** 45 | * JSON Schema [Draft 7](https://json-schema.org/draft-07/json-schema-validation.html) 46 | */ 47 | export type JSONSchema< 48 | Value = any, 49 | SchemaType = Value extends boolean ? "boolean" 50 | : Value extends null ? "null" 51 | : Value extends number ? "number" | "integer" 52 | : Value extends string ? "string" 53 | : Value extends unknown[] ? "array" 54 | : Value extends Record ? "object" 55 | : JSONSchema.TypeValue, 56 | > = boolean | { 57 | /** 58 | * This keyword is reserved for comments from schema authors to readers or 59 | * maintainers of the schema. The value of this keyword MUST be a string. 60 | * Implementations MUST NOT present this string to end users. Tools for 61 | * editing schemas SHOULD support displaying and editing this keyword. 62 | * 63 | * The value of this keyword MAY be used in debug or error output which is 64 | * intended for developers making use of schemas. Schema vocabularies 65 | * SHOULD allow `comment` within any object containing vocabulary 66 | * keywords. 67 | * 68 | * Implementations MAY assume `comment` is allowed unless the vocabulary 69 | * specifically forbids it. Vocabularies MUST NOT specify any effect of 70 | * `comment` beyond what is described in this specification. Tools that 71 | * translate other media types or programming languages to and from 72 | * `application/schema+json` MAY choose to convert that media type or 73 | * programming language's native comments to or from `comment` values. 74 | * 75 | * The behavior of such translation when both native comments and 76 | * `comment` properties are present is implementation-dependent. 77 | * Implementations SHOULD treat `comment` identically to an unknown 78 | * extension keyword. 79 | * 80 | * They MAY strip `comment` values at any point during processing. In 81 | * particular, this allows for shortening schemas when the size of deployed 82 | * schemas is a concern. Implementations MUST NOT take any other action 83 | * based on the presence, absence, or contents of `comment` properties. 84 | */ 85 | $comment?: string; 86 | 87 | /** 88 | * The `$id` keyword defines a URI for the schema, and the base URI that 89 | * other URI references within the schema are resolved against. A 90 | * subschema's `$id` is resolved against the base URI of its parent 91 | * schema. If no parent sets an explicit base with `$id`, the base URI is 92 | * that of the entire document, as determined per 93 | * [RFC 3986 section 5][RFC3986]. 94 | * 95 | * If present, the value for this keyword MUST be a string, and MUST 96 | * represent a valid [URI-reference][RFC3986]. This value SHOULD be 97 | * normalized, and SHOULD NOT be an empty fragment `#` or an empty string. 98 | * 99 | * [RFC3986]: https://datatracker.ietf.org/doc/html/rfc3986 100 | * 101 | * @format "uri-reference" 102 | */ 103 | $id?: string; 104 | 105 | /** 106 | * The `$ref` keyword is used to reference a schema, and provides the 107 | * ability to validate recursive structures through self-reference. 108 | * 109 | * An object schema with a `$ref` property MUST be interpreted as a 110 | * `$ref` reference. The value of the `$ref` property MUST be a URI 111 | * Reference. Resolved against the current URI base, it identifies the URI 112 | * of a schema to use. All other properties in a `$ref` object MUST be 113 | * ignored. 114 | * 115 | * The URI is not a network locator, only an identifier. A schema need not 116 | * be downloadable from the address if it is a network-addressable URL, and 117 | * implementations SHOULD NOT assume they should perform a network 118 | * operation when they encounter a network-addressable URI. 119 | * 120 | * A schema MUST NOT be run into an infinite loop against a schema. For 121 | * example, if two schemas `"#alice"` and `"#bob"` both have an 122 | * `allOf` property that refers to the other, a naive validator might get 123 | * stuck in an infinite recursive loop trying to validate the instance. 124 | * Schemas SHOULD NOT make use of infinite recursive nesting like this; the 125 | * behavior is undefined. 126 | * 127 | * @format "uri-reference" 128 | */ 129 | $ref?: string; 130 | 131 | /** 132 | * The `$schema` keyword is both used as a JSON Schema version identifier 133 | * and the location of a resource which is itself a JSON Schema, which 134 | * describes any schema written for this particular version. 135 | * 136 | * The value of this keyword MUST be a [URI][RFC3986] (containing a scheme) 137 | * and this URI MUST be normalized. The current schema MUST be valid 138 | * against the meta-schema identified by this URI. 139 | * 140 | * If this URI identifies a retrievable resource, that resource SHOULD be 141 | * of media type `application/schema+json`. 142 | * 143 | * The `$schema` keyword SHOULD be used in a root schema. It MUST NOT 144 | * appear in subschemas. 145 | * 146 | * Values for this property are defined in other documents and by other 147 | * parties. JSON Schema implementations SHOULD implement support for 148 | * current and previous published drafts of JSON Schema vocabularies as 149 | * deemed reasonable. 150 | * 151 | * [RFC3986]: https://datatracker.ietf.org/doc/html/rfc3986 152 | * 153 | * @format "uri" 154 | */ 155 | $schema?: string; 156 | 157 | /** 158 | * The value of `additionalItems` MUST be a valid JSON Schema. 159 | * 160 | * This keyword determines how child instances validate for arrays, and 161 | * does not directly validate the immediate instance itself. 162 | * 163 | * If `items` is an array of schemas, validation succeeds if every 164 | * instance element at a position greater than the size of `items` 165 | * validates against `additionalItems`. 166 | * 167 | * Otherwise, `additionalItems` MUST be ignored, as the `items` schema 168 | * (possibly the default value of an empty schema) is applied to all 169 | * elements. 170 | * 171 | * Omitting this keyword has the same behavior as an empty schema. 172 | */ 173 | additionalItems?: JSONSchema; 174 | 175 | /** 176 | * The value of `additionalProperties` MUST be a valid JSON Schema. 177 | * 178 | * This keyword determines how child instances validate for objects, and 179 | * does not directly validate the immediate instance itself. 180 | * 181 | * Validation with `additionalProperties` applies only to the child 182 | * values of instance names that do not match any names in `properties`, 183 | * and do not match any regular expression in `patternProperties`. 184 | * 185 | * For all such properties, validation succeeds if the child instance 186 | * validates against the `additionalProperties` schema. 187 | * 188 | * Omitting this keyword has the same behavior as an empty schema. 189 | */ 190 | additionalProperties?: JSONSchema; 191 | 192 | /** 193 | * This keyword's value MUST be a non-empty array. Each item of the array 194 | * MUST be a valid JSON Schema. 195 | * 196 | * An instance validates successfully against this keyword if it validates 197 | * successfully against all schemas defined by this keyword's value. 198 | */ 199 | allOf?: MaybeReadonlyArray>; 200 | 201 | /** 202 | * This keyword's value MUST be a non-empty array. Each item of the array 203 | * MUST be a valid JSON Schema. 204 | * 205 | * An instance validates successfully against this keyword if it validates 206 | * successfully against at least one schema defined by this keyword's 207 | * value. 208 | */ 209 | anyOf?: MaybeReadonlyArray>; 210 | 211 | /** 212 | * An instance validates successfully against this keyword if its value is 213 | * equal to the value of the keyword. 214 | * 215 | * Use of this keyword is functionally equivalent to the `enum` keyword 216 | * with a single value. 217 | */ 218 | const?: Value; 219 | 220 | /** 221 | * The value of this keyword MUST be a valid JSON Schema. 222 | * 223 | * An array instance is valid against `contains` if at least one of its 224 | * elements is valid against the given schema. 225 | */ 226 | contains?: JSONSchema; 227 | 228 | /** 229 | * If the instance value is a string, this property defines that the 230 | * string SHOULD be interpreted as binary data and decoded using the 231 | * encoding named by this property. [RFC 2045, Sec 6.1][RFC2045] lists the 232 | * possible values for this property. 233 | * 234 | * The value of this property SHOULD be ignored if the instance described 235 | * is not a string. 236 | * 237 | * [RFC2045]: https://datatracker.ietf.org/doc/html/rfc2045#section-6.1 238 | */ 239 | contentEncoding?: 240 | | "7bit" 241 | | "8bit" 242 | | "base64" 243 | | "binary" 244 | | "ietf-token" 245 | | "quoted-printable" 246 | | "x-token"; 247 | 248 | /** 249 | * The value of this property must be a media type, as defined by 250 | * [RFC 2046][RFC2046]. This property defines the media type of instances 251 | * which this schema defines. 252 | * 253 | * The value of this property SHOULD be ignored if the instance described 254 | * is not a string. 255 | * 256 | * If the `contentEncoding` property is not present, but the instance 257 | * value is a string, then the value of this property SHOULD specify a text 258 | * document type, and the character set SHOULD be the character set into 259 | * which the JSON string value was decoded (for which the default is 260 | * Unicode). 261 | * 262 | * [RFC2046]: https://datatracker.ietf.org/doc/html/rfc2046 263 | */ 264 | contentMediaType?: string; 265 | 266 | /** 267 | * This keyword can be used to supply a default JSON value associated with 268 | * a particular schema. It is RECOMMENDED that a `default` value be valid 269 | * against the associated schema. 270 | */ 271 | default?: Value; 272 | 273 | /** 274 | * The `definitions` keywords provides a standardized location for schema 275 | * authors to inline re-usable JSON Schemas into a more general schema. The 276 | * keyword does not directly affect the validation result. 277 | * 278 | * This keyword's value MUST be an object. Each member value of this object 279 | * MUST be a valid JSON Schema. 280 | */ 281 | definitions?: Record; 282 | 283 | /** 284 | * This keyword specifies rules that are evaluated if the instance is an 285 | * object and contains a certain property. 286 | * 287 | * This keyword's value MUST be an object. Each property specifies a 288 | * dependency. Each dependency value MUST be an array or a valid JSON 289 | * Schema. 290 | * 291 | * If the dependency value is a subschema, and the dependency key is a 292 | * property in the instance, the entire instance must validate against the 293 | * dependency value. 294 | * 295 | * If the dependency value is an array, each element in the array, if any, 296 | * MUST be a string, and MUST be unique. If the dependency key is a 297 | * property in the instance, each of the items in the dependency value must 298 | * be a property that exists in the instance. 299 | * 300 | * Omitting this keyword has the same behavior as an empty object. 301 | */ 302 | dependencies?: Record | JSONSchema>; 303 | 304 | /** 305 | * Can be used to decorate a user interface with explanation or information 306 | * about the data produced. 307 | */ 308 | description?: string; 309 | 310 | /** 311 | * This keyword's value MUST be a valid JSON Schema. 312 | * 313 | * When `if` is present, and the instance fails to validate against its 314 | * subschema, then validation succeeds against this keyword if the instance 315 | * successfully validates against this keyword's subschema. 316 | * 317 | * This keyword has no effect when `if` is absent, or when the instance 318 | * successfully validates against its subschema. Implementations MUST NOT 319 | * evaluate the instance against this keyword, for either validation or 320 | * annotation collection purposes, in such cases. 321 | */ 322 | else?: JSONSchema; 323 | 324 | /** 325 | * The value of this keyword MUST be an array. This array SHOULD have at 326 | * least one element. Elements in the array SHOULD be unique. 327 | * 328 | * An instance validates successfully against this keyword if its value is 329 | * equal to one of the elements in this keyword's array value. 330 | * 331 | * Elements in the array might be of any type, including `null`. 332 | */ 333 | enum?: MaybeReadonlyArray; 334 | 335 | /** 336 | * The value of this keyword MUST be an array. When multiple occurrences of 337 | * this keyword are applicable to a single sub-instance, implementations 338 | * MUST provide a flat array of all values rather than an array of arrays. 339 | * 340 | * This keyword can be used to provide sample JSON values associated with a 341 | * particular schema, for the purpose of illustrating usage. It is 342 | * RECOMMENDED that these values be valid against the associated schema. 343 | * 344 | * Implementations MAY use the value(s) of `default`, if present, as an 345 | * additional example. If `examples` is absent, `default` MAY still be 346 | * used in this manner. 347 | */ 348 | examples?: MaybeReadonlyArray; 349 | 350 | /** 351 | * The value of `exclusiveMaximum` MUST be a number, representing an 352 | * exclusive upper limit for a numeric instance. 353 | * 354 | * If the instance is a number, then the instance is valid only if it has a 355 | * value strictly less than (not equal to) `exclusiveMaximum`. 356 | */ 357 | exclusiveMaximum?: number; 358 | 359 | /** 360 | * The value of `exclusiveMinimum` MUST be a number, representing an 361 | * exclusive lower limit for a numeric instance. 362 | * 363 | * If the instance is a number, then the instance is valid only if it has a 364 | * value strictly greater than (not equal to) `exclusiveMinimum`. 365 | */ 366 | exclusiveMinimum?: number; 367 | 368 | /** 369 | * The `format` keyword functions as both an [annotation][annotation] and 370 | * as an [assertion][assertion]. While no special effort is required to 371 | * implement it as an annotation conveying semantic meaning, implementing 372 | * validation is non-trivial. 373 | * 374 | * Implementations MAY support the `format` keyword as a validation 375 | * assertion. 376 | * 377 | * Implementations MAY add custom `format` attributes. Save for agreement 378 | * between parties, schema authors SHALL NOT expect a peer implementation 379 | * to support this keyword and/or custom `format` attributes. 380 | * 381 | * [annotation]: https://json-schema.org/draft-07/json-schema-validation.html#annotations 382 | * [assertion]: https://json-schema.org/draft-07/json-schema-validation.html#assertions 383 | */ 384 | format?: string; 385 | 386 | /** 387 | * This keyword's value MUST be a valid JSON Schema. 388 | * 389 | * This validation outcome of this keyword's subschema has no direct effect 390 | * on the overall validation result. Rather, it controls which of the 391 | * `then` or `else` keywords are evaluated. 392 | * 393 | * Instances that successfully validate against this keyword's subschema 394 | * MUST also be valid against the subschema value of the `then` keyword, 395 | * if present. 396 | * 397 | * Instances that fail to validate against this keyword's subschema MUST 398 | * also be valid against the subschema value of the `else` keyword, if 399 | * present. 400 | * 401 | * If [annotations][annotations] are being collected, they are collected 402 | * from this keyword's subschema in the usual way, including when the 403 | * keyword is present without either `then` or `else`. 404 | * 405 | * [annotations]: https://json-schema.org/draft-07/json-schema-validation.html#annotations 406 | */ 407 | if?: JSONSchema; 408 | 409 | /** 410 | * The value of `items` MUST be either a valid JSON Schema or an array of 411 | * valid JSON Schemas. 412 | * 413 | * This keyword determines how child instances validate for arrays, and 414 | * does not directly validate the immediate instance itself. 415 | * 416 | * If `items` is a schema, validation succeeds if all elements in the 417 | * array successfully validate against that schema. 418 | * 419 | * If `items` is an array of schemas, validation succeeds if each element 420 | * of the instance validates against the schema at the same position, if 421 | * any. 422 | * 423 | * Omitting this keyword has the same behavior as an empty schema. 424 | */ 425 | items?: MaybeReadonlyArray | JSONSchema; 426 | 427 | /** 428 | * The value of `maximum` MUST be a number, representing an inclusive 429 | * upper limit for a numeric instance. 430 | * 431 | * If the instance is a number, then this keyword validates only if the 432 | * instance is less than or exactly equal to `maximum`. 433 | */ 434 | maximum?: number; 435 | 436 | /** 437 | * The value of this keyword MUST be a non-negative integer. 438 | * 439 | * An array instance is valid against `maxItems` if its size is less 440 | * than, or equal to, the value of this keyword. 441 | * 442 | * @minimum 0 443 | */ 444 | maxItems?: number; 445 | 446 | /** 447 | * The value of this keyword MUST be a non-negative integer. 448 | * 449 | * A string instance is valid against this keyword if its length is less 450 | * than, or equal to, the value of this keyword. 451 | * 452 | * The length of a string instance is defined as the number of its 453 | * characters as defined by [RFC 7159][RFC7159]. 454 | * 455 | * [RFC7159]: https://datatracker.ietf.org/doc/html/rfc7159 456 | * 457 | * @minimum 0 458 | */ 459 | maxLength?: number; 460 | 461 | /** 462 | * The value of this keyword MUST be a non-negative integer. 463 | * 464 | * An object instance is valid against `maxProperties` if its number of 465 | * `properties` is less than, or equal to, the value of this keyword. 466 | * 467 | * @minimum 0 468 | */ 469 | maxProperties?: number; 470 | 471 | /** 472 | * The value of `minimum` MUST be a number, representing an inclusive 473 | * lower limit for a numeric instance. 474 | * 475 | * If the instance is a number, then this keyword validates only if the 476 | * instance is greater than or exactly equal to `minimum`. 477 | */ 478 | minimum?: number; 479 | 480 | /** 481 | * The value of this keyword MUST be a non-negative integer. 482 | * 483 | * An array instance is valid against `minItems` if its size is greater 484 | * than, or equal to, the value of this keyword. 485 | * 486 | * Omitting this keyword has the same behavior as a value of `0`. 487 | * 488 | * @default 0 489 | * @minimum 0 490 | */ 491 | minItems?: number; 492 | 493 | /** 494 | * The value of this keyword MUST be a non-negative integer. 495 | * 496 | * A string instance is valid against this keyword if its length is greater 497 | * than, or equal to, the value of this keyword. 498 | * 499 | * The length of a string instance is defined as the number of its 500 | * characters as defined by [RFC 7159][RFC7159]. 501 | * 502 | * Omitting this keyword has the same behavior as a value of `0`. 503 | * 504 | * [RFC7159]: https://datatracker.ietf.org/doc/html/rfc7159 505 | * 506 | * @default 0 507 | * @minimum 0 508 | */ 509 | minLength?: number; 510 | 511 | /** 512 | * The value of this keyword MUST be a non-negative integer. 513 | * 514 | * An object instance is valid against `minProperties` if its number of 515 | * `properties` is greater than, or equal to, the value of this keyword. 516 | * 517 | * Omitting this keyword has the same behavior as a value of `0`. 518 | * 519 | * @default 0 520 | * @minimum 0 521 | */ 522 | minProperties?: number; 523 | 524 | /** 525 | * The value of `multipleOf` MUST be a number, strictly greater than 526 | * `0`. 527 | * 528 | * A numeric instance is valid only if division by this keyword's value 529 | * results in an integer. 530 | * 531 | * @exclusiveMinimum 0 532 | */ 533 | multipleOf?: number; 534 | 535 | /** 536 | * This keyword's value MUST be a valid JSON Schema. 537 | * 538 | * An instance is valid against this keyword if it fails to validate 539 | * successfully against the schema defined by this keyword. 540 | */ 541 | not?: JSONSchema; 542 | 543 | /** 544 | * This keyword's value MUST be a non-empty array. Each item of the array 545 | * MUST be a valid JSON Schema. 546 | * 547 | * An instance validates successfully against this keyword if it validates 548 | * successfully against exactly one schema defined by this keyword's value. 549 | */ 550 | oneOf?: MaybeReadonlyArray>; 551 | 552 | /** 553 | * The value of this keyword MUST be a string. This string SHOULD be a 554 | * valid regular expression, according to the [ECMA-262][ecma262] regular 555 | * expression dialect. 556 | * 557 | * A string instance is considered valid if the regular expression matches 558 | * the instance successfully. Recall: regular expressions are not 559 | * implicitly anchored. 560 | * 561 | * [ecma262]: https://www.ecma-international.org/publications-and-standards/standards/ecma-262/ 562 | * 563 | * @format "regex" 564 | */ 565 | pattern?: string; 566 | 567 | /** 568 | * The value of `patternProperties` MUST be an object. Each property name 569 | * of this object SHOULD be a valid regular expression, according to the 570 | * [ECMA-262][ecma262] regular expression dialect. Each property value of 571 | * this object MUST be a valid JSON Schema. 572 | * 573 | * This keyword determines how child instances validate for objects, and 574 | * does not directly validate the immediate instance itself. Validation of 575 | * the primitive instance type against this keyword always succeeds. 576 | * 577 | * Validation succeeds if, for each instance name that matches any regular 578 | * expressions that appear as a property name in this keyword's value, the 579 | * child instance for that name successfully validates against each schema 580 | * that corresponds to a matching regular expression. 581 | * 582 | * Omitting this keyword has the same behavior as an empty object. 583 | * 584 | * [ecma262]: https://www.ecma-international.org/publications-and-standards/standards/ecma-262/ 585 | */ 586 | patternProperties?: Record; 587 | 588 | /** 589 | * The value of `properties` MUST be an object. Each value of this object 590 | * MUST be a valid JSON Schema. 591 | * 592 | * This keyword determines how child instances validate for objects, and 593 | * does not directly validate the immediate instance itself. 594 | * 595 | * Validation succeeds if, for each name that appears in both the instance 596 | * and as a name within this keyword's value, the child instance for that 597 | * name successfully validates against the corresponding schema. 598 | * 599 | * Omitting this keyword has the same behavior as an empty object. 600 | */ 601 | properties?: Record; 602 | 603 | /** 604 | * The value of `propertyNames` MUST be a valid JSON Schema. 605 | * 606 | * If the instance is an object, this keyword validates if every property 607 | * name in the instance validates against the provided schema. Note the 608 | * property name that the schema is testing will always be a string. 609 | * 610 | * Omitting this keyword has the same behavior as an empty schema. 611 | */ 612 | propertyNames?: JSONSchema; 613 | 614 | /** 615 | * The value of this keyword MUST be a boolean. When multiple occurrences 616 | * of this keyword are applicable to a single sub-instance, the resulting 617 | * value MUST be `true` if any occurrence specifies a `true` value, and 618 | * MUST be `false` otherwise. 619 | * 620 | * If `readOnly` has a value of boolean `true`, it indicates that the 621 | * value of the instance is managed exclusively by the owning authority, 622 | * and attempts by an application to modify the value of this property are 623 | * expected to be ignored or rejected by that owning authority. 624 | * 625 | * An instance document that is marked as `readOnly` for the entire 626 | * document MAY be ignored if sent to the owning authority, or MAY result 627 | * in an error, at the authority's discretion. 628 | * 629 | * For example, `readOnly` would be used to mark a database-generated 630 | * serial number as read-only. 631 | * 632 | * This keyword can be used to assist in user interface instance 633 | * generation. 634 | * 635 | * @default false 636 | */ 637 | readOnly?: boolean; 638 | 639 | /** 640 | * The value of this keyword MUST be an array. Elements of this array, if 641 | * any, MUST be strings, and MUST be unique. 642 | * 643 | * An object instance is valid against this keyword if every item in the 644 | * array is the name of a property in the instance. 645 | * 646 | * Omitting this keyword has the same behavior as an empty array. 647 | */ 648 | required?: MaybeReadonlyArray; 649 | 650 | /** 651 | * This keyword's value MUST be a valid JSON Schema. 652 | * 653 | * When `if` is present, and the instance successfully validates against 654 | * its subschema, then validation succeeds against this keyword if the 655 | * instance also successfully validates against this keyword's subschema. 656 | * 657 | * This keyword has no effect when `if` is absent, or when the instance 658 | * fails to validate against its subschema. Implementations MUST NOT 659 | * evaluate the instance against this keyword, for either validation or 660 | * annotation collection purposes, in such cases. 661 | */ 662 | then?: JSONSchema; 663 | 664 | /** 665 | * Can be used to decorate a user interface with a short label about the 666 | * data produced. 667 | */ 668 | title?: string; 669 | 670 | /** 671 | * The value of this keyword MUST be either a string or an array. If it is 672 | * an array, elements of the array MUST be strings and MUST be unique. 673 | * 674 | * String values MUST be one of the six primitive types (`"null"`, 675 | * `"boolean"`, `"object"`, `"array"`, `"number"`, or 676 | * `"string"`), or `"integer"` which matches any number with a zero 677 | * fractional part. 678 | * 679 | * An instance validates if and only if the instance is in any of the sets 680 | * listed for this keyword. 681 | */ 682 | type?: SchemaType; 683 | 684 | /** 685 | * The value of this keyword MUST be a boolean. 686 | * 687 | * If this keyword has boolean value `false`, the instance validates 688 | * successfully. If it has boolean value `true`, the instance validates 689 | * successfully if all of its elements are unique. 690 | * 691 | * Omitting this keyword has the same behavior as a value of `false`. 692 | * 693 | * @default false 694 | */ 695 | uniqueItems?: boolean; 696 | 697 | /** 698 | * The value of this keyword MUST be a boolean. When multiple occurrences 699 | * of this keyword is applicable to a single sub-instance, the resulting 700 | * value MUST be `true` if any occurrence specifies a `true` value, and 701 | * MUST be `false` otherwise. 702 | * 703 | * If `writeOnly` has a value of boolean `true`, it indicates that the 704 | * value is never present when the instance is retrieved from the owning 705 | * authority. It can be present when sent to the owning authority to update 706 | * or create the document (or the resource it represents), but it will not 707 | * be included in any updated or newly created version of the instance. 708 | * 709 | * An instance document that is marked as `writeOnly` for the entire 710 | * document MAY be returned as a blank document of some sort, or MAY 711 | * produce an error upon retrieval, or have the retrieval request ignored, 712 | * at the authority's discretion. 713 | * 714 | * For example, `writeOnly` would be used to mark a password input field. 715 | * 716 | * These keywords can be used to assist in user interface instance 717 | * generation. In particular, an application MAY choose to use a widget 718 | * that hides input values as they are typed for write-only fields. 719 | * 720 | * @default false 721 | */ 722 | writeOnly?: boolean; 723 | }; 724 | 725 | // ----------------------------------------------------------------------------- 726 | 727 | export namespace JSONSchema { 728 | export type TypeValue = ( 729 | | ValueOf 730 | | TypeName 731 | | Array | TypeName> 732 | | ReadonlyArray | TypeName> 733 | ); 734 | 735 | /** 736 | * JSON Schema interface 737 | */ 738 | export type Interface< 739 | Value = any, 740 | SchemaType extends TypeValue = TypeValue, 741 | > = Exclude< 742 | JSONSchema, 743 | boolean 744 | >; 745 | 746 | export type Array = Pick< 747 | Interface, 748 | KeywordByType.Any | KeywordByType.Array 749 | >; 750 | 751 | export type Boolean = Pick< 752 | Interface, 753 | KeywordByType.Any 754 | >; 755 | 756 | export type Integer = Pick< 757 | Interface, 758 | KeywordByType.Any | KeywordByType.Number 759 | >; 760 | 761 | export type Number = Pick< 762 | Interface, 763 | KeywordByType.Any | KeywordByType.Number 764 | >; 765 | 766 | export type Null = Pick< 767 | Interface, 768 | KeywordByType.Any 769 | >; 770 | 771 | export type Object = Pick< 772 | Interface, 773 | KeywordByType.Any | KeywordByType.Object 774 | >; 775 | 776 | export type String = Pick< 777 | Interface, 778 | KeywordByType.Any | KeywordByType.String 779 | >; 780 | } 781 | 782 | namespace KeywordByType { 783 | export type Any = 784 | | "$comment" 785 | | "$id" 786 | | "$ref" 787 | | "$schema" 788 | | "allOf" 789 | | "anyOf" 790 | | "const" 791 | | "default" 792 | | "definitions" 793 | | "description" 794 | | "else" 795 | | "enum" 796 | | "examples" 797 | | "if" 798 | | "not" 799 | | "oneOf" 800 | | "readOnly" 801 | | "then" 802 | | "title" 803 | | "type" 804 | | "writeOnly"; 805 | 806 | export type Array = 807 | | "additionalItems" 808 | | "contains" 809 | | "items" 810 | | "maxItems" 811 | | "minItems" 812 | | "uniqueItems"; 813 | 814 | export type Number = 815 | | "exclusiveMaximum" 816 | | "exclusiveMinimum" 817 | | "maximum" 818 | | "minimum" 819 | | "multipleOf"; 820 | 821 | export type Object = 822 | | "additionalProperties" 823 | | "dependencies" 824 | | "maxProperties" 825 | | "minProperties" 826 | | "patternProperties" 827 | | "properties" 828 | | "propertyNames" 829 | | "required"; 830 | 831 | export type String = 832 | | "contentEncoding" 833 | | "contentMediaType" 834 | | "format" 835 | | "maxLength" 836 | | "minLength" 837 | | "pattern"; 838 | } 839 | 840 | // ----------------------------------------------------------------------------- 841 | 842 | /** 843 | * Content encoding strategy enum. 844 | * 845 | * - [Content-Transfer-Encoding Syntax](https://datatracker.ietf.org/doc/html/rfc2045#section-6.1) 846 | * - [7bit vs 8bit encoding](https://stackoverflow.com/questions/25710599/content-transfer-encoding-7bit-or-8-bit/28531705#28531705) 847 | */ 848 | export enum ContentEncoding { 849 | /** 850 | * Only US-ASCII characters, which use the lower 7 bits for each character. 851 | * 852 | * Each line must be less than 1,000 characters. 853 | */ 854 | "7bit" = "7bit", 855 | 856 | /** 857 | * Allow extended ASCII characters which can use the 8th (highest) bit to 858 | * indicate special characters not available in 7bit. 859 | * 860 | * Each line must be less than 1,000 characters. 861 | */ 862 | "8bit" = "8bit", 863 | 864 | /** 865 | * Useful for data that is mostly non-text. 866 | */ 867 | Base64 = "base64", 868 | 869 | /** 870 | * Same character set as 8bit, with no line length restriction. 871 | */ 872 | Binary = "binary", 873 | 874 | /** 875 | * An extension token defined by a standards-track RFC and registered with 876 | * IANA. 877 | */ 878 | IETFToken = "ietf-token", 879 | 880 | /** 881 | * Lines are limited to 76 characters, and line breaks are represented using 882 | * special characters that are escaped. 883 | */ 884 | QuotedPrintable = "quoted-printable", 885 | 886 | /** 887 | * The two characters "X-" or "x-" followed, with no intervening white space, 888 | * by any token. 889 | */ 890 | XToken = "x-token", 891 | } 892 | 893 | /** 894 | * This enum provides well-known formats that apply to strings. 895 | */ 896 | export enum Format { 897 | /** 898 | * A string instance is valid against this attribute if it is a valid 899 | * representation according to the "full-date" production in 900 | * [RFC 3339][RFC3339]. 901 | * 902 | * [RFC3339]: https://datatracker.ietf.org/doc/html/rfc3339 903 | */ 904 | Date = "date", 905 | 906 | /** 907 | * A string instance is valid against this attribute if it is a valid 908 | * representation according to the "date-time" production in 909 | * [RFC 3339][RFC3339]. 910 | * 911 | * [RFC3339]: https://datatracker.ietf.org/doc/html/rfc3339 912 | */ 913 | DateTime = "date-time", 914 | 915 | /** 916 | * A string instance is valid against this attribute if it is a valid Internet 917 | * email address as defined by [RFC 5322, section 3.4.1][RFC5322]. 918 | * 919 | * [RFC5322]: https://datatracker.ietf.org/doc/html/rfc5322 920 | */ 921 | Email = "email", 922 | 923 | /** 924 | * As defined by [RFC 1034, section 3.1][RFC1034], including host names 925 | * produced using the Punycode algorithm specified in 926 | * [RFC 5891, section 4.4][RFC5891]. 927 | * 928 | * [RFC1034]: https://datatracker.ietf.org/doc/html/rfc1034 929 | * [RFC5891]: https://datatracker.ietf.org/doc/html/rfc5891 930 | */ 931 | Hostname = "hostname", 932 | 933 | /** 934 | * A string instance is valid against this attribute if it is a valid Internet 935 | * email address as defined by [RFC 6531][RFC6531]. 936 | * 937 | * [RFC6531]: https://datatracker.ietf.org/doc/html/rfc6531 938 | */ 939 | IDNEmail = "idn-email", 940 | 941 | /** 942 | * As defined by either [RFC 1034, section 3.1][RFC1034] as for hostname, or 943 | * an internationalized hostname as defined by 944 | * [RFC 5890, section 2.3.2.3][RFC5890]. 945 | * 946 | * [RFC1034]: https://datatracker.ietf.org/doc/html/rfc1034 947 | * [RFC5890]: https://datatracker.ietf.org/doc/html/rfc5890 948 | */ 949 | IDNHostname = "idn-hostname", 950 | 951 | /** 952 | * An IPv4 address according to the "dotted-quad" ABNF syntax as defined in 953 | * [RFC 2673, section 3.2][RFC2673]. 954 | * 955 | * [RFC2673]: https://datatracker.ietf.org/doc/html/rfc2673 956 | */ 957 | IPv4 = "ipv4", 958 | 959 | /** 960 | * An IPv6 address as defined in [RFC 4291, section 2.2][RFC4291]. 961 | * 962 | * [RFC4291]: https://datatracker.ietf.org/doc/html/rfc4291 963 | */ 964 | IPv6 = "ipv6", 965 | 966 | /** 967 | * A string instance is valid against this attribute if it is a valid IRI, 968 | * according to [RFC 3987][RFC3987]. 969 | * 970 | * [RFC3987]: https://datatracker.ietf.org/doc/html/rfc3987 971 | */ 972 | IRI = "iri", 973 | 974 | /** 975 | * A string instance is valid against this attribute if it is a valid IRI 976 | * Reference (either an IRI or a relative-reference), according to 977 | * [RFC 3987][RFC3987]. 978 | * 979 | * [RFC3987]: https://datatracker.ietf.org/doc/html/rfc3987 980 | */ 981 | IRIReference = "iri-reference", 982 | 983 | /** 984 | * A string instance is valid against this attribute if it is a valid JSON 985 | * string representation of a JSON Pointer, according to 986 | * [RFC 6901, section 5][RFC6901]. 987 | * 988 | * [RFC6901]: https://datatracker.ietf.org/doc/html/rfc6901 989 | */ 990 | JSONPointer = "json-pointer", 991 | 992 | /** 993 | * A string instance is valid against this attribute if it is a valid JSON 994 | * string representation of a JSON Pointer fragment, according to 995 | * [RFC 6901, section 5][RFC6901]. 996 | * 997 | * [RFC6901]: https://datatracker.ietf.org/doc/html/rfc6901 998 | */ 999 | JSONPointerURIFragment = "json-pointer-uri-fragment", 1000 | 1001 | /** 1002 | * This attribute applies to string instances. 1003 | * 1004 | * A regular expression, which SHOULD be valid according to the 1005 | * [ECMA-262][ecma262] regular expression dialect. 1006 | * 1007 | * Implementations that validate formats MUST accept at least the subset of 1008 | * [ECMA-262][ecma262] defined in the [Regular Expressions][regexInterop] 1009 | * section of this specification, and SHOULD accept all valid 1010 | * [ECMA-262][ecma262] expressions. 1011 | * 1012 | * [ecma262]: https://www.ecma-international.org/publications-and-standards/standards/ecma-262/ 1013 | * [regexInterop]: https://json-schema.org/draft-07/json-schema-validation.html#regexInterop 1014 | */ 1015 | RegEx = "regex", 1016 | 1017 | /** 1018 | * A string instance is valid against this attribute if it is a valid 1019 | * [Relative JSON Pointer][relative-json-pointer]. 1020 | * 1021 | * [relative-json-pointer]: https://datatracker.ietf.org/doc/html/draft-handrews-relative-json-pointer-01 1022 | */ 1023 | RelativeJSONPointer = "relative-json-pointer", 1024 | 1025 | /** 1026 | * A string instance is valid against this attribute if it is a valid 1027 | * representation according to the "time" production in [RFC 3339][RFC3339]. 1028 | * 1029 | * [RFC3339]: https://datatracker.ietf.org/doc/html/rfc3339 1030 | */ 1031 | Time = "time", 1032 | 1033 | /** 1034 | * A string instance is valid against this attribute if it is a valid URI, 1035 | * according to [RFC3986][RFC3986]. 1036 | * 1037 | * [RFC3986]: https://datatracker.ietf.org/doc/html/rfc3986 1038 | */ 1039 | URI = "uri", 1040 | 1041 | /** 1042 | * A string instance is valid against this attribute if it is a valid URI 1043 | * Reference (either a URI or a relative-reference), according to 1044 | * [RFC3986][RFC3986]. 1045 | * 1046 | * [RFC3986]: https://datatracker.ietf.org/doc/html/rfc3986 1047 | */ 1048 | URIReference = "uri-reference", 1049 | 1050 | /** 1051 | * A string instance is valid against this attribute if it is a valid URI 1052 | * Template (of any level), according to [RFC6570][RFC6570]. 1053 | * 1054 | * Note that URI Templates may be used for IRIs; there is no separate IRI 1055 | * Template specification. 1056 | * 1057 | * [RFC6570]: https://datatracker.ietf.org/doc/html/rfc6570 1058 | */ 1059 | URITemplate = "uri-template", 1060 | 1061 | /** 1062 | * UUID 1063 | */ 1064 | UUID = "uuid", 1065 | } 1066 | 1067 | /** 1068 | * Enum consisting of simple type names for the `type` keyword 1069 | */ 1070 | export enum TypeName { 1071 | /** 1072 | * Value MUST be an array. 1073 | */ 1074 | Array = "array", 1075 | 1076 | /** 1077 | * Value MUST be a boolean. 1078 | */ 1079 | Boolean = "boolean", 1080 | 1081 | /** 1082 | * Value MUST be an integer, no floating point numbers are allowed. This is a 1083 | * subset of the number type. 1084 | */ 1085 | Integer = "integer", 1086 | 1087 | /** 1088 | * Value MUST be null. Note this is mainly for purpose of being able use union 1089 | * types to define nullability. If this type is not included in a union, null 1090 | * values are not allowed (the primitives listed above do not allow nulls on 1091 | * their own). 1092 | */ 1093 | Null = "null", 1094 | 1095 | /** 1096 | * Value MUST be a number, floating point numbers are allowed. 1097 | */ 1098 | Number = "number", 1099 | 1100 | /** 1101 | * Value MUST be an object. 1102 | */ 1103 | Object = "object", 1104 | 1105 | /** 1106 | * Value MUST be a string. 1107 | */ 1108 | String = "string", 1109 | } 1110 | 1111 | // ----------------------------------------------------------------------------- 1112 | // Keywords 1113 | // ----------------------------------------------------------------------------- 1114 | 1115 | export const keywords = [ 1116 | "$comment", 1117 | "$id", 1118 | "$ref", 1119 | "$schema", 1120 | "additionalItems", 1121 | "additionalProperties", 1122 | "allOf", 1123 | "anyOf", 1124 | "const", 1125 | "contains", 1126 | "contentEncoding", 1127 | "contentMediaType", 1128 | "default", 1129 | "definitions", 1130 | "dependencies", 1131 | "description", 1132 | "else", 1133 | "enum", 1134 | "examples", 1135 | "exclusiveMaximum", 1136 | "exclusiveMinimum", 1137 | "format", 1138 | "if", 1139 | "items", 1140 | "maximum", 1141 | "maxItems", 1142 | "maxLength", 1143 | "maxProperties", 1144 | "minimum", 1145 | "minItems", 1146 | "minLength", 1147 | "minProperties", 1148 | "multipleOf", 1149 | "not", 1150 | "oneOf", 1151 | "pattern", 1152 | "patternProperties", 1153 | "properties", 1154 | "propertyNames", 1155 | "readOnly", 1156 | "required", 1157 | "then", 1158 | "title", 1159 | "type", 1160 | "uniqueItems", 1161 | "writeOnly", 1162 | ] as const; 1163 | -------------------------------------------------------------------------------- /dist/deno/draft_latest.ts: -------------------------------------------------------------------------------- 1 | export * from "./draft_2020_12.ts"; -------------------------------------------------------------------------------- /dist/deno/version.ts: -------------------------------------------------------------------------------- 1 | export const VERSION = "8.0.0"; 2 | -------------------------------------------------------------------------------- /dist/node/LICENSE.md: -------------------------------------------------------------------------------- 1 | BSD 2-Clause License 2 | 3 | Original source code is copyright (c) 2019-2022 Jeremy Rylan 4 | 5 | 6 | All JSON Schema documentation and descriptions are copyright (c): 7 | 8 | 2009 [draft-0] IETF Trust , Kris Zyp , 9 | and SitePen (USA) . 10 | 11 | 2009 [draft-1] IETF Trust , Kris Zyp , 12 | and SitePen (USA) . 13 | 14 | 2010 [draft-2] IETF Trust , Kris Zyp , 15 | and SitePen (USA) . 16 | 17 | 2010 [draft-3] IETF Trust , Kris Zyp , 18 | Gary Court , and SitePen (USA) . 19 | 20 | 2013 [draft-4] IETF Trust ), Francis Galiegue 21 | , Kris Zyp , Gary Court 22 | , and SitePen (USA) . 23 | 24 | 2018 [draft-7] IETF Trust , Austin Wright , 25 | Henry Andrews , Geraint Luff , and 26 | Cloudflare, Inc. . 27 | 28 | 2019 [draft-2019-09] IETF Trust , Austin Wright 29 | , Henry Andrews , Ben Hutton 30 | , and Greg Dennis . 31 | 32 | 2020 [draft-2020-12] IETF Trust , Austin Wright 33 | , Henry Andrews , Ben Hutton 34 | , and Greg Dennis . 35 | 36 | All rights reserved. 37 | 38 | Redistribution and use in source and binary forms, with or without modification, 39 | are permitted provided that the following conditions are met: 40 | 41 | 1. Redistributions of source code must retain the above copyright notice, this 42 | list of conditions and the following disclaimer. 43 | 44 | 2. Redistributions in binary form must reproduce the above copyright notice, 45 | this list of conditions and the following disclaimer in the documentation 46 | and/or other materials provided with the distribution. 47 | 48 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 49 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 50 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 51 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 52 | ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 53 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 54 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 55 | ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 56 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 57 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -------------------------------------------------------------------------------- /dist/node/README.md: -------------------------------------------------------------------------------- 1 | [![npm](https://img.shields.io/npm/v/json-schema-typed.svg?style=flat-square)](https://npmjs.org/package/json-schema-typed) 2 | [![downloads-per-month](https://img.shields.io/npm/dm/json-schema-typed.svg?style=flat-square&label=npm%20downloads)](https://npmjs.org/package/json-schema-typed) 3 | [![License](https://img.shields.io/badge/license-BSD--2--Clause-blue.svg?style=flat-square)][license] 4 | 5 | # JSON Schema Typed 6 | 7 | JSON Schema TypeScript definitions with complete inline documentation. 8 | 9 | **NOTE:** This library only supports defining schemas. You will need a separate 10 | library for data validation. 11 | 12 | There are 3 JSON Schema drafts included in this package: 13 | 14 | - `draft-07` 15 | - `draft-2019-09` 16 | - `draft-2020-12` 17 | 18 | ## Install 19 | 20 | ```sh 21 | npm install json-schema-typed 22 | ``` 23 | 24 | ## Usage 25 | 26 | 1. Chose which draft you'd like to import. 27 | 28 | - The main package export points to the latest supported stable draft, currently 29 | `draft-2020-12`. Future releases that point the main package export to a new 30 | draft will always incur a bump to the major semantic version. 31 | 32 | ```ts 33 | import { type JSONSchema } from "json-schema-typed"; 34 | ``` 35 | 36 | - Or you can specify the exact draft you need. 37 | ```ts 38 | import { type JSONSchema } from "json-schema-typed/draft-2020-12"; 39 | ``` 40 | 41 | 2. Define a schema 42 | 43 | ```ts 44 | import { Format, type JSONSchema } from "json-schema-typed"; 45 | 46 | const schema: JSONSchema = { 47 | properties: { 48 | email: { 49 | format: Format.Email, 50 | type: "string", 51 | }, 52 | }, 53 | type: "object", 54 | }; 55 | 56 | // The JSONSchema namespace also provides type-specific narrowed interfaces 57 | const stringSchema: JSONSchema.String = { 58 | // Only { type: "string" } and common keywords are allowed 59 | maxLength: 100, 60 | type: "string", 61 | }; 62 | ``` 63 | 64 | ## Upgrading 65 | 66 | Version `8.0.0` has breaking changes from the previous release. 67 | 68 | - Now a 69 | [pure ESM package](https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c). 70 | - Many exports were renamed. The table below reflects the new export names. 71 | These are considered final and unlikely to change in future releases. 72 | - The `JSONSchema` type was changed from an `interface` to a `type` which is a 73 | mixed union that allows `boolean` values in order to properly align with the 74 | JSON Schema spec. If you were previously extending the `JSONSchema` interface, 75 | you can access the `interface` directly with `JSONSchema.Interface`. 76 | - The previous main package export pointed to Draft 7. Import it directly if you 77 | need to continue using it: 78 | ```ts 79 | import { type JSONSchema } from "json-schema-typed/draft-07"; 80 | ``` 81 | 82 | ## Exports supported in each draft module 83 | 84 | | Name | Type | Purpose | 85 | | ----------------- | --------------- | ------------------------------------------------------------------ | 86 | | `$schema` | `string` | Draft meta schema URL that can be used with the `$schema` keyword. | 87 | | `ContentEncoding` | Enum object | String content encoding strategies. | 88 | | `draft` | `string` | Draft version. | 89 | | `Format` | Enum object | String formats. | 90 | | `JSONSchema` | TypeScript Type | Used to define a JSON Schema. | 91 | | `keywords` | `string[]` | All the keywords for the imported draft. | 92 | | `TypeName` | Enum object | Simple type names for the `type` keyword. | 93 | 94 | ## Versioning 95 | 96 | This library follows [semantic versioning](https://semver.org). 97 | 98 | --- 99 | 100 | ## Maintainers 101 | 102 | - [Jeremy Rylan](https://github.com/jrylan) 103 | 104 | ## License 105 | 106 | [BSD-2-Clause][license] 107 | 108 | [license]: https://github.com/jrylan/json-schema-typed/blob/main/dist/node/LICENSE.md 109 | -------------------------------------------------------------------------------- /dist/node/draft-07.js: -------------------------------------------------------------------------------- 1 | /// 2 | // @generated 3 | // deno-fmt-ignore-file 4 | // deno-lint-ignore-file 5 | // This code was bundled using `deno bundle` and it's not recommended to edit it manually 6 | 7 | const draft = "7"; 8 | const $schema = "https://json-schema.org/draft-07/schema"; 9 | var ContentEncoding; 10 | (function(ContentEncoding1) { 11 | ContentEncoding1["7bit"] = "7bit"; 12 | ContentEncoding1["8bit"] = "8bit"; 13 | ContentEncoding1["Base64"] = "base64"; 14 | ContentEncoding1["Binary"] = "binary"; 15 | ContentEncoding1["IETFToken"] = "ietf-token"; 16 | ContentEncoding1["QuotedPrintable"] = "quoted-printable"; 17 | ContentEncoding1["XToken"] = "x-token"; 18 | })(ContentEncoding || (ContentEncoding = {})); 19 | var Format; 20 | (function(Format1) { 21 | Format1["Date"] = "date"; 22 | Format1["DateTime"] = "date-time"; 23 | Format1["Email"] = "email"; 24 | Format1["Hostname"] = "hostname"; 25 | Format1["IDNEmail"] = "idn-email"; 26 | Format1["IDNHostname"] = "idn-hostname"; 27 | Format1["IPv4"] = "ipv4"; 28 | Format1["IPv6"] = "ipv6"; 29 | Format1["IRI"] = "iri"; 30 | Format1["IRIReference"] = "iri-reference"; 31 | Format1["JSONPointer"] = "json-pointer"; 32 | Format1["JSONPointerURIFragment"] = "json-pointer-uri-fragment"; 33 | Format1["RegEx"] = "regex"; 34 | Format1["RelativeJSONPointer"] = "relative-json-pointer"; 35 | Format1["Time"] = "time"; 36 | Format1["URI"] = "uri"; 37 | Format1["URIReference"] = "uri-reference"; 38 | Format1["URITemplate"] = "uri-template"; 39 | Format1["UUID"] = "uuid"; 40 | })(Format || (Format = {})); 41 | var TypeName; 42 | (function(TypeName1) { 43 | TypeName1["Array"] = "array"; 44 | TypeName1["Boolean"] = "boolean"; 45 | TypeName1["Integer"] = "integer"; 46 | TypeName1["Null"] = "null"; 47 | TypeName1["Number"] = "number"; 48 | TypeName1["Object"] = "object"; 49 | TypeName1["String"] = "string"; 50 | })(TypeName || (TypeName = {})); 51 | const keywords = [ 52 | "$comment", 53 | "$id", 54 | "$ref", 55 | "$schema", 56 | "additionalItems", 57 | "additionalProperties", 58 | "allOf", 59 | "anyOf", 60 | "const", 61 | "contains", 62 | "contentEncoding", 63 | "contentMediaType", 64 | "default", 65 | "definitions", 66 | "dependencies", 67 | "description", 68 | "else", 69 | "enum", 70 | "examples", 71 | "exclusiveMaximum", 72 | "exclusiveMinimum", 73 | "format", 74 | "if", 75 | "items", 76 | "maximum", 77 | "maxItems", 78 | "maxLength", 79 | "maxProperties", 80 | "minimum", 81 | "minItems", 82 | "minLength", 83 | "minProperties", 84 | "multipleOf", 85 | "not", 86 | "oneOf", 87 | "pattern", 88 | "patternProperties", 89 | "properties", 90 | "propertyNames", 91 | "readOnly", 92 | "required", 93 | "then", 94 | "title", 95 | "type", 96 | "uniqueItems", 97 | "writeOnly", 98 | ]; 99 | export { draft as draft }; 100 | export { $schema as $schema }; 101 | export { ContentEncoding as ContentEncoding }; 102 | export { Format as Format }; 103 | export { TypeName as TypeName }; 104 | export { keywords as keywords }; 105 | 106 | //# sourceMappingURL=draft-07.js.map -------------------------------------------------------------------------------- /dist/node/draft-07.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"sources":["draft-07.ts"],"names":[],"mappings":";;;;AAqCO,KAAK,CAAC,KAAK,GAAG,CAAG;AACjB,KAAK,CAAC,OAAO,GAAG,CAAyC;;UAyyBpD,gBAAe;IAAf,gBAAe,CAMzB,CAAM,SAAG,CAAM;IANL,gBAAe,CAczB,CAAM,SAAG,CAAM;IAdL,gBAAe,CAmBzB,CAAM,WAAG,CAAQ;IAnBP,gBAAe,CAwBzB,CAAM,WAAG,CAAQ;IAxBP,gBAAe,CA8BzB,CAAS,cAAG,CAAY;IA9Bd,gBAAe,CAoCzB,CAAe,oBAAG,CAAkB;IApC1B,gBAAe,CA0CzB,CAAM,WAAG,CAAS;GA1CR,eAAe,KAAf,eAAe;;UAgDf,OAAM;IAAN,OAAM,CAQhB,CAAI,SAAG,CAAM;IARH,OAAM,CAiBhB,CAAQ,aAAG,CAAW;IAjBZ,OAAM,CAyBhB,CAAK,UAAG,CAAO;IAzBL,OAAM,CAmChB,CAAQ,aAAG,CAAU;IAnCX,OAAM,CA2ChB,CAAQ,aAAG,CAAW;IA3CZ,OAAM,CAqDhB,CAAW,gBAAG,CAAc;IArDlB,OAAM,CA6DhB,CAAI,SAAG,CAAM;IA7DH,OAAM,CAoEhB,CAAI,SAAG,CAAM;IApEH,OAAM,CA4EhB,CAAG,QAAG,CAAK;IA5ED,OAAM,CAqFhB,CAAY,iBAAG,CAAe;IArFpB,OAAM,CA8FhB,CAAW,gBAAG,CAAc;IA9FlB,OAAM,CAuGhB,CAAsB,2BAAG,CAA2B;IAvG1C,OAAM,CAuHhB,CAAK,UAAG,CAAO;IAvHL,OAAM,CA+HhB,CAAmB,wBAAG,CAAuB;IA/HnC,OAAM,CAuIhB,CAAI,SAAG,CAAM;IAvIH,OAAM,CA+IhB,CAAG,QAAG,CAAK;IA/ID,OAAM,CAwJhB,CAAY,iBAAG,CAAe;IAxJpB,OAAM,CAmKhB,CAAW,gBAAG,CAAc;IAnKlB,OAAM,CAwKhB,CAAI,SAAG,CAAM;GAxKH,MAAM,KAAN,MAAM;;UA8KN,SAAQ;IAAR,SAAQ,CAIlB,CAAK,UAAG,CAAO;IAJL,SAAQ,CASlB,CAAO,YAAG,CAAS;IATT,SAAQ,CAelB,CAAO,YAAG,CAAS;IAfT,SAAQ,CAuBlB,CAAI,SAAG,CAAM;IAvBH,SAAQ,CA4BlB,CAAM,WAAG,CAAQ;IA5BP,SAAQ,CAiClB,CAAM,WAAG,CAAQ;IAjCP,SAAQ,CAsClB,CAAM,WAAG,CAAQ;GAtCP,QAAQ,KAAR,QAAQ;AA6Cb,KAAK,CAAC,QAAQ,GAAG,CAAC;IACvB,CAAU;IACV,CAAK;IACL,CAAM;IACN,CAAS;IACT,CAAiB;IACjB,CAAsB;IACtB,CAAO;IACP,CAAO;IACP,CAAO;IACP,CAAU;IACV,CAAiB;IACjB,CAAkB;IAClB,CAAS;IACT,CAAa;IACb,CAAc;IACd,CAAa;IACb,CAAM;IACN,CAAM;IACN,CAAU;IACV,CAAkB;IAClB,CAAkB;IAClB,CAAQ;IACR,CAAI;IACJ,CAAO;IACP,CAAS;IACT,CAAU;IACV,CAAW;IACX,CAAe;IACf,CAAS;IACT,CAAU;IACV,CAAW;IACX,CAAe;IACf,CAAY;IACZ,CAAK;IACL,CAAO;IACP,CAAS;IACT,CAAmB;IACnB,CAAY;IACZ,CAAe;IACf,CAAU;IACV,CAAU;IACV,CAAM;IACN,CAAO;IACP,CAAM;IACN,CAAa;IACb,CAAW;AACb,CAAC;AApmCD,MAAM,GAAO,KAAK,IAAL,KAAK;AAClB,MAAM,GAAO,OAAO,IAAP,OAAO;;;;AAojCpB,MAAM,GAAO,QAAQ,IAAR,QAAQ"} -------------------------------------------------------------------------------- /dist/node/draft-07.ts: -------------------------------------------------------------------------------- 1 | // @generated 2 | // This code is automatically generated. Manual editing is not recommended. 3 | 4 | /* 5 | * BSD-2-Clause License 6 | * 7 | * Original source code is copyright (c) 2019-2022 Jeremy Rylan 8 | * 9 | * 10 | * Documentation and keyword descriptions are copyright (c) 2018 IETF Trust 11 | * , Austin Wright , Henry Andrews 12 | * , Geraint Luff , and Cloudflare, 13 | * Inc. . All rights reserved. 14 | * 15 | * Redistribution and use in source and binary forms, with or without 16 | * modification, are permitted provided that the following conditions are met: 17 | * 18 | * 1. Redistributions of source code must retain the above copyright notice, 19 | * this list of conditions and the following disclaimer. 20 | * 21 | * 2. Redistributions in binary form must reproduce the above copyright notice, 22 | * this list of conditions and the following disclaimer in the documentation 23 | * and/or other materials provided with the distribution. 24 | * 25 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 26 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 27 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 28 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 29 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 30 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 31 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 32 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 33 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 34 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 35 | * POSSIBILITY OF SUCH DAMAGE. 36 | */ 37 | 38 | export const draft = "7" as const; 39 | export const $schema = "https://json-schema.org/draft-07/schema" as const; 40 | 41 | type MaybeReadonlyArray = Array | ReadonlyArray; 42 | type ValueOf = T[keyof T]; 43 | 44 | /** 45 | * JSON Schema [Draft 7](https://json-schema.org/draft-07/json-schema-validation.html) 46 | */ 47 | export type JSONSchema< 48 | Value = any, 49 | SchemaType = Value extends boolean ? "boolean" 50 | : Value extends null ? "null" 51 | : Value extends number ? "number" | "integer" 52 | : Value extends string ? "string" 53 | : Value extends unknown[] ? "array" 54 | : Value extends Record ? "object" 55 | : JSONSchema.TypeValue, 56 | > = boolean | { 57 | /** 58 | * This keyword is reserved for comments from schema authors to readers or 59 | * maintainers of the schema. The value of this keyword MUST be a string. 60 | * Implementations MUST NOT present this string to end users. Tools for 61 | * editing schemas SHOULD support displaying and editing this keyword. 62 | * 63 | * The value of this keyword MAY be used in debug or error output which is 64 | * intended for developers making use of schemas. Schema vocabularies 65 | * SHOULD allow `comment` within any object containing vocabulary 66 | * keywords. 67 | * 68 | * Implementations MAY assume `comment` is allowed unless the vocabulary 69 | * specifically forbids it. Vocabularies MUST NOT specify any effect of 70 | * `comment` beyond what is described in this specification. Tools that 71 | * translate other media types or programming languages to and from 72 | * `application/schema+json` MAY choose to convert that media type or 73 | * programming language's native comments to or from `comment` values. 74 | * 75 | * The behavior of such translation when both native comments and 76 | * `comment` properties are present is implementation-dependent. 77 | * Implementations SHOULD treat `comment` identically to an unknown 78 | * extension keyword. 79 | * 80 | * They MAY strip `comment` values at any point during processing. In 81 | * particular, this allows for shortening schemas when the size of deployed 82 | * schemas is a concern. Implementations MUST NOT take any other action 83 | * based on the presence, absence, or contents of `comment` properties. 84 | */ 85 | $comment?: string; 86 | 87 | /** 88 | * The `$id` keyword defines a URI for the schema, and the base URI that 89 | * other URI references within the schema are resolved against. A 90 | * subschema's `$id` is resolved against the base URI of its parent 91 | * schema. If no parent sets an explicit base with `$id`, the base URI is 92 | * that of the entire document, as determined per 93 | * [RFC 3986 section 5][RFC3986]. 94 | * 95 | * If present, the value for this keyword MUST be a string, and MUST 96 | * represent a valid [URI-reference][RFC3986]. This value SHOULD be 97 | * normalized, and SHOULD NOT be an empty fragment `#` or an empty string. 98 | * 99 | * [RFC3986]: https://datatracker.ietf.org/doc/html/rfc3986 100 | * 101 | * @format "uri-reference" 102 | */ 103 | $id?: string; 104 | 105 | /** 106 | * The `$ref` keyword is used to reference a schema, and provides the 107 | * ability to validate recursive structures through self-reference. 108 | * 109 | * An object schema with a `$ref` property MUST be interpreted as a 110 | * `$ref` reference. The value of the `$ref` property MUST be a URI 111 | * Reference. Resolved against the current URI base, it identifies the URI 112 | * of a schema to use. All other properties in a `$ref` object MUST be 113 | * ignored. 114 | * 115 | * The URI is not a network locator, only an identifier. A schema need not 116 | * be downloadable from the address if it is a network-addressable URL, and 117 | * implementations SHOULD NOT assume they should perform a network 118 | * operation when they encounter a network-addressable URI. 119 | * 120 | * A schema MUST NOT be run into an infinite loop against a schema. For 121 | * example, if two schemas `"#alice"` and `"#bob"` both have an 122 | * `allOf` property that refers to the other, a naive validator might get 123 | * stuck in an infinite recursive loop trying to validate the instance. 124 | * Schemas SHOULD NOT make use of infinite recursive nesting like this; the 125 | * behavior is undefined. 126 | * 127 | * @format "uri-reference" 128 | */ 129 | $ref?: string; 130 | 131 | /** 132 | * The `$schema` keyword is both used as a JSON Schema version identifier 133 | * and the location of a resource which is itself a JSON Schema, which 134 | * describes any schema written for this particular version. 135 | * 136 | * The value of this keyword MUST be a [URI][RFC3986] (containing a scheme) 137 | * and this URI MUST be normalized. The current schema MUST be valid 138 | * against the meta-schema identified by this URI. 139 | * 140 | * If this URI identifies a retrievable resource, that resource SHOULD be 141 | * of media type `application/schema+json`. 142 | * 143 | * The `$schema` keyword SHOULD be used in a root schema. It MUST NOT 144 | * appear in subschemas. 145 | * 146 | * Values for this property are defined in other documents and by other 147 | * parties. JSON Schema implementations SHOULD implement support for 148 | * current and previous published drafts of JSON Schema vocabularies as 149 | * deemed reasonable. 150 | * 151 | * [RFC3986]: https://datatracker.ietf.org/doc/html/rfc3986 152 | * 153 | * @format "uri" 154 | */ 155 | $schema?: string; 156 | 157 | /** 158 | * The value of `additionalItems` MUST be a valid JSON Schema. 159 | * 160 | * This keyword determines how child instances validate for arrays, and 161 | * does not directly validate the immediate instance itself. 162 | * 163 | * If `items` is an array of schemas, validation succeeds if every 164 | * instance element at a position greater than the size of `items` 165 | * validates against `additionalItems`. 166 | * 167 | * Otherwise, `additionalItems` MUST be ignored, as the `items` schema 168 | * (possibly the default value of an empty schema) is applied to all 169 | * elements. 170 | * 171 | * Omitting this keyword has the same behavior as an empty schema. 172 | */ 173 | additionalItems?: JSONSchema; 174 | 175 | /** 176 | * The value of `additionalProperties` MUST be a valid JSON Schema. 177 | * 178 | * This keyword determines how child instances validate for objects, and 179 | * does not directly validate the immediate instance itself. 180 | * 181 | * Validation with `additionalProperties` applies only to the child 182 | * values of instance names that do not match any names in `properties`, 183 | * and do not match any regular expression in `patternProperties`. 184 | * 185 | * For all such properties, validation succeeds if the child instance 186 | * validates against the `additionalProperties` schema. 187 | * 188 | * Omitting this keyword has the same behavior as an empty schema. 189 | */ 190 | additionalProperties?: JSONSchema; 191 | 192 | /** 193 | * This keyword's value MUST be a non-empty array. Each item of the array 194 | * MUST be a valid JSON Schema. 195 | * 196 | * An instance validates successfully against this keyword if it validates 197 | * successfully against all schemas defined by this keyword's value. 198 | */ 199 | allOf?: MaybeReadonlyArray>; 200 | 201 | /** 202 | * This keyword's value MUST be a non-empty array. Each item of the array 203 | * MUST be a valid JSON Schema. 204 | * 205 | * An instance validates successfully against this keyword if it validates 206 | * successfully against at least one schema defined by this keyword's 207 | * value. 208 | */ 209 | anyOf?: MaybeReadonlyArray>; 210 | 211 | /** 212 | * An instance validates successfully against this keyword if its value is 213 | * equal to the value of the keyword. 214 | * 215 | * Use of this keyword is functionally equivalent to the `enum` keyword 216 | * with a single value. 217 | */ 218 | const?: Value; 219 | 220 | /** 221 | * The value of this keyword MUST be a valid JSON Schema. 222 | * 223 | * An array instance is valid against `contains` if at least one of its 224 | * elements is valid against the given schema. 225 | */ 226 | contains?: JSONSchema; 227 | 228 | /** 229 | * If the instance value is a string, this property defines that the 230 | * string SHOULD be interpreted as binary data and decoded using the 231 | * encoding named by this property. [RFC 2045, Sec 6.1][RFC2045] lists the 232 | * possible values for this property. 233 | * 234 | * The value of this property SHOULD be ignored if the instance described 235 | * is not a string. 236 | * 237 | * [RFC2045]: https://datatracker.ietf.org/doc/html/rfc2045#section-6.1 238 | */ 239 | contentEncoding?: 240 | | "7bit" 241 | | "8bit" 242 | | "base64" 243 | | "binary" 244 | | "ietf-token" 245 | | "quoted-printable" 246 | | "x-token"; 247 | 248 | /** 249 | * The value of this property must be a media type, as defined by 250 | * [RFC 2046][RFC2046]. This property defines the media type of instances 251 | * which this schema defines. 252 | * 253 | * The value of this property SHOULD be ignored if the instance described 254 | * is not a string. 255 | * 256 | * If the `contentEncoding` property is not present, but the instance 257 | * value is a string, then the value of this property SHOULD specify a text 258 | * document type, and the character set SHOULD be the character set into 259 | * which the JSON string value was decoded (for which the default is 260 | * Unicode). 261 | * 262 | * [RFC2046]: https://datatracker.ietf.org/doc/html/rfc2046 263 | */ 264 | contentMediaType?: string; 265 | 266 | /** 267 | * This keyword can be used to supply a default JSON value associated with 268 | * a particular schema. It is RECOMMENDED that a `default` value be valid 269 | * against the associated schema. 270 | */ 271 | default?: Value; 272 | 273 | /** 274 | * The `definitions` keywords provides a standardized location for schema 275 | * authors to inline re-usable JSON Schemas into a more general schema. The 276 | * keyword does not directly affect the validation result. 277 | * 278 | * This keyword's value MUST be an object. Each member value of this object 279 | * MUST be a valid JSON Schema. 280 | */ 281 | definitions?: Record; 282 | 283 | /** 284 | * This keyword specifies rules that are evaluated if the instance is an 285 | * object and contains a certain property. 286 | * 287 | * This keyword's value MUST be an object. Each property specifies a 288 | * dependency. Each dependency value MUST be an array or a valid JSON 289 | * Schema. 290 | * 291 | * If the dependency value is a subschema, and the dependency key is a 292 | * property in the instance, the entire instance must validate against the 293 | * dependency value. 294 | * 295 | * If the dependency value is an array, each element in the array, if any, 296 | * MUST be a string, and MUST be unique. If the dependency key is a 297 | * property in the instance, each of the items in the dependency value must 298 | * be a property that exists in the instance. 299 | * 300 | * Omitting this keyword has the same behavior as an empty object. 301 | */ 302 | dependencies?: Record | JSONSchema>; 303 | 304 | /** 305 | * Can be used to decorate a user interface with explanation or information 306 | * about the data produced. 307 | */ 308 | description?: string; 309 | 310 | /** 311 | * This keyword's value MUST be a valid JSON Schema. 312 | * 313 | * When `if` is present, and the instance fails to validate against its 314 | * subschema, then validation succeeds against this keyword if the instance 315 | * successfully validates against this keyword's subschema. 316 | * 317 | * This keyword has no effect when `if` is absent, or when the instance 318 | * successfully validates against its subschema. Implementations MUST NOT 319 | * evaluate the instance against this keyword, for either validation or 320 | * annotation collection purposes, in such cases. 321 | */ 322 | else?: JSONSchema; 323 | 324 | /** 325 | * The value of this keyword MUST be an array. This array SHOULD have at 326 | * least one element. Elements in the array SHOULD be unique. 327 | * 328 | * An instance validates successfully against this keyword if its value is 329 | * equal to one of the elements in this keyword's array value. 330 | * 331 | * Elements in the array might be of any type, including `null`. 332 | */ 333 | enum?: MaybeReadonlyArray; 334 | 335 | /** 336 | * The value of this keyword MUST be an array. When multiple occurrences of 337 | * this keyword are applicable to a single sub-instance, implementations 338 | * MUST provide a flat array of all values rather than an array of arrays. 339 | * 340 | * This keyword can be used to provide sample JSON values associated with a 341 | * particular schema, for the purpose of illustrating usage. It is 342 | * RECOMMENDED that these values be valid against the associated schema. 343 | * 344 | * Implementations MAY use the value(s) of `default`, if present, as an 345 | * additional example. If `examples` is absent, `default` MAY still be 346 | * used in this manner. 347 | */ 348 | examples?: MaybeReadonlyArray; 349 | 350 | /** 351 | * The value of `exclusiveMaximum` MUST be a number, representing an 352 | * exclusive upper limit for a numeric instance. 353 | * 354 | * If the instance is a number, then the instance is valid only if it has a 355 | * value strictly less than (not equal to) `exclusiveMaximum`. 356 | */ 357 | exclusiveMaximum?: number; 358 | 359 | /** 360 | * The value of `exclusiveMinimum` MUST be a number, representing an 361 | * exclusive lower limit for a numeric instance. 362 | * 363 | * If the instance is a number, then the instance is valid only if it has a 364 | * value strictly greater than (not equal to) `exclusiveMinimum`. 365 | */ 366 | exclusiveMinimum?: number; 367 | 368 | /** 369 | * The `format` keyword functions as both an [annotation][annotation] and 370 | * as an [assertion][assertion]. While no special effort is required to 371 | * implement it as an annotation conveying semantic meaning, implementing 372 | * validation is non-trivial. 373 | * 374 | * Implementations MAY support the `format` keyword as a validation 375 | * assertion. 376 | * 377 | * Implementations MAY add custom `format` attributes. Save for agreement 378 | * between parties, schema authors SHALL NOT expect a peer implementation 379 | * to support this keyword and/or custom `format` attributes. 380 | * 381 | * [annotation]: https://json-schema.org/draft-07/json-schema-validation.html#annotations 382 | * [assertion]: https://json-schema.org/draft-07/json-schema-validation.html#assertions 383 | */ 384 | format?: string; 385 | 386 | /** 387 | * This keyword's value MUST be a valid JSON Schema. 388 | * 389 | * This validation outcome of this keyword's subschema has no direct effect 390 | * on the overall validation result. Rather, it controls which of the 391 | * `then` or `else` keywords are evaluated. 392 | * 393 | * Instances that successfully validate against this keyword's subschema 394 | * MUST also be valid against the subschema value of the `then` keyword, 395 | * if present. 396 | * 397 | * Instances that fail to validate against this keyword's subschema MUST 398 | * also be valid against the subschema value of the `else` keyword, if 399 | * present. 400 | * 401 | * If [annotations][annotations] are being collected, they are collected 402 | * from this keyword's subschema in the usual way, including when the 403 | * keyword is present without either `then` or `else`. 404 | * 405 | * [annotations]: https://json-schema.org/draft-07/json-schema-validation.html#annotations 406 | */ 407 | if?: JSONSchema; 408 | 409 | /** 410 | * The value of `items` MUST be either a valid JSON Schema or an array of 411 | * valid JSON Schemas. 412 | * 413 | * This keyword determines how child instances validate for arrays, and 414 | * does not directly validate the immediate instance itself. 415 | * 416 | * If `items` is a schema, validation succeeds if all elements in the 417 | * array successfully validate against that schema. 418 | * 419 | * If `items` is an array of schemas, validation succeeds if each element 420 | * of the instance validates against the schema at the same position, if 421 | * any. 422 | * 423 | * Omitting this keyword has the same behavior as an empty schema. 424 | */ 425 | items?: MaybeReadonlyArray | JSONSchema; 426 | 427 | /** 428 | * The value of `maximum` MUST be a number, representing an inclusive 429 | * upper limit for a numeric instance. 430 | * 431 | * If the instance is a number, then this keyword validates only if the 432 | * instance is less than or exactly equal to `maximum`. 433 | */ 434 | maximum?: number; 435 | 436 | /** 437 | * The value of this keyword MUST be a non-negative integer. 438 | * 439 | * An array instance is valid against `maxItems` if its size is less 440 | * than, or equal to, the value of this keyword. 441 | * 442 | * @minimum 0 443 | */ 444 | maxItems?: number; 445 | 446 | /** 447 | * The value of this keyword MUST be a non-negative integer. 448 | * 449 | * A string instance is valid against this keyword if its length is less 450 | * than, or equal to, the value of this keyword. 451 | * 452 | * The length of a string instance is defined as the number of its 453 | * characters as defined by [RFC 7159][RFC7159]. 454 | * 455 | * [RFC7159]: https://datatracker.ietf.org/doc/html/rfc7159 456 | * 457 | * @minimum 0 458 | */ 459 | maxLength?: number; 460 | 461 | /** 462 | * The value of this keyword MUST be a non-negative integer. 463 | * 464 | * An object instance is valid against `maxProperties` if its number of 465 | * `properties` is less than, or equal to, the value of this keyword. 466 | * 467 | * @minimum 0 468 | */ 469 | maxProperties?: number; 470 | 471 | /** 472 | * The value of `minimum` MUST be a number, representing an inclusive 473 | * lower limit for a numeric instance. 474 | * 475 | * If the instance is a number, then this keyword validates only if the 476 | * instance is greater than or exactly equal to `minimum`. 477 | */ 478 | minimum?: number; 479 | 480 | /** 481 | * The value of this keyword MUST be a non-negative integer. 482 | * 483 | * An array instance is valid against `minItems` if its size is greater 484 | * than, or equal to, the value of this keyword. 485 | * 486 | * Omitting this keyword has the same behavior as a value of `0`. 487 | * 488 | * @default 0 489 | * @minimum 0 490 | */ 491 | minItems?: number; 492 | 493 | /** 494 | * The value of this keyword MUST be a non-negative integer. 495 | * 496 | * A string instance is valid against this keyword if its length is greater 497 | * than, or equal to, the value of this keyword. 498 | * 499 | * The length of a string instance is defined as the number of its 500 | * characters as defined by [RFC 7159][RFC7159]. 501 | * 502 | * Omitting this keyword has the same behavior as a value of `0`. 503 | * 504 | * [RFC7159]: https://datatracker.ietf.org/doc/html/rfc7159 505 | * 506 | * @default 0 507 | * @minimum 0 508 | */ 509 | minLength?: number; 510 | 511 | /** 512 | * The value of this keyword MUST be a non-negative integer. 513 | * 514 | * An object instance is valid against `minProperties` if its number of 515 | * `properties` is greater than, or equal to, the value of this keyword. 516 | * 517 | * Omitting this keyword has the same behavior as a value of `0`. 518 | * 519 | * @default 0 520 | * @minimum 0 521 | */ 522 | minProperties?: number; 523 | 524 | /** 525 | * The value of `multipleOf` MUST be a number, strictly greater than 526 | * `0`. 527 | * 528 | * A numeric instance is valid only if division by this keyword's value 529 | * results in an integer. 530 | * 531 | * @exclusiveMinimum 0 532 | */ 533 | multipleOf?: number; 534 | 535 | /** 536 | * This keyword's value MUST be a valid JSON Schema. 537 | * 538 | * An instance is valid against this keyword if it fails to validate 539 | * successfully against the schema defined by this keyword. 540 | */ 541 | not?: JSONSchema; 542 | 543 | /** 544 | * This keyword's value MUST be a non-empty array. Each item of the array 545 | * MUST be a valid JSON Schema. 546 | * 547 | * An instance validates successfully against this keyword if it validates 548 | * successfully against exactly one schema defined by this keyword's value. 549 | */ 550 | oneOf?: MaybeReadonlyArray>; 551 | 552 | /** 553 | * The value of this keyword MUST be a string. This string SHOULD be a 554 | * valid regular expression, according to the [ECMA-262][ecma262] regular 555 | * expression dialect. 556 | * 557 | * A string instance is considered valid if the regular expression matches 558 | * the instance successfully. Recall: regular expressions are not 559 | * implicitly anchored. 560 | * 561 | * [ecma262]: https://www.ecma-international.org/publications-and-standards/standards/ecma-262/ 562 | * 563 | * @format "regex" 564 | */ 565 | pattern?: string; 566 | 567 | /** 568 | * The value of `patternProperties` MUST be an object. Each property name 569 | * of this object SHOULD be a valid regular expression, according to the 570 | * [ECMA-262][ecma262] regular expression dialect. Each property value of 571 | * this object MUST be a valid JSON Schema. 572 | * 573 | * This keyword determines how child instances validate for objects, and 574 | * does not directly validate the immediate instance itself. Validation of 575 | * the primitive instance type against this keyword always succeeds. 576 | * 577 | * Validation succeeds if, for each instance name that matches any regular 578 | * expressions that appear as a property name in this keyword's value, the 579 | * child instance for that name successfully validates against each schema 580 | * that corresponds to a matching regular expression. 581 | * 582 | * Omitting this keyword has the same behavior as an empty object. 583 | * 584 | * [ecma262]: https://www.ecma-international.org/publications-and-standards/standards/ecma-262/ 585 | */ 586 | patternProperties?: Record; 587 | 588 | /** 589 | * The value of `properties` MUST be an object. Each value of this object 590 | * MUST be a valid JSON Schema. 591 | * 592 | * This keyword determines how child instances validate for objects, and 593 | * does not directly validate the immediate instance itself. 594 | * 595 | * Validation succeeds if, for each name that appears in both the instance 596 | * and as a name within this keyword's value, the child instance for that 597 | * name successfully validates against the corresponding schema. 598 | * 599 | * Omitting this keyword has the same behavior as an empty object. 600 | */ 601 | properties?: Record; 602 | 603 | /** 604 | * The value of `propertyNames` MUST be a valid JSON Schema. 605 | * 606 | * If the instance is an object, this keyword validates if every property 607 | * name in the instance validates against the provided schema. Note the 608 | * property name that the schema is testing will always be a string. 609 | * 610 | * Omitting this keyword has the same behavior as an empty schema. 611 | */ 612 | propertyNames?: JSONSchema; 613 | 614 | /** 615 | * The value of this keyword MUST be a boolean. When multiple occurrences 616 | * of this keyword are applicable to a single sub-instance, the resulting 617 | * value MUST be `true` if any occurrence specifies a `true` value, and 618 | * MUST be `false` otherwise. 619 | * 620 | * If `readOnly` has a value of boolean `true`, it indicates that the 621 | * value of the instance is managed exclusively by the owning authority, 622 | * and attempts by an application to modify the value of this property are 623 | * expected to be ignored or rejected by that owning authority. 624 | * 625 | * An instance document that is marked as `readOnly` for the entire 626 | * document MAY be ignored if sent to the owning authority, or MAY result 627 | * in an error, at the authority's discretion. 628 | * 629 | * For example, `readOnly` would be used to mark a database-generated 630 | * serial number as read-only. 631 | * 632 | * This keyword can be used to assist in user interface instance 633 | * generation. 634 | * 635 | * @default false 636 | */ 637 | readOnly?: boolean; 638 | 639 | /** 640 | * The value of this keyword MUST be an array. Elements of this array, if 641 | * any, MUST be strings, and MUST be unique. 642 | * 643 | * An object instance is valid against this keyword if every item in the 644 | * array is the name of a property in the instance. 645 | * 646 | * Omitting this keyword has the same behavior as an empty array. 647 | */ 648 | required?: MaybeReadonlyArray; 649 | 650 | /** 651 | * This keyword's value MUST be a valid JSON Schema. 652 | * 653 | * When `if` is present, and the instance successfully validates against 654 | * its subschema, then validation succeeds against this keyword if the 655 | * instance also successfully validates against this keyword's subschema. 656 | * 657 | * This keyword has no effect when `if` is absent, or when the instance 658 | * fails to validate against its subschema. Implementations MUST NOT 659 | * evaluate the instance against this keyword, for either validation or 660 | * annotation collection purposes, in such cases. 661 | */ 662 | then?: JSONSchema; 663 | 664 | /** 665 | * Can be used to decorate a user interface with a short label about the 666 | * data produced. 667 | */ 668 | title?: string; 669 | 670 | /** 671 | * The value of this keyword MUST be either a string or an array. If it is 672 | * an array, elements of the array MUST be strings and MUST be unique. 673 | * 674 | * String values MUST be one of the six primitive types (`"null"`, 675 | * `"boolean"`, `"object"`, `"array"`, `"number"`, or 676 | * `"string"`), or `"integer"` which matches any number with a zero 677 | * fractional part. 678 | * 679 | * An instance validates if and only if the instance is in any of the sets 680 | * listed for this keyword. 681 | */ 682 | type?: SchemaType; 683 | 684 | /** 685 | * The value of this keyword MUST be a boolean. 686 | * 687 | * If this keyword has boolean value `false`, the instance validates 688 | * successfully. If it has boolean value `true`, the instance validates 689 | * successfully if all of its elements are unique. 690 | * 691 | * Omitting this keyword has the same behavior as a value of `false`. 692 | * 693 | * @default false 694 | */ 695 | uniqueItems?: boolean; 696 | 697 | /** 698 | * The value of this keyword MUST be a boolean. When multiple occurrences 699 | * of this keyword is applicable to a single sub-instance, the resulting 700 | * value MUST be `true` if any occurrence specifies a `true` value, and 701 | * MUST be `false` otherwise. 702 | * 703 | * If `writeOnly` has a value of boolean `true`, it indicates that the 704 | * value is never present when the instance is retrieved from the owning 705 | * authority. It can be present when sent to the owning authority to update 706 | * or create the document (or the resource it represents), but it will not 707 | * be included in any updated or newly created version of the instance. 708 | * 709 | * An instance document that is marked as `writeOnly` for the entire 710 | * document MAY be returned as a blank document of some sort, or MAY 711 | * produce an error upon retrieval, or have the retrieval request ignored, 712 | * at the authority's discretion. 713 | * 714 | * For example, `writeOnly` would be used to mark a password input field. 715 | * 716 | * These keywords can be used to assist in user interface instance 717 | * generation. In particular, an application MAY choose to use a widget 718 | * that hides input values as they are typed for write-only fields. 719 | * 720 | * @default false 721 | */ 722 | writeOnly?: boolean; 723 | }; 724 | 725 | // ----------------------------------------------------------------------------- 726 | 727 | export namespace JSONSchema { 728 | export type TypeValue = ( 729 | | ValueOf 730 | | TypeName 731 | | Array | TypeName> 732 | | ReadonlyArray | TypeName> 733 | ); 734 | 735 | /** 736 | * JSON Schema interface 737 | */ 738 | export type Interface< 739 | Value = any, 740 | SchemaType extends TypeValue = TypeValue, 741 | > = Exclude< 742 | JSONSchema, 743 | boolean 744 | >; 745 | 746 | export type Array = Pick< 747 | Interface, 748 | KeywordByType.Any | KeywordByType.Array 749 | >; 750 | 751 | export type Boolean = Pick< 752 | Interface, 753 | KeywordByType.Any 754 | >; 755 | 756 | export type Integer = Pick< 757 | Interface, 758 | KeywordByType.Any | KeywordByType.Number 759 | >; 760 | 761 | export type Number = Pick< 762 | Interface, 763 | KeywordByType.Any | KeywordByType.Number 764 | >; 765 | 766 | export type Null = Pick< 767 | Interface, 768 | KeywordByType.Any 769 | >; 770 | 771 | export type Object = Pick< 772 | Interface, 773 | KeywordByType.Any | KeywordByType.Object 774 | >; 775 | 776 | export type String = Pick< 777 | Interface, 778 | KeywordByType.Any | KeywordByType.String 779 | >; 780 | } 781 | 782 | namespace KeywordByType { 783 | export type Any = 784 | | "$comment" 785 | | "$id" 786 | | "$ref" 787 | | "$schema" 788 | | "allOf" 789 | | "anyOf" 790 | | "const" 791 | | "default" 792 | | "definitions" 793 | | "description" 794 | | "else" 795 | | "enum" 796 | | "examples" 797 | | "if" 798 | | "not" 799 | | "oneOf" 800 | | "readOnly" 801 | | "then" 802 | | "title" 803 | | "type" 804 | | "writeOnly"; 805 | 806 | export type Array = 807 | | "additionalItems" 808 | | "contains" 809 | | "items" 810 | | "maxItems" 811 | | "minItems" 812 | | "uniqueItems"; 813 | 814 | export type Number = 815 | | "exclusiveMaximum" 816 | | "exclusiveMinimum" 817 | | "maximum" 818 | | "minimum" 819 | | "multipleOf"; 820 | 821 | export type Object = 822 | | "additionalProperties" 823 | | "dependencies" 824 | | "maxProperties" 825 | | "minProperties" 826 | | "patternProperties" 827 | | "properties" 828 | | "propertyNames" 829 | | "required"; 830 | 831 | export type String = 832 | | "contentEncoding" 833 | | "contentMediaType" 834 | | "format" 835 | | "maxLength" 836 | | "minLength" 837 | | "pattern"; 838 | } 839 | 840 | // ----------------------------------------------------------------------------- 841 | 842 | /** 843 | * Content encoding strategy enum. 844 | * 845 | * - [Content-Transfer-Encoding Syntax](https://datatracker.ietf.org/doc/html/rfc2045#section-6.1) 846 | * - [7bit vs 8bit encoding](https://stackoverflow.com/questions/25710599/content-transfer-encoding-7bit-or-8-bit/28531705#28531705) 847 | */ 848 | export enum ContentEncoding { 849 | /** 850 | * Only US-ASCII characters, which use the lower 7 bits for each character. 851 | * 852 | * Each line must be less than 1,000 characters. 853 | */ 854 | "7bit" = "7bit", 855 | 856 | /** 857 | * Allow extended ASCII characters which can use the 8th (highest) bit to 858 | * indicate special characters not available in 7bit. 859 | * 860 | * Each line must be less than 1,000 characters. 861 | */ 862 | "8bit" = "8bit", 863 | 864 | /** 865 | * Useful for data that is mostly non-text. 866 | */ 867 | Base64 = "base64", 868 | 869 | /** 870 | * Same character set as 8bit, with no line length restriction. 871 | */ 872 | Binary = "binary", 873 | 874 | /** 875 | * An extension token defined by a standards-track RFC and registered with 876 | * IANA. 877 | */ 878 | IETFToken = "ietf-token", 879 | 880 | /** 881 | * Lines are limited to 76 characters, and line breaks are represented using 882 | * special characters that are escaped. 883 | */ 884 | QuotedPrintable = "quoted-printable", 885 | 886 | /** 887 | * The two characters "X-" or "x-" followed, with no intervening white space, 888 | * by any token. 889 | */ 890 | XToken = "x-token", 891 | } 892 | 893 | /** 894 | * This enum provides well-known formats that apply to strings. 895 | */ 896 | export enum Format { 897 | /** 898 | * A string instance is valid against this attribute if it is a valid 899 | * representation according to the "full-date" production in 900 | * [RFC 3339][RFC3339]. 901 | * 902 | * [RFC3339]: https://datatracker.ietf.org/doc/html/rfc3339 903 | */ 904 | Date = "date", 905 | 906 | /** 907 | * A string instance is valid against this attribute if it is a valid 908 | * representation according to the "date-time" production in 909 | * [RFC 3339][RFC3339]. 910 | * 911 | * [RFC3339]: https://datatracker.ietf.org/doc/html/rfc3339 912 | */ 913 | DateTime = "date-time", 914 | 915 | /** 916 | * A string instance is valid against this attribute if it is a valid Internet 917 | * email address as defined by [RFC 5322, section 3.4.1][RFC5322]. 918 | * 919 | * [RFC5322]: https://datatracker.ietf.org/doc/html/rfc5322 920 | */ 921 | Email = "email", 922 | 923 | /** 924 | * As defined by [RFC 1034, section 3.1][RFC1034], including host names 925 | * produced using the Punycode algorithm specified in 926 | * [RFC 5891, section 4.4][RFC5891]. 927 | * 928 | * [RFC1034]: https://datatracker.ietf.org/doc/html/rfc1034 929 | * [RFC5891]: https://datatracker.ietf.org/doc/html/rfc5891 930 | */ 931 | Hostname = "hostname", 932 | 933 | /** 934 | * A string instance is valid against this attribute if it is a valid Internet 935 | * email address as defined by [RFC 6531][RFC6531]. 936 | * 937 | * [RFC6531]: https://datatracker.ietf.org/doc/html/rfc6531 938 | */ 939 | IDNEmail = "idn-email", 940 | 941 | /** 942 | * As defined by either [RFC 1034, section 3.1][RFC1034] as for hostname, or 943 | * an internationalized hostname as defined by 944 | * [RFC 5890, section 2.3.2.3][RFC5890]. 945 | * 946 | * [RFC1034]: https://datatracker.ietf.org/doc/html/rfc1034 947 | * [RFC5890]: https://datatracker.ietf.org/doc/html/rfc5890 948 | */ 949 | IDNHostname = "idn-hostname", 950 | 951 | /** 952 | * An IPv4 address according to the "dotted-quad" ABNF syntax as defined in 953 | * [RFC 2673, section 3.2][RFC2673]. 954 | * 955 | * [RFC2673]: https://datatracker.ietf.org/doc/html/rfc2673 956 | */ 957 | IPv4 = "ipv4", 958 | 959 | /** 960 | * An IPv6 address as defined in [RFC 4291, section 2.2][RFC4291]. 961 | * 962 | * [RFC4291]: https://datatracker.ietf.org/doc/html/rfc4291 963 | */ 964 | IPv6 = "ipv6", 965 | 966 | /** 967 | * A string instance is valid against this attribute if it is a valid IRI, 968 | * according to [RFC 3987][RFC3987]. 969 | * 970 | * [RFC3987]: https://datatracker.ietf.org/doc/html/rfc3987 971 | */ 972 | IRI = "iri", 973 | 974 | /** 975 | * A string instance is valid against this attribute if it is a valid IRI 976 | * Reference (either an IRI or a relative-reference), according to 977 | * [RFC 3987][RFC3987]. 978 | * 979 | * [RFC3987]: https://datatracker.ietf.org/doc/html/rfc3987 980 | */ 981 | IRIReference = "iri-reference", 982 | 983 | /** 984 | * A string instance is valid against this attribute if it is a valid JSON 985 | * string representation of a JSON Pointer, according to 986 | * [RFC 6901, section 5][RFC6901]. 987 | * 988 | * [RFC6901]: https://datatracker.ietf.org/doc/html/rfc6901 989 | */ 990 | JSONPointer = "json-pointer", 991 | 992 | /** 993 | * A string instance is valid against this attribute if it is a valid JSON 994 | * string representation of a JSON Pointer fragment, according to 995 | * [RFC 6901, section 5][RFC6901]. 996 | * 997 | * [RFC6901]: https://datatracker.ietf.org/doc/html/rfc6901 998 | */ 999 | JSONPointerURIFragment = "json-pointer-uri-fragment", 1000 | 1001 | /** 1002 | * This attribute applies to string instances. 1003 | * 1004 | * A regular expression, which SHOULD be valid according to the 1005 | * [ECMA-262][ecma262] regular expression dialect. 1006 | * 1007 | * Implementations that validate formats MUST accept at least the subset of 1008 | * [ECMA-262][ecma262] defined in the [Regular Expressions][regexInterop] 1009 | * section of this specification, and SHOULD accept all valid 1010 | * [ECMA-262][ecma262] expressions. 1011 | * 1012 | * [ecma262]: https://www.ecma-international.org/publications-and-standards/standards/ecma-262/ 1013 | * [regexInterop]: https://json-schema.org/draft-07/json-schema-validation.html#regexInterop 1014 | */ 1015 | RegEx = "regex", 1016 | 1017 | /** 1018 | * A string instance is valid against this attribute if it is a valid 1019 | * [Relative JSON Pointer][relative-json-pointer]. 1020 | * 1021 | * [relative-json-pointer]: https://datatracker.ietf.org/doc/html/draft-handrews-relative-json-pointer-01 1022 | */ 1023 | RelativeJSONPointer = "relative-json-pointer", 1024 | 1025 | /** 1026 | * A string instance is valid against this attribute if it is a valid 1027 | * representation according to the "time" production in [RFC 3339][RFC3339]. 1028 | * 1029 | * [RFC3339]: https://datatracker.ietf.org/doc/html/rfc3339 1030 | */ 1031 | Time = "time", 1032 | 1033 | /** 1034 | * A string instance is valid against this attribute if it is a valid URI, 1035 | * according to [RFC3986][RFC3986]. 1036 | * 1037 | * [RFC3986]: https://datatracker.ietf.org/doc/html/rfc3986 1038 | */ 1039 | URI = "uri", 1040 | 1041 | /** 1042 | * A string instance is valid against this attribute if it is a valid URI 1043 | * Reference (either a URI or a relative-reference), according to 1044 | * [RFC3986][RFC3986]. 1045 | * 1046 | * [RFC3986]: https://datatracker.ietf.org/doc/html/rfc3986 1047 | */ 1048 | URIReference = "uri-reference", 1049 | 1050 | /** 1051 | * A string instance is valid against this attribute if it is a valid URI 1052 | * Template (of any level), according to [RFC6570][RFC6570]. 1053 | * 1054 | * Note that URI Templates may be used for IRIs; there is no separate IRI 1055 | * Template specification. 1056 | * 1057 | * [RFC6570]: https://datatracker.ietf.org/doc/html/rfc6570 1058 | */ 1059 | URITemplate = "uri-template", 1060 | 1061 | /** 1062 | * UUID 1063 | */ 1064 | UUID = "uuid", 1065 | } 1066 | 1067 | /** 1068 | * Enum consisting of simple type names for the `type` keyword 1069 | */ 1070 | export enum TypeName { 1071 | /** 1072 | * Value MUST be an array. 1073 | */ 1074 | Array = "array", 1075 | 1076 | /** 1077 | * Value MUST be a boolean. 1078 | */ 1079 | Boolean = "boolean", 1080 | 1081 | /** 1082 | * Value MUST be an integer, no floating point numbers are allowed. This is a 1083 | * subset of the number type. 1084 | */ 1085 | Integer = "integer", 1086 | 1087 | /** 1088 | * Value MUST be null. Note this is mainly for purpose of being able use union 1089 | * types to define nullability. If this type is not included in a union, null 1090 | * values are not allowed (the primitives listed above do not allow nulls on 1091 | * their own). 1092 | */ 1093 | Null = "null", 1094 | 1095 | /** 1096 | * Value MUST be a number, floating point numbers are allowed. 1097 | */ 1098 | Number = "number", 1099 | 1100 | /** 1101 | * Value MUST be an object. 1102 | */ 1103 | Object = "object", 1104 | 1105 | /** 1106 | * Value MUST be a string. 1107 | */ 1108 | String = "string", 1109 | } 1110 | 1111 | // ----------------------------------------------------------------------------- 1112 | // Keywords 1113 | // ----------------------------------------------------------------------------- 1114 | 1115 | export const keywords = [ 1116 | "$comment", 1117 | "$id", 1118 | "$ref", 1119 | "$schema", 1120 | "additionalItems", 1121 | "additionalProperties", 1122 | "allOf", 1123 | "anyOf", 1124 | "const", 1125 | "contains", 1126 | "contentEncoding", 1127 | "contentMediaType", 1128 | "default", 1129 | "definitions", 1130 | "dependencies", 1131 | "description", 1132 | "else", 1133 | "enum", 1134 | "examples", 1135 | "exclusiveMaximum", 1136 | "exclusiveMinimum", 1137 | "format", 1138 | "if", 1139 | "items", 1140 | "maximum", 1141 | "maxItems", 1142 | "maxLength", 1143 | "maxProperties", 1144 | "minimum", 1145 | "minItems", 1146 | "minLength", 1147 | "minProperties", 1148 | "multipleOf", 1149 | "not", 1150 | "oneOf", 1151 | "pattern", 1152 | "patternProperties", 1153 | "properties", 1154 | "propertyNames", 1155 | "readOnly", 1156 | "required", 1157 | "then", 1158 | "title", 1159 | "type", 1160 | "uniqueItems", 1161 | "writeOnly", 1162 | ] as const; 1163 | -------------------------------------------------------------------------------- /dist/node/draft-2019-09.js: -------------------------------------------------------------------------------- 1 | /// 2 | // @generated 3 | // deno-fmt-ignore-file 4 | // deno-lint-ignore-file 5 | // This code was bundled using `deno bundle` and it's not recommended to edit it manually 6 | 7 | const draft = "2019-09"; 8 | const $schema = "https://json-schema.org/draft/2019-09/schema"; 9 | var ContentEncoding; 10 | (function(ContentEncoding1) { 11 | ContentEncoding1["7bit"] = "7bit"; 12 | ContentEncoding1["8bit"] = "8bit"; 13 | ContentEncoding1["Base64"] = "base64"; 14 | ContentEncoding1["Binary"] = "binary"; 15 | ContentEncoding1["IETFToken"] = "ietf-token"; 16 | ContentEncoding1["QuotedPrintable"] = "quoted-printable"; 17 | ContentEncoding1["XToken"] = "x-token"; 18 | })(ContentEncoding || (ContentEncoding = {})); 19 | var Format; 20 | (function(Format1) { 21 | Format1["Date"] = "date"; 22 | Format1["DateTime"] = "date-time"; 23 | Format1["Duration"] = "duration"; 24 | Format1["Email"] = "email"; 25 | Format1["Hostname"] = "hostname"; 26 | Format1["IDNEmail"] = "idn-email"; 27 | Format1["IDNHostname"] = "idn-hostname"; 28 | Format1["IPv4"] = "ipv4"; 29 | Format1["IPv6"] = "ipv6"; 30 | Format1["IRI"] = "iri"; 31 | Format1["IRIReference"] = "iri-reference"; 32 | Format1["JSONPointer"] = "json-pointer"; 33 | Format1["JSONPointerURIFragment"] = "json-pointer-uri-fragment"; 34 | Format1["RegEx"] = "regex"; 35 | Format1["RelativeJSONPointer"] = "relative-json-pointer"; 36 | Format1["Time"] = "time"; 37 | Format1["URI"] = "uri"; 38 | Format1["URIReference"] = "uri-reference"; 39 | Format1["URITemplate"] = "uri-template"; 40 | Format1["UUID"] = "uuid"; 41 | })(Format || (Format = {})); 42 | var TypeName; 43 | (function(TypeName1) { 44 | TypeName1["Array"] = "array"; 45 | TypeName1["Boolean"] = "boolean"; 46 | TypeName1["Integer"] = "integer"; 47 | TypeName1["Null"] = "null"; 48 | TypeName1["Number"] = "number"; 49 | TypeName1["Object"] = "object"; 50 | TypeName1["String"] = "string"; 51 | })(TypeName || (TypeName = {})); 52 | const keywords = [ 53 | "$anchor", 54 | "$comment", 55 | "$defs", 56 | "$id", 57 | "$recursiveAnchor", 58 | "$recursiveRef", 59 | "$ref", 60 | "$schema", 61 | "$vocabulary", 62 | "additionalItems", 63 | "additionalProperties", 64 | "allOf", 65 | "anyOf", 66 | "const", 67 | "contains", 68 | "contentEncoding", 69 | "contentMediaType", 70 | "contentSchema", 71 | "default", 72 | "definitions", 73 | "dependencies", 74 | "dependentRequired", 75 | "dependentSchemas", 76 | "deprecated", 77 | "description", 78 | "else", 79 | "enum", 80 | "examples", 81 | "exclusiveMaximum", 82 | "exclusiveMinimum", 83 | "format", 84 | "if", 85 | "items", 86 | "maxContains", 87 | "maximum", 88 | "maxItems", 89 | "maxLength", 90 | "maxProperties", 91 | "minContains", 92 | "minimum", 93 | "minItems", 94 | "minLength", 95 | "minProperties", 96 | "multipleOf", 97 | "not", 98 | "oneOf", 99 | "pattern", 100 | "patternProperties", 101 | "properties", 102 | "propertyNames", 103 | "readOnly", 104 | "required", 105 | "then", 106 | "title", 107 | "type", 108 | "unevaluatedItems", 109 | "unevaluatedProperties", 110 | "uniqueItems", 111 | "writeOnly", 112 | ]; 113 | export { draft as draft }; 114 | export { $schema as $schema }; 115 | export { ContentEncoding as ContentEncoding }; 116 | export { Format as Format }; 117 | export { TypeName as TypeName }; 118 | export { keywords as keywords }; 119 | 120 | //# sourceMappingURL=draft-2019-09.js.map -------------------------------------------------------------------------------- /dist/node/draft-2019-09.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"sources":["draft-2019-09.ts"],"names":[],"mappings":";;;;AAqCO,KAAK,CAAC,KAAK,GAAG,CAAS;AACvB,KAAK,CAAC,OAAO,GAAG,CAA8C;;UAwqCzD,gBAAe;IAAf,gBAAe,CAMzB,CAAM,SAAG,CAAM;IANL,gBAAe,CAczB,CAAM,SAAG,CAAM;IAdL,gBAAe,CAmBzB,CAAM,WAAG,CAAQ;IAnBP,gBAAe,CAwBzB,CAAM,WAAG,CAAQ;IAxBP,gBAAe,CA8BzB,CAAS,cAAG,CAAY;IA9Bd,gBAAe,CAoCzB,CAAe,oBAAG,CAAkB;IApC1B,gBAAe,CA0CzB,CAAM,WAAG,CAAS;GA1CR,eAAe,KAAf,eAAe;;UAgDf,OAAM;IAAN,OAAM,CAQhB,CAAI,SAAG,CAAM;IARH,OAAM,CAiBhB,CAAQ,aAAG,CAAW;IAjBZ,OAAM,CAuBhB,CAAQ,aAAG,CAAU;IAvBX,OAAM,CA+BhB,CAAK,UAAG,CAAO;IA/BL,OAAM,CAyChB,CAAQ,aAAG,CAAU;IAzCX,OAAM,CAiDhB,CAAQ,aAAG,CAAW;IAjDZ,OAAM,CA2DhB,CAAW,gBAAG,CAAc;IA3DlB,OAAM,CAmEhB,CAAI,SAAG,CAAM;IAnEH,OAAM,CA0EhB,CAAI,SAAG,CAAM;IA1EH,OAAM,CAkFhB,CAAG,QAAG,CAAK;IAlFD,OAAM,CA2FhB,CAAY,iBAAG,CAAe;IA3FpB,OAAM,CAoGhB,CAAW,gBAAG,CAAc;IApGlB,OAAM,CA6GhB,CAAsB,2BAAG,CAA2B;IA7G1C,OAAM,CA6HhB,CAAK,UAAG,CAAO;IA7HL,OAAM,CAqIhB,CAAmB,wBAAG,CAAuB;IArInC,OAAM,CA6IhB,CAAI,SAAG,CAAM;IA7IH,OAAM,CAqJhB,CAAG,QAAG,CAAK;IArJD,OAAM,CA8JhB,CAAY,iBAAG,CAAe;IA9JpB,OAAM,CAyKhB,CAAW,gBAAG,CAAc;IAzKlB,OAAM,CAiLhB,CAAI,SAAG,CAAM;GAjLH,MAAM,KAAN,MAAM;;UAuLN,SAAQ;IAAR,SAAQ,CAIlB,CAAK,UAAG,CAAO;IAJL,SAAQ,CASlB,CAAO,YAAG,CAAS;IATT,SAAQ,CAelB,CAAO,YAAG,CAAS;IAfT,SAAQ,CAuBlB,CAAI,SAAG,CAAM;IAvBH,SAAQ,CA4BlB,CAAM,WAAG,CAAQ;IA5BP,SAAQ,CAiClB,CAAM,WAAG,CAAQ;IAjCP,SAAQ,CAsClB,CAAM,WAAG,CAAQ;GAtCP,QAAQ,KAAR,QAAQ;AA6Cb,KAAK,CAAC,QAAQ,GAAG,CAAC;IACvB,CAAS;IACT,CAAU;IACV,CAAO;IACP,CAAK;IACL,CAAkB;IAClB,CAAe;IACf,CAAM;IACN,CAAS;IACT,CAAa;IACb,CAAiB;IACjB,CAAsB;IACtB,CAAO;IACP,CAAO;IACP,CAAO;IACP,CAAU;IACV,CAAiB;IACjB,CAAkB;IAClB,CAAe;IACf,CAAS;IACT,CAAa;IACb,CAAc;IACd,CAAmB;IACnB,CAAkB;IAClB,CAAY;IACZ,CAAa;IACb,CAAM;IACN,CAAM;IACN,CAAU;IACV,CAAkB;IAClB,CAAkB;IAClB,CAAQ;IACR,CAAI;IACJ,CAAO;IACP,CAAa;IACb,CAAS;IACT,CAAU;IACV,CAAW;IACX,CAAe;IACf,CAAa;IACb,CAAS;IACT,CAAU;IACV,CAAW;IACX,CAAe;IACf,CAAY;IACZ,CAAK;IACL,CAAO;IACP,CAAS;IACT,CAAmB;IACnB,CAAY;IACZ,CAAe;IACf,CAAU;IACV,CAAU;IACV,CAAM;IACN,CAAO;IACP,CAAM;IACN,CAAkB;IAClB,CAAuB;IACvB,CAAa;IACb,CAAW;AACb,CAAC;AAz/CD,MAAM,GAAO,KAAK,IAAL,KAAK;AAClB,MAAM,GAAO,OAAO,IAAP,OAAO;;;;AA47CpB,MAAM,GAAO,QAAQ,IAAR,QAAQ"} -------------------------------------------------------------------------------- /dist/node/draft-2020-12.js: -------------------------------------------------------------------------------- 1 | /// 2 | // @generated 3 | // deno-fmt-ignore-file 4 | // deno-lint-ignore-file 5 | // This code was bundled using `deno bundle` and it's not recommended to edit it manually 6 | 7 | const draft = "2020-12"; 8 | const $schema = "https://json-schema.org/draft/2020-12/schema"; 9 | var ContentEncoding; 10 | (function(ContentEncoding1) { 11 | ContentEncoding1["7bit"] = "7bit"; 12 | ContentEncoding1["8bit"] = "8bit"; 13 | ContentEncoding1["Base64"] = "base64"; 14 | ContentEncoding1["Binary"] = "binary"; 15 | ContentEncoding1["IETFToken"] = "ietf-token"; 16 | ContentEncoding1["QuotedPrintable"] = "quoted-printable"; 17 | ContentEncoding1["XToken"] = "x-token"; 18 | })(ContentEncoding || (ContentEncoding = {})); 19 | var Format; 20 | (function(Format1) { 21 | Format1["Date"] = "date"; 22 | Format1["DateTime"] = "date-time"; 23 | Format1["Duration"] = "duration"; 24 | Format1["Email"] = "email"; 25 | Format1["Hostname"] = "hostname"; 26 | Format1["IDNEmail"] = "idn-email"; 27 | Format1["IDNHostname"] = "idn-hostname"; 28 | Format1["IPv4"] = "ipv4"; 29 | Format1["IPv6"] = "ipv6"; 30 | Format1["IRI"] = "iri"; 31 | Format1["IRIReference"] = "iri-reference"; 32 | Format1["JSONPointer"] = "json-pointer"; 33 | Format1["JSONPointerURIFragment"] = "json-pointer-uri-fragment"; 34 | Format1["RegEx"] = "regex"; 35 | Format1["RelativeJSONPointer"] = "relative-json-pointer"; 36 | Format1["Time"] = "time"; 37 | Format1["URI"] = "uri"; 38 | Format1["URIReference"] = "uri-reference"; 39 | Format1["URITemplate"] = "uri-template"; 40 | Format1["UUID"] = "uuid"; 41 | })(Format || (Format = {})); 42 | var TypeName; 43 | (function(TypeName1) { 44 | TypeName1["Array"] = "array"; 45 | TypeName1["Boolean"] = "boolean"; 46 | TypeName1["Integer"] = "integer"; 47 | TypeName1["Null"] = "null"; 48 | TypeName1["Number"] = "number"; 49 | TypeName1["Object"] = "object"; 50 | TypeName1["String"] = "string"; 51 | })(TypeName || (TypeName = {})); 52 | const keywords = [ 53 | "$anchor", 54 | "$comment", 55 | "$defs", 56 | "$dynamicAnchor", 57 | "$dynamicRef", 58 | "$id", 59 | "$ref", 60 | "$schema", 61 | "$vocabulary", 62 | "additionalItems", 63 | "additionalProperties", 64 | "allOf", 65 | "anyOf", 66 | "const", 67 | "contains", 68 | "contentEncoding", 69 | "contentMediaType", 70 | "contentSchema", 71 | "default", 72 | "definitions", 73 | "dependencies", 74 | "dependentRequired", 75 | "dependentSchemas", 76 | "deprecated", 77 | "description", 78 | "else", 79 | "enum", 80 | "examples", 81 | "exclusiveMaximum", 82 | "exclusiveMinimum", 83 | "format", 84 | "if", 85 | "items", 86 | "maxContains", 87 | "maximum", 88 | "maxItems", 89 | "maxLength", 90 | "maxProperties", 91 | "minContains", 92 | "minimum", 93 | "minItems", 94 | "minLength", 95 | "minProperties", 96 | "multipleOf", 97 | "not", 98 | "oneOf", 99 | "pattern", 100 | "patternProperties", 101 | "prefixItems", 102 | "properties", 103 | "propertyNames", 104 | "readOnly", 105 | "required", 106 | "then", 107 | "title", 108 | "type", 109 | "unevaluatedItems", 110 | "unevaluatedProperties", 111 | "uniqueItems", 112 | "writeOnly", 113 | ]; 114 | export { draft as draft }; 115 | export { $schema as $schema }; 116 | export { ContentEncoding as ContentEncoding }; 117 | export { Format as Format }; 118 | export { TypeName as TypeName }; 119 | export { keywords as keywords }; 120 | 121 | //# sourceMappingURL=draft-2020-12.js.map -------------------------------------------------------------------------------- /dist/node/draft-2020-12.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"sources":["draft-2020-12.ts"],"names":[],"mappings":";;;;AAqCO,KAAK,CAAC,KAAK,GAAG,CAAS;AACvB,KAAK,CAAC,OAAO,GAAG,CAA8C;;UAgqCzD,gBAAe;IAAf,gBAAe,CAMzB,CAAM,SAAG,CAAM;IANL,gBAAe,CAczB,CAAM,SAAG,CAAM;IAdL,gBAAe,CAmBzB,CAAM,WAAG,CAAQ;IAnBP,gBAAe,CAwBzB,CAAM,WAAG,CAAQ;IAxBP,gBAAe,CA8BzB,CAAS,cAAG,CAAY;IA9Bd,gBAAe,CAoCzB,CAAe,oBAAG,CAAkB;IApC1B,gBAAe,CA0CzB,CAAM,WAAG,CAAS;GA1CR,eAAe,KAAf,eAAe;;UAgDf,OAAM;IAAN,OAAM,CAQhB,CAAI,SAAG,CAAM;IARH,OAAM,CAiBhB,CAAQ,aAAG,CAAW;IAjBZ,OAAM,CAuBhB,CAAQ,aAAG,CAAU;IAvBX,OAAM,CAgChB,CAAK,UAAG,CAAO;IAhCL,OAAM,CA0ChB,CAAQ,aAAG,CAAU;IA1CX,OAAM,CAmDhB,CAAQ,aAAG,CAAW;IAnDZ,OAAM,CA6DhB,CAAW,gBAAG,CAAc;IA7DlB,OAAM,CAqEhB,CAAI,SAAG,CAAM;IArEH,OAAM,CA4EhB,CAAI,SAAG,CAAM;IA5EH,OAAM,CAoFhB,CAAG,QAAG,CAAK;IApFD,OAAM,CA6FhB,CAAY,iBAAG,CAAe;IA7FpB,OAAM,CAsGhB,CAAW,gBAAG,CAAc;IAtGlB,OAAM,CA+GhB,CAAsB,2BAAG,CAA2B;IA/G1C,OAAM,CA+HhB,CAAK,UAAG,CAAO;IA/HL,OAAM,CAuIhB,CAAmB,wBAAG,CAAuB;IAvInC,OAAM,CA+IhB,CAAI,SAAG,CAAM;IA/IH,OAAM,CAuJhB,CAAG,QAAG,CAAK;IAvJD,OAAM,CAgKhB,CAAY,iBAAG,CAAe;IAhKpB,OAAM,CA2KhB,CAAW,gBAAG,CAAc;IA3KlB,OAAM,CAmLhB,CAAI,SAAG,CAAM;GAnLH,MAAM,KAAN,MAAM;;UAyLN,SAAQ;IAAR,SAAQ,CAIlB,CAAK,UAAG,CAAO;IAJL,SAAQ,CASlB,CAAO,YAAG,CAAS;IATT,SAAQ,CAelB,CAAO,YAAG,CAAS;IAfT,SAAQ,CAuBlB,CAAI,SAAG,CAAM;IAvBH,SAAQ,CA4BlB,CAAM,WAAG,CAAQ;IA5BP,SAAQ,CAiClB,CAAM,WAAG,CAAQ;IAjCP,SAAQ,CAsClB,CAAM,WAAG,CAAQ;GAtCP,QAAQ,KAAR,QAAQ;AA6Cb,KAAK,CAAC,QAAQ,GAAG,CAAC;IACvB,CAAS;IACT,CAAU;IACV,CAAO;IACP,CAAgB;IAChB,CAAa;IACb,CAAK;IACL,CAAM;IACN,CAAS;IACT,CAAa;IACb,CAAiB;IACjB,CAAsB;IACtB,CAAO;IACP,CAAO;IACP,CAAO;IACP,CAAU;IACV,CAAiB;IACjB,CAAkB;IAClB,CAAe;IACf,CAAS;IACT,CAAa;IACb,CAAc;IACd,CAAmB;IACnB,CAAkB;IAClB,CAAY;IACZ,CAAa;IACb,CAAM;IACN,CAAM;IACN,CAAU;IACV,CAAkB;IAClB,CAAkB;IAClB,CAAQ;IACR,CAAI;IACJ,CAAO;IACP,CAAa;IACb,CAAS;IACT,CAAU;IACV,CAAW;IACX,CAAe;IACf,CAAa;IACb,CAAS;IACT,CAAU;IACV,CAAW;IACX,CAAe;IACf,CAAY;IACZ,CAAK;IACL,CAAO;IACP,CAAS;IACT,CAAmB;IACnB,CAAa;IACb,CAAY;IACZ,CAAe;IACf,CAAU;IACV,CAAU;IACV,CAAM;IACN,CAAO;IACP,CAAM;IACN,CAAkB;IAClB,CAAuB;IACvB,CAAa;IACb,CAAW;AACb,CAAC;AAp/CD,MAAM,GAAO,KAAK,IAAL,KAAK;AAClB,MAAM,GAAO,OAAO,IAAP,OAAO;;;;AAs7CpB,MAAM,GAAO,QAAQ,IAAR,QAAQ"} -------------------------------------------------------------------------------- /dist/node/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "json-schema-typed", 3 | "description": "JSON Schema TypeScript definitions with complete inline documentation.", 4 | "license": "BSD-2-Clause", 5 | "version": "8.0.1", 6 | "homepage": "https://github.com/jrylan/json-schema-typed/tree/main/dist/node", 7 | "repository": { 8 | "type": "git", 9 | "url": "https://github.com/jrylan/json-schema-typed.git" 10 | }, 11 | "author": { 12 | "name": "Jeremy Rylan", 13 | "url": "https://github.com/jrylan" 14 | }, 15 | "main": "./draft-2020-12.js", 16 | "type": "module", 17 | "exports": { 18 | ".": "./draft-2020-12.js", 19 | "./draft-07": "./draft-07.js", 20 | "./draft-2019-09": "./draft-2019-09.js", 21 | "./draft-2020-12": "./draft-2020-12.js" 22 | }, 23 | "keywords": [ 24 | "jsonschema", 25 | "typescript", 26 | "types", 27 | "definitions", 28 | "json", 29 | "schema" 30 | ] 31 | } 32 | -------------------------------------------------------------------------------- /dist/spec_definitions/LICENSE.md: -------------------------------------------------------------------------------- 1 | BSD 2-Clause License 2 | 3 | Original source code is copyright (c) 2019-2022 Jeremy Rylan 4 | 5 | 6 | All JSON Schema documentation and descriptions are copyright (c): 7 | 8 | 2009 [draft-0] IETF Trust , Kris Zyp , 9 | and SitePen (USA) . 10 | 11 | 2009 [draft-1] IETF Trust , Kris Zyp , 12 | and SitePen (USA) . 13 | 14 | 2010 [draft-2] IETF Trust , Kris Zyp , 15 | and SitePen (USA) . 16 | 17 | 2010 [draft-3] IETF Trust , Kris Zyp , 18 | Gary Court , and SitePen (USA) . 19 | 20 | 2013 [draft-4] IETF Trust ), Francis Galiegue 21 | , Kris Zyp , Gary Court 22 | , and SitePen (USA) . 23 | 24 | 2018 [draft-7] IETF Trust , Austin Wright , 25 | Henry Andrews , Geraint Luff , and 26 | Cloudflare, Inc. . 27 | 28 | 2019 [draft-2019-09] IETF Trust , Austin Wright 29 | , Henry Andrews , Ben Hutton 30 | , and Greg Dennis . 31 | 32 | 2020 [draft-2020-12] IETF Trust , Austin Wright 33 | , Henry Andrews , Ben Hutton 34 | , and Greg Dennis . 35 | 36 | All rights reserved. 37 | 38 | Redistribution and use in source and binary forms, with or without modification, 39 | are permitted provided that the following conditions are met: 40 | 41 | 1. Redistributions of source code must retain the above copyright notice, this 42 | list of conditions and the following disclaimer. 43 | 44 | 2. Redistributions in binary form must reproduce the above copyright notice, 45 | this list of conditions and the following disclaimer in the documentation 46 | and/or other materials provided with the distribution. 47 | 48 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 49 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 50 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 51 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 52 | ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 53 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 54 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 55 | ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 56 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 57 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -------------------------------------------------------------------------------- /dist/spec_definitions/README.md: -------------------------------------------------------------------------------- 1 | # JSON Schema Spec Definitions 2 | 3 | Consistent JSON definitions to help library authors implement JSON Schema 4 | validators with bundled documentation. 5 | 6 | All the definitions in this directly adhere to the TypeScript types found in 7 | [types.ts](https://github.com/jrylan/json-schema-typed/blob/main/.src/types.ts). 8 | 9 | Be cautious that if you use **any** of the definitions provided here, your 10 | library must be compatible with the 11 | [BSD-2-Clause license](https://github.com/jrylan/json-schema-typed/blob/main/dist/spec_definitions/LICENSE.md) 12 | to be fully compliant with the [IETF](https://www.ietf.org/) licensing. 13 | 14 | --- 15 | 16 | ## Maintainers 17 | 18 | - [Jeremy Rylan](https://github.com/jrylan) 19 | 20 | ## License 21 | 22 | [BSD-2-Clause](https://github.com/jrylan/json-schema-typed/blob/main/dist/spec_definitions/LICENSE.md) 23 | -------------------------------------------------------------------------------- /dist/spec_definitions/draft_07.json: -------------------------------------------------------------------------------- 1 | { 2 | "$copyright": { 3 | "credits": [ 4 | "IETF Trust ", 5 | "Austin Wright ", 6 | "Henry Andrews ", 7 | "Geraint Luff ", 8 | "Cloudflare, Inc. " 9 | ], 10 | "year": 2018 11 | }, 12 | "$docsUrl": "https://json-schema.org/draft-07/json-schema-validation.html", 13 | "$draft": "7", 14 | "$license": "BSD-2-Clause License\n\nOriginal source code is copyright (c) 2019-2022 Jeremy Rylan\n\n\nDocumentation and keyword descriptions are copyright (c) 2018 IETF Trust , Austin Wright , Henry Andrews , Geraint Luff , and Cloudflare, Inc. . All rights reserved.\n\nRedistribution and use in source and binary forms, with or without\nmodification, are permitted provided that the following conditions are met:\n\n1. Redistributions of source code must retain the above copyright notice,\n this list of conditions and the following disclaimer.\n\n2. Redistributions in binary form must reproduce the above copyright notice,\n this list of conditions and the following disclaimer in the documentation\n and/or other materials provided with the distribution.\n\nTHIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\"\nAND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\nIMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\nARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE\nLIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR\nCONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF\nSUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS\nINTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN\nCONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)\nARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE\nPOSSIBILITY OF SUCH DAMAGE.", 15 | "$schemaUrl": "https://json-schema.org/draft-07/schema", 16 | "enums": { 17 | "contentEncoding": { 18 | "description": "Content encoding strategy enum.\n\n- [Content-Transfer-Encoding Syntax](https://datatracker.ietf.org/doc/html/rfc2045#section-6.1)\n- [7bit vs 8bit encoding](https://stackoverflow.com/questions/25710599/content-transfer-encoding-7bit-or-8-bit/28531705#28531705)", 19 | "title": "ContentEncoding", 20 | "values": { 21 | "7bit": { 22 | "description": "Only US-ASCII characters, which use the lower 7 bits for each character.\n\nEach line must be less than 1,000 characters.", 23 | "value": "7bit" 24 | }, 25 | "8bit": { 26 | "description": "Allow extended ASCII characters which can use the 8th (highest) bit to indicate special characters not available in 7bit.\n\nEach line must be less than 1,000 characters.", 27 | "value": "8bit" 28 | }, 29 | "Base64": { 30 | "description": "Useful for data that is mostly non-text.", 31 | "value": "base64" 32 | }, 33 | "Binary": { 34 | "description": "Same character set as 8bit, with no line length restriction.", 35 | "value": "binary" 36 | }, 37 | "IETFToken": { 38 | "description": "An extension token defined by a standards-track RFC and registered with IANA.", 39 | "value": "ietf-token" 40 | }, 41 | "QuotedPrintable": { 42 | "description": "Lines are limited to 76 characters, and line breaks are represented using special characters that are escaped.", 43 | "value": "quoted-printable" 44 | }, 45 | "XToken": { 46 | "description": "The two characters \"X-\" or \"x-\" followed, with no intervening white space, by any token.", 47 | "value": "x-token" 48 | } 49 | } 50 | }, 51 | "format": { 52 | "description": "This enum provides well-known formats that apply to strings.", 53 | "title": "Format", 54 | "values": { 55 | "Date": { 56 | "description": "A string instance is valid against this attribute if it is a valid representation according to the \"full-date\" production in [RFC 3339][RFC3339].\n\n[RFC3339]: https://datatracker.ietf.org/doc/html/rfc3339", 57 | "value": "date" 58 | }, 59 | "DateTime": { 60 | "description": "A string instance is valid against this attribute if it is a valid representation according to the \"date-time\" production in [RFC 3339][RFC3339].\n\n[RFC3339]: https://datatracker.ietf.org/doc/html/rfc3339", 61 | "value": "date-time" 62 | }, 63 | "Email": { 64 | "description": "A string instance is valid against this attribute if it is a valid Internet email address as defined by [RFC 5322, section 3.4.1][RFC5322].\n\n[RFC5322]: https://datatracker.ietf.org/doc/html/rfc5322", 65 | "value": "email" 66 | }, 67 | "Hostname": { 68 | "description": "As defined by [RFC 1034, section 3.1][RFC1034], including host names produced using the Punycode algorithm specified in [RFC 5891, section 4.4][RFC5891].\n\n[RFC1034]: https://datatracker.ietf.org/doc/html/rfc1034\n[RFC5891]: https://datatracker.ietf.org/doc/html/rfc5891", 69 | "value": "hostname" 70 | }, 71 | "IDNEmail": { 72 | "description": "A string instance is valid against this attribute if it is a valid Internet email address as defined by [RFC 6531][RFC6531].\n\n[RFC6531]: https://datatracker.ietf.org/doc/html/rfc6531", 73 | "value": "idn-email" 74 | }, 75 | "IDNHostname": { 76 | "description": "As defined by either [RFC 1034, section 3.1][RFC1034] as for hostname, or an internationalized hostname as defined by [RFC 5890, section 2.3.2.3][RFC5890].\n\n[RFC1034]: https://datatracker.ietf.org/doc/html/rfc1034\n[RFC5890]: https://datatracker.ietf.org/doc/html/rfc5890", 77 | "value": "idn-hostname" 78 | }, 79 | "IPv4": { 80 | "description": "An IPv4 address according to the \"dotted-quad\" ABNF syntax as defined in [RFC 2673, section 3.2][RFC2673].\n\n[RFC2673]: https://datatracker.ietf.org/doc/html/rfc2673", 81 | "value": "ipv4" 82 | }, 83 | "IPv6": { 84 | "description": "An IPv6 address as defined in [RFC 4291, section 2.2][RFC4291].\n\n[RFC4291]: https://datatracker.ietf.org/doc/html/rfc4291", 85 | "value": "ipv6" 86 | }, 87 | "IRI": { 88 | "description": "A string instance is valid against this attribute if it is a valid IRI, according to [RFC 3987][RFC3987].\n\n[RFC3987]: https://datatracker.ietf.org/doc/html/rfc3987", 89 | "value": "iri" 90 | }, 91 | "IRIReference": { 92 | "description": "A string instance is valid against this attribute if it is a valid IRI Reference (either an IRI or a relative-reference), according to [RFC 3987][RFC3987].\n\n[RFC3987]: https://datatracker.ietf.org/doc/html/rfc3987", 93 | "value": "iri-reference" 94 | }, 95 | "JSONPointer": { 96 | "description": "A string instance is valid against this attribute if it is a valid JSON string representation of a JSON Pointer, according to [RFC 6901, section 5][RFC6901].\n\n[RFC6901]: https://datatracker.ietf.org/doc/html/rfc6901", 97 | "value": "json-pointer" 98 | }, 99 | "JSONPointerURIFragment": { 100 | "description": "A string instance is valid against this attribute if it is a valid JSON string representation of a JSON Pointer fragment, according to [RFC 6901, section 5][RFC6901].\n\n[RFC6901]: https://datatracker.ietf.org/doc/html/rfc6901", 101 | "value": "json-pointer-uri-fragment" 102 | }, 103 | "RegEx": { 104 | "description": "This attribute applies to string instances.\n\nA regular expression, which SHOULD be valid according to the [ECMA-262][ecma262] regular expression dialect.\n\nImplementations that validate formats MUST accept at least the subset of [ECMA-262][ecma262] defined in the [Regular Expressions][regexInterop] section of this specification, and SHOULD accept all valid [ECMA-262][ecma262] expressions.\n\n[ecma262]: https://www.ecma-international.org/publications-and-standards/standards/ecma-262/\n[regexInterop]: https://json-schema.org/draft-07/json-schema-validation.html#regexInterop", 105 | "value": "regex" 106 | }, 107 | "RelativeJSONPointer": { 108 | "description": "A string instance is valid against this attribute if it is a valid [Relative JSON Pointer][relative-json-pointer].\n\n[relative-json-pointer]: https://datatracker.ietf.org/doc/html/draft-handrews-relative-json-pointer-01", 109 | "value": "relative-json-pointer" 110 | }, 111 | "Time": { 112 | "description": "A string instance is valid against this attribute if it is a valid representation according to the \"time\" production in [RFC 3339][RFC3339].\n\n[RFC3339]: https://datatracker.ietf.org/doc/html/rfc3339", 113 | "value": "time" 114 | }, 115 | "URI": { 116 | "description": "A string instance is valid against this attribute if it is a valid URI, according to [RFC3986][RFC3986].\n\n[RFC3986]: https://datatracker.ietf.org/doc/html/rfc3986", 117 | "value": "uri" 118 | }, 119 | "URIReference": { 120 | "description": "A string instance is valid against this attribute if it is a valid URI Reference (either a URI or a relative-reference), according to [RFC3986][RFC3986].\n\n[RFC3986]: https://datatracker.ietf.org/doc/html/rfc3986", 121 | "value": "uri-reference" 122 | }, 123 | "URITemplate": { 124 | "description": "A string instance is valid against this attribute if it is a valid URI Template (of any level), according to [RFC6570][RFC6570].\n\nNote that URI Templates may be used for IRIs; there is no separate IRI Template specification.\n\n[RFC6570]: https://datatracker.ietf.org/doc/html/rfc6570", 125 | "value": "uri-template" 126 | }, 127 | "UUID": { 128 | "description": "UUID", 129 | "value": "uuid" 130 | } 131 | } 132 | }, 133 | "typeName": { 134 | "description": "Enum consisting of simple type names for the `type` keyword", 135 | "title": "TypeName", 136 | "values": { 137 | "Array": { 138 | "description": "Value MUST be an array.", 139 | "value": "array" 140 | }, 141 | "Boolean": { 142 | "description": "Value MUST be a boolean.", 143 | "value": "boolean" 144 | }, 145 | "Integer": { 146 | "description": "Value MUST be an integer, no floating point numbers are allowed. This is a subset of the number type.", 147 | "value": "integer" 148 | }, 149 | "Null": { 150 | "description": "Value MUST be null. Note this is mainly for purpose of being able use union types to define nullability. If this type is not included in a union, null values are not allowed (the primitives listed above do not allow nulls on their own).", 151 | "value": "null" 152 | }, 153 | "Number": { 154 | "description": "Value MUST be a number, floating point numbers are allowed.", 155 | "value": "number" 156 | }, 157 | "Object": { 158 | "description": "Value MUST be an object.", 159 | "value": "object" 160 | }, 161 | "String": { 162 | "description": "Value MUST be a string.", 163 | "value": "string" 164 | } 165 | } 166 | } 167 | }, 168 | "keywords": { 169 | "$comment": { 170 | "description": "This keyword is reserved for comments from schema authors to readers or\nmaintainers of the schema. The value of this keyword MUST be a string.\nImplementations MUST NOT present this string to end users. Tools for\nediting schemas SHOULD support displaying and editing this keyword.\n\nThe value of this keyword MAY be used in debug or error output which is\nintended for developers making use of schemas. Schema vocabularies SHOULD\nallow `comment` within any object containing vocabulary keywords.\n\nImplementations MAY assume `comment` is allowed unless the vocabulary\nspecifically forbids it. Vocabularies MUST NOT specify any effect of\n`comment` beyond what is described in this specification. Tools that\ntranslate other media types or programming languages to and from\n`application/schema+json` MAY choose to convert that media type or\nprogramming language's native comments to or from `comment` values.\n\nThe behavior of such translation when both native comments and `comment`\nproperties are present is implementation-dependent. Implementations SHOULD\ntreat `comment` identically to an unknown extension keyword.\n\nThey MAY strip `comment` values at any point during processing. In\nparticular, this allows for shortening schemas when the size of deployed\nschemas is a concern. Implementations MUST NOT take any other action based\non the presence, absence, or contents of `comment` properties.", 171 | "type": "string" 172 | }, 173 | "$id": { 174 | "description": "The `$id` keyword defines a URI for the schema, and the base URI that other\nURI references within the schema are resolved against. A subschema's `$id`\nis resolved against the base URI of its parent schema. If no parent sets an\nexplicit base with `$id`, the base URI is that of the entire document, as\ndetermined per [RFC 3986 section 5][RFC3986].\n\nIf present, the value for this keyword MUST be a string, and MUST represent\na valid [URI-reference][RFC3986]. This value SHOULD be normalized, and\nSHOULD NOT be an empty fragment `#` or an empty string.\n\n[RFC3986]: https://datatracker.ietf.org/doc/html/rfc3986", 175 | "format": "uri-reference", 176 | "type": "string" 177 | }, 178 | "$ref": { 179 | "description": "The `$ref` keyword is used to reference a schema, and provides the ability\nto validate recursive structures through self-reference.\n\nAn object schema with a `$ref` property MUST be interpreted as a `$ref`\nreference. The value of the `$ref` property MUST be a URI Reference.\nResolved against the current URI base, it identifies the URI of a schema to\nuse. All other properties in a `$ref` object MUST be ignored.\n\nThe URI is not a network locator, only an identifier. A schema need not be\ndownloadable from the address if it is a network-addressable URL, and\nimplementations SHOULD NOT assume they should perform a network operation\nwhen they encounter a network-addressable URI.\n\nA schema MUST NOT be run into an infinite loop against a schema. For\nexample, if two schemas `\"#alice\"` and `\"#bob\"` both have an `allOf`\nproperty that refers to the other, a naive validator might get stuck in an\ninfinite recursive loop trying to validate the instance. Schemas SHOULD NOT\nmake use of infinite recursive nesting like this; the behavior is\nundefined.", 180 | "format": "uri-reference", 181 | "type": "string" 182 | }, 183 | "$schema": { 184 | "description": "The `$schema` keyword is both used as a JSON Schema version identifier and\nthe location of a resource which is itself a JSON Schema, which describes\nany schema written for this particular version.\n\nThe value of this keyword MUST be a [URI][RFC3986] (containing a scheme)\nand this URI MUST be normalized. The current schema MUST be valid against\nthe meta-schema identified by this URI.\n\nIf this URI identifies a retrievable resource, that resource SHOULD be of\nmedia type `application/schema+json`.\n\nThe `$schema` keyword SHOULD be used in a root schema. It MUST NOT appear\nin subschemas.\n\nValues for this property are defined in other documents and by other\nparties. JSON Schema implementations SHOULD implement support for current\nand previous published drafts of JSON Schema vocabularies as deemed\nreasonable.\n\n[RFC3986]: https://datatracker.ietf.org/doc/html/rfc3986", 185 | "format": "uri", 186 | "type": "string" 187 | }, 188 | "additionalItems": { 189 | "description": "The value of `additionalItems` MUST be a valid JSON Schema.\n\nThis keyword determines how child instances validate for arrays, and does\nnot directly validate the immediate instance itself.\n\nIf `items` is an array of schemas, validation succeeds if every instance\nelement at a position greater than the size of `items` validates against\n`additionalItems`.\n\nOtherwise, `additionalItems` MUST be ignored, as the `items` schema\n(possibly the default value of an empty schema) is applied to all elements.\n\nOmitting this keyword has the same behavior as an empty schema.", 190 | "type": "JSONSchema" 191 | }, 192 | "additionalProperties": { 193 | "description": "The value of `additionalProperties` MUST be a valid JSON Schema.\n\nThis keyword determines how child instances validate for objects, and does\nnot directly validate the immediate instance itself.\n\nValidation with `additionalProperties` applies only to the child values of\ninstance names that do not match any names in `properties`, and do not\nmatch any regular expression in `patternProperties`.\n\nFor all such properties, validation succeeds if the child instance\nvalidates against the `additionalProperties` schema.\n\nOmitting this keyword has the same behavior as an empty schema.", 194 | "type": "JSONSchema" 195 | }, 196 | "allOf": { 197 | "description": "This keyword's value MUST be a non-empty array. Each item of the array MUST\nbe a valid JSON Schema.\n\nAn instance validates successfully against this keyword if it validates\nsuccessfully against all schemas defined by this keyword's value.", 198 | "items": { 199 | "type": "JSONSchema" 200 | }, 201 | "type": "array" 202 | }, 203 | "anyOf": { 204 | "description": "This keyword's value MUST be a non-empty array. Each item of the array MUST\nbe a valid JSON Schema.\n\nAn instance validates successfully against this keyword if it validates\nsuccessfully against at least one schema defined by this keyword's value.", 205 | "items": { 206 | "type": "JSONSchema" 207 | }, 208 | "type": "array" 209 | }, 210 | "const": { 211 | "description": "An instance validates successfully against this keyword if its value is\nequal to the value of the keyword.\n\nUse of this keyword is functionally equivalent to the `enum` keyword with a\nsingle value.", 212 | "type": "Value" 213 | }, 214 | "contains": { 215 | "description": "The value of this keyword MUST be a valid JSON Schema.\n\nAn array instance is valid against `contains` if at least one of its\nelements is valid against the given schema.", 216 | "type": "JSONSchema" 217 | }, 218 | "contentEncoding": { 219 | "description": "If the instance value is a string, this property defines that the string\nSHOULD be interpreted as binary data and decoded using the encoding named\nby this property. [RFC 2045, Sec 6.1][RFC2045] lists the possible values\nfor this property.\n\nThe value of this property SHOULD be ignored if the instance described is\nnot a string.\n\n[RFC2045]: https://datatracker.ietf.org/doc/html/rfc2045#section-6.1", 220 | "enum": [ 221 | "7bit", 222 | "8bit", 223 | "base64", 224 | "binary", 225 | "ietf-token", 226 | "quoted-printable", 227 | "x-token" 228 | ], 229 | "type": "string" 230 | }, 231 | "contentMediaType": { 232 | "description": "The value of this property must be a media type, as defined by\n[RFC 2046][RFC2046]. This property defines the media type of instances\nwhich this schema defines.\n\nThe value of this property SHOULD be ignored if the instance described is\nnot a string.\n\nIf the `contentEncoding` property is not present, but the instance value is\na string, then the value of this property SHOULD specify a text document\ntype, and the character set SHOULD be the character set into which the JSON\nstring value was decoded (for which the default is Unicode).\n\n[RFC2046]: https://datatracker.ietf.org/doc/html/rfc2046", 233 | "type": "string" 234 | }, 235 | "default": { 236 | "description": "This keyword can be used to supply a default JSON value associated with a\nparticular schema. It is RECOMMENDED that a `default` value be valid\nagainst the associated schema.", 237 | "type": "Value" 238 | }, 239 | "definitions": { 240 | "additionalProperties": { 241 | "type": "JSONSchema" 242 | }, 243 | "description": "The `definitions` keywords provides a standardized location for schema\nauthors to inline re-usable JSON Schemas into a more general schema. The\nkeyword does not directly affect the validation result.\n\nThis keyword's value MUST be an object. Each member value of this object\nMUST be a valid JSON Schema.", 244 | "type": "object" 245 | }, 246 | "dependencies": { 247 | "description": "This keyword specifies rules that are evaluated if the instance is an\nobject and contains a certain property.\n\nThis keyword's value MUST be an object. Each property specifies a\ndependency. Each dependency value MUST be an array or a valid JSON Schema.\n\nIf the dependency value is a subschema, and the dependency key is a\nproperty in the instance, the entire instance must validate against the\ndependency value.\n\nIf the dependency value is an array, each element in the array, if any,\nMUST be a string, and MUST be unique. If the dependency key is a property\nin the instance, each of the items in the dependency value must be a\nproperty that exists in the instance.\n\nOmitting this keyword has the same behavior as an empty object.", 248 | "oneOf": [ 249 | { 250 | "additionalProperties": { 251 | "oneOf": [ 252 | { 253 | "items": { 254 | "type": "string" 255 | }, 256 | "type": "array" 257 | }, 258 | { 259 | "type": "JSONSchema" 260 | } 261 | ] 262 | }, 263 | "type": "object" 264 | } 265 | ] 266 | }, 267 | "description": { 268 | "description": "Can be used to decorate a user interface with explanation or information\nabout the data produced.", 269 | "type": "string" 270 | }, 271 | "else": { 272 | "description": "This keyword's value MUST be a valid JSON Schema.\n\nWhen `if` is present, and the instance fails to validate against its\nsubschema, then validation succeeds against this keyword if the instance\nsuccessfully validates against this keyword's subschema.\n\nThis keyword has no effect when `if` is absent, or when the instance\nsuccessfully validates against its subschema. Implementations MUST NOT\nevaluate the instance against this keyword, for either validation or\nannotation collection purposes, in such cases.", 273 | "type": "JSONSchema" 274 | }, 275 | "enum": { 276 | "description": "The value of this keyword MUST be an array. This array SHOULD have at least\none element. Elements in the array SHOULD be unique.\n\nAn instance validates successfully against this keyword if its value is\nequal to one of the elements in this keyword's array value.\n\nElements in the array might be of any type, including `null`.", 277 | "items": { 278 | "type": "Value" 279 | }, 280 | "type": "array" 281 | }, 282 | "examples": { 283 | "description": "The value of this keyword MUST be an array. When multiple occurrences of\nthis keyword are applicable to a single sub-instance, implementations MUST\nprovide a flat array of all values rather than an array of arrays.\n\nThis keyword can be used to provide sample JSON values associated with a\nparticular schema, for the purpose of illustrating usage. It is RECOMMENDED\nthat these values be valid against the associated schema.\n\nImplementations MAY use the value(s) of `default`, if present, as an\nadditional example. If `examples` is absent, `default` MAY still be used in\nthis manner.", 284 | "items": { 285 | "type": "Value" 286 | }, 287 | "type": "array" 288 | }, 289 | "exclusiveMaximum": { 290 | "description": "The value of `exclusiveMaximum` MUST be a number, representing an exclusive\nupper limit for a numeric instance.\n\nIf the instance is a number, then the instance is valid only if it has a\nvalue strictly less than (not equal to) `exclusiveMaximum`.", 291 | "type": "number" 292 | }, 293 | "exclusiveMinimum": { 294 | "description": "The value of `exclusiveMinimum` MUST be a number, representing an exclusive\nlower limit for a numeric instance.\n\nIf the instance is a number, then the instance is valid only if it has a\nvalue strictly greater than (not equal to) `exclusiveMinimum`.", 295 | "type": "number" 296 | }, 297 | "format": { 298 | "description": "The `format` keyword functions as both an [annotation][annotation] and as\nan [assertion][assertion]. While no special effort is required to implement\nit as an annotation conveying semantic meaning, implementing validation is\nnon-trivial.\n\nImplementations MAY support the `format` keyword as a validation assertion.\n\nImplementations MAY add custom `format` attributes. Save for agreement\nbetween parties, schema authors SHALL NOT expect a peer implementation to\nsupport this keyword and/or custom `format` attributes.\n\n[annotation]: https://json-schema.org/draft-07/json-schema-validation.html#annotations\n[assertion]: https://json-schema.org/draft-07/json-schema-validation.html#assertions", 299 | "type": "string" 300 | }, 301 | "if": { 302 | "description": "This keyword's value MUST be a valid JSON Schema.\n\nThis validation outcome of this keyword's subschema has no direct effect on\nthe overall validation result. Rather, it controls which of the `then` or\n`else` keywords are evaluated.\n\nInstances that successfully validate against this keyword's subschema MUST\nalso be valid against the subschema value of the `then` keyword, if\npresent.\n\nInstances that fail to validate against this keyword's subschema MUST also\nbe valid against the subschema value of the `else` keyword, if present.\n\nIf [annotations][annotations] are being collected, they are collected from\nthis keyword's subschema in the usual way, including when the keyword is\npresent without either `then` or `else`.\n\n[annotations]: https://json-schema.org/draft-07/json-schema-validation.html#annotations", 303 | "type": "JSONSchema" 304 | }, 305 | "items": { 306 | "description": "The value of `items` MUST be either a valid JSON Schema or an array of\nvalid JSON Schemas.\n\nThis keyword determines how child instances validate for arrays, and does\nnot directly validate the immediate instance itself.\n\nIf `items` is a schema, validation succeeds if all elements in the array\nsuccessfully validate against that schema.\n\nIf `items` is an array of schemas, validation succeeds if each element of\nthe instance validates against the schema at the same position, if any.\n\nOmitting this keyword has the same behavior as an empty schema.", 307 | "oneOf": [ 308 | { 309 | "items": { 310 | "type": "JSONSchema" 311 | }, 312 | "type": "array" 313 | }, 314 | { 315 | "type": "JSONSchema" 316 | } 317 | ] 318 | }, 319 | "maximum": { 320 | "description": "The value of `maximum` MUST be a number, representing an inclusive upper\nlimit for a numeric instance.\n\nIf the instance is a number, then this keyword validates only if the\ninstance is less than or exactly equal to `maximum`.", 321 | "type": "number" 322 | }, 323 | "maxItems": { 324 | "description": "The value of this keyword MUST be a non-negative integer.\n\nAn array instance is valid against `maxItems` if its size is less than, or\nequal to, the value of this keyword.", 325 | "minimum": 0, 326 | "type": "integer" 327 | }, 328 | "maxLength": { 329 | "description": "The value of this keyword MUST be a non-negative integer.\n\nA string instance is valid against this keyword if its length is less than,\nor equal to, the value of this keyword.\n\nThe length of a string instance is defined as the number of its characters\nas defined by [RFC 7159][RFC7159].\n\n[RFC7159]: https://datatracker.ietf.org/doc/html/rfc7159", 330 | "minimum": 0, 331 | "type": "integer" 332 | }, 333 | "maxProperties": { 334 | "description": "The value of this keyword MUST be a non-negative integer.\n\nAn object instance is valid against `maxProperties` if its number of\n`properties` is less than, or equal to, the value of this keyword.", 335 | "minimum": 0, 336 | "type": "integer" 337 | }, 338 | "minimum": { 339 | "description": "The value of `minimum` MUST be a number, representing an inclusive lower\nlimit for a numeric instance.\n\nIf the instance is a number, then this keyword validates only if the\ninstance is greater than or exactly equal to `minimum`.", 340 | "type": "number" 341 | }, 342 | "minItems": { 343 | "default": 0, 344 | "description": "The value of this keyword MUST be a non-negative integer.\n\nAn array instance is valid against `minItems` if its size is greater than,\nor equal to, the value of this keyword.\n\nOmitting this keyword has the same behavior as a value of `0`.", 345 | "minimum": 0, 346 | "type": "integer" 347 | }, 348 | "minLength": { 349 | "default": 0, 350 | "description": "The value of this keyword MUST be a non-negative integer.\n\nA string instance is valid against this keyword if its length is greater\nthan, or equal to, the value of this keyword.\n\nThe length of a string instance is defined as the number of its characters\nas defined by [RFC 7159][RFC7159].\n\nOmitting this keyword has the same behavior as a value of `0`.\n\n[RFC7159]: https://datatracker.ietf.org/doc/html/rfc7159", 351 | "minimum": 0, 352 | "type": "integer" 353 | }, 354 | "minProperties": { 355 | "default": 0, 356 | "description": "The value of this keyword MUST be a non-negative integer.\n\nAn object instance is valid against `minProperties` if its number of\n`properties` is greater than, or equal to, the value of this keyword.\n\nOmitting this keyword has the same behavior as a value of `0`.", 357 | "minimum": 0, 358 | "type": "integer" 359 | }, 360 | "multipleOf": { 361 | "description": "The value of `multipleOf` MUST be a number, strictly greater than `0`.\n\nA numeric instance is valid only if division by this keyword's value\nresults in an integer.", 362 | "exclusiveMinimum": 0, 363 | "type": "number" 364 | }, 365 | "not": { 366 | "description": "This keyword's value MUST be a valid JSON Schema.\n\nAn instance is valid against this keyword if it fails to validate\nsuccessfully against the schema defined by this keyword.", 367 | "type": "JSONSchema" 368 | }, 369 | "oneOf": { 370 | "description": "This keyword's value MUST be a non-empty array. Each item of the array MUST\nbe a valid JSON Schema.\n\nAn instance validates successfully against this keyword if it validates\nsuccessfully against exactly one schema defined by this keyword's value.", 371 | "items": { 372 | "type": "JSONSchema" 373 | }, 374 | "type": "array" 375 | }, 376 | "pattern": { 377 | "description": "The value of this keyword MUST be a string. This string SHOULD be a valid\nregular expression, according to the [ECMA-262][ecma262] regular expression\ndialect.\n\nA string instance is considered valid if the regular expression matches the\ninstance successfully. Recall: regular expressions are not implicitly\nanchored.\n\n[ecma262]: https://www.ecma-international.org/publications-and-standards/standards/ecma-262/", 378 | "format": "regex", 379 | "type": "string" 380 | }, 381 | "patternProperties": { 382 | "additionalProperties": { 383 | "type": "JSONSchema" 384 | }, 385 | "description": "The value of `patternProperties` MUST be an object. Each property name of\nthis object SHOULD be a valid regular expression, according to the\n[ECMA-262][ecma262] regular expression dialect. Each property value of this\nobject MUST be a valid JSON Schema.\n\nThis keyword determines how child instances validate for objects, and does\nnot directly validate the immediate instance itself. Validation of the\nprimitive instance type against this keyword always succeeds.\n\nValidation succeeds if, for each instance name that matches any regular\nexpressions that appear as a property name in this keyword's value, the\nchild instance for that name successfully validates against each schema\nthat corresponds to a matching regular expression.\n\nOmitting this keyword has the same behavior as an empty object.\n\n[ecma262]: https://www.ecma-international.org/publications-and-standards/standards/ecma-262/", 386 | "type": "object" 387 | }, 388 | "properties": { 389 | "additionalProperties": { 390 | "type": "JSONSchema" 391 | }, 392 | "description": "The value of `properties` MUST be an object. Each value of this object MUST\nbe a valid JSON Schema.\n\nThis keyword determines how child instances validate for objects, and does\nnot directly validate the immediate instance itself.\n\nValidation succeeds if, for each name that appears in both the instance and\nas a name within this keyword's value, the child instance for that name\nsuccessfully validates against the corresponding schema.\n\nOmitting this keyword has the same behavior as an empty object.", 393 | "type": "object" 394 | }, 395 | "propertyNames": { 396 | "description": "The value of `propertyNames` MUST be a valid JSON Schema.\n\nIf the instance is an object, this keyword validates if every property name\nin the instance validates against the provided schema. Note the property\nname that the schema is testing will always be a string.\n\nOmitting this keyword has the same behavior as an empty schema.", 397 | "type": "JSONSchema" 398 | }, 399 | "readOnly": { 400 | "default": false, 401 | "description": "The value of this keyword MUST be a boolean. When multiple occurrences of\nthis keyword are applicable to a single sub-instance, the resulting value\nMUST be `true` if any occurrence specifies a `true` value, and MUST be\n`false` otherwise.\n\nIf `readOnly` has a value of boolean `true`, it indicates that the value of\nthe instance is managed exclusively by the owning authority, and attempts\nby an application to modify the value of this property are expected to be\nignored or rejected by that owning authority.\n\nAn instance document that is marked as `readOnly` for the entire document\nMAY be ignored if sent to the owning authority, or MAY result in an error,\nat the authority's discretion.\n\nFor example, `readOnly` would be used to mark a database-generated serial\nnumber as read-only.\n\nThis keyword can be used to assist in user interface instance generation.", 402 | "type": "boolean" 403 | }, 404 | "required": { 405 | "description": "The value of this keyword MUST be an array. Elements of this array, if any,\nMUST be strings, and MUST be unique.\n\nAn object instance is valid against this keyword if every item in the array\nis the name of a property in the instance.\n\nOmitting this keyword has the same behavior as an empty array.", 406 | "items": { 407 | "type": "string" 408 | }, 409 | "type": "array" 410 | }, 411 | "then": { 412 | "description": "This keyword's value MUST be a valid JSON Schema.\n\nWhen `if` is present, and the instance successfully validates against its\nsubschema, then validation succeeds against this keyword if the instance\nalso successfully validates against this keyword's subschema.\n\nThis keyword has no effect when `if` is absent, or when the instance fails\nto validate against its subschema. Implementations MUST NOT evaluate the\ninstance against this keyword, for either validation or annotation\ncollection purposes, in such cases.", 413 | "type": "JSONSchema" 414 | }, 415 | "title": { 416 | "description": "Can be used to decorate a user interface with a short label about the data\nproduced.", 417 | "type": "string" 418 | }, 419 | "type": { 420 | "description": "The value of this keyword MUST be either a string or an array. If it is an\narray, elements of the array MUST be strings and MUST be unique.\n\nString values MUST be one of the six primitive types (`\"null\"`,\n`\"boolean\"`, `\"object\"`, `\"array\"`, `\"number\"`, or `\"string\"`), or\n`\"integer\"` which matches any number with a zero fractional part.\n\nAn instance validates if and only if the instance is in any of the sets\nlisted for this keyword.", 421 | "oneOf": [ 422 | { 423 | "enum": [ 424 | "array", 425 | "boolean", 426 | "integer", 427 | "null", 428 | "number", 429 | "object", 430 | "string" 431 | ], 432 | "type": "string" 433 | }, 434 | { 435 | "items": { 436 | "enum": [ 437 | "array", 438 | "boolean", 439 | "integer", 440 | "null", 441 | "number", 442 | "object", 443 | "string" 444 | ], 445 | "type": "string" 446 | }, 447 | "type": "array" 448 | } 449 | ] 450 | }, 451 | "uniqueItems": { 452 | "default": false, 453 | "description": "The value of this keyword MUST be a boolean.\n\nIf this keyword has boolean value `false`, the instance validates\nsuccessfully. If it has boolean value `true`, the instance validates\nsuccessfully if all of its elements are unique.\n\nOmitting this keyword has the same behavior as a value of `false`.", 454 | "type": "boolean" 455 | }, 456 | "writeOnly": { 457 | "default": false, 458 | "description": "The value of this keyword MUST be a boolean. When multiple occurrences of\nthis keyword is applicable to a single sub-instance, the resulting value\nMUST be `true` if any occurrence specifies a `true` value, and MUST be\n`false` otherwise.\n\nIf `writeOnly` has a value of boolean `true`, it indicates that the value\nis never present when the instance is retrieved from the owning authority.\nIt can be present when sent to the owning authority to update or create the\ndocument (or the resource it represents), but it will not be included in\nany updated or newly created version of the instance.\n\nAn instance document that is marked as `writeOnly` for the entire document\nMAY be returned as a blank document of some sort, or MAY produce an error\nupon retrieval, or have the retrieval request ignored, at the authority's\ndiscretion.\n\nFor example, `writeOnly` would be used to mark a password input field.\n\nThese keywords can be used to assist in user interface instance generation.\nIn particular, an application MAY choose to use a widget that hides input\nvalues as they are typed for write-only fields.", 459 | "type": "boolean" 460 | } 461 | }, 462 | "keywordsByType": { 463 | "any": { 464 | "title": "Any", 465 | "values": [ 466 | "$comment", 467 | "$id", 468 | "$ref", 469 | "$schema", 470 | "allOf", 471 | "anyOf", 472 | "const", 473 | "default", 474 | "definitions", 475 | "description", 476 | "else", 477 | "enum", 478 | "examples", 479 | "if", 480 | "not", 481 | "oneOf", 482 | "readOnly", 483 | "then", 484 | "title", 485 | "type", 486 | "writeOnly" 487 | ] 488 | }, 489 | "array": { 490 | "title": "Array", 491 | "values": [ 492 | "additionalItems", 493 | "contains", 494 | "items", 495 | "maxItems", 496 | "minItems", 497 | "uniqueItems" 498 | ] 499 | }, 500 | "number": { 501 | "title": "Number", 502 | "values": [ 503 | "exclusiveMaximum", 504 | "exclusiveMinimum", 505 | "maximum", 506 | "minimum", 507 | "multipleOf" 508 | ] 509 | }, 510 | "object": { 511 | "title": "Object", 512 | "values": [ 513 | "additionalProperties", 514 | "dependencies", 515 | "maxProperties", 516 | "minProperties", 517 | "patternProperties", 518 | "properties", 519 | "propertyNames", 520 | "required" 521 | ] 522 | }, 523 | "string": { 524 | "title": "String", 525 | "values": [ 526 | "contentEncoding", 527 | "contentMediaType", 528 | "format", 529 | "maxLength", 530 | "minLength", 531 | "pattern" 532 | ] 533 | } 534 | } 535 | } -------------------------------------------------------------------------------- /import_map.json: -------------------------------------------------------------------------------- 1 | { 2 | "imports": { 3 | "std/": "https://deno.land/std@0.128.0/" 4 | } 5 | } 6 | --------------------------------------------------------------------------------