Repository navigation
Feature Configuration
Five features decide what ends up on a generated class. All of them are off by default - out of the box you get a plain immutable POJO with no third-party annotations.
-
jackson-{ enabled, annotateFields, annotateGetters, includeNonNull }. Adds@JsonCreator,@JsonProperty,@JsonPropertyOrderand@JsonIgnoreProperties, plus@JsonInclude(NON_NULL)whenincludeNonNullis on. -
validation-{ enabled, annotateFields, annotateGetters }. Addsjakarta.validationconstraints and@Validcascades. -
openApi-{ enabled, annotateFields, annotateGetters }. Adds OpenAPI@Schemametadata. -
withers-{ enabled }. Adds awithXyz(value)single-field copy method per property. -
preferPrimitives-{ enabled }. Usesint/double/booleaninstead of boxed types where the property can never be null.
withers and preferPrimitives are covered on Generated Java Code.
| Setting | Default |
|---|---|
enabled |
false |
annotateFields |
false |
annotateGetters |
true |
So an enabled annotation feature annotates the getters.
Resolved highest priority first:
-
Per schema file - a top-level
"features"object in the schema. -
Per task - a
features { }block ongenerateModelJava. -
Project-wide -
modelmaker { features { } }in the build script.
Anything left unspecified at a level falls through to the next one, key by key - a schema that sets only
jackson.enabled keeps the project's annotateGetters.
modelmaker {
features {
jackson {
enabled = true
annotateFields = false
annotateGetters = true
includeNonNull = false
}
validation { enabled = true }
openApi { enabled = true }
withers { enabled = false }
preferPrimitives { enabled = false }
}
}tasks.named<JavaModelGenerate>("generateModelJava") {
features {
withers { enabled = true }
}
}{
"$modelmaker": "v1.0",
"title": "com.example.dto.Person",
"type": "object",
"properties": { "id": { "type": "string" } },
"features": {
"jackson": { "enabled": true },
"validation": { "enabled": true, "annotateFields": true, "annotateGetters": false },
"withers": { "enabled": true }
}
}Each entry is an object matching the DSL shape, not a bare boolean. "jackson": true is rejected, as is an
unknown feature name or an unknown key inside a feature.
annotateFields and annotateGetters decide where a feature's annotations sit. They are independent, so three
useful combinations exist:
annotateFields |
annotateGetters |
Result |
|---|---|---|
false |
true |
Getters only. The default. |
true |
false |
Fields only. |
true |
true |
Both. |
Setting both to false while enabled = true leaves the feature with nowhere to emit, which is almost certainly a
mistake.
Warning
Annotating both sites with validation means Hibernate Validator visits every constraint twice - each
violation is reported twice.
Container-element annotations (a List's element constraints and the @Valid cascade into a list of generated
types) render at the same site as the property's own constraints. The constructor and the builder always keep the
plain List<T>.
-
DTOs bound from JSON -
jackson. -
Constraints enforced at runtime -
validation. -
Contract metadata in generated API docs -
openApi, usually alongsidejacksonandvalidation. -
Ergonomic single-field copies -
withers. -
No boxing for always-present numbers -
preferPrimitives. -
A Kotlin
mutate { }DSL -kotlin { enabled = true }. Not a feature flag, see Kotlin Extensions.
Each annotation feature needs its library on the consumer's compile classpath; ModelMaker emits the annotations but brings no dependencies. See Getting Started.
ModelMaker - Apache License 2.0 - Issues - Wiki index
Start here
Schemas
Output
Features
Integration
Reference