npm.io
2.0.2 • Published 7 months ago

ya-json-schema-types

Licence
MIT
Version
2.0.2
Deps
1
Size
28 kB
Vulns
0
Weekly
0
Stars
5

ya-json-schema-types

TypeScript types for JSONSchema 2020-12

GitHub license

JSONSchema 2020-12 types for TypeScript with a focus on detecting syntax errors for a better developer experience.

import { type JSONSchema } from "ya-json-schema-types";

const mySchema: JSONSchema = {
  type: "string",
};

Also export an alternative type for convenience allowing to create more expressive types for clarity and schemas that allow proper TypeScript types generation.

import { type ExpressiveJSONSchema } from "ya-json-schema-types";

// This still works
const mySchema: ExpressiveJSONSchema = {
  type: "string",
};

// This is not considered "expressive"
const myComposedSchema: ExpressiveJSONSchema = {
  $ref: "aRef",
  type: "string",
  anyof: [
    {
      const: "test",
    },
    {
      const: true,
    },
  ],
};

Authors

License

MIT