Skip to content

api‐zimic‐typegen

Diego Aquino edited this page Aug 19, 2024 · 1 revision

API reference: zimic/typegen

Contents


This module exports resources to generate types programmatically. We recommend using the zimic typegen CLI, but this is still a valid alternative for more advanced use cases.

typegen.generateFromOpenAPI(options)

An example using the programmatic API to generate types from an OpenAPI schema:

import { typegen } from 'zimic/typegen';

await typegen.generateFromOpenAPI({
  input: './schema.yaml',
  output: './schema.ts',
  serviceName: 'MyService',
  filters: ['* /users**'],
  includeComments: true,
  prune: true,
});

The options of typegen.generateFromOpenAPI(options) are the same as the CLI options for the zimic typegen openapi command.

CLI usage

See the zimic typegen CLI reference.