CLIKontractGenerators
← Generators

Models · OpenAPI

Types and schemas, no transport.

Use when another package owns the client or server. Point it at the same source as a client target to keep both model sets identical.

What it emits

TypeScript interfacesEnumsZod schemas when enabled

Options

This generator adds no options of its own.

Shared options

Every OpenAPI generator accepts these, so a schema choice made once stays consistent between a server and its clients.

OptionDescriptionValuesDefault
audiencesApply operation `x-kontract-audiences` policy. `exclude` is validated once against the complete selected OpenAPI source/target universe, not per generated service: siblings with no matching audience generate normally, while a token absent from the whole source fails validation and `generate --clean` preflight before deletion. NestJS may instead set `marker: true` to retain and annotate output.object (exclude: string[]; marker: true for typescript-nestjs)unset (operations belong to every audience)
zodEmit framework-neutral Zod schemas alongside the inferred request and response types.true | falsefalse
schemaModeHow faithfully the source schema is reproduced. `normalize` reshapes inline schemas into named components; `strict` keeps the document as authored.normalize | strictstrict for typescript-nestjs, normalize for SDK targets
useSingleRequestParameterCollapse an operation's parameters into one request object instead of a positional argument list.true | falsefalse
stringEnumsEmit enums as string union types rather than TypeScript `enum` declarations.true | falsefalse
enumUnknownDefaultCaseAdd a fallback member so an unrecognised wire value does not throw at the boundary.true | falsefalse
modelPropertyNamingCasing applied to model properties.camelCase | PascalCase | snake_case | originaloriginal
paramNamingCasing applied to operation parameters.camelCase | PascalCase | snake_case | originaloriginal
enumPropertyNamingCasing applied to enum members.PascalCase | camelCase | snake_case | UPPERCASE | originaloriginal
sortModelPropertiesByRequiredFlagOrder model properties with required ones first.true | falsefalse
sortParamsByRequiredFlagOrder operation parameters with required ones first.true | falsefalse

Example

type: typescript-modelsgenerates

One interface per schema component, with enum members resolved to their own named types.

sumr.yamlyaml
targets:
  - name: web-models
    output: ./apps/web/src/lib/models
    generator:
      type: typescript-models
      stringEnums: true
models/organization.tsts
export interface Organization {
  id: string;
  status: OrganizationStatus;
  name: string;
}

On this page