explaingit

alufers/mitmproxy2swagger

9,471HTMLAudience · developerComplexity · 2/5LicenseSetup · easy

TLDR

A command-line tool that converts recorded network traffic, from mitmproxy captures or browser HAR exports, into an OpenAPI 3.0 spec describing an app's API. No access to source code or backend needed.

Mindmap

mindmap
  root((repo))
    Inputs
      mitmproxy flow file
      Browser HAR export
    Process
      First pass draft
      Edit ignore prefix
      Second pass enrich
    Output
      OpenAPI 3.0 spec
      Endpoint descriptions
    Install
      pip install
      Docker option
Click or tap to explore — scroll the page freely

Code map

Detail Auto

An interactive map of this repo's files and how they connect — its source is parsed live in your browser. Click Visualize to build it.

filefunction / class

Things people build with this

USE CASE 1

Reverse-engineer an undocumented mobile app's API to build integrations without backend source code

USE CASE 2

Generate an OpenAPI spec from browser traffic captured in Chrome DevTools without setting up a proxy

USE CASE 3

Auto-document a legacy backend by recording real usage and running it through the two-pass conversion process

USE CASE 4

Import the resulting OpenAPI spec into Postman or other tools to generate tests or client code

Tech stack

PythonOpenAPIDockerpip

Getting it running

Difficulty · easy Time to first run · 30min

Requires a recorded mitmproxy traffic capture or a HAR file exported from Chrome DevTools before running the tool.

Use freely for any purpose, including commercial use, as long as you keep the copyright notice.

In plain English

mitmproxy2swagger is a command-line tool that watches the network traffic going in and out of an app and automatically builds a written description of the API that app is using. An API description in this context is a structured document that spells out what requests the app makes, what data it sends, and what it expects back. The format it produces is called OpenAPI 3.0, which many other developer tools can read to generate documentation or tests. The typical scenario is: you have a mobile app or a web service, and you want to understand how it communicates with its backend server, but you do not have access to the backend's source code or documentation. You run a traffic-capture tool called mitmproxy alongside the app, use the app normally for a while, then save that recorded traffic to a file. You feed that file into mitmproxy2swagger, and it figures out the URL patterns, HTTP methods, and data structures on its own. The process runs in two passes. The first pass produces a draft file listing every URL path it detected, each marked with an ignore prefix by default. You open that file in a text editor, remove the ignore prefix from the endpoints you actually care about, and save it. The second pass reads the edited file and fills in the full endpoint descriptions. You can optionally include example request and response data, though the README notes that this may expose sensitive information like tokens or passwords. Beyond mitmproxy captures, the tool also accepts HAR files, which are traffic exports you can get directly from the Network tab in a browser's developer tools. This makes it usable without any proxy setup at all. Installation is through pip, the standard Python package installer, or via Docker if you prefer a contained environment. The tool is open source under the MIT license and includes a test suite and code formatting checks for contributors.

Copy-paste prompts

Prompt 1
I used mitmproxy to record traffic from a mobile app and saved a flow file. Walk me through the two-pass mitmproxy2swagger process to produce a final OpenAPI 3.0 spec.
Prompt 2
I want to document an undocumented API using only Chrome DevTools. How do I export a HAR file and feed it into mitmproxy2swagger to get an openapi.yaml?
Prompt 3
After running mitmproxy2swagger's first pass, what do I edit in the draft YAML file to select which endpoints get fully documented in the second pass?
Prompt 4
How do I install mitmproxy2swagger via pip and run it on a HAR file to produce an OpenAPI spec I can import into Postman?
Open on GitHub → Explain another repo

← alufers on gitmyhub — every repo by this author, as a profile.

Verify against the repo before relying on details.