Skip to content

Commit e596edb

Browse files
committed
docs: update copy for NestJS
1 parent c09e477 commit e596edb

9 files changed

Lines changed: 89 additions & 56 deletions

File tree

.changeset/bright-wasps-invite.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@hey-api/openapi-ts": patch
3+
---
4+
5+
**plugin(nestjs)**: initial release

docs/.vitepress/config/en.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -227,6 +227,10 @@ export default defineConfig({
227227
link: '/openapi-ts/plugins/fastify',
228228
text: 'Fastify',
229229
},
230+
{
231+
link: '/openapi-ts/plugins/nest',
232+
text: 'Nest',
233+
},
230234
{
231235
link: '/openapi-ts/plugins/adonis',
232236
text: 'Adonis <span data-soon>soon</span>',
@@ -247,10 +251,6 @@ export default defineConfig({
247251
link: '/openapi-ts/plugins/koa',
248252
text: 'Koa <span data-soon>soon</span>',
249253
},
250-
{
251-
link: '/openapi-ts/plugins/nest',
252-
text: 'Nest',
253-
},
254254
],
255255
link: '/openapi-ts/web-frameworks',
256256
text: 'Web Frameworks',
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
<script setup lang="ts">
2+
const props = defineProps<{
3+
githubExamplePath?: string;
4+
}>();
5+
</script>
6+
7+
<template>
8+
<h2 id="examples" tabindex="-1">
9+
Examples
10+
<a class="header-anchor" href="#examples" aria-label="Permalink to “Examples”">​</a>
11+
</h2>
12+
<p>
13+
You can view live examples on
14+
<a
15+
href="https://stackblitz.com/orgs/github/hey-api/collections/openapi-ts-examples"
16+
target="_blank"
17+
rel="noreferrer"
18+
>StackBlitz</a
19+
>
20+
or on
21+
<a
22+
:href="`https://github.com/hey-api/openapi-ts/tree/main/examples${props.githubExamplePath ? props.githubExamplePath : ''}`"
23+
target="_blank"
24+
rel="noreferrer"
25+
>GitHub</a
26+
>.
27+
</p>
28+
</template>

docs/data/people.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,3 +27,8 @@ export const sebastiaanWouters: Person = {
2727
github: 'https://github.com/SebastiaanWouters',
2828
name: 'Sebastiaan Wouters',
2929
};
30+
31+
export const yuriMikhin: Person = {
32+
github: 'https://github.com/mikhin',
33+
name: 'Yuri Mikhin',
34+
};

docs/openapi-ts/plugins/fastify.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ description: Generate Fastify v5 route handlers from OpenAPI with the Fastify pl
55

66
<script setup lang="ts">
77
import AuthorsList from '@components/AuthorsList.vue';
8+
import Examples from '@components/Examples.vue';
89
import Heading from '@components/Heading.vue';
910
import { jacobCohen } from '@data/people.js';
1011
import VersionLabel from '@components/VersionLabel.vue';
@@ -99,5 +100,6 @@ export default {
99100

100101
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/fastify/types.ts) interface.
101102

102-
<!--@include: ../../partials/examples.md-->
103+
<Examples githubExamplePath="/openapi-ts-fastify" />
104+
103105
<!--@include: ../../partials/sponsors.md-->

docs/openapi-ts/plugins/nest.md

Lines changed: 38 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,18 @@
11
---
2-
title: NestJS Plugin
3-
description: Generate NestJS controller method types from OpenAPI specs. Type-safe controllers via implements.
2+
title: NestJS v11 Plugin
3+
description: Generate NestJS v11 controller methods from OpenAPI with the NestJS plugin for openapi-ts. Fully compatible with validators, transformers, and all core features.
44
---
55

66
<script setup lang="ts">
7+
import AuthorsList from '@components/AuthorsList.vue';
8+
import Examples from '@components/Examples.vue';
79
import Heading from '@components/Heading.vue';
10+
import { yuriMikhin } from '@data/people.js';
811
import VersionLabel from '@components/VersionLabel.vue';
912
</script>
1013

1114
<Heading>
12-
<h1>NestJS</h1>
15+
<h1>NestJS<span class="sr-only"> v11</span></h1>
1316
<VersionLabel value="v11" />
1417
</Heading>
1518

@@ -19,18 +22,24 @@ NestJS plugin is currently in beta. The interface might change before it becomes
1922

2023
### About
2124

22-
The NestJS plugin generates type-safe controller method signatures from your OpenAPI spec.
25+
[Nest](https://nestjs.com) is a progressive Node.js framework for building efficient, reliable and scalable server-side applications.
26+
27+
The NestJS plugin for Hey API generates type-safe controller method signatures from your OpenAPI spec, fully compatible with all core features.
28+
29+
### Collaborators
30+
31+
<AuthorsList :people="[yuriMikhin]" />
2332

2433
## Features
2534

26-
- type-safe controller methods via `implements`
27-
- tag-based grouping for per-controller types
28-
- incremental adoption with `Pick<ControllerMethods, ...>`
29-
- zero runtime coupling — pure TypeScript types
35+
- NestJS v11 support
36+
- seamless integration with `@hey-api/openapi-ts` ecosystem
37+
- type-safe controller methods
38+
- minimal learning curve thanks to extending the underlying technology
3039

3140
## Installation
3241

33-
In your [configuration](/openapi-ts/get-started), add `nestjs` to your plugins.
42+
In your [configuration](/openapi-ts/get-started), add `nestjs` to your plugins and you'll be ready to generate NestJS artifacts. :tada:
3443

3544
```js
3645
export default {
@@ -45,12 +54,18 @@ export default {
4554

4655
## Output
4756

48-
Operations are grouped by their first OpenAPI tag into separate types like `PetsControllerMethods`, `StoreControllerMethods`, etc.
57+
The NestJS plugin will generate the following artifacts, depending on the input specification.
58+
59+
## Controller Methods
60+
61+
Operations are grouped by their first tag into separate types.
4962

50-
```ts
63+
::: code-group
64+
65+
```ts [example]
5166
export type PetsControllerMethods = {
52-
listPets: (query?: ListPetsData['query']) => Promise<ListPetsResponse>;
5367
createPet: (body: CreatePetData['body']) => Promise<CreatePetResponse>;
68+
listPets: (query?: ListPetsData['query']) => Promise<ListPetsResponse>;
5469
showPetById: (path: ShowPetByIdData['path']) => Promise<ShowPetByIdResponse>;
5570
};
5671

@@ -59,10 +74,9 @@ export type StoreControllerMethods = {
5974
};
6075
```
6176

62-
## Usage
63-
64-
```ts
77+
```ts [usage]
6578
import { Body, Controller, Get, Param, Post, Query } from '@nestjs/common';
79+
6680
import type { PetsControllerMethods } from '../client/nestjs.gen';
6781
import type { CreatePetData, ListPetsData, ShowPetByIdData } from '../client/types.gen';
6882

@@ -71,44 +85,23 @@ export class PetsController implements Pick<
7185
PetsControllerMethods,
7286
'createPet' | 'listPets' | 'showPetById'
7387
> {
74-
@Get()
75-
async listPets(@Query() query?: ListPetsData['query']) {
76-
// ...
77-
}
78-
7988
@Post()
80-
async createPet(@Body() body: CreatePetData['body']) {
81-
// ...
82-
}
89+
async createPet(@Body() body: CreatePetData['body']) {}
90+
91+
@Get()
92+
async listPets(@Query() query?: ListPetsData['query']) {}
8393

8494
@Get(':petId')
85-
async showPetById(@Param() path: ShowPetByIdData['path']) {
86-
// ...
87-
}
95+
async showPetById(@Param() path: ShowPetByIdData['path']) {}
8896
}
8997
```
9098

91-
## Example
92-
93-
The [openapi-ts-nestjs example](https://github.com/hey-api/openapi-ts/tree/main/examples/openapi-ts-nestjs) demonstrates the plugin with a minimal NestJS v11 app featuring two controllers and integration tests.
94-
95-
## Constraints
96-
97-
The `implements` pattern requires **whole-object parameter style** with NestJS decorators:
99+
:::
98100

99-
```ts
100-
// WORKS with implements - whole-object style (recommended)
101-
@Get(':petId')
102-
async showPetById(@Param() path: ShowPetByIdData['path']) { ... }
101+
## API
103102

104-
// DOES NOT WORK with implements - decomposed style
105-
@Get(':petId')
106-
async showPetById(@Param('petId') petId: string) { ... }
107-
```
103+
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.
108104

109-
- Methods using `@Res()` for raw response access are incompatible — the extra parameter breaks assignability
110-
- Operations without tags are grouped under `DefaultControllerMethods`
111-
- Cookie parameters are not included in generated signatures — NestJS handles cookies via `@Req()` or dedicated middleware
105+
<Examples githubExamplePath="/openapi-ts-nestjs" />
112106

113-
<!--@include: ../../partials/examples.md-->
114107
<!--@include: ../../partials/sponsors.md-->

docs/openapi-ts/web-frameworks.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,12 @@ Hey API natively supports the following frameworks.
1313

1414
- [Angular](/openapi-ts/plugins/angular)
1515
- [Fastify](/openapi-ts/plugins/fastify)
16+
- [Nest](/openapi-ts/plugins/nest)
1617
- [Adonis](/openapi-ts/plugins/adonis) <span data-soon>Soon</span>
1718
- [Elysia](/openapi-ts/plugins/elysia) <span data-soon>Soon</span>
1819
- [Express](/openapi-ts/plugins/express) <span data-soon>Soon</span>
1920
- [Hono](/openapi-ts/plugins/hono) <span data-soon>Soon</span>
2021
- [Koa](/openapi-ts/plugins/koa) <span data-soon>Soon</span>
21-
- [Nest](/openapi-ts/plugins/nest) <span data-soon>Soon</span>
2222

2323
Don't see your framework? Let us know your interest by [opening an issue](https://github.com/hey-api/openapi-ts/issues).
2424

packages/openapi-ts/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -343,6 +343,7 @@ These plugins help reduce boilerplate associated with third-party dependencies.
343343
- [`@tanstack/svelte-query`](https://heyapi.dev/openapi-ts/plugins/tanstack-query)
344344
- [`@tanstack/vue-query`](https://heyapi.dev/openapi-ts/plugins/tanstack-query)
345345
- [`fastify`](https://heyapi.dev/openapi-ts/plugins/fastify)
346+
- [`nestjs`](https://heyapi.dev/openapi-ts/plugins/nest)
346347
- [`valibot`](https://heyapi.dev/openapi-ts/plugins/valibot)
347348
- [`zod`](https://heyapi.dev/openapi-ts/plugins/zod)
348349

@@ -362,7 +363,6 @@ The following plugins are planned but not in development yet. You can help us pr
362363
- [Joi](https://heyapi.dev/openapi-ts/plugins/joi)
363364
- [Koa](https://heyapi.dev/openapi-ts/plugins/koa)
364365
- [MSW](https://heyapi.dev/openapi-ts/plugins/msw)
365-
- [Nest](https://heyapi.dev/openapi-ts/plugins/nest)
366366
- [Nock](https://heyapi.dev/openapi-ts/plugins/nock)
367367
- [Superstruct](https://heyapi.dev/openapi-ts/plugins/superstruct)
368368
- [Supertest](https://heyapi.dev/openapi-ts/plugins/supertest)

packages/openapi-ts/src/index.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -211,10 +211,6 @@ export namespace Plugins {
211211
export type Types = FastifyPlugin;
212212
}
213213

214-
export namespace NestJs {
215-
export type Types = NestJsPlugin;
216-
}
217-
218214
export namespace HeyApiClientAngular {
219215
export type Client = AngularClientImp;
220216
export type Types = HeyApiClientAngularPlugin;
@@ -267,6 +263,10 @@ export namespace Plugins {
267263
export type Types = HeyApiTypeScriptPlugin;
268264
}
269265

266+
export namespace NestJs {
267+
export type Types = NestJsPlugin;
268+
}
269+
270270
export namespace PiniaColada {
271271
export type Types = PiniaColadaPlugin;
272272
}

0 commit comments

Comments
 (0)