From c1546f0ad8a9f24da0a8d3e3bcf340249c5e1752 Mon Sep 17 00:00:00 2001 From: Gao Sun Date: Sat, 12 Nov 2022 16:39:09 +0800 Subject: [PATCH] fix(core): swagger json --- packages/core/src/utils/zod.ts | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/packages/core/src/utils/zod.ts b/packages/core/src/utils/zod.ts index 3d3b36c55..940fc4ab7 100644 --- a/packages/core/src/utils/zod.ts +++ b/packages/core/src/utils/zod.ts @@ -5,6 +5,7 @@ import { conditional } from '@silverhand/essentials'; import type { OpenAPIV3 } from 'openapi-types'; import type { ZodStringDef } from 'zod'; import { + ZodRecord, ZodArray, ZodBoolean, ZodEffects, @@ -201,6 +202,13 @@ export const zodTypeToSwagger = ( }; } + if (config instanceof ZodRecord) { + return { + type: 'object', + additionalProperties: zodTypeToSwagger(config.valueSchema), + }; + } + if (config instanceof ZodArray) { return { type: 'array',