Products Open Source Blog About Us Contact Us Sign in
lac gendoc: API Docs That Write Themselves

lac gendoc: API Docs That Write Themselves

Writing API docs by hand is the task every developer postpones until a teammate gets angry about it. lac gendoc detects your framework, reads your routes, and generates interactive HTML docs in one command.

The docs are always out of date. Or they don't exist at all.

Every backend project I've worked on has the same story. Someone added three new endpoints last sprint. Nobody updated the Swagger file. The frontend dev is pinging you on Slack asking what the request body looks like. You say "just look at the controller" and feel a little bad about it.

Writing docs by hand is one of those tasks that's easy to skip because it feels disconnected from actual work. It's also one of those things that bites you hard later — onboarding a new person, handing off a project, or integrating with a third party who needs something they can actually read.

lac gendoc is the part of lac-cli that fixes this. You run one command, it figures out what framework you're using, reads your routes, and spits out interactive HTML docs. That's the whole pitch.

How it actually works

Point it at your project root and run:

lac gendoc

It detects the framework automatically — Laravel, Django, FastAPI, Flask, Express, or Rails — then crawls your route definitions and controller signatures. No config file. No decorators to add. No YAML to maintain.

The output is a single interactive HTML file. Every route is listed with its method, path, expected parameters, and request/response shape. There's a built-in UI where you can expand each endpoint and try it live — similar to what you'd get from a Swagger UI setup, without the setup.

If your team uses Postman, you can export a collection straight from the same command. If you need an OpenAPI spec, that's covered too.

Framework detection that doesn't lie to you

The thing I was most skeptical about was the auto-detection. "Detects your framework" sounds like it just checks for a package.json or a requirements.txt and guesses. In practice it's more careful than that — it looks at project structure, route file patterns, and imports before committing to a framework.

I tested it on a FastAPI project that also had some Express tooling in a subfolder (a legacy webhook handler, don't ask). It correctly identified FastAPI as the primary framework and scoped the docs to that. Didn't get confused by the noise.

For Laravel it reads routes/api.php and traces through the controller methods. For Django it walks urlpatterns. For FastAPI and Flask it picks up the decorators directly. Express projects get their router files scanned.

What the output looks like

The generated HTML doc has a clean sidebar with all your routes grouped by prefix. Click any route and you get:

  • HTTP method and full path
  • Path parameters and query parameters with their types
  • Request body schema if one exists
  • Expected response shape
  • A live "Try it" panel that fires real requests against your running server

The live panel is the part that makes it genuinely useful instead of just a prettier README. You can hand this file to a frontend developer or an API consumer and they can actually poke at your endpoints without setting up anything else.

Where it fits in a real workflow

The most obvious place is right before a handoff. You finish a feature, run lac gendoc, and drop the HTML file in your PR description or a shared drive. Done. Takes about five seconds.

It's also useful during development if you're working on a larger API and need to keep track of what you've built. Opening the generated doc is faster than reading through route files when you just need to check what a specific endpoint expects.

If you're using lac agent to build or modify backend code, you can run lac gendoc right after a session to regenerate docs that reflect what the agent just wrote. The two tools pair naturally — agent builds, gendoc documents.

Getting it running

If you haven't installed lac-cli yet:

pip install lac-cli

Or if you prefer the shell script:

curl -fsSL https://lacai.io/install.sh | bash

Then navigate to your project root and run lac gendoc. The first time, it'll ask you to confirm the detected framework before generating. After that, it remembers.

If your project uses a non-standard structure — a monorepo, a custom router setup — you can pass the path explicitly:

lac gendoc --path ./backend/api

That's about as much configuration as you'll ever need.

The thing most people miss

Most developers who install lac-cli discover lac shell first, then lac agent if they dig around. lac gendoc tends to stay under the radar because it doesn't sound as exciting as an agentic coding assistant or a multi-model debate engine.

But if you've ever spent 45 minutes writing Swagger YAML by hand, or opened a project months later with no idea what the API surface looks like, you'll use this constantly. It's one of those tools where the value is obvious the moment you actually have undocumented endpoints sitting in front of you.

Run lac gendoc --help to see the full list of export options. The Postman export in particular is worth knowing about — lac gendoc --export postman drops a ready-to-import collection JSON right alongside your HTML file.

We use cookies to keep you signed in and to serve ads via Google AdSense. By continuing to use this site you agree to our Privacy Policy.