openapi-merge
    Preparing search index...

    Type Alias ExtensionMergeNode

    ExtensionMergeNode:
        | { kind: "scalar"; strategy: "first"
        | "last"
        | "error" }
        | { kind: "array"; strategy: "first" | "last" | "error" }
        | { kind: "array"; sortBy?: string; strategy: "concat" | "concat-unique" }
        | {
            item: ExtensionMergeNode;
            key: string;
            kind: "array";
            strategy: "union-by-key";
        }
        | { kind: "object"; strategy: "first"
        | "last"
        | "error" }
        | {
            fields?: { [fieldName: string]: ExtensionMergeNode };
            kind: "object";
            strategy: "merge";
        }

    Configuration for how to combine one document-root x-* extension's value across inputs (proposal 48, generalising issue #60).

    A node mirrors one point in the extension value's own JSON shape: kind says what shape is expected there, strategy says how to combine it. Left unconfigured (the extension key absent from ExtensionMergeStrategies, or a field absent from an object/merge node's fields), a value is taken wholesale from whichever input declared it first -- today's behaviour, unchanged.

    kind is declarative-only for 'first'/'last'/'error': those three operate on a value of any shape, so a scalar node with strategy 'error' still fails on disagreement even if the actual value turns out to be an object. Checking kind there and silently falling back on a mismatch would mean the one strategy whose entire purpose is "tell me about disagreement" could disagree and say nothing -- the worst version of the type-mismatch fallback below. kind only gates behaviour for the strategies that inspect internal structure (concat, concat-unique, union-by-key, merge), where there is no sensible operation to fall back to except 'first'.

    Type Declaration

    • { kind: "scalar"; strategy: "first" | "last" | "error" }

      A leaf value: string, number, boolean, or null.

    • { kind: "array"; strategy: "first" | "last" | "error" }

      A JSON array, combined wholesale -- one input's whole array wins.

    • { kind: "array"; sortBy?: string; strategy: "concat" | "concat-unique" }

      A JSON array, combined element-by-element: every input's array concatenated in input order ('concat'), optionally deduplicated by deep equality ('concat-unique'). sortBy (optional) sorts the result afterwards by a named field, for arrays of objects; omitted, the result keeps concatenation order.

      If any input's value at this key is not an array, the whole node falls back to 'first' (see the module-level type-mismatch note).

    • {
          item: ExtensionMergeNode;
          key: string;
          kind: "array";
          strategy: "union-by-key";
      }

      A JSON array of objects, where elements sharing the same value at key across (and within) inputs are the same logical entry and are combined using item. item is required: defaulting it to wholesale 'first' would make this strategy behave exactly like 'concat-unique' on the outer array minus true duplicates, silently defeating the reason to pick this strategy over that one.

      Elements whose key value appears only once across every input's array pass through unchanged (via item applied to a single-element group). Output order is first-seen order across all inputs, flattened -- there is no sortBy here, because preserving first-seen order is this strategy's point, not an accident of it.

      If any input's value is not an array, or any element is not an object carrying a string/number/boolean value at key, the whole node falls back to 'first'.

    • { kind: "object"; strategy: "first" | "last" | "error" }

      A JSON object, combined wholesale -- one input's whole object wins.

    • {
          fields?: { [fieldName: string]: ExtensionMergeNode };
          kind: "object";
          strategy: "merge";
      }

      A JSON object, combined field by field. A field not listed in fields defaults to 'first', applied to that field's value wholesale regardless of its own shape -- an unconfigured field is never guessed at.

      If any input's value at this key is not a plain object, the whole node falls back to 'first'.