Processing reports

Pass --report <PATH> to either discover or generate to write a JSON processing summary. This is useful for CI pipelines that need structured data instead of log scraping.

Usage

mitm2openapi discover \
  -i capture.flow \
  -o templates.yaml \
  -p "https://api.example.com" \
  --report report.json

Report schema

{
  "report_version": 1,
  "tool_version": "0.5.1",
  "input": {
    "path": "capture.flow",
    "format": "Auto",
    "size_bytes": 102400
  },
  "result": {
    "flows_read": 150,
    "flows_emitted": 148,
    "paths_in_spec": 12
  },
  "events": {
    "parse_error": {
      "TNetString parse error at byte 98304: unexpected end of input": 1
    }
  }
}

Fields

FieldTypeDescription
report_versionintegerSchema version (currently 1)
tool_versionstringmitm2openapi version that produced the report
input.pathstringInput file path
input.formatstringDetected or specified format (Auto, Mitmproxy, Har)
input.size_bytesintegerInput file size in bytes
result.flows_readintegerTotal flows/entries parsed from input
result.flows_emittedintegerFlows that passed all filters and were processed
result.paths_in_specintegerUnique paths in the output (for generate)
eventsobjectMap of event categories to message counts

Event categories

CategoryMeaningStatus
parse_errorCorrupt data encountered (tnetstring errors, malformed HAR entries)Populated
cap_firedA resource limit was triggered (body too large, depth exceeded)Reserved — not yet populated at runtime
rejectedA flow was skipped (invalid UTF-8, unsupported scheme, bad port/status)Reserved — not yet populated at runtime

The cap_fired and rejected categories are present in the report schema and will be connected to the reader pipelines in a future release. Currently, only parse_error events are counted.

CI integration

Parse the report in CI to make decisions based on processing quality:

mitm2openapi generate \
  -i capture.flow \
  -t templates.yaml \
  -o openapi.yaml \
  -p "https://api.example.com" \
  --report report.json

# Check if any events occurred
if jq -e '.events | length > 0' report.json > /dev/null 2>&1; then
  echo "Warning: processing had events"
  jq '.events' report.json
fi

Report with strict mode

The report is written even when --strict causes a non-zero exit code. This lets you capture full diagnostics while still failing the CI job:

mitm2openapi discover \
  -i capture.flow \
  -o templates.yaml \
  -p "https://api.example.com" \
  --strict \
  --report report.json \
  || { jq '.' report.json; exit 1; }