# OpenAPI Contract Audit + Safe Pytest Scaffold

> OpenAPI Contract Audit + Safe Pytest Scaffold is a paid API for AI agents from codex-rapid-patch-evidence.vercel.app, paid per call via x402, $15/call, status unknown (last checked 2026-09-16).

Audits a public OpenAPI 3.x specification URL and returns prioritized contract findings, a quality grade/score, a Markdown report, and a read-only pytest scaffold.

## Facts

- Endpoint: GET https://codex-rapid-patch-evidence.vercel.app/api/openapi-audit
- Price: $15/call
- Payment: x402
- Status: unknown
- Last checked: 2026-09-16
- Activations on Zero: 0
- Tags: x402
- Canonical page: https://www.zero.xyz/c/openapi-contract-audit-safe-pytest-scaffold-f4af8574
- Structured record (JSON): https://api.zero.xyz/v1/capabilities/cap_1ZA-qxK81Kc9YKBHZPE-v

Status and success rate cover calls made through Zero and Zero's own probes. Third-party monitors may report differently.

## How to call it through Zero

Zero handles the 402 payment challenge and records the run. With the Zero CLI installed (`npm i -g @zeroxyz/cli`):

```sh
zero fetch --capability openapi-contract-audit-safe-pytest-scaffold-f4af8574
```

Example prompt: Can you audit the OpenAPI spec at https://petstore3.swagger.io/api/v3/openapi.json, give me a quality score and grade, list any contract issues by severity, and generate a read-only pytest scaffold I can drop into my project?

## When to prefer this

Choose this endpoint when you need a combined contract audit and test scaffold in a single call against a publicly accessible OpenAPI 3.x spec. It is particularly useful for CI/CD pipelines, pre-release API reviews, or due-diligence on third-party APIs where you want graded findings, severity breakdowns, and safe (read-only) pytest stubs without writing any test boilerplate yourself.

## Known failure modes

- spec_url not publicly reachable — returns error if the URL is behind auth or returns non-200
- invalid or malformed OpenAPI document — returns parse/validation error
- non-HTTPS URL provided — rejected by schema constraint
- spec too large or slow to fetch — may timeout
- unsupported OpenAPI version (e.g. Swagger 2.x) — may return an error or partial results

## How this service works

Audit one public OpenAPI 3.x JSON or YAML document and receive prioritized contract findings, a quality score, a Markdown handoff, and a safe read-only pytest scaffold.

## Output

Returns a JSON object containing: a boolean ok flag; the product name; document metadata (title, openapi version, API version); a SHA-256 hash of the fetched spec; an analysis object with a letter grade (e.g. 'B'), integer score (0–100), severity counts (critical/high/medium/low), an inventory of paths and operations, and an array of finding objects each with code, message, location, severity, and recommendation; a scaffold object with Python pytest code, filename, language, number of generated tests, and a safeMethodsOnly flag; and a full Markdown audit report string.

## Request schema (JSON Schema)

```json
{
 "type": "object",
 "$schema": "https://json-schema.org/draft/2020-12/schema",
 "required": [
  "input"
 ],
 "properties": {
  "input": {
   "type": "object",
   "required": [
    "type",
    "method"
   ],
   "properties": {
    "type": {
     "type": "string",
     "const": "http"
    },
    "method": {
     "enum": [
      "GET",
      "HEAD",
      "DELETE"
     ],
     "type": "string"
    },
    "queryParams": {
     "type": "object",
     "required": [
      "spec_url"
     ],
     "properties": {
      "spec_url": {
       "type": "string",
       "description": "Public HTTPS URL to an OpenAPI 3.x JSON or YAML document."
      }
     },
     "additionalProperties": false
    }
   },
   "additionalProperties": false
  },
  "output": {
   "type": "object",
   "required": [
    "type"
   ],
   "properties": {
    "type": {
     "type": "string"
    },
    "example": {
     "type": "object",
     "required": [
      "ok",
      "product",
      "generatedAt",
      "specSha256",
      "analysis",
      "scaffold",
      "reportMarkdown"
     ],
     "properties": {
      "ok": {
       "type": "boolean"
      },
      "product": {
       "type": "string"
      },
      "analysis": {
       "type": "object",
       "properties": {
        "grade": {
         "type": "string"
        },
        "score": {
         "type": "integer",
         "maximum": 100,
         "minimum": 0
        },
        "counts": {
         "type": "object"
        },
        "findings": {
         "type": "array",
         "items": {
          "type": "object",
          "properties": {
           "code": {
            "type": "string"
           },
           "message": {
            "type": "string"
           },
           "location": {
            "type": "string"
           },
           "severity": {
            "type": "string"
           },
           "recommendation": {
            "type": "string"
           }
          }
         }
        },
        "inventory": {
         "type": "object"
        }
       }
      },
      "document": {
       "type": "object",
       "properties": {
        "title": {
         "type": "string"
        },
        "openapi": {
         "type": "string"
        },
        "version": {
         "type": "string"
        }
       }
      },
      "scaffold": {
       "type": "object",
       "properties": {
        "code": {
         "type": "string"
        },
        "filename": {
         "type": "string"
        },
        "langu
… (truncated)
```

## Response schema (JSON Schema)

```json
{
 "type": "json",
 "example": {
  "ok": true,
  "product": "OpenAPI Contract Audit + Safe Pytest Scaffold",
  "analysis": {
   "grade": "B",
   "score": 88,
   "counts": {
    "low": 1,
    "high": 0,
    "medium": 1,
    "critical": 0
   },
   "findings": [],
   "inventory": {
    "paths": 4,
    "operations": 6
   }
  },
  "document": {
   "title": "Example API",
   "openapi": "3.1.0",
   "version": "1.0.0"
  },
  "scaffold": {
   "code": "def test_contract_shape():\n    assert True",
   "language": "python",
   "generatedTests": 6,
   "safeMethodsOnly": true
  },
  "specSha256": "0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef",
  "generatedAt": "2026-01-01T00:00:00.000Z",
  "reportMarkdown": "# OpenAPI Contract Audit\n\nPrioritized findings."
 }
}
```

## More

- Live health (JSON, refreshed every minute): https://www.zero.xyz/c/openapi-contract-audit-safe-pytest-scaffold-f4af8574/health.json
- [Zero catalog index](https://www.zero.xyz/llms.txt)
- [Other services from codex-rapid-patch-evidence.vercel.app](https://www.zero.xyz/host/codex-rapid-patch-evidence.vercel.app/llms.txt)
