Repository navigation
FAQ
Records are a fine value carrier, but they give no builder, no defaults, no defensive copying of byte[] or List,
and no control over constructor visibility - all of which ModelMaker emits. The generated class is what you would
write by hand for a DTO that must stay immutable and bind from JSON.
Generated models support the simple types most likely to round-trip cleanly between a Java object and JSON. An
enum becomes a String field plus a generated @Pattern over the allowed values, with a
must be one of ... message. If you want a real Java enum, write it by hand and reference it with a $ref - see
Property Types.
Only java.* and javax.* $ref targets are passed through as-is. Anything else must resolve to a schema title
or a nested type name.
That is the default (src.enabled = true), and it is a deliberate choice: a schema change shows up as a reviewable
diff in the generated code. If you would rather not, set src { enabled = false } and the output moves under
build/generated. See Gradle Plugin.
No. The output directory is deleted and rewritten on every run of the task.
No. The core generator has no build-tool dependency, so it can be driven from a Maven mojo, an Ant task or a plain
main - see Library Usage - but only the Gradle plugin ships.
No. The format is a small subset of JSON Schema aimed at flat, predictable DTOs. See Property Types.
Yes. $ref is resolved by name after all schemas are loaded, so cycles between top-level types are fine. Inline
nested objects are expanded in place and therefore cannot recurse.
Because it can never be null: the default is applied in the constructor. That also makes it eligible for
preferPrimitives. See Schema Format.
So Jackson can bind straight through it, keeping the type immutable and skipping the builder. Without the jackson
feature the constructor is private. See Jackson.
Neither. build() only enforces that required properties were set, throwing NullPointerException; Jackson binds
whatever the JSON contains, missing required properties included. A Validator has to run over the object, and
whether that happens automatically is a property of the framework you are in - Spring Boot validates an annotated
@RequestBody, a Kafka consumer or a batch job validates nothing. See
Validation.
range checks need a Validator - see Validation.
withXyz(...) for a single field; mutate() when changing several at once, since it copies once rather than once
per field. Kotlin callers get mutate { } as a DSL, see Kotlin Extensions.
No. kotlin { enabled = true } adds mutate { } extension functions next to the Java classes; the DTOs themselves
are always Java.
The output uses instanceof patterns and sealed interfaces, so Java 17 or newer.
Yes. A missing or empty schema directory is not an error - the tasks log No model schemas found in ... and generate
nothing, which makes the plugin safe to apply from a convention plugin across a multi-module build.
Because javax.annotation.processing.Generated lives in the java.compiler module, so every consumer with a
module-info.java would have to requires java.compiler for generated code to compile. The do-not-edit banner at the
top of each file carries the same information at no cost.
Mark the property "sensitive": true and its value is masked as *** in the generated toString(), see
Schema Format.
Yes - the schema directory is scanned recursively. The package comes from title, not from the directory layout.
The directory itself is configurable, see Gradle Plugin.
Some annotations - @Schema with a long description, container-element constraints on a List - are emitted on one
line by design. Exclude the generated directory from your formatter rather than reflowing it.
ModelMaker - Apache License 2.0 - Issues - Wiki index
Start here
Schemas
Output
Features
Integration
Reference