import { NodeTransform } from "./normalise.mjs"; //#region src/core/openapi30.d.ts /** * Lift OpenAPI 3.x singular `example` onto the plural `examples` key. * * Two output shapes are spec-correct depending on the parent object type: * - `"array"` — Schema Object: `examples: [example]` (Draft 2020-12 plural). * - `"map"` — Parameter / Header / Media Type Object: an Examples Map * keyed by name. The single value is wrapped under the * synthetic key `default` to produce a valid one-entry map * of one Example Object. * * When both `example` and `examples` coexist the spec declares them mutually * exclusive — `example` is dropped and `examples` wins. */ declare function liftExampleToExamples(node: Record, shape: "array" | "map"): void; /** * Normalise OpenAPI 3.0.x `nullable` keyword to `anyOf [T, null]`. * * OpenAPI 3.0 uses `nullable: true` instead of the JSON Schema standard * `anyOf: [T, { type: "null" }]`. The walker understands the latter form * natively, so this normaliser converts `nullable` to `anyOf`. * * Only applied when `nullable` is explicitly `true`. `nullable: false` or * absent is the default and requires no transformation. */ declare function normaliseOpenApi30Node(node: Record): Record; /** * Normalise OpenAPI 3.0.x `discriminator` keyword by injecting `const` * values into each `oneOf`/`anyOf` option's discriminator property. * * In OpenAPI 3.0, `discriminator` is a sibling of `oneOf`/`anyOf`: * `discriminator: { propertyName: "type" }` * The walker detects discriminated unions from `oneOf` + `const` on a * property, so this normaliser injects the `const` values from the * `mapping` or infers them from `$ref` fragment names. */ declare function normaliseOpenApi30Discriminator(node: Record): Record; /** * Document-level pre-pass for OpenAPI discriminators that are declared * on a base schema and inherited by subtypes via `allOf`. * * The per-node {@link 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 `const`s. * * Mutates a shallow clone of `components/schemas` — the input document * is never modified. */ declare function applyDiscriminatorAllOfPrepass(doc: Record): Record; /** * Combined OpenAPI 3.0.x node transform: Draft 04 + nullable + discriminator. * Applied to every schema node in an OpenAPI 3.0 document. * * Draft 04 normalisation is included because OpenAPI 3.0 inherits * Draft 04/05 schema semantics including `exclusiveMinimum: boolean`. */ declare function normaliseOpenApi30Combined(node: Record): Record; /** * Per-schema normaliser supplied by the caller. Given a Schema Object, * returns the normalised (deep-cloned) Schema Object. The visitor is * agnostic to which transforms run inside. */ type SchemaNormaliser = (schema: Record) => Record; /** * Deep-clone the parent first, then patch back any keys whose values were * rewritten by the visitor. This preserves immutability of the original * document while keeping the visitor straightforward to write. */ /** * Deep-normalise every Schema Object in an OpenAPI document. * * Walks: `paths.*` (operations + path-level parameters), `webhooks.*` * (3.1), `components.schemas`, `components.parameters`, * `components.responses`, `components.requestBodies`, * `components.headers`, `components.callbacks`, `components.pathItems` * (3.1). For each Schema-bearing location, applies the supplied * `normaliseSchema` function. * * The walker is structural (it understands OAS document shapes) and * delegates the per-schema transformation. For OAS 3.0 the caller * passes a full Draft 04 + nullable + discriminator + example * normaliser; for OAS 3.1 the caller passes a discriminator-only * normaliser so the walker's discriminated-union detection sees the * injected `const`s regardless of OAS minor version. */ declare function deepNormaliseOpenApiDoc(doc: Record, normaliseSchema: SchemaNormaliser): Record; /** * Backwards-compatible wrapper retaining the historic `deepNormalise` * signature used by callers in `normalise.ts`. Always applies the full * 3.0 combined transform via `deepNormalise(schema, normaliseOpenApi30Combined)`. */ declare function deepNormaliseOpenApi30Doc(doc: Record, deepNormalise: (schema: Record, transform: NodeTransform) => Record): Record; //#endregion export { applyDiscriminatorAllOfPrepass, deepNormaliseOpenApi30Doc, deepNormaliseOpenApiDoc, liftExampleToExamples, normaliseOpenApi30Combined, normaliseOpenApi30Discriminator, normaliseOpenApi30Node };