json-schema-typed
Advanced tools
Comparing version 7.0.3 to 8.0.0
{ | ||
"name": "json-schema-typed", | ||
"description": "JSONSchema TypeScript definitions.", | ||
"version": "7.0.3", | ||
"description": "JSON Schema TypeScript definitions with complete inline documentation.", | ||
"license": "BSD-2-Clause", | ||
"files": [ | ||
"dist-*/", | ||
"bin/" | ||
], | ||
"pika": true, | ||
"sideEffects": false, | ||
"keywords": [ | ||
"jsonschema", | ||
"typescript" | ||
], | ||
"homepage": "https://github.com/typeslick/json-schema-typed", | ||
"contributors": [ | ||
{ | ||
"name": "Austin Wright", | ||
"email": "aaa@bzfx.net" | ||
}, | ||
{ | ||
"name": "Henry Andrews", | ||
"email": "henry@cloudflare.com" | ||
}, | ||
{ | ||
"name": "Geraint Luff", | ||
"email": "luffgd@gmail.com" | ||
}, | ||
{ | ||
"name": "Jay Rylan", | ||
"email": "jay@jayrylan.com" | ||
} | ||
], | ||
"version": "8.0.0", | ||
"homepage": "https://github.com/jrylan/json-schema-typed/tree/main/dist/node", | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/typeslick/json-schema-typed.git" | ||
"url": "https://github.com/jrylan/json-schema-typed.git" | ||
}, | ||
"dependencies": {}, | ||
"devDependencies": { | ||
"@babel/cli": "7.6.4", | ||
"@babel/core": "7.6.4", | ||
"@babel/runtime-corejs2": "7.6.3", | ||
"@loomble/cspell-dictionary": "1.0.0", | ||
"@microsoft/api-extractor": "7.3.4", | ||
"@pika/pack": "0.5.0", | ||
"@pika/plugin-build-node": "0.7.1", | ||
"@pika/plugin-build-types": "0.7.1", | ||
"@pika/plugin-build-web": "0.7.1", | ||
"@pika/plugin-standard-pkg": "0.7.1", | ||
"@types/babel__core": "7.1.3", | ||
"@types/jest": "24.0.20", | ||
"@types/jest-diff": "20.0.1", | ||
"@types/node": "12.11.7", | ||
"babel-core": "6.26.3", | ||
"babel-jest": "24.9.0", | ||
"babel-preset-slick": "7.0.4", | ||
"core-js": "3.3.4", | ||
"cspell": "4.0.31", | ||
"deep-sort-object": "1.0.2", | ||
"jest": "24.9.0", | ||
"jest-serializer-path": "0.1.15", | ||
"prettier": "1.18.2", | ||
"tsconfig-slick": "3.0.2", | ||
"tslint": "5.20.0", | ||
"tslint-slick": "5.0.0", | ||
"typedoc": "0.15.0", | ||
"typedoc-plugin-markdown": "2.2.11", | ||
"typescript": "3.6.4", | ||
"typescript-tslint-plugin": "0.5.4" | ||
"author": { | ||
"name": "Jeremy Rylan", | ||
"url": "https://github.com/jrylan" | ||
}, | ||
"esnext": "dist-src/index.js", | ||
"main": "dist-node/index.js", | ||
"module": "dist-web/index.js", | ||
"types": "dist-types/index.d.ts" | ||
"main": "./draft-2020-12.js", | ||
"type": "module", | ||
"exports": { | ||
".": "./draft-2020-12.js", | ||
"./draft-07": "./draft-07.js", | ||
"./draft-2019-09": "./draft-2019-09.js", | ||
"./draft-2020-12": "./draft-2020-12.js" | ||
}, | ||
"keywords": [ | ||
"jsonschema", | ||
"typescript", | ||
"types", | ||
"definitions", | ||
"json", | ||
"schema" | ||
] | ||
} |
119
README.md
@@ -1,16 +0,22 @@ | ||
# json-schema-typed | ||
[![npm](https://img.shields.io/npm/v/json-schema-typed.svg?style=flat-square)](https://npmjs.org/package/json-schema-typed) | ||
[![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) | ||
[![License](https://img.shields.io/badge/license-BSD--2--Clause-blue.svg?style=flat-square)][license] | ||
JSON Schema draft-07 TypeScript definitions with complete inline documentation | ||
for each property. | ||
# JSON Schema Typed | ||
[![code style: Prettier](https://img.shields.io/badge/code_style-prettier-ff69b4.svg?style=flat-square)](https://github.com/prettier/prettier) | ||
[![npm](https://img.shields.io/npm/v/json-schema-typed.svg?style=flat-square)](https://npmjs.org/package/json-schema-typed) | ||
[![semantic-release](https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg?style=flat-square)](https://github.com/semantic-release/semantic-release) | ||
[![License](https://img.shields.io/badge/license-BSD--2--Clause-blue.svg?style=flat-square)](https://github.com/typeschema/json-schema-typed/blob/master/LICENSE) | ||
JSON Schema TypeScript definitions with complete inline documentation. | ||
**NOTE:** This library only supports defining schemas. You will need a separate | ||
library for data validation. | ||
There are 3 JSON Schema drafts included in this package: | ||
- `draft-07` | ||
- `draft-2019-09` | ||
- `draft-2020-12` | ||
## Install | ||
```sh | ||
npm install json-schema-typed # NPM | ||
yarn add json-schema-typed # or Yarn | ||
npm install json-schema-typed | ||
``` | ||
@@ -20,45 +26,84 @@ | ||
TypeScript: | ||
1. Chose which draft you'd like to import. | ||
```typescript | ||
import { JSONSchema } from 'json-schema-typed' | ||
- The main package export points to the latest supported stable draft, currently | ||
`draft-2020-12`. Future releases that point the main package export to a new | ||
draft will always incur a bump to the major semantic version. | ||
const schema: JSONSchema = { | ||
// ... | ||
} | ||
``` | ||
```ts | ||
import { type JSONSchema } from "json-schema-typed"; | ||
``` | ||
## API | ||
- Or you can specify the exact draft you need. | ||
```ts | ||
import { type JSONSchema } from "json-schema-typed/draft-2020-12"; | ||
``` | ||
Additional exports: | ||
2. Define a schema | ||
| Name | Type | Purpose | | ||
| --------------------------- | ---------- | ---------------------------------------------------------- | | ||
| `JSONSchemaFormat` | Enum | JSON Schema string formats. | | ||
| `JSONSchemaType` | Enum | Standard values for the "type" field. | | ||
| `JSONSchemaContentEncoding` | Enum | JSON Schema content encoding strategies. | | ||
| `JSONSchemaKeys` | `string[]` | All the standard property keys available in a JSON schema. | | ||
```ts | ||
import { Format, type JSONSchema } from "json-schema-typed"; | ||
const schema: JSONSchema = { | ||
properties: { | ||
email: { | ||
format: Format.Email, | ||
type: "string", | ||
}, | ||
}, | ||
type: "object", | ||
}; | ||
// The JSONSchema namespace also provides type-specific narrowed interfaces | ||
const stringSchema: JSONSchema.String = { | ||
// Only { type: "string" } and common keywords are allowed | ||
maxLength: 100, | ||
type: "string", | ||
}; | ||
``` | ||
## Upgrading | ||
Version `10.0.0` has breaking changes from the previous release. | ||
- Now a | ||
[pure ESM package](https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c). | ||
- Many exports were renamed. The table below reflects the new export names. | ||
These are considered final and unlikely to change in future releases. | ||
- The `JSONSchema` type was changed from an `interface` to a `type` which is a | ||
mixed union that allows `boolean` values in order to properly align with the | ||
JSON Schema spec. If you were previously extending the `JSONSchema` interface, | ||
you can access the `interface` directly with `JSONSchema.Interface`. | ||
- The previous main package export pointed to Draft 7. Import it directly if you | ||
need to continue using it: | ||
```ts | ||
import { type JSONSchema } from "json-schema-typed/draft-07"; | ||
``` | ||
## Exports supported in each draft module | ||
| Name | Type | Purpose | | ||
| ----------------- | --------------- | ------------------------------------------------------------------ | | ||
| `$schema` | `string` | Draft meta schema URL that can be used with the `$schema` keyword. | | ||
| `ContentEncoding` | Enum object | String content encoding strategies. | | ||
| `draft` | `string` | Draft version. | | ||
| `Format` | Enum object | String formats. | | ||
| `JSONSchema` | TypeScript Type | Used to define a JSON Schema. | | ||
| `keywords` | `string[]` | All the keywords for the imported draft. | | ||
| `TypeName` | Enum object | Simple type names for the `type` keyword. | | ||
## Versioning | ||
``` | ||
+----- Major version is synchronized with the major version of JSON Schema. | ||
| +--- Minor version has BREAKING CHANGE and/or new features. | ||
| | +- Patch version. | ||
| | | | ||
x.x.x | ||
``` | ||
This library follows [semantic versioning](https://semver.org). | ||
--- | ||
## Sponsors | ||
- [Loomble](https://loomble.com/) | ||
## Maintainers | ||
- [Jay Rylan](https://jayrylan.com/) | ||
- [Jeremy Rylan](https://github.com/jrylan) | ||
## License | ||
[BSD-2-Clause](https://github.com/typeschema/json-schema-typed/blob/master/LICENSE) | ||
[BSD-2-Clause][license] | ||
[license]: https://github.com/jrylan/json-schema-typed/blob/main/dist/node/LICENSE.md |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
Unidentified License
License(Experimental) Something that seems like a license was found, but its contents could not be matched with a known license.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
173700
0
12
4300
109
Yes
1
80
2