Repository navigation
Troubleshooting
Schema errors are raised while loading, before anything is written. Every one of them is a SchemaException, and
every message is prefixed with the file name:
com.example.dto.Person.json: property "age": unsupported format "short" for type "integer" (allowed: int, long)
A load reports every problem it finds rather than stopping at the first, so a batch of broken schemas comes back as one listing:
3 schema errors:
- com.example.dto.Address.json: missing "title"
- com.example.dto.Order.json: property "total": default must be a number
- com.example.dto.Person.json: property "age": unsupported format "short" for type "integer" (allowed: int, long)
-
not valid JSON (...)- the file is not parseable JSON. -
missing "$modelmaker"- the version key is absent. Add"$modelmaker": "v1.0". -
unsupported "$modelmaker": "X" (only "v1.0" is supported)- unknown schema version. -
missing "title"- notitlekey. -
"title" must be a fully-qualified class name, e.g. "com.example.dto.Foo"-titlehas no package part. -
file must be named "<title>.json" to match its title- file name andtitledisagree. Rename the file. -
top-level "type" must be "object"- the top-leveltypeis missing or is not"object". -
type "X": missing "properties" object- nopropertieson the type, or on an inline nested object. -
<file>: unsupported file extension "x"- a file the loader does not handle was passed in.
-
property "x": needs "type" or "$ref"- the property object has neither key. -
property "x": unsupported type "t" (allowed: string, bytes, integer, number, boolean, object, array, $ref)- unknowntypevalue. -
property "x": unsupported format "f" for type "integer" (allowed: int, long)- badformaton aninteger. -
property "x": unsupported format "f" for type "number" (allowed: double, float)- badformaton anumber. -
property "x": array needs "items"- anarraywithout an element schema. -
property "x": nested arrays are not supported-itemsis itself anarray. -
nested object "title" must be a plain class name, not "X"- an inline object'stitlecontains a..
-
type "T": property "k" must be camelCase, snake_case, or UpperCamelCase, optionally prefixed with underscores- the key form is not accepted, see Property Naming. -
type "T": properties "a" and "b" both map to the field name "f"- two keys normalize to the same Java field.
-
property "x": default must be a string- and thean integer/a number/a boolean/an arrayvariants: the default's JSON type does not match the property type. -
property "x": default is not supported for "bytes"-byteshas no default support. -
property "x": array default is only supported for scalar items- a default on an array of objects or$refs. -
property "x": default is not supported for object / $ref properties- a default on an object-typed property.
-
Customer.shippingAddress: $ref "X" does not match any schema title or nested type- the target schema is missing from the source tree, thetitleis spelled differently, or the nested-type name is wrong. A JDK target must start withjava.orjavax..
-
"features" must be an object-featuresis a scalar or an array. -
unknown "features" entry "x"- onlyjackson,validation,openApi,withersandpreferPrimitivesare accepted. -
"features.jackson" must be an object, e.g. { "enabled": true }- a bare boolean was used. -
unknown "features.jackson" entry "x"- onlyenabled,annotateFieldsandannotateGetters, orenabledalone forwithers/preferPrimitives. -
"features.jackson.enabled" must be a boolean- a non-boolean value.
The feature is on but its library is missing from the compile classpath. Add the dependency, see
Getting Started. For NullMarked specifically: the plugin
only contributes org.jspecify:jspecify when the java plugin is applied - check that it is.
- Schemas must be under
src/main/modelwith a.jsonextension. The task logsNo model schemas found in .... -
generateModelJavaruns as part of compilation; running only./gradlew teston an up-to-date build may show it asUP-TO-DATErather than re-running.
Both modelmaker { kotlin { enabled = true } } and the org.jetbrains.kotlin.jvm plugin are required. With
either missing, generateModelKotlin deletes its output directory instead of writing to it - which is also why
previously generated .kt files disappear after turning Kotlin off. See Kotlin Extensions.
Expected: the output directory is wiped and rebuilt on every run. Change the schema or the feature flags instead.
Builder.build() enforces that every required property was set. Either set it, or drop it from the schema's
required array. Note that this is a construction check, not bean validation - see
Validation.
annotateFields and annotateGetters are both on for validation, so each constraint is emitted at both sites. Pick
one, see Feature Configuration.
Jackson binds through the constructor and does not enforce requiredness - or any other constraint. Turn on
validation and make sure something actually runs a Validator: a framework at its own boundary
(Spring Boot's @Valid @RequestBody, for instance), or your own code. See
Validation.
With src.enabled = true the output lives in the project tree. Exclude it:
spotless {
java {
targetExclude("build/**", "src/main/model/java/**")
}
}Check the FAQ, then open an issue at damianmalczewski/modelmaker/issues with the schema and the message.
ModelMaker - Apache License 2.0 - Issues - Wiki index
Start here
Schemas
Output
Features
Integration
Reference