NestJSv11
v11
此内容尚不支持你的语言。
Beta Leave feedback Contribute
Nest 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”Features
Section titled “Features”- NestJS v11 support
- seamless integration with
@hey-api/openapi-tsecosystem - type-safe controller methods
- minimal learning curve thanks to extending the underlying technology
Installation
Section titled “Installation”In your configuration, add nestjs to your plugins and you’ll be ready to generate NestJS artifacts. 🎉
export default { input: 'hey-api/backend', // sign up at app.heyapi.dev output: 'src/client', plugins: [ // ...other plugins 'nestjs', ],};Output
Section titled “Output”The NestJS plugin will generate the following artifacts, depending on the input specification.
Controller Methods
Section titled “Controller Methods”Operations are grouped by their first tag into separate types.
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>;};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']) {}}You can view the complete list of options in the UserConfig interface.
Examples
You can view live examples on StackBlitz or on GitHub.