New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

io-ts-from-json-schema

Package Overview
Dependencies
Maintainers
2
Versions
47
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

io-ts-from-json-schema

Iotsfjs is a static code generation utility used for converting json schema files into static TypeScript types and io-ts runtime validators.

  • 0.0.26
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
324
decreased by-38.52%
Maintainers
2
Weekly downloads
 
Created
Source

io-ts-from-json-schema

Iotsfjs is a static code generation utility used for converting json schema files into static TypeScript types and io-ts runtime validators.

Basic Use

npm install -g io-ts-from-json-schema typescript
iotsfjs --inputFile schema.json --outputDir output

Usage Example

# Create a Project
mkdir example && cd example
npm init -f && npm install --peer fp-ts io-ts io-ts-types

# Create a Schema File
npm install --peer maas-schemas-ts
mkdir -p ./schemas/examples && echo '{
  "$id": "http://example.com/iotsfjs/examples/user.json",
  "description": "Example user schema with an external dependency",
  "type": "object",
  "definitions": {
    "name": {
      "description": "Human-readable name of the user",
      "type": "string"
    }
  },
  "properties": {
    "name": {
      "$ref": "#/definitions/name"
    },
    "phone": {
      "$ref": "http://maasglobal.com/core/components/common.json#/definitions/phone"
    }
  },
  "required": ["name", "phone"],
  "additionalProperties": false,
  "examples": [
    {
      "name": "Joe User",
      "phone": "+358407654321"
    }
  ]
}' > ./schemas/examples/user.json

# Generate TypeScript Code
npm install --dev io-ts-from-json-schema typescript
./node_modules/.bin/iotsfjs --inputFile 'schemas/**/*.json' --outputDir src --base http://example.com/iotsfjs/ --import http://maasglobal.com/^maas-schemas-ts/lib/

# Generate Tests
npm install --dev jest @types/jest doctest-ts ts-jest io-ts-validator maas-schemas-ts fp-ts io-ts io-ts-types
./node_modules/.bin/ts-jest config:init
./node_modules/.bin/doctest-ts --jest `find src -name '*.ts'`

# Run Tests
./node_modules/.bin/jest --testPathPattern --testMatch **/*.doctest.ts --roots src/

# Compile TypeScript Code
./node_modules/.bin/tsc -d --rootDir src src/examples/user.ts --outDir lib/

Keywords

FAQs

Package last updated on 23 Aug 2023

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