Skip to content

Commit 1ce1739

Browse files
committed
Include arrays in generated entity relationship diagram
1 parent bebeb3a commit 1ce1739

File tree

2 files changed

+110
-82
lines changed

2 files changed

+110
-82
lines changed

codegen/templates/relations.md.erb

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,15 +21,15 @@ erDiagram
2121
referent[0] = referent[0].upcase
2222
required = (schema['required'] || []).index(property_name)
2323
-%>
24-
<%= class_name(key) %> }|..<%= required ? '||' : 'o|' %> <%= referent %>: <%= property_name %>
24+
<%= class_name(key) %> }|..<%= required ? '||' : 'o|' %> <%= referent %>: <%= property_name %>
2525
<%- end -%>
2626
<%-
2727
if property_name.end_with?("Ids")
2828
referent = property_name.delete_suffix("Ids")
2929
referent[0] = referent[0].upcase
3030
required = (schema['required'] || []).index(property_name)
3131
-%>
32-
<%= class_name(key) %> }|..<%= required ? '|{' : 'o{' %> <%= referent %>: <%= property_name %>
32+
<%= class_name(key) %> }|..<%= required ? '|{' : 'o{' %> <%= referent %>: <%= property_name %>
3333
<%- end -%>
3434
<%- end -%>
3535
<%- end -%>
@@ -47,10 +47,17 @@ erDiagram
4747
<% @schemas.each do |key, schema| -%>
4848
<%- schema['properties'].each do |property_name, property| -%>
4949
<%-
50-
next unless property['$ref']
51-
next unless class_name(key) != "Envelope"
50+
next unless class_name(key) != "Envelope"
51+
required = (schema['required'] || []).index(property_name)
52+
if property['$ref']
5253
-%>
53-
<%= class_name(key) %> ||..|| <%= class_name(property['$ref']) %>: has a
54+
<%= class_name(key) %> ||..<%= required ? '||' : 'o|' %> <%= class_name(property['$ref']) %>: "has a"
55+
<%- end -%>
56+
<%-
57+
if property['items'] && property['items']['$ref']
58+
-%>
59+
<%= class_name(key) %> ||..<%= required ? '|{' : 'o{' %> <%= class_name(property['items']['$ref']) %>: "has"
60+
<%- end -%>
5461
<%- end -%>
5562
<%- end -%>
5663
```

jsonschema/relations.md

Lines changed: 98 additions & 77 deletions
Original file line numberDiff line numberDiff line change
@@ -14,29 +14,29 @@ config:
1414
layout: elk
1515
---
1616
erDiagram
17-
Attachment }|..o| TestCaseStarted: testCaseStartedId
18-
Attachment }|..o| TestStep: testStepId
19-
Attachment }|..o| TestRunStarted: testRunStartedId
20-
Attachment }|..o| TestRunHookStarted: testRunHookStartedId
21-
Pickle }|..|{ AstNode: astNodeIds
22-
PickleStep }|..|{ AstNode: astNodeIds
23-
PickleTag }|..|| AstNode: astNodeId
24-
TestCase }|..|| Pickle: pickleId
25-
TestCase }|..o| TestRunStarted: testRunStartedId
26-
TestStep }|..o| Hook: hookId
27-
TestStep }|..o| PickleStep: pickleStepId
28-
TestStep }|..o{ StepDefinition: stepDefinitionIds
29-
TestCaseFinished }|..|| TestCaseStarted: testCaseStartedId
30-
TestCaseStarted }|..|| TestCase: testCaseId
31-
TestCaseStarted }|..o| Worker: workerId
32-
TestRunFinished }|..o| TestRunStarted: testRunStartedId
33-
TestRunHookFinished }|..|| TestRunHookStarted: testRunHookStartedId
34-
TestRunHookStarted }|..|| TestRunStarted: testRunStartedId
35-
TestRunHookStarted }|..|| Hook: hookId
36-
TestStepFinished }|..|| TestCaseStarted: testCaseStartedId
37-
TestStepFinished }|..|| TestStep: testStepId
38-
TestStepStarted }|..|| TestCaseStarted: testCaseStartedId
39-
TestStepStarted }|..|| TestStep: testStepId
17+
Attachment }|..o| TestCaseStarted: testCaseStartedId
18+
Attachment }|..o| TestStep: testStepId
19+
Attachment }|..o| TestRunStarted: testRunStartedId
20+
Attachment }|..o| TestRunHookStarted: testRunHookStartedId
21+
Pickle }|..|{ AstNode: astNodeIds
22+
PickleStep }|..|{ AstNode: astNodeIds
23+
PickleTag }|..|| AstNode: astNodeId
24+
TestCase }|..|| Pickle: pickleId
25+
TestCase }|..o| TestRunStarted: testRunStartedId
26+
TestStep }|..o| Hook: hookId
27+
TestStep }|..o| PickleStep: pickleStepId
28+
TestStep }|..o{ StepDefinition: stepDefinitionIds
29+
TestCaseFinished }|..|| TestCaseStarted: testCaseStartedId
30+
TestCaseStarted }|..|| TestCase: testCaseId
31+
TestCaseStarted }|..o| Worker: workerId
32+
TestRunFinished }|..o| TestRunStarted: testRunStartedId
33+
TestRunHookFinished }|..|| TestRunHookStarted: testRunHookStartedId
34+
TestRunHookStarted }|..|| TestRunStarted: testRunStartedId
35+
TestRunHookStarted }|..|| Hook: hookId
36+
TestStepFinished }|..|| TestCaseStarted: testCaseStartedId
37+
TestStepFinished }|..|| TestStep: testStepId
38+
TestStepStarted }|..|| TestCaseStarted: testCaseStartedId
39+
TestStepStarted }|..|| TestStep: testStepId
4040
```
4141

