Skip to main content

HTML-Schema Support

The HtmlSchemaSerializer class is the HTML-equivalent to the JsonSchemaSerializer class. It's used to generate HTML versions of JSON-Schema documents that describe the output generated by the JsonSerializer class.

Sample Beans
public class Person {

// Bean properties
public String name;
public Calendar birthDate;
public List addresses;

// Getters/setters omitted
}

public class Address {

// Bean properties
public String street, city;
public StateEnum state;
public int zip;
public boolean isCurrent;

// Getters/setters omitted
}

The code for creating our POJO model and generating HTML-Schema is shown below:

// Get the one of the default schema serializers.
HtmlSchemaSerializer serializer = HtmlSchemaSerializer.DEFAULT_SIMPLE_READABLE;

// Get the HTML Schema for the POJO.
String htmlSchema = serializer.serialize(new Person());

// This also works.
htmlSchema = serializer.serialize(Person.class);

The result is the HTML table shown below:

typeobject
properties
name
typestring
birthDate
typestring
addresses
typearray
items
typeobject
properties
street
typestring
city
typestring
state
typestring
enum
  • AL
  • PA
  • NC
zip
typeinteger
formatint32
isCurrent
typeboolean