easily generate docs and playground for your RESTful API
Here is an example of writing documentation for a simple class.
package org.jsondoc.sample.pojo;
import org.jsondoc.core.annotation.ApiObject;
import org.jsondoc.core.annotation.ApiObjectField;
@ApiObject
public class City extends Location {
@ApiObjectField
private Long id;
@ApiObjectField(description = "The name of the city")
private String name;
}
Notes:
Superclasses are not always needed from an API user perspective. They are still needed to build an effective documentation though. Here is how to do it:
package org.jsondoc.sample.pojo;
import org.jsondoc.core.annotation.ApiObject;
import org.jsondoc.core.annotation.ApiObjectField;
@ApiObject(show = false)
public class Location {
@ApiObjectField(description = "The population of the location")
private Integer population;
@ApiObjectField(description = "The square km of the location")
private Integer squarekm;
}
Notes:
show = false
, indicating that this object will take part to the documentation build process, but it will not be shown as a stadalone object in the resulting documentationIf JSONDoc finds Hibernate validator libraries on the classpath, it will trigger the scan for its annotations put on objects' fields. It will then extract data from them and use them to display validation rules in the JSONDoc UI. Currently JSONDoc supports these Hibernate validator annotations: