diff --git a/api-cli/.gitignore b/api-cli/.gitignore index 8aa64e3c2e..d57d7c71d7 100644 --- a/api-cli/.gitignore +++ b/api-cli/.gitignore @@ -12,3 +12,4 @@ resources/react .api/ resources/optic-domain-1.0.0-snapshot.tgz provided/domain.js +Readme.md diff --git a/api-cli/README.md b/api-cli/README.md index ab03cb2e18..9f488cf59e 100644 --- a/api-cli/README.md +++ b/api-cli/README.md @@ -1,3 +1,79 @@ -Read the docs at [useoptic.com](https://dashboard.useoptic.com) -Nice readme coming this week :) +
+ +
+ ++ Key Features β’ + How To Use β’ + Installing Optic β’ + License +
+ +![screenshot](https://raw.githubusercontent.com/opticdev/optic/develop/webapp/public/netlify.png) + +## Key Features +π**Easily Document any API** - 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 change log of its behavior over time. + +Itβs kind of like Git, but instead of tracking files, Optic automatically diffs and tracks API endpoints. When new behavior is observed, Optic makes it easy to update the spec: +![screenshot](https://raw.githubusercontent.com/opticdev/optic/develop/webapp/public/changes.png) + +π¨**A powerful API designer** - Optic ships with an open source API design tool that makes it easy to read and modify your API specification. + +π**100% Open Source, Runs locally, data is only stored in your API Repo** + +## How to Use +Optic learns and monitors your API's behavior by using a local proxy. To run your API with the Optic proxy in front of it, use Optic's `api start` command instead of `npm start`, `rails server`, etc. + +```bash +demo$ api start +[optic] Starting ToDo on Port: 3005, with npm run server-start + +> tododemo@0.1.0 server-start +> babel-node server/server.js +``` +Your API will behave normally when you run it with `api start`, but when Optic observes behavior that isn't in your API spec, it notifies you: +```bash +[optic] New behavior was observed. Run api spec to review. +``` +Seeing this message means that Optic has observed a non-empty diff between your API specification and your API's actual behavior. You can review this diff by running `api spec` and either merge Optic's proposed changes into your API spec or mark the new behavior as a bug. Here's a 5 min video showing this entire process end-end: +### [Watch Video on Youtube](https://www.youtube-nocookie.com/embed/WjC4Fqyyi5E) + +## Installing Optic +```bash +npm install @useoptic/cli -g +# or using yarn +yarn add global @useoptic/cli +``` +### Add Optic to your API + +```bash +cd path/to/api +api init +``` + + +This command adds a folder called '.api' that tracks the evolution of your API. This is similar to how Git uses the '.git' folder to track your code. + +```bash +.api/ +βββ api.yml # The file that configures Optic +βββ readme-docs.md # A readme that explains how to use Optic (for your teammates) +βββ .gitignore # Optic's gitignore. We want to keep your repo clean :) +βββ spec-store.json # The API spec Optic manages +``` + +The Optic proxy will make your API available on the port you use today and will assign your API another port to run on with an environment variable named: `OPTIC_API_PORT`. You should update your API code to start on `OPTIC_API_PORT` while in development so Optic can properly forward it traffic. There are [language / framework specific example of these code changes here.](https://dashboard.useoptic.com) + +## License +MIT diff --git a/api-cli/package.json b/api-cli/package.json index 9866735b5b..26759fdd91 100644 --- a/api-cli/package.json +++ b/api-cli/package.json @@ -94,7 +94,7 @@ "scripts": { "postpack": "rm -f oclif.manifest.json", "xposttest": "tslint -p test -t stylish", - "prepack": "rm tsconfig.tsbuildinfo || true && rm -rf lib && tsc -b && oclif-dev manifest && oclif-dev readme", + "prepack": "cp ../Readme.md ./Readme.md && rm tsconfig.tsbuildinfo || true && rm -rf lib && tsc -b && oclif-dev manifest && oclif-dev readme", "xtest": "ANALYTICS_IMPL=null nyc --extension .ts mocha --forbid-only \"test/**/*.test.ts\"", "version": "oclif-dev readme && git add README.md" },