JavaScript library v3.1.1 providing compact shorthand syntax for JSON Schema definitions. Transforms string types, references (local with #, external with $), and shorthand functions into full schema objects. Supports all major JSON Schema constructs: object, array, primitive types, composition (allOf/oneOf/anyOf), not, and nested references. Includes TypeScript type definitions for schema validation. Active development with regular releases; minimal dependencies. Differentiator: reduces schema boilerplate significantly while maintaining full JSON Schema compatibility.
npm install json-schema-shorthandNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Demonstrates basic usage: creating a JSON Schema with string shorthands in object properties, and using helper functions with optional description and extra properties.
Use string literal `'integer'` where you want integer-typed properties, not `'number'`.
If your property key intentionally starts with `#` or `$`, escape by using explicit `{ type: '...', $ref: undefined }` or use the `shorthand()` function only on the value, not the key.Always pass description as a string (or `undefined`) if you intend to pass extra schema as second argument: `object(undefined, { additionalProperties: false })`.Use named imports: `import { shorthand } from 'json-schema-shorthand'` or `import shorthand from 'json-schema-shorthand'` (both work).Manually expand nested arrays using `array()` function or ensure the inner schemas are already expanded.
Add `"type": "module"` to package.json, or use `const shorthand = require('json-schema-shorthand')`.Use `import shorthand from 'json-schema-shorthand'` (ESM) or `const shorthand = require('json-schema-shorthand').default` (CommonJS).Use `import { object } from 'json-schema-shorthand'`.No dependency data recorded yet.