import "../../_dnt.polyfills.js"; import type { SchemaPath } from '../../types/SchemaPath.js'; import type { Method } from '../../types/Method.js'; import type { OasPathItem } from '../pathItem/PathItem.js'; import type { OasParameter } from '../parameter/Parameter.js'; import type { OasRequestBody } from '../requestBody/RequestBody.js'; import type { OasResponse } from '../response/Response.js'; import type { OasParameterLocation } from '../parameter/parameter-types.js'; import type { OasSchema } from '../schema/Schema.js'; import type { OasRef } from '../ref/Ref.js'; import { OasObject } from '../object/Object.js'; import type { ToJsonSchemaOptions } from '../schema/Schema.js'; import type { OpenAPIV3 } from 'openapi-types'; import type { OasSecurityRequirement } from '../securityRequirement/SecurityRequirement.js'; import type { OasExternalDocs } from '../externalDocs/ExternalDocs.js'; import type { OasServer } from '../server/Server.js'; import { OasBase } from '../../types/OasBase.js'; import type { ParseContextType } from '../../context/parseTypes.js'; /** * Fields for configuring an OpenAPI operation object. * * Contains all the properties needed to define a complete OpenAPI operation, * including path information, parameters, request/response specifications, * security requirements, and metadata. */ export type OperationFields = { /** The API path for this operation */ path: string; /** The HTTP method for this operation */ method: Method; /** The parent path item containing this operation */ pathItem: OasPathItem | undefined; /** Unique identifier for the operation */ operationId?: string | undefined; /** Brief summary of the operation */ summary?: string | undefined; /** Tags for organizing operations in documentation */ tags?: string[] | undefined; /** Detailed description of the operation */ description?: string | undefined; /** Parameters accepted by this operation */ parameters?: (OasParameter | OasRef<'parameter'>)[] | undefined; /** Request body specification for this operation */ requestBody?: OasRequestBody | OasRef<'requestBody'> | undefined; /** Response specifications mapped by status code */ responses: Record>; /** Security requirements for this operation */ security?: OasSecurityRequirement[] | undefined; /** Whether this operation is deprecated */ deprecated?: boolean | undefined; /** External documentation for this operation */ externalDocs?: OasExternalDocs | undefined; /** OpenAPI specification extensions */ extensionFields?: Record; servers?: OasServer[] | undefined; }; /** * Arguments passed to request body mapping functions. */ export type ToRequestBodyMapArgs = { schema: OasSchema | OasRef<'schema'>; requestBody: OasRequestBody; /** The `content` key the schema was read from. */ mediaType: string; /** * The media type to send the body as: the explicit media type when one was * passed, else `contentType` of `OasRequestBody.toJsonContent` (the * JSON-like key, or `application/json` for a body read from `*\/*`). */ contentType: string; }; export declare class OasOperation extends OasBase { /** Type identifier for OAS operation objects */ oasType: 'operation'; /** The API path for this operation */ path: string; /** The HTTP method for this operation */ method: Method; /** The parent path item containing this operation */ pathItem: OasPathItem | undefined; /** Unique identifier for the operation */ operationId: string | undefined; /** Brief summary of the operation */ summary: string | undefined; /** Tags for organizing operations in documentation */ tags: string[] | undefined; /** Detailed description of the operation */ description: string | undefined; /** Parameters accepted by this operation */ parameters: (OasParameter | OasRef<'parameter'>)[] | undefined; /** Request body specification for this operation */ requestBody: OasRequestBody | OasRef<'requestBody'> | undefined; /** Response specifications mapped by status code */ responses: Record>; /** Security requirements for this operation */ security: OasSecurityRequirement[] | undefined; /** Whether this operation is deprecated */ deprecated: boolean | undefined; /** External documentation for this operation */ externalDocs: OasExternalDocs | undefined; /** OpenAPI specification extensions */ extensionFields: Record | undefined; /** Servers for this operation */ servers: OasServer[] | undefined; /** * Creates a new OasOperation instance from operation field data. * * @param fields - Operation field data from OpenAPI specification */ constructor(fields: OperationFields, context?: ParseContextType); /** * Returns the successful response definition for this operation. * * Looks for the lowest numbered 2xx response code and returns its response definition. * * @returns Success response object or undefined if none found */ toSuccessResponse(): OasResponse | OasRef<'response'> | undefined; /** * Returns the HTTP status code for the primary success response. * * Finds the lowest numbered 2xx status code in the responses. * * @returns Success status code as string or undefined if none found */ toSuccessResponseCode(): string | undefined; /** * Maps the request body schema to a custom value using the provided mapping function. * * @param map - Function to transform the request body schema and metadata * @param mediaType - Media type to extract schema from, an exact lookup. Omitted: the media type `OasRequestBody.toJsonContent` picks. * @returns Mapped value or undefined if no request body schema found */ toRequestBody(map: ({ schema, requestBody }: ToRequestBodyMapArgs) => V, mediaType?: string): V | undefined; /** * Navigate into this operation's response or request body schema along an * {@link SchemaPath}. The first segment selects the entry point — * `'SuccessResponse'` (the 2xx response body schema) or `'RequestBody'` (the * request body schema) — and the rest descend through object properties, * array `items`, and union members, resolving `$ref`s on the way. See * {@link traverseSchema}. * * @param path - Schema path; `path[0]` must be `'SuccessResponse'` or `'RequestBody'`. * @param mediaType - Media type the body schema is read from, an exact lookup. Omitted: the JSON media type (`application/json`, else the first JSON-like type, else `*\/*`). * @returns The schema at the path (may be an unresolved `$ref`). * @throws Error on an unknown root, a missing response/request body, or a non-navigable segment. */ traverse(path: SchemaPath, mediaType?: string): OasSchema | OasRef<'schema'>; /** * The parameters that apply to this operation, as OpenAPI defines them: the * path item's parameters apply to each of its operations, and an operation's * own parameter with the same name and location replaces the path item's. * The path item's come first. * * References stay references, so a caller can resolve each one on its own. * A reference that names nothing (kept when `system.danglingRefs` lists * `parameter`) keeps its place, and resolving it throws `DanglingRefError`. * {@link OasOperation.toParams} resolves them all. * * @returns the parameters, path item's first */ toEffectiveParameters(): (OasParameter | OasRef<'parameter'>)[]; /** * Resolve all parameters and optionally filter by location: the resolved * {@link OasOperation.toEffectiveParameters}. * * @param filter - only include parameters from specified locations * @returns * @throws {DanglingRefError} when a parameter is a reference that names nothing */ toParams(filter?: OasParameterLocation[]): OasParameter[]; /** * Creates an OAS object representation of operation parameters. * * @param filter - Optional array of parameter locations to include * @returns OAS object with parameter properties */ toParametersObject(filter?: OasParameterLocation[]): OasObject; /** * Converts the operation to OpenAPI v3 JSON schema format. * * @param options - Conversion options for nested components * @returns OpenAPI v3 operation object * @throws {DanglingRefError} when a parameter is a reference that names * nothing, as {@link OasOperation.toParams} does: there is no parameter to * write, and the caller decides what to do */ toJsonSchema(options: ToJsonSchemaOptions): OpenAPIV3.OperationObject; /** * Serializes the operation to a plain JavaScript object. * * @returns Plain object representation of the operation */ toJSON(): object; }