AD SPACE AVAILABLE · BRAND PARTNERS WELCOME

How to Import OpenAPI Specifications into Mintlify for Interactive API Reference Pages

365Finds Editorial
Indexed 11,430 Wiki articles

Put 365 Wiki to work with your AI

Copy the prompt below, paste it into the AI you already use, then ask your question.

Download full Skill

Try it with the prompt first. If you use 365 Wiki often, install the full 365Wiki Skill so you do not have to paste it again. No regular AI? Gemini or Microsoft Copilot on the web will work.

365Wiki Skill

Mintlify transforms OpenAPI 3.0 and 3.1 specifications into modern, interactive API documentation. Instead of manually writing markdown tables for request parameters, headers, and payload schemas, development and documentation teams can import an OpenAPI file in JSON or YAML format. Mintlify automatically parses the endpoints, renders structured parameter lists, provides code sample generators across multiple programming languages, and supplies a live API playground where developers can test requests directly from the browser.

The platform follows a docs-as-code workflow. Your OpenAPI definition lives alongside your documentation source in Git, and any configuration changes are managed through Mintlify's central configuration file (docs.json, or mint.json in earlier setups). Depending on your team's workflow, you can either automatically generate an entire API reference section from the spec with zero manual maintenance, or bind individual OpenAPI endpoints to custom MDX pages to weave narrative guides around your operations.


Prerequisites and Supported Formats

Before configuring Mintlify, verify that your specification meets the following criteria:


Step 1: Placing the OpenAPI Specification File

