# OpenAPI Spec Drift Detector (`stellar_ballet_0bu/openapi-spec-drift-detector`) Actor

Compare two OpenAPI 3.0/3.1 specs (JSON or YAML) and emit per-endpoint / per-operation / per-schema change rows with a `breaking` flag. Pairs with the api-response-delta-monitor.

- **URL**: https://apify.com/stellar\_ballet\_0bu/openapi-spec-drift-detector.md
- **Developed by:** [Nikita S](https://apify.com/stellar_ballet_0bu) (community)
- **Categories:** Developer tools, Automation
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

Pay per usage

This Actor is paid per platform usage. The Actor is free to use, and you only pay for the Apify platform usage, which gets cheaper the higher subscription plan you have.

Learn more: https://docs.apify.com/platform/actors/running/actors-in-store#pay-per-usage

## What's an Apify Actor?

Actors are a software tools running on the Apify platform, for all kinds of web data extraction and automation use cases.
In Batch mode, an Actor accepts a well-defined JSON input, performs an action which can take anything from a few seconds to a few hours,
and optionally produces a well-defined JSON output, datasets with results, or files in key-value store.
In Standby mode, an Actor provides a web server which can be used as a website, API, or an MCP server.
Actors are written with capital "A".

## How to integrate an Actor?

If asked about integration, you help developers integrate Actors into their projects.
You adapt to their stack and deliver integrations that are safe, well-documented, and production-ready.
The best way to integrate Actors is as follows.

In JavaScript/TypeScript projects, use official [JavaScript/TypeScript client](https://docs.apify.com/api/client/js.md):

```bash
npm install apify-client
```

In Python projects, use official [Python client library](https://docs.apify.com/api/client/python.md):

```bash
pip install apify-client
```

In shell scripts, use [Apify CLI](https://docs.apify.com/cli/docs.md):

````bash
# MacOS / Linux
curl -fsSL https://apify.com/install-cli.sh | bash
# Windows
irm https://apify.com/install-cli.ps1 | iex
```bash

In AI frameworks, you might use the [Apify MCP server](https://docs.apify.com/platform/integrations/mcp.md).

If your project is in a different language, use the [REST API](https://docs.apify.com/api/v2.md).

For usage examples, see the [API](#api) section below.

For more details, see Apify documentation as [Markdown index](https://docs.apify.com/llms.txt) and [Markdown full-text](https://docs.apify.com/llms-full.txt).


# README

## OpenAPI Spec Drift Detector

Drop two OpenAPI 3.0 / 3.1 specs (JSON or YAML) and get a per-change row with a **`breaking`** flag. Run it in a PR check, a migration audit, or a nightly CI job — the change rows are made for `jq` filtering, Slack alerts, and PR comments.

Pure JavaScript, **zero dependencies**, zero network when both specs are inline.

### Why this Actor

- **Catches what breaks clients** — added required parameters, removed 2xx responses, removed schemas, new required properties, type narrowing, enum removals.
- **Trivial CI integration** — diff two URLs, fail the build if any `breaking === true` row appears.
- **No external services** — works fully offline when both specs are inline strings.
- **Pairs with the [`api-response-delta-monitor`](https://apify.com/stellar_ballet_0bu/api-response-delta-monitor)** for runtime response-shape diffing.

### Who it is for

- Backend / platform teams shipping a public or internal HTTP API.
- DevX / SRE maintaining API gateways that need contract CI.
- Migration projects ("what changed between v1 and v2 of our API?").
- Tech writers auto-generating change logs from `openapi.yaml` PRs.

### What it catches

| Level | Change kind | Breaking? |
|-------|-------------|-----------|
| Path | `added` | no |
| Path | `removed` | **yes** |
| Operation | `added` / `removed` | yes if removed |
| Parameter | `added` | only if `required: true` |
| Parameter | `removed` | only if was `required: true` |
| Parameter | `required`-changed | **yes** if becomes required |
| Response | `added` | no |
| Response | `removed` | **yes** if 2xx |
| Response schema | `removed` | **yes** for 2xx |
| Request body | `added` / `removed` | only if removed |
| Request body | `required`-changed | **yes** if becomes required |
| Schema | `added` / `removed` | yes if removed |
| Schema property | `type`-changed (narrowing) | **yes** |
| Schema property | `required`-added | **yes** |
| Schema enum | `value`-removed | **yes** |

### Quick start

**Inline JSON (the easiest first run)**

```json
{
  "oldSpec": "{\"openapi\":\"3.0.0\",\"info\":{\"title\":\"X\",\"version\":\"1\"},\"paths\":{\"/users\":{\"get\":{\"parameters\":[{\"name\":\"q\",\"in\":\"query\"}],\"responses\":{\"200\":{\"description\":\"ok\"}}}}}}",
  "newSpec": "{\"openapi\":\"3.0.0\",\"info\":{\"title\":\"X\",\"version\":\"2\"},\"paths\":{\"/users\":{\"get\":{\"parameters\":[{\"name\":\"q\",\"in\":\"query\",\"required\":true}],\"responses\":{\"200\":{\"description\":\"ok\"},\"404\":{\"description\":\"no\"}}}}}}"
}
````

**From public URLs** (no API key, no auth, just a public `openapi.yaml`/`openapi.json`)

```json
{
  "oldUrl": "https://petstore3.openapis.org/api/v3/openapi.json",
  "newUrl": "https://petstore3.openapis.org/api/v3/openapi.json"
}
```

Mix one inline + one URL if needed.

### Output

One dataset item per detected change. Plus a `SUMMARY` key-value record with run-level counts.

```json
{
  "_kind": "change",
  "kind": "param-required-changed",
  "level": "parameter",
  "path": "/users",
  "method": "get",
  "in": "query",
  "name": "q",
  "breaking": true,
  "oldValue": { "required": false },
  "newValue": { "required": true }
}
```

`SUMMARY`:

```json
{
  "ok": true,
  "oldVersion": "3.0.0",
  "newVersion": "3.0.0",
  "changes": 2,
  "added": 1,
  "removed": 0,
  "breaking": 1
}
```

### CI example (GitHub Actions)

```yaml
- name: OpenAPI drift check
  uses: apify/apify-cli-action@v1
  with:
    command: 'apify call stellar_ballet_0bu/openapi-spec-drift-detector --input "{\"oldUrl\":\"$OLD_SPEC\",\"newUrl\":\"$NEW_SPEC\"}"'
- name: Fail on breaking changes
  run: |
    if apify call stellar_ballet_0bu/openapi-spec-drift-detector \
        --input "{\"oldUrl\":\"$OLD_SPEC\",\"newUrl\":\"$NEW_SPEC\"}" \
        --output-dataset breaking-only | jq -e '.[] | select(.breaking==true)' ; then
      echo "Breaking OpenAPI changes detected"; exit 1
    fi
```

### Pricing / cost expectations

Default 256 MB / 1 GB, no network when specs are inline. The Actor does no fetching when both `oldSpec` and `newSpec` are provided, so a single diff run is a few hundred KB of memory and well under a second of CPU. **Pay-per-event pricing** is scheduled to activate after public launch.

### Run locally

```bash
npm install
npm test     # 13 cases including breaking-change detection
```

### FAQ

**Does it support OpenAPI 2.0 (Swagger)?** Yes — it parses any spec that starts with `openapi:` or `swagger:`. Breaking-flag logic is the same; the `2.0 → 3.0` migration is out of scope.

**Does it support Swagger diff (`oldUrl` + `newUrl`)?** Yes. Public URLs only, no auth, no proxy. For private specs, paste them inline.

**Will it falsely flag 4xx/5xx as breaking on removal?** No. Only 2xx response removals are flagged breaking — losing a 404 is usually fine. Path removals and operation removals are always breaking.

**Is YAML fully supported?** A pragmatic subset: top-level scalars, nested mappings, and block sequences — covers the OpenAPI 3 YAML files typically seen in CI. For exotic YAML (anchors, multi-doc, flow style), pre-convert to JSON.

**Does it touch the network?** Only if you provide `oldUrl` and/or `newUrl`. With both specs inline, the Actor runs fully offline.

### Related Actors

- [`api-response-delta-monitor`](https://apify.com/stellar_ballet_0bu/api-response-delta-monitor) — runtime response-shape diffing (one URL over time, with emit-only-on-change).
- [`json-schema-validator`](https://apify.com/stellar_ballet_0bu/json-schema-validator) — validate any JSON document against any JSON Schema.
- [`jsonpointer-resolver`](https://apify.com/stellar_ballet_0bu/jsonpointer-resolver) — apply RFC 6901 read / RFC 6902 patch operations.
- [`webhook-sig-verifier`](https://apify.com/stellar_ballet_0bu/webhook-sig-verifier) — verify Stripe / GitHub / Apify / generic HMAC webhook signatures.
- [`security-headers-validator`](https://apify.com/stellar_ballet_0bu/security-headers-validator) — quick webops audit on a public URL.

### Support

Issues / feature requests: open an issue on the Income Factory GitHub repo or message via the Apify Actor page.

# Actor input Schema

## `oldSpec` (type: `string`):

Baseline OpenAPI 3 spec (JSON or YAML).

## `newSpec` (type: `string`):

Candidate OpenAPI 3 spec (JSON or YAML).

## `oldUrl` (type: `string`):

Public URL of the baseline spec.

## `newUrl` (type: `string`):

Public URL of the candidate spec.

## Actor input object example

```json
{
  "oldSpec": "",
  "newSpec": "",
  "oldUrl": "",
  "newUrl": ""
}
```

# Actor output Schema

## `changeRows` (type: `string`):

Default dataset items: one row per detected change, with \_kind='change', kind, level (path|operation|parameter|response|requestBody|schema), path, method, status, schema, in, name, breaking, oldValue, newValue.

## `summary` (type: `string`):

Run summary with ok, oldVersion, newVersion, changes, added, removed, breaking counts.

# API

You can run this Actor programmatically using our API. Below are code examples in JavaScript, Python, and CLI, as well as the OpenAPI specification and MCP server setup.

## JavaScript example

```javascript
import { ApifyClient } from 'apify-client';

// Initialize the ApifyClient with your Apify API token
// Replace the '<YOUR_API_TOKEN>' with your token
const client = new ApifyClient({
    token: '<YOUR_API_TOKEN>',
});

// Prepare Actor input
const input = {};

// Run the Actor and wait for it to finish
const run = await client.actor("stellar_ballet_0bu/openapi-spec-drift-detector").call(input);

// Fetch and print Actor results from the run's dataset (if any)
console.log('Results from dataset');
console.log(`💾 Check your data here: https://console.apify.com/storage/datasets/${run.defaultDatasetId}`);
const { items } = await client.dataset(run.defaultDatasetId).listItems();
items.forEach((item) => {
    console.dir(item);
});

// 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/js/docs

```

## Python example

```python
from apify_client import ApifyClient

# Initialize the ApifyClient with your Apify API token
# Replace '<YOUR_API_TOKEN>' with your token.
client = ApifyClient("<YOUR_API_TOKEN>")

# Prepare the Actor input
run_input = {}

# Run the Actor and wait for it to finish
run = client.actor("stellar_ballet_0bu/openapi-spec-drift-detector").call(run_input=run_input)

# Fetch and print Actor results from the run's dataset (if there are any)
print("💾 Check your data here: https://console.apify.com/storage/datasets/" + run["defaultDatasetId"])
for item in client.dataset(run["defaultDatasetId"]).iterate_items():
    print(item)

# 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/python/docs/quick-start

```

## CLI example

```bash
echo '{}' |
apify call stellar_ballet_0bu/openapi-spec-drift-detector --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "command": "npx",
            "args": [
                "mcp-remote",
                "https://mcp.apify.com/?tools=stellar_ballet_0bu/openapi-spec-drift-detector",
                "--header",
                "Authorization: Bearer <YOUR_API_TOKEN>"
            ]
        }
    }
}

```

## OpenAPI specification

```json
{
    "openapi": "3.0.1",
    "info": {
        "title": "OpenAPI Spec Drift Detector",
        "description": "Compare two OpenAPI 3.0/3.1 specs (JSON or YAML) and emit per-endpoint / per-operation / per-schema change rows with a `breaking` flag. Pairs with the api-response-delta-monitor.",
        "version": "0.1",
        "x-build-id": "975Ro8fcB5Watb5Zl"
    },
    "servers": [
        {
            "url": "https://api.apify.com/v2"
        }
    ],
    "paths": {
        "/acts/stellar_ballet_0bu~openapi-spec-drift-detector/run-sync-get-dataset-items": {
            "post": {
                "operationId": "run-sync-get-dataset-items-stellar_ballet_0bu-openapi-spec-drift-detector",
                "x-openai-isConsequential": false,
                "summary": "Executes an Actor, waits for its completion, and returns Actor's dataset items in response.",
                "tags": [
                    "Run Actor"
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "$ref": "#/components/schemas/inputSchema"
                            }
                        }
                    }
                },
                "parameters": [
                    {
                        "name": "token",
                        "in": "query",
                        "required": true,
                        "schema": {
                            "type": "string"
                        },
                        "description": "Enter your Apify token here"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK"
                    }
                }
            }
        },
        "/acts/stellar_ballet_0bu~openapi-spec-drift-detector/runs": {
            "post": {
                "operationId": "runs-sync-stellar_ballet_0bu-openapi-spec-drift-detector",
                "x-openai-isConsequential": false,
                "summary": "Executes an Actor and returns information about the initiated run in response.",
                "tags": [
                    "Run Actor"
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "$ref": "#/components/schemas/inputSchema"
                            }
                        }
                    }
                },
                "parameters": [
                    {
                        "name": "token",
                        "in": "query",
                        "required": true,
                        "schema": {
                            "type": "string"
                        },
                        "description": "Enter your Apify token here"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/runsResponseSchema"
                                }
                            }
                        }
                    }
                }
            }
        },
        "/acts/stellar_ballet_0bu~openapi-spec-drift-detector/run-sync": {
            "post": {
                "operationId": "run-sync-stellar_ballet_0bu-openapi-spec-drift-detector",
                "x-openai-isConsequential": false,
                "summary": "Executes an Actor, waits for completion, and returns the OUTPUT from Key-value store in response.",
                "tags": [
                    "Run Actor"
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "$ref": "#/components/schemas/inputSchema"
                            }
                        }
                    }
                },
                "parameters": [
                    {
                        "name": "token",
                        "in": "query",
                        "required": true,
                        "schema": {
                            "type": "string"
                        },
                        "description": "Enter your Apify token here"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK"
                    }
                }
            }
        }
    },
    "components": {
        "schemas": {
            "inputSchema": {
                "type": "object",
                "properties": {
                    "oldSpec": {
                        "title": "Old spec (inline JSON or YAML)",
                        "type": "string",
                        "description": "Baseline OpenAPI 3 spec (JSON or YAML).",
                        "default": ""
                    },
                    "newSpec": {
                        "title": "New spec (inline JSON or YAML)",
                        "type": "string",
                        "description": "Candidate OpenAPI 3 spec (JSON or YAML).",
                        "default": ""
                    },
                    "oldUrl": {
                        "title": "Old spec URL (alternative)",
                        "type": "string",
                        "description": "Public URL of the baseline spec.",
                        "default": ""
                    },
                    "newUrl": {
                        "title": "New spec URL (alternative)",
                        "type": "string",
                        "description": "Public URL of the candidate spec.",
                        "default": ""
                    }
                }
            },
            "runsResponseSchema": {
                "type": "object",
                "properties": {
                    "data": {
                        "type": "object",
                        "properties": {
                            "id": {
                                "type": "string"
                            },
                            "actId": {
                                "type": "string"
                            },
                            "userId": {
                                "type": "string"
                            },
                            "startedAt": {
                                "type": "string",
                                "format": "date-time",
                                "example": "2025-01-08T00:00:00.000Z"
                            },
                            "finishedAt": {
                                "type": "string",
                                "format": "date-time",
                                "example": "2025-01-08T00:00:00.000Z"
                            },
                            "status": {
                                "type": "string",
                                "example": "READY"
                            },
                            "meta": {
                                "type": "object",
                                "properties": {
                                    "origin": {
                                        "type": "string",
                                        "example": "API"
                                    },
                                    "userAgent": {
                                        "type": "string"
                                    }
                                }
                            },
                            "stats": {
                                "type": "object",
                                "properties": {
                                    "inputBodyLen": {
                                        "type": "integer",
                                        "example": 2000
                                    },
                                    "rebootCount": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "restartCount": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "resurrectCount": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "computeUnits": {
                                        "type": "integer",
                                        "example": 0
                                    }
                                }
                            },
                            "options": {
                                "type": "object",
                                "properties": {
                                    "build": {
                                        "type": "string",
                                        "example": "latest"
                                    },
                                    "timeoutSecs": {
                                        "type": "integer",
                                        "example": 300
                                    },
                                    "memoryMbytes": {
                                        "type": "integer",
                                        "example": 1024
                                    },
                                    "diskMbytes": {
                                        "type": "integer",
                                        "example": 2048
                                    }
                                }
                            },
                            "buildId": {
                                "type": "string"
                            },
                            "defaultKeyValueStoreId": {
                                "type": "string"
                            },
                            "defaultDatasetId": {
                                "type": "string"
                            },
                            "defaultRequestQueueId": {
                                "type": "string"
                            },
                            "buildNumber": {
                                "type": "string",
                                "example": "1.0.0"
                            },
                            "containerUrl": {
                                "type": "string"
                            },
                            "usage": {
                                "type": "object",
                                "properties": {
                                    "ACTOR_COMPUTE_UNITS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATASET_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATASET_WRITES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "KEY_VALUE_STORE_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "KEY_VALUE_STORE_WRITES": {
                                        "type": "integer",
                                        "example": 1
                                    },
                                    "KEY_VALUE_STORE_LISTS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "REQUEST_QUEUE_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "REQUEST_QUEUE_WRITES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATA_TRANSFER_INTERNAL_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATA_TRANSFER_EXTERNAL_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "PROXY_RESIDENTIAL_TRANSFER_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "PROXY_SERPS": {
                                        "type": "integer",
                                        "example": 0
                                    }
                                }
                            },
                            "usageTotalUsd": {
                                "type": "number",
                                "example": 0.00005
                            },
                            "usageUsd": {
                                "type": "object",
                                "properties": {
                                    "ACTOR_COMPUTE_UNITS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATASET_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATASET_WRITES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "KEY_VALUE_STORE_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "KEY_VALUE_STORE_WRITES": {
                                        "type": "number",
                                        "example": 0.00005
                                    },
                                    "KEY_VALUE_STORE_LISTS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "REQUEST_QUEUE_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "REQUEST_QUEUE_WRITES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATA_TRANSFER_INTERNAL_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATA_TRANSFER_EXTERNAL_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "PROXY_RESIDENTIAL_TRANSFER_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "PROXY_SERPS": {
                                        "type": "integer",
                                        "example": 0
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }
}
```
