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.
Files changed (38) hide show
  1. package/README.md +2 -2
  2. package/lib-commonjs/index.js +683 -289
  3. package/lib-esm/{index.js → index.mjs} +683 -289
  4. package/lib-types/create/components.d.ts +25 -2
  5. package/lib-types/create/schema/index.d.ts +19 -12
  6. package/lib-types/create/schema/metadata.d.ts +2 -1
  7. package/lib-types/create/schema/parsers/array.d.ts +2 -3
  8. package/lib-types/create/schema/parsers/boolean.d.ts +2 -2
  9. package/lib-types/create/schema/parsers/brand.d.ts +2 -3
  10. package/lib-types/create/schema/parsers/catch.d.ts +2 -3
  11. package/lib-types/create/schema/parsers/date.d.ts +2 -2
  12. package/lib-types/create/schema/parsers/default.d.ts +2 -3
  13. package/lib-types/create/schema/parsers/discriminatedUnion.d.ts +2 -2
  14. package/lib-types/create/schema/parsers/enum.d.ts +2 -2
  15. package/lib-types/create/schema/parsers/index.d.ts +2 -3
  16. package/lib-types/create/schema/parsers/intersection.d.ts +2 -3
  17. package/lib-types/create/schema/parsers/lazy.d.ts +2 -3
  18. package/lib-types/create/schema/parsers/literal.d.ts +2 -2
  19. package/lib-types/create/schema/parsers/manual.d.ts +2 -3
  20. package/lib-types/create/schema/parsers/nativeEnum.d.ts +2 -3
  21. package/lib-types/create/schema/parsers/null.d.ts +2 -2
  22. package/lib-types/create/schema/parsers/nullable.d.ts +2 -3
  23. package/lib-types/create/schema/parsers/number.d.ts +2 -2
  24. package/lib-types/create/schema/parsers/object.d.ts +14 -6
  25. package/lib-types/create/schema/parsers/optional.d.ts +9 -4
  26. package/lib-types/create/schema/parsers/pipeline.d.ts +2 -3
  27. package/lib-types/create/schema/parsers/preprocess.d.ts +2 -3
  28. package/lib-types/create/schema/parsers/readonly.d.ts +2 -3
  29. package/lib-types/create/schema/parsers/record.d.ts +2 -3
  30. package/lib-types/create/schema/parsers/refine.d.ts +2 -3
  31. package/lib-types/create/schema/parsers/set.d.ts +2 -3
  32. package/lib-types/create/schema/parsers/string.d.ts +2 -2
  33. package/lib-types/create/schema/parsers/transform.d.ts +8 -4
  34. package/lib-types/create/schema/parsers/tuple.d.ts +2 -3
  35. package/lib-types/create/schema/parsers/union.d.ts +2 -3
  36. package/lib-types/create/schema/parsers/unknown.d.ts +2 -2
  37. package/lib-types/extendZod.d.ts +1 -1
  38. 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. Make a side-effectful import at the top of your entry point(s).
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 `output`. 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 use this when you know your transform has not changed the type.
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