schema-components - v3.7.0
    Preparing search index...

    Function applyDiscriminatorAllOfPrepass

    • Document-level pre-pass for OpenAPI discriminators that are declared on a base schema and inherited by subtypes via allOf.

      The per-node normaliseOpenApi30Discriminator only handles discriminators that already sit alongside oneOf/anyOf. For the canonical "Cat extends Pet" pattern — where Pet carries the discriminator and Cat/Dog reference Pet via allOf — the discriminator is silently lost. This pre-pass:

      1. Injects the discriminator const on each subtype's local properties (so a direct render of the subtype validates the discriminator value correctly).
      2. Synthesises a oneOf on the base whenever it lacks one, listing each subtype as { $ref, properties: { propertyName: { const } } }. The per-node discriminator transform then sees oneOf and clears the discriminator keyword, and the walker's detectDiscriminated finds the per-option consts.

      Mutates a shallow clone of components/schemas — the input document is never modified.

      Parameters

      • doc: Record<string, unknown>

      Returns Record<string, unknown>