← 全部工具

@amritk/mjst

热度 65 更新于 开发与构建

Generate TypeScript parsers and type definitions from JSON Schemas.

npmauto-collected

安装

npm
npm install -g @amritk/mjst

通过 npm 安装。

<div align="center"

mjst — More JSON Schema Tools

Fast, type-safe TypeScript parsers, validators, types, docs, and test data — generated from JSON Schema. Plus a JSON/YAML linter to keep the schemas themselves in shape.

</div

[!WARNING] mjst is pre-alpha. APIs and generated output will change without notice until 1.0.

---

What is mjst?

mjst is a monorepo of JSON Schema (Draft 2020-12) tooling for TypeScript. At its core are code generators that turn a schema into:

| Output | Description | |:---|:---| | Parsers | Runtime functions that validate and coerce unknown input into typed values | | Validators | Error-collecting validateX functions plus flat isX boolean type guards | | Type definitions | .d.ts types matching the schema, with documentation comments | | Test data | fast-check arbitraries for property testing, plus concrete example values | | Markdown | A configuration-reference table rendered from a schema's properties |

Around the generators sits a wider toolbox:

  • API layer — @amritk/api turns route contracts into typed handlers, request/response validation, an OpenAPI 3.1 document, and a typed client
  • Linting — mjst lint checks JSON/YAML documents against JSON Schema and custom style rules, with exact line:column findings
  • Adapters — consume schemas authored in TypeBox, Zod, Valibot, or Effect as input
  • $ref resolution — resolve and inline JSON Schema / OpenAPI $refs, with a default-deny SSRF guard
  • Runtime validation — fast validation for schemas you don't know ahead of time
  • YAML parsing — a tiny, dependency-free YAML parser that keeps exact source positions

The CLI (mjst) is the primary entry point; everything above is also published as a standalone package — see Packages below.

---

Packages

| Package | Description | |:---|:---| | @amritk/mjst | CLI — generates parsers, validators, types, and test data from a schema; lints JSON/YAML (mjst lint); compiles API contracts (mjst compile-api) | | @amritk/api | Contract-first, framework-agnostic API layer — typed routes, request/response validation, OpenAPI 3.1, typed client | | @amritk/lint | Format-agnostic JSON/YAML style-guide linter — JSON Schema + custom rules, with exact line:column findings | | @amritk/generate-parsers | Programmatic API for parser + type generation | | @amritk/generate-validators | Programmatic API for validator generation | | @amritk/runtime-validators | Runtime JSON Schema validation for schemas not known ahead of time | | @amritk/generate-examples | Programmatic API for fast-check arbitraries + example data generation | | @amritk/generate-markdown | Renders a configuration-reference table from a config.schema.json into a README | | @amritk/adapters | Convert schemas from external libraries (TypeBox, Zod, Valibot, Effect) into JSON Schema | | @amritk/resolve-refs | Resolve and inline JSON Schema / OpenAPI $refs, with a default-deny SSRF guard | | @amritk/yaml | Tiny, dependency-free YAML parser with exact source positions for diagnostics | | @amritk/helpers | Shared runtime helpers used by generated code |

---

How mjst compares

Most tools in this space pick a single lane — types or validation or docs. mjst generates the whole TypeScript surface from one schema, and it can also consume schemas authored in other libraries as input.