UNPKG

@nuxt/content

Version:

Write your content inside your Nuxt app

27 lines (24 loc) 647 B
import { toJsonSchema } from '@valibot/to-json-schema'; function toJSONSchema(schema, name) { const definitions = toJsonSchema(schema, { overrideSchema(context) { if (context.valibotSchema.type === "date") { return { type: "string", format: "date-time" }; } if (context.valibotSchema.$content) { return { ...context.jsonSchema, $content: context.valibotSchema.$content }; } } }); return { $schema: "http://json-schema.org/draft-07/schema#", $ref: `#/definitions/${name}`, definitions: { [name]: definitions } }; } export { toJSONSchema };