integration with @hono/zod-openapi
Is your feature request related to a problem? Please describe. we use @hono/zod-openapi. this is create openapi shema by using zod shema. we use prisma, so we use this library. but the generated schema is not compatible with @hono/zod-openapi... Can i request new feature??
I love this library because we need not create schema like template... if new feature is accepted and release, the developer who use cloudflare wokers in edge runtime with hono api will be happy!
duplicate of https://github.com/chrishoermann/zod-prisma-types/issues/276
For anyone else looking to ~~kludge~~ achieve this now, using patch-package:
patches/zod-prisma-types+3.2.4.patch:
diff --git a/node_modules/zod-prisma-types/dist/classes/fileWriter.js b/node_modules/zod-prisma-types/dist/classes/fileWriter.js
index b463964..b637392 100644
--- a/node_modules/zod-prisma-types/dist/classes/fileWriter.js
+++ b/node_modules/zod-prisma-types/dist/classes/fileWriter.js
@@ -39,6 +39,9 @@ class FileWriter {
fs_1.default.writeFileSync(path, this.writer.toString());
}
writeImport(importName, importPath) {
+ if (importPath === 'zod') {
+ importPath = '@hono/zod-openapi';
+ }
this.writer.writeLine(`import ${importName} from '${importPath}';`);
}
writeImportSet(strings) {
diff --git a/node_modules/zod-prisma-types/dist/functions/contentWriters/writeModelOrType.js b/node_modules/zod-prisma-types/dist/functions/contentWriters/writeModelOrType.js
index 3402e82..e97fb23 100644
--- a/node_modules/zod-prisma-types/dist/functions/contentWriters/writeModelOrType.js
+++ b/node_modules/zod-prisma-types/dist/functions/contentWriters/writeModelOrType.js
@@ -55,7 +55,7 @@ const writeModelOrType = ({ fileWriter: { writer, writeImport, writeImportSet, w
if (model.zodCustomErrors) {
writer.write(`, ${model.zodCustomErrors}`);
}
- writer.write(`)`);
+ writer.write(`).openapi('${model.name}');`);
writer
.blankLine()
.write(`export type ${model.name} = z.infer<typeof ${model.name}Schema>`);