OpenAPI Import
OpenAPI Import
If you have an existing OpenAPI (Swagger) specification, you can import it directly into MockLab to instantly generate mock collections that match your API's schema — no manual field configuration required.
How to import
- Go to Mock API in the dashboard. Click Import Docs in the top right.
-
Choose how to provide your spec:
Paste a URLPoint to a publicly accessible URL that serves your OpenAPI JSON or YAML (e.g. https://petstore.swagger.io/v2/swagger.json).Upload a fileUpload a local
.jsonor.yamlfile directly from your machine. -
MockLab parses the spec and shows you a list of detected schemas (e.g.
Pet,Order,User). Select which ones to import. - Click Import. MockLab creates a collection for each selected schema with auto-generated sample records and the correct field types.
Supported spec versions
OpenAPI 3.0.x Fully supported
OpenAPI 3.1.x Fully supported
Swagger 2.0 Fully supported
JSON Schema Partial (properties only)
Postman v2.1 Not supported (use OpenAPI export first)
Example import
Given this OpenAPI schema fragment:
openapi.yaml — schema definition
components:
schemas:
Product:
type: object
properties:
id:
type: string
format: uuid
name:
type: string
price:
type: number
format: float
inStock:
type: boolean
category:
type: string
enum: [Electronics, Furniture, Clothing]
createdAt:
type: string
format: date-time
MockLab generates a products collection
with the correct field types and sample data:
GET /m/user123/products/prod_4kX9z 200 OK
{
"id": "a3f2c1d0-9e4b-4f2a-8c1d-0e9b4f2a8c1d",
"name": "Wireless Headphones Pro",
"price": 79.99,
"inStock": true,
"category": "Electronics",
"createdAt": "2024-11-03T14:22:00Z"
} Known limitations
- Circular references in schemas are flattened to a maximum depth of 3 levels.
- allOf / anyOf / oneOf are simplified — MockLab picks the first schema in the list.
- Binary, file, and stream response types are not mockable and are skipped.
- $ref references to external files (outside the spec) are not resolved.
- Request/response examples from the spec are used as hints but MockLab generates its own data.