Integrates Optic with your API. API init guides you through setup so that you can get running as quickly as possible. There are no required parameters, and the CLI will take you directly to the Optic dashboard to complete and test the integration.
The following optional parameters may be included to pre-populate configuration parameters:
To initialize Optic with your project use:
<your present working directory>Is this your API's root directory? (yes/no): yesWhat is this API named?: <api name>[optic] Added Optic configuration to <your present working directory>/optic.yml
To initialize Optic with your project, passing a start command for your API project and setting the port on which Optic will listen for traffic to 4000 use:
api init --command "./run" --inboundUrl https://localhost:4000
which results in the same output as above, with the
start taks in your
optic.yml file pre-populated with the passed values.
When running api init against a project that has already been initialized, you'll see an error message:
This directory already has an optic.yml file. You can see the current documentation for this project with api spec.
Having trouble? Open an issue on GitHub
Have an idea for changing this command? Here's where it lives in the repo. PRs welcome!
Need help or want to talk with us about a use case? Join Contributing on Discord