You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This week i got a task that involves a lot of API testing with different versions of the same JSON body, i thought of a VSCODE extension that generates JSON body from a zod schema, didnt find any, then i started coding my own extension, my extension repo. I got it working with simple "primitive" schemas such as z.object({id: z.number(), name: z.string()}) but when it comes to nested schemas i started getting in trouble because of the many ways we can import stuff in TS. I tried a lot of deepseek generated code to make it work, if it is a skill issue please let me know. I'm planning on contributing to zod with this method if noone is doing it already, if i was not clear enough please let me know. Here's the idea:
my current version of the extension works with this schema (there's no nested schema)
but when i need to generate a JSON body from a schema that contains a nested schema i would need the method .resolveSchema() (or something like this) to get it as a another z.object...
import { z } from 'zod';
import { UserPartialSchema } from '../../User';
export const BirthdaySchema = z.object({
idSync: z.string(),
farmIdSync: z.string(),
componentType: z.literal('birthday'),
name: z.string(),
email: z.string().nullable(),
phone: z.string().nullable(),
birthDate: z.string().datetime(),
createdBy: UserPartialSchema,
});
export type BirthdayDto = z.infer<typeof BirthdaySchema>;
in this schema i would call the method to resolve it's shape at runtime so i could mock it on the extension side.
The text was updated successfully, but these errors were encountered:
This week i got a task that involves a lot of API testing with different versions of the same JSON body, i thought of a VSCODE extension that generates JSON body from a zod schema, didnt find any, then i started coding my own extension, my extension repo. I got it working with simple "primitive" schemas such as
z.object({id: z.number(), name: z.string()})
but when it comes to nested schemas i started getting in trouble because of the many ways we can import stuff in TS. I tried a lot of deepseek generated code to make it work, if it is a skill issue please let me know. I'm planning on contributing to zod with this method if noone is doing it already, if i was not clear enough please let me know. Here's the idea:my current version of the extension works with this schema (there's no nested schema)
but when i need to generate a JSON body from a schema that contains a nested schema i would need the method
.resolveSchema()
(or something like this) to get it as a another z.object...in this schema i would call the method to resolve it's shape at runtime so i could mock it on the extension side.
The text was updated successfully, but these errors were encountered: