You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
autorestic/scripts/generateSchema.ts

18 lines
553 B

import { mkdir, rm, writeFile } from 'node:fs/promises'
import { zodToJsonSchema } from 'zod-to-json-schema'
import { ConfigSchema } from '../src/config/schema/config'
const OUTPUT = './schema'
await rm(OUTPUT, { recursive: true, force: true })
await mkdir(OUTPUT, { recursive: true })
const Schemas = {
config: ConfigSchema,
}
for (const [name, schema] of Object.entries(Schemas)) {
const jsonSchema = zodToJsonSchema(schema, 'mySchema')
await writeFile(`${OUTPUT}/${name}.json`, JSON.stringify(jsonSchema, null, 2), { encoding: 'utf-8' })
}