iToverDose/Software· 28 MAY 2026 · 08:04

AutoDoc turns raw C# code into OpenAPI docs with AI—no annotations needed

A developer built AutoDoc to eliminate manual OpenAPI documentation in .NET projects. The tool uses a local AI model to infer routes, schemas, and responses directly from raw C# controller code, generating complete specs without annotations or decorators.

DEV Community4 min read0 Comments

For many .NET developers, keeping OpenAPI documentation in sync with live code feels like chasing a moving target. Every missed attribute or undocumented error response widens the gap between what the API actually does and what the Swagger UI claims it does. AutoDoc was built to close that gap by letting developers write code and let AI handle the documentation—no extra annotations, no decorators, no maintenance.

The project started as a frustration during a software engineering internship. Swagger documentation in .NET projects often documents only what developers explicitly declare. When attributes are forgotten or summaries skipped, the documentation silently drifts from reality. Developers end up spending time writing documentation instead of writing code.

How AutoDoc works: AI-powered OpenAPI generation from C#

AutoDoc is a three-phase tool that transforms raw C# ASP.NET Core controller code into complete OpenAPI 3.0.3 documentation using a local AI model. The process begins with a terminal script and evolves into a containerized REST API with a browser-based playground.

  • Phase 1 (Console App): Paste C# controller code and receive OpenAPI YAML directly in the terminal.
  • Phase 2 (Docker Web API): A containerized REST backend accepts controller code via HTTP POST and returns YAML.
  • Phase 3 (Playground UI): A browser dashboard splits the screen for input and output, showing raw YAML and a live Swagger preview.

The tool is designed to be zero-maintenance. Developers paste raw controller code, click Generate, and receive a fully documented OpenAPI spec—no attributes, no decorators, no manual annotations required.

A live demo: from raw C# to interactive API docs in seconds

The AutoDoc Playground UI features a split-panel dashboard where developers paste any ASP.NET Core controller code on the left and see the results on the right. The sample TodoController comes pre-filled for immediate testing.

When a developer hits Generate OpenAPI Docs, the raw C# code is sent to a local AI backend running Ollama. The AI analyzes the code and infers everything automatically:

  • operationId: Unique names like GetAllTodos or CreateTodo
  • tags: Grouped by controller name (e.g., TodoController)
  • summary: Human-readable descriptions per endpoint
  • requestBody: Schema inferred from method parameters
  • responses: 200, 201, 400, 404, 500 inferred from code logic
  • components/schemas/ErrorResponse: Defined once and referenced everywhere

None of these details existed in the original controller code. The AI understood the code’s intent and generated a complete OpenAPI spec.

From terminal to browser: building a production-ready tool

AutoDoc began as a simple console application—a proof of concept answering one question: Can an AI model read raw C# controller code and generate valid OpenAPI documentation without any manual annotations? The answer was yes, but the initial version was far from finished.

The console app worked locally but lacked an HTTP interface, UI, or Docker support. It printed raw YAML to the terminal and offered no output validation. To move from concept to tool, three major phases were required.

Phase 2: Dockerizing the backend

The console app was converted into a minimal ASP.NET Core API with two endpoints:

  • POST /generate-openapi – accepts controller code as JSON and returns OpenAPI YAML
  • GET /health – confirms the service is running

A Dockerfile was added so the entire service runs in a container with a single command. The Ollama host was made configurable via environment variable, enabling seamless local and Docker deployment.

Phase 3: Building the Playground UI

A browser-based dashboard was integrated directly into the Docker container via wwwroot. The UI features:

  • A split-panel layout with controller input on the left and output on the right
  • A Raw YAML tab displaying the full generated spec in monospace formatting
  • A Swagger Preview tab rendering a live interactive Swagger UI from the YAML
  • A status pill showing real-time generation state
  • A pre-filled sample controller for zero-setup testing

The toughest challenge: taming AI output consistency

While the local Llama 3.2 model performed remarkably well, it occasionally introduced small inconsistencies—missing commas, inconsistent indentation—that broke Swagger preview rendering. To ensure reliability, the team implemented validation and error correction logic to clean the AI’s output and guarantee valid OpenAPI specs every time.

What’s next for AutoDoc?

AutoDoc proves that AI can automate a traditionally manual and error-prone task in .NET development. The tool removes the need for decorators, attributes, and XML comments, letting developers focus on writing robust code while AI handles documentation.

Looking ahead, the team plans to expand language support beyond C#, add support for more AI models, and integrate with CI/CD pipelines. AutoDoc isn’t just a documentation generator—it’s a step toward AI-assisted development where the code itself becomes the source of truth.

AI summary

AutoDoc uses local AI to convert raw C# ASP.NET Core controllers into complete OpenAPI specs without annotations or decorators, saving developers time and reducing documentation drift.

Comments

00
LEAVE A COMMENT
ID #7FIA3N

0 / 1200 CHARACTERS

Human check

8 + 5 = ?

Will appear after editor review

Moderation · Spam protection active

No approved comments yet. Be first.