Registry / devops / functional-json-schema

functional-json-schema

JSON →
library1.0.0jsnpmunverified

A JavaScript library for building JSON Schema objects using a functional DSL. v1.0.0 (stable, no recent updates). Provides functions to define schema properties, types, arrays, enums, definitions, and $refs in a composable way. Supports Draft-06 and Draft-07. Differentiators: programmatic schema construction with nested object syntax, built-in type helpers, and definition management. Lightweight, no runtime dependencies.

devops
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

Default export does not exist; use namespace import.

import * as schema from 'functional-json-schema'

Named import for type helpers is also valid.

import { types } from 'functional-json-schema'

Exported function is `definition`, not `define`.

import { definition } from 'functional-json-schema'

`schema` is the main function, not a default export. Always invoke as `schema.schema()` or import `schema` function directly.

import * as schema from 'functional-json-schema'; const JsonSchema = schema.schema(props, definitions, options)

Shows basic usage of `schema` and `types.type` to build a JSON Schema object in CommonJS style.

const { schema, types } = require('functional-json-schema'); const jsonSchema = schema( { name: types.type('string', { required: true }), age: types.type('number'), }, null, { schema: 'http://json-schema.org/draft-06/#' } ); console.log(JSON.stringify(jsonSchema, null, 2));
Debug
Known footguns
gotchaNamespace import is required; default export does not exist.
deprecatedThe library is based on Draft-06; Draft-07 might have differences.
gotchaArray items with `types.arrayOf` must define item type; missing type leads to invalid schema.
gotchaDefinitions passed as second argument must be an object with definition names as keys; incorrect format breaks output.
Upgrade
Version history

Breaking-change detection hasn't run for this library yet.

Audit
Security & dependencies

CVE tracking and dependency tree are planned for a later release.

Agent activity
8 hits · last 30 days
gptbot
3
ahrefsbot
1
Resources