zod-openapi 2.12.0 → 2.13.0
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 +2 -2
- package/lib-commonjs/index.js +683 -289
- package/lib-esm/{index.js → index.mjs} +683 -289
- package/lib-types/create/components.d.ts +25 -2
- package/lib-types/create/schema/index.d.ts +19 -12
- package/lib-types/create/schema/metadata.d.ts +2 -1
- package/lib-types/create/schema/parsers/array.d.ts +2 -3
- package/lib-types/create/schema/parsers/boolean.d.ts +2 -2
- package/lib-types/create/schema/parsers/brand.d.ts +2 -3
- package/lib-types/create/schema/parsers/catch.d.ts +2 -3
- package/lib-types/create/schema/parsers/date.d.ts +2 -2
- package/lib-types/create/schema/parsers/default.d.ts +2 -3
- package/lib-types/create/schema/parsers/discriminatedUnion.d.ts +2 -2
- package/lib-types/create/schema/parsers/enum.d.ts +2 -2
- package/lib-types/create/schema/parsers/index.d.ts +2 -3
- package/lib-types/create/schema/parsers/intersection.d.ts +2 -3
- package/lib-types/create/schema/parsers/lazy.d.ts +2 -3
- package/lib-types/create/schema/parsers/literal.d.ts +2 -2
- package/lib-types/create/schema/parsers/manual.d.ts +2 -3
- package/lib-types/create/schema/parsers/nativeEnum.d.ts +2 -3
- package/lib-types/create/schema/parsers/null.d.ts +2 -2
- package/lib-types/create/schema/parsers/nullable.d.ts +2 -3
- package/lib-types/create/schema/parsers/number.d.ts +2 -2
- package/lib-types/create/schema/parsers/object.d.ts +14 -6
- package/lib-types/create/schema/parsers/optional.d.ts +9 -4
- package/lib-types/create/schema/parsers/pipeline.d.ts +2 -3
- package/lib-types/create/schema/parsers/preprocess.d.ts +2 -3
- package/lib-types/create/schema/parsers/readonly.d.ts +2 -3
- package/lib-types/create/schema/parsers/record.d.ts +2 -3
- package/lib-types/create/schema/parsers/refine.d.ts +2 -3
- package/lib-types/create/schema/parsers/set.d.ts +2 -3
- package/lib-types/create/schema/parsers/string.d.ts +2 -2
- package/lib-types/create/schema/parsers/transform.d.ts +8 -4
- package/lib-types/create/schema/parsers/tuple.d.ts +2 -3
- package/lib-types/create/schema/parsers/union.d.ts +2 -3
- package/lib-types/create/schema/parsers/unknown.d.ts +2 -2
- package/lib-types/extendZod.d.ts +1 -1
- package/package.json +11 -5
package/README.md
CHANGED
|
@@ -29,7 +29,7 @@ yarn add zod zod-openapi
|
|
|
29
29
|
|
|
30
30
|
### `extendZodWithOpenApi`
|
|
31
31
|
|
|
32
|
-
This mutates Zod to add an extra `.openapi()` method.
|
|
32
|
+
This mutates Zod to add an extra `.openapi()` method. Call this at the top of your entry point(s).
|
|
33
33
|
|
|
34
34
|
```typescript
|
|
35
35
|
import { z } from 'zod';
|
|
@@ -334,7 +334,7 @@ _Input_: Request Bodies, Request Parameters, Headers
|
|
|
334
334
|
|
|
335
335
|
_Output_: Responses, Response Headers
|
|
336
336
|
|
|
337
|
-
If a registered schema with a transform or pipeline is used in both a request and response schema you will receive an error because the created schema for each will be different. To override the creation type for a specific ZodEffect, add an `.openapi()` field on it and set the `effectType` field to `input` or `
|
|
337
|
+
If a registered schema with a transform or pipeline is used in both a request and response schema you will receive an error because the created schema for each will be different. To override the creation type for a specific ZodEffect, add an `.openapi()` field on it and set the `effectType` field to `input`, `output` or `same`. This will force this library to always generate the input/output type even if we are creating a response (output) or request (input) type. You typically want to set this when you know the type has not changed in the transform. `same` is the recommended choice as it will throw a type error if the input and output types in the transform drift.
|
|
338
338
|
|
|
339
339
|
`.preprocess()` will always return the `output` type even if we are creating an input schema. If a different input type is required you can achieve this with a `.transform()` combined with a `.pipe()` or simply declare a manual `type` in `.openapi()`.
|
|
340
340
|
|