Api docs

From tinh2/skills-hub-registry · View interactive version

Api docs is an AI agent skill from the GitHub repository tinh2/skills-hub-registry. Generate OpenAPI 3.1 documentation from your API codebase. Auto-detects Express, Fastify, NestJS, Django, FastAPI, Flask, Rails, Spring, Go, and more. Triggers: you need API documentation, OpenAPI spec, Swagger docs, endpoint reference, or REST API docs.

How to use this skill

Skill file

You are in AUTONOMOUS MODE. Do NOT ask questions. Analyze the project's API

layer and produce complete OpenAPI documentation.

INPUT:

$ARGUMENTS

If no arguments provided, auto-detect the API framework and document all endpoints.

If a specific path, module, or endpoint group is provided, scope documentation to that area.

============================================================

PHASE 1: FRAMEWORK DETECTION

============================================================

Detect the API framework by scanning for config files and import patterns:

| Framework | Detection Signals |

|-----------|------------------|

| Express | require('express'), import express, app.get(, router.post( |

| Fastify | require('fastify'), import Fastify, fastify.route(, fastify.get( |

| NestJS | @Controller(, @Get(, @Post(, nest-cli.json |

| Hono | import { Hono }, new Hono(), app.get( with Hono types |

| Django REST | urls.py, views.py, serializers.py, rest_framework imports |

| FastAPI | from fastapi, @app.get(, @router.post(, APIRouter |

| Flask | from flask, @app.route(, Blueprint |

| Go net/http | http.HandleFunc(, http.ListenAndServe(, mux.Handle( |

| Gin | gin.Default(), r.GET(, r.POST( |

| Rails | routes.rb, config/routes, resources : |

| Spring | @RestController, @RequestMapping, @GetMapping |

| ASP.NET | [ApiController], [HttpGet], MapGet(, app.MapControllers() |

Record the detected framework as API_FRAMEWORK for subsequent phases.

If no API framework is detected, check for:

Report the finding and adapt accordingly.

============================================================

PHASE 2: ROUTE EXTRACTION

============================================================

Systematically extract all API routes:

Step 2.1 -- Find Route Files

Based on API_FRAMEWORK, locate route definitions:

Step 2.2 -- Extract Route Details

For each route, extract:

Step 2.3 -- Extract Authentication Requirements

Identify auth patterns:

Step 2.4 -- Extract Validation Schemas

Look for request validation:

============================================================

PHASE 3: OPENAPI SPEC GENERATION

============================================================

Generate an OpenAPI 3.1.0 specification:

Generate a valid OpenAPI 3.1.0 YAML spec with: info (title, description, version

from package config), servers (localhost with detected port), paths (from extracted

routes), components/schemas (from extracted types), and securitySchemes.

For each path item include: operationId, summary, description, tags (grouped by

controller/router or URL prefix), parameters, requestBody, responses with status

codes, and security requirements.

For schemas: convert TypeScript interfaces, Pydantic models, Zod schemas, or Django

serializers to JSON Schema. Mark required vs optional fields. Include examples from

test fixtures or seed data where available. Generate both success and error examples.

============================================================

PHASE 4: INTERACTIVE DOCS SETUP

============================================================

Set up interactive API documentation:

Step 4.1 -- Choose Tool

Based on the framework and existing dependencies:

| Condition | Tool | Setup |

|-----------|------|-------|

| Fastify project | @fastify/swagger + @scalar/fastify-api-reference | Plugin registration |

| Express project | swagger-ui-express | Middleware mount |

| NestJS project | @nestjs/swagger | Module configuration |

| FastAPI project | Built-in (Swagger UI at /docs) | Already available |

| Django REST | drf-spectacular or drf-yasg | Settings configuration |

| Any project | Redoc standalone | Static HTML page |

| Any project | Scalar | CDN-based HTML page |

Step 4.2 -- Integration

If the project supports it, add interactive docs as a development dependency:

If the project does not support middleware-based docs, generate a standalone

HTML file using Scalar or Redoc CDN that references the spec file.

============================================================

PHASE 5: VALIDATION

============================================================

Validate the generated spec against the actual codebase:

Step 5.1 -- Route Coverage

Step 5.2 -- Schema Accuracy

Step 5.3 -- Spec Lint

============================================================

SELF-HEALING VALIDATION (max 2 iterations)

============================================================

After producing documentation, validate completeness:

  1. Verify all required sections are present and non-empty.
  2. Verify internal cross-references and links resolve correctly.
  3. Verify no placeholder text remains ("{TODO}", "[TBD]", "...", "etc.").
  4. Verify code examples are syntactically valid.

IF VALIDATION FAILS:

============================================================

OUTPUT

============================================================

Write the following files:

  1. docs/openapi.yaml -- The complete OpenAPI 3.1.0 specification
  2. docs/api-docs.md -- Human-readable API reference (for GitHub browsing)

Report:

API Documentation Generated

Framework

Coverage

Files Created

Interactive Docs

Endpoint Summary

| Method | Path | Auth | Description |

|--------|------|------|-------------|

| GET | /api/users | Bearer | List all users |

| POST | /api/users | Bearer | Create a user |

| ... | ... | ... | ... |

Validation Results

============================================================

SELF-EVOLUTION TELEMETRY

============================================================

After producing output, record execution metadata for the /evolve pipeline.

Check if a project memory directory exists:

Entry format:

### /api-docs — {{YYYY-MM-DD}}
- Outcome: {{SUCCESS | PARTIAL | FAILED}}
- Self-healed: {{yes — what was healed | no}}
- Iterations used: {{N}} / {{N max}}
- Bottleneck: {{phase that struggled or "none"}}
- Suggestion: {{one-line improvement idea for /evolve, or "none"}}

Only log if the memory directory exists. Skip silently if not found.

Keep entries concise — /evolve will parse these for skill improvement signals.

============================================================

DO NOT

============================================================

preserving any manually-written descriptions or examples.

part of the documented API surface.

NEXT STEPS:

After generating API documentation:

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.