Skip to content
Back to skills

Api Docs

ASecurity

Use when generating API documentation — OpenAPI/Swagger auto-generation from code, MkDocs Material, Docusaurus, Mintlify, Postman/Insomnia export. Trigger on "openapi", "swagger", "api docs", "mkdocs", "docusaurus", "/api-docs".

  • 2 stars
  • 0 votes
  • 0 copies
  • 2 views
  • Added September 19, 2026
ai-agentsjavascriptpythongojavabashreactnodeexpressfastapigit

Works with

  • cursor
  • cli
  • api

Security analysis

A92/100
  • mediumInstalls packages at runtime which could introduce malicious dependencies
  • mediumInstalls packages at runtime which could introduce malicious dependencies

Pro shows the line behind each finding and how to fix it

Scanned September 19, 2026

npx -y skills add Fqih/.mycc-setup --skill api-docs --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Api Docs?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Api Docs
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/fqih-api-docs/badge)](https://www.skillsdirectory.com/skills/fqih-api-docs)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: api-docs
description: Use when generating API documentation — OpenAPI/Swagger auto-generation from code, MkDocs Material, Docusaurus, Mintlify, Postman/Insomnia export. Trigger on "openapi", "swagger", "api docs", "mkdocs", "docusaurus", "/api-docs".
---

# api-docs

Auto-generate API documentation from source code atau manual specification. Local-first, version-controlled.

## Pendekatan

| Pendekatan | Tool | Best for |
|---|---|---|
| **Spec-first** | OpenAPI YAML/JSON hand-written | Public API, contract dengan client |
| **Code-first (Python)** | FastAPI → auto OpenAPI | FastAPI projects |
| **Code-first (Node)** | swagger-jsdoc / tsoa | Express/Fastify |
| **Code-first (Go)** | swag | Gin/Echo |
| **Static site** | MkDocs Material, Docusaurus, Mintlify | Long-form + API reference |
| **Hosted** | Stoplight, ReadMe, Mintlify cloud | Zero ops, $$ |

**Default FastAPI**: zero effort, OpenAPI auto-generated.  
**Default Node**: swagger-jsdoc inline JSDoc annotations.  
**Default Go**: swag dengan `// @Summary` annotations.

## FastAPI auto-OpenAPI

FastAPI generates OpenAPI spec at `/openapi.json` by default. Plus Swagger UI di `/docs`, ReDoc di `/redoc`. Customization:

```python
from fastapi import FastAPI
from fastapi.openapi.utils import get_openapi
import json

app = FastAPI(
    title="My API",
    description="API for X",
    version="1.0.0",
    contact={"name": "Fqih", "email": "mhmdfkih21@gmail.com"},
    license_info={"name": "MIT"},
    openapi_tags=[
        {"name": "users", "description": "User operations"},
        {"name": "auth", "description": "Authentication endpoints"},
    ],
)

# Add security scheme
from fastapi.security import OAuth2PasswordBearer
oauth2_scheme = OAuth2PasswordBearer(tokenUrl="auth/token")

@app.get("/users", tags=["users"], summary="List users")
async def list_users():
    """List all users with pagination.

    - **skip**: number of users to skip
    - **limit**: max users to return (max 100)
    """
    ...

# Export spec ke file
with open("openapi.json", "w") as f:
    json.dump(app.openapi(), f, indent=2)
```

## MkDocs Material setup

```bash
pip install mkdocs mkdocs-material
mkdocs new my-docs
```

`mkdocs.yml`:

```yaml
site_name: My API
site_url: https://docs.example.com
repo_url: https://github.com/Fqih/repo
repo_name: Fqih/repo

theme:
  name: material
  palette:
    - scheme: default
      primary: indigo
      toggle:
        icon: material/brightness-7
        name: Switch to dark mode
    - scheme: slate
      primary: indigo
      toggle:
        icon: material/brightness-4
        name: Switch to light mode
  features:
    - navigation.tabs
    - navigation.sections
    - navigation.expand
    - search.highlight
    - content.code.copy

markdown_extensions:
  - admonition
  - pymdownx.highlight
  - pymdownx.superfences
  - pymdownx.tabbed
  - pymdownx.inlinehilite

plugins:
  - search
  - mkdocstrings:  # Python source doc integration
      handlers:
        python:
          paths: [src]
          options:
            docstring_style: google
            show_source: true

nav:
  - Home: index.md
  - Getting Started: getting-started.md
  - API Reference:
    - Users: api/users.md
    - Auth: api/auth.md
  - Guides:
    - Deployment: guides/deployment.md
```

Serve locally:
```bash
mkdocs serve  # http://localhost:8000
```

Build + deploy:
```bash
mkdocs build  # → site/
# Deploy:
# - GitHub Pages: mkdocs gh-deploy
# - Netlify: drag-drop site/ folder
# - Vercel: vercel deploy --prebuilt
```

## mkdocstrings (auto-generate dari docstrings)

Di `docs/api/users.md`:

```markdown
::: myapp.users
    options:
      show_source: true
      docstring_style: google
      members:
        - create_user
        - list_users
        - delete_user
```

Auto-renders signature + Google-style docstrings sebagai markdown.

## Docusaurus (React-based, JS-heavy)

```bash
npx create-docusaurus@latest my-docs classic
cd my-docs
npm start
```

Plus OpenAPI integration:
```bash
npm install docusaurus-plugin-openapi-docs
```

`docusaurus.config.js`:

```js
{
  plugins: [
    [
      'docusaurus-plugin-openapi-docs',
      {
        id: 'api',
        specPath: '../openapi.json',
        outputDir: 'docs/api',
      },
    ],
  ],
}
```

## Mintlify (hosted, paid, but best DX)

`mint.json`:

```json
{
  "name": "My API",
  "openapi": "openapi.json",
  "navigation": [
    {
      "group": "Getting Started",
      "pages": ["introduction", "authentication"]
    },
    {
      "group": "API",
      "pages": ["api/users", "api/auth"]
    }
  ]
}
```

Auto-generates from OpenAPI + allows custom MDX pages.

## Code-first: Node (swagger-jsdoc)

```javascript
// routes/users.js
/**
 * @openapi
 * /users:
 *   get:
 *     tags: [users]
 *     summary: List users
 *     responses:
 *       200:
 *         description: List of users
 *         content:
 *           application/json:
 *             schema:
 *               type: array
 *               items:
 *                 $ref: '#/components/schemas/User'
 */
router.get('/users', listUsers);
```

```javascript
// swagger.js
const swaggerJsdoc = require('swagger-jsdoc');
const swaggerUi = require('swagger-ui-express');

const spec = swaggerJsdoc({
  definition: {
    openapi: '3.0.0',
    info: { title: 'My API', version: '1.0.0' },
  },
  apis: ['./routes/*.js'],
});

app.use('/docs', swaggerUi.serve, swaggerUi.setup(spec));
```

## Code-first: Go (swag)

```go
// @Summary List users
// @Description Get list of users with pagination
// @Tags users
// @Param skip query int false "Skip count"
// @Param limit query int false "Limit (max 100)"
// @Success 200 {array} User
// @Router /users [get]
func ListUsers(c *gin.Context) {
    ...
}
```

```bash
swag init  # → docs/swagger.json
# Serve via gin-swagger
```

## CI/CD: keep docs in sync

```yaml
# .github/workflows/docs.yml
name: Build docs
on: [push]
jobs:
  docs:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - run: pip install mkdocs mkdocs-material
      - run: mkdocs build --strict
      - uses: actions/deploy-pages@v4
        with:
          artifact: site
```

## Versioning

API versions di spec + URL:
- `/api/v1/users`
- `/api/v2/users` (breaking changes)

OpenAPI versions via info.version. Maintain changelog.md.

## OpenAPI spec tips

✅ Use `$ref` untuk reusable components (User schema, Error response)
✅ Add `example` ke semua fields (Swagger UI tampilkan)
✅ Define error responses (400, 401, 404, 500)
✅ Security schemes: Bearer JWT, OAuth2, API key
✅ Pagination: cursor-based atau offset-based, document choice
✅ Document rate limits + quotas

## Anti-patterns

❌ Hand-write OpenAPI untuk FastAPI (auto-generated lebih reliable)
❌ Docs repo terpisah dari code repo (drift inevitable)
❌ Skip error response docs (user bingung saat error)
❌ Publish docs tanpa versioning
❌ Inline JSDoc tanpa @openapi annotation (tidak ter-export)
❌ Hosting public docs untuk internal API (security leak)

## Integration dengan audit-workflow

Audit dimension "docs drift" cek apakah README references match actual files. Untuk API docs, validasi:
- All endpoint di OpenAPI ter-implement di code
- All routes terdaftar punya description
- OpenAPI valid JSON/YAML
- Docs site builds tanpa error (mkdocs --strict)

## Invokation

Auto-trigger:
- Edit FastAPI routes, Node route handlers, Go handlers
- Reference ke "openapi", "swagger", "api docs", "docs site"
- Slash command: `/api-docs`, `/gen-openapi`

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

Comments

Loading comments…