Skip to content

Commit fc5032f

Browse files
committed
Ref: unref once.
1 parent 5bf7c0f commit fc5032f

File tree

2 files changed

+4
-5
lines changed

2 files changed

+4
-5
lines changed

express-zod-api/src/documentation-helpers.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,6 @@ const isSupportedType = (subject: string): subject is SchemaObjectType =>
204204
export const onDateIn: Overrider = ({ jsonSchema }, ctx) => {
205205
if (ctx.isResponse)
206206
throw new DocumentationError("Please use ez.dateOut() for output.", ctx);
207-
unref(jsonSchema);
208207
delete jsonSchema.anyOf; // undo default
209208
Object.assign(jsonSchema, {
210209
description: "YYYY-MM-DDTHH:mm:ss.sssZ",
@@ -299,7 +298,6 @@ export const onPipeline: Overrider = ({ zodSchema, jsonSchema }, ctx) => {
299298
};
300299

301300
export const onRaw: Overrider = ({ jsonSchema }) => {
302-
unref(jsonSchema);
303301
if (jsonSchema.type !== "object") return;
304302
const objSchema = jsonSchema as JSONSchema.ObjectSchema;
305303
if (!objSchema.properties) return;
@@ -500,6 +498,7 @@ const depict = (
500498
unrepresentable: "any",
501499
io: ctx.isResponse ? "output" : "input",
502500
override: (zodCtx) => {
501+
unref(zodCtx.jsonSchema);
503502
const { brand } =
504503
globalRegistry.get(zodCtx.zodSchema)?.[metaSymbol] ?? {};
505504
rules[

express-zod-api/tests/__snapshots__/documentation.spec.ts.snap

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2307,15 +2307,15 @@ paths:
23072307
required: true
23082308
description: GET /v1/:name Parameter
23092309
schema:
2310-
summary: My custom schema
23112310
type: string
2311+
summary: My custom schema
23122312
- name: other
23132313
in: query
23142314
required: true
23152315
description: GET /v1/:name Parameter
23162316
schema:
2317-
summary: My custom schema
23182317
type: boolean
2318+
summary: My custom schema
23192319
- name: regular
23202320
in: query
23212321
required: true
@@ -2336,8 +2336,8 @@ paths:
23362336
type: object
23372337
properties:
23382338
number:
2339-
summary: My custom schema
23402339
type: number
2340+
summary: My custom schema
23412341
required:
23422342
- number
23432343
required:

0 commit comments

Comments
 (0)