import { I as InfoObject, a as ServerObject, T as TagObject, b as SecurityRequirementObject, P as PathItem, J as JsonValue, H as HttpMethod, c as OperationObject, d as ParameterObject, e as ParameterLocation, R as RequestBodyObject, f as ResponseObject, g as HeaderObject, h as ReferenceObject, M as MediaTypeObject, C as CallbackObject, E as ExternalDocumentationObject, i as SchemaObject, j as SecuritySchemeObject, L as LinkObject, k as ExampleObject, O as OpenAPIDocument } from './types-Dzi0PpYX.cjs'; /** * Per-operation override recipe used inside {@link SpecOverlay.overrides}. * * @public */ interface PathOverride { /** HTTP method → operation fragment. Keys are lowercase. */ operations?: Partial>; /** Fields on the PathItem itself (e.g. `parameters`) to merge. */ pathItem?: Partial; } /** * Recipe for patching a single {@link ResponseObject} inside an * operation. Used by {@link OperationOverride.patchResponses} to modify * a response in place rather than replace the whole thing (the * coarse-grained replacement lives on {@link OperationOverride.responses}). * * @public */ interface ResponseOverride { /** Set or replace the response's `description`. */ description?: string; /** * Shallow-merge into the response's `headers` map, keyed by header * name. Existing entries with the same key are overwritten. */ headers?: Record; /** * Patch the response's `content` map, keyed by media type. When the * media type exists in the base, the override and base are * shallow-merged. When both supply a `schema`, the override schema * is wrapped as `allOf: [existing, override]` (mirrors * {@link SpecOverlay.extendSchemas}); when only the override supplies * one, it's applied as-is. */ content?: Record; } /** * Recipe for patching a single {@link OperationObject}. Each field is * independent; use any subset. Field groups, in the order they apply: * * - {@link OperationOverride.replace | replace}: wholesale swap; mutually * exclusive with every other field on this interface. * - Parameters: {@link OperationOverride.upsertParameters | upsertParameters}, * {@link OperationOverride.removeParameters | removeParameters}. * - Body: {@link OperationOverride.requestBody | requestBody}. * - Responses: {@link OperationOverride.responses | responses} (per-status * replace), {@link OperationOverride.patchResponses | patchResponses} * (per-status patch), {@link OperationOverride.removeResponses | removeResponses}. * - Tags: {@link OperationOverride.tags | tags} (replace), * {@link OperationOverride.addTags | addTags}, * {@link OperationOverride.removeTags | removeTags}. * - Security: {@link OperationOverride.security | security} (replace), * {@link OperationOverride.addSecurity | addSecurity}, * {@link OperationOverride.removeSecurity | removeSecurity}. * - Metadata: {@link OperationOverride.servers | servers}, * {@link OperationOverride.callbacks | callbacks}, * {@link OperationOverride.externalDocs | externalDocs}, * {@link OperationOverride.setExtensions | setExtensions}. * * Conflict rules applied by {@link applyOverlays}: * - `replace` is wholesale and cannot be combined with any other field. * - Within tags / security, the replace field cannot coexist with the * matching add / remove additives. * - `removeParameters` / `removeResponses` silently no-op when the * target isn't present; wildcard overrides (`"*"`) fan out to many * operations and can't assume every target has the same surface. * * @public */ interface OperationOverride { /** Replace the whole OperationObject. Mutually exclusive with every other field. */ replace?: OperationObject; /** * Add-or-replace parameters by (`name`, `in`). Existing entries with * the same key are overwritten; anything else appends. * Reference-object entries (`{ $ref: … }`) in the base can't be * matched without resolution, so new parameters with the same key * append alongside them rather than replacing. */ upsertParameters?: ParameterObject[]; /** Remove parameters by (`name`, `in`). Silent no-op on missing entries. */ removeParameters?: Array<{ name: string; in: ParameterLocation; }>; /** Replace the request body entirely. */ requestBody?: RequestBodyObject; /** Merge-by-status-code into responses. Status codes present in both base and override take the override. */ responses?: Record; /** * Per-status response patches. Unlike {@link OperationOverride.responses} * which replaces a whole response by status code, `patchResponses` * modifies the existing response (description / headers / content) in * place. When the target status isn't present on the operation, the * patch is applied to an empty response and becomes the new entry * (matches OpenAPI Overlay 1.0 merge-on-missing semantics). */ patchResponses?: Record; /** Remove response status codes. Silent no-op on missing entries. */ removeResponses?: string[]; /** Replace the operation's tags wholesale. Cannot combine with `addTags` / `removeTags`. */ tags?: string[]; /** Append tag names. Duplicates against existing tags are dropped. */ addTags?: string[]; /** Remove tag names. Silent no-op on missing entries. */ removeTags?: string[]; /** Replace the operation's security requirement wholesale. Cannot combine with the additives. */ security?: SecurityRequirementObject[]; /** Append security requirements. */ addSecurity?: SecurityRequirementObject[]; /** * Remove security requirements that deep-equal one of the listed * entries. Silent no-op on missing entries (operations rarely list * the same requirement twice). */ removeSecurity?: SecurityRequirementObject[]; /** Replace the operation's `servers` list wholesale. */ servers?: ServerObject[]; /** * Add or replace callbacks by key. Existing callback names are * overwritten with the override's value. */ callbacks?: Record; /** Set the operation's `externalDocs`. Replaces any existing value. */ externalDocs?: ExternalDocumentationObject; /** Set or replace the operation's `operationId`. */ operationId?: string; /** Set or replace the operation's `summary`. */ summary?: string; /** Set or replace the operation's `description`. */ description?: string; /** Set or replace the operation's `deprecated` flag. */ deprecated?: boolean; /** * Set or remove `x-*` extension fields on the operation. A `undefined` * value deletes the field; any other value sets / replaces it. */ setExtensions?: Record<`x-${string}`, JsonValue | undefined>; } /** * Predicate filter used by {@link SpecOverlay.modifyOperations}. All * present fields must match (AND); an undefined `where` matches every * operation under `paths` and `webhooks`. * * @public */ interface OperationWhere { /** Match operations whose `tags` array contains any of these. */ tags?: string[]; /** Restrict by HTTP method. */ methods?: HttpMethod[]; /** Restrict by path; tested against the path string with `RegExp.test`. */ pathPattern?: RegExp; } /** * One entry in {@link SpecOverlay.modifyOperations}. * * @public */ interface ModifyOperationsEntry { where?: OperationWhere; apply: OperationOverride; } /** * Predicate filter used by {@link SpecOverlay.modifyParameters}. * * @public */ interface ParameterWhere { /** Restrict by parameter location. */ in?: ParameterLocation; /** Match the parameter `name` with `RegExp.test`. */ nameMatches?: RegExp; } /** * One entry in {@link SpecOverlay.modifyParameters}. The `apply` * fragment is shallow-merged into each matching parameter; passing * `undefined` does not delete a field (use a different overlay verb * for deletion). * * @public */ interface ModifyParametersEntry { where?: ParameterWhere; apply: Partial; } /** * A spec overlay: instructions to patch the base OpenAPI document. * Overlays apply in order; later overlays win on conflict. * * Field groups, applied in this order within a single overlay: * * - Document metadata: {@link SpecOverlay.info | info}, * {@link SpecOverlay.servers | servers} (replace) / * {@link SpecOverlay.addServers | addServers}, * {@link SpecOverlay.tags | tags} (replace) / * {@link SpecOverlay.extendTags | extendTags} / * {@link SpecOverlay.replaceTags | replaceTags} / * {@link SpecOverlay.removeTags | removeTags}, * {@link SpecOverlay.security | security} (replace) / * {@link SpecOverlay.addSecurity | addSecurity}, * {@link SpecOverlay.setExtensions | setExtensions}. * - Paths: {@link SpecOverlay.addPaths | addPaths} / * {@link SpecOverlay.removePaths | removePaths} / * {@link SpecOverlay.overrides | overrides}. * - Webhooks: {@link SpecOverlay.addWebhooks | addWebhooks} / * {@link SpecOverlay.removeWebhooks | removeWebhooks}. * - Iterators: {@link SpecOverlay.modifyOperations | modifyOperations} / * {@link SpecOverlay.modifyParameters | modifyParameters} run after * the path / webhook edits above have settled. * - Components: schemas, parameters, requestBodies, responses, headers, * securitySchemes, links, callbacks, examples each get * `extend` / `replace` / `remove` verbs. The * `extendSchemas` verb wraps in `allOf`; the other extend verbs * shallow-merge. * * @public */ interface SpecOverlay { /** Shallow-merge into the document's `info` object. */ info?: Partial; /** Replace the document's `servers` array wholesale. Cannot combine with `addServers`. */ servers?: ServerObject[]; /** Append to the document's `servers` array. */ addServers?: ServerObject[]; /** Replace the document's `tags` array wholesale. Cannot combine with the per-name tag verbs. */ tags?: TagObject[]; /** * Merge or insert tags by name. For an existing tag of the same name, * the entry is shallow-merged (override fields win). Tags absent from * the base are appended. */ extendTags?: TagObject[]; /** Replace tags by name. Tags absent from the base are appended. */ replaceTags?: TagObject[]; /** Remove tags by name. Throws if any name isn't present in the base. */ removeTags?: string[]; /** * Replace the document-level security requirement wholesale. Cannot * combine with `addSecurity`. Note that the OAS-defined "empty array * means anonymous" semantics are preserved: setting this to `[]` * removes the requirement. */ security?: SecurityRequirementObject[]; /** Append security requirements to the document's `security` array. */ addSecurity?: SecurityRequirementObject[]; /** Add webhook paths. Throws if a target name already exists. */ addWebhooks?: Record; /** Remove webhook paths by name. Throws if a target name isn't present. */ removeWebhooks?: string[]; /** * Set or remove document-level `x-*` extension fields. A value of * `undefined` deletes the field; any other value sets / replaces it. */ setExtensions?: Record<`x-${string}`, JsonValue | undefined>; /** Add new paths. Throws if a target path already exists in the base document. */ addPaths?: Record; /** Remove paths. Throws if a target path isn't present in the base document. */ removePaths?: string[]; /** Per-path modifications; see {@link PathOverride}. */ overrides?: Record; /** * Walk every operation under `paths` (and `webhooks` when present), * run the {@link ModifyOperationsEntry.where} predicate, and apply * the override on matches. Entries run in declaration order. */ modifyOperations?: ModifyOperationsEntry[]; /** * Walk every operation's parameters (and each path-item-level * parameters list) and apply the patch on matches. Reference-object * parameters are skipped (their name / location aren't inspectable * without resolution). */ modifyParameters?: ModifyParametersEntry[]; /** Extend a component schema via `allOf` (original + extension both apply). */ extendSchemas?: Record; /** Replace a component schema wholesale. */ replaceSchemas?: Record; /** Remove component schemas. Throws if a target schema isn't present. */ removeSchemas?: string[]; /** Shallow-merge into existing `components.parameters` entries; new keys append. */ extendParameters?: Record; /** Replace `components.parameters` entries by name. New keys append. */ replaceParameters?: Record; /** Remove `components.parameters` entries by name. Throws on missing. */ removeComponentParameters?: string[]; /** Shallow-merge into existing `components.responses` entries; new keys append. */ extendComponentResponses?: Record; /** Replace `components.responses` entries by name. New keys append. */ replaceComponentResponses?: Record; /** Remove `components.responses` entries by name. Throws on missing. */ removeComponentResponses?: string[]; /** Shallow-merge into existing `components.requestBodies` entries; new keys append. */ extendRequestBodies?: Record; /** Replace `components.requestBodies` entries by name. New keys append. */ replaceRequestBodies?: Record; /** Remove `components.requestBodies` entries by name. Throws on missing. */ removeRequestBodies?: string[]; /** Shallow-merge into existing `components.headers` entries; new keys append. */ extendHeaders?: Record; /** Replace `components.headers` entries by name. New keys append. */ replaceHeaders?: Record; /** Remove `components.headers` entries by name. Throws on missing. */ removeHeaders?: string[]; /** Shallow-merge into existing `components.securitySchemes` entries; new keys append. */ extendSecuritySchemes?: Record; /** Replace `components.securitySchemes` entries by name. New keys append. */ replaceSecuritySchemes?: Record; /** Remove `components.securitySchemes` entries by name. Throws on missing. */ removeSecuritySchemes?: string[]; /** Shallow-merge into existing `components.links` entries; new keys append. */ extendLinks?: Record; /** Replace `components.links` entries by name. New keys append. */ replaceLinks?: Record; /** Remove `components.links` entries by name. Throws on missing. */ removeLinks?: string[]; /** Shallow-merge into existing `components.callbacks` entries; new keys append. */ extendCallbacks?: Record; /** Replace `components.callbacks` entries by name. New keys append. */ replaceCallbacks?: Record; /** Remove `components.callbacks` entries by name. Throws on missing. */ removeCallbacks?: string[]; /** Shallow-merge into existing `components.examples` entries; new keys append. */ extendExamples?: Record; /** Replace `components.examples` entries by name. New keys append. */ replaceExamples?: Record; /** Remove `components.examples` entries by name. Throws on missing. */ removeExamples?: string[]; } /** * Every verb recognised by {@link applyOverlays}; the canonical key * list for {@link SpecOverlay}, kept in sync with the interface by the * type system. Useful for callers that want to report which keys of a * would-be overlay are unrecognised. * * @public */ declare const specOverlayVerbs: ReadonlySet; /** * Whether `value` is shaped like a {@link SpecOverlay}: a non-array * object whose every key is a recognised overlay verb. Key-level only; * the values are validated when {@link applyOverlays} applies them. An * empty object passes (a no-op overlay). A standard OpenAPI Overlay * 1.0 envelope (`overlay` / `actions`) fails; translate it first with * `oav/overlay-spec`'s `translateOverlay`. * * @public */ declare function isSpecOverlay(value: unknown): value is SpecOverlay; /** * Apply a sequence of overlays to a base OpenAPI document, returning a new * document. Does not mutate the input. * * @param base - The base (resolved) OpenAPI document. * @param overlays - Overlays to apply in order. * @returns The patched document. * @throws On conflicts that the overlay semantics do not know how to merge. * * @example * ```ts * const patched = applyOverlays(spec, [overlay1, overlay2]); * ``` * * @public */ declare function applyOverlays(base: OpenAPIDocument, overlays: readonly SpecOverlay[]): OpenAPIDocument; export { type ModifyOperationsEntry as M, type OperationOverride as O, type ParameterWhere as P, type ResponseOverride as R, type SpecOverlay as S, type ModifyParametersEntry as a, type OperationWhere as b, type PathOverride as c, applyOverlays as d, isSpecOverlay as i, specOverlayVerbs as s };