package com.saasquatch.jsonschemainferrer.examples;

import java.net.URL;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.node.ObjectNode;
import com.saasquatch.jsonschemainferrer.AdditionalPropertiesPolicies;
import com.saasquatch.jsonschemainferrer.ArrayLengthFeature;
import com.saasquatch.jsonschemainferrer.JsonSchemaInferrer;
import com.saasquatch.jsonschemainferrer.ObjectSizeFeature;
import com.saasquatch.jsonschemainferrer.RequiredPolicies;
import com.saasquatch.jsonschemainferrer.SpecVersion;
import com.saasquatch.jsonschemainferrer.StringLengthFeature;
import com.saasquatch.jsonschemainferrer.TitleGenerators;

public class Example2 {

  private static final ObjectMapper mapper = new ObjectMapper();
  private static final JsonSchemaInferrer inferrer =
      JsonSchemaInferrer.newBuilder()
          .setSpecVersion(SpecVersion.DRAFT_06)
          .setAdditionalPropertiesPolicy(AdditionalPropertiesPolicies.existingTypes())
          .setRequiredPolicy(RequiredPolicies.nonNullCommonFields())
          .setTitleGenerator(TitleGenerators.useFieldNames())
          .setExamplesLimit(3)
          .enable(ArrayLengthFeature.MIN_ITEMS, ArrayLengthFeature.MAX_ITEMS)
          .enable(ObjectSizeFeature.MIN_PROPERTIES, ObjectSizeFeature.MAX_PROPERTIES)
          .enable(StringLengthFeature.MIN_LENGTH, StringLengthFeature.MAX_LENGTH)
          .build();

  public static void main(String[] args) throws Exception {
    final JsonNode sample = mapper.readTree(new URL(
        "https://cdn.jsdelivr.net/gh/quicktype/quicktype@3ea476df5c1c4a6821d3cca7c1de359724a90a92/test/inputs/json/samples/reddit.json"));
    final ObjectNode schema = inferrer.inferForSample(sample);
    System.out.println(mapper.writerWithDefaultPrettyPrinter().writeValueAsString(schema));
  }

}

@@ -64,17 +64,71 @@
 a.net.UR
-L
+I;%0Aimport java.net.URL;%0Aimport javax.annotation.Nonnull
 ;%0Aimport
@@ -400,32 +400,94 @@
 yLengthFeature;%0A
+import com.saasquatch.jsonschemainferrer.FormatInferrerInput;%0A
 import com.saasq
@@ -1054,16 +1054,47 @@
 AFT_06)%0A
+          .setExamplesLimit(3)%0A
         
@@ -1313,39 +1313,74 @@
         .set
-ExamplesLimit(3
+FormatInferrer(Example2::absoluteUriFormatInferrer
 )%0A          
@@ -1615,16 +1615,16 @@
 LENGTH)%0A
-
         
@@ -1636,16 +1636,422 @@
 ild();%0A%0A
+  private static String absoluteUriFormatInferrer(@Nonnull FormatInferrerInput input) %7B%0A    final String textValue = input.getSample().textValue();%0A    if (textValue == null) %7B%0A      return null;%0A    %7D%0A    try %7B%0A      final URI uri = new URI(input.getSample().textValue());%0A      if (uri.isAbsolute()) %7B%0A        return %22uri%22;%0A      %7D%0A    %7D catch (Exception e) %7B%0A      // ignore%0A    %7D%0A    return null;%0A  %7D%0A%0A
   public

Update Example2.java