Exonerate.PropertyRegistry (exonerate v1.2.2)

Copy Markdown View Source

Compile-time registry for consolidating property validators across combining schemas.

When combining filters (allOf, anyOf, oneOf) contain sub-schemas with properties, this module collects all property validators and allows generating a single-pass iteration instead of iterating once per sub-schema.

Architecture

The registry collects property definitions from multiple sub-schemas and generates a merged iterator that validates all properties in a single pass.

Combining Semantics

  • allOf: All validators for a property must pass (AND semantics)
  • anyOf: At least one sub-schema's validators must pass
  • oneOf: Exactly one sub-schema's validators must pass

Summary

Functions

Analyzes sub-schemas in a combining filter and returns optimization info.

Builds a merged property registry from optimizable sub-schema indices.

Checks if optimization is beneficial for the given combining filter.

Generates a merged iterator that validates all properties in a single pass.

Generates a merged property validator function for allOf semantics.

Checks if a sub-schema is "property-only" and can be merged.

Functions

analyze_subschemas(caller, resource, pointer)

Analyzes sub-schemas in a combining filter and returns optimization info.

Returns a tuple: {optimizable_indices, non_optimizable_indices}

Where:

  • optimizable_indices: list of sub-schema indices that can be merged
  • non_optimizable_indices: list of indices that need standard processing

build_registry(caller, resource, pointer, indices)

Builds a merged property registry from optimizable sub-schema indices.

Returns: %{

properties: %{property_name => [{sub_index, pointer, schema}]},
pattern_properties: [{pattern, sub_index, pointer, schema}]

}

can_optimize?(caller, resource, pointer)

Checks if optimization is beneficial for the given combining filter.

Returns true if there are at least 2 optimizable sub-schemas (worth the overhead).

generate_allof_merged_iterator(resource, pointer, registry, opts)

(macro)

Generates a merged iterator that validates all properties in a single pass.

generate_allof_property_validators(resource, pointer, registry, opts)

(macro)

Generates a merged property validator function for allOf semantics.

This creates a function that validates a property against ALL validators from all merged sub-schemas that define that property.

is_property_only_schema?(caller, resource, pointer)

Checks if a sub-schema is "property-only" and can be merged.

A schema is property-only if it only contains:

  • type (must include "object" or be absent)
  • properties
  • patternProperties
  • metadata (title, description, etc.)

Returns true if the schema can be fully handled by the merged property iterator.