zod-openapi

Generate OpenAPI 3.0 specifications from Zod v4 schemas in Express middleware.

Updated Apr 27, 2026
One-click install
npx skills add https://github.com/miracleonyenma/skills --skill zod-openapi
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: zod-openapi
Source: https://github.com/miracleonyenma/skills/tree/main/zod-openapi
Command: npx skills add https://github.com/miracleonyenma/skills --skill zod-openapi

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

This Skill removes the need to handwrite and maintain separate OpenAPI YAML or JSON files for Express APIs, reducing schema drift and documentation overhead.

Core Features & Use Cases

  • Schema-driven validation and docs: Attach Zod v4 schemas to Express middleware and reuse them for both runtime validation and OpenAPI generation.
  • Route introspection: Discover request and response schemas from mounted routers automatically, including path, query, and body parameters.
  • Production-ready API docs: Generate OpenAPI 3.0 specs, filter private routes from public docs, and serve interactive Scalar UI documentation.
  • Use Case: When migrating an existing Express API, use this Skill to convert manual validation into Zod schemas and instantly produce consistent API documentation.

Quick Start

Ask the AI to convert your Express route definitions into Zod-based validation and a generated OpenAPI 3.0 specification with public and admin doc separation.

Frequently Asked Questions about zod-openapi

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I generate OpenAPI specs from Zod schemas in an Express app?

You can generate OpenAPI 3.0 specifications by attaching Zod v4 schemas to Express middleware. The tool introspects mounted routers to discover path, query, and body parameters, automatically converting validation rules into API documentation.

Can I serve interactive API documentation using Scalar UI with Zod?

Yes, after generating your OpenAPI 3.0 specification from Zod schemas, you can serve interactive Scalar UI documentation. This provides a production-ready interface for users to explore and test your API endpoints.

How do I hide private routes from public API documentation?

You can filter private routes from public docs using public versus private spec filtering. This ensures sensitive admin endpoints are excluded from the generated OpenAPI specification served to external users.

Does this approach to API documentation work with Zod v4?

Yes, this approach specifically requires Zod v4 schemas attached to Express middleware. It reuses the runtime validation schemas you already have to produce consistent OpenAPI 3.0 documentation.

What is the best way to migrate Express routes to schema-driven validation?

The best way is converting manual validation into Zod v4 schemas. This instantly produces consistent API documentation alongside runtime validation, eliminating the need to handwrite separate OpenAPI YAML or JSON files.

Why does my OpenAPI documentation drift from my Express route validation?

Documentation drifts when you handwrite separate OpenAPI YAML or JSON files. By attaching Zod schemas to Express middleware, validation and documentation are generated from a single source, eliminating schema drift and maintenance overhead.