Skip to content
Damian Malczewski edited this page Sep 13, 2026 · 2 revisions

ModelMaker

ModelMaker turns small schema files into immutable Java DTOs - a final class with no setters, a builder, equals / hashCode / toString - plus optional Kotlin mutate { } extensions.

It exists because:

  • Hand-written DTOs drift from the contract, and keeping them immutable and correct is tedious.
  • Full code generators produce heavy, mutable or framework-coupled types. ModelMaker emits the plain POJOs you would have written by hand.
  • One schema feeds several concerns - JSON binding (Jackson), runtime validation (jakarta.validation), API docs (OpenAPI @Schema) - toggled per project or per schema instead of re-specified by hand.

The Gradle plugin is the intended entry point: drop schemas under src/main/model, build, and the generated types are on the main source set.

Wiki map

Start here

  • Getting Started - apply the plugin, write a first schema, build, see the output.
  • Examples - the runnable sample builds shipped in the repository.

Schemas

Output

Features

  • Feature Configuration - the three-level precedence model and annotation placement.
  • Jackson - annotations emitted, constructor visibility, Jackson 2 / 3.
  • Validation - schema keyword to jakarta.validation annotation mapping.
  • OpenAPI - what ends up in @Schema, and what deliberately does not.

Integration

Reference

  • Troubleshooting - error messages and what causes them.
  • FAQ - short answers to recurring questions.
  • Development - building the project itself, module layout, conventions.

At a glance

plugins {
    id("io.github.malczuuu.modelmaker") version "..."
}

modelmaker {
    features {
        jackson { enabled = true }
        validation { enabled = true }
    }
}
src/main/model/
└── com.example.dto.Person.json                  ← you write this

build/generated/sources/modelmaker/java/main/
└── com/example/dto/Person.java                  ← ModelMaker writes this

Scope and limits

Generated models support simple types only - the ones most likely to serialize and deserialize cleanly between a Java object and JSON. An enum, for example, becomes a plain String field with a generated @Pattern over the allowed values. See Property Types for the full list, and FAQ for the reasoning.

Clone this wiki locally