Validating container elements by annotating type arguments of parameterized types

Author: WRupCreated Dec 28, 2021Updated Feb 2, 2026

Could support generating annotations for container elements (especially Java classes like String, Integer and so on)? E.g. I have following json schema:

json
{
  "type": "object",
  "properties": {
      "testProperty": {
        "type": "array",
        "items": {
              "type": ["string","null"],
              "maxLength": 8
            }
      }
}

What I expect it that generated POJO will have following annotations on testProperty:

java
public class TestClass {

    @JsonProperty("testProperty")
    @Valid
    private List< @Size(max = 8) String> testProperty

However generated class is missing @Size annotation and schema "maxLength": 8 property is completely omitted:

java
public class TestClass {

    @JsonProperty("testProperty")
    @Valid
    private List<String> testProperty

Source: joelittlejohn/jsonschema2pojo