Skema.JsonSchema.Converter.FromSkema (Skema v1.5.0)

Copy Markdown View Source

Converts Skema schema maps to JSON Schema format.

Pattern Support

Supports both :format and :pattern as aliases for regex pattern constraints. When both are present, :format takes precedence.

Examples

# Using :format (traditional)
field: [type: :string, format: ~r/^[a-z]+$/]

# Using :pattern (alias)
field: [type: :string, pattern: ~r/^[a-z]+$/]

# Both convert to JSON Schema "pattern" property
%{"type" => "string", "pattern" => "^[a-z]+$"}

Summary

Functions

Converts a Skema field definition (keyword list) to JSON Schema field format.

Converts a Skema field definition (keyword list) to JSON Schema field format with per-field required.

Converts a Skema schema map to JSON Schema properties format.

Converts a Skema schema map to JSON Schema properties format with per-field required.

Functions

convert_field_definition(field_def)

Converts a Skema field definition (keyword list) to JSON Schema field format.

Returns a tuple containing:

  • JSON field map
  • Boolean indicating if field is required

convert_field_definition_per_field(field_def)

Converts a Skema field definition (keyword list) to JSON Schema field format with per-field required.

Returns JSON field map with required property included if needed.

convert_schema_to_properties(schema)

Converts a Skema schema map to JSON Schema properties format.

Returns a tuple containing:

  • Properties map for JSON Schema "properties" field
  • Required fields list for JSON Schema "required" field

convert_schema_to_properties_per_field(schema)

Converts a Skema schema map to JSON Schema properties format with per-field required.

Returns properties map with required property included in individual fields.