Skip to content

Commit c48deb2

Browse files
authored
Update unknown type error message for ZodEffects (#17)
1 parent 6b1051e commit c48deb2

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

src/create/schema/unknown.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,14 @@ export const createUnknownSchema = <
1010
): oas31.SchemaObject => {
1111
if (!zodSchema._def.openapi?.type) {
1212
const zodType = zodSchema.constructor.name;
13-
const schemaName =
14-
zodSchema instanceof ZodEffects
15-
? `${zodType} - ${zodSchema._def.effect.type}`
16-
: zodType;
13+
if (zodSchema instanceof ZodEffects) {
14+
const schemaName = `${zodType} - ${zodSchema._def.effect.type}`;
15+
throw new Error(
16+
`Unknown schema ${schemaName}. Please assign it a manual 'type', wrap it in a ZodPipeline or change the 'effectType'.`,
17+
);
18+
}
1719
throw new Error(
18-
`Unknown schema ${schemaName}. Please assign it a manual type ${
19-
zodSchema instanceof ZodEffects ? 'or wrap it in a ZodPipeline' : ''
20-
}`,
20+
`Unknown schema ${zodType}. Please assign it a manual 'type'.`,
2121
);
2222
}
2323

0 commit comments

Comments
 (0)