Gathering detailed insights and metrics for @anatine/zod-openapi
Gathering detailed insights and metrics for @anatine/zod-openapi
Gathering detailed insights and metrics for @anatine/zod-openapi
Gathering detailed insights and metrics for @anatine/zod-openapi
npm install @anatine/zod-openapi
Typescript
Module System
Node Version
NPM Version
99.5
Supply Chain
99
Quality
81
Maintenance
100
Vulnerability
100
License
zod-nestjs-2.0.12
Updated on Apr 05, 2025
zod-nestjs-2.0.11
Updated on Apr 04, 2025
zod-mock-3.14.0
Updated on Apr 04, 2025
zod-openapi-2.2.8
Updated on Apr 04, 2025
zod-mock-3.13.5
Updated on Jan 20, 2025
zod-nestjs-2.0.10
Updated on Jan 20, 2025
TypeScript (99.51%)
JavaScript (0.49%)
Total Downloads
11,509,636
Last Day
36,846
Last Week
195,305
Last Month
846,439
Last Year
7,234,881
736 Stars
525 Commits
102 Forks
7 Watchers
12 Branches
53 Contributors
Updated on May 04, 2025
Minified
Minified + Gzipped
Latest Version
2.2.8
Package Id
@anatine/zod-openapi@2.2.8
Unpacked Size
48.67 kB
Size
11.55 kB
File Count
13
NPM Version
10.8.2
Node Version
18.20.7
Published on
Apr 04, 2025
Cumulative downloads
Total Downloads
Last Day
-6.7%
36,846
Compared to previous day
Last Week
-4.2%
195,305
Compared to previous week
Last Month
-7.1%
846,439
Compared to previous month
Last Year
122%
7,234,881
Compared to previous year
1
2
Converts a Zod schema to an OpenAPI SchemaObject
as defined by openapi3-ts
Both openapi3-ts and zod are peer dependencies instead of dependant packages.
While zod
is necessary for operation, openapi3-ts
is for type-casting.
1npm install openapi3-ts zod @anatine/zod-openapi
1import { generateSchema } from '@anatine/zod-openapi'; 2const aZodSchema = z.object({ 3 uid: z.string().nonempty(), 4 firstName: z.string().min(2), 5 lastName: z.string().optional(), 6 email: z.string().email(), 7 phoneNumber: z.string().min(10).optional(), 8}) 9const myOpenApiSchema = generateSchema(aZodSchema); 10// ...
This will generate an OpenAPI schema for myOpenApiSchema
1{ 2 "type": "object", 3 "properties": { 4 "uid": { 5 "type": "string", 6 "minLength": 1 7 }, 8 "firstName": { 9 "type": "string", 10 "minLength": 2 11 }, 12 "lastName": { 13 "type": "string" 14 }, 15 "email": { 16 "type": "string", 17 "format": "email" 18 }, 19 "phoneNumber": { 20 "type": "string", 21 "minLength": 10 22 } 23 }, 24 "required": [ 25 "uid", 26 "firstName", 27 "email" 28 ] 29}
1import { extendApi, generateSchema } from '@anatine/zod-openapi'; 2const aZodExtendedSchema = extendApi( 3 z.object({ 4 uid: extendApi(z.string().nonempty(), { 5 title: 'Unique ID', 6 description: 'A UUID generated by the server', 7 }), 8 firstName: z.string().min(2), 9 lastName: z.string().optional(), 10 email: z.string().email(), 11 phoneNumber: extendApi(z.string().min(10), { 12 description: 'US Phone numbers only', 13 example: '555-555-5555', 14 }), 15 }), 16 { 17 title: 'User', 18 description: 'A user schema', 19 } 20 ); 21const myOpenApiSchema = generateSchema(aZodExtendedSchema); 22// ...
... or via extension of the Zod schema:
1import { extendApi, generateSchema, extendZodWithOpenApi } from '@anatine/zod-openapi'; 2import {z} from 'zod'; 3 4extendZodWithOpenApi(z); 5 6const aZodExtendedSchema = 7 z.object({ 8 uid: z.string().nonempty().openapi({ 9 title: 'Unique ID', 10 description: 'A UUID generated by the server', 11 }), 12 firstName: z.string().min(2), 13 lastName: z.string().optional(), 14 email: z.string().email(), 15 phoneNumber: z.string().min(10).openapi({ 16 description: 'US Phone numbers only', 17 example: '555-555-5555', 18 }), 19 }).openapi( 20 { 21 title: 'User', 22 description: 'A user schema', 23 } 24 ); 25const myOpenApiSchema = generateSchema(aZodExtendedSchema); 26// ...
This will generate an extended schema:
1{ 2 "type": "object", 3 "properties": { 4 "uid": { 5 "type": "string", 6 "minLength": 1, 7 "title": "Unique ID", 8 "description": "A UUID generated by the server" 9 }, 10 "firstName": { 11 "type": "string", 12 "minLength": 2 13 }, 14 "lastName": { 15 "type": "string" 16 }, 17 "email": { 18 "type": "string", 19 "format": "email" 20 }, 21 "phoneNumber": { 22 "type": "string", 23 "minLength": 10, 24 "description": "US Phone numbers only", 25 "example": "555-555-5555" 26 } 27 }, 28 "required": [ 29 "uid", 30 "firstName", 31 "email", 32 "phoneNumber" 33 ], 34 "title": "User", 35 "description": "A user schema" 36}
A great lib that provided some insights on dealing with various zod types.
Lib providing insights into using Zod with NestJS
This library is part of a nx monorepo @anatine/zod-plugins.
No vulnerabilities found.
Reason
16 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 10
Reason
no dangerous workflow patterns detected
Reason
no binaries found in the repo
Reason
Found 12/20 approved changesets -- score normalized to 6
Reason
5 existing vulnerabilities detected
Details
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
detected GitHub workflow tokens with excessive permissions
Details
Reason
dependency not pinned by hash detected -- score normalized to 0
Details
Reason
security policy file not detected
Details
Reason
license file not detected
Details
Reason
project is not fuzzed
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Score
Last Scanned on 2025-04-28
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More