The generate command creates new code for you to use in your project. It will either:

○ Generate new code based on a model you provide

↦ Transform code it finds in your project into related code (ie transforming an API Endpoint into an HTTP Request that calls itself)

Calling Generate

There are two ways to call generate

  1. run optic generate [your query] from your terminal and press (return)
  2. or (if you're inside the interactive prompt) just type your query into the prompt.

You'll be presented with search results within Optic:


You can use the (arrow keys) navigate the results and the (return) key to select.

Generate New Code Example

Generates:'/hello-world', (req, res) => {
  const {firstName} = req.query.firstName

Transform Code Example


request.get({ uri: '', qs: { status: 'incomplete' } }, (err, response, body) => {  //source: Get All Todos Route -> optic:request-js/request-from-route {}


Next Steps: CLI Commands

  • sync
  • help - displays man in content section