---
title: "NestJS v11 Plugin"
description: "Generate NestJS v11 controller methods from OpenAPI with the NestJS plugin for openapi-ts. Fully compatible with validators, transformers, and all core features."
url: "https://heyapi.dev/docs/openapi/typescript/plugins/nest"
---

Beta [Leave feedback](https://github.com/hey-api/openapi-ts/issues) · [Contribute](https://heyapi.dev/openapi-ts/community/contributing)

### About

[Section titled “About”](#about)

[Nest](https://nestjs.com) is a progressive Node.js framework for building efficient, reliable and scalable server-side applications.

The NestJS plugin for Hey API generates type-safe controller method signatures from your OpenAPI spec, fully compatible with all core features.

### Collaborators

[Section titled “Collaborators”](#collaborators)

* [![Yuri Mikhin](https://heyapi.dev/_astro/mikhin_1LTQGN.webp) Yuri Mikhin](https://github.com/mikhin)

## Features

[Section titled “Features”](#features)

* NestJS v11 support
* seamless integration with `@hey-api/openapi-ts` ecosystem
* type-safe controller methods
* minimal learning curve thanks to extending the underlying technology

## Installation

[Section titled “Installation”](#installation)

In your [configuration](https://heyapi.dev/openapi-ts/get-started), add `nestjs` to your plugins and you’ll be ready to generate NestJS artifacts. 🎉

openapi-ts.config.ts

```js
export default {
  input: 'hey-api/backend', // sign up at app.heyapi.dev
  output: 'src/client',
  plugins: [
    // ...other plugins
    'nestjs',
  ],
};
```

## Output

[Section titled “Output”](#output)

The NestJS plugin will generate the following artifacts, depending on the input specification.

## Controller Methods

[Section titled “Controller Methods”](#controller-methods)

Operations are grouped by their first tag into separate types.

* example

  nestjs.gen.ts

  ```ts
  export type PetsControllerMethods = {
    createPet: (body: CreatePetData['body']) => Promise<CreatePetResponse>;
    listPets: (query?: ListPetsData['query']) => Promise<ListPetsResponse>;
    showPetById: (path: ShowPetByIdData['path']) => Promise<ShowPetByIdResponse>;
  };


  export type StoreControllerMethods = {
    getInventory: () => Promise<GetInventoryResponse>;
  };
  ```

* usage

  pets.controller.ts

  ```ts
  import { Body, Controller, Get, Param, Post, Query } from '@nestjs/common';


  import type { PetsControllerMethods } from '../client/nestjs.gen';
  import type { CreatePetData, ListPetsData, ShowPetByIdData } from '../client/types.gen';


  @Controller('pets')
  export class PetsController implements Pick<
    PetsControllerMethods,
    'createPet' | 'listPets' | 'showPetById'
  > {
    @Post()
    async createPet(@Body() body: CreatePetData['body']) {}


    @Get()
    async listPets(@Query() query?: ListPetsData['query']) {}


    @Get(':petId')
    async showPetById(@Param() path: ShowPetByIdData['path']) {}
  }
  ```

## API

[Section titled “API”](#api)

You can view the complete list of options in the [UserConfig](https://github.com/hey-api/openapi-ts/blob/main/packages/openapi-ts/src/plugins/nestjs/types.ts) interface.

## Examples

You can view live examples on [StackBlitz](https://stackblitz.com/orgs/github/hey-api/collections/openapi-ts-examples) or on [GitHub](https://github.com/hey-api/openapi-ts/tree/main/examples/openapi-ts-nestjs).
