spec2proxy
This is a command-line tool that generates an Apigee X API Proxy bundle from an OpenAPI spec.
(OAS2 and OAS3 are supported)
By default, the tool generates a simple API Proxy bundle that can serve as scaffolding for
building more complex proxies.
It's possible to customize the generation logic through the use of plugins.
For example, you can create a plugin that understands OpenAPI spec extensions, and
customizes the generated API Proxy bundle based on the value of the extensions.
How to use it
spec2proxy -oas petstore.yaml -out ./petstore
How to use it with plugins
You can pass one or more plugins to use with the -plugins parameter.
e.g.
spec2proxy -oas petstore.yaml -out ./petstore -plugins example,custom_plugin,etc
This tool works as basic processing pipeline with three steps: Parse, Transform, and Generate
SpecText // file on disk
|
v
Parse(...)
|
v
libopenapi_SpecModel // Structs in memory
|
v
Transform(...)
|
v
apigee_ProxyModel // Structs in memory
|
v
Generate(...)
|
V
ProxyBundle // files on disk
How plugins work
Each plugin has two hooks ProcessSpecModel and ProcessProxyModel
- ProcessSpecModel - Invoked after the input spec text has been parsed into the libopenapi data model.
- ProcessProxyModel - Invoked after the spec has been transformed into the Apigee data model.
How to add plugins
To get started, you make a copy the example plugin, and register it in the init.go file.
plugins.RegisterPlugin(&custom_plugin.Plugin{})
Then, you need to re-compile the generator.
go build -o spec2proxy cmd/spec2proxy/main.go
Available plugins
The following plugins are available to be used out of the box
- apigee_policies - Supports adding and using Apigee policies
- custom_plugin - Shows how to traverse and manipulate the data models
- example - Serves as template for creating new plugins
What about Go-Lang Plugin package ...
Plugins are not dynamic libraries like those built with Go-Lang's plugin package.
Instead, plugins are compiled into the generator itself. This is on purpose for the sake of portability,
and ease of development of the plugins.
Support
This is not an officially supported Google product