erunion / mill

☴ An annotation-based DSL for documenting a REST API.
MIT License
39 stars 2 forks source link

Hook-based compiler #211

Closed erunion closed 5 years ago

erunion commented 5 years ago

This slightly tweaks the compiler engine to have a hook-like system for transposing compiled data into customized formats (like an OpenAPI schema).

The way the various compiler extensions (OpenAPI, API Blueprint, changelog, etc.) run right now is that first the core compiler compiles the API into a large map of versioned objects, and then the extensions loop through that to further compile their own data.

This updates it so that while the core compiler is building that map of versioned objects, an extendable method is now called in real time that extensions can hook into to set up their own data at the same time for that object. So now when the compiler is compiling a resource action, the OpenAPI hook can now build up a schema for that action at the same time.

Flowcharts

Old compiler architecutre

mill-old-compiler

Rewritten architecture

mill-new