Replies: 2 comments 2 replies
-
|
We use Zod’s built-in |
Beta Was this translation helpful? Give feedback.
0 replies
-
|
It appears so. A simple testbed of Zod 4.3.6 and the following code: import * as z from "zod";
const testSchema = z
.object({
title: z.string().meta({
title: "Title",
description: "This is a cool description",
}),
})
.meta({
markdown: true,
});
const schema = z.toJSONSchema(testSchema);
console.log(schema);log the following JSON Schema: {
'$schema': 'https://json-schema.org/draft/2020-12/schema',
type: 'object',
properties: {
title: {
type: 'string',
title: 'Title',
description: 'This is a cool description'
}
},
required: [ 'title' ],
additionalProperties: false,
markdown: true
} |
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Body
Summary
With Astro 6, the
.metaproperty for chain opens up lots of possibilities for programatic management of collection content. However, it doesn't appear to render out when added t the top-level schema object, which is unfortunate as it prevents us from being able to add meta-information to the schema as a whole. It'd be great if that could be supportedBackground & Motivation
I'm building a CMS built on the JSON Schema that content collections outputs, but given that there are different loaders (JSON, MD, MDX, etc…), I'd like to be able to pass meta information about the actual schema to properly configure the UI. For instance, JSON loaders wouldn't offer a body area, whereas MD loaders would.
Goals
metaproperties directly onto the top-level object of a content collection's JSON Schema, like it does today for everything else.Example
Input
Output
{ "$schema": "https://json-schema.org/draft/2020-12/schema", "type": "object", "body": true, "properties": { "title": { "type": "string" }, "date": { "type": "string", "format": "date-time" }, "draft": { "type": "boolean" }, "author": { "anyOf": [ { "type": "string" }, { "type": "object", "properties": { "id": { "type": "string" }, "collection": { "type": "string" } }, "required": [ "id", "collection" ] }, { "type": "object", "properties": { "slug": { "type": "string" }, "collection": { "type": "string" } }, "required": [ "slug", "collection" ] } ] }, "$schema": { "type": "string" } }, "required": [ "title", "date", "author" ] }The linked schema desn't appear to have a way of adding extensions like this, is there another schema that would allow this?
Beta Was this translation helpful? Give feedback.
All reactions