Making it easy to capture traffic is one of the most important aspects of the Optic project. Without traffic, the tool can not auto-document our APIs, detect changes, calculate coverage and test our APIs.
There are multiple ways to capture traffic, all with their own tradeoffs. Here is an accounting of the tradeoffs as they're understood today:
When baselining an API, it's often useful to use a mix of Manual Traffic Collection techniques and Automated Traffic Collection techniques. If you have good test coverage, or some other automated traffic sources (like Postman) already set up, you can use those to get the core of your API documented very quickly. Anything you don't have good tests for can be captured by running Optic locally or intercepting traffic from your Browsers to your application.
Once you have your API baselined in Optic, having Automated Traffic Collection methods becomes very useful. Repeatable test traffic that can be run in CI and/or locally helps developers catch unplanned API changes before they get released, and work with confidence that their API meets its contract on every build. This is most useful if you are using the API Changes in Pull Requests Workflow.
Some Optic Workflows use Passive Collection from Live API environments like Staging to help you document existing APIs, use Live Contract Testing and track API changes.
Optic can integrate with your project locally, and provides flexibility in learning from many sources. Manual integrations are a quick way to get started, no matter how you test your API today:
Integrating automated tests is the next best step for projects with good test coverage. Optic can use your existing tests to validate that your API schema follows the specification, and gives you insight into how well your tests cover the known endpoints of your API. How you can integrate your test will vary by project, so check out our general guidelines for an overview.
Explore some common deployed capture scenarios with Optic:
This is a great place to contribute new capabilities to the project.