jscheam

Values

pub fn allow_additional_props(
  object_type: property.Type,
) -> property.Type

Explicitly allows any additional properties (outputs “additionalProperties”: true)

pub fn array(item_type: property.Type) -> property.Type

Creates an array type with the specified item type

pub fn boolean() -> property.Type

Creates a boolean type for JSON Schema

pub fn constrain_additional_props(
  object_type: property.Type,
  schema: property.Type,
) -> property.Type

Constrains additional properties to conform to the specified schema

pub fn description(
  property: property.Property,
  desc: String,
) -> property.Property

Adds a description to a property for documentation purposes

pub fn disallow_additional_props(
  object_type: property.Type,
) -> property.Type

Disallows additional properties (outputs “additionalProperties”: false)

pub fn enum(
  property: property.Property,
  values: List(json.Json),
) -> property.Property

Adds an enum constraint to a property that restricts values to a fixed set Example: prop(“color”, string()) |> enum(enum_strings([“red”, “green”, “blue”]))

pub fn float() -> property.Type

Creates a float/number type for JSON Schema

pub fn integer() -> property.Type

Creates an integer/number type for JSON Schema

pub fn null() -> property.Type

Creates a null type for JSON Schema

pub fn object(
  properties: List(property.Property),
) -> property.Type

Creates an object type with the specified properties By default allows any additional properties (JSON Schema default behavior - omits the field)

pub fn optional(property: property.Property) -> property.Property

Makes a property optional (not required in the schema)

pub fn pattern(
  property: property.Property,
  regex: String,
) -> property.Property

Adds a pattern constraint to a property that restricts values to match a regex pattern Example: prop(“phone”, string()) |> pattern(“^(\([0-9]{3}\))?[0-9]{3}-[0-9]{4}$”)

pub fn prop(
  name: String,
  property_type: property.Type,
) -> property.Property

Creates a property with the specified name and type Properties are required by default

pub fn string() -> property.Type

Creates a string type for JSON Schema

pub fn to_json(object_type: property.Type) -> json.Json

Converts a Type to a JSON Schema document This is the main function to generate JSON Schema from your type definitions

pub fn union(types: List(property.Type)) -> property.Type

Creates a union type that accepts multiple types (e.g., string or null) Example: union([string(), null()]) creates a schema that accepts both strings and null values

Search Document