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
- Host: GitHub
- URL: https://github.com/cdaringe/runtypes-to-jsonschema
- Owner: cdaringe
- Created: 2023-01-11T20:15:47.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2024-08-05T18:33:48.000Z (almost 2 years ago)
- Last Synced: 2025-03-17T20:09:42.425Z (over 1 year ago)
- Language: TypeScript
- Size: 520 KB
- Stars: 3
- Watchers: 2
- Forks: 1
- Open Issues: 4
-
Metadata Files:
- Readme: readme.md
- Contributing: .github/contributing.md
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/).
[](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.