Running in CI

Running Optic in CI

Connecting optic diff to your CI Provider and Code Host makes it easy for every developer to review API changes and follow your team's standards.

Visual API Changelogs on Pull Requests: Large YAML diffs are hard to understand and review. Optic generates visual API changelogs to make code review more effective:

Test your team's API Changes: Optic can fail CI to prevent breaking changes and deviation from your team's API standards:

[Setup] Start tracking your APIs with Optic

Optic Cloud makes it easy to run Optic is CI, share documentation and full history of every APIs with your team, and allow developers to subscribe to each other's API changes. First create an Optic Cloud account and login:

optic login

Open one of your API projects and run the add command with an OpenAPI specification:

optic api add specs/account-service-openapi.yml

Now this OpenAPI spec is being tracked by Optic. You will notice:

  • This API's documentation appears in Optic Cloud, along with its recent history.
  • One line was added to your OpenAPI file x-optic-url. Optic uses this pointer to uniquely identify this OpenAPI in CI and on other developer's machines. Commit this to your version control system.

If you have a lot of OpenAPI specs in a monorepo, you might want to add multiple specs at once. You can always come back and add more specs later so it is ok to skip this step for now.

optic api add --all

Next we will help you run optic diff with your CI Provider: