OpenAPI: Extend Functionality of Generator Plugin Using Custom Mustache Templates

OpenAPI Specification is a standard for documentation of HTTP REST services. You can try it using the Swagger editor. Based on specification files, code generators generate all model, server, and client classes required for development. This article is about the OpenAPI generator. It allows the generation of API client libraries (SDK generation), server stubs, documentation, and configuration automatically given an OpenAPI Spec. It’s available for several programming languages. I will use Java 17 and the OpenAPI generator of the 6.0.0 version to give an example of how to extend its functionality by amending mustache templates used by this code generator.

Quick Guide to Mustache

Before going further, let’s take a closer look at the mustache itself. It will help us amend current OpenAPI templates according to our needs. 

CategoriesUncategorized