Conversation
☁️ Nx Cloud ReportCI is running/has finished running commands for commit 6ab25f5. As they complete they will appear below. Click to see the status, the terminal output, and the build insights. 📂 See all runs for this CI Pipeline Execution ✅ Successfully ran 2 targetsSent with 💌 from NxCloud. |
|
This is great, but it does add a large dependency on Front Matter. For example, you could just do: const User = z.object({
name: z.string().optional().describe(
frontMatter(`
---
title: Name
deprecated: use fullName instead
---
# Name
The name of the thing.
`)
),
fullName: z.string()
})That should give you the same result without adding the dependency to the full library. |
|
Oh, sorry, I didn't see you were mapping frontmatter results out inside your function. |
|
Maybe we can add in an optional parser function option in the LIke: generateSchema(
zodRef: OpenApiZodAny,
useOutput?: boolean,
optionalParsers?: {
describeParser: (zodRef: OpenApiZodAny) => SchemaObject
}
): SchemaObjectThen we can mod the base code similar to how you did. return merge(baseSchema, describeParser?.(zodRef), ...schemas); |
This PR adds support for parsing front-matter in Zod type descriptions. This allows us to propagate metadata from the description into the generated OpenAPI spec. For example:
becomes:
{ "type": "object", "properties": { "name": { "type": "string", "description": "# Name\nThe name of the thing.", "deprecated": true, "x-title": "Name", "x-deprecated": "use fullName instead" }, "fullName": { "type": "string" } }, "required": ["fullName"] }Descriptions that don't include front matter are left intact.