Peri.JSONSchema.Encoder (peri v0.7.0)

View Source

Encodes a Peri schema definition into a JSON Schema (Draft 7) map.

Field-level metadata attached via {:meta, type, opts} is read during encoding and surfaced as JSON Schema annotation keywords (title, description, examples, deprecated).

Dynamic Peri types (:dependent, :cond, :custom) cannot be expressed statically. The :on_unsupported option controls the fallback:

  • :omit (default) — emit %{} (true schema)
  • :true_schema — same as :omit
  • :raise — raise Peri.JSONSchema.Encoder.UnsupportedTypeError

Prefer Peri.to_json_schema/2 as the public entry point.

Summary

Types

opts()

@type opts() :: [{:on_unsupported, :omit | :true_schema | :raise}]

Functions

encode(schema, opts \\ [])

@spec encode(Peri.schema(), opts()) :: map()