This project defines a JSON Schema message format for the exchange of OntoUML models.
This project is defined under the umbrella of the OntoUML Server project and stands as a proof of concept at the moment.
If you are interested to know more, feel free to open an issue to provide feedback on the project or reach our team members for more specific cases:
How to use
JSON Schema is a popular web standard for definition and validation of JSON files. The standard employs JSON files describing valid schema formats as input to validation software to check the validity of any other JSON file its is feed with.
The code excerpt bellow, exemplifies how to use the
ontouml-schema project to validate objects representing OntoUML 2 models:
const schemas = ;const Ajv = ;let validator = ;let model =type: 'Package'id: 'm1'name: 'My Model'description: nullcontents: nullpropertyAssignments: null;let isValid = ;if isValidconsole;elseconsole;console;
This section describes the object types defined in the OntoUML Schema.
The type of an object is identified by the field "type".
All fields defined for an object type are MANDATORY, but only some are not nullable.
Additional fields are NOT allowed for any object type.
Package: An object representing an ontology or an ontology (sub)module. The Package object at the root of a JSON file instantiating the ontouml-schema is also referred to as "root package" and "model", where the later captures the notion of all container for all model elements in an ontology module.
Class: An object representing a type defined in the ontology.
An enumeration is represented as a class with the "enumeration" stereotype and its values using the field "literals".
Literal: An object representing a value defined for an enumeration.
Relation: An object representing a relation defined in the ontology.
The field "properties" is a nullable ordered array of objets of type "Property" whose minimum size should be 2. Relation objects with less than 2 items in the "properties" must raise error messages.
The order of the properties in this array represents their position on a equivalent predicate, e.g., in the ternary relation "buys-product-from(buyer,product,seller)", the order of items representing these entities must follow the order "buyer" (in properties), "product" (in properties), and "seller" (in properties).
Relation elements are also used to represent derivation relations, in which case they must contain the stereotype "derivation" and have only 2 properties, the first being an object of type "Relation" and the second an object of type "Class" element.
Generalization: An object representing a generalization defined in the ontology.
GeneralizationSet: An object representing a generalization set defined in the ontology.
Property: An object representing a property defined in the ontology. Properties contained by classes are deemed attributes and those contained by relations are deemed association ends.
contents: A non-empty nullable array of objects representing model elements. Possible object types in this array are: "Package", "Class", "Relation", "Generalization", "GeneralizationSet".
id: A non-empty and non-nullable string that uniquely identifies an object of a given type. Thus, two objects of the same type (e.g. two classes, two relations, two properties) may not have the same id, even if they are contained by different packages.
name: A non-empty nullable string containing the object's name. It is allowed for two objects of the ontology to have identical names, even if they are of the same type,.
description: A non-empty nullable string representing the description of the object in free textual format.
properties: A non-empty array of Property elements representing properties exhibited by instances of the container model element. Nullable.
propertyAssignments: A non-empty array of key-value pairs representing assignments to instantiated properties instantiated by the container object. Assignments may have any key name, but its values are restricted to null, booleans, numbers, strings, references or arrays of these. Assignments are analogous to UML's notion of tagged values. Nullable.
reference: An object representing a singular reference to a model element. Mandatory fields: "type", "id".
stereotypes: A non-empty array of non-empty strings representing stereotypes of its container object. Nullable.