UML JSON Schema Diagram

The UML JSON Schema diagram allows you to design JSON schemas visually. JSON schemas specify the restrictions on the data in JSON format.

This diagram type offers the following box elements:

And the following relationships:

  • Items
  • Contains
  • All Of
  • Any Of
  • One Of
  • Not
  • If
  • Then
  • Else

Using the JSON diagramming tool we can design the schema as follows:

UML JSON Schema Diagram
UML JSON Schema Diagram

The JSON schema will be generated for the Root Schema element. The other definitions will be placed in the $defs schema node. The owned schema elements can be specified in two ways - as typed attributes or classes (ArraySchema, BooleanSchema, NullSchema, NumberSchema, ObjectSchema, StringSchema) associated with the Aggregation (Items) relationship - the name of such element is specified in the association role field.

Define JSON Schema Diagram

Constraints

The constraints of typed schemas can be defined using rule fields. The individual schema tools insert the class with all available rules. You can enter the value of the rule you want to specify. The rule has the following format: { {ruleName} ruleValue} (e.g. { {minItems} 5} )

Array Schemas

You can specify the schema for the items that can be part of the array. The array item schema is connected using the Items (UML Aggregation) connector. If you want to define that at least one array item should conform to the defined schema, you should connect this schema to the array schema using the Contains connector.

Schema Compositions and Conditional Schemas

You can combine the schemas using the stereotyped associations (allOf, anyOf, not, if, then, else). If you want to to to express that a schema should meet at least one of the other schemas, you should use the anyOf association. The association can connect only two elements. That's why if you want to model an anyOf composition, you need to use an N-ary association element. The relationship from the parent schema leads to the N-ary association (the diamond shape) and the other associations connect the individual subschemas with the N-ary association element.

JSON Schema to Diagram

If you want to generate a diagram for a JSON Schema, you should use the JSON Schema Import feature in Software Ideas Modeler. It is accessible from:

  • ribbon: Process tab / Reverse Engineering group / JSON Schema button
  • menu: Tools / Reverse Engineering / JSON Schema

In the JSON Schema Import dialog, choose the JSON files you want to import using the Add Files button. Then click on the OK button, and the diagram will be generated by the schema definition.

New Comment

Comment