Skip to content

Latest commit

 

History

History
269 lines (197 loc) · 6.84 KB

File metadata and controls

269 lines (197 loc) · 6.84 KB

Final Implementation: OpenAPI with Mintlify

✅ What Was Implemented

Successfully migrated Dialgen API documentation to OpenAPI 3.0 specification. Mintlify automatically displays HTTP method indicators for all endpoints generated from the OpenAPI spec.

🎯 Key Implementation

1. OpenAPI Specification (openapi.json)

Created a comprehensive OpenAPI 3.0 specification file with:

  • 11 endpoints fully documented
  • 20+ reusable schemas
  • Complete request/response examples
  • Clean descriptions without embedded components

2. Mintlify Automatic HTTP Method Display

When you use OpenAPI with Mintlify:

  • HTTP methods are automatically displayed in the page title and header
  • Color-coded badges appear automatically (GET = green, POST = blue, etc.)
  • No manual badge components needed in OpenAPI descriptions

3. Badge Components in MDX Files Only

The <Badge> component works in MDX files like introduction.mdx:

<Badge color="green">GET</Badge> - Retrieve data

<Badge color="blue">POST</Badge> - Create or modify data

Important: Badge components do NOT work in OpenAPI JSON descriptions.

📊 All 11 Endpoints Documented

Agents (1 endpoint)

  • GET /api/v1/agent - Get Agent

Calls (5 endpoints)

  • POST /api/v1/call/dial - Start a Single Call
  • GET /api/v1/status/call - Get Live Call Status
  • GET /api/v1/call/check-status - Persistent Call Status
  • GET /api/v1/call/get-metric - Get Call Metrics
  • POST /api/v1/call/create-summary - Create Call Summary

Batches (5 endpoints)

  • POST /api/v1/batch - Create a New Call Batch
  • GET /api/v1/status/batch - Get Live Batch Status
  • GET /api/v1/batch/check-status - Get Batch Statistics
  • GET /api/v1/batch/list - List All Batches
  • POST /api/v1/batch/cancel - Cancel Batch

📁 Files Structure

dialgen-docs/
├── openapi.json                    # OpenAPI 3.0 spec (clean, no badges)
├── docs.json                       # Mintlify config (references OpenAPI)
├── api-reference/
│   ├── introduction.mdx            # Uses Badge components
│   └── endpoint/                   # Old MDX files (can be archived)
└── [documentation files]

🎨 How HTTP Methods Are Displayed

In OpenAPI-Generated Pages

Mintlify automatically:

  1. Shows the HTTP method in the page title (e.g., "GET Get Agent")
  2. Displays a color-coded badge/indicator
  3. Highlights the method in the navigation
  4. Uses consistent styling across all endpoints

You don't need to do anything - it's automatic!

In MDX Files

For custom pages or documentation, use Badge components:

## API Methods

<Badge color="green">GET</Badge> - Retrieve data (read operations)

<Badge color="blue">POST</Badge> - Create or modify data (write operations)

<Badge color="orange">PUT</Badge> - Update existing data

<Badge color="red">DELETE</Badge> - Remove data

🔧 Configuration

docs.json

{
  "openapi": "openapi.json",
  "navigation": {
    "tabs": [
      {
        "tab": "API Reference",
        "openapi": "openapi.json",
        "groups": [
          {
            "group": "Agents",
            "pages": [
              "GET /api/v1/agent"
            ]
          },
          {
            "group": "Calls",
            "pages": [
              "POST /api/v1/call/dial",
              "GET /api/v1/status/call"
            ]
          }
        ]
      }
    ]
  }
}

OpenAPI Endpoint Example

{
  "paths": {
    "/api/v1/agent": {
      "get": {
        "summary": "Get Agent",
        "description": "Retrieves the configuration and details for a specific AI agent.",
        "operationId": "getAgent",
        "tags": ["Agents"],
        "responses": {
          "200": {
            "description": "Success"
          }
        }
      }
    }
  }
}

Note: No Badge components in OpenAPI descriptions!

✅ Benefits

1. Automatic HTTP Method Display

Mintlify handles all HTTP method indicators automatically from OpenAPI spec

2. Single Source of Truth

All API specifications in one openapi.json file

3. Standards Compliance

Following OpenAPI 3.0 specification

4. Interactive API Playground

Built-in testing interface for all endpoints

5. Consistent Styling

Mintlify ensures consistent display across all endpoints

6. Easy Maintenance

Update one file instead of multiple MDX files

🚀 Testing

Start Local Development

cd dialgen-docs
mintlify dev

Visit http://localhost:3000

Validate OpenAPI Spec

mintlify openapi-check openapi.json

What to Check

  1. ✅ HTTP methods display automatically on endpoint pages
  2. ✅ Navigation shows correct endpoint paths
  3. ✅ API playground works for all endpoints
  4. ✅ Descriptions display correctly
  5. ✅ Badge components work in introduction.mdx

📚 Key Learnings

❌ What Doesn't Work

  • Badge components in OpenAPI descriptions - They cause errors
  • JSX/HTML in OpenAPI JSON - Not supported
  • Custom components in OpenAPI - Only works in MDX files

✅ What Works

  • Clean OpenAPI descriptions - Plain text only
  • Badge components in MDX files - Works perfectly
  • Automatic HTTP method display - Mintlify handles it
  • OpenAPI navigation - Use "METHOD /path" format

🎓 Best Practices

1. Keep OpenAPI Clean

// ✅ Good
{
  "description": "Retrieves agent configuration and details."
}

// ❌ Bad
{
  "description": "<Badge color=\"green\">GET</Badge>\n\nRetrieves agent..."
}

2. Use Badge Components in MDX

<!--  Good - In MDX files -->
<Badge color="green">GET</Badge>

<!--  Bad - In OpenAPI JSON -->
"description": "<Badge...>"

3. Let Mintlify Handle HTTP Methods

  • Don't manually add method indicators to OpenAPI
  • Mintlify automatically displays them
  • Focus on clear, concise descriptions

📖 Resources

Mintlify Documentation

OpenAPI Resources

🎯 Summary

The Dialgen API documentation now features:

✅ Complete OpenAPI 3.0 specification
✅ Automatic HTTP method display by Mintlify
✅ Badge components in MDX files (introduction.mdx)
✅ Clean, standards-compliant OpenAPI descriptions
✅ Interactive API playground
✅ Single source of truth
✅ Easy to maintain and update

Key Point: Mintlify automatically displays HTTP methods for OpenAPI-generated pages. Badge components are only for use in MDX files, not in OpenAPI JSON descriptions.

All 11 endpoints are documented and will display with automatic HTTP method indicators when viewed in Mintlify.