Chaining Injectors
Injectors can be useful on their own, but we can make them even more powerful and cleanly separated if we can chain them. This can enable each injector to have a single responsibility, and we can build a more complex result by chaining injectors and building on top of each other.
As of now, there is no automatic way to specify dependencies between injectors. Automatic dependency resolution is on the roadmap, but for now, all you need to do is specify them in order, from the least dependent to the most dependent injector.
For example, you can have something like this (which will be used in the next example):
{
"schemaDir": "./models",
"outputDir": "./",
"plugins": [
{
"name": "routes",
"outputType": "none"
},
{
"name": "faked-routes",
"outputType": "file"
},
{
"name": "open-api",
"outputType": "file"
}
]
}
In this case, both faked-routes and open-api injectors depend on the routes injector, so that is the order they are specified in. When Aida is run, the open-api and faked-routes will have access to the result generated by the routes injector.
All we have remaining is to combine everything we have learned so far into a real-world use case for Aida, so let's do that now.