Class JsonSchema


  • public final class JsonSchema
    extends java.lang.Object
    Simplified JSON schema generator only targeting Detection class and its dependents. Honours Jackson JsonIgnore annotations on fields.

    Limitations include:

    • arrays not supported (not required for Detection class)
    • fields are considered required if not typed using Optional
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static java.lang.String generateSchema​(java.lang.Class<?> cls, java.util.Map<java.lang.Class<?>,​java.util.List<java.lang.Class<?>>> subclasses, java.lang.String schemaId)
      Returns the JSON Schema for the heirarchy of classes pointed to by classes.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Method Detail

      • generateSchema

        public static java.lang.String generateSchema​(java.lang.Class<?> cls,
                                                      java.util.Map<java.lang.Class<?>,​java.util.List<java.lang.Class<?>>> subclasses,
                                                      java.lang.String schemaId)
        Returns the JSON Schema for the heirarchy of classes pointed to by classes. Targets Detection class only (but might be extended in the future for more). Any subclasses within the heirarchy should be mentioned in subclasses so that the appropriate JSON Schema structures are produced. Subclasses should include a discriminator field that allows users to differentiate the JSON representations.
        Parameters:
        cls - root class to be converted into a JSON Schema
        subclasses - maps classes to a list of their subclasses
        schemaId - value to be used in the $id field.
        Returns:
        JSON Schema