Skip to content

Using Optic Capture with HAR

Aidan Cunniffe edited this page Feb 5, 2025 · 1 revision

Generate OpenAPI from HAR

optic capture generates and updates OpenAPI specs based on real traffic. Most teams use their integration tests as a traffic source. Optic also has built-in support for reading HAR 1.1 and 1.2 dumps

Note on performance: you should not run huge volumes of production traffic through this command. Performance degrades markedly after 100MB. If you really need to reverse engineer an API from a large volume of traffic, chunk it. This shouldn't be something you do over and over again on the same service.

optic capture openapi.yml --har ./file.har

Learning path patterns for unmatched requests... Documenting new operations: ✔ GET / ✔ GET /users ✔ POST /users/create

existing requests

$ optic capture openapi.yml --har ./file.har ✔ GET / ✓ 200 response ✔ GET /users ✓ 200 response ✔ POST /users/create ✓ 201 response