# `A2UICore.Catalog.SchemaCleaner`
[🔗](https://github.com/a2ui-elixir/a2ui/blob/v0.1.1/umbrella/apps/a2ui_core/lib/a2ui_core/catalog/schema_cleaner.ex#L1)

Normalizes the schema nodes a catalog's validation schema is assembled
from, as the reference catalog does before bundling common types:

  * a `title` keyword is dropped unless it was marked as authored
    (`mark_titles/1`);
  * `default: null` and `items: {}` are dropped;
  * `null` branches leave unions, and a union with one branch left
    becomes that branch;
  * an inline dynamic value union (a literal, a `DataBinding` and a
    `FunctionCall` branch) becomes a `$ref` to the common type it
    matches (`DynamicString`, `DynamicStringList`, `DynamicValue`, …);
  * `anyOf` becomes `oneOf`, except under `additionalProperties` and
    where a branch only constrains (`required` without `type`).

`clean/2` also reports the `#/$defs/…` names the result references.

# `index`
*since 0.1.0* 

```elixir
@type index() :: %{
  names: MapSet.t(String.t()),
  by_scalar_kind: %{optional(String.t()) =&gt; String.t()},
  catch_all: String.t() | nil,
  by_literal_shape: %{optional(term()) =&gt; String.t()}
}
```

The dynamic value defs of a common types document, by the literal
branches of their unions.

# `clean`
*since 0.1.0* 

```elixir
@spec clean(term(), index()) :: {term(), MapSet.t(String.t())}
```

Cleans `node` (see the module doc) with the dynamic value `index`,
returning the cleaned node and the `#/$defs/…` names it references.

# `index`
*since 0.1.0* 

```elixir
@spec index(map()) :: index()
```

Builds the dynamic value index of a `$defs` map: every def whose union
has a `DataBinding` branch, a `FunctionCall` branch and literal
branches.

# `mark_titles`
*since 0.1.0* 

Marks the `title` keywords of an authored schema so `clean/2` keeps
them. A property named `title` and the values of data keywords
(`const`, `default`, `enum`, `examples`) are left alone.

---

*Consult [api-reference.md](api-reference.md) for complete listing*
