import { $ as TypeParam, A as ModelRef, At as LoggingPolicy, B as RangeResponse, C as Extensions, Ct as walkTypeRef, D as LiteralType, Dt as ErrorPolicy, E as HttpMethod, Et as DeepPartial, F as PaginationStrategy, Ft as TelemetryPolicy, G as ResponseHeader, Gt as CompatConfig, H as RequestBodyType, I as Parameter, It as TimeoutPolicy, J as ServerEntry, K as SecurityRequirement, L as ParameterGroup, Lt as UserAgentPolicy, M as Operation, Mt as RequestGuardPolicy, N as PaginationEndOfIteration, Nt as RetryPolicy, O as MapType, Ot as IdempotencyPolicy, P as PaginationMeta, Pt as SdkBehavior, Q as SuccessResponse, R as ParameterGroupVariant, Rt as defaultSdkBehavior, S as ErrorResponse, St as validateModelHints, T as Field, Tt as BackoffStrategy, U as ResponseBodyType, V as RequestBodyContent, W as ResponseContent, X as Service, Y as ServerVariable, Z as StatusRange, _ as Constraints, _t as collectResponseHeaders, a as ResolvedMethodCollision, an as ApiSurface, at as assignModelsToServices, b as EnumRef, bt as renameModelRefs, c as SplitHint, cn as Extractor, ct as collectEnumRefs, d as resolveMountTarget, dn as OverlayLookup, dt as collectModelRefs, et as TypeRef, f as resolveOperations, ft as collectModelTypeRefs, g as Callback, gt as collectResponseBodyTypes, h as AuthScheme, ht as collectRequestBodyTypes, i as PaginationHint, it as assertNever, j as NullableType, jt as PaginationPolicy, k as Model, kt as LogEvent, l as deriveMethodName, lt as collectFallbackResponseTypes, m as ArrayType, mt as collectRequestBodyModels, n as OperationNaming, nt as Webhook, o as ResolvedOperation, ot as callbackContext, p as ApiSpec, pt as collectOperationTypeRefs, q as SecurityRequirementSet, r as OperationResolution, rt as WebhookResponse, s as ResolvedWrapper, st as collectAlternateRequestBodyContents, t as OperationHint, tt as UnionType, u as findResolvedMethodCollisions, ut as collectFieldDependencies, v as DefaultResponse, vt as collectWebhookTypeRefs, w as ExternalDocs, wt as AiAgentEnvVar, x as EnumValue, xt as typeRefConstraints, y as Enum, yt as mapTypeRef, z as PrimitiveType, zt as mergeSdkBehavior } from "./operation-hints-DzxFffcr.mjs"; //#region src/ir/server-url.d.ts /** Outcome of filling a server URL template with its variables' defaults. */ interface ResolvedServerUrl { /** The template with every placeholder that names a declared variable replaced by that variable's `default`. */ url: string; /** * Placeholder names still in `url` because the server declares no variable * for them, in order of first appearance and without repeats. */ unresolved: string[]; } /** * Fill a server URL template with its variables' defaults. * * Each `{name}` is replaced by `variables[name].default`; a placeholder with no * declared variable is kept verbatim and reported in `unresolved`. The same * variable may appear more than once, and a declared variable the template * never mentions is simply unused (`serverUrlPlaceholders` lists the names the * template does mention). The substituted value is spliced in as text and not * scanned again, so a default such as `{other}` cannot trigger a second * substitution. A `{` with no closing `}`, an empty `{}`, and a `{` that opens * another `{` before closing are all literal text. * * Plain string scanning only: no pattern is built from the variable names, so * a name containing `.`, `+` or any other character is matched as written. * * The parser uses this for `ApiSpec.baseUrl`; an emitter that offers every * server (an environment picker, say) can resolve each `spec.servers[i]` the * same way instead of reading the OpenAPI document again. */ export declare function resolveServerUrl(server: Pick): ResolvedServerUrl; /** * The placeholder names a server URL template references, in order of first * appearance and without repeats: `['region', 'port']` for * `https://{region}.example.com:{port}/{region}`. Read from the template * alone, by the same scan as `resolveServerUrl` (so the same literal-brace * rules apply), whether or not the server declares a variable for each name. * * A declared variable whose name is not listed here is one the template never * references: its default and its allowed values cannot reach any resolved * URL. The differ classifies a change to such a variable as additive on that * basis; an emitter that exposes a server's variables can use it to offer * only the ones that take effect. */ export declare function serverUrlPlaceholders(url: string): string[]; /** * A server URL in the form two equivalent spellings share, for comparing * server URLs — templates as written and resolved URLs alike. The IR never * stores it: `ServerEntry.url` and `ApiSpec.baseUrl` stay as written, and * the differ reports every URL as written in the document that declares it. * * The rules are those of RFC 3986 §6.2.2 (syntax-based) and §6.2.3 * (scheme-based normalization) that apply to a base URL: * * - The scheme and the host are case-insensitive and are lower-cased * (`HTTPS://PETS.example.com` and `https://pets.example.com` are one * server). Userinfo, path, query and fragment are case-sensitive and keep * their case, so `/V1` and `/v1` stay two servers. * - A port that is empty or is the scheme's default is dropped * (`https://pets.example.com:443`, `https://pets.example.com:` and * `https://pets.example.com` are one server; `http` and `ws` default to * 80, `https` and `wss` to 443). Any other port stays. * - An empty path after a wholly literal authority is `/` * (`https://pets.example.com` and `https://pets.example.com/` are one * server). Nothing else is done to the path: `/v1` and `/v1/` stay two * servers, and dot-segments are kept. * - In a percent-encoded octet the hex digits are upper-cased (`%2f` is * `%2F`) and one that encodes an unreserved character — a letter, a digit, * `-`, `.`, `_` or `~` — is decoded (`%7E` is `~`). Every other octet is * kept encoded, and a `%` not followed by two hex digits is literal. * * A `{name}` placeholder is kept exactly as written wherever it sits, so a * variable name is never case-folded (`{Region}` and `{region}` are different * variables) and a template is never confused with what it resolves to * (`https://{region}.api.example.com` and `https://eu.api.example.com` stay * two servers). A placeholder also ends what can be known about the URL's * structure: its value may carry any delimiter — `@` (which makes the text * before it in the authority a username), `:` and a port, `/` and a path, * `://` and a whole URL — so nothing from the first placeholder on is folded, * and a component is folded only when it is complete before that point: the * scheme when its `:` comes first, the authority when its end (`/`, `?`, `#` * or the end of the template) comes first. So `HTTPS://API.example.com/{v}` * is `https://api.example.com/{v}` and `HTTPS://API.example.com{basePath}` * is `https://API.example.com{basePath}`, while `…{basePath}` and * `…{basePath}/`, `https://{host}:443/v2` and `https://{host}/v2`, * `https://USER{suffix}/v1` and `https://user{suffix}/v1` (a `suffix` of * `@api.example.com` makes `USER` a username), and `{prefix}://api.example.com` * and `{prefix}://api.example.com/` (a `prefix` of * `https://gateway.example.com/path` makes the rest a path) all stay two * servers. From the first placeholder on not even percent-encoding is * folded, and neither is it in an authority the placeholder sits in: a value * may put the text in a scheme or a port, where `%` has no meaning * (`{scheme}%73://…` and `{scheme}s://…`, `…{x}%34%34%33` and `…{x}443`, * `https://api.example.com:4{port}` and `https://api.example.com:%34{port}`, * `{scheme}://host:%34%34%33` and `{scheme}://host:443` stay two servers), * or end in a `%` that joins with the text after it into a different octet * (`https://{host}/{x}7e` and `https://{host}/{x}%37e` stay two servers). * Percent-encoding before the first placeholder in a path, query or * fragment is folded, since a complete octet there is a complete octet under * every value. Every folding therefore applies to text whose part and bytes * no variable value can change, and two templates that come out as one * string resolve to one URL under every value of their variables. Not folded at * all: dot-segments (`/v1/../v2` is compared as written) and * internationalised host names (`bücher.example.com` and * `xn--bcher-kva.example.com` are two hosts). A relative reference (`/v1`, * `//api.example.com/v1`) goes through the same rules from wherever its * syntax starts. */ export declare function normalizeServerUrl(url: string): string; /** * Whether two server lists are the same, entry for entry. * * Structural: the same length, and at each position the same `url` — up to * `normalizeServerUrl`, so a scheme or host that differs only in case, a * default port written or not, and a trailing `/` after a bare authority * are the same URL, and that form folds nothing a placeholder's value could * change, so two entries it calls equal resolve to one URL under every value * of their variables, which `resolveAlike` checks value by value all the * same — and the same `description` and the same `variables`: * the same names, each with the same `default`, the same `enum` (same values * in the same order) and the same `description`, all compared as written. * Position matters because `servers[0]` is the one a client defaults to. A * key that is absent and one set to `undefined` compare equal. Variables are * compared by own key only, so one named `__proto__` or `constructor` is * compared like any other and never read off `Object.prototype`. * * The parser uses this to decide whether an operation's effective servers * differ from the document's (`Operation.servers` is set only when they do): * the IR carries exactly what the document says. The differ's * `serversChanged` deliberately uses a looser rule — descriptions, enum order * and position ignored, matching the document-level diff — so a description * edit sets the field without being reported as a change. */ export declare function serverListsEqual(a: readonly ServerEntry[], b: readonly ServerEntry[]): boolean; /** * Whether a server entry is OpenAPI's default server: its `url` is `/`. * Neither its `description` nor its `variables` count. The default server * has neither; a description changes nothing about where a request goes; and * `/` contains no placeholder (`serverUrlPlaceholders('/')` is empty), so a * variable declared on it is never referenced and cannot change where it * points either (#292). A template that merely resolves to `/` (a referenced * variable whose default is `/`) is a template, not the default server. */ export declare function isDefaultServerEntry(server: ServerEntry): boolean; /** * Whether a server list means OpenAPI's default server. OpenAPI gives a * document with no `servers`, or `servers: []`, a single server at `/`; a * document that writes that server out declares nothing beyond it, and * neither does one that writes it out twice. So `undefined`, an empty list, * and a list whose every entry is the default by `isDefaultServerEntry` are * all the default. A list with any other entry is not, wherever `/` sits in * it, because position decides the default host. * * The parser asks this of an operation's list and the document's: both at * the default means the operation inherits (`Operation.servers`, #291). The * differ asks it to tell the `/` a document is only implied to have, which * is never reported as added or removed, from one it lists beside another * server, which is. */ export declare function isDefaultServerList(servers: readonly ServerEntry[] | undefined): boolean; /** * The servers a document is served from: its list as written (the same * array, not a copy) when it declares anything beyond the default, else * OpenAPI's default server, a single `{ url: '/' }`. A document without * `servers`, one with `servers: []`, one whose only server is `/`, and one * that writes `/` out twice all come out as `[{ url: '/' }]` (a description * on the entry is not carried: the default server has none), while * `[/, host]` stays `[/, host]`, because there `/` is a server the document * lists, not one it is implied to have. The differ matches servers on this, * so the three spellings of the default pair with each other and with a `/` * listed beside a host. */ export declare function serversOrDefault(servers: readonly ServerEntry[] | undefined): readonly ServerEntry[]; /** * A document's default address beyond OpenAPI's default: `''` when * `baseUrl` is `''` (the parser's value for a document with no server) or * `/` (the resolved address of the default server, written out or not), * else `baseUrl` as given. The differ compares `base-url-changed` on this, * so the three spellings of the default share one address and a document * whose first server merely resolves to `/` has not moved from it. Any other * `baseUrl` — a host, or `/v1` — is compared as written, even with no * `servers` beside it (an IR built by hand, which the parser never * produces). */ export declare function baseUrlBeyondDefault(baseUrl: string): string; //#endregion //#region src/ir/parameter-key.d.ts /** * How one parameter is told apart from another on an operation, a webhook or * a response. OpenAPI identifies a parameter by its `name` and its `in` * location — a path `id` may sit beside a query `id` — so the two are * compared together. Header names are case-insensitive (RFC 9110 §5.1), so a * header's name is folded before it is compared; path, query and cookie * names are case-sensitive and compared as written. The IR keeps every name * as written: only the comparison folds. Every place that asks whether two * parameters are the same one — the parser merging a path item's parameters * with an operation's, the parser reading a response's `headers` map, the * differ pairing a parameter across two documents — goes through this * module, so one rule answers it. */ /** Where a parameter lives, as OpenAPI's `in` names it. */ type ParameterLocation = 'path' | 'query' | 'header' | 'cookie'; /** * A header name as it is compared: lower-cased, since RFC 9110 §5.1 makes * header names case-insensitive (`X-Request-Id` and `x-request-id` name one * header). A header name is an ASCII token, so plain case folding is exact. * It is also the name the parser mints a header's inline model or enum * from (`X-RateLimit-Policy` → `…XRatelimitPolicy`, whatever its case), so * two spellings of one header type the same way; the IR's `name` stays as * written. */ export declare function foldHeaderName(name: string): string; /** * A parameter name as it is compared at `location`: a header's is folded by * `foldHeaderName`; a path, query or cookie name is case-sensitive and kept * as written (`Limit` and `limit` are two query parameters). It is also the * name the parser mints a parameter's inline model or enum from, so a * header's type name does not move with the header's case. */ export declare function foldParameterName(location: ParameterLocation, name: string): string; /** * The identity of a parameter within one operation or webhook: * `location:name`, the name folded by `foldParameterName`. Two parameters * with one key are one parameter — the parser lets the later declaration * (an operation's over its path item's) replace the earlier, and the differ * pairs the old and new declarations rather than reporting a removal beside * an addition. */ export declare function parameterKey(location: ParameterLocation, name: string): string; //#endregion //#region src/errors.d.ts /** * Structured error hierarchy for oagen. * * Every error carries a human-readable `hint` that suggests a recovery action. * The hint is appended to the `message` so it appears in stack traces and logs. */ /** Base class for all oagen errors. */ export declare class OagenError extends Error { readonly hint: string; constructor(message: string, hint: string); } /** Thrown when a command should terminate with a specific exit code. */ export declare class CommandError extends OagenError { readonly exitCode: number; constructor(message: string, hint: string, exitCode: number); } /** Thrown when an OpenAPI spec cannot be parsed or has an unsupported version. */ export declare class SpecParseError extends OagenError { constructor(message: string, hint: string); } /** Thrown when configuration files (manifests, API surfaces, overlays) are missing or malformed. */ export declare class ConfigError extends OagenError { constructor(message: string, hint: string); } /** Thrown when a config file exists but cannot be loaded or evaluated. */ export declare class ConfigLoadError extends ConfigError { constructor(message: string, hint: string); } /** Thrown when a config targets a different IR version than the installed package. */ export declare class ConfigVersionMismatchError extends ConfigError { constructor(message: string, hint: string); } /** Thrown when an API surface extractor encounters a problem. */ export declare class ExtractorError extends OagenError { constructor(message: string, hint: string); } /** Thrown when a requested language or extractor is not found in a registry. */ export declare class RegistryError extends OagenError { constructor(message: string, hint: string); } /** Thrown for internal invariant violations that indicate a bug. */ export declare class InternalError extends OagenError { constructor(message: string, hint: string); } //#endregion //#region src/engine/types.d.ts interface GeneratedFile { path: string; content: string; skipIfExists?: boolean; headerPlacement?: 'prepend' | 'skip'; /** When false, exclude this file from --target integration. Defaults to true. */ integrateTarget?: boolean; /** When true, always overwrite existing file instead of merging. Defaults to false. */ overwriteExisting?: boolean; } interface EmitterContext { namespace: string; namespacePascal: string; spec: ApiSpec; outputDir?: string; apiSurface?: ApiSurface; overlayLookup?: OverlayLookup; /** Resolved operations from the hint-aware resolver. Populated by buildEmitterContext(). */ resolvedOperations?: ResolvedOperation[]; /** * Model-placement pins from `OagenConfig.modelHints`. Emitters that call * `assignModelsToServices` should pass this through so hinted models land in * the configured service instead of the default first-reference winner. */ modelHints?: Record; /** Language-specific emitter options from config for the active emitter. */ emitterOptions?: Record; /** Absolute path to the integration target directory (when --target is used). */ targetDir?: string; /** * Scoped-generation signal: the set of POST-MOUNT service names a `--services` * run selected. When present and non-empty, emitters must emit ONLY these * services' per-service resource/test files, while still emitting models, * enums, the root client, and all aggregate/barrel files for the surface the * engine hands them (so shared files stay byte-identical and a brand-new * selected service is wired into the client automatically). Absent/empty ⇒ * full generation. * * NOTE: the engine narrows the spec it passes to the aggregate generators to * `selected ∪ already-on-disk` services (see `presentServiceKeys`), so the * "full spec" an emitter sees in a scoped run excludes services the spec just * added that this SDK has never generated — they would otherwise be wired into * barrels/the client with no implementation behind them (orphaned imports). */ scopedServices?: Set; /** * Canonical (casing/separator-insensitive) keys of services the prior manifest * recorded as already generated on disk. Populated only in a scoped run, from * the output/target `.oagen-manifest.json` operations map. The engine uses it * to keep an already-present service in the aggregate surface (byte-identical * regen) while dropping a spec-only, never-generated, out-of-scope service. */ presentServiceKeys?: Set; /** * Scoped-generation model/enum allow-lists: names of models/enums reachable * from the selected services. When `scopedServices` is active, * emitters must write a per-model/per-enum FILE only when its name is in these * sets — but must still include EVERY model/enum (the full set passed to * generateModels/generateEnums) in barrels/indexes, so on-disk files for * out-of-scope models (left untouched) stay importable. Absent ⇒ write all. */ scopedModelNames?: Set; scopedEnumNames?: Set; /** * Paths (relative to the output/target dir) that the previous run wrote, * loaded from that directory's `.oagen-manifest.json`. Emitters can use this * to distinguish "file exists because oagen wrote it last time" from "file * exists because a human wrote it" — the former is safe to overwrite, the * latter should be merged. */ priorTargetManifestPaths?: Set; } interface FormatCommand { /** The executable to run (e.g., "npx", "gofmt", "bundle"). */ cmd: string; /** Arguments before the file list (e.g., ["prettier", "--write"]). */ args: string[]; /** Max files per invocation (to avoid OS arg-length limits). Defaults to 100. */ batchSize?: number; } /** Maps "METHOD /path" to SDK method info. Values may be arrays for polymorphic operations. */ type OperationsMapEntry = { sdkMethod: string; service: string; }; type OperationsMap = Record; interface Emitter { language: string; generateModels(models: Model[], ctx: EmitterContext): GeneratedFile[]; generateEnums(enums: Enum[], ctx: EmitterContext): GeneratedFile[]; generateResources(services: Service[], ctx: EmitterContext): GeneratedFile[]; generateClient(spec: ApiSpec, ctx: EmitterContext): GeneratedFile[]; generateErrors(ctx: EmitterContext): GeneratedFile[]; generateTypeSignatures?(spec: ApiSpec, ctx: EmitterContext): GeneratedFile[]; generateTests(spec: ApiSpec, ctx: EmitterContext): GeneratedFile[]; /** Optional: build operation-to-SDK-method mapping, stored in .oagen-manifest.json */ buildOperationsMap?(spec: ApiSpec, ctx: EmitterContext): OperationsMap; fileHeader(): string; /** * Optional: return a format command to run on generated files after target * integration. The emitter can inspect the target directory to detect the * project's formatter (e.g., prettier config, .editorconfig, Gemfile). * Return null to skip formatting. */ formatCommand?(targetDir: string): FormatCommand | null; } //#endregion //#region src/differ/types.d.ts interface DiffReport { oldVersion: string; newVersion: string; changes: Change[]; /** * Cross-cutting events that a type signature does not show: a parameter * default changing observable runtime behavior for callers who never set it * explicitly (breaking), an IR node becoming or ceasing to be deprecated * (additive), the security requirements a request must satisfy changing * (either), or a security scheme definition those requirements name * being added, removed or modified (either). Surfaced separately so * PR-description and changelog tooling can call them out even when the * shapes in `changes` are otherwise unchanged. Every entry here mirrors a * flag, a nested entry or a security scheme change in `changes`, so the * totals in `summary` count each event once. */ behaviorChanges: BehaviorChange[]; summary: { added: number; removed: number; modified: number; breaking: number; additive: number; behaviorChanges: number; }; } type BehaviorChange = ParamDefaultChanged | DeprecatedChanged | SecurityChanged | SecuritySchemeChanged | ExtensionsChanged; interface ParamDefaultChanged { kind: 'param-default-changed'; /** Service name (e.g. 'authorization', 'accounts'). */ serviceName: string; /** Operation name within the service. */ operationName: string; /** Parameter name (e.g. 'order', 'limit'). */ paramName: string; /** Where the parameter lives; kept in step with `ParamChange.paramLocation`. */ paramLocation: ParamLocation; /** Old default value as a string, or null if previously unset. */ oldDefault: string | null; /** New default value as a string, or null if now unset. */ newDefault: string | null; classification: 'breaking'; } /** * An IR node became deprecated, or stopped being deprecated. The node is still * there with the same shape, so nothing a caller compiles against changes and * the event is additive; it is surfaced here, beside the `deprecatedChanged` * flag or `*-deprecated-changed` entry on the owning change, so a changelog * can say it. `oldDeprecated`/`newDeprecated` are copied from that change, * which carries them beside its flag. `undefined` and `false` both read as * not deprecated, as the parser only ever writes `true`. */ type DeprecatedChanged = { kind: 'deprecated-changed'; /** Whether the node was deprecated in the old spec. Always the opposite of `newDeprecated`. */ oldDeprecated: boolean; /** Whether the node is deprecated in the new spec. */ newDeprecated: boolean; classification: 'additive'; } & DeprecatedNode; /** Which IR node a `deprecated-changed` entry is about, named the way the owning change names it. */ type DeprecatedNode = { node: 'operation'; serviceName: string; operationName: string; } | { node: 'parameter'; serviceName: string; operationName: string; paramName: string; paramLocation: ParamLocation; } | { node: 'response-header'; serviceName: string; operationName: string; /** The header's name as written in the new spec. */ headerName: string; /** The response entry's status code, as on `ResponseHeaderChange`; unset for a fallback response. */ statusCode?: number; /** Set instead of `statusCode` for the `default` or a range response. */ fallback?: 'default' | StatusRange; } | { node: 'model'; modelName: string; } | { node: 'field'; modelName: string; fieldName: string; } | { node: 'envelope-field'; serviceName: string; operationName: string; fieldName: string; } | { node: 'enum'; enumName: string; } | { node: 'enum-value'; enumName: string; valueName: string; } | { node: 'webhook'; name: string; httpMethod: string; } | { node: 'webhook-parameter'; name: string; httpMethod: string; paramName: string; paramLocation: ParamLocation; } | ({ node: 'callback'; name: string; expression: string; httpMethod: string; } & CallbackSite) | ({ node: 'callback-parameter'; name: string; expression: string; httpMethod: string; paramName: string; paramLocation: ParamLocation; } & CallbackSite); /** * The security requirements a node's requests must satisfy changed. Mirrors * the document-level `security-changed` change (`node: 'document'`) and the * `securityChanged` flag on an `operation-modified` or `webhook-modified` * change, copying `oldSecurity`/`newSecurity` from it. The classification is * the security change's own — `classifySecurityChange` on the two lists, * read from the caller's side for an operation and from the receiver's side * for a webhook or a callback, and for the document as * `DocumentSecurityChanged` says — not the owning change's, which may be * breaking for another reason. */ type SecurityChanged = { kind: 'security-changed'; oldSecurity: SecurityRequirementSet[]; newSecurity: SecurityRequirementSet[]; classification: 'additive' | 'breaking'; } & SecurityNode; /** Which node a `security-changed` entry is about, named the way the owning change names it. */ type SecurityNode = { node: 'document'; } | { node: 'operation'; serviceName: string; operationName: string; } | { node: 'webhook'; name: string; httpMethod: string; } | ({ node: 'callback'; name: string; expression: string; httpMethod: string; } & CallbackSite); /** * A security scheme definition — `ApiSpec.auth`, the parsed * `components.securitySchemes` — was added, removed or modified (#384). * Mirrors every `security-scheme-added`, `security-scheme-removed` and * `security-scheme-modified` change, one entry each, listed beside the * `security-changed` entries: `oldScheme` is present when the old document * declares the scheme and `newScheme` when the new one does, so an added * scheme carries `newScheme` alone, a removed one `oldScheme` alone and a * modified one both. The classification is copied from the change. */ interface SecuritySchemeChanged { kind: 'security-scheme-changed'; /** The key under `components.securitySchemes`, as the requirements name it. */ schemeName: string; /** The definition as the old document declared it; absent when it did not. */ oldScheme?: AuthScheme; /** The definition as the new document declares it; absent when it does not. */ newScheme?: AuthScheme; classification: 'additive' | 'breaking'; } /** * An IR node's `extensions` — the `x-*` keys of the object it was built * from — changed: a key added, removed or given another value (compared * deeply, key order aside; an absent key and an empty object are the * same). The node is still there with the same shape, so nothing a caller * compiles against changes and the event is additive; it is surfaced here, * beside the `extensionsChanged` flag or `field-extensions-changed` entry * on the owning change, since an emitter may derive behavior from a key it * knows (`x-idempotent`, say) and a changelog has to say it. * `oldExtensions`/`newExtensions` are copied from that change: each is the * node's `extensions` on that side, absent when the node had none there. */ type ExtensionsChanged = { kind: 'extensions-changed'; oldExtensions?: Extensions; newExtensions?: Extensions; classification: 'additive'; } & ExtensionsNode; /** * Which IR node an `extensions-changed` entry is about, named the way the * owning change names it. One entry kind per carrier of `extensions`: an * operation, a model, a model's field, an enum, and a list envelope's field * (`Operation.pagination.envelopeFields`, which sits on no model). */ type ExtensionsNode = { node: 'operation'; serviceName: string; operationName: string; } | { node: 'model'; modelName: string; } | { node: 'field'; modelName: string; fieldName: string; } | { node: 'enum'; enumName: string; } | { node: 'envelope-field'; serviceName: string; operationName: string; fieldName: string; }; type Change = ModelAdded | ModelRemoved | ModelModified | EnumAdded | EnumRemoved | EnumModified | ServiceAdded | ServiceRemoved | OperationAdded | OperationRemoved | OperationModified | BaseUrlChanged | ServerAdded | ServerRemoved | ServerModified | DocumentSecurityChanged | SecuritySchemeAdded | SecuritySchemeRemoved | SecuritySchemeModified | WebhookAdded | WebhookRemoved | WebhookModified | CallbackAdded | CallbackRemoved | CallbackModified; interface ModelAdded { kind: 'model-added'; name: string; classification: 'additive'; } interface ModelRemoved { kind: 'model-removed'; name: string; classification: 'breaking'; } interface ModelModified { kind: 'model-modified'; name: string; fieldChanges: FieldChange[]; /** * Changes to a named union's `variants` and `discriminator` * (`Model.variants`). Present only when there is at least one. */ variantChanges?: VariantChange[]; /** * The model's own `deprecated` flipped. Additive either way: the model and * its fields are unchanged. A model whose only change is this flag is still * reported, with an empty `fieldChanges`. */ deprecatedChanged: boolean; /** Present exactly when `deprecatedChanged`: the flag's two sides, old → new. */ oldDeprecated?: boolean; newDeprecated?: boolean; /** * Present, and `true`, only when the model's own `extensions` differ * (see `ExtensionsChanged`). Additive: the model and its fields are * unchanged. A model whose only change is this is still reported, with * an empty `fieldChanges`. */ extensionsChanged?: true; /** Present exactly when `extensionsChanged`, each when the model had extensions on that side: old → new. */ oldExtensions?: Extensions; newExtensions?: Extensions; /** * Present, and `true`, only when the model's own `constraints` differ — * for an object schema `minProperties`, `maxProperties` and * `dependentRequired`, for a named union what is written beside its * `oneOf`/`anyOf` — compared keyword by keyword (`constraintsShift`; * #599). Breaking when a keyword was tightened and the model is * request-facing, both-facing or of unknown direction, since a value a * caller sends today can be rejected; additive on a response-only model, * or when every keyword only loosened (`classifyConstraintsChange`). A * model whose only change is this is still reported, with an empty * `fieldChanges`. A field's limits are a `field-constraints-changed` * entry in `fieldChanges` instead, and a named union's variant's a * `variant-constraints-changed` entry in `variantChanges`. */ constraintsChanged?: true; /** Present exactly when `constraintsChanged`, each when the model declared limits on that side: old → new. */ oldConstraints?: Constraints; newConstraints?: Constraints; /** * Present exactly when `constraintsChanged`: every keyword that moved, * old → new (`maxProperties 10 → 5; dependentRequired {"a":["b"]} → * {"a":["b","c"]}`), followed by `; tightened on a response-only model` * when the model's direction is what made a tightened keyword additive. */ details?: string; classification: 'additive' | 'breaking'; } interface VariantChange { kind: 'variant-added' | 'variant-removed' | 'discriminator-changed' | 'composition-changed' | 'variant-constraints-changed'; /** * The variant, as a short type label (`Cat`, `string`, `nullable`, * `array`) — the new spec's, for `variant-constraints-changed`; the * discriminator property for `discriminator-changed`; the new * composition keyword for `composition-changed`. */ variant: string; /** * `variant-added` is additive and `variant-removed` breaking, from either * side of the wire. `discriminator-changed` and `composition-changed` are * breaking. A mapping entry that comes with an added variant or goes with a * removed one is part of that variant's entry (see `details`), not a * `discriminator-changed` of its own. `variant-constraints-changed` is * breaking when a keyword was tightened and the union is request-facing, * both-facing or of unknown direction, additive on a response-only union * or when every keyword only loosened, as a field's limits are judged * (`classifyConstraintsChange`; #599). */ classification: 'additive' | 'breaking'; /** * For `variant-constraints-changed`: the limits the variant's type carries * on each side, each present when it carries any there (#599). */ oldConstraints?: Constraints; newConstraints?: Constraints; /** * For `variant-added` / `variant-removed`: present when discriminator * mapping keys came or went with the variant, reading `mapping added for * 'bird'` / `mapping removed for 'dog'`; absent otherwise (an undiscriminated * union's entries never carry it). For `discriminator-changed`: * `discriminator added` / `discriminator removed`, `property changed from * 'kind' to 'type'`, or `mapping changed for 'dog'` naming every key * retargeted, added for a model the old union already dispatched to under * any wrapper (an alias: `kitty: Cat` beside a kept `Cat`, bare or as * `nullable`) or for no variant, or removed while its model stays. For * `composition-changed`: `composition changed from 'anyOf' to 'oneOf'`. * For `variant-constraints-changed`: every keyword that moved, old → new, * at every level of the variant's type (`pattern '^pet_' → '^pt_'`, * `items.maxLength 10 → 5`), followed by `; tightened on a response-only * model` when the union's direction is what made a tightened keyword * additive (#599). */ details?: string; } interface FieldChange { kind: 'field-added' | 'field-removed' | 'field-type-changed' | 'field-format-changed' | 'field-required-changed' | 'field-access-changed' | 'field-deprecated-changed' | 'field-extensions-changed' | 'field-constraints-changed'; fieldName: string; classification: 'additive' | 'breaking'; /** For `field-deprecated-changed`: the flag's two sides, old → new. */ oldDeprecated?: boolean; newDeprecated?: boolean; /** For `field-extensions-changed` (additive, see `ExtensionsChanged`): the field's `extensions` on each side, each when it had any there. */ oldExtensions?: Extensions; newExtensions?: Extensions; /** * For `field-constraints-changed` (#599): the field's own `constraints` * on each side, each present when it declared any there. The field's own * are its type's (under a nullable wrapper) whenever the type can carry * them; a keyword that moved on a nested level of the type — an array's * `items`, a map's `valueType`, a union's variant — is named in * `details` and read from the type, so such a change alone carries two * equal sides, or none. Breaking when a keyword was tightened * (`constraintsShift`) and the model is request-facing, both-facing or of * unknown direction; additive on a response-only model, or when every * keyword only loosened (`classifyConstraintsChange`). Reported beside, * not instead of, a type or format change on the same field. */ oldConstraints?: Constraints; newConstraints?: Constraints; /** * For `field-deprecated-changed`: `live → deprecated` or `deprecated → live`. * For `field-type-changed`: `type changed`, breaking, or — additive, for a * field typed by an inline union that only gained variants — `variant Bird * added` / `variants Bird, Fish added`. For `field-constraints-changed`: * every keyword that moved, old → new, joined with `; ` and prefixed with * the path to a nested level (`maxLength 100 → 10`, `pattern '^pet_' → * '^pt_'`, `minimum → 5`, `items.pattern '^tag_' → '^tg_'`, * `variants[1].maxLength 10 → 5`), followed by `; tightened on a * response-only model` when the model's direction is what made a tightened * keyword additive. */ details?: string; } interface EnumAdded { kind: 'enum-added'; name: string; classification: 'additive'; } interface EnumRemoved { kind: 'enum-removed'; name: string; classification: 'breaking'; } interface EnumModified { kind: 'enum-modified'; name: string; valueChanges: EnumValueChange[]; /** * The enum's own `deprecated` flipped. Additive either way: the values are * unchanged. An enum whose only change is this flag is still reported, with * an empty `valueChanges`. */ deprecatedChanged: boolean; /** Present exactly when `deprecatedChanged`: the flag's two sides, old → new. */ oldDeprecated?: boolean; newDeprecated?: boolean; /** * Present, and `true`, only when the enum's own `extensions` differ (see * `ExtensionsChanged`). Additive: the values are unchanged. An enum whose * only change is this is still reported, with an empty `valueChanges`. */ extensionsChanged?: true; /** Present exactly when `extensionsChanged`, each when the enum had extensions on that side: old → new. */ oldExtensions?: Extensions; newExtensions?: Extensions; classification: 'additive' | 'breaking'; } interface EnumValueChange { kind: 'value-added' | 'value-removed' | 'value-changed' | 'value-deprecated-changed'; valueName: string; classification: 'additive' | 'breaking'; /** For `value-deprecated-changed`: the flag's two sides, old → new. */ oldDeprecated?: boolean; newDeprecated?: boolean; /** For `value-deprecated-changed`: `live → deprecated` or `deprecated → live`. */ details?: string; } interface ServiceAdded { kind: 'service-added'; name: string; classification: 'additive'; } interface ServiceRemoved { kind: 'service-removed'; name: string; classification: 'breaking'; } interface OperationAdded { kind: 'operation-added'; serviceName: string; operationName: string; classification: 'additive'; } interface OperationRemoved { kind: 'operation-removed'; serviceName: string; operationName: string; classification: 'breaking'; } /** The wire encodings a request body or webhook payload is serialized as: `Operation.requestBodyEncoding`'s values. */ type RequestBodyEncoding = NonNullable; interface OperationModified { kind: 'operation-modified'; serviceName: string; operationName: string; paramChanges: ParamChange[]; /** * `Operation.response` changed type, or the operation gained or lost its * only 2xx/3xx response (`responseStatusCode` present on one side only), * with or without a body. Breaking, except a response written as an * inline union that only gained variants, which is additive as a named * union's `variant-added` is. */ responseChanged: boolean; /** * The body appeared, disappeared, or changed type. Breaking, except that a * body appearing with `requestBodyRequired` not `true` is additive: callers * gain an argument they may leave out, like an optional `param-added`; and * so is a body written as an inline union that only gained variants, as a * named union's `variant-added` is. */ requestBodyChanged: boolean; /** * The body stayed but its `requestBodyRequired` flipped. Optional → required * is breaking (callers must now send a body); required → optional is additive. * Compared whenever both specs carry a body the parser keeps the flag on: * one read as `requestBody`, or one carried in `requestBodyContents` alone * — a body under `application/xml` or `application/*+json` alone, which an * SDK offers through its contents and makes mandatory by the flag just the * same — so the flip is reported for either reading, and for a body read * one way in the old spec and the other way in the new (#528). A body * appearing or disappearing takes its flag with it: one read as * `requestBody` is `requestBodyChanged` instead, one carried in its * contents alone is nothing. An absent flag on a carried body reads as * optional, as it does in OpenAPI. */ requestBodyRequiredChanged: boolean; /** * The body stayed but its `requestBodyEncoding` differs: the wire format * the SDK serializes it as (`json`, `form-data`, `form-urlencoded`, * `binary` or `text`), read from the media type the body is declared * under. An SDK built for the old spec keeps serializing and labelling the * body as that spec said, so the change is breaking when the new spec no * longer accepts that representation — the media type the old body was * read from is gone from `requestBodyContentTypes`, or its shape changed, * compared as `retyped` is (`application/json` where the server now reads only * `application/x-www-form-urlencoded`) — and additive when it still does, * as when a media type the parser prefers is added beside it * (`application/json` added beside a kept * `application/x-www-form-urlencoded`: existing callers keep sending the * form body). A body without media-type lists reads as breaking. Compared * only while both specs carry a `requestBody` — unlike * `requestBodyRequiredChanged`, which a body carried in * `requestBodyContents` alone also sets, no encoding is read from such a * body; a body appearing or disappearing takes its encoding with it and * is `requestBodyChanged` alone. Reported beside * `requestBodyContentTypesChanged`, which lists the media types callers * may choose from: a body moving from `application/json` to * `application/x-www-form-urlencoded` sets both (the JSON media type is * removed, the form one added), while a media type changing essence * within one encoding (`application/json` → `application/vnd.api+json`) * sets `requestBodyContentTypesChanged` alone. */ requestBodyEncodingChanged: boolean; /** * Set exactly when `requestBodyEncodingChanged`: the encoding on each * side, old → new. A side is `undefined` when that spec's body carries no * encoding, which the parser never produces (it sets one beside every * body) but a hand-built IR may. */ oldRequestBodyEncoding?: RequestBodyEncoding; newRequestBodyEncoding?: RequestBodyEncoding; /** * True when, both specs declaring a body, it gained or lost a media type * or a secondary media type's body type changed; * `requestBodyContentTypeChange` says which. A body appearing or * disappearing is `requestBodyChanged` alone. */ requestBodyContentTypesChanged: boolean; /** Present exactly when `requestBodyContentTypesChanged`. */ requestBodyContentTypeChange?: RequestBodyContentTypesChange; httpMethodChanged: boolean; pathChanged: boolean; paginatedChanged: boolean; /** * Both versions paginate but `pagination.strategy` differs. Breaking: the * iterator must advance differently (an offset by items received, a page * number by one, a cursor from the response). */ paginationStrategyChanged: boolean; /** Both versions paginate but the parameter the iterator advances (`pagination.param`) differs. Breaking. */ paginationParamChanged: boolean; /** Both versions paginate but the page-size parameter (`pagination.limitParam`) differs, gained or lost. Breaking. */ paginationLimitParamChanged: boolean; /** Both versions paginate but the data array's location (`pagination.dataPath`) differs. Breaking. */ paginationDataPathChanged: boolean; /** Both versions paginate but the first page number (`pagination.pageStart`) differs. Breaking. */ paginationPageStartChanged: boolean; /** * Both versions paginate but `pagination.endOfIteration` differs. Additive * when a stop field appears for the first time (the iterator merely stops * one request sooner); breaking when an existing one changes or disappears. */ paginationEndOfIterationChanged: boolean; injectIdempotencyKeyChanged: boolean; errorsChanged: boolean; /** * The servers the operation is actually served from changed. Each side is * `op.servers ??` that document's servers (`diffSpecs` supplies them), * compared by `diffServers`, the document-level diff, with each list read * as a document whose `baseUrl` is its first entry resolved: matched on * `url` template plus variables (names, defaults, enum values as a set), * ignoring position, descriptions and enum order — except that a reorder * that moves the first entry's resolved URL counts, as `base-url-changed` * does for the document. URLs are compared through `normalizeServerUrl`, * so a scheme or host that only changed case, a default port written or * dropped, or a `/` added after a bare authority is no change. Absent on * both sides is unchanged: the operation inherits twice, and a moved * document is the document-level diff's to report. So a document that * moves to where an operation already pointed is not a change to that * operation. OpenAPI's default server is one list however it is spelled * (#291): no servers and `/` alone — description and variables aside, * since `/` references no variable — are served from the same place. * * Classified change by change, as the document-level diff classifies the * same edit to the document's `servers` (#299), and `serverChanges` lists * them. Breaking when a server the operation's callers could use is gone * or its resolved URL moved: the first entry's resolved URL changed or * disappeared (`base-url-changed`), an entry removed (`server-removed`), * or, on a `server-modified`, a variable the template references removed, * its default changed so that a resolved URL moves, an enum put on it or a * value taken off it. Additive otherwise: an entry added, a first entry * appearing where there was none, a variable added, an enum lifted or a * value added to it, a default changed that moves no resolved URL in its * RFC 3986 form, whatever values a caller picks for the other variables * (a host that only changed case, #406), and any change to a variable the * template never references. The operation is breaking for its servers * exactly when one entry of `serverChanges` is. A webhook carries no * `servers` in the IR (`Webhook` has no such field), so a * `webhook-modified` change has no such flag. */ serversChanged: boolean; /** * What changed between the two effective lists, as `diffServers` reports * it for a document — `base-url-changed`, `server-added`, `server-removed` * and `server-modified` with its `variableChanges` — in that order, each * with its own classification and every URL as written in the spec that * declares it. `[]` when `serversChanged` is false. */ serverChanges: ServerChange[]; /** * The operation's own `deprecated` flipped. Additive either way: the * signature is unchanged. A parameter's flag flipping is a * `param-deprecated-changed` entry in `paramChanges` instead, and a * response header's a `header-deprecated-changed` entry in * `responseHeaderChanges`. */ deprecatedChanged: boolean; /** Present exactly when `deprecatedChanged`: the flag's two sides, old → new. */ oldDeprecated?: boolean; newDeprecated?: boolean; /** * The security requirements the operation's requests must satisfy changed. * Each side is `op.security ?? ` that document's `security` (`diffSpecs` * supplies them), `[]` when neither declares any; the two lists are * compared as sets of alternatives, each a set of schemes with scopes as * sets, so order and repetition do not count. Absent on both sides is * unchanged: the operation inherits twice, and a moved document default is * the document-level `security-changed` change's to report. Breaking when * a request built for the old list no longer satisfies the new one — a * scheme or scope it now has to carry, an alternative it could use that is * gone, an anonymous alternative withdrawn; additive when every old * alternative still passes — a new alternative, a scope or scheme no longer * needed, authentication made optional. */ securityChanged: boolean; /** Present exactly when `securityChanged`: the effective requirements on each side, old → new. */ oldSecurity?: SecurityRequirementSet[]; newSecurity?: SecurityRequirementSet[]; /** * The operation's `tags` differ, compared in document order (an absent key * is an empty list). Always additive: tags group and document a method and * change nothing a caller compiles against. Operations are matched by * name within a service, so this flag only ever carries an edit that * leaves the operation in a service of the same name; a first-tag change * that the parser's grouping files under another service leaves nothing * to match, and the diff reports the move instead — removed from the old * service and added to the new one, or `service-removed` and * `service-added` when a service goes or comes with it. */ tagsChanged: boolean; /** Present exactly when `tagsChanged`: the lists on each side, old → new, `[]` for none. */ oldTags?: string[]; newTags?: string[]; /** * Present, and `true`, only when the operation's `extensions` differ (see * `ExtensionsChanged`). Additive: the operation's signature is unchanged. * A change whose only content is this is still reported. */ extensionsChanged?: true; /** Present exactly when `extensionsChanged`, each when the operation had extensions on that side: old → new. */ oldExtensions?: Extensions; newExtensions?: Extensions; /** * What changed about the list envelope's fields * (`Operation.pagination.envelopeFields`, which an emitter types the * envelope from), matched by field name while both specs paginate and * compared as a model's fields are (`diffFields`), an absent list reading * as no field. Each entry is classified as on a response-only model, since * the envelope is only ever read: a field added is additive, required or * not; one removed or retyped is breaking, but for an inline union that * only gained variants; format, requiredness, access flags, `deprecated` * and extensions are judged as on any model's field, and a limit * tightened or loosened (`field-constraints-changed`) is additive either * way, as on a response-only model (#599). The operation is * breaking when an entry is. Present only when there is at least one. A * scalar companion (`has_more`) sits on no model `diffModels` reads, so * this is where its change is reported; a companion object's own fields * are compared in the models diff like any model's, and its envelope field * is an entry here only when the field itself changes, the model it names * included. */ envelopeFieldChanges?: FieldChange[]; /** * True when a response entry gained or lost a media type, or a secondary * media type's body type changed; `responseContentTypeChanges` says which. */ responseContentTypesChanged: boolean; responseContentTypeChanges: ResponseContentTypesChange[]; /** * True when a response entry gained, lost, retyped, re-required, renamed * or deprecated one of the headers it declares, or changed the limits * its type carries; `responseHeaderChanges` says which. */ responseHeadersChanged: boolean; responseHeaderChanges: ResponseHeaderChange[]; /** * `Operation.responseStatusCode` — the status code the primary success * response is read from — differs while both specs carry one: a lone * `201` that became a lone `200`, a `200` added beside a lone `201` (the * `200` is now the primary), a `201` that became the primary beside a * `200` whose body is no longer typed, or a `200` beside a `202` that * became a `201` beside the `202`. Breaking when the new spec no longer * declares the code the old primary answered with — neither as its * `responseStatusCode` nor among its `successResponses`; errors, `default` * and ranges do not count — since a caller that checks the declared code * (generated code, or the smoke helpers that read `responseStatusCode`) * stops matching, and a redirect moving between temporary and permanent * (`302` → `301`) changes what caches may do: the first and last cases, * and a lone `200` that became a lone `204`. Additive when the old code * is still declared, as in the second and third cases: the `201` beside * the added `200` is still answered, so a caller built for it still * works, and the `200` whose body lost its type is still declared — what * breaks there is its body, reported as a `responseContentTypeChanges` * entry under `200` (`retyped`, or `removed` when the body is gone), not * the move (#407). Only two lone primaries pair over the move, though: a * primary replaced among several 2xx (the last case) no longer declares * its old code, so its headers and media types are reported removed under * that code, breaking, beside this flag, as they are for a `200` dropped * beside a kept `202` (#408). * Compared only while both sides carry a code, as `requestBodyRequired` * is while both carry a body; an operation gaining or losing its only * 2xx/3xx is not a move but `responseChanged`. Not mirrored into * `behaviorChanges`. */ responseStatusCodeChanged: boolean; /** Present exactly when `responseStatusCodeChanged`: the code on each side, old → new. */ oldResponseStatusCode?: number; newResponseStatusCode?: number; /** The `default` or a `1XX`–`5XX` range response was added, removed, or changed type. */ fallbackResponsesChanged: boolean; classification: 'additive' | 'breaking'; } /** * A change to one header a response declares — `Operation.responseHeaders` * on the primary success response, `headers` on each other `SuccessResponse`, * on each `ErrorResponse`, on the `DefaultResponse` and on each * `RangeResponse` — between two specs. The SDK reads these headers off the * response and never sends them, so each kind is classified from the * reader's side, as a webhook's parameters are: a header added is additive, * required or not (the server simply starts sending it); one removed is * breaking (an accessor the SDK exposed is gone); a type change is breaking, * a format-only change additive, as elsewhere; optional → required is * additive (the header is now always present) and required → optional * breaking (code that assumed it breaks); a `deprecated` flip, a * respelling and a limit tightened or loosened on the header's type * (`header-constraints-changed`; #599) are additive. * * Response entries pair up between the two specs exactly as they do for * `responseContentTypeChanges`: by status code — every 2xx entry, the * primary among them (a lone 2xx by `Operation.responseStatusCode`), and * every error — with `statusCode` set; two lone primaries of different * codes pair with each other, the move reported once as * `responseStatusCodeChanged`, though a primary replaced among several 2xx * (`200` + `202` → `201` + `202`) pairs with nothing, its headers reported * `header-removed` under its code (#408); a lone 2xx that carries no code (a hand-built * IR) pairs with the entry of the other spec that offers its media types, * else with that spec's primary, and is reported with `statusCode` unset, * though only one that carries media types or headers pairs as the old * spec's: one that carries neither, as the primary of an operation that * declared no 2xx/3xx does, pairs with nothing, so a 2xx the new spec adds * to it is no header change; the `default` and range responses by key, * with `fallback` set. Within an entry, headers pair * by name case-insensitively (RFC 9110 §5.1, `foldHeaderName`), so * `X-Rate-Limit` and `x-rate-limit` are one header: a pair whose written * names differ is reported as `header-name-changed` with `oldName`/`newName` * beside it, additive, since an emitter may derive an identifier from the * name as written. Two names of one folding declared side by side (a * hand-built IR; the parser keeps one) stay two headers: each pairs with the * one spelled the same way on the other side, else with the other side's * next unpaired name of its folding, and one left over is added or removed. * A 2xx entry the old spec declared and the new does not has no other diff * to report its headers, so each is reported `header-removed`; an error or * fallback entry only one spec declares is the errors or fallback diff's * business, and so is a 2xx the new spec adds. A webhook's accepted * responses (`WebhookResponse`) carry no headers in the IR, so a * `webhook-modified` change has no such list. */ interface ResponseHeaderChange { kind: 'header-added' | 'header-removed' | 'header-type-changed' | 'header-format-changed' | 'header-required-changed' | 'header-name-changed' | 'header-deprecated-changed' | 'header-constraints-changed'; /** The header's name as written in the spec that declares it: the new spec's for a header both declare. */ headerName: string; /** * The response entry's status code — `Operation.responseStatusCode` for a * lone 2xx — of the entry that declares what changed: the old spec's for * `header-removed`, the new spec's for every other kind — so an operation * that lost its only 2xx, whose new primary carries no code, reports that * entry's headers under its old code. Unset for a fallback response, and * for a lone 2xx of a hand-built IR that carries no code. */ statusCode?: number; /** Set instead of `statusCode` for the `default` or a `1XX`–`5XX` range response, which carry no code. */ fallback?: 'default' | StatusRange; classification: 'additive' | 'breaking'; /** For `header-name-changed`: the name as written in the old spec. */ oldName?: string; /** For `header-name-changed`: the name as written in the new spec (the same as `headerName`). */ newName?: string; /** For `header-deprecated-changed`: the flag's two sides, old → new. */ oldDeprecated?: boolean; newDeprecated?: boolean; /** * For `header-constraints-changed` (#599): the limits the header's type * carries on each side, each present when it carries any there (a * `ResponseHeader` carries none of its own). A keyword that moved on a * nested level — an array header's `items` — is named in `details`. */ oldConstraints?: Constraints; newConstraints?: Constraints; /** * What changed, in words: `format → ` for `header-format-changed`, * `optional → required` or `required → optional` for * `header-required-changed`, `name → ` for `header-name-changed`, * `live → deprecated` or `deprecated → live` for `header-deprecated-changed`, * every keyword that moved, old → new (`pattern '^req_' → '^rq_'`, * `items.maxLength 10 → 5`), for `header-constraints-changed`. */ details?: string; } /** * How one response entry's media types changed between two specs. Entries * pair up by status code — 2xx entries from `successResponses`, the primary * among them, errors from `errors` — so a primary that changes status still * pairs with the entry of its code; a lone 2xx pairs by its * `Operation.responseStatusCode` and is reported with that code, and two * lone primaries of different codes pair with each other * (`responseStatusCodeChanged` reports the move), though a primary replaced * among several 2xx (`200` + `202` → `201` + `202`) pairs with nothing, its * media types `removed` under its code (#408); a primary that carries no * code (an operation declaring no 2xx/3xx, or a hand-built IR's lone 2xx) is * paired with the entry of the other spec that offers its media types, else * with that spec's primary, except the old spec's when it carries no media * types or headers either, as the primary of an operation that declared no * 2xx/3xx does: that one pairs with nothing, so a 2xx the new spec adds to * it is no media-type change. A change is located at the new spec's entry, * or — when that entry carries no code and the change only removes, as * when an operation lost its only 2xx — at the old spec's entry, which * declared what is gone, so `statusCode` is unset only for a lone 2xx of a * hand-built IR that carries no code. The `default` and range responses pair by key * and are reported with `fallback` set. A 2xx the old spec declared and the * new does not is reported with its media types `removed`; one the new spec * adds is no media-type change. Media types are compared by essence — * `type/subtype`, case folded, parameters stripped (`mediaTypeEssence`, the * rule the parser types a body by) — and order aside: reordering them is no * change, and neither is a key that only changed case (`Text/HTML`) or * gained, lost or respelled `charset` (`application/problem+json; * charset=utf-8`); a pair whose other parameters differ is * `reparameterized`, additive. Each media type is reported as written in * the spec that declares it (`retyped` lists the new spec's spelling). Two keys of one * essence declared side by side (`application/json` beside * `application/json; charset=utf-8`) stay two media types: each pairs, in * this order of preference, with the key spelled the same way on the other * side, else one of its essence with the same parameters other than * `charset`, else one of its essence whose body is the same shape, else the * other side's next unpaired key of its essence; one left over is `added` * or `removed`. */ interface ResponseContentTypesChange { statusCode?: number; /** Set instead of `statusCode` for the `default` or a `1XX`–`5XX` range response, which carry no code. */ fallback?: 'default' | '1XX' | '2XX' | '3XX' | '4XX' | '5XX'; /** Media types the new spec declares and the old did not: callers gain a representation to ask for. */ added: string[]; /** Media types the old spec declared and the new does not: a representation callers could ask for is gone. */ removed: string[]; /** * Media types declared by both whose body's shape changed — two model * refs are compared field by field through the two specs' models, nested * models and enums included, so a model that was only renamed (a * parameter edit on a key declared beside another spelling of its essence * renames the model the parser mints for it) is no retype and surfaces as * `model-removed` + `model-added` instead — other than the one the entry's * own `type` is read from, which `responseChanged` and `errorsChanged` * already report. Two model or enum refs whose names both specs declare * are compared by name, nested ones included, however alike: neither was * renamed, so a body moved from `Note` to an identical `NoteCopy` is * retyped. */ retyped: string[]; /** * Media types declared by both whose parameters other than `charset` * differ (`application/pdf; version=1.7` → `; version=2.0`), both * spellings as written: the body is typed the same, but the parameter * may select another representation, so the change is kept visible. * Additive. Case, whitespace, parameter order and `charset` are not * differences. */ reparameterized: Array<{ from: string; to: string; }>; /** `breaking` when anything was removed or retyped, else `additive`. */ classification: 'additive' | 'breaking'; } /** * How an operation's or a webhook's request body media types changed: the * `content` keys of its Request Body Object, compared the way a response * entry's are (see `ResponseContentTypesChange`) — by essence, order aside, * each reported as written in the spec that declares it, two keys of one * essence kept apart. Compared only while both specs declare a body: one * appearing or disappearing is `requestBodyChanged` alone, and the body * `requestBody` is read from is left to `requestBodyChanged` when it changes * type, so `retyped` only ever lists a secondary media type. Classified * from the node's side. For an operation, the caller sends the body: a * media type it could send that is gone, or whose body changed type, is * breaking; one it can newly send is additive. For a webhook, the handler * decodes the body the sender chose: a media type the sender can newly use, * or whose body changed type, is breaking; one it can no longer use is * additive. */ interface RequestBodyContentTypesChange { /** Media types the new spec declares and the old did not: a representation the caller can newly send. */ added: string[]; /** Media types the old spec declared and the new does not: a representation the caller could send is gone. */ removed: string[]; /** * Media types declared by both whose body's shape changed — two model * refs are compared field by field through the two specs' models, nested * models and enums included, so a model that was only renamed (a * parameter edit on a key declared beside another spelling of its essence * renames the model the parser mints for it) is no retype and surfaces as * `model-removed` + `model-added` instead — other than the one * `requestBody` is read from, which `requestBodyChanged` reports. Two * model or enum refs whose names both specs declare are compared by name, * nested ones included, however alike: neither was renamed, so a body * moved from `Note` to an identical `NoteCopy` is retyped. */ retyped: string[]; /** * Media types declared by both whose parameters other than `charset` * differ (`application/vnd.pets+json; version=1` → `; version=2`), both * spellings as written: the body is typed the same, but the parameter * may select another representation, so the change is kept visible. * Additive on either side. Case, whitespace, parameter order and * `charset` are not differences. */ reparameterized: Array<{ from: string; to: string; }>; /** * From the caller's side on an operation: `breaking` when anything was * removed or retyped, else `additive`. From the receiver's side on a * webhook: `breaking` when anything was added or retyped, else `additive`. */ classification: 'additive' | 'breaking'; } /** * A webhook is identified by its `name` and `httpMethod` together, since one * `webhooks` key may declare several methods; a method change therefore * reports as one webhook removed and another added. */ interface WebhookAdded { kind: 'webhook-added'; name: string; httpMethod: string; classification: 'additive'; } interface WebhookRemoved { kind: 'webhook-removed'; name: string; httpMethod: string; classification: 'breaking'; } /** * Changes to a webhook the receiver already handles. Read from the receiver's * side: a payload type or encoding change breaks the handler's signature, a * body that may now be absent breaks a handler that assumed one, and * parameter changes are classified the way a response's would be (see * `diffWebhookParams`). Every `ParamChange` carries its `paramLocation`, * since a header and a query parameter may share a name; a header's name is * matched case-insensitively, as on an operation, so a header whose name * only changed case is a `param-name-changed` entry. A parameter's * `deprecated` flipping is a `param-deprecated-changed` entry there, as on * an operation. The security the request carries is read from the * receiver's side too: a credential the sender stops presenting, or an * alternative it may now present that the handler never checked for, is * breaking. A webhook carries no `servers` in the IR (`Webhook` has no such * field), so there is no `serversChanged` or `serverChanges` here. The * fields are `ReceivedRequestModified`'s, which a `callback-modified` * change carries too, since a callback is compared exactly as a webhook is * (#382). */ interface WebhookModified extends ReceivedRequestModified { kind: 'webhook-modified'; name: string; httpMethod: string; } /** * Where a callback sits, named the way the owning change names its owner: * an operation's callback by `serviceName` + `operationName` (the * `operation-modified` change's), a webhook's by `webhookName` + * `webhookMethod` (the `webhook-modified` change's `name` + `httpMethod`). * A nested callback — one declared by a callback operation — additionally * lists the callbacks between the owner and itself under `parents`, * outermost first, present only when nested. Carried on every * `callback-added` / `callback-removed` / `callback-modified` change and on * the `callback` and `callback-parameter` nodes of `behaviorChanges` (#382). */ type CallbackSite = ({ serviceName: string; operationName: string; } | { webhookName: string; webhookMethod: string; }) & { parents?: CallbackParent[]; }; /** One callback on the way down to a nested one: the triple that identifies it (see `Callback`). */ interface CallbackParent { name: string; expression: string; httpMethod: string; } /** * A callback is identified by its `name`, `expression` and `httpMethod` * together — one `callbacks` key may map several runtime expressions to * path items, each declaring several methods — so an expression or method * edit reports as one callback removed and another added, as a webhook's * method edit does. Reported for each pair of operations or webhooks both * documents carry, right after the owner's `operation-modified` / * `webhook-modified` change or where it would be: a callback change is * reported even when the owner itself has no other change, and an owner * added or removed reports nothing for its callbacks, since the owner's * change already says it (#382). */ type CallbackAdded = { kind: 'callback-added'; name: string; expression: string; httpMethod: string; classification: 'additive'; } & CallbackSite; type CallbackRemoved = { kind: 'callback-removed'; name: string; expression: string; httpMethod: string; classification: 'breaking'; } & CallbackSite; /** * Changes to a callback the receiver already handles: the comparison and * classification `webhook-modified` makes, read from the receiver's side * (`ReceivedRequestModified`), on the callback the site names. Its own * `deprecated` flip and security change are mirrored into `behaviorChanges` * as `callback` nodes and a parameter's flip as a `callback-parameter` * node, each carrying the site, as a webhook's are (#382). */ type CallbackModified = { kind: 'callback-modified'; name: string; expression: string; httpMethod: string; } & ReceivedRequestModified & CallbackSite; /** * What a `webhook-modified` and a `callback-modified` change carry beside * the node's identity: the comparison of a request the SDK user receives, * read from the receiver's side (`diffReceivedRequest`). */ interface ReceivedRequestModified { paramChanges: ParamChange[]; /** * True when the payload's type changed, or — both specs declaring a * payload — its encoding, its `requestBodyRequired` or the media types the * sender may use did; `details` says which. The flag is compared whenever * both specs carry a payload the parser keeps it on, read as `requestBody` * or carried in `requestBodyContents` alone (one under `application/xml` * alone, say), as an operation's `requestBodyRequiredChanged` is (#528); * the encoding only while both carry a `requestBody`, since none is read * from a payload carried in its contents alone; the media types whenever * both carry a `requestBody` or declare `requestBodyContentTypes`, as the * flag is, so a payload carried in its contents alone on either side still * reports the media types the sender gained or lost. */ requestBodyChanged: boolean; /** * Set exactly when the payload's encoding changed (`details` reads * `encoding json → form-urlencoded`): the encoding on each side, old → * new, as an `operation-modified` change carries them. Breaking when the * representation the sender now uses — the media type the new payload is * read from, with its shape — is not one the old spec declared with that * shape, so the handler decodes a wire format it never saw; additive when * the old spec already declared it. A payload without media-type lists * reads as breaking. Compared only while both specs carry a `requestBody`, * as on an operation: a payload appearing or disappearing is `payload * added` / `payload removed` in `details` and carries neither field, and * one carried in its contents alone on either side (no encoding is read * from it) carries neither too, whatever its media types did. */ oldRequestBodyEncoding?: RequestBodyEncoding; newRequestBodyEncoding?: RequestBodyEncoding; /** * Present exactly when the payload's media types changed: which were * added, removed or retyped, classified from the receiver's side (see * `RequestBodyContentTypesChange`). */ requestBodyContentTypeChange?: RequestBodyContentTypesChange; /** True when the set of status codes the sender accepts changed; `details` says which (a code removed is breaking). */ responsesChanged: boolean; /** * The webhook's own `deprecated` flipped. Additive either way: the handler's * signature is unchanged. A webhook whose only change is this flag is still * reported, with an empty `paramChanges`. */ deprecatedChanged: boolean; /** Present exactly when `deprecatedChanged`: the flag's two sides, old → new. */ oldDeprecated?: boolean; newDeprecated?: boolean; /** * The security the request carries changed. Each side is * `webhook.security ?? ` that document's `security`, `[]` when neither * declares any, compared as on an operation (sets of alternatives; absent * on both sides is unchanged). Breaking when what the sender may now * present no longer carries what the handler checked for — a scheme it * stops presenting, an alternative it may now use that the old list never * offered; additive when every new alternative still carries some old one * — a credential the sender starts carrying beside the old ones, an * alternative withdrawn. */ securityChanged: boolean; /** Present exactly when `securityChanged`: the effective requirements on each side, old → new. */ oldSecurity?: SecurityRequirementSet[]; newSecurity?: SecurityRequirementSet[]; /** The webhook's `tags` differ, compared in document order. Always additive, as on an operation. */ tagsChanged: boolean; /** Present exactly when `tagsChanged`: the lists on each side, old → new, `[]` for none. */ oldTags?: string[]; newTags?: string[]; /** What changed about the body or the accepted responses, e.g. `payload type changed; accepted response 200 removed`. */ details?: string; classification: 'additive' | 'breaking'; } /** * Where a parameter lives. An operation carries parameters in all four * locations (`Operation.pathParams`, `queryParams`, `headerParams` and * `cookieParams`); a webhook carries `header`, `query` and `cookie` ones. * `locatedParams` in `params.ts` tags every parameter a node carries with * its location, and `paramKey` there joins it to the name to identify one. * The same four locations `ParameterLocation` in `ir/parameter-key.ts` * names, since the parser merges parameters on the same identity. */ type ParamLocation = ParameterLocation; /** * A change to one parameter of an operation or a webhook, in any location it * carries one. Parameters are matched by location and name (`paramKey` in * `params.ts`, which is `parameterKey` in `ir/parameter-key.ts`) — OpenAPI * allows a path `id` beside a query `id` on one operation — so every entry * carries `paramLocation` to say which one it is. A header's name is * compared case-insensitively (RFC 9110 §5.1): a header written * `X-Pet-Token` on one side and `x-pet-token` on the other is one parameter, * and the spelling change is a `param-name-changed` entry (additive, with * `oldName`/`newName`) beside whatever else changed about it, not a * `param-removed` beside a `param-added`. Path, query and cookie names are * case-sensitive. On the entries of a paired parameter, `paramName` is the * name as the new spec writes it; a `param-removed` entry carries the old * spec's name, which the new spec no longer has, and a `param-added` entry * the new spec's. */ interface ParamChange { kind: 'param-added' | 'param-removed' | 'param-type-changed' | 'param-format-changed' | 'param-required-changed' | 'param-default-changed' | 'param-deprecated-changed' | 'param-name-changed' | 'param-content-type-changed' | 'param-constraints-changed'; paramName: string; classification: 'additive' | 'breaking'; /** * For `param-constraints-changed` (#599): the parameter's own * `constraints` on each side, each present when it declared any there — * its type's (under a nullable wrapper) whenever the type can carry them, * so a keyword that moved on a nested level of the type (an array * parameter's `items`) is named in `details` and read from the type. On * an operation, judged from the caller's side: breaking when a keyword * was tightened (`constraintsShift`), since a value a caller sends today * can be rejected, additive when every keyword only loosened. On a * webhook or a callback, additive either way: the receiver reads the * value and never supplies it. Reported beside, not instead of, a type or * format change on the same parameter. */ oldConstraints?: Constraints; newConstraints?: Constraints; /** For `param-name-changed`: the name as the old spec wrote it. */ oldName?: string; /** For `param-name-changed`: the name as the new spec writes it (also `paramName`). */ newName?: string; /** For `param-default-changed`: serialized old default value, or `null` if previously unset. */ oldDefault?: string | null; /** For `param-default-changed`: serialized new default value, or `null` if now unset. */ newDefault?: string | null; /** For `param-deprecated-changed`: the flag's two sides, old → new. */ oldDeprecated?: boolean; newDeprecated?: boolean; /** * For `param-content-type-changed`: `Parameter.contentType` on each side as * written — for a `content` map none of whose media types is read, the * first of its `Parameter.contentTypes` — or `null` for a parameter typed * by `schema` (see `parameterContentTypeShift` in `params.ts`). */ oldContentType?: string | null; newContentType?: string | null; /** * Where the parameter lives. Set on every entry `diffOperations` produces * (an operation's path, query, header and cookie parameters) and on every * entry `diffWebhooks` produces (a webhook's header, query and cookie * parameters may share a name). */ paramLocation?: ParamLocation; /** * For `param-deprecated-changed`: `live → deprecated` or `deprecated → live`. * For `param-name-changed`: `name X-Pet-Token → x-pet-token`. * For `param-content-type-changed`: `content type → application/json`, * a side whose map the parser does not read followed by `(unread)` * (`content type → application/xml (unread)`). * For `param-constraints-changed`: every keyword that moved, old → new, * joined with `; ` and prefixed with the path to a nested level * (`pattern '^pet_[0-9A-Z]{26}$' → '^pet_[0-9A-Z]{12}$'`, `minimum 1 → 5`, * `maxLength 10 → `, `items.pattern '^tag_' → '^tg_'`). */ details?: string; } /** * `ApiSpec.baseUrl` — the first server's URL with its variables' defaults * filled in — differs, so a client built on the default host sends its * requests somewhere else. Reported once per diff whatever moved it: a * changed `servers[0]` template (also a `server-removed` plus a * `server-added`), a changed variable default (also a `server-modified`), a * reordered list, or a `servers` list that appeared or disappeared. The two * URLs are compared through `normalizeServerUrl` (RFC 3986: scheme and host * case, a default or empty port, a bare authority's `/`, percent-encoding * case), so a `baseUrl` that only changed in one of those ways is not * reported; both are carried as written. The comparison also reads `''` and * `/` as one address — OpenAPI's default, whether the document declares no * server, writes `/` out, or resolves its first server to `/` — so nothing * is reported between those (#291). */ interface BaseUrlChanged { kind: 'base-url-changed'; /** As written in the old document; `''` when it declared no server, `/` when its first server resolved to `/`, which means the same. */ oldBaseUrl: string; /** As written in the new document; `''` when it declares no server, `/` when its first server resolves to `/`, which means the same. */ newBaseUrl: string; /** * Breaking when the default host moves or disappears. Additive when the old * document declared nothing beyond OpenAPI's default server — no `servers`, * `servers: []`, or nothing but `/` (`isDefaultServerList`): every existing * caller had to name a host themselves and still can. A `/` the old * document listed first beside another server is the address a caller got * without naming one, so a host taking the front from it is breaking * (#405). */ classification: 'additive' | 'breaking'; } /** * A server the new document lists and the old did not. The `/` a document * is only implied to have — its list means OpenAPI's default — is never * reported here; `/` listed beside another server is, like any other (#291). */ interface ServerAdded { kind: 'server-added'; /** The URL template as written in the new document, placeholders included. */ url: string; classification: 'additive'; } /** * A server the old document listed and the new does not. The `/` a document * is only implied to have is never reported here; `/` listed beside another * server is, like any other (#291). */ interface ServerRemoved { kind: 'server-removed'; /** The URL template as written in the old document, placeholders included. */ url: string; classification: 'breaking'; } /** * A server present in both documents — matched on its `url` template through * `normalizeServerUrl`, so a template that only changed scheme or host case, * a default port or a bare authority's `/` is the same server; * position-independent; a template declared more than once is matched as a * multiset, see `diffServers` — whose variables changed. A changed template * is a `server-removed` plus a `server-added` instead. */ interface ServerModified { kind: 'server-modified'; /** The URL template as written in the new document, placeholders included. */ url: string; variableChanges: ServerVariableChange[]; classification: 'additive' | 'breaking'; } /** * One variable of a `server-modified` server, matched by name. A variable * added, an enum lifted (`variable-enum-removed`) and an enum value added are * additive for any variable. The other four kinds — the variable removed, its * default changed, an enum appearing, an enum value removed — are breaking * when the server's `url` template references the variable (its `{name}` is * in the template, so the resolved URL a caller built on moves) and additive * when it does not: a variable the template never references cannot reach * any resolved URL, so nothing a caller relied on is taken away. In that * additive case — those four kinds only — `details` says so; the three kinds * that are additive for any variable keep their shape. A referenced * variable's default changed is additive too when it moves nothing: when the * template with only that variable filled in is one URL in its RFC 3986 form * (`normalizeServerUrl`) from either default, as when only the host's case * changed (#406); `details` then says so. The other placeholders are kept * rather than filled from their defaults, so that holds whatever values a * caller picks for them: in `{scheme}://pets.example.com:{port}`, `port` * going from `443` to `''` stays breaking, since a caller who picks `http` * moves from port 443 to 80. */ interface ServerVariableChange { kind: 'variable-added' | 'variable-removed' | 'variable-default-changed' | 'variable-enum-added' | 'variable-enum-removed' | 'variable-enum-value-added' | 'variable-enum-value-removed'; variableName: string; classification: 'additive' | 'breaking'; /** For `variable-default-changed`: the previous default. */ oldDefault?: string; /** For `variable-default-changed`: the new default. */ newDefault?: string; /** For `variable-enum-value-added` / `variable-enum-value-removed`: the value. */ value?: string; /** * What changed, in words, for `variable-default-changed`, * `variable-enum-added` and `variable-enum-removed`. For a variable the * template never references, every change that would otherwise be breaking * also carries (appended after `; ` when there is other text) `{name} is * not in the URL template, so no resolved URL moves`. A default changed on a * referenced variable without moving any resolved URL carries `either * default resolves to the same URL in its RFC 3986 form` after its text the * same way. */ details?: string; } /** * The changes `diffServers` reports between two server lists: the * document-level kinds, which an `operation-modified` change carries as * `serverChanges` when the operation's effective servers differ (#299). */ type ServerChange = BaseUrlChanged | ServerAdded | ServerRemoved | ServerModified; /** * `ApiSpec.security` — the default every operation and webhook that declares * no `security` of its own inherits — differs between the two documents, * compared as sets of alternatives (order and repetition do not count; `[]` * and an undeclared list both mean no authentication). Reported once per * diff: an operation or webhook that inherits on both sides is not reported * again for it, while one that declares its own list on either side is * compared on what it actually requires (`securityChanged`). */ interface DocumentSecurityChanged { kind: 'security-changed'; /** The old document's list; `[]` when it declared none. */ oldSecurity: SecurityRequirementSet[]; /** The new document's list; `[]` when it declares none. */ newSecurity: SecurityRequirementSet[]; /** * Read from each side that inherits the default in both documents, by the * rule the inheriting node would be read by (`classifySecurityChange`): * the caller's when an operation does, the receiver's when a webhook or * a callback does (#382), each matched across the documents as its own * change is; breaking * if any such side breaks. A node that declares its own list on either * side is compared on its own (`securityChanged`), and one added or * removed is reported as such. When nothing inherits it in both * documents, no request reads both defaults, so the change is additive. */ classification: 'additive' | 'breaking'; } /** * A security scheme the new document declares under * `components.securitySchemes` (`ApiSpec.auth`) and the old did not, * matched by `schemeName` (#384). Breaking when the old document already * had the scheme in use — named by the effective requirement list, * `node.security ?? spec.security ?? []`, of one of its operations or * webhooks — under a definition the parser omits from `auth` * (`openIdConnect`, an `http` scheme such as `digest`, `mutualTLS`): every * old request carried that, not what the new definition reads, so `petKey: * { type: openIdConnect, … }` becoming `{ type: apiKey, in: header, name: * X-Key }` under `security: [{ petKey: [] }]` breaks, as the reverse (a * `security-scheme-removed` a requirement still names) does. Additive * otherwise: no request built for the old document carried it, and a * requirement that starts naming it is reported as the requirement change * it is (`security-changed`, `securityChanged`). Listed after the * document's `security-changed` change and before the models, with the * removed and modified schemes after it. */ interface SecuritySchemeAdded { kind: 'security-scheme-added'; /** The key under `components.securitySchemes`, as the requirements name it. */ schemeName: string; /** The definition as the new document declares it. */ scheme: AuthScheme; classification: 'additive' | 'breaking'; } /** * A security scheme the old document declared under * `components.securitySchemes` and the new does not (#384). Breaking when * some request read it: the scheme is in use in the old document — named * by the effective requirement list, `node.security ?? spec.security ?? * []`, of one of its operations, webhooks or callbacks (#382), so the * document default counts only through a node that inherits it — or in the * new document, which * then requires what it does not define. Additive when nothing read it on * either side, as a change to a server variable no template references is * (#342): dropping a definition no request carries moves nothing on the * wire. */ interface SecuritySchemeRemoved { kind: 'security-scheme-removed'; /** The key under `components.securitySchemes`, as the requirements name it. */ schemeName: string; /** The definition as the old document declared it. */ scheme: AuthScheme; classification: 'additive' | 'breaking'; } /** * A security scheme both documents declare whose definitions differ in * anything but `description` and `x-*` keys (documentation and extensions * are never a change, as everywhere in the differ) (#384). Breaking when * its wire form regressed and the scheme is in use in the new document * (named by the effective requirement list of one of its operations, * webhooks or callbacks, as for a removed scheme): an SDK built for the * old definition sends `X-Key` to a server that now reads `X-Api-Key`, and * a webhook handler built for it checks a header the sender no longer * carries. Additive when nothing in the new document uses it (no request * carries the old form to the new server), or when the definition only * grew. * * The wire form is the `kind`; an `apiKey`'s `in` and `name`, a header's * name compared folded (`foldHeaderName`) since HTTP header names are * case-insensitive (RFC 9110 §5.1) — a header respelled `X-Key` → `x-key` * is still reported, with the spelling in `details`, but is additive, as a * case-only header parameter rename is, while a query or cookie name is * case-sensitive, so the same respelling there is breaking in use; and an * `oauth2` scheme's `flows`, read the way `security-changed` reads a * requirement's alternatives: a flow added beside unchanged ones, or a * `refreshUrl` added to a flow that had none, is an alternative a caller * may use and is additive, while a flow removed, or a URL a flow already * declared (`authorizationUrl`, `tokenUrl`, `refreshUrl`) changed or * removed, is breaking in use. Each flow's `scopes` map is the * requirement's to need, which `security-changed` compares, so a scope * added, re-described, or removed while no requirement names it is * reported but additive; a scope the old definition offered in some flow, * the new offers in none, and a requirement in the new document still * names on the scheme is breaking, `details` naming it: the document now * asks for what its definition no longer offers, as it does for a removed * scheme a requirement still names. */ interface SecuritySchemeModified { kind: 'security-scheme-modified'; /** The key under `components.securitySchemes`, as the requirements name it. */ schemeName: string; /** The definition as the old document declared it. */ oldScheme: AuthScheme; /** The definition as the new document declares it. */ newScheme: AuthScheme; /** * What changed, in words: `apiKey → http basic` (`http bearer`, `oauth2`) * for a changed kind; `apiKey in header "X-Key" → in header "X-Api-Key"` * for an `apiKey` whose location or name moved; `oauth2 flows changed` * when anything but a `scopes` map moved in an `oauth2` scheme's flows, * `oauth2 scopes changed` when only scopes did, either followed by * `; required scope "write:pets" removed` (`required scopes "a", "b" * removed`, sorted) when a scope a requirement in the new document still * names is no longer offered. */ details: string; classification: 'additive' | 'breaking'; } /** * The changes `diffAuthSchemes` reports between two documents' `auth` * lists: added, then removed, then modified, each in its document's order. */ type SecuritySchemeChange = SecuritySchemeAdded | SecuritySchemeRemoved | SecuritySchemeModified; //#endregion //#region src/parser/schemas.d.ts /** * Signature of the `schemaNameTransform` hook. `name` is the cleaned * PascalCase name; `originalName` is the `components.schemas` key exactly * as spelled in the document, or `undefined` for names oagen synthesises. * See `SchemaExtractionOptions.schemaNameTransform`. */ type SchemaNameTransform = (name: string, originalName?: string) => string; //#endregion //#region src/parser/parse.d.ts /** * A bundled OpenAPI document, post-`$ref` resolution but pre-IR extraction. * * This is the shape the spec author wrote, with external refs inlined and * internal refs left intact. It is intentionally loose (`Record`) so `transformSpec` can reach arbitrary spec extensions without * fighting types — narrow with `as` at use sites. */ type OpenApiDocument = Record; interface ParseOptions { /** * Custom transform for operation IDs. Receives each `operationId` once, as * the document spells it with its trailing `[N]` overload markers stripped; * returns the operation's name, used as is (no casing conversion). A result * with no ASCII letter or digit once such markers are stripped (`''`, * `' '`, `'-'`, `'[1]'`), or that is not a string, names nothing: the * operation is then read as one without an `operationId` — path-named, its * models named from its path, `Operation.operationId` unset — after one * warning naming the id and the operation (#570). An `operationId` that * itself names nothing is never passed. When omitted, ids are camelCased. */ operationIdTransform?: (id: string) => string; /** * Custom transform for schema (model/enum) names. Receives the cleaned * PascalCase name and, for component schemas, the original name as spelled * in the document. Returning `originalName` opts out of normalization. * See `SchemaExtractionOptions.schemaNameTransform`. */ schemaNameTransform?: SchemaNameTransform; /** * Domain-facing field-name overrides, keyed by IR model name then wire field * name: `{ Connection: { connection_type: 'type' } }`. Sets `Field.domainName` * so emitters expose the field under the friendlier name while keeping the * wire key. Language-agnostic — honored by any emitter that reads `domainName`. */ fieldHints?: Record>; /** * Per-operation overrides keyed by "METHOD /path" — the same map * `resolveOperations` reads. The parser applies only each hint's * `pagination`, which wins over the operation's `x-pagination` extension * and over name-based detection (see `PaginationHint`). */ operationHints?: Record; /** * Fold the models materialized for inline error bodies onto shared models * named by shape (`ErrorBody`, `ErrorBodyWithCode`, the enum `ErrorBodyCode`; * see `collapseErrorBodies`). A body's shape, and so its name, is its * required fields — their names, domain names and types — so an optional * field added to a body or to a nested item moves no model (#506, #516), * and two shapes never ask for one name (#515): `{ message: string | null }` * is `ErrorBodyWithNullableMessage`, `{ code: integer, message }` is * `ErrorBodyWithCodeInteger`, `{ status: 404, message }` is * `ErrorBodyWithStatus404`, `{ error: integer, error_description }` is * `OAuthErrorBodyWithErrorInteger`, `{ message, errors: [{ code, message }] }` * is `ErrorBodyWithCodeMessageErrors`, a `{ message }` hinted * `message → detail` is `ErrorBodyWithMessageAsDetail`, and a body that * requires no field is named from every field under `Optional` * (`OptionalErrorBody` for `{ message? }`); what no name can spell — a * value pinned inside an array, a discriminator mapping, the component or * named enum a field references, a field named like another field's * qualifier (`code_integer` beside `code: integer`), a pinned value that * spells a family prefix (`code: 'optional'` beside `{ message? }`) — * leaves the later shape's models as they are, with a warning; a shape * whose name is its field names alone sorts before one a qualifier * spelled, so adding the qualified shape moves no model. A component of the shared name takes each * body it declares every field, domain name and limit of, and leaves a * body it would narrow as it is. An optional field's hint is carried * whichever bodies give it, and dropped with a warning when two bodies * hint it apart. On by default; `false` keeps one model per operation and * status code (`Error`). */ collapseErrorBodies?: boolean; /** * Pre-IR overlay applied to the bundled OpenAPI document before any IR * extraction runs. Use this when the upstream spec can't be changed but you * need to patch around a spec quirk that would otherwise emit a breaking SDK * change — e.g. rewriting a path's response `$ref` back to its prior schema, * merging the new fields onto the prior schema, and dropping the fork. * * The function may mutate the document in place and return it, or return a * new object; the returned value is what the rest of oagen sees. * * Runs once, after `$ref` bundling and before schema/operation extraction. * If you need to inspect the resulting IR instead, post-process the * `ApiSpec` returned by `parseSpec`. */ transformSpec?: (spec: OpenApiDocument) => OpenApiDocument; } export declare function parseSpec(specPath: string, options?: ParseOptions): Promise; //#endregion //#region src/engine/orchestrator.d.ts export declare function generate(spec: ApiSpec, emitter: Emitter, options: { namespace: string; dryRun?: boolean; outputDir: string; target?: string; apiSurface?: ApiSurface; overlayLookup?: OverlayLookup; operationHints?: Record; mountRules?: Record; operationNaming?: OperationNaming; modelHints?: Record; emitterOptions?: Record; /** When true, skip deletion of files recorded in the previous manifest but not in the current emission. */ noPrune?: boolean; /** * Post-mount service names to generate (a `--services` run). When non-empty, * the FULL spec is still emitted for models/enums/client/barrels (so shared * files stay byte-identical and a brand-new selected service is wired into the * client automatically); only per-service resource/test emission is gated to * the selection (via `ctx.scopedServices`). Pruning is disabled and the * manifest is merged so unselected services' records survive. */ services?: string[]; }): Promise; //#endregion //#region src/engine/generate-files.d.ts export declare function buildEmitterContext(spec: ApiSpec, options: { namespace: string; outputDir: string; apiSurface?: ApiSurface; overlayLookup?: OverlayLookup; operationHints?: Record; mountRules?: Record; operationNaming?: OperationNaming; modelHints?: Record; emitterOptions?: Record; target?: string; priorTargetManifestPaths?: Set; scopedServices?: Set; presentServiceKeys?: Set; }): EmitterContext; /** * Collect model and enum names transitively referenced by service operations. * Walks operation parameters, request bodies, responses, and pagination item * and envelope types, then chases model field references until the set stabilizes. */ export declare function collectReferencedNames(services: Service[], models: Model[], opts?: { preserveAllDiscriminated?: boolean; webhooks?: Webhook[]; }): { models: Set; enums: Set; }; /** * Collect all generated files from an emitter (no headers, no path prefixes). * * A full run emits over the whole spec. A scoped (`--services`) run still emits * model placement, dedup, the root client, and aggregate/barrel files * byte-identically for every service ALREADY on disk (plus the brand-new * selected service, which is wired into the client automatically) — but it * narrows that surface to `selected ∪ already-on-disk` services * (`aggregateSurfaceServices`). A service the spec just added that is neither * selected nor already generated is dropped from the surface entirely, so its * models/discriminators are not pulled into reachability and barrels/the client * never import a resource this run does not emit. The emitters additionally * consult `ctx.scopedServices` to emit only the selected services' per-service * resource/test files. */ export declare function generateAllFiles(spec: ApiSpec, emitter: Emitter, ctx: EmitterContext): GeneratedFile[]; /** Apply file header to generated files, respecting headerPlacement and JSON files. */ export declare function applyFileHeaders(files: GeneratedFile[], header: string): GeneratedFile[]; export declare function generateFiles(spec: ApiSpec, emitter: Emitter, options: { namespace: string; outputDir: string; apiSurface?: ApiSurface; overlayLookup?: OverlayLookup; operationHints?: Record; mountRules?: Record; operationNaming?: OperationNaming; modelHints?: Record; emitterOptions?: Record; target?: string; priorTargetManifestPaths?: Set; /** Scoped-generation signal (POST-MOUNT names); set on ctx for emitters to gate per-service emission. */ scopedServices?: Set; /** Canonical keys of services already on disk (prior manifest); narrows the scoped aggregate surface. */ presentServiceKeys?: Set; }): { files: GeneratedFile[]; ctx: EmitterContext; header: string; operations?: OperationsMap; }; //#endregion //#region src/engine/writer.d.ts interface WriteResult { written: string[]; merged: string[]; skipped: string[]; identical: string[]; ignored: string[]; } //#endregion //#region src/engine/integrate.d.ts /** * Build a file-level dependency graph from generated files and return only * files reachable from root entry points. Uses tree-sitter to parse imports. */ export declare function treeShakeFiles(files: GeneratedFile[], language: string): Promise; export declare function mapFilesForTargetIntegration(files: GeneratedFile[], language: string): GeneratedFile[]; interface IntegrateResult extends WriteResult { /** Final set of paths this run claims ownership of in the target (post tree-shake + conflict resolution). */ emittedPaths: string[]; } export declare function integrateGeneratedFiles(opts: { files: GeneratedFile[]; language: string; targetDir: string; header: string; }): Promise; //#endregion //#region src/engine/registry.d.ts export declare function registerEmitter(emitter: Emitter): void; export declare function getEmitter(language: string): Emitter; //#endregion //#region src/differ/diff.d.ts export declare function diffSpecs(oldSpec: ApiSpec, newSpec: ApiSpec): DiffReport; //#endregion //#region src/differ/direction.d.ts /** * Which side of the wire a model sits on, from the caller's point of view. * * Requiredness only binds callers on the request side — they must construct * every required request field, but they only ever *read* responses. The differ * needs that distinction before it can call a newly-required field breaking. */ type ModelDirection = 'request' | 'response' | 'both' | 'unknown'; type DirectionIndex = ReadonlyMap; /** * Classify every model in `specs` as request-facing, response-facing, both, or * unknown. * * Pass both the baseline and the candidate spec: a model that was request-facing * in either one keeps its request direction for the whole diff, so a schema that * moves request → response mid-release doesn't get that release's requiredness * changes silently downgraded. * * Models reachable from neither side (unreferenced schemas, or a spec whose * operations weren't supplied) stay `unknown`, which preserves the conservative * pre-direction classification. */ export declare function buildDirectionIndex(...specs: ApiSpec[]): DirectionIndex; export declare function directionOf(index: DirectionIndex | undefined, modelName: string): ModelDirection; //#endregion //#region src/utils/naming.d.ts export declare const ACRONYM_SET: Set; export declare function toPascalCase(s: string, acronyms?: Set): string; export declare function toCamelCase(s: string, acronyms?: Set): string; export declare function toSnakeCase(s: string): string; export declare function toKebabCase(s: string): string; export declare function toUpperSnakeCase(s: string): string; export declare function stripBackendPrefixes(name: string): string; export declare function cleanSchemaName(name: string): string; //#endregion //#region src/engine/operation-plan.d.ts interface OperationPlan { operation: Operation; isDelete: boolean; hasBody: boolean; isIdempotentPost: boolean; pathParamsInOptions: boolean; isPaginated: boolean; /** The model the response deserializes to, read under a nullable wrapper * on the response or on an array's items, and through a union's first * model variant (`extractModelName`). Null when there is none. */ responseModelName: string | null; /** For paginated operations, the model name of individual list items * (unwrapped from the list wrapper, and from a nullable wrapper on the * item type: an item that is a `$ref` to a component admitting `null` is * `nullable`, #615, and deserializes to that model when present). * Null for non-paginated. */ paginatedItemModelName: string | null; isModelResponse: boolean; /** True when the response is an unpaginated `type: array` of models — * the items a model, or `nullable` (#615). Emitters should use * this to return `Model[]` (or the language's list equivalent) and map * the deserializer over each element, passing a `null` element through * when `op.response.items` is nullable. */ isArrayResponse: boolean; hasQueryParams: boolean; isAsync: boolean; } export declare function planOperation(op: Operation): OperationPlan; //#endregion //#region src/utils/escape.d.ts /** * Escape a string for safe interpolation inside a JS/TS block comment. * * Free-text spec fields (schema/field/operation descriptions) are * attacker-influenceable data. A `*` followed by `/` inside such text would * terminate the surrounding `/* ... *\/` comment and turn the remainder of the * string into live source in the generated output. Neutralizing every comment * terminator keeps the text inert inside the comment. * * This is specific to languages whose block comments end at `*\/` (JS, TS, * Java, C#, Go, ...). Emitters for languages with other comment syntax (Python * `"""`, Ruby `=begin`/`#`, ...) must apply language-appropriate escaping * instead of, or in addition to, this helper. */ export declare function escapeBlockComment(text: string): string; /** * Sanitize a string for safe interpolation into a JS/TS identifier position * (class name, variable, property, ...). * * Free-text spec fields flow into identifiers too — notably `info.title`, which * becomes the SDK namespace (and thus the client class name) when no explicit * `--namespace` is given. Interpolating that raw value into an identifier lets a * crafted title (e.g. `X {}; run(); class Y`) break out of the declaration and * emit arbitrary top-level source. Replacing every character that is not valid * in an identifier keeps the value inert. * * Already-valid identifiers pass through unchanged (`WorkOS` stays `WorkOS`), so * this does not disturb legitimate output. A leading digit is prefixed with `_` * so the result is always a usable identifier. */ export declare function sanitizeIdentifier(text: string): string; //#endregion //#region src/cli/config-loader.d.ts interface OagenConfig { emitters?: Emitter[]; extractors?: Extractor[]; /** Compatibility verification policy. See docs/core/compatibility-policy.md. */ compat?: CompatConfig; /** Path to the emitter project (where skills scaffold new emitters, tests, smoke runners). */ emitterProject?: string; /** Map from language key to custom smoke runner script path. */ smokeRunners?: Record; /** * Custom transform for operation IDs. When provided, replaces the default * camelCase pass-through. Receives each operationId once, as the spec * spells it with its trailing `[N]` overload markers stripped; return the * desired operation name (no additional conversion is applied). A result * with no ASCII letter or digit once such markers are stripped (`''`, * `' '`, `'-'`, `'[1]'`), or that is not a string, names nothing: the * operation is read as one without an operationId — path-named, its models * named from its path — after one warning (#570). An operationId that * itself names nothing is never passed. */ operationIdTransform?: (id: string) => string; /** * Custom transform for schema (model/enum) names. Applied after the built-in * cleanSchemaName normalization. Receives the cleaned PascalCase name and, * for component schemas, the original name exactly as spelled in the * document (`originalName`); return the desired name. Returning * `originalName` opts that schema out of normalization (e.g. keeps * `HTTPConfig` instead of `HttpConfig`); only do so when it is a valid * identifier, since keys like `user-profile` are otherwise fixed by * cleanSchemaName. `originalName` is undefined for * any name oagen synthesises (inline enums, request-body variant models, * title-derived names). Collisions are detected automatically -- if a * transform would produce a duplicate name, the cleaned name is kept. */ schemaNameTransform?: SchemaNameTransform; /** Base URL for documentation links. When set, relative paths in descriptions * (e.g. `/reference/users/user`) are expanded to full URLs. */ docUrl?: string; /** * Pre-IR overlay applied to the bundled OpenAPI document before any IR * extraction. Use this when the upstream spec can't be changed but a quirk * in it would otherwise emit a breaking SDK change — e.g. rewriting a * path's response `$ref` back to its prior schema, merging the new fields * onto the prior schema, and dropping the fork schema. * * The function may mutate the document in place and return it, or return a * new object. Runs once, after `$ref` bundling and before schema/operation * extraction. See `docs/advanced/transform-spec.md` for examples. */ transformSpec?: (spec: OpenApiDocument) => OpenApiDocument; /** * Per-operation overrides keyed by "METHOD /path" (e.g. "POST /auth/token"). * Used by the operation resolver to override derived method names, mount * targets, and to split union-body operations into typed wrappers. A hint's * `pagination` entry is applied by the parser instead, where it overrides * the operation's `x-pagination` extension and name-based detection. */ operationHints?: Record; /** * Service-level mount rules: maps an IR service name to a target * service/namespace (PascalCase). Keys may be exact names or trailing-`*` * prefix patterns (e.g. `UserManagement*`); an exact key beats any wildcard, * and among wildcards the longest prefix wins. All operations in the source * service are mounted on the target. Per-operation mountOn in operationHints * takes priority. */ mountRules?: Record; /** * Where the operation resolver takes an unhinted method name from. `path` * (the default) derives it from the HTTP method and path; `operationId` * uses the operation's own name when the document declares an * `operationId` (`Operation.name`, so `operationIdTransform` applies) and * the path only for an operation without one. That name is snake_cased * word by word: a lower-case letter before a capital, a digit or a run of * capitals before a capitalized word, and any character that is not a * letter or digit mark a boundary, so `getSSOAuthorizationUrl` becomes * `get_sso_authorization_url`, `createM2MApp` `create_m2m_app` and an id a * transform keeps as written, `pets:adopt`, `pets_adopt`. A `name` in * `operationHints` overrides either. Switching an existing SDK renames * every method whose operationId and path disagree, so run `oagen resolve` * and diff before flipping it. */ operationNaming?: OperationNaming; /** * Pin specific models to a specific IR service for placement, overriding the * default "first service to reference the model wins" assignment. * * Maps IR model name → IR service name (both PascalCase). Useful when a model * is shared across services and the natural ordering would place it in a * service that's wrong for the public API. * * Both names must exist in the parsed spec; unknown names throw at generation * time so typos fail loud. Note that keys are post-cleanSchemaName / * post-schemaNameTransform model names (e.g. `User`, not `UserlandUser`). */ modelHints?: Record; /** * Domain-facing field-name overrides, keyed by IR model name then wire field * name: `{ Connection: { connection_type: 'type' } }`. Sets `Field.domainName` * so every emitter can expose the field under a friendlier domain name while * keeping the wire key unchanged. */ fieldHints?: Record>; /** * Fold inline error bodies onto shared, shape-named models (`ErrorBody`, * `ErrorBodyWithCode`). On by default; `false` keeps `Error` per * operation and status code. See `ParseOptions.collapseErrorBodies`. */ collapseErrorBodies?: boolean; /** * Language-specific emitter options. The CLI passes only the active * language's option bag to that emitter. */ emitterOptions?: Record>; } //#endregion //#region src/snippets/example-builder.d.ts /** * Builds illustrative example values for IR types. Used by snippet emitters * to produce realistic argument values in call-site samples. * * Values prefer, in order: * 1. An explicit `example` carried on the field/param. * 2. The `default` from the schema. * 3. The first enum value, when the type is an enum. * 4. A type-driven value (e.g. `"string_example"`, `1`, `true`), generated * inside the field's/param's `constraints` when it carries any. * * A document-given `example` or `default` is returned verbatim, never * adjusted, even when it violates a limit the same document declares: the * author's value is the better illustration, and a snippet is not a * validator. Only generated values are shaped by `constraints`: * * - Numbers are chosen to satisfy every declared bound and `multipleOf`: * with only a lower bound, the smallest value at or just past it (rounded * up to the next multiple); with only an upper bound, the largest value * at or just below it (rounded down); with both, the smallest integer * inside for `integer` and the midpoint for `number`, snapped to a * multiple inside the range; with none, `1` (or the first multiple). * Only when no value can satisfy the limits together (contradictory * bounds, or no multiple between them) is the lower bound returned as * is. * - Plain strings are padded (by repeating the sample) to `minLength` and * truncated to `maxLength`; format-driven values (`date-time`, `email`, * `uuid`, ...) are never touched. A `pattern` is not synthesized: the * sample is kept even when it does not match, since generating a string * from an arbitrary regex is out of scope. * - Arrays emit `max(1, minItems)` items capped at `maxItems` (an explicit * `maxItems: 0` gives `[]`). Under `uniqueItems`, generated primitives * vary by index (strings get the index appended, numbers get it added, * booleans alternate — so a unique boolean array holds at most two * items); enum, literal and model items are not varied. * - Maps emit `max(1, minProperties)` entries capped at `maxProperties`: * one entry keeps the `key` name, more are `key1`, `key2`, ... * - Model-level `minProperties` / `maxProperties` are ignored: every * non-deprecated, non-readOnly field is emitted anyway. * * Snippets are illustrative, so generation has a size budget: at most * {@link MAX_GENERATED_LENGTH} characters per string and * {@link MAX_GENERATED_ITEMS} items per array or entries per map. A * `minLength`, `minItems` or `minProperties` above the budget yields the * capped size — a readable sample rather than a conforming one. * * Limits nested inside array items or map values are not carried by the * IR, so items and values are generated unconstrained. * * Recursion through models/arrays/maps is depth-limited; cyclic models * collapse to a placeholder object rather than blowing the stack. */ interface ExampleBuilder { /** * Build an example value for a single type reference (no field metadata), * generated inside `constraints` when given. */ forType(type: TypeRef, constraints?: Constraints): unknown; /** Build an example value for a field, honoring its `example`/`default` and `constraints`. */ forField(field: Field): unknown; /** Build an example value for a parameter, honoring its `example`/`default` and `constraints`. */ forParameter(param: Parameter): unknown; /** Build an example object from a model, keyed by field wire name. */ forModel(model: Model | string): Record; } export declare function createExampleBuilder(spec: ApiSpec): ExampleBuilder; //#endregion //#region src/snippets/types.d.ts /** * A call-site code sample for one SDK operation. * * Snippet emitters produce these instead of full SDK source files. Consumers * (REST API docs builds, partner integrations, etc.) decide where to write * them based on their own layout conventions — see * {@link snippetResultsToFiles} for a default file-per-snippet layout. */ interface SnippetResult { /** Language key (e.g. 'ruby', 'node'). Matches the underlying SDK emitter. */ language: string; /** File extension without the leading dot (e.g. 'rb', 'js', 'cs'). */ fileExtension: string; /** Stable identifier for the operation: `${mountTarget}.${methodName}`. */ operationId: string; /** PascalCase mount target the method lives on (e.g. 'Organizations'). */ mountTarget: string; /** snake_case method name as resolved by oagen (e.g. 'create_organization'). */ methodName: string; /** The rendered snippet, ending in a trailing newline. */ content: string; } /** * A snippet emitter renders one call-site example per resolved SDK operation * in a specific language. Unlike the full {@link Emitter} contract, snippet * emitters don't generate models, enums, or clients — only short, runnable * call samples. * * Implementations typically reuse the corresponding full emitter's naming * helpers (e.g. `src//naming.ts`) so generated snippets stay in * lockstep with the SDK they document. Framework primitives like * {@link collectSnippetArgs} live in `@workos/oagen` so emitter authors * don't have to reimplement the required-only / hidden-param / split-wrapper * logic per language. */ interface SnippetEmitter { /** Language key (must match the full emitter's `language`). */ language: string; /** File extension without the leading dot. */ fileExtension: string; /** * Render a single resolved operation as a complete, runnable snippet. * * Return `null` to skip — e.g. for URL-builder operations that don't make * an HTTP call, or other shapes the language SDK doesn't expose. */ renderOperation(resolved: ResolvedOperation, ctx: EmitterContext, examples: ExampleBuilder): string | null; } //#endregion //#region src/snippets/runner.d.ts /** * Run one or more snippet emitters over every resolved operation in the spec. * * Iteration order matches `ctx.resolvedOperations`. For each operation the * runner asks every emitter to render once; emitters that return `null` * contribute nothing for that op (the URL-builder / unsupported case). * * Returns a flat list of {@link SnippetResult}. Consumers map these to * file paths according to their own layout — see * {@link snippetResultsToFiles} for a convenience that writes * `//-request.`. */ export declare function runSnippetEmitters(emitters: SnippetEmitter[], ctx: EmitterContext): SnippetResult[]; /** * Convenience: turn snippet results into oagen-style {@link GeneratedFile}s * under `//-request.`. * * Useful for consumers wired into the standard oagen file-writing pipeline. * Docs builds that already have their own per-tag file layout (e.g. * `content/reference/{tag}/_code/...`) typically skip this helper and route * `SnippetResult.operationId` / `mountTarget` through their own mapping. */ export declare function snippetResultsToFiles(results: SnippetResult[], outputDir?: string): GeneratedFile[]; //#endregion //#region src/snippets/shared.d.ts /** * One argument resolved for a call-site snippet. The {@link wireName} stays * in the spec's casing so each language emitter can apply its own * field/param casing rules (snake_case for Python/Ruby/PHP, PascalCase for * Go/.NET, etc.). * * Path and query params carry their {@link Parameter} so emitters can pick * language-specific safe names; body args carry their {@link Field} so * emitters can read field-level metadata (deprecated, type details). */ interface SnippetArg { /** 'path' | 'body' | 'query' — used by emitters to pick a casing rule. */ source: 'path' | 'body' | 'query'; /** Spec wire name (e.g. `domain_data`, `client_id`). */ wireName: string; /** Pre-computed illustrative value (string, number, array, object, ...). */ value: unknown; /** Original parameter for path/query args, null for body fields. */ parameter: Parameter | null; /** Original field for body args, null for path/query params. */ field: Field | null; } /** * Resolve the set of required arguments for a snippet. Body fields are * expanded from the request body model; defaults / inferFromClient fields * are filtered out (they're injected by the SDK, not the caller). * * Iteration order: path params, then required body fields, then required * query params. Wire-name collisions between body and path are reported in * {@link collisionNames} so the emitter can rename whichever side it * prefers (e.g. prefix body field with `body_`). */ interface CollectedArgs { args: SnippetArg[]; /** Body field wire names that also appear as path params. */ collisionNames: Set; } export declare function collectSnippetArgs(resolved: ResolvedOperation, ctx: EmitterContext, examples: ExampleBuilder): CollectedArgs; /** * Build the arg list for a single split (wrapper) variant. The wrapper's * `exposedParams` is the contract; fields are looked up on the variant model * by exact name and then snake-case-normalized name. Optional status comes * from `wrapper.optionalParams` first, then from the field's `required` flag. */ export declare function collectWrapperArgs(wrapper: ResolvedWrapper, ctx: EmitterContext, examples: ExampleBuilder): SnippetArg[]; export declare function hiddenParamSet(resolved: ResolvedOperation): Set; //#endregion export { type AiAgentEnvVar, type ApiSpec, type ArrayType, type AuthScheme, type BackoffStrategy, type BaseUrlChanged, type BehaviorChange, type Callback, type CallbackAdded, type CallbackModified, type CallbackParent, type CallbackRemoved, type CallbackSite, type Change, type CollectedArgs, type Constraints, type DeepPartial, type DefaultResponse, type DeprecatedChanged, type DeprecatedNode, type DiffReport, type DirectionIndex, type DocumentSecurityChanged, type Emitter, type EmitterContext, type Enum, type EnumAdded, type EnumModified, type EnumRef, type EnumRemoved, type EnumValue, type EnumValueChange, type ErrorPolicy, type ErrorResponse, type ExampleBuilder, type Extensions, type ExtensionsChanged, type ExtensionsNode, type ExternalDocs, type Field, type FieldChange, type FormatCommand, type GeneratedFile, type HttpMethod, type IdempotencyPolicy, type LiteralType, type LogEvent, type LoggingPolicy, type MapType, type Model, type ModelAdded, type ModelDirection, type ModelModified, type ModelRef, type ModelRemoved, type NullableType, type OagenConfig, type OpenApiDocument, type Operation, type OperationAdded, type OperationHint, type OperationModified, type OperationNaming, type OperationPlan, type OperationRemoved, type OperationResolution, type OperationsMap, type OperationsMapEntry, type PaginationEndOfIteration, type PaginationHint, type PaginationMeta, type PaginationPolicy, type PaginationStrategy, type ParamChange, type ParamDefaultChanged, type ParamLocation, type Parameter, type ParameterGroup, type ParameterGroupVariant, type ParameterLocation, type ParseOptions, type PrimitiveType, type RangeResponse, type ReceivedRequestModified, type RequestBodyContent, type RequestBodyContentTypesChange, type RequestBodyType, type RequestGuardPolicy, type ResolvedMethodCollision, type ResolvedOperation, type ResolvedServerUrl, type ResolvedWrapper, type ResponseBodyType, type ResponseContent, type ResponseContentTypesChange, type ResponseHeader, type ResponseHeaderChange, type RetryPolicy, type SchemaNameTransform, type SdkBehavior, type SecurityChanged, type SecurityNode, type SecurityRequirement, type SecurityRequirementSet, type SecuritySchemeAdded, type SecuritySchemeChange, type SecuritySchemeChanged, type SecuritySchemeModified, type SecuritySchemeRemoved, type ServerAdded, type ServerChange, type ServerEntry, type ServerModified, type ServerRemoved, type ServerVariable, type ServerVariableChange, type Service, type ServiceAdded, type ServiceRemoved, type SnippetArg, type SnippetEmitter, type SnippetResult, type SplitHint, type StatusRange, type SuccessResponse, type TelemetryPolicy, type TimeoutPolicy, type TypeParam, type TypeRef, type UnionType, type UserAgentPolicy, type VariantChange, type Webhook, type WebhookAdded, type WebhookModified, type WebhookRemoved, type WebhookResponse, assertNever, assignModelsToServices, callbackContext, collectAlternateRequestBodyContents, collectEnumRefs, collectFallbackResponseTypes, collectFieldDependencies, collectModelRefs, collectModelTypeRefs, collectOperationTypeRefs, collectRequestBodyModels, collectRequestBodyTypes, collectResponseBodyTypes, collectResponseHeaders, collectWebhookTypeRefs, defaultSdkBehavior, deriveMethodName, findResolvedMethodCollisions, mapTypeRef, mergeSdkBehavior, renameModelRefs, resolveMountTarget, resolveOperations, typeRefConstraints, validateModelHints, walkTypeRef }; //# sourceMappingURL=index.d.mts.map