Page
Library
Module
Module type
Parameter
Class
Class type
Source
Json_schemaAbstract representation of JSON schemas as of version http://json-schema.org/draft-04/schema#.
and element = {title : string option;An optional short description.
*)description : string option;An optional long description.
*)default : Json_repr.any option;A default constant to be substituted in case of a missing value.
*)enum : Json_repr.any list option;A valid value must equal one of these constants.
*)kind : element_kind;The type-specific part.
*)format : string option;predefined formats such as date-time, email, ipv4, ipv6, uri.
id : string option;An optional ID.
*)}A node in the schema, embeds all type-agnostic specs.
and element_kind = | Object of object_specsThe type of an object.
*)| Array of element list * array_specsAn fixed-length array with the types of its elements (a tuple).
*)| Monomorphic_array of element * array_specsA variable-length array with the type of its children.
*)| Combine of combinator * element listA mix of schemas using logical combinators.
*)| Def_ref of Json_query.pathA ref to an element from its path in the JSON representation.
*)| Id_ref of stringA ref to an element from its ID.
*)| Ext_ref of Uri.tA ref to an external element.
*)| String of string_specsA string (with optional characteristics).
*)| Integer of numeric_specsAn int (with optional characteristics).
*)| Number of numeric_specsA float (with optional characteristics).
*)| BooleanAny boolean.
*)| NullThe null value.
*)| AnyAny JSON value.
*)| DummyFor building cyclic definitions, a definition bound to a dummy will be considered absent for add_definition but present for update. The idea is to insert a dummy definition, build a cyclic structure using it for recursion, and finally update the definition with the structure.
The type-specific part of schema nodes.
and array_specs = {min_items : int;The minimum number of elements.
*)max_items : int option;The maximum number of elements.
*)unique_items : bool;Teels if all elements must be different.
*)additional_items : element option;The type of additional items, if allowed.
*)}Parameters of the Array and MonomorphicArray type specifiers.
and numeric_specs = {multiple_of : float option;An optional divisor of valid values
*)minimum : (float * [ `Inclusive | `Exclusive ]) option;The optional lower bound of the numeric range
*)maximum : (float * [ `Inclusive | `Exclusive ]) option;The optional upper bound of the numeric range
*)}Parameters of the Integer and Number type specifiers.
and object_specs = {properties : (string * element * bool * Json_repr.any option) list;The names and types of properties, with a flag to indicate if they are required (true) or optional.
pattern_properties : (string * element) list;Alternative definition of properties, matching field names using regexps instead of constant strings.
*)additional_properties : element option;The type of additional properties, if allowed.
*)min_properties : int;The minimum number of properties.
*)max_properties : int option;The maximum number of properties.
*)schema_dependencies : (string * element) list;Additional schemas the value must verify if a property is present (property, additional schema).
*)property_dependencies : (string * string list) list;Additional properties required whenever some property is present (property, additional properties).
*)}Parameters of the Object type specifier.
and string_specs = {pattern : string option;A regexp the string must conform to.
*)min_length : int;The minimum string length.
*)max_length : int option;The maximum string length.
*)}Parameters of the String type specifier.
val element : element_kind -> elementConstruct a naked element (all optional properties to None).
Construct a schema from its root, without any definition ; the element is checked not to contain any Def element.
Update a schema from its root, using the definitions from an existing schema ; the element is checked to contain only valid Def elements ; unused definitions are kept, see simplify.
val self : schemaDescribes the implemented schema specification as a schema.
val any : schemaA completely generic schema, without any definition.
val combine : combinator -> schema list -> schemaCombines several schemas.
Merges the definitions of two schemas if possible and returns the updated schemas, so that their elements can be mixed without introducing dangling references ; if two different definitions are bound to the same path, Duplicate_definition will be raised.
Adds a definition by its path. If the path is absolute (starting with a '/'), it is untouched. Otherwise, it is considered relative to "#/definitions" as recommended by the standard. May raise Duplicate_definition if this path is already used or any error raised by Json_repr.path_of_json_pointer with ~wildcards:false. Returns the modified schema and the Def_ref node that references this definition to be used in the schema.
Finds a definition by its path, may raise Not_found. See add_definition for the name format.
val definition_exists : string -> schema -> boolTells if a path leads to a definition. See add_definition for the name format.
val array_specs : array_specsDefault Parameters of the Array and MonomorphicArray type specifiers.
val object_specs : object_specsDefault parameters of the Object type specifier.
val string_specs : string_specsDefault parameters of the String type specifier.
val numeric_specs : numeric_specsDefault parameters of the Integer and Number type specifiers.
val to_json : schema -> Json_repr.ezjsonmFormats a JSON schema as its JSON representation.
This function works with JSON data represented in the Json_repr.ezjsonm format. See functor Make for using another representation.
val of_json : Json_repr.ezjsonm -> schemaParse a JSON structure as a JSON schema, if possible. May throw Cannot_parse.
This function works with JSON data represented in the Json_repr.ezjsonm format. See functor Make for using another representation.
val pp : Format.formatter -> schema -> unitFormats a JSON schema in human readable format.
exception Cannot_parse of Json_query.path * exnAn error happened during parsing. May box one of the following exceptions, among others..
exception Dangling_reference of Uri.tA reference to a non-existent location was detected.
exception Duplicate_definition of Json_query.pathA non-Dummy definition appeared twice on insertion or merge.
val print_error :
?print_unknown:(Format.formatter -> exn -> unit) ->
Format.formatter ->
exn ->
unitProduces a human readable version of an error.
module Make (Repr : Json_repr.Repr) : sig ... end