Catalog npm
PACKAGE EXPLORERView in registry

1schema

npm

One schema to rule them all

jsonschemaschematypescript
Versions collected8
Direct dependencies35From release 1.0.0
Last observed20 Oct, 18:37 UTC

README

Current package documentation

1schema

1schema provides friendly developer tooling for runtime checking of TypeScript schemas. It uses the powerful and effective ts-json-schema-generator to generate JSON Schema which can be validated at runtime using 1schema's built-in support for Ajv or any other JSON Schema validator. For example, in our Python projects we use jsonschema.

This is way better than writing and maintaining JSON Schema by hand, and if you use TypeScript you also get the benefit of compile-time checking.

Since the schemas are written in TypeScript it's ideal for TypeScript projects, however it's easy to use in JavaScript projects, and works in non-JavaScript projects too.

I didn't write this blog post, but it explains the idea really well.

We've been using this pattern for a while at Metabolize–Curvewise, both for validating user uploads and validating across interface boundaries. This open-source tooling is new and considered alpha. Developer feedback and contributions welcome!

Why not use ts-json-schema-generator directly?

You can! However, to provide a smooth development experience, 1schema provides a few niceties:

  1. Globbing
  2. Formatting
  3. Checking that the schema are up to date
  4. Pruning JSON schemas when their corresponding source files are removed

How it works

  • In your project, create a schema.ts file:

    export type ContactMethodType = 'mobile' | 'home' | 'work' | 'other'
    
    export interface Address {
      streetAddress: string
      locality: string
      region: string
      postalCode: string
      country: string
    }
    
    export interface Contact {
      familyName: string
      givenName: string
      honorificPrefix?: string
      honorificSuffix?: string
      nickname?: string
      url?: string
      imageUrl?: string
      email: {
        address: string
        type: ContactMethodType
      }[]
      phone: {
        phoneNumber: string
        type: ContactMethodType
      }[]
      address: Array<Address & { type: ContactMethodType }>
      birthdate: Date
      gender?: string
    }
    
  • Run 1schema update to generate generated/schema.json with all exported types and their dependents. Check in this file.

  • COMING SOON: At runtime, import { validate } from '1schema' and validate(inputData).

  • If you're using TypeScript, cast the validated input to the appropriate type from your schema (e.g. const contact = inputData as Contact) to get compile-time checking.

  • In CI, run 1schema check to verify the generated schema are up to date.

Your schema files are just ordinary TypeScript files so they can import and extend other TypeScript types and schemas, so long as the types are supported by ts-json-schema-validator.

If you have a tsconfig.json it will be used and if not one is provided for you.

You can spread schemas across multiple files: If you create: this.schema.ts, that.schema.ts, the-other/schema.ts. Running 1schema update will generate generated/this.schema.json, generated/that.schema.json and the-other/schema.json.

We use 1schema with Werkit, a toolkit for encapsulating Python functions on AWS Lambda.

Acknowledgements

Serious thanks to Dominik Moritz for maintaining the wonderful ts-json-schema-validator tool. And thanks to Jacob Beard who turned me back onto JSON Schema in the first place.

Downloads & popularity

Awaiting observations

No metric observations yet

Download counts and popularity will appear here as the collector receives them.

Versions 8

Collected releases
VersionPublishedDirect dependenciesOpen version
1.0.0Registry latest11 Mar 202635
0.2.014 May 202237
0.1.526 Jul 202136
0.1.425 Jul 202136
0.1.325 Jul 202136
0.1.225 Jul 202134
0.1.125 Jul 202134
0.1.025 Jul 202132

Package advisories

0
No matching advisories collected

This describes our collected data; it is not a security assessment.

Repository

ACCESSIBLE
metabolize/1schema

Shared repository data · GitHub

License detected in repository
MIT
License branch / ref
main
Last push
1 Apr 2026
Archived
No
Contributor identities
— · partial collection

Public sponsor counts have not been collected. These signals belong to the repository owner.

Downloads & popularity

0count
Gauge · observed snapshots21 Oct 2026
10.50
2026-10-21: 0 · observed 2026-10-21T20:12:24.6639241Z
21 Oct21 Oct

github · 1 observations shown. Missing days are unknown.

View observed values
Date / source periodValueObserved at
2026-10-2102026-10-21T20:12:24.6639241Z

Metadata history

Meaningful changes
Current collected state Current

Observed since 20 Oct, 18:37 UTC

No superseded metadata states collected. Unchanged observations do not create new revisions.

Record identity

package:0b80817c271757abe02298fe1f7ad5980c2fae4883e5d98f3eeaf91a0864d96d