schema-viz
schema-viz copied to clipboard
Show cardinality for relations
Currently, all relations are showed in the same way - a line going from the containing element to the contained element, with a black diamond on the contained end. For example, the relations in these three examples look identical, even though there is a difference in the cardinality:
;;Example 1: Zero to many
(s/defschema State
{:name s/Str})
(s/defschema Country
{:name s/Str
:states [State]})
;;Example 2: Exactly one
(s/defschema State
{:name s/Str})
(s/defschema Citizen
{:first-name s/Str
:last-name s/Str
:home-state State})
;;Example 3: Optional
(s/defschema State
{:name s/Str})
(s/defschema Burger
{:name s/Str
(s/optional-key :origin-state) State})
The difference between these relations could be shown as:
- Example 1: A
*on the end of the line going to the contained element - Example 2: A
1on the end of the line going to the contained element - Example 2: A
0..1on the end of the line going to the contained element
Thanks for the report! Also, sequential schemas could have lower bound, e.g. [(s/one s/Str "s") s/Str] => 1..*
Indeed, I missed that one :) :+1: