Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/node.js.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ name: Node.js CI

on:
push:
branches: [ master, v21, v22, v23, v24 ]
branches: [ master, v25 ]
pull_request:
branches: [ master, v21, v22, v23, v24 ]
branches: [ master, v25 ]

jobs:
build:
Expand Down
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@

## Version 25

### v25.6.3

- Limited Zod compatibility to `>=4.0.0 <4.4.0`:
- Zod 4.4.0 introduced a breaking change to how `brand` method works, making the current plugin approach incompatible;
- Supporting Zod 4.4+ requires a breaking change and will be addressed in v28.

### v25.6.2

- Fixed performance regression since v24.0.0:
Expand Down
18 changes: 9 additions & 9 deletions example/example.documentation.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -132,10 +132,10 @@ paths:
required: true
description: PATCH /v1/user/:id Parameter
schema:
examples:
- "1234567890"
type: string
minLength: 1
examples:
- "1234567890"
examples:
example1:
value: "1234567890"
Expand All @@ -144,9 +144,9 @@ paths:
required: true
description: PATCH /v1/user/:id Parameter
schema:
type: string
examples:
- "12"
type: string
examples:
example1:
value: "12"
Expand All @@ -158,15 +158,15 @@ paths:
type: object
properties:
key:
type: string
minLength: 1
examples:
- 1234-5678-90
name:
type: string
minLength: 1
name:
examples:
- John Doe
type: string
minLength: 1
birthday:
description: the day of birth
type: string
Expand Down Expand Up @@ -205,9 +205,9 @@ paths:
type: object
properties:
name:
type: string
examples:
- John Doe
type: string
createdAt:
description: account creation date
type: string
Expand Down Expand Up @@ -275,11 +275,11 @@ paths:
type: object
properties:
name:
type: string
pattern: ^\w+ \w+$
description: first name and last name
examples:
- John Doe
type: string
pattern: ^\w+ \w+$
required:
- name
examples:
Expand Down
2 changes: 1 addition & 1 deletion express-zod-api/src/diagnostics.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export class Diagnostics {
public checkSchema(endpoint: AbstractEndpoint, ctx: FlatObject): void {
if (this.#verifiedEndpoints.has(endpoint)) return;
for (const dir of ["input", "output"] as const) {
const stack = [
const stack: z.core.JSONSchema.BaseSchema[] = [
z.toJSONSchema(endpoint[`${dir}Schema`], { unrepresentable: "any" }),
];
while (stack.length > 0) {
Expand Down
52 changes: 30 additions & 22 deletions express-zod-api/tests/__snapshots__/documentation.spec.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -2072,6 +2072,8 @@ paths:
const: only
additionalProperties:
type: boolean
required:
- only
union:
type: object
propertyNames:
Expand All @@ -2082,6 +2084,9 @@ paths:
const: option2
additionalProperties:
type: boolean
required:
- option1
- option2
enum:
type: object
propertyNames:
Expand All @@ -2091,6 +2096,9 @@ paths:
- option2
additionalProperties:
type: boolean
required:
- option1
- option2
required:
- simple
- stringy
Expand Down Expand Up @@ -3594,8 +3602,8 @@ paths:
required: true
description: GET /v1/getSomething Parameter
schema:
deprecated: true
type: string
deprecated: true
responses:
"200":
description: GET /v1/getSomething Positive response
Expand Down Expand Up @@ -3653,8 +3661,8 @@ paths:
required: true
description: HEAD /v1/getSomething Parameter
schema:
deprecated: true
type: string
deprecated: true
responses:
"200":
description: HEAD /v1/getSomething Positive response
Expand Down Expand Up @@ -3713,11 +3721,6 @@ paths:
type: string
const: success
data:
examples:
- a: first
b: prefix_first
- a: second
b: prefix_second
type: object
properties:
a:
Expand All @@ -3728,6 +3731,11 @@ paths:
- a
- b
additionalProperties: false
examples:
- a: first
b: prefix_first
- a: second
b: prefix_second
required:
- status
- data
Expand Down Expand Up @@ -3937,15 +3945,15 @@ paths:
type: string
const: success
data:
examples:
- num: 123
type: object
properties:
num:
type: number
required:
- num
additionalProperties: false
examples:
- num: 123
required:
- status
- data
Expand Down Expand Up @@ -4017,13 +4025,13 @@ paths:
type: object
properties:
key:
type: string
examples:
- 1234-56789-01
type: string
str:
type: string
examples:
- test
type: string
required:
- key
- str
Expand All @@ -4048,9 +4056,9 @@ paths:
type: object
properties:
num:
type: number
examples:
- 123
type: number
required:
- num
additionalProperties: false
Expand Down Expand Up @@ -4141,15 +4149,15 @@ paths:
type: string
const: success
data:
examples:
- numericStr: "123"
type: object
properties:
numericStr:
type: string
required:
- numericStr
additionalProperties: false
examples:
- numericStr: "123"
required:
- status
- data
Expand Down Expand Up @@ -4258,15 +4266,15 @@ paths:
type: string
const: success
data:
examples:
- numericStr: "123"
type: object
properties:
numericStr:
type: string
required:
- numericStr
additionalProperties: false
examples:
- numericStr: "123"
required:
- status
- data
Expand Down Expand Up @@ -4336,9 +4344,9 @@ paths:
required: true
description: GET /v1/getSomething Parameter
schema:
type: string
examples:
- "123"
type: string
examples:
example1:
value: "123"
Expand Down Expand Up @@ -4411,9 +4419,9 @@ paths:
required: true
description: HEAD /v1/getSomething Parameter
schema:
type: string
examples:
- "123"
type: string
examples:
example1:
value: "123"
Expand Down Expand Up @@ -4455,9 +4463,9 @@ paths:
type: object
properties:
strNum:
type: string
examples:
- "123"
type: string
required:
- strNum
examples:
Expand Down Expand Up @@ -4557,8 +4565,8 @@ paths:
required: true
description: here is the test
schema:
description: here is the test
type: string
description: here is the test
responses:
"200":
description: GET /v1/getSomething Positive response
Expand All @@ -4574,10 +4582,10 @@ paths:
type: object
properties:
result:
description: some positive integer
type: integer
exclusiveMinimum: 0
maximum: 9007199254740991
description: some positive integer
required:
- result
additionalProperties: false
Expand Down Expand Up @@ -4621,8 +4629,8 @@ paths:
required: true
description: here is the test
schema:
description: here is the test
type: string
description: here is the test
responses:
"200":
description: HEAD /v1/getSomething Positive response
Expand Down
20 changes: 20 additions & 0 deletions express-zod-api/tests/__snapshots__/env.spec.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ exports[`Environment checks > Zod checks/refinements > Snapshot control 'ZodEmai
],
"parse": [Function],
"pattern": /\\^\\(\\?!\\\\\\.\\)\\(\\?!\\.\\*\\\\\\.\\\\\\.\\)\\(\\[A-Za-z0-9_'\\+\\\\-\\\\\\.\\]\\*\\)\\[A-Za-z0-9_\\+-\\]@\\(\\[A-Za-z0-9\\]\\[A-Za-z0-9\\\\-\\]\\*\\\\\\.\\)\\+\\[A-Za-z\\]\\{2,\\}\\$/,
"processJSONSchema": [Function],
"run": [Function],
"traits": Set {
"ZodEmail",
Expand Down Expand Up @@ -60,8 +61,13 @@ exports[`Environment checks > Zod checks/refinements > Snapshot control 'ZodNumb
"type": "number",
},
"deferred": [],
"parent": {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"type": "number",
},
"parse": [Function],
"pattern": /\\^-\\?\\\\d\\+\\$/,
"processJSONSchema": [Function],
"run": [Function],
"traits": Set {
"ZodNumber",
Expand Down Expand Up @@ -94,6 +100,7 @@ exports[`Environment checks > Zod checks/refinements > Snapshot control 'ZodNumb
],
"parse": [Function],
"pattern": /\\^-\\?\\\\d\\+\\$/,
"processJSONSchema": [Function],
"run": [Function],
"traits": Set {
"ZodNumberFormat",
Expand Down Expand Up @@ -130,6 +137,7 @@ exports[`Environment checks > Zod checks/refinements > Snapshot control 'ZodNumb
],
"parse": [Function],
"pattern": /\\^-\\?\\\\d\\+\\$/,
"processJSONSchema": [Function],
"run": [Function],
"traits": Set {
"ZodNumberFormat",
Expand Down Expand Up @@ -167,8 +175,15 @@ exports[`Environment checks > Zod checks/refinements > Snapshot control 'ZodNumb
"onattach": [
[Function],
],
"parent": {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"maximum": 9007199254740991,
"minimum": -9007199254740991,
"type": "integer",
},
"parse": [Function],
"pattern": /\\^-\\?\\\\d\\+\\$/,
"processJSONSchema": [Function],
"run": [Function],
"traits": Set {
"ZodNumberFormat",
Expand Down Expand Up @@ -204,8 +219,13 @@ exports[`Environment checks > Zod checks/refinements > Snapshot control 'ZodStri
"type": "string",
},
"deferred": [],
"parent": {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"type": "string",
},
"parse": [Function],
"pattern": /\\^\\(\\?!\\\\\\.\\)\\(\\?!\\.\\*\\\\\\.\\\\\\.\\)\\(\\[A-Za-z0-9_'\\+\\\\-\\\\\\.\\]\\*\\)\\[A-Za-z0-9_\\+-\\]@\\(\\[A-Za-z0-9\\]\\[A-Za-z0-9\\\\-\\]\\*\\\\\\.\\)\\+\\[A-Za-z\\]\\{2,\\}\\$/,
"processJSONSchema": [Function],
"run": [Function],
"traits": Set {
"ZodString",
Expand Down
Loading
Loading