Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@useoptic/cli

Package Overview
Dependencies
Maintainers
4
Versions
217
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@useoptic/cli

The Optic CLI

  • 9.0.7
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
11
decreased by-21.43%
Maintainers
4
Weekly downloads
 
Created
Source

Optic

Optic documents and tests your API as you build it

Build Status issues rust closedprs currentversion License stars


How it WorksInstallDocument APIsDetect ChangesOptic GitBotContributing License

How it Works

Optic is like Git, but for your APIs

  • Optic documents your APIs as you build them by observing development traffic and learning your API's behavior
  • Optic detects API changes by diffing traffic against the current specification
  • Optic Adds an accurate API changelog to every Pull Request

Add Optic to your API

Similar to git init

Install Optic with npm or yarn"

yarn add global @useoptic/cli
npm install @useoptic/cli -g

Then run init command:

## Navigate to your API project directory
api init

Setup aliases in for the commands your team runs when building the API in optic.yml

ie npm start -> api start

ie newman run mycollection.json -> postman-tests

name: My API
tasks:
  start:
    command: npm start
    inboundUrl: http://localhost:4000
  postman-tests:
    command: newman run mycollection.json
    usesTask: http://localhost:4000

How does Optic monitor local traffic? Whenever you start your API or run tests using Optic's CLI, it will observe your traffic and surface API diffs. All of this processing is done locally, in the background, by a Rust binary built from the open source code in this repository.

Document your API using real traffic

Similar to git add

Once you add Optic to your API, hit it with some traffic, and document your first endpoints.

You just have to provide Optic with your API paths, and it will document every status code, response body, and request body automatically based on its observations.

You don't have to worry about hitting every possible request/response your first go -- Optic isn't "one-shot", it builds your spec up incrementally as it makes more observations about your API's behavior. If it sees a 200 for an endpoint, and later sees a 400 for the same endpoint, it will help you add the new response -- same for fields, requests, entire endpoints and instances of polymorphism in your API.

api start
[optic] Starting My API API on Port: 3005, with npm run server-start

The api documentation

Detect API Changes

Similar to git status

You should keep using the Optic CLI to start your API and run its tests whenever you're developing new functionality. Optic strives to be completely transparent, and the aliases api start and api run <task> are easy to remember.

While Git diffs your, Optic will be sitting there, in the background, diffing your API. You can run api status to check if for diffs:

The api start command initializing

Use the Optic UI to Review Diffs + Update your Specification

Similar to staging changes

When Optic detects an API diff, it helps you:

  • Document new endpoints without writing a bunch of OpenAPI
  • Update your API specification with a few clicks
  • Detect any unplanned changes, breaks and regressions, then fix them

The api start command initializing

An API Changelog in Every PR

Similar to GitHub's compare page, but for API changes

The Optic GitBot adds an API Changelog during Code Review, so your team understands how the API will change when each PR is merged.

🚦 Prevent Breaking Changes

Discover breaking changes before they're merged. Request compatible changes in code review, or coordinate the breaking changes with consumers.

🔎 API First

Adding explicit API changelogs in PRs facilitates discussion and leads to better API design. It's also a great way to make sure unintended API changes don't get deployed.

✅ Updated Docs

No more doc drift. When you approve an API change Optic also updates the specification.

Install & Set up the GitBot it's free!

changelog

Key Features

📝 Accurate API Documentation - We built Optic to make maintaining accurate specs for your APIs automatic and developer friendly. Once you add Optic to your API repo, it automatically tracks your API’s behavior and maintains a changelog

⚙️ Automated Testing - Automate most of your contract testing. Optic turns your existing tests and development traffic into contract tests, and measures your API coverage from various sources.

👍 Beautiful Docs - Stripe-style documentation for every API managed by Optic.

👋 100% Open Source, Runs locally, data is only stored in your API Repo

Documentation https://useoptic.com/docs

Resources

Want to help us design the next features? Book Maintainer Office Hours

License

MIT

Contributors ✨

Thanks goes to these wonderful people (emoji key):

All Contributors


Aidan Cunniffe

📖 💻

devdoshi

📖 💻

Evan Mallory

📖

Jaap van Hardeveld

💻 📖

Ronak Shah

💻 📖

taraedits

📖

Lou Manglass

💻 📖

Nate Meyer

💻

Tim Gates

📖

Matthew Hudson

📖

LaV

📖

Gaurav Nelson

📖

Ross Nordstrom

🎨 💻 🐛

Kin Lane

🤔 🖋

Viljami Kuosmanen

🤔 🖋

Richard Crowley

🔬 🤔

dnmtr

👀

This project follows the all-contributors specification. Contributions of any kind welcome!

Keywords

FAQs

Package last updated on 29 Jan 2021

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc