JsonSchema
Defined in: extract/schema.ts:708
JSON Schema utilities for extraction specs.
Provides static methods to derive JSON Schema from extraction specs.
Constructors
Section titled “Constructors”Constructor
Section titled “Constructor”new JsonSchema():
JsonSchema
Returns
Section titled “Returns”JsonSchema
Methods
Section titled “Methods”output()
Section titled “output()”Call Signature
Section titled “Call Signature”
staticoutput(source,options?):JsonSchemaObject
Defined in: extract/schema.ts:747
Generates a JSON Schema describing the output shape produced by a spec. Works statically without executing against data.
Use cases:
- Generate API contracts / OpenAPI schemas
- Generate TypeScript types
- Document output structure
Parameters
Section titled “Parameters”source
Section titled “source”A Spec or a compiled Plan
options?
Section titled “options?”Optional schema generation options
Returns
Section titled “Returns”JSON Schema describing the output structure
Example
Section titled “Example”// From a Specconst spec = extract($ => ({ name: $.get('user').get('name').string(), age: $.get('user').get('age').number(),}))const schema = JsonSchema.output(spec)
// From a Plan with optionsconst plan = new Planner() .in(loadFile('data.json')) .mapIn(parseJson()) .emit((out, $) => out .add('name', $.get('name').string()) .add('age', $.get('age').number()) ) .compile()const schema = JsonSchema.output(plan, { id: 'https://example.com/schema', title: 'User', deduplicate: true,})Call Signature
Section titled “Call Signature”
staticoutput(source,options?):JsonSchemaObject
Defined in: extract/schema.ts:748
Generates a JSON Schema describing the output shape produced by a spec. Works statically without executing against data.
Use cases:
- Generate API contracts / OpenAPI schemas
- Generate TypeScript types
- Document output structure
Parameters
Section titled “Parameters”source
Section titled “source”Plan<unknown>
A Spec or a compiled Plan
options?
Section titled “options?”Optional schema generation options
Returns
Section titled “Returns”JSON Schema describing the output structure
Example
Section titled “Example”// From a Specconst spec = extract($ => ({ name: $.get('user').get('name').string(), age: $.get('user').get('age').number(),}))const schema = JsonSchema.output(spec)
// From a Plan with optionsconst plan = new Planner() .in(loadFile('data.json')) .mapIn(parseJson()) .emit((out, $) => out .add('name', $.get('name').string()) .add('age', $.get('age').number()) ) .compile()const schema = JsonSchema.output(plan, { id: 'https://example.com/schema', title: 'User', deduplicate: true,})