Advanced Features

OpenAPI Import

Import existing API specifications to instantly create mock endpoints

What is OpenAPI?

OpenAPI (formerly Swagger) is an industry-standard specification format for describing RESTful APIs. It defines endpoints, request/response schemas, authentication, and more in a structured JSON or YAML format.

Benefits of OpenAPI Import

  • Instant Setup: Create complete APIs in seconds, not hours
  • Accurate Structure: Preserve exact data types and validation rules
  • Team Collaboration: Share specs between backend and frontend teams
  • Documentation: Import descriptions and examples automatically
  • Consistency: Ensure mock API matches production spec

Supported Formats

OpenAPI 3.x (JSON)

Modern OpenAPI format in JSON

{
  "openapi": "3.0.0",
  "info": {
    "title": "User API",
    "version": "1.0.0"
  },
  "paths": { ... }
}
Recommended
OpenAPI 3.x (YAML)

Modern OpenAPI format in YAML

openapi: 3.0.0
info:
  title: User API
  version: 1.0.0
paths: ...
Recommended
Swagger 2.0 (JSON)

Legacy Swagger format

{
  "swagger": "2.0",
  "info": {
    "title": "User API",
    "version": "1.0.0"
  }
}
Supported
Swagger 2.0 (YAML)

Legacy Swagger format

swagger: "2.0"
info:
  title: User API
  version: 1.0.0
Supported

How to Import

1

Navigate to Import Page

Go to Dashboard → Import → OpenAPI

2

Choose Import Method

Select one of three import methods:

File Upload

Upload .json or .yaml file

URL Import

Paste URL to spec file

Paste Content

Copy/paste spec directly

3

Validation

System validates your OpenAPI spec for errors

Valid OpenAPI 3.0.0 specification detected
4

Review & Configure

Preview what will be imported:

  • • Number of endpoints found
  • • Data schemas and models
  • • HTTP methods supported
  • • Mock data generation settings
5

Import Complete

Your project is created with all endpoints and schemas ready to use!

What Gets Imported?

Endpoints & Paths

All paths from the spec become API endpoints:

/users → GET, POST/users/{id} → GET, PUT, DELETE/products → GET, POST
Data Schemas

Schema definitions are converted to database models:

OpenAPI:

type: string

Mock API:

String field
type: integer
Number field
HTTP Methods

GET, POST, PUT, PATCH, DELETE operations are automatically configured

Descriptions & Examples

Field descriptions and example values from the spec are preserved

Validation Rules

Constraints are automatically applied:

  • • Required fields
  • • String length (minLength, maxLength)
  • • Number ranges (minimum, maximum)
  • • Enum values
  • • Pattern matching (regex)

Example OpenAPI Spec

Complete User API Example
{
  "openapi": "3.0.0",
  "info": {
    "title": "User Management API",
    "version": "1.0.0",
    "description": "Complete CRUD API for user management"
  },
  "servers": [
    {
      "url": "https://api.example.com/v1"
    }
  ],
  "paths": {
    "/users": {
      "get": {
        "summary": "Get all users",
        "responses": {
          "200": {
            "description": "List of users",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/User"
                  }
                }
              }
            }
          }
        }
      },
      "post": {
        "summary": "Create a new user",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/UserInput"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "User created successfully"
          }
        }
      }
    },
    "/users/{id}": {
      "get": {
        "summary": "Get user by ID",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "integer"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "User details"
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "User": {
        "type": "object",
        "properties": {
          "id": {
            "type": "integer",
            "example": 1
          },
          "name": {
            "type": "string",
            "minLength": 3,
            "maxLength": 50,
            "example": "John Doe"
          },
          "email": {
            "type": "string",
            "format": "email",
            "example": "john@example.com"
          },
          "role": {
            "type": "string",
            "enum": ["user", "admin"],
            "default": "user"
          },
          "isActive": {
            "type": "boolean",
            "default": true
          },
          "createdAt": {
            "type": "string",
            "format": "date-time"
          }
        },
        "required": ["name", "email"]
      }
    }
  }
}
This creates 3 endpoints with full CRUD operations

Mock Data Generation

After importing, you can automatically generate mock data based on your schemas:

Automatic Field Mapping

Field types are intelligently mapped to Faker.js generators:

format: email

→ faker.internet.email()

format: date-time

→ faker.date.recent()

format: uri

→ faker.internet.url()

type: boolean

→ faker.datatype.boolean()

Example Values

If your spec includes example values, they're used as templates:

"email": {
  "type": "string",
  "example": "user@company.com"
}
// Generated: alice@tech.com, bob@startup.io, etc.

Common Issues & Solutions

Invalid Spec Format

Problem: "Invalid OpenAPI specification"

Solutions:

  • • Validate your spec at editor.swagger.io
  • • Check JSON/YAML syntax for errors
  • • Ensure openapi version is specified correctly
  • • Verify all $ref references are valid
Missing Schemas

Problem: Endpoints imported but no data structure

Solution: Define schemas in components/schemas section

Large Spec Files

Problem: Import takes a long time or times out

Solution: Split large specs into smaller ones or import only needed paths

Best Practices

✓ Validate Before Import

Use Swagger Editor or online validators to ensure your spec is valid before importing.

✓ Include Examples

Add example values to your schemas for better mock data generation.

✓ Use Components/Schemas

Define reusable schemas in components section to avoid duplication and ensure consistency.

✓ Keep Specs Updated

When your backend API changes, re-import the updated spec to keep your mock API in sync.