4242
And all has-a relationships, excluding `Envelope`:
@@ -48,58 +48,79 @@ config:
4848
layout: elk
4949
---
5050
erDiagram
51-
Attachment ||..|| Source: has a
52-
Attachment ||..|| Timestamp: has a
53-
GherkinDocument ||..|| Feature: has a
54-
Background ||..|| Location: has a
55-
Comment ||..|| Location: has a
56-
DataTable ||..|| Location: has a
57-
DocString ||..|| Location: has a
58-
Examples ||..|| Location: has a
59-
Examples ||..|| TableRow: has a
60-
Feature ||..|| Location: has a
61-
FeatureChild ||..|| Rule: has a
62-
FeatureChild ||..|| Background: has a
63-
FeatureChild ||..|| Scenario: has a
64-
Rule ||..|| Location: has a
65-
RuleChild ||..|| Background: has a
66-
RuleChild ||..|| Scenario: has a
67-
Scenario ||..|| Location: has a
68-
Step ||..|| Location: has a
69-
Step ||..|| DocString: has a
70-
Step ||..|| DataTable: has a
71-
TableCell ||..|| Location: has a
72-
TableRow ||..|| Location: has a
73-
Tag ||..|| Location: has a
74-
Hook ||..|| SourceReference: has a
75-
Meta ||..|| Product: has a
76-
Meta ||..|| Product: has a
77-
Meta ||..|| Product: has a
78-
Meta ||..|| Product: has a
79-
Meta ||..|| Ci: has a
80-
Ci ||..|| Git: has a
81-
ParameterType ||..|| SourceReference: has a
82-
ParseError ||..|| SourceReference: has a
83-
PickleStep ||..|| PickleStepArgument: has a
84-
PickleStepArgument ||..|| PickleDocString: has a
85-
PickleStepArgument ||..|| PickleTable: has a
86-
SourceReference ||..|| JavaMethod: has a
87-
SourceReference ||..|| JavaStackTraceElement: has a
88-
SourceReference ||..|| Location: has a
89-
StepDefinition ||..|| StepDefinitionPattern: has a
90-
StepDefinition ||..|| SourceReference: has a
91-
StepMatchArgument ||..|| Group: has a
92-
TestCaseFinished ||..|| Timestamp: has a
93-
TestCaseStarted ||..|| Timestamp: has a
94-
TestRunFinished ||..|| Timestamp: has a
95-
TestRunFinished ||..|| Exception: has a
96-
TestRunHookFinished ||..|| TestStepResult: has a
97-
TestRunHookFinished ||..|| Timestamp: has a
98-
TestRunHookStarted ||..|| Timestamp: has a
99-
TestRunStarted ||..|| Timestamp: has a
100-
TestStepFinished ||..|| TestStepResult: has a
101-
TestStepFinished ||..|| Timestamp: has a
102-
TestStepResult ||..|| Duration: has a
103-
TestStepResult ||..|| Exception: has a
104-
TestStepStarted ||..|| Timestamp: has a
51+
Attachment ||..o| Source: "has a"
52+
Attachment ||..o| Timestamp: "has a"
53+
GherkinDocument ||..o| Feature: "has a"
54+
GherkinDocument ||..|{ Comment: "has"
55+
Background ||..|| Location: "has a"
56+
Background ||..|{ Step: "has"
57+
Comment ||..|| Location: "has a"
58+
DataTable ||..|| Location: "has a"
59+
DataTable ||..|{ TableRow: "has"
60+
DocString ||..|| Location: "has a"
61+
Examples ||..|| Location: "has a"
62+
Examples ||..|{ Tag: "has"
63+
Examples ||..o| TableRow: "has a"
64+
Examples ||..|{ TableRow: "has"
65+
Feature ||..|| Location: "has a"
66+
Feature ||..|{ Tag: "has"
67+
Feature ||..|{ FeatureChild: "has"
68+
FeatureChild ||..o| Rule: "has a"
69+
FeatureChild ||..o| Background: "has a"
70+
FeatureChild ||..o| Scenario: "has a"
71+
Rule ||..|| Location: "has a"
72+
Rule ||..|{ Tag: "has"
73+
Rule ||..|{ RuleChild: "has"
74+
RuleChild ||..o| Background: "has a"
75+
RuleChild ||..o| Scenario: "has a"
76+
Scenario ||..|| Location: "has a"
77+
Scenario ||..|{ Tag: "has"
78+
Scenario ||..|{ Step: "has"
79+
Scenario ||..|{ Examples: "has"
80+
Step ||..|| Location: "has a"
81+
Step ||..o| DocString: "has a"
82+
Step ||..o| DataTable: "has a"
83+
TableCell ||..|| Location: "has a"
84+
TableRow ||..|| Location: "has a"
85+
TableRow ||..|{ TableCell: "has"
86+
Tag ||..|| Location: "has a"
87+
Hook ||..|| SourceReference: "has a"
88+
Meta ||..|| Product: "has a"
89+
Meta ||..|| Product: "has a"
90+
Meta ||..|| Product: "has a"
91+
Meta ||..|| Product: "has a"
92+
Meta ||..o| Ci: "has a"
93+
Ci ||..o| Git: "has a"
94+
ParameterType ||..o| SourceReference: "has a"
95+
ParseError ||..|| SourceReference: "has a"
96+
Pickle ||..|{ PickleStep: "has"
97+
Pickle ||..|{ PickleTag: "has"
98+
PickleStep ||..o| PickleStepArgument: "has a"
99+
PickleStepArgument ||..o| PickleDocString: "has a"
100+
PickleStepArgument ||..o| PickleTable: "has a"
101+
PickleTable ||..|{ PickleTableRow: "has"
102+
PickleTableRow ||..|{ PickleTableCell: "has"
103+
SourceReference ||..o| JavaMethod: "has a"
104+
SourceReference ||..o| JavaStackTraceElement: "has a"
105+
SourceReference ||..o| Location: "has a"
106+
StepDefinition ||..|| StepDefinitionPattern: "has a"
107+
StepDefinition ||..|| SourceReference: "has a"
108+
TestCase ||..|{ TestStep: "has"
109+
Group ||..|{ Group: "has"
110+
StepMatchArgument ||..|| Group: "has a"
111+
StepMatchArgumentsList ||..|{ StepMatchArgument: "has"
112+
TestStep ||..o{ StepMatchArgumentsList: "has"
113+
TestCaseFinished ||..|| Timestamp: "has a"
114+
TestCaseStarted ||..|| Timestamp: "has a"
115+
TestRunFinished ||..|| Timestamp: "has a"
116+
TestRunFinished ||..o| Exception: "has a"
117+
TestRunHookFinished ||..|| TestStepResult: "has a"
118+
TestRunHookFinished ||..|| Timestamp: "has a"
119+
TestRunHookStarted ||..|| Timestamp: "has a"
120+
TestRunStarted ||..|| Timestamp: "has a"
121+
TestStepFinished ||..|| TestStepResult: "has a"
122+
TestStepFinished ||..|| Timestamp: "has a"
123+
TestStepResult ||..|| Duration: "has a"
124+
TestStepResult ||..o| Exception: "has a"
125+
TestStepStarted ||..|| Timestamp: "has a"
105126
```

0 commit comments

Comments
 (0)