{"uid":"cap_1ZA-qxK81Kc9YKBHZPE-v","slug":"openapi-contract-audit-safe-pytest-scaffold-f4af8574","name":"OpenAPI Contract Audit + Safe Pytest Scaffold","description":"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.","url":"https://codex-rapid-patch-evidence.vercel.app/api/openapi-audit","method":"GET","headers":{},"bodySchema":{"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"},"language":{"type":"string"},"generatedTests":{"type":"integer"},"safeMethodsOnly":{"type":"boolean"}}},"specSha256":{"type":"string"},"generatedAt":{"type":"string","format":"date-time"},"reportMarkdown":{"type":"string"}}}}}}},"responseSchema":{"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."}},"example":null,"exampleRequest":null,"tags":["x402"],"displayCostAmount":"15","displayCostAsset":"USDC","priceDynamic":false,"priceHint":null,"priceStatus":"priced","priceSource":"probe","requiresHandshake":false,"reviewCount":0,"rating":{"score":"0.00","successRate":"0.00","reviews":0,"stars":null,"state":"unrated"},"availabilityStatus":"unknown","priceObserved":null,"sessionDeposit":null,"pricing":{"kind":"static","summary":"$15/call","primary":{"kind":"static","protocol":"x402","network":"base","amountUsd":"15","per":"call","confidence":"exact"},"accepted":[{"kind":"static","protocol":"x402","network":"base","amountUsd":"15","per":"call","confidence":"exact"}]},"paymentMethods":[{"uid":"pm_rpXltD4gbSnu75gEwq-uW","protocol":"x402","methodType":"crypto","chain":"base","mode":"charge","costAmount":"15","costPer":"request","priority":0,"asset":"0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913","unit":"request","depositMicros":null,"planRef":null}],"brandName":null,"brandSlug":null,"brandBaseUrl":null,"brandDocsUrl":null,"whatItDoes":"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.","exampleAgentPrompt":"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?","exampleUseCases":[{"title":"Pre-release API contract review","prompt":"Before we ship, can you audit our OpenAPI spec at https://api.mycompany.com/openapi.yaml and tell me the quality grade, any critical or high-severity findings, and how many operations are covered?"},{"title":"Auto-generate safe regression tests","prompt":"I want a read-only pytest scaffold generated from the OpenAPI spec at https://raw.githubusercontent.com/myorg/myservice/main/openapi.json — make sure it only touches safe GET/HEAD/DELETE endpoints."},{"title":"Third-party API due diligence","prompt":"We're integrating a vendor API — can you pull their spec from https://vendor.example.com/api/openapi.yaml and give me a Markdown report with prioritized contract findings and an overall quality score so I can decide if it's production-ready?"}],"resultDescription":"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.","failureModes":["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"],"whenToPreferThis":"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.","instructions":null,"reviewSummary":null,"reviewSummaryHighlights":null,"reviewSummaryConcerns":null,"reviewSummaryGeneratedAt":null,"activationCount":0,"lastUsedAt":null,"lastSuccessfullyRanAt":null,"lastHealthCheckAt":"2026-09-13T18:43:50.305Z","isFirstParty":false}