Repository: samchungy/zod-openapi
Pull request #395 (2024-12-23 01:16:00)

Bump @arethetypeswrong/cli from 0.17.1 to 0.17.2
Bumps [@arethetypeswrong/cli](https://github.com/arethetypeswrong/arethetypeswrong.github.io/tree/HEAD/packages/cli) from 0.17.1 to 0.17.2.
<details>
<summary>Changelog</summary>
<p><em>Sourced from <a href="https://github.com/arethetypeswrong/arethetypeswrong.github.io/blob/main/packages/cli/CHANGELOG.md"><code>@​arethetypeswrong/cli</code>'s changelog</a>.</em></p>
<blockquote>
<h2>0.17.2</h2>
<h3>Patch Changes</h3>
<ul>
<li>Updated dependencies [59940cd]
<ul>
<li><code>@​arethetypeswrong/core</code><a href="https://github.com/0"><code>@​0</code></a>.17.2</li>
</ul>
</li>
</ul>
</blockquote>
</details>
<details>
<summary>Commits</summary>
<ul>
<li>See full diff in <a href="https://github.com/arethetypeswrong/arethetypeswrong.github.io/commits/HEAD/packages/cli">compare view</a></li>
</ul>
</details>
<br />


[![Dependabot compatibility score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=@arethetypeswrong/cli&package-manager=npm_and_yarn&previous-version=0.17.1&new-version=0.17.2)](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores)

Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting `@dependabot rebase`.

[//]: # (dependabot-automerge-start)
[//]: # (dependabot-automerge-end)

---

<details>
<summary>Dependabot commands and options</summary>
<br />

You can trigger Dependabot actions by commenting on this PR:
- `@dependabot rebase` will rebase this PR
- `@dependabot recreate` will recreate this PR, overwriting any edits that have been made to it
- `@dependabot merge` will merge this PR after your CI passes on it
- `@dependabot squash and merge` will squash and merge this PR after your CI passes on it
- `@dependabot cancel merge` will cancel a previously requested merge and block automerging
- `@dependabot reopen` will reopen this PR if it is closed
- `@dependabot close` will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
- `@dependabot show <dependency name> ignore conditions` will show all of the ignore conditions of the specified dependency
- `@dependabot ignore this major version` will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
- `@dependabot ignore this minor version` will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
- `@dependabot ignore this dependency` will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)


</details>


Patch:
diff --git a/package.json b/package.json
index f7bd74f..b419f48 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
 {
   "name": "zod-openapi",
-  "version": "4.2.1",
+  "version": "4.2.2",
   "description": "Convert Zod Schemas to OpenAPI v3.x documentation",
   "keywords": [
     "typescript",
@@ -72,14 +72,14 @@
     "test:watch": "skuba test --watch"
   },
   "devDependencies": {
-    "@arethetypeswrong/cli": "0.17.1",
+    "@arethetypeswrong/cli": "0.17.2",
     "@crackle/cli": "0.15.5",
-    "@redocly/cli": "1.26.0",
+    "@redocly/cli": "1.27.0",
     "@types/node": "^20.3.0",
     "eslint-plugin-zod-openapi": "^1.0.0-beta.0",
     "openapi3-ts": "4.4.0",
     "skuba": "9.1.0",
-    "yaml": "2.6.1",
+    "yaml": "2.7.0",
     "zod": "3.24.1"
   },
   "peerDependencies": {
diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml
index 4f06015..f7aab01 100644
--- a/pnpm-lock.yaml
+++ b/pnpm-lock.yaml
@@ -9,14 +9,14 @@ importers:
   .:
     devDependencies:
       '@arethetypeswrong/cli':
-        specifier: 0.17.1
-        version: 0.17.1
+        specifier: 0.17.2
+        version: 0.17.2
       '@crackle/cli':
         specifier: 0.15.5
         version: 0.15.5(@types/node@20.12.13)(terser@5.31.1)(typescript@5.6.2)(webpack@5.92.0(@swc/core@1.6.1)(esbuild@0.24.0))
       '@redocly/cli':
-        specifier: 1.26.0
-        version: 1.26.0(encoding@0.1.13)(enzyme@3.11.0)
+        specifier: 1.27.0
+        version: 1.27.0(encoding@0.1.13)(enzyme@3.11.0)
       '@types/node':
         specifier: ^20.3.0
         version: 20.12.13
@@ -30,8 +30,8 @@ importers:
         specifier: 9.1.0
         version: 9.1.0(@babel/core@7.24.6)(@jest/transform@29.7.0)(@swc/core@1.6.1)(@typescript-eslint/eslint-plugin@8.7.0(@typescript-eslint/parser@8.7.0(eslint@9.11.1(jiti@1.21.6))(typescript@5.6.2))(eslint@9.11.1(jiti@1.21.6))(typescript@5.6.2))(@typescript-eslint/parser@8.7.0(eslint@9.11.1(jiti@1.21.6))(typescript@5.6.2))(babel-jest@29.7.0(@babel/core@7.24.6))(eslint-plugin-import@2.29.1(@typescript-eslint/parser@8.7.0(eslint@9.11.1(jiti@1.21.6))(typescript@5.6.2))(eslint@9.11.1(jiti@1.21.6)))(jiti@1.21.6)
       yaml:
-        specifier: 2.6.1
-        version: 2.6.1
+        specifier: 2.7.0
+        version: 2.7.0
       zod:
         specifier: 3.24.1
         version: 3.24.1
@@ -45,13 +45,13 @@ packages:
   '@andrewbranch/untar.js@1.0.3':
     resolution: {integrity: sha512-Jh15/qVmrLGhkKJBdXlK1+9tY4lZruYjsgkDFj08ZmDiWVBLJcqkok7Z0/R0In+i1rScBpJlSvrTS2Lm41Pbnw==}
 
-  '@arethetypeswrong/cli@0.17.1':
-    resolution: {integrity: sha512-WNKTcC7lqWmbRWWku3Xz0hl7zj9szoGzx7gcGaZPxszKcMPiRnKsiLbxMpf1FzA6myIjE1yalqxNCJ0UkCWTXQ==}
+  '@arethetypeswrong/cli@0.17.2':
+    resolution: {integrity: sha512-/u2VcQJ8PKc4hcao/vXnHrYLEI/sQqKarbHi+NEIfvdymaW5o62XOCXy2yvalQa/vR+AAD/QNEgAUzHo5f7hrw==}
     engines: {node: '>=18'}
     hasBin: true
 
-  '@arethetypeswrong/core@0.17.1':
-    resolution: {integrity: sha512-NgEuyO/D79q2K6lVoSLmRX2YzKNlh2LHU+no3AVkpY4gA20zEhp129KUV1W6jMnbmpRm3xAxF+v3myZ/eFixnA==}
+  '@arethetypeswrong/core@0.17.2':
+    resolution: {integrity: sha512-JYeLgS4rQ2l3gHCabaka3atsEyskfpx+WqUbo+6l8LApILJgr0/XDb7KNC9Ovevp4iPVF2Q73oshpgOKJ3uDRQ==}
     engines: {node: '>=18'}
 
   '@babel/code-frame@7.24.6':
@@ -1181,16 +1181,16 @@ packages:
   '@redocly/ajv@8.11.2':
     resolution: {integrity: sha512-io1JpnwtIcvojV7QKDUSIuMN/ikdOUd1ReEnUnMKGfDVridQZ31J0MmIuqwuRjWDZfmvr+Q0MqCcfHM2gTivOg==}
 
-  '@redocly/cli@1.26.0':
-    resolution: {integrity: sha512-yUsrTmEPHaBDQf16jSFGi2n+AJabHacLpr7La92Dseo0tRkgLKsUWiaVEEyqm79POBytD87mVTi3THitqnSyZQ==}
+  '@redocly/cli@1.27.0':
+    resolution: {integrity: sha512-Ifk7ocvKKCKkNBugX2EQZq6HPMrpEzy6OCB7kejmrrGt3wLpLGIy4SwJk9G4YNn6cmCYiOdTkw661VLHTYhe1Q==}
     engines: {node: '>=14.19.0', npm: '>=7.0.0'}
     hasBin: true
 
   '@redocly/config@0.17.1':
     resolution: {integrity: sha512-CEmvaJuG7pm2ylQg53emPmtgm4nW2nxBgwXzbVEHpGas/lGnMyN8Zlkgiz6rPw0unASg6VW3wlz27SOL5XFHYQ==}
 
-  '@redocly/openapi-core@1.26.0':
-    resolution: {integrity: sha512-8Ofu6WpBp7eoLmf1qQ4+T0W4LRr8es+4Drw/RJG+acPXmaT2TmHk2B2v+3+1R9GqSIj6kx3N7JmQkxAPCnvDLw==}
+  '@redocly/openapi-core@1.27.0':
+    resolution: {integrity: sha512-C3EU9NYbo7bCc9SduHrk6/liUuuBqVfJHOhfbscNCR1443Rdpz3s+bB2Xhso9mdQJT0JjklRn2WTANjavl2Zng==}
     engines: {node: '>=14.19.0', npm: '>=7.0.0'}
 
   '@remix-run/router@1.16.1':
@@ -5565,8 +5565,8 @@ packages:
     resolution: {integrity: sha512-r3vXyErRCYJ7wg28yvBY5VSoAF8ZvlcW9/BwUzEtUsjvX/DKs24dIkuwjtuprwJJHsbyUbLApepYTR1BN4uHrg==}
     engines: {node: '>= 6'}
 
-  yaml@2.6.1:
-    resolution: {integrity: sha512-7r0XPzioN/Q9kXBro/XPnA6kznR73DHq+GXh5ON7ZozRO6aMjbmiBuKste2wslTFkC5d1dw0GooOCepZXJ2SAg==}
+  yaml@2.7.0:
+    resolution: {integrity: sha512-+hSoy/QHluxmC9kCIJyL/uyFmLmc+e5CFR5Wa+bpIhIj85LVb9ZH2nVnqrHoSvKogwODv0ClqZkmiSSaIH5LTA==}
     engines: {node: '>= 14'}
     hasBin: true
 
@@ -5610,9 +5610,9 @@ snapshots:
 
   '@andrewbranch/untar.js@1.0.3': {}
 
-  '@arethetypeswrong/cli@0.17.1':
+  '@arethetypeswrong/cli@0.17.2':
     dependencies:
-      '@arethetypeswrong/core': 0.17.1
+      '@arethetypeswrong/core': 0.17.2
       chalk: 4.1.2
       cli-table3: 0.6.5
       commander: 10.0.1
@@ -5620,7 +5620,7 @@ snapshots:
       marked-terminal: 7.1.0(marked@9.1.6)
       semver: 7.6.3
 
-  '@arethetypeswrong/core@0.17.1':
+  '@arethetypeswrong/core@0.17.2':
     dependencies:
       '@andrewbranch/untar.js': 1.0.3
       cjs-module-lexer: 1.3.1
@@ -6731,9 +6731,9 @@ snapshots:
       require-from-string: 2.0.2
       uri-js-replace: 1.0.1
 
-  '@redocly/cli@1.26.0(encoding@0.1.13)(enzyme@3.11.0)':
+  '@redocly/cli@1.27.0(encoding@0.1.13)(enzyme@3.11.0)':
     dependencies:
-      '@redocly/openapi-core': 1.26.0(encoding@0.1.13)
+      '@redocly/openapi-core': 1.27.0(encoding@0.1.13)
       abort-controller: 3.0.0
       chokidar: 3.6.0
       colorette: 1.4.0
@@ -6762,7 +6762,7 @@ snapshots:
 
   '@redocly/config@0.17.1': {}
 
-  '@redocly/openapi-core@1.26.0(encoding@0.1.13)':
+  '@redocly/openapi-core@1.27.0(encoding@0.1.13)':
     dependencies:
       '@redocly/ajv': 8.11.2
       '@redocly/config': 0.17.1
@@ -6770,7 +6770,6 @@ snapshots:
       https-proxy-agent: 7.0.4
       js-levenshtein: 1.1.6
       js-yaml: 4.1.0
-      lodash.isequal: 4.5.0
       minimatch: 5.1.6
       node-fetch: 2.7.0(encoding@0.1.13)
       pluralize: 8.0.0
@@ -10382,7 +10381,7 @@ snapshots:
 
   openapi3-ts@4.4.0:
     dependencies:
-      yaml: 2.6.1
+      yaml: 2.7.0
 
   optionator@0.9.4:
     dependencies:
@@ -10766,7 +10765,7 @@ snapshots:
   redoc@2.2.0(core-js@3.37.1)(encoding@0.1.13)(enzyme@3.11.0)(mobx@6.12.3)(react-dom@18.3.1(react@18.3.1))(react@18.3.1)(styled-components@6.1.11(react-dom@18.3.1(react@18.3.1))(react@18.3.1)):
     dependencies:
       '@cfaester/enzyme-adapter-react-18': 0.8.0(enzyme@3.11.0)(react-dom@18.3.1(react@18.3.1))(react@18.3.1)
-      '@redocly/openapi-core': 1.26.0(encoding@0.1.13)
+      '@redocly/openapi-core': 1.27.0(encoding@0.1.13)
       classnames: 2.5.1
       core-js: 3.37.1
       decko: 1.2.0
@@ -11976,11 +11975,11 @@ snapshots:
     dependencies:
       eslint-visitor-keys: 3.4.3
       lodash: 4.17.21
-      yaml: 2.6.1
+      yaml: 2.7.0
 
   yaml@1.10.2: {}
 
-  yaml@2.6.1: {}
+  yaml@2.7.0: {}
 
   yargs-parser@20.2.9: {}
 
diff --git a/src/create/schema/index.ts b/src/create/schema/index.ts
index 5f69f07..99046d4 100644
--- a/src/create/schema/index.ts
+++ b/src/create/schema/index.ts
@@ -1,6 +1,6 @@
 import type { ZodType, ZodTypeDef } from 'zod';
 
-import { currentSymbol, previousSymbol } from '../../extendZodTypes';
+import { currentSymbol, previousSymbol } from '../../extendZodSymbols';
 import type { oas30, oas31 } from '../../openapi3-ts/dist';
 import {
   type ComponentsObject,
diff --git a/src/entries/extend.ts b/src/entries/extend.ts
index ad509e9..fea7d7e 100644
--- a/src/entries/extend.ts
+++ b/src/entries/extend.ts
@@ -4,4 +4,5 @@ import { extendZodWithOpenApi } from '../extendZod';
 
 extendZodWithOpenApi(z);
 
+// eslint-disable-next-line @typescript-eslint/consistent-type-exports
 export * from '../extendZodTypes'; // compatibility with < TS 5.0 as the export type * syntax is not supported
diff --git a/src/extendZod.ts b/src/extendZod.ts
index 149daee..be8d77b 100644
--- a/src/extendZod.ts
+++ b/src/extendZod.ts
@@ -1,6 +1,7 @@
 import type { ZodRawShape, ZodTypeDef, z } from 'zod';
 
-import { currentSymbol, previousSymbol } from './extendZodTypes';
+import './extendZodTypes';
+import { currentSymbol, previousSymbol } from './extendZodSymbols';
 
 type ZodOpenApiMetadataDef = NonNullable<ZodTypeDef['zodOpenApi']>;
 type ZodOpenApiMetadata = ZodOpenApiMetadataDef['openapi'];
diff --git a/src/extendZodSymbols.ts b/src/extendZodSymbols.ts
new file mode 100644
index 0000000..c1f38dc
--- /dev/null
+++ b/src/extendZodSymbols.ts
@@ -0,0 +1,3 @@
+// TODO: Remove this file for TS 5.0
+export const currentSymbol = Symbol('current');
+export const previousSymbol = Symbol('previous');
diff --git a/src/extendZodTypes.ts b/src/extendZodTypes.ts
index c4ff49d..e844586 100644
--- a/src/extendZodTypes.ts
+++ b/src/extendZodTypes.ts
@@ -1,15 +1,13 @@
 import type { ZodObject, ZodTypeAny, z } from 'zod';
 
 import type { CreationType } from './create/components';
+import type { currentSymbol, previousSymbol } from './extendZodSymbols';
 import type { oas30, oas31 } from './openapi3-ts/dist';
 
 type SchemaObject = oas30.SchemaObject & oas31.SchemaObject;
 
 type ReplaceDate<T> = T extends Date ? Date | string : T;
 
-export const currentSymbol = Symbol('current');
-export const previousSymbol = Symbol('previous');
-
 /**
  * zod-openapi metadata
  */


Test patch:
diff --git a/src/create/document.test.ts b/src/create/document.test.ts
index 537c92d..1eb675a 100644
--- a/src/create/document.test.ts
+++ b/src/create/document.test.ts
@@ -1625,4 +1625,124 @@ describe('createDocument', () => {
       }
     `);
   });
+
+  it('Supports unionOneOf option', () => {
+    const UserSchema = z.object({
+      id: z.string(),
+      timestamp: z.date(),
+    });
+
+    const documentOptions: CreateDocumentOptions = {
+      unionOneOf: true,
+    };
+
+    const document = createDocument(
+      {
+        info: {
+          title: 'My API',
+          version: '1.0.0',
+        },
+        openapi: '3.1.0',
+        components: {
+          schemas: {
+            User: UserSchema,
+          },
+        },
+        paths: {
+          '/timestamp/:timestamp': {
+            post: {
+              responses: {
+                '200': {
+                  description: '200 OK',
+                  content: {
+                    'application/json': {
+                      schema: z.union([
+                        z.object({
+                          foo: z.string(),
+                        }),
+                        z.object({
+                          bar: z.string(),
+                        }),
+                      ]),
+                    },
+                  },
+                },
+              },
+            },
+          },
+        },
+      },
+      documentOptions,
+    );
+
+    expect(document).toMatchInlineSnapshot(`
+{
+  "components": {
+    "schemas": {
+      "User": {
+        "properties": {
+          "id": {
+            "type": "string",
+          },
+          "timestamp": {
+            "type": "string",
+          },
+        },
+        "required": [
+          "id",
+          "timestamp",
+        ],
+        "type": "object",
+      },
+    },
+  },
+  "info": {
+    "title": "My API",
+    "version": "1.0.0",
+  },
+  "openapi": "3.1.0",
+  "paths": {
+    "/timestamp/:timestamp": {
+      "post": {
+        "responses": {
+          "200": {
+            "content": {
+              "application/json": {
+                "schema": {
+                  "oneOf": [
+                    {
+                      "properties": {
+                        "foo": {
+                          "type": "string",
+                        },
+                      },
+                      "required": [
+                        "foo",
+                      ],
+                      "type": "object",
+                    },
+                    {
+                      "properties": {
+                        "bar": {
+                          "type": "string",
+                        },
+                      },
+                      "required": [
+                        "bar",
+                      ],
+                      "type": "object",
+                    },
+                  ],
+                },
+              },
+            },
+            "description": "200 OK",
+          },
+        },
+      },
+    },
+  },
+}
+`);
+  });
 });
diff --git a/src/extendZod.test.ts b/src/extendZod.test.ts
index 831ee36..185fdaa 100644
--- a/src/extendZod.test.ts
+++ b/src/extendZod.test.ts
@@ -2,7 +2,7 @@ import { z } from 'zod';
 
 import { createSchema } from './create/schema/single';
 import { extendZodWithOpenApi } from './extendZod';
-import { currentSymbol, previousSymbol } from './extendZodTypes';
+import { currentSymbol, previousSymbol } from './extendZodSymbols';
 
 extendZodWithOpenApi(z);