The {@link oaj.html.HtmlSchemaSerializer} class is the HTML-equivalent to the
{@link oaj.json.JsonSchemaSerializer} class.
It's used to generate HTML versions of JSON-Schema documents that describe the output generated by the
{@link oaj.json.JsonSerializer} class.
| public class Person {
|
| // Bean properties
| public String name;
| public Calendar birthDate;
| public List<Address> 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:
| type |
object |
| properties |
| name |
|
| birthDate |
|
| addresses |
| type |
array |
| items |
| type |
object |
| properties |
| street |
|
| city |
|
| state |
|
| zip |
| type |
integer |
| format |
int32 |
|
| isCurrent |
|
|
|
|
|