---
title: "openapi-import"
description: "Import an OpenAPI spec in TypeScript like any other file, with types, autocomplete, and errors from the spec and no generated files."
canonical_url: "https://stijnvanhulle.be/projects/openapi-import"
---

> Index of every page on this site: [llms.txt](https://stijnvanhulle.be/llms.txt)

`openapi-import` is a [TypeScript 7.1 content mapper](https://github.com/microsoft/typescript-go). Register it in `tsconfig.json`, then import a spec:

```ts
import type { Pet } from './petStore.openapi.yaml'
```

## Features

- Types straight from the spec, with no generated files.
- Works without a config: you get the types from [Kubb](https://stijnvanhulle.be/projects/kubb)'s `pluginTs`.
- Add a `kubb.config.ts` to get Zod schemas, clients and other plugin output from the same import.
- Autocomplete and type errors come from the spec.
- Go to definition, find references and hover jump between the types and the YAML.
- Rename a schema type and the key in the spec is renamed too.
- `tsc --runExternalCode` reports the same errors in CI.
- At run time, `unplugin-kubb` loads the same module in Vite, webpack, Rollup and other bundlers.

## Sitemap

See the full [sitemap](https://stijnvanhulle.be/sitemap.md) for all pages.
