JsonSchemaModule
PackageReified.Schema
JsonSchema
JsonSchema.generate publishes a schema as JSON Schema Draft 2020-12. Field names, required properties, nested shapes,
union tags, and portable interpreted constraints come from the same declaration used by parsing and JSON codecs.
Only rules the target can enforce are lowered to JSON Schema keywords. Runtime-only or non-portable constraints remain
visible as prose and x-reified-runtime-constraints; generation never claims that another tool enforces an omitted rule.
Summary
| Name | Signature | Synopsis |
|---|---|---|
| generate | JsonSchema.generate schema | Generates a compact JSON Schema document from any completed schema declaration. |
| generateValue | JsonSchema.generateValue schema | Generates a compact JSON Schema document for a standalone value schema. |
Generates a compact JSON Schema document from any completed schema declaration.
Parameters
| Name | Type | Description |
|---|---|---|
| schema | Schema<'model> | The record, primitive, collection, union, or other completed schema to lower. |
Returns
string
Verification Examples
open Reified.SchemaDSL
open Reified.ConstraintDSL
type Customer = { Name: string; Email: string }
let customerSchema =
schema<Customer> {
field _.Name { constrain present }
field _.Email { constraints [ present; email ] }
construct (fun name email -> { Name = name; Email = email })
}
let document = JsonSchema.generate customerSchema
// {"$schema":"https://json-schema.org/draft/2020-12/schema","type":"object","properties":{...},"required":[...]}