Skip to main content
@vertz/openapi generates a fully typed TypeScript SDK from any OpenAPI 3.x spec. It produces typed resource methods, TypeScript interfaces, and optional Zod schemas — powered by @vertz/fetch under the hood.
This page covers generating SDKs from external OpenAPI specs (third-party APIs, FastAPI backends, etc.). For the SDK generated from your own Vertz entity definitions, see SDK & Fetch Client.

Install

Quick start

This generates:

Configuration

Create an openapi.config.ts in your project root:
CLI flags override config file values.

CLI options

FlagDescriptionDefault
--from <path-or-url>Path to OpenAPI spec file or URLRequired (or use config)
--output <dir>Output directory./src/generated
--base-url <url>Default base URL for API calls''
--group-by <mode>Grouping: tag, path, nonetag
--schemasGenerate Zod validation schemasfalse
--exclude-tags <t>Comma-separated tags to excludenone
--dry-runPreview without writing filesfalse

Using the generated SDK

Install @vertz/fetch in the project that consumes the SDK:
Every method returns Result<T, FetchError> — never throws for HTTP errors.

Operation ID normalization

Many backend frameworks generate verbose operationIds that include the full URL path. The generator provides three levels of control to produce clean, idiomatic method names.

Auto-cleaning (default)

Without any configuration, the generator automatically:
  • Strips controller prefixes (e.g., TasksController_findAllfindAll)
  • Removes trailing HTTP method words (listTasksGetlistTasks)
  • Detects CRUD patterns from the HTTP method and path shape

Framework adapters

Built-in adapters handle operationId quirks for common backend frameworks. Import from @vertz/openapi/adapters.

FastAPI

FastAPI generates operationIds by concatenating the function name, route path, and HTTP verb:
The fastapi() adapter strips the route+verb suffix, leaving just the meaningful function name:
FastAPI operationIdPathResult
list_tasks_tasks_get/taskslist_tasks
get_user_v1_users__id__get/v1/users/{id}get_user_v1
create_task_v2_tasks_post/v2/taskscreate_task_v2
delete_task_tasks__id__delete/tasks/{id}delete_task
get_bot_activities_web_...bot_activities_get/web/organizations/{id}/...get_bot_activities
The adapter also handles API version prefixes — if your path starts with /v1/, /v2/, etc., the version is preserved in the method name.

NestJS

NestJS (@nestjs/swagger) generates operationIds like TasksController_findAll. The adapter strips the Controller prefix:
NestJS operationIdResult
TasksController_findAllfindAll
UsersController.getByIdgetById

Custom transform

For full control, provide a transform function that receives the auto-cleaned name and a full OperationContext:

Static overrides

For one-off renames, use overrides — a map from raw operationId to desired method name:
Overrides take the highest priority — they’re applied before any transform or auto-cleaning.

Writing a custom adapter

An adapter is a function that returns { transform }. You can write one for any backend framework:

Excluding tags

Skip internal or deprecated tags:
Operations where any tag matches the exclude list are skipped entirely.

Programmatic API

Supported specs

  • OpenAPI 3.0.x and 3.1.x
  • JSON and YAML formats
  • File paths and URLs