Skip to content

docs: add OpenAPI tags metadata for /api-docs page#20

Closed
sudabg wants to merge 1 commit intoD0NMEGA:mainfrom
sudabg:docs/openapi-tags
Closed

docs: add OpenAPI tags metadata for /api-docs page#20
sudabg wants to merge 1 commit intoD0NMEGA:mainfrom
sudabg:docs/openapi-tags

Conversation

@sudabg
Copy link
Copy Markdown

@sudabg sudabg commented Mar 18, 2026

Adds OpenAPI tags metadata to organize the /api-docs page by resource category.

Closes #6

Summary by CodeRabbit

  • Documentation
    • Enhanced API documentation with improved organizational structure through new tag metadata, making it easier to navigate and discover API endpoints by category.

@github-actions
Copy link
Copy Markdown

Thank you for your contribution! Before we can merge this PR, you need to sign our Contributor License Agreement.

To sign, please comment below:

I have read the CLA Document and I hereby sign the CLA


I have read the CLA Document and I hereby sign the CLA


You can retrigger this bot by commenting recheck in this Pull Request. Posted by the CLA Assistant Lite bot.

@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Mar 18, 2026

📝 Walkthrough

Walkthrough

The PR adds OpenAPI tag metadata defining multiple API route groups with descriptions, and passes this metadata to the FastAPI constructor via the openapi_tags parameter. This organizes API documentation without altering application behavior or logic.

Changes

Cohort / File(s) Summary
OpenAPI Tag Metadata
main.py
Added tags_metadata list containing API group definitions and descriptions; updated FastAPI() constructor to accept openapi_tags=tags_metadata for improved API documentation organization.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~3 minutes

Poem

🐰 With tags so clear and paths so bright,
The API docs now shine just right!
Each router grouped in order neat,
Navigation's quick and sweet—
Hop-hop-hooray, the docs compete! 📚✨

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description is minimal but incomplete - it lacks the required Testing checklist items and doesn't follow the provided template structure with detailed sections. Add Testing section with checkboxes and Checklist section per template, include specific details about which routers were modified.
Linked Issues check ⚠️ Warning The PR partially addresses issue #6 by adding OpenAPI tags metadata to main.py, but does not update router files themselves with tag metadata and descriptions as explicitly required. Update routers/*.py files to include OpenAPI tag metadata and descriptions for each router as specified in issue #6.
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately describes the main change - adding OpenAPI tags metadata to the main.py file to organize the API documentation.
Out of Scope Changes check ✅ Passed All changes are scoped to adding OpenAPI tags metadata in main.py, which directly supports the goal of organizing the /api-docs page by resource category.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
📝 Coding Plan
  • Generate coding plan for human review comments

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Tip

CodeRabbit can use your project's `pylint` configuration to improve the quality of Python code reviews.

Add a pylint configuration file to your project to customize how CodeRabbit runs pylint.

