Skip to content

About

Automatically generate beautiful, interactive documentation for your doofpi APIs

Resources

Stars

1 star

Watchers

0 watching

Forks

Repository files navigation

doofpi Docs Generator logo
doofpi Docs Generator

Generate interactive, zero-config API documentation with a built-in testing playground for doofpi APIs

npm version License: MIT TypeScript


Installation

bun install doofpi-docs-generator
# or
npm install doofpi-docs-generator

Requirements:

  • doofpi ^1.0.0
  • Zod v4+ (with toJSONSchema support)

Quick Start

import { collectRoutes, generateDocsHtml } from "doofpi-docs-generator";
import { routes } from "./routes";

const routeInfo = collectRoutes(routes);
const html = generateDocsHtml(routeInfo, { title: "My API Documentation" });

app.get("/docs", (req, res) => {
  res.send(html);
});
import { d } from "doofpi";
import { z } from "zod";
import type { RouteMeta } from "doofpi-docs-generator";

const doofpi = d.defineMeta<RouteMeta>();

export const routes = {
  getUser: doofpi({
    meta: {
      docs: {
        title: "Get User",
        description: "Retrieve a user by ID",
        tags: ["Users"],
      },
    },
    model: {
      input: z.object({ userId: z.string() }),
      output: z.object({ id: z.string(), name: z.string() }),
    },
    read: async ({ input }) => {
      // Implementation
    },
  }),
};

Open /docs in your browser: every endpoint gets a testing panel (configurable base URL, headers, auto-filled request bodies), copy-paste code snippets (cURL / fetch / doofpi client), response schema validation, and per-endpoint request history.


API Reference

  • collectRoutes(routes) - Traverses a doofpi routes object and returns RouteInfo[] with input/output JSON schemas, TypeScript types, and generated examples.
  • generateDocsHtml(routes, options?) - Renders the full interactive documentation page. options accepts title.
  • generateSnippets(route, options?) / generateCurlSnippet / generateFetchSnippet / generateDoofpiClientSnippet - Generate ready-to-copy call snippets for a single route.
  • validateAgainstSchema(data, schema, path?) - Validates a value against a JSON Schema object, returning a list of human-readable mismatch messages (empty when it matches).
  • Types: RouteMeta, DocsGeneratorOptions, RouteInfo, SnippetOptions, RouteSnippets.

Troubleshooting

  • "Failed to fetch" / CORS errors - Make sure the configured base URL's host matches exactly how you're accessing the docs (don't mix localhost and 127.0.0.1), and that your API allows CORS from the docs origin.
  • 404 Not Found - The base URL must include your doofpi root mount path (e.g. http://localhost:3000/doofpi).

About

Automatically generate beautiful, interactive documentation for your doofpi APIs

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages