Skip to content

Fast handlebars templates based code generator, ingesting swagger/openapi and other json/yaml documents with $refs, or graphql schema, outputs whatever you template

License

Notifications You must be signed in to change notification settings

thormighti/codegenr

Repository files navigation

CodeGenR

codegenr graphical explanation

Installation

Install Rust : https://www.rust-lang.org/tools/install. And then install codegenr

cargo install codegenr

or install the development version

cargo install --git https://github.com/eventuallyconsultant/codegenr --branch dev

Documentation

codegenr documentation on docs.rs

Helpers

The defaults handlebars helpers (eq, ne, gt, gte, lt, lte, and, or, not ...) are provided by the rust handlebars implementation : https://docs.rs/handlebars/latest/handlebars/#built-in-helpers

Other handlebars helpers are provided by the handlebars_misc_helpers crate : https://github.com/davidB/handlebars_misc_helpers

Some more helpers are added by this project and are documented here.

Finally you can add your own custom helpers at runtime using the rhai embedded scripting language

Contribute

You can also open the repository in GitPod with this button Open in Gitpod

In the command line you can :

  • cargo test to launch all the unit tests
  • cargo doc --open to compile and open the local documentation

Some command lines

  • cargo doc --open compile and open the documentation
  • cargo install --path codegenr installs codegenr command line from sources
  • cargo install --git https://github.com/eventuallyconsultant/codegenr --branch dev installs codegenr command line from the latest github dev branch

Legacy

This tool is based on the design of a precedent one written in C# : CodegenUP.

Roadmap :

  • Load a yaml or json to serde::json

  • Resolve $ref tags

  • Pass all the resulting document to an handlebar template

  • Implement some default helper (and make some doc tests about them)

  • A plugin system

  • Migrate C# custom helpers to this new plugin system

  • A this point, we could use codegenr in place of CodegenUP, just by calling some commands

  • Rename codegenr-cli to codegenr & codegenr to codegenr-lib

  • Publish on crates.io

  • Be able to have a codegenr.toml on a workspace root to describe all the templates to execute around the workspace

  • Better Errors (typed ones)

  • Resolved Json Cache optimisation

  • all tests passing on windows too

  • Verbose/Tracing? mode

  • Better examples

  • Smol strings optimisation ?

  • Watch mode for the file changes

  • Make a VSCode extension about all of this to make it live / super user friendly for everyone

  • Allow multiple swagger2 documents merging

  • Allow multiple swagger3 documents merging

  • Transform the json to an OpenApi Generator model, and be able to use all the OpenApi Generator templates ?

About

Fast handlebars templates based code generator, ingesting swagger/openapi and other json/yaml documents with $refs, or graphql schema, outputs whatever you template

Resources

License

Code of conduct

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Rust 97.6%
  • Handlebars 2.3%
  • Other 0.1%