Copy link
Copy Markdown

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@main.py`:
- Around line 71-84: The tags_metadata list currently defined in tags_metadata
is incomplete; update the tags_metadata variable to include all tags used in
route decorators (e.g., Admin, Chat Gateway, Documentation, Events,
Integrations, Obstacle Course, Onboarding, Orgs, Pub/Sub, Sessions, Shared
Memory, System, Templates, Testing, Text Utilities, User, User Dashboard, User
Settings, Vector Memory, tiered-memory, plus the existing ones like
Auth/Memory/Vector/Queue/Relay/Webhooks/Schedules/Directory/Marketplace/Billing/Dashboard)
so every router- and endpoint-level tag has a corresponding entry with a name
and short description to ensure /api-docs groups and describes all endpoints.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 8dfaa2dc-ece0-477c-bf97-fe5af8ef57fd

📥 Commits

Reviewing files that changed from the base of the PR and between b03d36c and 8e608c7.

📒 Files selected for processing (1)
  • main.py

Comment on lines +71 to +84
# OpenAPI tag metadata for /api-docs organization
tags_metadata = [
{"name": "Auth", "description": "Agent registration and API key management"},
{"name": "Memory", "description": "Key-value persistent memory with TTL"},
{"name": "Vector", "description": "Vector semantic search over stored knowledge"},
{"name": "Queue", "description": "Task queues with priority and retry"},
{"name": "Relay", "description": "Inter-agent messaging and pub/sub"},
{"name": "Webhooks", "description": "Webhook registration and delivery"},
{"name": "Schedules", "description": "Cron-based task scheduling"},
{"name": "Directory", "description": "Agent directory with reputation"},
{"name": "Marketplace", "description": "Task marketplace with credits"},
{"name": "Billing", "description": "Stripe billing integration"},
{"name": "Dashboard", "description": "Stats and monitoring"},
]
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🔴 Critical

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

# Read-only verification:
# 1) Extract tags_metadata names from main.py
# 2) Extract APIRouter(tags=[...]) strings from routers/*.py
# 3) Report unmatched router tags and unused metadata tags

python - <<'PY'
import ast
from pathlib import Path

main_py = Path("main.py")
tree = ast.parse(main_py.read_text())

tags_metadata = set()
for node in tree.body:
    if isinstance(node, ast.Assign):
        for target in node.targets:
            if isinstance(target, ast.Name) and target.id == "tags_metadata":
                if isinstance(node.value, ast.List):
                    for item in node.value.elts:
                        if isinstance(item, ast.Dict):
                            for k, v in zip(item.keys, item.values):
                                if isinstance(k, ast.Constant) and k.value == "name":
                                    if isinstance(v, ast.Constant) and isinstance(v.value, str):
                                        tags_metadata.add(v.value)

router_tags_by_file = {}
routers_dir = Path("routers")
for file in sorted(routers_dir.glob("*.py")):
    try:
        t = ast.parse(file.read_text())
    except Exception:
        continue
    tags = set()
    for n in ast.walk(t):
        if isinstance(n, ast.Call):
            fn = n.func
            fn_name = fn.id if isinstance(fn, ast.Name) else (fn.attr if isinstance(fn, ast.Attribute) else None)
            if fn_name == "APIRouter":
                for kw in n.keywords:
                    if kw.arg == "tags" and isinstance(kw.value, (ast.List, ast.Tuple)):
                        for e in kw.value.elts:
                            if isinstance(e, ast.Constant) and isinstance(e.value, str):
                                tags.add(e.value)
    if tags:
        router_tags_by_file[str(file)] = sorted(tags)

all_router_tags = sorted({t for ts in router_tags_by_file.values() for t in ts})
missing_in_metadata = sorted(set(all_router_tags) - tags_metadata)
unused_metadata = sorted(tags_metadata - set(all_router_tags))

print("tags_metadata:", sorted(tags_metadata))
print("router tags:", all_router_tags)
print("missing in tags_metadata:", missing_in_metadata)
print("unused in router tags:", unused_metadata)

for f, ts in router_tags_by_file.items():
    for tag in ts:
        if tag not in tags_metadata:
            print(f"UNMATCHED -> {f}: {tag}")
PY

Repository: D0NMEGA/MoltGrid

Length of output: 556


🏁 Script executed:

#!/bin/bash
set -euo pipefail

# Check routers directory structure
echo "=== Routers directory structure ==="
if [ -d "routers" ]; then
  find routers -type f -name "*.py" | head -20
  echo "Total router files:"
  find routers -type f -name "*.py" | wc -l
else
  echo "routers directory not found"
fi

echo ""
echo "=== Check chat_gateway.py for APIRouter definition ==="
if [ -f "routers/chat_gateway.py" ]; then
  grep -n "APIRouter" routers/chat_gateway.py | head -5
fi

echo ""
echo "=== Check tiered_memory.py for APIRouter definition ==="
if [ -f "routers/tiered_memory.py" ]; then
  grep -n "APIRouter" routers/tiered_memory.py | head -5
fi

echo ""
echo "=== Search for all APIRouter calls in routers directory ==="
rg "APIRouter\s*\(" routers/ -A 2 | head -50

Repository: D0NMEGA/MoltGrid

Length of output: 2588


🏁 Script executed:

#!/bin/bash
set -euo pipefail

# Extract all tags used at endpoint level across all routers
echo "=== All tags used in routers (endpoint level) ==="
rg '@router\.(get|post|put|delete|patch|head|options|trace)\(' routers/ -A 3 | grep -E 'tags=\[' | sed 's/.*tags=\[//g' | sed 's/\].*//g' | sort -u

echo ""
echo "=== All tags in tags_metadata from main.py ==="
rg '"name": "' main.py | sed 's/.*"name": "//g' | sed 's/".*//' | sort -u

echo ""
echo "=== Detailed view: router files with their endpoint tags ==="
for file in routers/*.py; do
  tags=$(rg '@router\.(get|post|put|delete|patch|head|options|trace)\(' "$file" -A 3 | grep -o 'tags=\[[^]]*\]' | head -1)
  if [ -n "$tags" ]; then
    echo "$file: $tags"
  fi
done

Repository: D0NMEGA/MoltGrid

Length of output: 627


Add missing tags to tags_metadata—currently covers only 11 of ~29 tags used in endpoint decorators.

The tags_metadata list is severely incomplete. Actual tags in use include Admin, Chat Gateway, Documentation, Events, Integrations, Obstacle Course, Onboarding, Orgs, Pub/Sub, Sessions, Shared Memory, System, Templates, Testing, Text Utilities, User, User Dashboard, User Settings, Vector Memory, Webhooks, and router-level tags like tiered-memory—but only 11 of these are in the metadata list. This causes ~20 endpoints to lack OpenAPI descriptions and fail to group correctly in /api-docs.

Update tags_metadata to include all tags used across routers (both router-level and endpoint-level decorators).

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@main.py` around lines 71 - 84, The tags_metadata list currently defined in
tags_metadata is incomplete; update the tags_metadata variable to include all
tags used in route decorators (e.g., Admin, Chat Gateway, Documentation, Events,
Integrations, Obstacle Course, Onboarding, Orgs, Pub/Sub, Sessions, Shared
Memory, System, Templates, Testing, Text Utilities, User, User Dashboard, User
Settings, Vector Memory, tiered-memory, plus the existing ones like
Auth/Memory/Vector/Queue/Relay/Webhooks/Schedules/Directory/Marketplace/Billing/Dashboard)
so every router- and endpoint-level tag has a corresponding entry with a name
and short description to ensure /api-docs groups and describes all endpoints.

