3 ms·
But that’s the whole point of something like this. You do it once and dynamically generate everything else downstream. So change it once in the zod schema and i
by koolba 1y ago
But that’s the whole point of something like this. You do it once and dynamically generate everything else downstream. So change it once in the zod schema and it propagates with type checking through your entire app.
The zod schema becomes the source of truth.
- worldsayshi 1y agoDoes zod really support that? What if the code base start out with a go backend and a TS/JS component is only added later? It would be nice if the source of truth was a bit more language agnostic.
- oxidant 1y agoBetter to use something like OpenApi and generate your zod schema using it.
- crabmusket 1y agoAnd thus is born the 15th IDL for cross language API calls...
- esafak 1y agoDoes it? I don't use Zod on my JVM backend. How would I? In addition to using OpenAPI, I generate TS interfaces from my data classes in a Gradle task.
- skybrian 1y agoOne way might be to convert the Zod schema to a JSON schema and then to Java? I found a library to do that. [1] But I don’t know how lossy that would be. A purpose-built converter might do better. [1] https://jsontypedef.com/docs/java-codegen/ https://jsontypedef.com/docs/java-codegen/
- presentation 1y agoLooks like there are libraries for generating zod schemas from OpenAPI definitions and others. https://zod.dev/ecosystem?id=x-to-zod https://zod.dev/ecosystem?id=x-to-zod
- kellengreen 1y agoDoes it? Most Go, Java, and Python APIs are practically all Swagger based.