Skip to content

Commit dea9dbc

Browse files
authored
Support 3.x (#510)
1 parent 0120c31 commit dea9dbc

File tree

9 files changed

+186
-89
lines changed

9 files changed

+186
-89
lines changed

.changeset/little-areas-bet.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'zod-openapi': minor
3+
---
4+
5+
Re-introduce support for OpenAPI 3.x

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<h1 align="center">zod-openapi</h1>
44
</p>
55
<p align="center">
6-
A TypeScript library which uses <a href="https://github.com/colinhacks/zod">Zod</a> schemas to generate OpenAPI v3.1x documentation.
6+
A TypeScript library which uses <a href="https://github.com/colinhacks/zod">Zod</a> schemas to generate OpenAPI v3.x documentation.
77
</p>
88
<div align="center">
99
<a href="https://www.npmjs.com/package/zod-openapi"><img src="https://img.shields.io/npm/v/zod-openapi"/></a>

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@
6868
"tsdown": "0.14.0",
6969
"vitest": "3.2.4",
7070
"yaml": "2.8.1",
71-
"zod": "4.0.17"
71+
"zod": "4.1.1"
7272
},
7373
"peerDependencies": {
7474
"zod": "^3.25.74 || ^4.0.0"

pnpm-lock.yaml

Lines changed: 83 additions & 83 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/create/components.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { type $ZodType, globalRegistry } from 'zod/v4/core';
22

3+
import type { OpenApiVersion } from '../openapi.js';
34
import { isAnyZodType } from '../zod.js';
45

56
import { createContent } from './content.js';
@@ -954,6 +955,7 @@ const createIOSchemas = (ctx: {
954955
registry: ComponentRegistry;
955956
io: 'input' | 'output';
956957
opts: CreateDocumentOptions;
958+
openapiVersion?: OpenApiVersion;
957959
}) => {
958960
const { schemas, components, manual } = createSchemas(
959961
Object.fromEntries(ctx.registry.components.schemas[ctx.io]),
@@ -999,9 +1001,10 @@ const createManualSchemas = (registry: ComponentRegistry) => {
9991001
export const createComponents = (
10001002
registry: ComponentRegistry,
10011003
opts: CreateDocumentOptions,
1004+
openapiVersion?: OpenApiVersion,
10021005
) => {
1003-
createIOSchemas({ registry, io: 'input', opts });
1004-
createIOSchemas({ registry, io: 'output', opts });
1006+
createIOSchemas({ registry, io: 'input', opts, openapiVersion });
1007+
createIOSchemas({ registry, io: 'output', opts, openapiVersion });
10051008
createManualSchemas(registry);
10061009

10071010
const components: oas31.ComponentsObject = {};

0 commit comments

Comments
 (0)