openapi-contrib / openapi3-generator

Use your API OpenAPI 3 definition to generate code, documentation, and literally anything you need.
Apache License 2.0
89 stars 27 forks source link

Support for any template engine #25

Closed pitpit closed 3 months ago

pitpit commented 5 years ago

This is a PR I wrote because I need to reuse a template that I already made on nunjucks

It decouples templating and generator in a clean way using jstransformer.

I think it could be useful for other people. I'll publish my template based on nunjucks in another PR

fmvilas commented 5 years ago

I think this is an interesting concept to explore. I'm currently working more on the https://github.com/asyncapi/generator package (similar to this one but for AsyncAPI) and this is interesting. How difficult do you think it would be to migrate and test the whole library to support multiple template engines?

pitpit commented 5 years ago

Hi @fmvilas I test it with jstransformer-nunjucks using this PR as a base and it actually works well now. Do you want me to push another PR as an example in order you to try it ?

How difficult do you think it would be to migrate and test the whole library to support multiple template engines?

What do you mean by "test the whole library" ? Unit testing ?

fmvilas commented 5 years ago

A PR with an example would be appreciated, thanks!

And by testing I mean unit or integration tests. Just curious, not saying it should be done now. Thanks!

pitpit commented 5 years ago

@fmvilas here's a draft PR with nunjucks support https://github.com/fmvilas/openapi3-generator/pull/26

About the tests: we could have some tests using the same openapi spec and two different templating engine, two templates collections supposed to generate the same markdown and check that the output actually match. Or easier, dumping the openapi specs in json through the two template engines and check that the output in json match the input. That will only check that the engines are well linked and bootstrapped but that's a good beginning