Hyperlinkv0.8.0-beta.28

Schema

Schema.toJsonSchemaDocumentfunctioneffect/Schema.ts:13426
(
  schema: Constraint,
  options?: ToJsonSchemaOptions
): JsonSchema.Document<"draft-2020-12">

Returns a JSON Schema document using draft 2020-12.

Details

The options parameter controls generation details such as additional properties and synthesized check descriptions; it does not change the draft target.

Gotchas

JSON Schema generation is best-effort. Some Effect schema semantics cannot be represented exactly in JSON Schema, and importing an emitted JSON Schema may produce an equivalent approximation rather than the original schema shape.

converting
Source effect/Schema.ts:1342612 lines
export function toJsonSchemaDocument(
  schema: Constraint,
  options?: ToJsonSchemaOptions
): JsonSchema.Document<"draft-2020-12"> {
  const sd = toRepresentation(schema)
  const jd = InternalStandard.toJsonSchemaDocument(sd, options)
  return {
    dialect: "draft-2020-12",
    schema: jd.schema,
    definitions: jd.definitions
  }
}