diff --git a/packages/zod/src/index.ts b/packages/zod/src/index.ts index 7a743784d..f959013d4 100644 --- a/packages/zod/src/index.ts +++ b/packages/zod/src/index.ts @@ -9,7 +9,9 @@ import { GeneratorMutator, GeneratorOptions, GeneratorVerbOptions, + getFileInfo, getNumberWord, + getRefInfo, isBoolean, isObject, isString, @@ -556,8 +558,15 @@ const deference = ( childContext, ); + const { specKey } = getRefInfo(refName ?? '', context); + + const resolvedContext: ContextSpecs = { + ...childContext, + specKey: specKey ?? childContext.specKey, + }; + return Object.entries(resolvedSchema).reduce((acc, [key, value]) => { - acc[key] = deferenceScalar(value, childContext); + acc[key] = deferenceScalar(value, resolvedContext); return acc; }, {} as any); };