UNPKG

@nuxt/content

Version:

Write your content inside your Nuxt app

29 lines (25 loc) 688 B
'use strict'; const toJsonSchema = require('@valibot/to-json-schema'); function toJSONSchema(schema, name) { const definitions = toJsonSchema.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 } }; } exports.toJSONSchema = toJSONSchema;