Scriptable Interface and Multi-Project Sync

Today we're releasing Optic 1.0.5 which contains 3 new features:

More Languages

The engine can now support multiple languages at the same time. Scala support is included in this release and Python is currently in beta.

Multi-Project Sync

You can now sync multiple projects even if they're written in a different language. For instance if you have a Akka-Http Scala backend, you can sync it with a Javascript frontend. Currently this feature is only supported locally so you'll need to have all the repos you wish to connect on your computer. Making this work remotely is on our road map but we don't have an exact release date yet.

Right now multi-project sync is structured like as a publisher/subscribe service. To publish a version of your project graph to Optic's local server just navigate to an Optic project and run:

optic publish

Your project's name from the optic.yml file will be the key the project graph is stored under. There's one local namespace for now, but as we learn more about how users take advantage of this feature we can build something more scalable.

In the optic.yml file of the projects you want to subscribe from add a connected_projects object.

name: My JS Frontend
connected_projects:
    - My Scala Backend

That's it! All the named objects in a connected project will now be available within the subscribing project. You can use them to generate client code and maintain it over time with sync.

Scriptable Interface

Optic now comes with a CLI so you can run it headless as part of your CI pipeline. We're still exploring the use cases this could support so I built the most generic command I could think of.

It's called dumpgraph and all it does is dump the project graph for an Optic project as JSON.

optic dumpgraph
ac:akka-http-optic-demo aidancunniffe$ optic dumpgraph
Loading Project: Akka HTTP Demo at /Users/aidancunniffe/Desktop/akka-http-optic-demo/optic.yml
Skills Compiled...

 Parsers: scala@0.0.1,es7@1.0.0
 Schemas: optic:rest@0.3.0/response,optic:requestjs@0.3.0/request,optic:rest@0.3.0/parameter,optic:rest@0.3.0/route,optic:rest@0.3.0/header
 Lenses: Some(Header Directive),Some(Optional Parameter),Some(200 with Json),Some(Akka Path Directive),Some(example-scala),Some(Not Found Response),Some(Required Parameter),Some(HTTP Request)
 Transformations: Request From Route

Reading Project...

Finished Reading Project
Snapshoting Project


{
  "projectInfo" : {
    "name" : "Akka HTTP Demo",
    "directory" : "/Users/aidancunniffe/Desktop/akka-http-optic-demo",
    "status" : {
      "loaded" : "Loaded",
      "sourcegear" : "Valid",
      "monitoring" : "Watching",
      "config" : "ValidConfig",
      "firstPass" : "Complete",
      "lastUpdate" : "Fri Aug 10 13:20:45 PDT 2018",
      "isValid" : true,
      "isLoading" : false,
      "hasErrors" : false,
      "errors" : [ ],
      "syncStatus" : "UpToDate"
    }
  },
  "results" : [{
    "name" : "Get Account",
    "schemaRef" : "optic:rest@0.3.0/route",
    "lensRef" : "optic:akka-http@0.1.0/akka-path-directive",
    "value" : {
      "parameters" : [ {
        "in" : "query",
        "required" : true,
        "name" : "accountId"
      } ],
      "method" : "get",
      "url" : "account",
      "headers" : [ ],
      "responses" : [ {
        "code" : 200
      }, {
        "code" : 404
      } ]
    },
    "inFile" : "/src/main/scala/com/optic/demo/api/AccountRoutes.scala"
  }

  ...a few dozen other objects

  ]
}

You can also pipe the resulting json into an arbitrary cmd like so:

optic dumpgraph 'node dosomething.js'

optic dumpgraph 'python3 dosomething.py'

The graph with come in as a json string in the first arg.

What are some good use cases for the CLI? Any more commands we should add? Email me at aidan@useoptic.com