Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@types/json-schema

Package Overview
Dependencies
Maintainers
1
Versions
19
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@types/json-schema

TypeScript definitions for json-schema 4.0, 6.0 and

  • 7.0.10
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
37M
increased by0.58%
Maintainers
1
Weekly downloads
 
Created

What is @types/json-schema?

The @types/json-schema package provides TypeScript type definitions for JSON Schema. It allows developers to use JSON Schema in TypeScript projects with type checking, enabling them to define valid JSON structures more accurately and with the benefits of autocompletion and compile-time validation. This package does not include functionality to validate JSON data against schemas but rather provides types to assist in writing code that can create, manipulate, or understand JSON Schemas.

What are @types/json-schema's main functionalities?

Defining a JSON Schema

This code sample demonstrates how to define a simple JSON Schema for an object with required 'name' (string) and 'age' (number) properties using TypeScript. The @types/json-schema package provides types that make it easier to define such schemas with the benefits of type checking.

{"$schema": "http://json-schema.org/draft-07/schema#","type": "object","properties": {"name": {"type": "string"},"age": {"type": "number"}},"required": ["name", "age"]}

Using JSON Schema with TypeScript interfaces

This example shows how to define a TypeScript interface and a corresponding JSON Schema. The @types/json-schema package allows the use of JSONSchema7 (or other version-specific types) to ensure the schema definition is type-safe.

interface Person {name: string; age: number;}; const personSchema: JSONSchema7 = {type: 'object', properties: {name: {type: 'string'}, age: {type: 'number'}}, required: ['name', 'age']};

Other packages similar to @types/json-schema

FAQs

Package last updated on 16 Mar 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

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