Debug API failures using OpenAPI specs and HTTP logs
Debugs REST API failures by analyzing OpenAPI specs and HTTP logs to identify root causes and generate test commands.
/plugin marketplace add jeremylongshore/claude-code-plugins-plus-skills/plugin install cors-policy-validator@claude-code-plugins-plusSystematically debug REST API failures by analyzing OpenAPI specifications and HTTP request/response logs.
When the user requests API debugging, follow this comprehensive approach:
Use load_openapi to parse the OpenAPI spec:
- Accepts JSON or YAML format
- Extracts all endpoints, parameters, and expected responses
- Identifies authentication requirements
- Captures base URLs and server information
Example:
load_openapi({
filePath: "/path/to/openapi.yaml",
name: "my-api"
})
Use ingest_logs to import request/response data:
- Supports HAR (HTTP Archive) format from browser DevTools
- Accepts direct log arrays
- Automatically categorizes successful vs failed requests
- Calculates status code and method distributions
Example (HAR file):
ingest_logs({
filePath: "/path/to/requests.har",
format: "har"
})
Example (direct logs):
ingest_logs({
logs: [
{
timestamp: "2025-10-10T12:00:00Z",
method: "POST",
url: "https://api.example.com/users",
statusCode: 400,
requestBody: { "name": "John" },
responseBody: { "error": "Missing required field: email" }
}
]
})
Use explain_failure to understand why requests failed:
- Identifies root causes based on HTTP status codes
- Compares actual behavior with OpenAPI spec expectations
- Suggests specific fixes
- Assesses severity (critical, high, medium, low)
Example:
explain_failure({
logIndex: 0, // Index from ingest_logs
specName: "my-api" // Compare against loaded spec
})
Use make_repro to create cURL commands:
- Generates executable cURL command
- Includes alternative formats (HTTPie, JavaScript fetch)
- Useful for documentation, bug reports, and testing
Example:
make_repro({
logIndex: 0,
includeHeaders: true,
pretty: true // Format for readability
})
The debugging workflow produces:
pretty: true for readable cURL commands (good for docs)pretty: false for one-liner cURL (good for scripts)User: "My API is returning 400 errors, help me debug"
You:
1. First, do you have an OpenAPI spec? If yes, I'll load it.
2. How are you capturing HTTP logs? (HAR file, JSON logs, manual entry?)
3. Let me analyze the failures and suggest fixes.
[After receiving spec and logs]
I've loaded your API spec and found 5 failed requests:
- 3x POST /users → 400 (Missing required field: email)
- 2x GET /users/{id} → 404 (Invalid user ID format)
Let me explain the first failure...
[Uses explain_failure]
Here's a working cURL command to test the fix:
[Uses make_repro]