zod-openapi
Advanced tools
Comparing version 2.16.0 to 2.17.0-beta.1
@@ -41,3 +41,3 @@ import type { EnumLike, UnknownKeysParam, ZodAny, ZodArray, ZodBigInt, ZodBoolean, ZodBranded, ZodCatch, ZodDate, ZodDefault, ZodDiscriminatedUnion, ZodEffects, ZodEnum, ZodFunction, ZodIntersection, ZodLazy, ZodLiteral, ZodMap, ZodNaN, ZodNativeEnum, ZodNever, ZodNull, ZodNullable, ZodNumber, ZodObject, ZodOptional, ZodPipeline, ZodPromise, ZodRawShape, ZodReadonly, ZodRecord, ZodSet, ZodString, ZodSymbol, ZodTuple, ZodType, ZodTypeAny, ZodTypeDef, ZodUndefined, ZodUnion, ZodUnionOptions, ZodUnknown, ZodVoid } from 'zod'; | ||
export declare const isZodType: <K extends keyof ZodTypeMap>(zodType: unknown, typeName: K) => zodType is ZodTypeMap[K]; | ||
export declare const isAnyZodType: (zodType: unknown) => zodType is ZodType<unknown, ZodTypeDef, unknown>; | ||
export declare const isAnyZodType: (zodType: unknown) => zodType is ZodType<any, ZodTypeDef, any>; | ||
export {}; |
{ | ||
"name": "zod-openapi", | ||
"version": "2.16.0", | ||
"version": "2.17.0-beta.1", | ||
"description": "Convert Zod Schemas to OpenAPI v3.x documentation", | ||
@@ -23,3 +23,7 @@ "keywords": [ | ||
"license": "MIT", | ||
"sideEffects": false, | ||
"sideEffects": [ | ||
"./src/extend.ts", | ||
"./lib-esm/extend.mjs", | ||
"./lib-commonjs/extend.js" | ||
], | ||
"exports": { | ||
@@ -30,2 +34,7 @@ ".": { | ||
"types": "./lib-types/index.d.ts" | ||
}, | ||
"./extend": { | ||
"import": "./lib-esm/extend.mjs", | ||
"require": "./lib-commonjs/extend.js", | ||
"types": "./lib-types/extend.d.ts" | ||
} | ||
@@ -57,5 +66,5 @@ }, | ||
"openapi3-ts": "4.3.1", | ||
"skuba": "8.0.0", | ||
"skuba": "8.0.1", | ||
"yaml": "2.4.1", | ||
"zod": "3.23.0-beta.2" | ||
"zod": "3.23.3" | ||
}, | ||
@@ -62,0 +71,0 @@ "peerDependencies": { |
@@ -32,8 +32,21 @@ <p align="center"> | ||
### `extendZodWithOpenApi` | ||
### Extend Zod | ||
This mutates Zod to add an extra `.openapi()` method. Call this at the top of your entry point(s). | ||
#### Automatic | ||
```ts | ||
import 'zod-openapi/extend'; | ||
import { z } from 'zod'; | ||
z.string().openapi({ description: 'hello world!', example: 'hello world' }); | ||
``` | ||
#### Manual | ||
This is useful if you have a different instance of Zod that you would like to extend. | ||
```typescript | ||
import { z } from 'zod'; | ||
import { z } from 'another-lib'; | ||
import { extendZodWithOpenApi } from 'zod-openapi'; | ||
@@ -69,7 +82,6 @@ | ||
extendZodWithOpenApi(z); | ||
const jobId = z.string().openapi({ | ||
description: 'Job ID', | ||
description: 'A unique identifier for a job', | ||
example: '12345', | ||
ref: 'jobId', | ||
}); | ||
@@ -127,6 +139,5 @@ | ||
"name": "jobId", | ||
"description": "A unique identifier for a job", | ||
"schema": { | ||
"type": "string", | ||
"description": "Job ID", | ||
"example": "12345" | ||
"$ref": "#/components/schemas/jobId" | ||
} | ||
@@ -161,5 +172,3 @@ } | ||
"jobId": { | ||
"type": "string", | ||
"description": "Job ID", | ||
"example": "12345" | ||
"$ref": "#/components/schemas/jobId" | ||
}, | ||
@@ -180,2 +189,11 @@ "title": { | ||
} | ||
}, | ||
"components": { | ||
"schemas": { | ||
"jobId": { | ||
"type": "string", | ||
"description": "A unique identifier for a job", | ||
"example": "12345" | ||
} | ||
} | ||
} | ||
@@ -182,0 +200,0 @@ } |
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
208779
64
5553
643
1