Socket
Book a DemoInstallSign in
Socket

@etclabscore/json-schema-to-types

Package Overview
Dependencies
Maintainers
4
Versions
25
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@etclabscore/json-schema-to-types

This is a JSON-Schema transpiler. It converts a JSON Schema into types for various strongly typed languages.

latest
npmnpm
Version
1.12.0
Version published
Maintainers
4
Created
Source

JSON-Schema-To-Types

This is a JSON-Schema transpiler. It converts a JSON Schema into types for various strongly typed languages.

Features:

  • Supports the following languages:
    • Typescript
    • Rust
    • Go
    • Python
  • minimal external dependencies
  • circular JSON structure handling
  • Supports merging multiple JSONSchema into one set of types
  • Generates titles for schemas that are missing them
  • Run in browser / node

Installing

npm install --save @etclabscore/json-schema-to-types

Usage

const schema = {
  title: "testerooskies",
  type: "object",
  properties: {
    fooThing: { title: "foo", type: "string" },
    barThing: { title: "bar", type: "number" },
  },
};
const transpiler = new JsonSchemaToTypes(schema);

console.log(transpiler.toRust())
/** outputs:
"#[derive(Serialize, Deserialize)]
pub struct testerooskies {
    pub(crate) fooThing: foo,
    pub(crate) barThing: bar,
**
pub type foo = String;
pub type bar = String;"
**/

console.log(transpiler.toTypescript());
/**outputs
"export interface testerooskies {
  fooThing: foo;
  barThing: bar;
}
export type foo = string;
export type bar = string;"
**/

To add a new integration test case

npm run test:generate

Contributing

How to contribute, build and release are outlined in CONTRIBUTING.md, BUILDING.md and RELEASING.md respectively. Commits in this repository follow the CONVENTIONAL_COMMITS.md specification.

FAQs

Package last updated on 25 Jun 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