@voznov/zod-dto-nestjs 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 +4 -5
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -24,13 +24,12 @@ import { ZodDto } from '@voznov/zod-dto';
|
|
|
24
24
|
import { z } from 'zod';
|
|
25
25
|
|
|
26
26
|
const CreateUserDto = ZodDto(z.object({ name: z.string(), email: z.email() }));
|
|
27
|
-
type CreateUser = z.infer<typeof CreateUserDto>;
|
|
28
27
|
|
|
29
28
|
@Controller('users')
|
|
30
29
|
export class UsersController {
|
|
31
30
|
@Post()
|
|
32
|
-
create(@Body() body:
|
|
33
|
-
// already validated; `body` is a CreateUserDto instance
|
|
31
|
+
create(@Body() body: CreateUserDto) {
|
|
32
|
+
// already validated; `body` is a CreateUserDto instance.
|
|
34
33
|
}
|
|
35
34
|
}
|
|
36
35
|
```
|
|
@@ -41,7 +40,7 @@ export class UsersController {
|
|
|
41
40
|
|
|
42
41
|
## Swagger integration
|
|
43
42
|
|
|
44
|
-
Importing this package side-effect-registers an `onCreate` hook that decorates every DTO class with `@ApiProperty` metadata based on its Zod schema — no manual decorators required.
|
|
43
|
+
Importing this package side-effect-registers an `onCreate` hook that decorates every DTO class with `@ApiProperty` metadata based on its Zod schema — no manual decorators required. **Import order doesn't matter**: DTOs created before `@voznov/zod-dto-nestjs` was imported are retroactively decorated at hook registration, so `import '@voznov/zod-dto-nestjs'` from anywhere in the app works.
|
|
45
44
|
|
|
46
45
|
Supported shapes: scalars, objects (nested), arrays, tuples, records, enums, literals, unions (including discriminated), intersections, optional/nullable/default wrappers, and nested DTO references (via `oneOf` + `ApiExtraModels`).
|
|
47
46
|
|
|
@@ -69,4 +68,4 @@ app.useGlobalPipes(
|
|
|
69
68
|
|
|
70
69
|
## License
|
|
71
70
|
|
|
72
|
-
Apache-2.0
|
|
71
|
+
[Apache-2.0](./LICENSE)
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@voznov/zod-dto-nestjs",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.2",
|
|
4
4
|
"description": "NestJS adapter for @voznov/zod-dto — validation pipe, Swagger generation",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"zod",
|
|
@@ -48,7 +48,7 @@
|
|
|
48
48
|
"@nestjs/common": ">=10.0.0",
|
|
49
49
|
"@nestjs/swagger": ">=7.0.0",
|
|
50
50
|
"zod": ">=4.0.0",
|
|
51
|
-
"@voznov/zod-dto": "^0.1.
|
|
51
|
+
"@voznov/zod-dto": "^0.1.2"
|
|
52
52
|
},
|
|
53
53
|
"publishConfig": {
|
|
54
54
|
"access": "public"
|