Generators
A generator is where a plugin produces code. The plugin handles options, lifecycle, and wiring. The generator does the narrower job of reading a node from the AST and returning the files that node should become. A plugin with no generators emits nothing.
Why a plugin splits into generators
You could write one big function, but most plugins produce several kinds of output from the same spec. @kubb/plugin-react-query writes a hook per operation, a query key per operation, and a barrel once everything is done. Splitting that into named generators keeps each one small, and it lets the engine call the right generator for each node instead of asking a single function to branch on everything it might see.
A plugin registers its generators during plugin setup. After that the engine owns the schedule. It walks the AST once and calls each generator's methods as the matching nodes come up.
What each method handles
A generator implements up to three methods, and each maps to a slice of the spec:
schemaruns once per data schema. It is where types, validators, and mock factories come from.operationruns once per API operation. It builds request hooks, clients, and route handlers.operationsruns a single time with the whole set at once. Reach for it when an index or a router has to see every operation before it writes anything.
Each method receives the generator context and returns the files that node becomes. It can hand back file nodes directly, return a renderer element, or write through the context and return nothing. The generator reference lists every field on that context.