An open API service indexing awesome lists of open source software.

https://github.com/cdaringe/runtypes-to-jsonschema

Converts runtypes schema to jsonschema documents
https://github.com/cdaringe/runtypes-to-jsonschema

Last synced: about 1 year ago
JSON representation

Converts runtypes schema to jsonschema documents

Awesome Lists containing this project

README

          

# runtypes-to-jsonschema

convert [runtypes](https://github.com/pelotom/runtypes) schemas to [jsonschema](https://json-schema.org/understanding-json-schema/reference/).

[![main](https://github.com/cdaringe/runtypes-to-jsonschema/actions/workflows/main.yml/badge.svg)](https://github.com/cdaringe/runtypes-to-jsonschema/actions/workflows/main.yml)

## install

`npm install runtypes-to-jsonschema`

## usage

```ts
import { tojsonschema } from "runtypes-to-jsonschema";
import * as rt from "runtypes";

const myRtSchema = rt.Record({ foo: rt.Literal("bar") });
const myjsonschema = tojsonschema(myRtSchema);
// {
// type: "object",
// properties: { foo: { const: "bar" } },
// required: ["foo"],
// }
```

see [test.ts](./test.ts) for more.