Writing a generator
This is the documentation for writing an openapi-yagen generator - a plugin (JS + Inja
templates) that turns a resolved OpenAPI document into source code. For building/testing the
openapi-yagen CLI itself, see the root README.md and
AGENTS.md
instead.
New to this? Start with the tutorial - it builds a small real generator from scratch, step by step, with every command and its actual output.
Reference material, once you know the shape of things:
- Generator format - the folder layout,
generator.yml, how-gloads a built-in generator/directory/zip/URL,--override-dir, and post-processing generated files. - JavaScript API - the globals (
schema,vars) and built-in functions (kindOf,nameOf,constraintsOf,collectOperations,renderTemplate,copyFile, ...) available tomain.js. - Templating - the Inja template syntax, calling built-in/custom functions from a template, and whitespace control.
Real, complete generators to read alongside this documentation live in
../generators/.