You can introduce your OpenAPI file to Mintlify through either local repository storage or a remote URL:

  1. Local Repository (Recommended): Place your specification file directly inside your documentation repository. A common pattern is placing it in the root directory (for example, openapi.json or openapi.yaml) or inside a dedicated API directory (such as api-reference/openapi.json or specs/v1.yaml).

  2. Hosted Remote URL: If your backend CI/CD pipeline automatically publishes an updated specification file to an accessible object storage bucket or CDN, you can provide an HTTPS URL directly (for example, https://api.example.com/specs/openapi.json). For production builds, remote specification URLs must use HTTPS.


Step 2: Configuring Navigation in docs.json

To render the API reference in your documentation sidebar, map the specification within the navigation object of docs.json.

Approach A: Automatic Reference Generation

If you want Mintlify to automatically parse all paths, group them by their OpenAPI tags, and generate endpoint pages on the fly, reference the file directly within a navigation tab or group:

{
  "$schema": "https://mintlify.com/docs.json",
  "name": "Acme API Docs",
  "navigation": {
    "tabs": [
      {
        "tab": "Guides",
        "groups": [
          {
            "group": "Getting Started",
            "pages": ["introduction", "quickstart"]
          }
        ]
      },
      {
        "tab": "API Reference",
        "openapi": "openapi.json"
      }
    ]
  }
}

When Mintlify reads this configuration, it inspects every endpoint defined under paths, extracts the HTTP method, summary, description, parameters, and responses, and automatically creates a browsable navigation structure without requiring a single MDX file.

Handling Multiple Specifications

If your platform consists of distinct microservices or separate API versions, pass an array of file paths:

{
  "navigation": {
    "tabs": [
      {
        "tab": "API Reference",
        "openapi": [
          "specs/v1/auth.json",
          "specs/v1/billing.json",
          "specs/v2/core.json"
        ]
      }
    ]
  }
}

Step 3: Granular Control with MDX Endpoint Pages

While full auto-generation requires the least maintenance, technical writers often need to insert custom narrative content, callout warnings, prerequisites, architecture diagrams, or bespoke code snippets alongside an endpoint. Mintlify enables this hybrid approach through frontmatter binding.

1. Linking an MDX File to a Specific Endpoint

Create an MDX file (for example, api-reference/users/create.mdx) and specify the HTTP method and route in the openapi frontmatter key:

---
title: "Create User"
sidebarTitle: "Create User"
description: "Register a new user account within an organization"
openapi: "POST /v1/users"
---

## Overview

Before creating a user, ensure that your application has obtained the `users:write` OAuth scope.

<Warning>
  User email addresses must be unique across the entire organization. Attempting to register an existing email will return a `409 Conflict`.
</Warning>

## Webhook Notifications

Upon successful registration, Acme triggers a `user.created` event to your configured webhook endpoints.

Mintlify parses POST /v1/users from your global OpenAPI specification, injects the interactive request builder and parameter documentation directly into the page, and places your custom MDX copy seamlessly around it.

If your project imports multiple OpenAPI files, prepend the specific file path to avoid route collisions:

---
title: "Create User"
openapi: "specs/v1/auth.json POST /v1/users"
---

2. Scaffolding MDX Pages Using the Mintlify Scraper

If you have dozens of endpoints and want individual MDX files generated automatically so you can selectively customize them, use Mintlify's official scraping utility:

npx @mintlify/scraping@latest openapi-file ./openapi.json -o api-reference

This command parses your specification and generates dedicated MDX files for each operation inside the api-reference directory, pre-configured with the corresponding openapi frontmatter properties.


Step 4: Configuring the Interactive API Playground

Mintlify's interactive playground allows developers to send live HTTP requests directly from the documentation. To ensure the playground functions smoothly, align your OpenAPI file and docs.json settings:

1. Defining the Base URL

Mintlify derives target URLs from the servers array in your OpenAPI document:

servers:
  - url: https://api.example.com/v1
    description: Production Server
  - url: https://staging.api.example.com/v1
    description: Staging Sandbox

If multiple servers are defined, Mintlify displays a dropdown selector in the playground interface.

2. Setting Up Authentication Schemes

Configure securitySchemes in your specification so the playground prompts users for appropriate credentials:

components:
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      bearerFormat: JWT
      description: Enter your account API token
security:
  - bearerAuth: []

To provide safe test credentials or demo keys in documentation sandboxes, you can define the x-default vendor extension on your security scheme:

{
  "components": {
    "securitySchemes": {
      "apiKey": {
        "type": "apiKey",
        "in": "header",
        "name": "X-API-Key",
        "x-default": "demo_pk_live_testing123"
      }
    }
  }
}

3. Handling Browser CORS Requirements

Because the interactive playground issues real HTTP requests from the developer's web browser, your API server must support Cross-Origin Resource Sharing (CORS). Ensure your staging or public endpoints return appropriate headers:

If your backend rejects browser preflight requests (OPTIONS), the playground will fail to receive responses even if curl commands succeed.


Step 5: Modifying Specifications with OpenAPI Overlays

Technical writers often encounter backend-generated OpenAPI specs containing internal endpoints, technical jargon, or missing marketing copy that cannot easily be modified in source code. Rather than manually editing or maintaining a divergent copy of the spec, Mintlify supports the OpenAPI Overlay Specification (v1.1.0).

An overlay file defines targeted JSONPath actions (update, remove, copy) applied during documentation compilation.

Create an overlay file (for example, overlays/public-filter.yaml):

overlay: 1.1.0
info:
  title: Public Documentation Tweaks
  version: 1.0.0
extends: ./openapi.json
actions:
  - target: $.info.description
    update: "Welcome to Acme's developer documentation. Explore endpoints and test payloads."
  - target: $.paths['/internal/system-health']
    remove: true
  - target: $.paths['/v1/billing'].post.summary
    update: "Create recurring billing subscription"

Then reference the overlay in your docs.json:

{
  "navigation": {
    "tabs": [
      {
        "tab": "API Reference",
        "openapi": {
          "source": "openapi.json",
          "overlays": ["overlays/public-filter.yaml"]
        }
      }
    ]
  }
}

Mintlify applies the overlay non-destructively, stripping out internal routes and updating customer-facing descriptions while keeping upstream engineering specs pristine.


Step 6: Local Validation and CI/CD Automation

Before deploying documentation updates to production, validate the configuration locally using the Mintlify CLI.

  1. Install and Run the Dev Server:

    npm i -g mintlify
    mint dev
    
  2. Testing Local Schema Endpoints: If your backend service runs locally (for instance, http://localhost:8000/openapi.json), start the Mintlify server with the local schema permission flag:

    mint dev --local-schema
    
  3. Strict Validation Checks: Run syntax and integrity checks to catch broken schema references or formatting discrepancies:

    mint validate
    
  4. Continuous Integration (CI): Incorporate mint validate into your GitHub Actions or GitLab CI pipelines. Whenever backend engineers push changes to the OpenAPI file, CI verifies that all references resolve, preventing broken documentation from reaching production.


References