zod-openapi
Advanced tools
Comparing version 2.17.0-beta.1 to 2.17.0-beta.2
@@ -1,1 +0,1 @@ | ||
export type * from './extendZod'; | ||
export * from './extendZodTypes'; |
@@ -1,76 +0,3 @@ | ||
import type { ZodDate, ZodObject, ZodTypeAny, z } from 'zod'; | ||
import type { CreationType } from './create/components'; | ||
import type { oas30, oas31 } from './openapi3-ts/dist'; | ||
type SchemaObject = oas30.SchemaObject & oas31.SchemaObject; | ||
/** | ||
* zod-openapi metadata | ||
*/ | ||
interface ZodOpenApiMetadata<T extends ZodTypeAny, TInferred = z.input<T> | z.output<T>> extends SchemaObject { | ||
example?: TInferred; | ||
examples?: [TInferred, ...TInferred[]]; | ||
default?: T extends ZodDate ? string : TInferred; | ||
/** | ||
* Used to set the output of a ZodUnion to be `oneOf` instead of `allOf` | ||
*/ | ||
unionOneOf?: boolean; | ||
/** | ||
* Used to output this Zod Schema in the components schemas section. Any usage of this Zod Schema will then be transformed into a $ref. | ||
*/ | ||
ref?: string; | ||
/** | ||
* Used when you are manually adding a Zod Schema to the components section. This controls whether this should be rendered as request (`input`) or response (`output`). Defaults to `output` | ||
*/ | ||
refType?: CreationType; | ||
/** | ||
* Used to set the created type of an effect. | ||
*/ | ||
effectType?: CreationType | (z.input<T> extends z.output<T> ? z.output<T> extends z.input<T> ? 'same' : never : never); | ||
/** | ||
* Used to set metadata for a parameter, request header or cookie | ||
*/ | ||
param?: Partial<oas31.ParameterObject> & { | ||
example?: TInferred; | ||
examples?: Record<string, (oas31.ExampleObject & { | ||
value: TInferred; | ||
}) | oas31.ReferenceObject>; | ||
/** | ||
* Used to output this Zod Schema in the components parameters section. Any usage of this Zod Schema will then be transformed into a $ref. | ||
*/ | ||
ref?: string; | ||
}; | ||
/** | ||
* Used to set data for a response header | ||
*/ | ||
header?: Partial<oas31.HeaderObject & oas30.HeaderObject> & { | ||
/** | ||
* Used to output this Zod Schema in the components headers section. Any usage of this Zod Schema will then be transformed into a $ref. | ||
*/ | ||
ref?: string; | ||
}; | ||
/** | ||
* Used to override the generated type. If this is provided no metadata will be generated. | ||
*/ | ||
type?: SchemaObject['type']; | ||
} | ||
interface ZodOpenApiExtendMetadata { | ||
extends: ZodObject<any, any, any, any, any>; | ||
} | ||
declare module 'zod' { | ||
interface ZodType { | ||
/** | ||
* Add OpenAPI metadata to a Zod Type | ||
*/ | ||
openapi<T extends ZodTypeAny>(this: T, metadata: ZodOpenApiMetadata<T>): T; | ||
} | ||
interface ZodTypeDef { | ||
/** | ||
* OpenAPI metadata | ||
*/ | ||
openapi?: ZodOpenApiMetadata<ZodTypeAny>; | ||
} | ||
interface ZodObjectDef { | ||
extendMetadata?: ZodOpenApiExtendMetadata; | ||
} | ||
} | ||
import type { z } from 'zod'; | ||
import './extendZodTypes'; | ||
export declare function extendZodWithOpenApi(zod: typeof z): void; | ||
export {}; |
{ | ||
"name": "zod-openapi", | ||
"version": "2.17.0-beta.1", | ||
"version": "2.17.0-beta.2", | ||
"description": "Convert Zod Schemas to OpenAPI v3.x documentation", | ||
@@ -43,2 +43,10 @@ "keywords": [ | ||
"types": "./lib-types/index.d.ts", | ||
"typesVersions": { | ||
"*": { | ||
"*": [ | ||
"lib-types/index.d.ts", | ||
"lib-types/extend.d.ts" | ||
] | ||
} | ||
}, | ||
"files": [ | ||
@@ -45,0 +53,0 @@ "lib*/**/*.d.ts", |
@@ -36,4 +36,2 @@ <p align="center"> | ||
#### Automatic | ||
```ts | ||
@@ -40,0 +38,0 @@ import 'zod-openapi/extend'; |
208948
65
5555
641