Skip to content

Plugin Architecture

Tim Burks edited this page Jan 27, 2017 · 7 revisions

openapic can invoke third-party OpenAPI tools using a plugin architecture that is similar to the one used by protoc, the Protocol Buffer compiler.

openapic plugins can be written in any language that can read and write Protocol Buffers. They interface with openapic by reading from stdin and writing to stdout. When openapic calls a plugin, it launches the plugin process and writes a PluginRequest message to the plugin's stdin and waits for the plugin to write a PluginResponse message to its stdout.

Plugins are invoked by passing an option to openapic of the form --<plugin>_out=<path> where path is a directory where the plugin's output should be written. Plugin binaries are expected to be named openapi_<plugin> and in the current search path. For example --go_service_out=. will invoke the openapi_go_service plugin and write its output in the current working directory.

For details of the plugin interface and examples, see the plugins directory.

To Do: Plugin Parameters

We would like to be able to pass parameters to plugins, and to do that, will build support similar to what is provided by protoc: https://github.com/golang/protobuf#parameters

Clone this wiki locally