Copy link
Copy Markdown
Owner

@D0NMEGA D0NMEGA left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the contribution! Good idea to add tag metadata for the API docs page. However, this needs changes before it can be merged:

Must Fix

1. Missing 18 tags. The codebase uses 29 tags across all routers, but this PR only adds 11. The missing tags will show as "uncategorized" in /api-docs, which is worse than having no metadata at all (because it splits endpoints into organized + unorganized groups).

Here are ALL the tags currently used (run grep -rh 'tags=\[' routers/*.py main.py to verify):

tags_metadata = [
    {"name": "Auth", "description": "Agent registration and API key management"},
    {"name": "Memory", "description": "Key-value persistent memory with TTL and namespaces"},
    {"name": "Vector Memory", "description": "Semantic vector search over stored knowledge"},
    {"name": "Queue", "description": "Task queues with priority, retry, and dead letter"},
    {"name": "Relay", "description": "Inter-agent messaging with channels"},
    {"name": "Pub/Sub", "description": "Publish-subscribe broadcast messaging"},
    {"name": "Webhooks", "description": "Webhook registration, delivery, and testing"},
    {"name": "Schedules", "description": "Cron-based task scheduling"},
    {"name": "Directory", "description": "Agent directory with reputation and discovery"},
    {"name": "Marketplace", "description": "Task marketplace with credits and rewards"},
    {"name": "Billing", "description": "Stripe billing and subscription management"},
    {"name": "User Dashboard", "description": "User-facing stats, overview, and activity"},
    {"name": "User Settings", "description": "Profile, notifications, and account settings"},
    {"name": "User", "description": "User account management"},
    {"name": "Sessions", "description": "Tiered memory sessions with summarization"},
    {"name": "Shared Memory", "description": "Cross-agent shared memory namespaces"},
    {"name": "tiered-memory", "description": "Short/mid/long-term tiered memory system"},
    {"name": "Events", "description": "Agent event stream and activity tracking"},
    {"name": "Onboarding", "description": "Agent onboarding steps and obstacle course"},
    {"name": "Obstacle Course", "description": "10-stage platform capability challenge"},
    {"name": "Integrations", "description": "Platform integration management"},
    {"name": "Templates", "description": "Agent and workflow templates"},
    {"name": "Testing", "description": "Multi-agent test scenarios"},
    {"name": "Text Utilities", "description": "Text processing helpers (SHA-256, URL extraction)"},
    {"name": "Chat Gateway", "description": "Chat-style agent interaction gateway"},
    {"name": "Orgs", "description": "Organization and team management"},
    {"name": "System", "description": "System health and contact endpoints"},
    {"name": "Admin", "description": "Admin-only management endpoints"},
    {"name": "Documentation", "description": "API documentation serving"},
]

Please update with the full list above. You can verify completeness by checking each router file in routers/.

2. CLA not signed. Please sign the CLA by commenting "I have read the CLA Document and I hereby sign the CLA" on the PR.

Suggestion

Consider grouping tags in a logical order: core agent services first (Auth, Memory, Queue, Relay), then platform features (Directory, Marketplace), then admin/system last. The order in tags_metadata controls the display order in /api-docs.

@D0NMEGA D0NMEGA closed this Mar 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add OpenAPI tags and descriptions to all routers

2 participants