JsonSchema { public static JSONSchemaProps from(TypeDef definition) { JSONSchemaPropsBuilder builder = new JSONSchemaPropsBuilder(); builder.withType("object"); List<String> required = new ArrayList<>(); for (Property property : TypeUtils.allProperties(definition)) { JSONSchemaProps schema = from(property.getTypeRef()); if (property.getAnnotations() .stream() .anyMatch(a -> a.getClassRef().getFullyQualifiedName().equals("javax.validation.constraints.NotNull"))) { required.add(property.getName()); } if (schema != null) { builder.addToProperties(property.getName(), from(property.getTypeRef())); } } builder.withRequired(required); return builder.build(); }  static JSONSchemaProps from(TypeDef definition); static JSONSchemaProps from(TypeRef typeRef);  }
@Test void shouldCreateJsonSchemaFromClass() { TypeDef person = ClassTo.TYPEDEF.apply(Person.class); JSONSchemaProps schema = JsonSchema.from(person); System.out.println(Serialization.asJson(schema)); assertNotNull(schema); }