Mustache templates with OpenAPI specs

Best features of the OpenAPI code generation

Beppe Catanese
Geek Culture

--

This article explores the Mustache templates, in the context of the OpenAPI specification, and the underrated features that can help developers in optimizing the code generation.

At Adyen we adopted OpenAPI specs some time ago and we have created our own Mustache templates to streamline the generation of the Adyen SDKs (in various languages) every time there is a new release of the payment APIs.

Photo by Tim Arterbury on Unsplash

Mustache is a logic-less template framework used to generate output that must conform to a structure and format we want to control. The applications are several: generating code, HTML, configuration files, etc…

They are logic-less (meaning the actual templating engine must take care of the conversion logic), simple (having just the features you need — no-frills) and open-source.

In a nutshell

Given a template

Hello {{name}} {{lastname}}

and a data structure

{
"name": "Beppe",
"lastname": "Catanese"
}

the template engine will know how to produce

Hello Beppe Catanese

OpenAPI language templates

--

--

Beppe Catanese
Geek Culture

Developer Relations @ Adyen. Here sharing new trends, dev tools and best practises about APIs.