Skip to content

Parse .describe as markdown with yaml front matter #131

@razor-x

Description

@razor-x

Parse Zod description as Markdown with YAML front matter: https://jekyllrb.com/docs/front-matter/
This is a well established system for including metadata inside a plain markdown string.

The front matter would be included in the openapi spec as metadata while the body would be used as the description. Some keys can trigger special behavior, for example injecting @deprecated into the generated types.

For example:

const routeSpec = {
  methods: ["POST"],
  auth: "auth_token",
  jsonBody: z.object({
    name: z.string().describe(`
    ---
    deprecated: Use full_name
    ---
    The name of the user.
    `),
    full_name: z.string().describe("The name of the user."),
  }),
  jsonResponse: z.object({
    ok: z.boolean(),
  }),
} as const

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions