Skip to content

covenix / generateContract

Function: generateContract() ​

generateContract(controllers, info?, options?): object

Defined in: src/contract.ts:364

Standalone, instance-free contract generation: pass the controller classes directly (or { controller, prefix } to mirror grouped registration). The contract is derived entirely from class-level metadata — no instances, no dependency wiring — making this the path for build-time client codegen.

Parameters ​

controllers ​

StaticController[]

The controller classes (constructors, not instances).

info? ​

InfoObject = ...

Contract info block. Defaults to { title: 'API', version: '1.0.0' }.

options? ​

ContractOptions = {}

Extra inputs, e.g. route-less schemas.

Returns ​

object

The validated CovenixContract.

covenixContract ​

covenixContract: "0.1"

info ​

info: object

Index Signature ​

[key: string]: unknown

info.title ​

title: string

info.version ​

version: string

operations ​

operations: object[]

schemas ​

schemas: Record<string, SchemaNode>

Example ​

ts
const contract = generateContract([UsersController, HealthController]);
await writeFile('contract.json', JSON.stringify(contract, null, 2));