# 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 event

This Actor is paid per event. You are not charged for the Apify platform usage, but only a fixed price for specific events.

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

## What's an Apify Actor?

Actors are web data automations that power AI and operations. They run on the Apify platform to scrape websites, process data, connect APIs, and automate workflows.
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.

- **AI agents and MCP clients** — the [Apify MCP server](https://docs.apify.com/integrations/mcp.md) at `https://mcp.apify.com` (remote, streamable HTTP, OAuth on first use).
- **Agentic workflows and local Actor development** — [Agent Skills](https://apify.com/.well-known/agent-skills/index.json) with the [Apify CLI](https://docs.apify.com/cli/docs.md): `npm install -g apify-cli`, then `apify login`.
- **JavaScript/TypeScript projects** — the official [JS/TS client](https://docs.apify.com/api/client/js/docs.md): `npm install apify-client`.
- **Python projects** — the official [Python client](https://docs.apify.com/api/client/python/docs.md): `pip install apify-client`.
- **Any other language** — 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

Download the OpenAPI definition: https://api.apify.com/v2/actors/t9t599bs1xyWDBvar/builds/975Ro8fcB5Watb5Zl/openapi.json
