import { http, type HttpHandler, type RequestHandlerOptions } from "msw"; import type { AnyApiSpec, HttpMethod, PathsForMethod } from "./api-spec.ts"; import { type ResponseResolver } from "./response-resolver.ts"; /** HTTP handler factory with type inference for provided api paths. */ export type OpenApiHttpRequestHandler = >(path: Path, resolver: ResponseResolver, options?: RequestHandlerOptions) => HttpHandler; /** Collection of enhanced HTTP handler factories for each available HTTP Method. */ export type OpenApiHttpHandlers = { [Method in HttpMethod]: OpenApiHttpRequestHandler; } & { untyped: typeof http; }; export interface HttpOptions { /** Optional baseUrl that is prepended to the `path` of each HTTP handler. */ baseUrl?: string; } /** * Creates a wrapper around MSW's {@linkcode http} object, which is enhanced with * type inference from the provided OpenAPI-TS `paths` definition. * * **Usage** * ```typescript * import { HttpResponse } from "msw"; * import { createOpenApiHttp } from "openapi-msw"; * // 1. Import the paths from your OpenAPI schema definitions * import type { paths } from "./your-openapi-schema"; * * // 2. Provide your paths definition to enable type inference in HTTP handlers * const http = createOpenApiHttp(); * * // TS only suggests available GET paths * const handler = http.get("/resource/{id}", ({ params }) => { * const id = params.id; * return HttpResponse.json({ id, other: "..." }); * }); * ``` * * @param options Additional options that are used by all defined HTTP handlers. */ export declare function createOpenApiHttp(options?: HttpOptions): OpenApiHttpHandlers; //# sourceMappingURL=openapi-http.d.ts.map