Socket
Socket
Sign inDemoInstall

json-schema-typed

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

json-schema-typed - npm Package Compare versions

Comparing version 7.0.3 to 8.0.0

draft-07.js

91

package.json
{
"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"
]
}

@@ -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
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc