# 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.

Latest version **0.0.26** (published 2023-08-23) · MIT license · 0 weekly downloads

## Install

```sh
npm install io-ts-from-json-schema
pnpm add io-ts-from-json-schema
yarn add io-ts-from-json-schema
bun add io-ts-from-json-schema
```

Provides the command `iotsfjs`.

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.0.26 |
| Published | 2023-08-23 |
| First published | 2020-05-15 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 4 |
| Unpacked size | 79.1 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 33 |
| Maintainers | maasglobal, cyberixae |
| Keywords | typescript, io-ts, code-generation |

## Links

- npm: https://www.npmjs.com/package/io-ts-from-json-schema
- Repository: https://github.com/maasglobal/io-ts-from-json-schema
- Homepage: https://github.com/maasglobal/io-ts-from-json-schema/
- Issues: https://github.com/maasglobal/io-ts-from-json-schema/issues
- npm.io page: https://npm.io/package/io-ts-from-json-schema

## Dependencies (4)

- [glob](https://npm.io/package/glob.md) ^7.1.6
- [yargs](https://npm.io/package/yargs.md) ^15.3.1
- [uri-template](https://npm.io/package/uri-template.md) ^1.0.1
- [io-ts-codegen](https://npm.io/package/io-ts-codegen.md) ^0.4.5

## Alternatives

- [@openai/codex-sdk](https://npm.io/package/@openai/codex-sdk.md) — 731.4K weekly downloads
- [babel-plugin-transform-react-jsx](https://npm.io/package/babel-plugin-transform-react-jsx.md) — 565.0K weekly downloads
- [babel-helper-remove-or-void](https://npm.io/package/babel-helper-remove-or-void.md) — 508.5K weekly downloads
- [@pnpm/store-controller-types](https://npm.io/package/@pnpm/store-controller-types.md) — 186.9K weekly downloads
- [react-native-signature-canvas](https://npm.io/package/react-native-signature-canvas.md) — 155.6K weekly downloads

## Recent versions

- 0.0.26 (latest) — 2023-08-23
- 0.0.26-alpha1 (alpha) — 2023-08-17
- 0.0.25 — 2023-08-17
- 0.0.24 — 2023-06-01
- 0.0.25-alpha1 — 2023-06-01
- 0.0.23 — 2023-01-17
- 0.0.22 — 2023-01-17
- 0.0.22-alpha1 — 2023-01-17
- 0.0.21 — 2022-05-06
- 0.0.20 — 2022-04-07
- 0.0.20-alpha7 — 2022-04-01
- 0.0.20-alpha6 — 2022-04-01
- 0.0.20-alpha5 — 2022-04-01
- 0.0.20-alpha4 — 2022-04-01
- 0.0.20-alpha3 — 2022-04-01
- … 32 more at https://npm.io/package/io-ts-from-json-schema/versions

## README

# io-ts-from-json-schema

Iotsfjs is a static code generation utility used for converting [json schema](https://json-schema.org/) files into static [TypeScript](https://www.typescriptlang.org/) types and [io-ts](https://github.com/gcanti/io-ts) runtime validators.

## Basic Use

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

## Usage Example

```Shell
# 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/
```

---
_Source: https://npm.io/package/io-ts-from-json-schema · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
