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

@env0/ts-transform-json-schema

Package Overview
Dependencies
Maintainers
5
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@env0/ts-transform-json-schema

Generate inline JSON schema from TypeScript types

  • 2.0.8
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
2
decreased by-60%
Maintainers
5
Weekly downloads
 
Created
Source

ts-transform-json-schema

  • 🌳 Generate inline JSON schema from TypeScript types

Example

In

import * as JsonSchema from "ts-transform-json-schema";

export interface SomeInterface {
  a: string;
  b: number;
  c?: boolean;
}

export const schema = JsonSchema.fromType<SomeInterface>({
  additionalProperties: false
});
// tsconfig.json
{
  "compilerOptions": {
    "target": "es2015",
    "plugins": [
      {
        "transform": "ts-transform-json-schema",
        "type": "program"
      }
    ]
  }
}

Out

import * as JsonSchema from "ts-transform-json-schema";
export const schema = {
  additionalProperties: false,
  type: "object", 
  properties: { 
    a: { type: "string" }, 
    b: { type: "number" }, 
    c: { type: "boolean" } 
  }, 
  $schema: "http://json-schema.org/draft-07/schema#" 
};

Installation

npm install ts-transform-json-schema ttypescript --save-dev

Usage

// tsconfig.json
{
  "compilerOptions": {
    "target": "es2015",
    "plugins": [
      {
        "transform": "ts-transform-json-schema",
        "type": "program"
      }
    ]
  }
}

See TTypeScript for docs about integration with other toolchains.


See ./example for a basic setup based on TTypeScript

License

MIT

Keywords

FAQs

Package last updated on 06 Aug 2020

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