/** * @polygonlabs/zod-codecs/openapi — drop-in replacement for * `extendZodWithOpenApi` from `@asteasolutions/zod-to-openapi` that also * patches `ZodCodec.prototype` so chained `.openapi(...)` works on * codecs. * * Why this is needed: in zod v4, `ZodCodec` is a sibling class of * `ZodType` — not a subclass. `extendZodWithOpenApi` patches only * `ZodType.prototype.openapi`, so the patch never lands on codecs. * Calling `.openapi(...)` on a codec throws `TypeError: not a function` * at runtime; the upstream README example * (`Int64Codec.openapi({ ... })`) silently doesn't work in v4 + v8. * * `@asteasolutions/zod-to-openapi` is an optional peer dependency: this * subpath is the only thing in the package that imports it. Codec * consumers that don't generate OpenAPI never need it installed. */ import type { z } from 'zod'; /** * Like `extendZodWithOpenApi` from `@asteasolutions/zod-to-openapi` — * call once at module load to enable `.openapi(...)` chaining on every * zod schema — and additionally extends the patch to `ZodCodec` so * `BigIntegerCodec.openapi({ ... })`, `IsoDateCodec.openapi({ ... })`, * etc. work the same way. * * import { z } from 'zod'; * import { extendZodAndCodecsWithOpenApi } from '@polygonlabs/zod-codecs/openapi'; * import { BigIntegerCodec } from '@polygonlabs/zod-codecs'; * * extendZodAndCodecsWithOpenApi(z); * * const Wei = BigIntegerCodec.openapi({ * description: 'Amount in wei — decoded to bigint by the client.', * example: '1000000000000000000' * }); * * The function body is `ZodType.prototype.openapi` itself — copied, not * delegated — so codecs get full-fidelity `.openapi(...)` semantics: * fresh-instance creation per call, `refId` and `param` handling, * metadata merge with prior `.openapi(...)` calls. The OpenAPI document * generated by `OpenApiGeneratorV3` reads the same registry the * asteasolutions patch writes to, so codec fields and regular fields are * indistinguishable in the output. * * Idempotent — safe to call multiple times. The second call no-ops via * a `hasOwnProperty` guard, so importing this from multiple modules * doesn't double-patch. */ export declare function extendZodAndCodecsWithOpenApi(zod: typeof z): void; //# sourceMappingURL=openapi.d.ts.map