normalizeDefinitions
Function: normalizeDefinitions()
normalizeDefinitions<
T>(schema):T
Defined in: packages/content-mapper/src/schema/action.ts:147
Hoist every nested definitions block to the root and drop dangling refs.
Applied to action schemas only. Two real failures motivate it, both of
which crash AJV rather than merely looking untidy: a bound generic keeps
its definitions on a sub-schema where a root-relative $ref cannot see
it, and an unbound generic produces a definition whose key does not match
the $ref pointing at it. Hoisting fixes the first; pruning the $ref —
leaving an unconstrained {} — contains the second.
Accepts any JSON value: the guard against non-objects is deliberate, so
callers never have to check before flattening.
Type Parameters
T
T
the value type, preserved
Parameters
schema
T
the schema to flatten, mutated in place
Returns
T
the same value