Apigen is a modular tool for generating type safe APIs from OpenAPI specs.
This package contains a CLI tool (a runner) that relies on separate plugins to generate code for different languages.
The OpenAPI spec is the de facto standard for describing RESTful APIs. I often find myself writing code in multiple languages that interacts with the same API. This tool aims to reduce the amount of boilerplate code that needs to be written by both clients and servers.
run cargo build --release
to build the runner
Start the executablew with the --help
flag to see the available options.
apigen --help
The runner can either load plugins via a filesystem path, or by searching the System PATH for executables with the name apigen-<plugin-name>
. Run apigen --help
for more information.
Plugins are standalone executables that read the OpenAPI spec (as JSON) from stdin and write the generated code to stdout. This approach allows for plugins to be written in any language.
The OpenAPI spec is passed to the plugin as a JSON object. The plugin should read this object from stdin. The input is expected to be a valid OpenAPI spec.
The generated code is then written to an output file by this runner.
In case of an error, the plugin should write the error message to stderr and exit with a non-zero status code.