zod-openapi 4.1.0 → 4.1.2

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 CHANGED
@@ -450,7 +450,7 @@ Wherever `title` is used in schemas across the document, it will instead be crea
450
450
  }
451
451
  ```
452
452
 
453
- This can be an extremely powerful way to create less repetitive Open API documentation. There are some Open API features like [discriminator mapping](https://swagger.io/docs/specification/data-models/inheritance-and-polymorphism/) which require all schemas in the union to contain a ref.
453
+ This is a great way to create less repetitive Open API documentation. There are some Open API features like [discriminator mapping](https://swagger.io/docs/specification/data-models/inheritance-and-polymorphism/) which require all schemas in the union to contain a ref.
454
454
 
455
455
  ##### Manually Registering Schema
456
456
 
@@ -468,7 +468,7 @@ createDocument({
468
468
  });
469
469
  ```
470
470
 
471
- Unfortunately, as a limitation of this library, you will need to attach an `.openapi()` field or `.describe()` to the schema that you are passing into the components or else you may not get the full power of the component generation. As a result, I recommend utilising the auto registering components over manual registration.
471
+ Unfortunately, as a limitation of this library, you will need to attach an `.openapi()` field or `.describe()` to the schema that you are passing into the components or you will not reap the full benefits of component generation. As a result, I recommend utilising the auto registering components over manual registration.
472
472
 
473
473
  #### Parameters
474
474
 
@@ -72,6 +72,7 @@ function extendZodWithOpenApi(zod) {
72
72
  const cloned = { ...zodOpenApi };
73
73
  cloned.openapi = mergeOpenApi({}, cloned.openapi);
74
74
  delete cloned.previous;
75
+ delete cloned.current;
75
76
  omitResult._def.zodOpenApi = cloned;
76
77
  }
77
78
  return omitResult;
@@ -84,6 +85,7 @@ function extendZodWithOpenApi(zod) {
84
85
  const cloned = { ...zodOpenApi };
85
86
  cloned.openapi = mergeOpenApi({}, cloned.openapi);
86
87
  delete cloned.previous;
88
+ delete cloned.current;
87
89
  pickResult._def.zodOpenApi = cloned;
88
90
  }
89
91
  return pickResult;
@@ -71,6 +71,7 @@ function extendZodWithOpenApi(zod) {
71
71
  const cloned = { ...zodOpenApi };
72
72
  cloned.openapi = mergeOpenApi({}, cloned.openapi);
73
73
  delete cloned.previous;
74
+ delete cloned.current;
74
75
  omitResult._def.zodOpenApi = cloned;
75
76
  }
76
77
  return omitResult;
@@ -83,6 +84,7 @@ function extendZodWithOpenApi(zod) {
83
84
  const cloned = { ...zodOpenApi };
84
85
  cloned.openapi = mergeOpenApi({}, cloned.openapi);
85
86
  delete cloned.previous;
87
+ delete cloned.current;
86
88
  pickResult._def.zodOpenApi = cloned;
87
89
  }
88
90
  return pickResult;
@@ -1,16 +1,17 @@
1
- import { ZodTypeAny, z, ZodDate, ZodObject } from 'zod';
1
+ import { ZodTypeAny, z, ZodObject } from 'zod';
2
2
  import { CreationType } from './create/components.js';
3
3
  import { HeaderObject as HeaderObject$1, SchemaObject as SchemaObject$1 } from './openapi3-ts/dist/model/openapi30.js';
4
4
  import { ParameterObject, ExampleObject, ReferenceObject, HeaderObject, SchemaObject as SchemaObject$2 } from './openapi3-ts/dist/model/openapi31.js';
5
5
 
6
6
  type SchemaObject = SchemaObject$1 & SchemaObject$2;
7
+ type ReplaceDate<T> = T extends Date ? Date | string : T;
7
8
  /**
8
9
  * zod-openapi metadata
9
10
  */
10
- interface ZodOpenApiMetadata<T extends ZodTypeAny, TInferred = z.input<T> | z.output<T>> extends SchemaObject {
11
+ interface ZodOpenApiMetadata<T extends ZodTypeAny, TInferred = Exclude<ReplaceDate<z.input<T> | z.output<T>>, undefined>> extends SchemaObject {
11
12
  example?: TInferred;
12
13
  examples?: [TInferred, ...TInferred[]];
13
- default?: T extends ZodDate ? string : TInferred;
14
+ default?: TInferred;
14
15
  /**
15
16
  * Used to set the output of a ZodUnion to be `oneOf` instead of `allOf`
16
17
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "zod-openapi",
3
- "version": "4.1.0",
3
+ "version": "4.1.2",
4
4
  "description": "Convert Zod Schemas to OpenAPI v3.x documentation",
5
5
  "keywords": [
6
6
  "typescript",
@@ -72,9 +72,9 @@
72
72
  "test:watch": "skuba test --watch"
73
73
  },
74
74
  "devDependencies": {
75
- "@arethetypeswrong/cli": "0.17.0",
75
+ "@arethetypeswrong/cli": "0.17.1",
76
76
  "@crackle/cli": "0.15.5",
77
- "@redocly/cli": "1.25.13",
77
+ "@redocly/cli": "1.25.15",
78
78
  "@types/node": "^20.3.0",
79
79
  "eslint-plugin-zod-openapi": "^1.0.0-beta.0",
80
80
  "openapi3-ts": "4.4.0",