Skip to content
Host your specs. Generate from anywhere.

Output

Every generated file in your output folder is created by a plugin. This page describes the default output, but similar logic applies to all plugins.

If you use the default configuration, your project might look like this.

  • Directorymy-app/
    • Directorynode_modules/
    • Directorysrc/
      • Directoryclient/
        • Directoryclient/
        • Directorycore/
        • client.gen.ts
        • index.ts
        • sdk.gen.ts
        • types.gen.ts
      • index.ts
    • package.json

Your actual output depends on your Hey API configuration. It may contain a different number of files and their contents might differ.

Let’s go through each file in the src/client folder and explain what it looks like, what it does, and how to use it.

client.gen.ts is generated by client plugins. If you choose to generate SDKs (enabled by default), we use the Fetch client unless specified otherwise.

client.gen.ts
import { createClient, createConfig } from './client';
export const client = createClient(createConfig());

The contents of this file are consumed by SDKs, but you can also import client in your application to perform additional configuration or send manual requests.

Client plugins provide their bundles inside client and core folders. The contents of these folders don’t depend on the provided input. Everything inside these folders serves as a scaffolding so the generated code can make HTTP requests.

You can learn more on the TypeScript page.

You can learn more on the SDK page.

index.ts is not generated by any specific plugin. It’s meant for convenience and by default, it re-exports every artifact generated by default plugins (TypeScript and SDK).

index.ts
export * from './sdk.gen';
export * from './types.gen';

We recommend importing artifacts from their respective files to avoid ambiguity, but we leave this choice up to you.

index.ts
import type { Pet } from './client';
// or
import type { Pet } from './client/types.gen';

If you’re not importing artifacts from the entry file, you can skip generating it altogether by setting the output.entryFile option to false.

openapi-ts.config.ts
export default {
input: 'hey-api/backend', // sign up at app.heyapi.dev
output: {
entryFile: false,
path: 'src/client',
},
};

You can choose which artifacts should be re-exported from the entry file using the includeInEntry option on any plugin. For example, we can re-export all Zod plugin artifacts by setting includeInEntry to true:

index.ts
export {
zAddPetData,
zAddPetResponse,
zApiResponse,
zCategory,
// ...more exports
} from './zod.gen';

Or we can re-export only specific artifacts by providing a predicate function:

index.ts
export { zTag } from './zod.gen';

Examples

You can view live examples on StackBlitz or on GitHub.