@@ -7,10 +7,12 @@ import {
77 $TemplateDeletedEventV1 ,
88 $TemplateDraftedEventV1 ,
99} from '../src' ;
10- import { keyof , toJSONSchema , type ZodType } from 'zod' ;
10+ import { toJSONSchema , type ZodType } from 'zod' ;
1111import { JSONSchema } from 'zod/v4/core' ;
1212
13- const fixIdFieldInDefs = ( jsonSchema : JSONSchema . JSONSchema ) : JSONSchema . JSONSchema => {
13+ const removeIdFieldFromDefs = (
14+ jsonSchema : JSONSchema . JSONSchema
15+ ) : JSONSchema . JSONSchema => {
1416 const defs = jsonSchema . $defs ?? { } ;
1517
1618 const newDefs = Object . entries ( defs ) . map ( ( [ key , value ] ) => {
@@ -21,9 +23,9 @@ const fixIdFieldInDefs = (jsonSchema: JSONSchema.JSONSchema): JSONSchema.JSONSch
2123
2224 return {
2325 ...jsonSchema ,
24- ' $defs' : Object . fromEntries ( newDefs ) ,
26+ $defs : Object . fromEntries ( newDefs ) ,
2527 } ;
26- }
28+ } ;
2729
2830// Converts Zod Schema to JSON Schema and writes to JSON file
2931function writeSchema (
@@ -37,15 +39,13 @@ function writeSchema(
3739
3840 const jsonSchema = toJSONSchema ( schema , { io : 'input' } ) ;
3941
40-
41-
4242 const outPath = path . resolve ( outDir , `v${ majorVersion } .json` ) ;
4343 fs . writeFileSync (
4444 outPath ,
4545 `${ JSON . stringify (
4646 {
47- ...fixIdFieldInDefs ( jsonSchema ) ,
48- ' $id' : id ,
47+ ...removeIdFieldFromDefs ( jsonSchema ) ,
48+ $id : id ,
4949 } ,
5050 null ,
5151 2
0 commit comments