### Configuration File: ESM Example
Source: https://context7.com/matejchalk/zod2md/llms.txt
Example of a zod2md configuration file using plain ESM. This is useful when not using TypeScript in your configuration.
```js
// zod2md.config.mjs (plain ESM, no TypeScript)
/** @type {import('zod2md').Config} */
export default {
title: 'Prettier configuration file reference',
entry: 'prettierrc.js',
format: 'esm',
output: 'docs/prettier.md',
};
```
--------------------------------
### Configuration File: TypeScript Example
Source: https://context7.com/matejchalk/zod2md/llms.txt
Example of a zod2md configuration file using TypeScript. Define entry points, title, output path, and optional settings like tsconfig and format.
```ts
// zod2md.config.ts (TypeScript, recommended)
import type { Config } from 'zod2md';
const config: Config = {
// Required: one or more entry files exporting Zod schemas
entry: ['src/models.ts', 'src/endpoints/index.ts'],
// Required: top-level heading in the generated Markdown
title: 'User REST API',
// Required: output path (directories are created recursively)
output: 'docs/api-reference.md',
// Optional: path to tsconfig used when bundling the entry files
tsconfig: 'tsconfig.build.json',
// Optional: 'esm' | 'cjs' — module format for entry file import
format: 'esm',
// Optional: custom function to derive section headings from schema names
transformName: (name, filePath, schema) => {
// name – exported variable name (undefined for default exports)
// path – resolved file path of the entry module
// schema – the Zod v3 or v4 schema instance
return name?.replace(/Schema$/, '') ?? 'Unknown';
},
};
export default config;
```
--------------------------------
### Full End-to-End Example: User REST API
Source: https://context7.com/matejchalk/zod2md/llms.txt
Demonstrates defining Zod schemas for a REST API and generating Markdown documentation using a configuration file with zod2md.
```APIDOC
## Full End-to-End Example: User REST API
Defining Zod schemas for a REST API and generating Markdown documentation with a config file.
```ts
// src/models.ts
import { z } from 'zod/v4';
export const Username = z.string().regex(/^[a-z][a-z\d.]*$/);
export const User = z.object({
username: Username,
email: z.email(),
firstName: z.string().optional(),
lastName: z.string().optional(),
});
```
```ts
// src/endpoints/get-users.ts
import { z } from 'zod/v4';
import { User } from '../models';
export const GetUsersParams = z.object({
page: z.number().int().min(1).default(1),
pageSize: z.number().int().min(0).max(100).default(30),
});
export const GetUsersResponse = z.object({
users: z.array(User),
});
```
```ts
// src/endpoints/create-user.ts
import { z } from 'zod/v4';
import { User } from '../models';
export const CreateUserParams = z.object({
...User.shape,
password: z.string().min(6),
});
export const CreateUserResponse = User;
```
```js
// zod2md.config.mjs
/** @type {import('zod2md').Config} */
export default {
title: 'User REST API',
entry: [
'./src/endpoints/get-users.ts',
'./src/endpoints/create-user.ts',
],
output: 'docs/user-api.md',
};
```
```sh
npx zod2md
# 🚀 Generated Markdown docs in docs/user-api.md
```
The resulting `docs/user-api.md`:
```md
# User REST API
## GetUsersParams
_Object containing the following properties:_
| Property | Type | Default |
| :--------- | :------------------------- | :------ |
| `page` | `number` (_int, ≥1_) | `1` |
| `pageSize` | `number` (_int, ≥0, ≤100_) | `30` |
_All properties are optional._
## GetUsersResponse
_Object containing the following properties:_
| Property | Type |
| :--------------- | :-------------------------------------------------- |
| **`users`** (*) | _Array of_ [User](#user) _items_ |
_(\*)
Required._
## CreateUserParams
_Object containing the following properties:_
| Property | Type |
| :------------------ | :--------------------------------------- |
| **`username`** (*) | `string` (_regex: `/^[a-z][a-z\d.]*$/`_) |
| **`email`** (*) | `string` (_email_) |
| `firstName` | `string` |
| `lastName` | `string` |
| **`password`** (*) | `string` (_min length: 6_) |
_(\*)
Required._
## CreateUserResponse
_Object containing the following properties:_
| Property | Type |
| :------------------ | :--------------------------------------- |
| **`username`** (*) | `string` (_regex: `/^[a-z][a-z\d.]*$/`_) |
| **`email`** (*) | `string` (_email_) |
| `firstName` | `string` |
| `lastName` | `string` |
_(\*)
Required._
```
```
--------------------------------
### Install zod2md CLI
Source: https://github.com/matejchalk/zod2md/blob/main/README.md
Install the zod2md package as a development dependency using npm.
```sh
npm install --save-dev zod2md
```
--------------------------------
### Zod Function Schema Usage Example
Source: https://github.com/matejchalk/zod2md/blob/main/README.md
Example demonstrating the usage of the `convertZodFunctionToSchema` helper to define a predicate schema with string and number inputs and a boolean output.
```typescript
export const predicateSchema = convertZodFunctionToSchema(
z.function({ input: [z.string(), z.number()], output: z.boolean() }),
);
```
--------------------------------
### Get Users
Source: https://github.com/matejchalk/zod2md/blob/main/e2e/__snapshots__/user-rest-api-example.md
Retrieves a list of users, with optional pagination parameters.
```APIDOC
## GET /users
### Description
Retrieves a list of users. Supports pagination via query parameters.
### Method
GET
### Endpoint
/users
### Parameters
#### Query Parameters
- **page** (number) - Optional - The page number to retrieve (default: 1, minimum: 1).
- **pageSize** (number) - Optional - The number of users per page (default: 30, minimum: 0, maximum: 100).
### Response
#### Success Response (200)
- **users** (Array of objects) - Required - A list of user objects.
- **username** (string) - Required - The user's unique username.
- **email** (string) - Required - The user's email address.
- **firstName** (string) - Optional - The user's first name.
- **lastName** (string) - Optional - The user's last name.
### Response Example
{
"users": [
{
"username": "johndoe",
"email": "john.doe@example.com",
"firstName": "John",
"lastName": "Doe"
}
]
}
```
--------------------------------
### Get User by Username
Source: https://github.com/matejchalk/zod2md/blob/main/e2e/__snapshots__/user-rest-api-example.md
Retrieves a specific user's details by their username.
```APIDOC
## GET /users/{username}
### Description
Retrieves a specific user's details using their username.
### Method
GET
### Endpoint
/users/{username}
### Parameters
#### Path Parameters
- **username** (string) - Required - The username of the user to retrieve.
### Response
#### Success Response (200)
- **username** (string) - Required - The user's unique username.
- **email** (string) - Required - The user's email address.
- **firstName** (string) - Optional - The user's first name.
- **lastName** (string) - Optional - The user's last name.
### Response Example
{
"username": "johndoe",
"email": "john.doe@example.com",
"firstName": "John",
"lastName": "Doe"
}
```
--------------------------------
### Get Users Endpoint Schemas
Source: https://context7.com/matejchalk/zod2md/llms.txt
Defines the request parameters and response structure for the 'get users' API endpoint.
```typescript
// src/endpoints/get-users.ts
import { z } from 'zod/v4';
import { User } from '../models';
export const GetUsersParams = z.object({
page: z.number().int().min(1).default(1),
pageSize: z.number().int().min(0).max(100).default(30),
});
export const GetUsersResponse = z.object({
users: z.array(User),
});
```
--------------------------------
### Custom Name Transformation Function
Source: https://context7.com/matejchalk/zod2md/llms.txt
Implement `NameTransformFn` to customize schema name generation. The default transform handles suffixes, casing, and Zod v4 metadata. Examples show prefixing names and using Zod v4 descriptions.
```typescript
import type { NameTransformFn } from 'zod2md';
import { z } from 'zod/v4';
// Default behavior examples:
// 'userSchema' → 'User'
// 'uploadConfigSchema' → 'UploadConfig'
// undefined, 'src/user.ts' → 'User'
// undefined, 'schemas/log-entry.mjs' → 'LogEntry'
// z.object({}).meta({ title: 'CoreConfig' }) → 'CoreConfig' (Zod v4)
// Custom transform: prefix all names with "API."
const prefixTransform: NameTransformFn = (name, filePath, schema) => {
const base = name ?? filePath.split('/').at(-1)?.replace(/\.\w+$/, '') ?? '';
return `API.${base}`;
};
// Custom transform: use Zod v4 description as the heading
import * as z4core from 'zod/v4/core';
const descriptionTransform: NameTransformFn = (name, filePath, schema) => {
if (schema instanceof z4core.$ZodType) {
const meta = z4core.globalRegistry.get(schema);
if (meta?.description) return meta.description;
}
return name ?? 'Unknown';
};
// Usage in config
const config = {
entry: 'src/schemas.ts',
title: 'Docs',
output: 'docs/api.md',
transformName: prefixTransform,
};
```
--------------------------------
### CLI Usage: Point to Config File
Source: https://context7.com/matejchalk/zod2md/llms.txt
Use the CLI to point to an explicit configuration file. This allows for more complex configurations to be managed separately.
```sh
npx zod2md --config ./configs/zod2md.config.ts
```
--------------------------------
### Create User
Source: https://github.com/matejchalk/zod2md/blob/main/e2e/__snapshots__/user-rest-api-example.md
Creates a new user with the provided details.
```APIDOC
## POST /users
### Description
Creates a new user. Requires username, email, and password.
### Method
POST
### Endpoint
/users
### Parameters
#### Request Body
- **username** (string) - Required - The desired username for the new user.
- **email** (string) - Required - The email address for the new user.
- **firstName** (string) - Optional - The first name of the user.
- **lastName** (string) - Optional - The last name of the user.
- **password** (string) - Required - The user's password (minimum length of 6).
### Request Example
{
"username": "janedoe",
"email": "jane.doe@example.com",
"firstName": "Jane",
"lastName": "Doe",
"password": "securepassword123"
}
### Response
#### Success Response (201)
- **username** (string) - Required - The username of the newly created user.
- **email** (string) - Required - The email address of the newly created user.
- **firstName** (string) - Optional - The first name of the newly created user.
- **lastName** (string) - Optional - The last name of the newly created user.
### Response Example
{
"username": "janedoe",
"email": "jane.doe@example.com",
"firstName": "Jane",
"lastName": "Doe"
}
```
--------------------------------
### CLI Usage: Display Help
Source: https://context7.com/matejchalk/zod2md/llms.txt
Display the help message for the zod2md CLI, showing all available options and commands.
```sh
npx zod2md --help
```
--------------------------------
### Programmatic API: Multiple Entry Files and Custom Transform
Source: https://context7.com/matejchalk/zod2md/llms.txt
Generate API documentation from multiple entry files using the programmatic API. Customize the naming of sections using the `transformName` option.
```ts
// Multiple entry files + custom name transform
const apiDocs = await zod2md({
entry: [
'src/endpoints/get-users.ts',
'src/endpoints/create-user.ts',
],
title: 'API Reference',
transformName: (name, filePath) => {
// strip "Params" / "Response" suffix for cleaner headings
return name?.replace(/(Params|Response)$/, '') ?? path.basename(filePath);
},
});
```
--------------------------------
### Run zod2md CLI with arguments
Source: https://github.com/matejchalk/zod2md/blob/main/README.md
Execute the zod2md CLI with required arguments for entry point, title, and output path.
```sh
npx zod2md --entry src/schemas.ts --title "Models reference" --output docs/models.md
```
--------------------------------
### Config
Source: https://github.com/matejchalk/zod2md/blob/main/src/formatter/__snapshots__/config.md
Represents the complete configuration, combining input and output settings. The input configuration is mandatory.
```APIDOC
## Config
_Object containing the following properties:_
| Property | Type |
| :--------------- | :---------------------------- |
| **`input`** (\*)| [InputConfig](#inputconfig) |
| `output` | [OutputConfig](#outputconfig) |
_(\*). Required._
```
--------------------------------
### CLI Usage: Single Entry File
Source: https://context7.com/matejchalk/zod2md/llms.txt
Use the CLI to generate Markdown from a single Zod schema entry file. Specify the entry file, a title for the document, and the output path.
```sh
npx zod2md --entry src/schemas.ts --title "Models Reference" --output docs/models.md
```
--------------------------------
### CLI Usage: Multiple Entry Files
Source: https://context7.com/matejchalk/zod2md/llms.txt
Generate Markdown from multiple Zod schema entry files by repeating the --entry flag. This is useful for organizing documentation for different parts of an API or application.
```sh
npx zod2md \
--entry src/endpoints/get-users.ts \
--entry src/endpoints/create-user.ts \
--title "User REST API" \
--output docs/api.md
```
--------------------------------
### Run Zod2md CLI
Source: https://context7.com/matejchalk/zod2md/llms.txt
Command to execute zod2md to generate Markdown documentation from the specified entry points.
```sh
npx zod2md
# 🚀 Generated Markdown docs in docs/user-api.md
```
--------------------------------
### InputConfig
Source: https://github.com/matejchalk/zod2md/blob/main/src/formatter/__snapshots__/config.md
Defines the input configuration for the process. It specifies the entry point and optionally a tsconfig file path.
```APIDOC
## InputConfig
_Object containing the following properties:_
| Property | Type |
| :--------------- | :------- |
| **`entry`** (\*)| `string` |
| `tsconfig` | `string` |
_(\*). Required._
```
--------------------------------
### zod2md Configuration File
Source: https://github.com/matejchalk/zod2md/blob/main/README.md
Create a zod2md.config.ts file to configure the tool. This allows running `npx zod2md` without arguments.
```typescript
import type { Config } from 'zod2md';
const config: Config = {
entry: 'src/schemas.ts',
title: 'Models reference',
output: 'docs/models.md',
};
export default config;
```
--------------------------------
### PromptConfig
Source: https://github.com/matejchalk/zod2md/blob/main/e2e/__snapshots__/commitlint-example-v3.md
Defines the configuration structure for prompts, including settings, messages, and questions for commit message generation.
```APIDOC
## PromptConfig
_Object containing the following properties:_
| Property | Type |
| :------------------- | :----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| **`settings`** (\*)
| _Object with properties:
scopeEnumSeparator (\*): stringenableMultipleScopes (\*): boolean
|
| **`messages`** (\*)
| [PromptMessages](#promptmessages) |
| **`questions`** (\*)
| _Object with dynamic keys of type_ [PromptName](#promptname) _and values of type_ _Object with properties:_description: stringmessages: Recordenum: Object with dynamic keys of type string and values of type Object with properties:description: stringtitle: stringemoji: string
_(\*). Required._
```
--------------------------------
### OutputConfig
Source: https://github.com/matejchalk/zod2md/blob/main/src/formatter/__snapshots__/config.md
Defines the output configuration for the process. It allows specifying the output directory, file format, and whether to clear existing files.
```APIDOC
## OutputConfig
_Object containing the following properties:_
| Property | Type |
| :---------- | :--------------- |
| `directory` | `string` |
| `format` | `'md' | 'html'` |
| `clear` | `boolean` |
_All properties are optional._
```
--------------------------------
### PromptName
Source: https://github.com/matejchalk/zod2md/blob/main/e2e/__snapshots__/commitlint-example-v3.md
Enum representing the possible names for prompts in commitlint configuration.
```APIDOC
## PromptName
_Enum, one of the following possible values:_
- `'header'`
- `'type'`
- `'scope'`
- `'subject'`
- `'body'`
- `'footer'`
- `'isBreaking'`
- `'breakingBody'`
- `'breaking'`
- `'isIssueAffected'`
- `'issuesBody'`
- `'issues'`
```
--------------------------------
### Programmatic API: Generate Markdown String
Source: https://context7.com/matejchalk/zod2md/llms.txt
Use the programmatic API to generate a Markdown string from Zod schemas. This function does not write to disk, allowing manual file I/O.
```ts
import { zod2md } from 'zod2md';
import { writeFile, mkdir } from 'node:fs/promises';
import path from 'node:path';
// Generate Markdown string from a single entry file
const markdown = await zod2md({
entry: 'src/schemas.ts',
title: 'Models Reference',
});
// Write to disk manually
const outputPath = 'docs/models.md';
await mkdir(path.dirname(outputPath), { recursive: true });
await writeFile(outputPath, markdown);
console.log(markdown);
/*
# Models Reference
## User
_Object containing the following properties:_
| Property | Type |
| :------------------ | :--------------------------------------- |
| **`username`** (\*)
| `string` (_regex: `/^[a-z][a-z\d.]*$/`_) |
| **`email`** (\*)
| `string` (_email_) |
| `firstName` | `string` |
| `lastName` | `string` |
_(\*)
Required._
*/
```
--------------------------------
### Create User Endpoint Schemas
Source: https://context7.com/matejchalk/zod2md/llms.txt
Defines the request parameters and response structure for the 'create user' API endpoint.
```typescript
// src/endpoints/create-user.ts
import { z } from 'zod/v4';
import { User } from '../models';
export const CreateUserParams = z.object({
...User.shape,
password: z.string().min(6),
});
export const CreateUserResponse = User;
```
--------------------------------
### CLI Usage: Custom tsconfig and Module Format
Source: https://context7.com/matejchalk/zod2md/llms.txt
Specify a custom tsconfig file and module format (e.g., 'esm') when using the CLI. This ensures correct parsing of TypeScript files and module resolution.
```sh
npx zod2md \
--entry src/schemas.ts \
--title "Schemas" \
--output docs/schemas.md \
--tsconfig tsconfig.build.json \
--format esm
```
--------------------------------
### PromptMessages
Source: https://github.com/matejchalk/zod2md/blob/main/e2e/__snapshots__/commitlint-example-v3.md
Defines the structure for prompt messages, including skip, max, min, and various warning messages.
```APIDOC
## PromptMessages
_Intersection of the following types:_
- _Object with properties:_
- **`skip`** (\*): `string`
- **`max`** (\*): `string`
- **`min`** (\*): `string`
- **`emptyWarning`** (\*): `string`
- **`upperLimitWarning`** (\*): `string`
- **`lowerLimitWarning`** (\*): `string`
- `Record`
```
--------------------------------
### zod2md Configuration Types
Source: https://context7.com/matejchalk/zod2md/llms.txt
The `Config` and `Options` types are exported for programmatic use. `Config` includes a required `output` path, while `Options` contains loader and formatter settings.
```typescript
import type { Config, Options } from 'zod2md';
// Options = LoaderOptions & FormatterOptions
// Config = Options & { output: string }
// LoaderOptions
type LoaderOptions = {
entry: string | string[]; // path(s) to Zod schema modules
tsconfig?: string; // tsconfig.json for TypeScript compilation
format?: 'esm' | 'cjs'; // module format override
};
// FormatterOptions
type FormatterOptions = {
title: string; // document heading (h1)
transformName?: (
name: string | undefined,
path: string,
schema: ZodType,
) => string;
};
// Usage example: build options dynamically
function buildConfig(env: 'staging' | 'prod'): Config {
const base: Options = {
entry: 'src/schemas.ts',
title: `API Reference (${env})`,
format: 'esm',
};
return { ...base, output: `docs/${env}/api.md` };
}
```
--------------------------------
### User Model Schema
Source: https://context7.com/matejchalk/zod2md/llms.txt
Defines the basic structure for a User object, including username, email, and optional first/last names.
```typescript
// src/models.ts
import { z } from 'zod/v4';
export const Username = z.string().regex(/^[a-z][a-z\d.]*$/);
export const User = z.object({
username: Username,
email: z.email(),
firstName: z.string().optional(),
lastName: z.string().optional(),
});
```
--------------------------------
### Zod2md Configuration
Source: https://context7.com/matejchalk/zod2md/llms.txt
Configuration file for zod2md to generate Markdown documentation for the User REST API.
```javascript
// zod2md.config.mjs
/** @type {import('zod2md').Config} */
export default {
title: 'User REST API',
entry: [
'./src/endpoints/get-users.ts',
'./src/endpoints/create-user.ts',
],
output: 'docs/user-api.md',
};
```
--------------------------------
### RulesConfig
Source: https://github.com/matejchalk/zod2md/blob/main/e2e/__snapshots__/commitlint-example-v3.md
Configuration object for commitlint rules, where keys are rule names and values are RuleConfigTuple.
```APIDOC
## RulesConfig
_Object with dynamic keys:_
- _keys of type_ `string`
- _values of type_ [RuleConfigTuple](#ruleconfigtuple)
```
--------------------------------
### Format Zod Schemas to Markdown
Source: https://context7.com/matejchalk/zod2md/llms.txt
Use `formatSchemasAsMarkdown` to convert Zod schemas into Markdown strings. It accepts an array of schema objects or a plain record of schemas. Useful for in-memory schema conversion without file system access.
```typescript
import { formatSchemasAsMarkdown } from 'zod2md';
import { z } from 'zod';
// Pass an array of ExportedSchema objects
const markdown = formatSchemasAsMarkdown(
[
{
name: 'CreateUserParams',
schema: z.object({
username: z.string().regex(/^[a-z][a-z\d.]*$/),
email: z.string().email(),
password: z.string().min(6),
}),
path: 'src/schemas.ts',
},
{
name: 'GetUsersParams',
schema: z.object({
page: z.number().int().min(1).default(1),
pageSize: z.number().int().min(0).max(100).default(30),
}),
path: 'src/schemas.ts',
},
],
{ title: 'API Schemas' },
);
// Or pass a plain record (name → schema), useful for inline schema maps
const markdownFromRecord = formatSchemasAsMarkdown(
{
Status: z.enum(['active', 'inactive', 'pending']),
Priority: z.union([z.literal('low'), z.literal('medium'), z.literal('high')]),
},
{ title: 'Enums' },
);
console.log(markdown);
```
--------------------------------
### RuleConfigTuple
Source: https://github.com/matejchalk/zod2md/blob/main/e2e/__snapshots__/commitlint-example-v3.md
Represents a rule configuration tuple, which can be a severity level, or a severity level with a condition, optionally with an unknown third element.
```APIDOC
## RuleConfigTuple
_Union of the following possible types:_
- `[0]`
- _Tuple:_
1. [RuleConfigSeverity](#ruleconfigseverity)
2. [RuleConfigCondition](#ruleconfigcondition)
- _Tuple:_
1. [RuleConfigSeverity](#ruleconfigseverity)
2. [RuleConfigCondition](#ruleconfigcondition)
3. `unknown`
_Readonly._
```
--------------------------------
### Convert Zod Function to Schema Helper
Source: https://github.com/matejchalk/zod2md/blob/main/README.md
This helper function is necessary for defining function schemas as in Zod v3, due to changes in Zod v4. It uses metadata to enable zod2md to find input/output schemas.
```typescript
import { z } from 'zod/v4';
import type { $ZodFunction } from 'zod/v4/core';
export function convertZodFunctionToSchema(factory: T) {
return z
.custom()
.transform((arg, ctx) => {
// 👇 runtime validation
if (typeof arg !== 'function') {
ctx.addIssue('Must be a function');
return z.NEVER;
}
return factory.implement(arg as Parameters[0]); // 👈 compile-time validation
})
.meta({
$ZodFunction: factory, // 👈 this metadata enables zod2md to find your input/output schemas
});
}
```
--------------------------------
### Zod v4 Function Schema Workaround
Source: https://context7.com/matejchalk/zod2md/llms.txt
Demonstrates the `convertZodFunctionToSchema` helper for documenting Zod functions in v4, which no longer has a direct `z.function()` type. This helper uses custom metadata to inform zod2md.
```APIDOC
## Zod v4 Function Schema Workaround (`convertZodFunctionToSchema`)
Since Zod v4 removed `z.function()` as a schema type, `zod2md` supports function documentation via a `$ZodFunction` metadata key. The helper below is the recommended pattern for preserving function input/output schema introspection.
```ts
// helpers/zod-function.ts
import { z } from 'zod/v4';
import type { $ZodFunction } from 'zod/v4/core';
export function convertZodFunctionToSchema(factory: T) {
return z
.custom()
.transform((arg, ctx) => {
if (typeof arg !== 'function') {
ctx.addIssue('Must be a function');
return z.NEVER;
}
return factory.implement(arg as Parameters[0]);
})
.meta({
$ZodFunction: factory, // ← tells zod2md to render as a function schema
});
}
// src/schemas.ts
import { z } from 'zod/v4';
import { convertZodFunctionToSchema } from './helpers/zod-function';
import { Commit } from './models';
// A "Rule" function: (commit, condition?, never?) => RuleOutcome | Promise
export const RuleOutcome = z.tuple([z.boolean(), z.string().optional()]).readonly();
export const RuleConfigCondition = z.enum(['always', 'never']);
export const Rule = convertZodFunctionToSchema(
z.function({
input: [Commit, RuleConfigCondition.optional(), z.never().optional()],
output: z.union([RuleOutcome, z.promise(RuleOutcome)]),
}),
);
// zod2md will render "Rule" as a function type with parameters and return value.
```
```
--------------------------------
### RuleConfigCondition
Source: https://github.com/matejchalk/zod2md/blob/main/e2e/__snapshots__/commitlint-example-v3.md
Enum defining the condition for a rule, either 'always' or 'never'.
```APIDOC
## RuleConfigCondition
_Enum, one of the following possible values:_
- `'always'`
- `'never'`
```
--------------------------------
### Rule
Source: https://github.com/matejchalk/zod2md/blob/main/e2e/__snapshots__/commitlint-example-v3.md
Represents a commitlint rule function that validates commit messages.
```APIDOC
## Rule
_Function._
_Parameters:_
1. [Commit](#commit)
2. [RuleConfigCondition](#ruleconfigcondition)
3. `never` (_optional_)
_Return value:_
- [RuleOutcome](#ruleoutcome) _or_ _Promise of:_ [RuleOutcome](#ruleoutcome)
```
--------------------------------
### RuleOutcome
Source: https://github.com/matejchalk/zod2md/blob/main/e2e/__snapshots__/commitlint-example-v3.md
Represents the outcome of a rule execution, a boolean indicating success or failure, optionally with a string message.
```APIDOC
## RuleOutcome
_Tuple, array of 2 items:_
1. `boolean`
2. `string` (_optional_)
_Readonly._
```
--------------------------------
### RuleConfigSeverity
Source: https://github.com/matejchalk/zod2md/blob/main/e2e/__snapshots__/commitlint-example-v3.md
Enum representing the severity level of a rule: Disabled, Warning, or Error.
```APIDOC
## RuleConfigSeverity
_Native enum:_
| Key | Value |
| :--------- | ----: |
| `Disabled` | `0` |
| `Warning` | `1` |
| `Error` | `2` |
```
--------------------------------
### Programmatic Usage of zod2md
Source: https://github.com/matejchalk/zod2md/blob/main/README.md
Import and use the zod2md function directly within your code to generate Markdown strings.
```typescript
import { zod2md } from 'zod2md';
const markdown = await zod2md({
entry: 'src/schemas.ts',
title: 'Models reference',
});
```
--------------------------------
### Update User
Source: https://github.com/matejchalk/zod2md/blob/main/e2e/__snapshots__/user-rest-api-example.md
Updates an existing user's details. Requires username and payload with updatable fields.
```APIDOC
## PUT /users/{username}
### Description
Updates an existing user's information. The username is specified in the path, and the fields to update are in the request body.
### Method
PUT
### Endpoint
/users/{username}
### Parameters
#### Path Parameters
- **username** (string) - Required - The username of the user to update.
#### Request Body
- **email** (string) - Required - The updated email address for the user.
- **firstName** (string) - Optional - The updated first name for the user.
- **lastName** (string) - Optional - The updated last name for the user.
### Request Example
{
"email": "john.doe.updated@example.com",
"firstName": "Jonathan"
}
### Response
#### Success Response (200)
- **username** (string) - Required - The username of the updated user.
- **email** (string) - Required - The updated email address of the user.
- **firstName** (string) - Optional - The updated first name of the user.
- **lastName** (string) - Optional - The updated last name of the user.
### Response Example
{
"username": "johndoe",
"email": "john.doe.updated@example.com",
"firstName": "Jonathan",
"lastName": "Doe"
}
```
--------------------------------
### Convert Zod Function to Schema Helper
Source: https://context7.com/matejchalk/zod2md/llms.txt
Use this helper function to preserve function input/output schema introspection in Zod v4. It transforms a Zod function factory into a custom schema with metadata for documentation generation.
```typescript
// helpers/zod-function.ts
import { z } from 'zod/v4';
import type { $ZodFunction } from 'zod/v4/core';
export function convertZodFunctionToSchema(factory: T) {
return z
.custom()
.transform((arg, ctx) => {
if (typeof arg !== 'function') {
ctx.addIssue('Must be a function');
return z.NEVER;
}
return factory.implement(arg as Parameters[0]);
})
.meta({
$ZodFunction: factory, // ← tells zod2md to render as a function schema
});
}
```
```typescript
// src/schemas.ts
import { z } from 'zod/v4';
import { convertZodFunctionToSchema } from './helpers/zod-function';
import { Commit } from './models';
// A "Rule" function: (commit, condition?, never?) => RuleOutcome | Promise
export const RuleOutcome = z.tuple([z.boolean(), z.string().optional()]).readonly();
export const RuleConfigCondition = z.enum(['always', 'never']);
export const Rule = convertZodFunctionToSchema(
z.function({
input: [Commit, RuleConfigCondition.optional(), z.never().optional()],
output: z.union([RuleOutcome, z.promise(RuleOutcome)]),
}),
);
// zod2md will render "Rule" as a function type with parameters and return value.
```
--------------------------------
### Delete User
Source: https://github.com/matejchalk/zod2md/blob/main/e2e/__snapshots__/user-rest-api-example.md
Deletes a user by their username.
```APIDOC
## DELETE /users/{username}
### Description
Deletes a user from the system using their username.
### Method
DELETE
### Endpoint
/users/{username}
### Parameters
#### Path Parameters
- **username** (string) - Required - The username of the user to delete.
### Response
#### Success Response (204)
No content is returned upon successful deletion.
```
=== COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.