v2.11.0
Minor Changes
-
6c383c9: Admin API is now disabled by default. Use the
--admin-apiflag to opt in. -
a58241f: generator: emit
types/versions.tswithVersions,VersionsGTE, andVersionedtypesWhen at least one
SpecConfigentry has a non-emptyversionfield, the code generator now writestypes/versions.tsto thebasePathroot. The file exports:Versions— a union of all distinct version strings in config-declaration orderVersionsGTE— a map from each version to the set of versions that are >= itVersioned<T, V>— a utility type that narrows the$argument of a route handler to a specific API version
Versionedis also exported fromcounterfact-types/index.tsin its generic form (with explicitTVersionsandTVersionsGTEtype parameters) for use outside of the generated file.No file is written when no spec defines a
version. -
4bb9493: Add runtime implementation of
$.minVersion()for versioned route handlers.When multiple versioned specs share the same API group, each request's
$
argument now includes:version— a string identifying which version is handling the request
(e.g."v1","v2").minVersion(min)— a method that returnstruewhen the current version
is greater than or equal tominin the declared version order, and
falseotherwise.
The version order is determined by the position of each spec in the
specs
array passed tocounterfact()(first entry = oldest version).For unversioned runners (
versionis not set), neitherversionnor
minVersionis present on$. -
af44d5b:
OperationTypeCodernow emits version-mapped handler types for multi-version APIs.When two or more versioned specs share the same operation path, the shared
types/paths/<path>.types.tsfile exports a mergedHTTP_<METHOD>type
whose$argument isVersioned<{ v1: …; v2: … }>(a union of each
version's strongly-typed argument object). Each version's$-argument type
is emitted totypes/<version>/paths/<path>.types.tsand imported by the
shared file.Single-spec (unversioned) output is unchanged for full backwards compatibility.
A new
Versioned<T>utility type is exported fromcounterfact-types/index.js. -
142bcdd: When a
SpecConfigentry declares bothgroupandversion, the server now automatically mounts that spec's routes under/<group>/<version>without requiring an explicitprefix.The derivation rules are:
prefixprovided?groupset?versionset?Derived prefix Yes any any use the explicit prefix No Yes Yes /<group>/<version>No Yes No /<group>No No No ""(root)Two specs with the same
groupbut differentversionvalues can coexist on a single server instance — validation now checks uniqueness on the(group, version)pair instead ofgroupalone.Migration note:
SpecConfig.prefixis now an optional field (prefix?: string). Specs that omitprefixwill have it derived automatically; pass an explicitprefix: ""to force the root prefix.
Patch Changes
-
825b65d: Cast parameters at runtime: parameters defined with OAS3-style schema types (e.g.
schema: { type: "integer" }) are now correctly cast to their declared JavaScript types in route handlers. For example, whenGET /pet/1is called,$.path.petIdwill be a number rather than a string when the OpenAPI spec declares it asinteger. -
161deca: Fix documentation inconsistencies: complete CLI reference table, correct programmatic API example in FAQ, fix invalid JS syntax and broken link in without-openapi guide, and fix formatting in programmatic-api guide.
-
6d19132: Fix TypeScript error caused by combining a mapped type and explicit properties in the same generated response object type.
When an OpenAPI spec defines a
defaultresponse alongside explicit status codes (e.g.200,400), the generatedResponseBuilderFactorytype argument now uses an intersection ({ 200: ..., 400: ... } & { [statusCode in Exclude<HttpStatusCode, 200 | 400>]: ... }) instead of mixing both in a single object literal, which TypeScript does not allow. -
ee38734: Fix: parameters defined at the path item level in an OpenAPI spec are now included in generated TypeScript types.
Previously, parameters declared under a path item (e.g.
/stuff/{stuffId}: parameters: [...]) were ignored during type generation, causing the route handler'spath(and other) argument types to benever. Now those path-item-level parameters are merged with any operation-level parameters (operation-level takes precedence when both declare the same name and location), producing the correct strongly-typed handler signatures. -
3e0fbc1: Telemetry is now always enabled (removed the pre-May-2026 date gate)
-
bce607e: Update usage link in REPL and CLI banner to point to the new GitHub docs URL.
-
dd4abb8: Generated
$-arg types now include aversionproperty. For versioned specs the property is a string literal (e.g.version: "v3"); for unversioned specs it isnever(omitted at runtime byOmitValueWhenNever).