nestjs-docfy 0.1.0 → 0.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +61 -4
- package/package.json +17 -2
package/README.md
CHANGED
|
@@ -2,16 +2,73 @@
|
|
|
2
2
|
|
|
3
3
|
Keep your NestJS controllers clean. Swagger documentation lives in a dedicated companion file — by naming convention, zero boilerplate.
|
|
4
4
|
|
|
5
|
+
## Before / After
|
|
6
|
+
|
|
7
|
+
**Before** — Swagger decorators buried in your controller:
|
|
8
|
+
|
|
5
9
|
```ts
|
|
6
|
-
// users.controller.ts
|
|
7
|
-
@
|
|
10
|
+
// users.controller.ts
|
|
11
|
+
@ApiTags('users')
|
|
8
12
|
@Controller('users')
|
|
9
13
|
export class UsersController {
|
|
10
14
|
@Get()
|
|
11
|
-
|
|
15
|
+
@ApiOperation({ summary: 'List all users' })
|
|
16
|
+
@ApiResponse({ status: 200, type: [UserEntity] })
|
|
17
|
+
findAll(): Promise<UserEntity[]> {
|
|
18
|
+
return this.usersService.findAll();
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
@Get(':id')
|
|
22
|
+
@ApiOperation({ summary: 'Get a user by ID' })
|
|
23
|
+
@ApiParam({ name: 'id', description: 'User UUID' })
|
|
24
|
+
@ApiResponse({ status: 200, type: UserEntity })
|
|
25
|
+
@ApiResponse({ status: 404, description: 'User not found' })
|
|
26
|
+
findOne(@Param('id') id: string): Promise<UserEntity> {
|
|
27
|
+
return this.usersService.findOne(id);
|
|
28
|
+
}
|
|
12
29
|
|
|
13
30
|
@Post()
|
|
14
|
-
|
|
31
|
+
@ApiOperation({ summary: 'Create a user' })
|
|
32
|
+
@ApiBody({ type: CreateUserDto })
|
|
33
|
+
@ApiResponse({ status: 201, type: UserEntity })
|
|
34
|
+
@ApiResponse({ status: 400, description: 'Invalid input' })
|
|
35
|
+
create(@Body() dto: CreateUserDto): Promise<UserEntity> {
|
|
36
|
+
return this.usersService.create(dto);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
@Delete(':id')
|
|
40
|
+
@ApiOperation({ summary: 'Delete a user' })
|
|
41
|
+
@ApiParam({ name: 'id', description: 'User UUID' })
|
|
42
|
+
@ApiResponse({ status: 204 })
|
|
43
|
+
@ApiResponse({ status: 404, description: 'User not found' })
|
|
44
|
+
remove(@Param('id') id: string): Promise<void> {
|
|
45
|
+
return this.usersService.remove(id);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
**After** — controller expresses only behavior:
|
|
51
|
+
|
|
52
|
+
```ts
|
|
53
|
+
// users.controller.ts
|
|
54
|
+
@WithDocs()
|
|
55
|
+
@Controller('users')
|
|
56
|
+
export class UsersController {
|
|
57
|
+
findAll(): Promise<UserEntity[]> {
|
|
58
|
+
return this.usersService.findAll();
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
findOne(@Param('id') id: string): Promise<UserEntity> {
|
|
62
|
+
return this.usersService.findOne(id);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
create(@Body() dto: CreateUserDto): Promise<UserEntity> {
|
|
66
|
+
return this.usersService.create(dto);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
remove(@Param('id') id: string): Promise<void> {
|
|
70
|
+
return this.usersService.remove(id);
|
|
71
|
+
}
|
|
15
72
|
}
|
|
16
73
|
```
|
|
17
74
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "nestjs-docfy",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.2",
|
|
4
4
|
"description": "Keep your NestJS controllers clean — Swagger docs live in a separate companion file by naming convention",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -34,7 +34,22 @@
|
|
|
34
34
|
"openapi",
|
|
35
35
|
"decorator",
|
|
36
36
|
"documentation",
|
|
37
|
-
"companion"
|
|
37
|
+
"companion",
|
|
38
|
+
"nestjs-swagger",
|
|
39
|
+
"nestjs-openapi",
|
|
40
|
+
"nestjs-module",
|
|
41
|
+
"nestjs-decorator",
|
|
42
|
+
"nestjs-clean",
|
|
43
|
+
"swagger-decorator",
|
|
44
|
+
"swagger-companion",
|
|
45
|
+
"openapi-decorator",
|
|
46
|
+
"controller-docs",
|
|
47
|
+
"clean-controller",
|
|
48
|
+
"separation-of-concerns",
|
|
49
|
+
"developer-experience",
|
|
50
|
+
"dx",
|
|
51
|
+
"typescript",
|
|
52
|
+
"reflect-metadata"
|
|
38
53
|
],
|
|
39
54
|
"author": "Marvin Rocha",
|
|
40
55
|
"repository": {
|