From 8e34f118dd88ec9d419e20d76aac43610d6f95c8 Mon Sep 17 00:00:00 2001 From: "M.P. Korstanje" Date: Mon, 1 Sep 2025 17:43:22 +0200 Subject: [PATCH 1/8] Generate entity relationship diagram --- codegen/templates/relations.enum.md.erb | 0 codegen/templates/relations.md.erb | 27 ++++ jsonschema/Makefile | 8 +- jsonschema/relations.md | 193 ++++++++++++++++++++++++ 4 files changed, 226 insertions(+), 2 deletions(-) create mode 100644 codegen/templates/relations.enum.md.erb create mode 100644 codegen/templates/relations.md.erb create mode 100644 jsonschema/relations.md diff --git a/codegen/templates/relations.enum.md.erb b/codegen/templates/relations.enum.md.erb new file mode 100644 index 00000000..e69de29b diff --git a/codegen/templates/relations.md.erb b/codegen/templates/relations.md.erb new file mode 100644 index 00000000..5ddcda4b --- /dev/null +++ b/codegen/templates/relations.md.erb @@ -0,0 +1,27 @@ +# Cucumber Messages + + +```mermaid +erDiagram +<% @schemas.each do |key, schema| -%> +<%- schema['properties'].each do |property_name, property| -%> +<%- +next unless property_name.end_with?("Id") +referent = property_name.delete_suffix("Id") +referent[0] = referent[0].upcase +-%> + +<%= class_name(key) %> }|..|| <%= referent %>: <%= property_name %> +<%- end -%> +<%- end -%> + +<% @schemas.each do |key, schema| -%> +<%- schema['properties'].each do |property_name, property| -%> +<%- + next unless property['$ref'] +-%> + +<%= class_name(key) %> ||..|| <%= class_name(property['$ref']) %>: has +<%- end -%> +<%- end -%> +``` \ No newline at end of file diff --git a/jsonschema/Makefile b/jsonschema/Makefile index 90a166c4..2958efed 100644 --- a/jsonschema/Makefile +++ b/jsonschema/Makefile @@ -32,7 +32,7 @@ schemas = \ help: ## Show this help @awk 'BEGIN {FS = ":.*##"; printf "\nUsage:\n make \n\nWhere is one of:\n"} /^[$$()% a-zA-Z_-]+:.*?##/ { printf " \033[36m%-15s\033[0m %s\n", $$1, $$2 } /^##@/ { printf "\n\033[1m%s\033[0m\n", substr($$0, 5) } ' $(MAKEFILE_LIST) -generate: require-doc messages.md ## Generate markdown documentation using the scripts in ./jsonschema/scripts for the generation +generate: require-doc messages.md relations.md ## Generate markdown documentation using the scripts in ./jsonschema/scripts for the generation validate: $(schemas) ## Validate the json schemas are valid npm install @@ -46,5 +46,9 @@ messages.md: $(schemas) ../codegen/codegen.rb ../codegen/templates/markdown.md.e ruby ../codegen/codegen.rb Generator::Markdown markdown.md.erb > $@ ruby ../codegen/codegen.rb Generator::Markdown markdown.enum.md.erb >> $@ +relations.md: $(schemas) ../codegen/codegen.rb ../codegen/templates/relations.md.erb ../codegen/templates/relations.enum.md.erb + ruby ../codegen/codegen.rb Generator::Markdown relations.md.erb > $@ + ruby ../codegen/codegen.rb Generator::Markdown relations.enum.md.erb >> $@ + clean: ## Remove automatically generated documentation files and related artifacts - rm -f messages.md + rm -f messages.md relations.md diff --git a/jsonschema/relations.md b/jsonschema/relations.md new file mode 100644 index 00000000..41c1c084 --- /dev/null +++ b/jsonschema/relations.md @@ -0,0 +1,193 @@ +# Cucumber Messages + + +```mermaid +erDiagram + +Attachment }|..|| TestCaseStarted: testCaseStartedId + +Attachment }|..|| TestStep: testStepId + +Attachment }|..|| TestRunStarted: testRunStartedId + +Attachment }|..|| TestRunHookStarted: testRunHookStartedId + +PickleTag }|..|| AstNode: astNodeId + +TestCase }|..|| Pickle: pickleId + +TestCase }|..|| TestRunStarted: testRunStartedId + +TestStep }|..|| Hook: hookId + +TestStep }|..|| PickleStep: pickleStepId + +TestCaseFinished }|..|| TestCaseStarted: testCaseStartedId + +TestCaseStarted }|..|| TestCase: testCaseId + +TestCaseStarted }|..|| Worker: workerId + +TestRunFinished }|..|| TestRunStarted: testRunStartedId + +TestRunHookFinished }|..|| TestRunHookStarted: testRunHookStartedId + +TestRunHookStarted }|..|| TestRunStarted: testRunStartedId + +TestRunHookStarted }|..|| Hook: hookId + +TestStepFinished }|..|| TestCaseStarted: testCaseStartedId + +TestStepFinished }|..|| TestStep: testStepId + +TestStepStarted }|..|| TestCaseStarted: testCaseStartedId + +TestStepStarted }|..|| TestStep: testStepId + + +Attachment ||..|| Source: has + +Attachment ||..|| Timestamp: has + +Envelope ||..|| Attachment: has + +Envelope ||..|| GherkinDocument: has + +Envelope ||..|| Hook: has + +Envelope ||..|| Meta: has + +Envelope ||..|| ParameterType: has + +Envelope ||..|| ParseError: has + +Envelope ||..|| Pickle: has + +Envelope ||..|| Source: has + +Envelope ||..|| StepDefinition: has + +Envelope ||..|| TestCase: has + +Envelope ||..|| TestCaseFinished: has + +Envelope ||..|| TestCaseStarted: has + +Envelope ||..|| TestRunFinished: has + +Envelope ||..|| TestRunStarted: has + +Envelope ||..|| TestStepFinished: has + +Envelope ||..|| TestStepStarted: has + +Envelope ||..|| TestRunHookStarted: has + +Envelope ||..|| TestRunHookFinished: has + +Envelope ||..|| UndefinedParameterType: has + +GherkinDocument ||..|| Feature: has + +Background ||..|| Location: has + +Comment ||..|| Location: has + +DataTable ||..|| Location: has + +DocString ||..|| Location: has + +Examples ||..|| Location: has + +Examples ||..|| TableRow: has + +Feature ||..|| Location: has + +FeatureChild ||..|| Rule: has + +FeatureChild ||..|| Background: has + +FeatureChild ||..|| Scenario: has + +Rule ||..|| Location: has + +RuleChild ||..|| Background: has + +RuleChild ||..|| Scenario: has + +Scenario ||..|| Location: has + +Step ||..|| Location: has + +Step ||..|| DocString: has + +Step ||..|| DataTable: has + +TableCell ||..|| Location: has + +TableRow ||..|| Location: has + +Tag ||..|| Location: has + +Hook ||..|| SourceReference: has + +Meta ||..|| Product: has + +Meta ||..|| Product: has + +Meta ||..|| Product: has + +Meta ||..|| Product: has + +Meta ||..|| Ci: has + +Ci ||..|| Git: has + +ParameterType ||..|| SourceReference: has + +ParseError ||..|| SourceReference: has + +PickleStep ||..|| PickleStepArgument: has + +PickleStepArgument ||..|| PickleDocString: has + +PickleStepArgument ||..|| PickleTable: has + +SourceReference ||..|| JavaMethod: has + +SourceReference ||..|| JavaStackTraceElement: has + +SourceReference ||..|| Location: has + +StepDefinition ||..|| StepDefinitionPattern: has + +StepDefinition ||..|| SourceReference: has + +StepMatchArgument ||..|| Group: has + +TestCaseFinished ||..|| Timestamp: has + +TestCaseStarted ||..|| Timestamp: has + +TestRunFinished ||..|| Timestamp: has + +TestRunFinished ||..|| Exception: has + +TestRunHookFinished ||..|| TestStepResult: has + +TestRunHookFinished ||..|| Timestamp: has + +TestRunHookStarted ||..|| Timestamp: has + +TestRunStarted ||..|| Timestamp: has + +TestStepFinished ||..|| TestStepResult: has + +TestStepFinished ||..|| Timestamp: has + +TestStepResult ||..|| Duration: has + +TestStepResult ||..|| Exception: has + +TestStepStarted ||..|| Timestamp: has +``` \ No newline at end of file From 1cdbdaf02dda935dc7b150f2b9f44ef68c6c8773 Mon Sep 17 00:00:00 2001 From: "M.P. Korstanje" Date: Mon, 1 Sep 2025 17:51:50 +0200 Subject: [PATCH 2/8] Generate entity relationship diagram --- codegen/templates/relations.md.erb | 17 +++++++++++++++++ jsonschema/relations.md | 12 ++++++++++++ 2 files changed, 29 insertions(+) diff --git a/codegen/templates/relations.md.erb b/codegen/templates/relations.md.erb index 5ddcda4b..46fce52b 100644 --- a/codegen/templates/relations.md.erb +++ b/codegen/templates/relations.md.erb @@ -3,6 +3,7 @@ ```mermaid erDiagram + direction TB <% @schemas.each do |key, schema| -%> <%- schema['properties'].each do |property_name, property| -%> <%- @@ -15,6 +16,22 @@ referent[0] = referent[0].upcase <%- end -%> <%- end -%> + + +<% @schemas.each do |key, schema| -%> +<%- schema['properties'].each do |property_name, property| -%> +<%- +next unless property_name.end_with?("Ids") +referent = property_name.delete_suffix("Ids") +referent[0] = referent[0].upcase +-%> + +<%= class_name(key) %> }|..|{ <%= referent %>: <%= property_name %> +<%- end -%> +<%- end -%> + + + <% @schemas.each do |key, schema| -%> <%- schema['properties'].each do |property_name, property| -%> <%- diff --git a/jsonschema/relations.md b/jsonschema/relations.md index 41c1c084..3988a248 100644 --- a/jsonschema/relations.md +++ b/jsonschema/relations.md @@ -3,6 +3,7 @@ ```mermaid erDiagram + direction TB Attachment }|..|| TestCaseStarted: testCaseStartedId @@ -45,6 +46,17 @@ TestStepStarted }|..|| TestCaseStarted: testCaseStartedId TestStepStarted }|..|| TestStep: testStepId + + +Pickle }|..|{ AstNode: astNodeIds + +PickleStep }|..|{ AstNode: astNodeIds + +TestStep }|..|{ StepDefinition: stepDefinitionIds + + + + Attachment ||..|| Source: has Attachment ||..|| Timestamp: has From 89f5691de46b29c4c1e24e85e91fbd6664ae5bac Mon Sep 17 00:00:00 2001 From: "M.P. Korstanje" Date: Mon, 1 Sep 2025 18:25:39 +0200 Subject: [PATCH 3/8] Generate entity relationship diagram --- codegen/templates/relations.enum.md.erb | 0 codegen/templates/relations.md.erb | 25 ++- jsonschema/Makefile | 3 +- jsonschema/relations.md | 209 +++++++++++++----------- 4 files changed, 130 insertions(+), 107 deletions(-) delete mode 100644 codegen/templates/relations.enum.md.erb diff --git a/codegen/templates/relations.enum.md.erb b/codegen/templates/relations.enum.md.erb deleted file mode 100644 index e69de29b..00000000 diff --git a/codegen/templates/relations.md.erb b/codegen/templates/relations.md.erb index 46fce52b..e10360ec 100644 --- a/codegen/templates/relations.md.erb +++ b/codegen/templates/relations.md.erb @@ -1,18 +1,26 @@ -# Cucumber Messages +# Cucumber Messages +All relationships where an entity is referenced by `id`. + +Note: The left side cardinality of the relationship is always rendered as one-or-more, but may also be exactly-one. This can't be extracted from the json schema easily. ```mermaid +--- +title: Entity relationships +config: + layout: elk +--- erDiagram - direction TB <% @schemas.each do |key, schema| -%> <%- schema['properties'].each do |property_name, property| -%> <%- next unless property_name.end_with?("Id") referent = property_name.delete_suffix("Id") referent[0] = referent[0].upcase +required = (schema['required'] || []).index(property_name) -%> -<%= class_name(key) %> }|..|| <%= referent %>: <%= property_name %> +<%= class_name(key) %> }|..<%= required ? '||' : 'o|' %> <%= referent %>: <%= property_name %> <%- end -%> <%- end -%> @@ -24,21 +32,26 @@ referent[0] = referent[0].upcase next unless property_name.end_with?("Ids") referent = property_name.delete_suffix("Ids") referent[0] = referent[0].upcase +required = (schema['required'] || []).index(property_name) -%> -<%= class_name(key) %> }|..|{ <%= referent %>: <%= property_name %> +<%= class_name(key) %> }|..<%= required ? '|{' : 'o{' %> <%= referent %>: <%= property_name %> <%- end -%> <%- end -%> +``` +And all has-a relationships: +```mermaid +erDiagram <% @schemas.each do |key, schema| -%> <%- schema['properties'].each do |property_name, property| -%> <%- next unless property['$ref'] -%> -<%= class_name(key) %> ||..|| <%= class_name(property['$ref']) %>: has +<%= class_name(key) %> ||..|| <%= class_name(property['$ref']) %>: has a <%- end -%> <%- end -%> -``` \ No newline at end of file +``` diff --git a/jsonschema/Makefile b/jsonschema/Makefile index 2958efed..a8cb259e 100644 --- a/jsonschema/Makefile +++ b/jsonschema/Makefile @@ -46,9 +46,8 @@ messages.md: $(schemas) ../codegen/codegen.rb ../codegen/templates/markdown.md.e ruby ../codegen/codegen.rb Generator::Markdown markdown.md.erb > $@ ruby ../codegen/codegen.rb Generator::Markdown markdown.enum.md.erb >> $@ -relations.md: $(schemas) ../codegen/codegen.rb ../codegen/templates/relations.md.erb ../codegen/templates/relations.enum.md.erb +relations.md: $(schemas) ../codegen/codegen.rb ../codegen/templates/relations.md.erb ruby ../codegen/codegen.rb Generator::Markdown relations.md.erb > $@ - ruby ../codegen/codegen.rb Generator::Markdown relations.enum.md.erb >> $@ clean: ## Remove automatically generated documentation files and related artifacts rm -f messages.md relations.md diff --git a/jsonschema/relations.md b/jsonschema/relations.md index 3988a248..e42e2e6b 100644 --- a/jsonschema/relations.md +++ b/jsonschema/relations.md @@ -1,205 +1,216 @@ -# Cucumber Messages +# Cucumber Messages +All relationships where an entity is referenced by `id`. + +Note: The left side cardinality of the relationship is always rendered as one-or-more, but may also be exactly-one. This can't be extracted from the json schema easily. ```mermaid +--- +title: Entity relationships +config: + layout: elk +--- erDiagram - direction TB -Attachment }|..|| TestCaseStarted: testCaseStartedId +Attachment }|..o| TestCaseStarted: testCaseStartedId -Attachment }|..|| TestStep: testStepId +Attachment }|..o| TestStep: testStepId -Attachment }|..|| TestRunStarted: testRunStartedId +Attachment }|..o| TestRunStarted: testRunStartedId -Attachment }|..|| TestRunHookStarted: testRunHookStartedId +Attachment }|..o| TestRunHookStarted: testRunHookStartedId -PickleTag }|..|| AstNode: astNodeId +PickleTag }|..|| AstNode: astNodeId -TestCase }|..|| Pickle: pickleId +TestCase }|..|| Pickle: pickleId -TestCase }|..|| TestRunStarted: testRunStartedId +TestCase }|..o| TestRunStarted: testRunStartedId -TestStep }|..|| Hook: hookId +TestStep }|..o| Hook: hookId -TestStep }|..|| PickleStep: pickleStepId +TestStep }|..o| PickleStep: pickleStepId -TestCaseFinished }|..|| TestCaseStarted: testCaseStartedId +TestCaseFinished }|..|| TestCaseStarted: testCaseStartedId -TestCaseStarted }|..|| TestCase: testCaseId +TestCaseStarted }|..|| TestCase: testCaseId -TestCaseStarted }|..|| Worker: workerId +TestCaseStarted }|..o| Worker: workerId -TestRunFinished }|..|| TestRunStarted: testRunStartedId +TestRunFinished }|..o| TestRunStarted: testRunStartedId -TestRunHookFinished }|..|| TestRunHookStarted: testRunHookStartedId +TestRunHookFinished }|..|| TestRunHookStarted: testRunHookStartedId -TestRunHookStarted }|..|| TestRunStarted: testRunStartedId +TestRunHookStarted }|..|| TestRunStarted: testRunStartedId -TestRunHookStarted }|..|| Hook: hookId +TestRunHookStarted }|..|| Hook: hookId -TestStepFinished }|..|| TestCaseStarted: testCaseStartedId +TestStepFinished }|..|| TestCaseStarted: testCaseStartedId -TestStepFinished }|..|| TestStep: testStepId +TestStepFinished }|..|| TestStep: testStepId -TestStepStarted }|..|| TestCaseStarted: testCaseStartedId +TestStepStarted }|..|| TestCaseStarted: testCaseStartedId -TestStepStarted }|..|| TestStep: testStepId +TestStepStarted }|..|| TestStep: testStepId -Pickle }|..|{ AstNode: astNodeIds +Pickle }|..|{ AstNode: astNodeIds -PickleStep }|..|{ AstNode: astNodeIds +PickleStep }|..|{ AstNode: astNodeIds -TestStep }|..|{ StepDefinition: stepDefinitionIds +TestStep }|..o{ StepDefinition: stepDefinitionIds +``` +And all has-a relationships: +```mermaid +erDiagram -Attachment ||..|| Source: has +Attachment ||..|| Source: has a -Attachment ||..|| Timestamp: has +Attachment ||..|| Timestamp: has a -Envelope ||..|| Attachment: has +Envelope ||..|| Attachment: has a -Envelope ||..|| GherkinDocument: has +Envelope ||..|| GherkinDocument: has a -Envelope ||..|| Hook: has +Envelope ||..|| Hook: has a -Envelope ||..|| Meta: has +Envelope ||..|| Meta: has a -Envelope ||..|| ParameterType: has +Envelope ||..|| ParameterType: has a -Envelope ||..|| ParseError: has +Envelope ||..|| ParseError: has a -Envelope ||..|| Pickle: has +Envelope ||..|| Pickle: has a -Envelope ||..|| Source: has +Envelope ||..|| Source: has a -Envelope ||..|| StepDefinition: has +Envelope ||..|| StepDefinition: has a -Envelope ||..|| TestCase: has +Envelope ||..|| TestCase: has a -Envelope ||..|| TestCaseFinished: has +Envelope ||..|| TestCaseFinished: has a -Envelope ||..|| TestCaseStarted: has +Envelope ||..|| TestCaseStarted: has a -Envelope ||..|| TestRunFinished: has +Envelope ||..|| TestRunFinished: has a -Envelope ||..|| TestRunStarted: has +Envelope ||..|| TestRunStarted: has a -Envelope ||..|| TestStepFinished: has +Envelope ||..|| TestStepFinished: has a -Envelope ||..|| TestStepStarted: has +Envelope ||..|| TestStepStarted: has a -Envelope ||..|| TestRunHookStarted: has +Envelope ||..|| TestRunHookStarted: has a -Envelope ||..|| TestRunHookFinished: has +Envelope ||..|| TestRunHookFinished: has a -Envelope ||..|| UndefinedParameterType: has +Envelope ||..|| UndefinedParameterType: has a -GherkinDocument ||..|| Feature: has +GherkinDocument ||..|| Feature: has a -Background ||..|| Location: has +Background ||..|| Location: has a -Comment ||..|| Location: has +Comment ||..|| Location: has a -DataTable ||..|| Location: has +DataTable ||..|| Location: has a -DocString ||..|| Location: has +DocString ||..|| Location: has a -Examples ||..|| Location: has +Examples ||..|| Location: has a -Examples ||..|| TableRow: has +Examples ||..|| TableRow: has a -Feature ||..|| Location: has +Feature ||..|| Location: has a -FeatureChild ||..|| Rule: has +FeatureChild ||..|| Rule: has a -FeatureChild ||..|| Background: has +FeatureChild ||..|| Background: has a -FeatureChild ||..|| Scenario: has +FeatureChild ||..|| Scenario: has a -Rule ||..|| Location: has +Rule ||..|| Location: has a -RuleChild ||..|| Background: has +RuleChild ||..|| Background: has a -RuleChild ||..|| Scenario: has +RuleChild ||..|| Scenario: has a -Scenario ||..|| Location: has +Scenario ||..|| Location: has a -Step ||..|| Location: has +Step ||..|| Location: has a -Step ||..|| DocString: has +Step ||..|| DocString: has a -Step ||..|| DataTable: has +Step ||..|| DataTable: has a -TableCell ||..|| Location: has +TableCell ||..|| Location: has a -TableRow ||..|| Location: has +TableRow ||..|| Location: has a -Tag ||..|| Location: has +Tag ||..|| Location: has a -Hook ||..|| SourceReference: has +Hook ||..|| SourceReference: has a -Meta ||..|| Product: has +Meta ||..|| Product: has a -Meta ||..|| Product: has +Meta ||..|| Product: has a -Meta ||..|| Product: has +Meta ||..|| Product: has a -Meta ||..|| Product: has +Meta ||..|| Product: has a -Meta ||..|| Ci: has +Meta ||..|| Ci: has a -Ci ||..|| Git: has +Ci ||..|| Git: has a -ParameterType ||..|| SourceReference: has +ParameterType ||..|| SourceReference: has a -ParseError ||..|| SourceReference: has +ParseError ||..|| SourceReference: has a -PickleStep ||..|| PickleStepArgument: has +PickleStep ||..|| PickleStepArgument: has a -PickleStepArgument ||..|| PickleDocString: has +PickleStepArgument ||..|| PickleDocString: has a -PickleStepArgument ||..|| PickleTable: has +PickleStepArgument ||..|| PickleTable: has a -SourceReference ||..|| JavaMethod: has +SourceReference ||..|| JavaMethod: has a -SourceReference ||..|| JavaStackTraceElement: has +SourceReference ||..|| JavaStackTraceElement: has a -SourceReference ||..|| Location: has +SourceReference ||..|| Location: has a -StepDefinition ||..|| StepDefinitionPattern: has +StepDefinition ||..|| StepDefinitionPattern: has a -StepDefinition ||..|| SourceReference: has +StepDefinition ||..|| SourceReference: has a -StepMatchArgument ||..|| Group: has +StepMatchArgument ||..|| Group: has a -TestCaseFinished ||..|| Timestamp: has +TestCaseFinished ||..|| Timestamp: has a -TestCaseStarted ||..|| Timestamp: has +TestCaseStarted ||..|| Timestamp: has a -TestRunFinished ||..|| Timestamp: has +TestRunFinished ||..|| Timestamp: has a -TestRunFinished ||..|| Exception: has +TestRunFinished ||..|| Exception: has a -TestRunHookFinished ||..|| TestStepResult: has +TestRunHookFinished ||..|| TestStepResult: has a -TestRunHookFinished ||..|| Timestamp: has +TestRunHookFinished ||..|| Timestamp: has a -TestRunHookStarted ||..|| Timestamp: has +TestRunHookStarted ||..|| Timestamp: has a -TestRunStarted ||..|| Timestamp: has +TestRunStarted ||..|| Timestamp: has a -TestStepFinished ||..|| TestStepResult: has +TestStepFinished ||..|| TestStepResult: has a -TestStepFinished ||..|| Timestamp: has +TestStepFinished ||..|| Timestamp: has a -TestStepResult ||..|| Duration: has +TestStepResult ||..|| Duration: has a -TestStepResult ||..|| Exception: has +TestStepResult ||..|| Exception: has a -TestStepStarted ||..|| Timestamp: has -``` \ No newline at end of file +TestStepStarted ||..|| Timestamp: has a +``` From c69f07d8d926b9db5ae81fbf541d8d31d9cda9b6 Mon Sep 17 00:00:00 2001 From: "M.P. Korstanje" Date: Mon, 1 Sep 2025 18:27:44 +0200 Subject: [PATCH 4/8] Generate entity relationship diagram --- codegen/templates/relations.md.erb | 10 +++++-- jsonschema/relations.md | 47 +++++------------------------- 2 files changed, 15 insertions(+), 42 deletions(-) diff --git a/codegen/templates/relations.md.erb b/codegen/templates/relations.md.erb index e10360ec..253355ea 100644 --- a/codegen/templates/relations.md.erb +++ b/codegen/templates/relations.md.erb @@ -6,7 +6,7 @@ Note: The left side cardinality of the relationship is always rendered as one-or ```mermaid --- -title: Entity relationships +title: Entity relationships - by id config: layout: elk --- @@ -41,14 +41,20 @@ required = (schema['required'] || []).index(property_name) ``` -And all has-a relationships: +And all has-a relationships, excluding `Envelope`: ```mermaid +--- +title: Entity relationships - has a +config: + layout: elk +--- erDiagram <% @schemas.each do |key, schema| -%> <%- schema['properties'].each do |property_name, property| -%> <%- next unless property['$ref'] + next unless class_name(key) != "Envelope" -%> <%= class_name(key) %> ||..|| <%= class_name(property['$ref']) %>: has a diff --git a/jsonschema/relations.md b/jsonschema/relations.md index e42e2e6b..44d67d4c 100644 --- a/jsonschema/relations.md +++ b/jsonschema/relations.md @@ -6,7 +6,7 @@ Note: The left side cardinality of the relationship is always rendered as one-or ```mermaid --- -title: Entity relationships +title: Entity relationships - by id config: layout: elk --- @@ -63,53 +63,20 @@ TestStep }|..o{ StepDefinition: stepDefinitionIds ``` -And all has-a relationships: +And all has-a relationships, excluding `Envelope`: ```mermaid +--- +title: Entity relationships - has a +config: + layout: elk +--- erDiagram Attachment ||..|| Source: has a Attachment ||..|| Timestamp: has a -Envelope ||..|| Attachment: has a - -Envelope ||..|| GherkinDocument: has a - -Envelope ||..|| Hook: has a - -Envelope ||..|| Meta: has a - -Envelope ||..|| ParameterType: has a - -Envelope ||..|| ParseError: has a - -Envelope ||..|| Pickle: has a - -Envelope ||..|| Source: has a - -Envelope ||..|| StepDefinition: has a - -Envelope ||..|| TestCase: has a - -Envelope ||..|| TestCaseFinished: has a - -Envelope ||..|| TestCaseStarted: has a - -Envelope ||..|| TestRunFinished: has a - -Envelope ||..|| TestRunStarted: has a - -Envelope ||..|| TestStepFinished: has a - -Envelope ||..|| TestStepStarted: has a - -Envelope ||..|| TestRunHookStarted: has a - -Envelope ||..|| TestRunHookFinished: has a - -Envelope ||..|| UndefinedParameterType: has a - GherkinDocument ||..|| Feature: has a Background ||..|| Location: has a From ad818c0c560e724e4f6443a7c9c9407ebf3b8a92 Mon Sep 17 00:00:00 2001 From: "M.P. Korstanje" Date: Mon, 1 Sep 2025 18:37:51 +0200 Subject: [PATCH 5/8] Generate entity relationship diagram --- README.md | 4 +++- jsonschema/relations.md | 1 + 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 3b924198..389d5d1e 100644 --- a/README.md +++ b/README.md @@ -11,7 +11,9 @@ from Cucumber. The protocol aims to decouple various components of the Cucumber ![messages.png](jsonschema/messages.png) -Note: Markdown and Excel formats are currently not supported and mentioned here as potential future alternative languages to express BDD scenarios. +Notes: + * The image sketches out the general concept, but is incomplete. See [relations.md](jsonschema/relations.md) for a complete visualisation of the relationships between messages. + * Markdown and Excel formats are currently not supported and mentioned here as potential future alternative languages to express BDD scenarios. ## JSON Schema diff --git a/jsonschema/relations.md b/jsonschema/relations.md index 44d67d4c..8b6de224 100644 --- a/jsonschema/relations.md +++ b/jsonschema/relations.md @@ -11,6 +11,7 @@ config: layout: elk --- erDiagram +group test Attachment }|..o| TestCaseStarted: testCaseStartedId From 8006612b257d46bf38fa8f28e3677e4b1914883f Mon Sep 17 00:00:00 2001 From: "M.P. Korstanje" Date: Mon, 1 Sep 2025 18:40:02 +0200 Subject: [PATCH 6/8] Generate entity relationship diagram --- jsonschema/relations.md | 1 - 1 file changed, 1 deletion(-) diff --git a/jsonschema/relations.md b/jsonschema/relations.md index 8b6de224..44d67d4c 100644 --- a/jsonschema/relations.md +++ b/jsonschema/relations.md @@ -11,7 +11,6 @@ config: layout: elk --- erDiagram -group test Attachment }|..o| TestCaseStarted: testCaseStartedId From ee1da2d102496f3b4f9c415efdd613148cf6d9c5 Mon Sep 17 00:00:00 2001 From: "M.P. Korstanje" Date: Mon, 1 Sep 2025 18:41:47 +0200 Subject: [PATCH 7/8] Generate entity relationship diagram --- codegen/templates/relations.md.erb | 4 +++- jsonschema/relations.md | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/codegen/templates/relations.md.erb b/codegen/templates/relations.md.erb index 253355ea..b2f4bb65 100644 --- a/codegen/templates/relations.md.erb +++ b/codegen/templates/relations.md.erb @@ -2,7 +2,9 @@ All relationships where an entity is referenced by `id`. -Note: The left side cardinality of the relationship is always rendered as one-or-more, but may also be exactly-one. This can't be extracted from the json schema easily. +Notes: + * The left side cardinality of the relationship is always rendered as one-or-more, but may also be exactly-one. This can't be extracted from the json schema easily. + * Worker is not actually an entity in the message protocol, but is referenced by id. ```mermaid --- diff --git a/jsonschema/relations.md b/jsonschema/relations.md index 44d67d4c..aa39f4de 100644 --- a/jsonschema/relations.md +++ b/jsonschema/relations.md @@ -2,7 +2,9 @@ All relationships where an entity is referenced by `id`. -Note: The left side cardinality of the relationship is always rendered as one-or-more, but may also be exactly-one. This can't be extracted from the json schema easily. +Notes: + * The left side cardinality of the relationship is always rendered as one-or-more, but may also be exactly-one. This can't be extracted from the json schema easily. + * Worker is not actually an entity in the message protocol, but is referenced by id. ```mermaid --- From 2768ba2f9bd9139a1d90056d4c568da21c2a20e8 Mon Sep 17 00:00:00 2001 From: "M.P. Korstanje" Date: Tue, 2 Sep 2025 21:59:05 +0200 Subject: [PATCH 8/8] Generate entity relationship diagram --- codegen/templates/relations.md.erb | 35 +++----- jsonschema/relations.md | 128 ++++++----------------------- 2 files changed, 37 insertions(+), 126 deletions(-) diff --git a/codegen/templates/relations.md.erb b/codegen/templates/relations.md.erb index b2f4bb65..791342f1 100644 --- a/codegen/templates/relations.md.erb +++ b/codegen/templates/relations.md.erb @@ -5,6 +5,7 @@ All relationships where an entity is referenced by `id`. Notes: * The left side cardinality of the relationship is always rendered as one-or-more, but may also be exactly-one. This can't be extracted from the json schema easily. * Worker is not actually an entity in the message protocol, but is referenced by id. + * `AstNode` is not actually an entity in the message protocol, but does reference an element in the `GherkinDocument`. ```mermaid --- @@ -13,34 +14,25 @@ config: layout: elk --- erDiagram -<% @schemas.each do |key, schema| -%> +<%- @schemas.each do |key, schema| -%> <%- schema['properties'].each do |property_name, property| -%> -<%- -next unless property_name.end_with?("Id") -referent = property_name.delete_suffix("Id") -referent[0] = referent[0].upcase -required = (schema['required'] || []).index(property_name) +<%- if property_name.end_with?("Id") + referent = property_name.delete_suffix("Id") + referent[0] = referent[0].upcase + required = (schema['required'] || []).index(property_name) -%> - -<%= class_name(key) %> }|..<%= required ? '||' : 'o|' %> <%= referent %>: <%= property_name %> -<%- end -%> +<%= class_name(key) %> }|..<%= required ? '||' : 'o|' %> <%= referent %>: <%= property_name %> <%- end -%> - - - -<% @schemas.each do |key, schema| -%> -<%- schema['properties'].each do |property_name, property| -%> <%- -next unless property_name.end_with?("Ids") -referent = property_name.delete_suffix("Ids") -referent[0] = referent[0].upcase -required = (schema['required'] || []).index(property_name) +if property_name.end_with?("Ids") + referent = property_name.delete_suffix("Ids") + referent[0] = referent[0].upcase + required = (schema['required'] || []).index(property_name) -%> - -<%= class_name(key) %> }|..<%= required ? '|{' : 'o{' %> <%= referent %>: <%= property_name %> +<%= class_name(key) %> }|..<%= required ? '|{' : 'o{' %> <%= referent %>: <%= property_name %> +<%- end -%> <%- end -%> <%- end -%> - ``` And all has-a relationships, excluding `Envelope`: @@ -58,7 +50,6 @@ erDiagram next unless property['$ref'] next unless class_name(key) != "Envelope" -%> - <%= class_name(key) %> ||..|| <%= class_name(property['$ref']) %>: has a <%- end -%> <%- end -%> diff --git a/jsonschema/relations.md b/jsonschema/relations.md index aa39f4de..84a2aaa0 100644 --- a/jsonschema/relations.md +++ b/jsonschema/relations.md @@ -5,6 +5,7 @@ All relationships where an entity is referenced by `id`. Notes: * The left side cardinality of the relationship is always rendered as one-or-more, but may also be exactly-one. This can't be extracted from the json schema easily. * Worker is not actually an entity in the message protocol, but is referenced by id. + * `AstNode` is not actually an entity in the message protocol, but does reference an element in the `GherkinDocument`. ```mermaid --- @@ -13,56 +14,29 @@ config: layout: elk --- erDiagram - -Attachment }|..o| TestCaseStarted: testCaseStartedId - -Attachment }|..o| TestStep: testStepId - -Attachment }|..o| TestRunStarted: testRunStartedId - -Attachment }|..o| TestRunHookStarted: testRunHookStartedId - -PickleTag }|..|| AstNode: astNodeId - -TestCase }|..|| Pickle: pickleId - -TestCase }|..o| TestRunStarted: testRunStartedId - -TestStep }|..o| Hook: hookId - -TestStep }|..o| PickleStep: pickleStepId - -TestCaseFinished }|..|| TestCaseStarted: testCaseStartedId - -TestCaseStarted }|..|| TestCase: testCaseId - -TestCaseStarted }|..o| Worker: workerId - -TestRunFinished }|..o| TestRunStarted: testRunStartedId - -TestRunHookFinished }|..|| TestRunHookStarted: testRunHookStartedId - -TestRunHookStarted }|..|| TestRunStarted: testRunStartedId - -TestRunHookStarted }|..|| Hook: hookId - -TestStepFinished }|..|| TestCaseStarted: testCaseStartedId - -TestStepFinished }|..|| TestStep: testStepId - -TestStepStarted }|..|| TestCaseStarted: testCaseStartedId - -TestStepStarted }|..|| TestStep: testStepId - - - - -Pickle }|..|{ AstNode: astNodeIds - -PickleStep }|..|{ AstNode: astNodeIds - -TestStep }|..o{ StepDefinition: stepDefinitionIds - +Attachment }|..o| TestCaseStarted: testCaseStartedId +Attachment }|..o| TestStep: testStepId +Attachment }|..o| TestRunStarted: testRunStartedId +Attachment }|..o| TestRunHookStarted: testRunHookStartedId +Pickle }|..|{ AstNode: astNodeIds +PickleStep }|..|{ AstNode: astNodeIds +PickleTag }|..|| AstNode: astNodeId +TestCase }|..|| Pickle: pickleId +TestCase }|..o| TestRunStarted: testRunStartedId +TestStep }|..o| Hook: hookId +TestStep }|..o| PickleStep: pickleStepId +TestStep }|..o{ StepDefinition: stepDefinitionIds +TestCaseFinished }|..|| TestCaseStarted: testCaseStartedId +TestCaseStarted }|..|| TestCase: testCaseId +TestCaseStarted }|..o| Worker: workerId +TestRunFinished }|..o| TestRunStarted: testRunStartedId +TestRunHookFinished }|..|| TestRunHookStarted: testRunHookStartedId +TestRunHookStarted }|..|| TestRunStarted: testRunStartedId +TestRunHookStarted }|..|| Hook: hookId +TestStepFinished }|..|| TestCaseStarted: testCaseStartedId +TestStepFinished }|..|| TestStep: testStepId +TestStepStarted }|..|| TestCaseStarted: testCaseStartedId +TestStepStarted }|..|| TestStep: testStepId ``` And all has-a relationships, excluding `Envelope`: @@ -74,112 +48,58 @@ config: layout: elk --- erDiagram - Attachment ||..|| Source: has a - Attachment ||..|| Timestamp: has a - GherkinDocument ||..|| Feature: has a - Background ||..|| Location: has a - Comment ||..|| Location: has a - DataTable ||..|| Location: has a - DocString ||..|| Location: has a - Examples ||..|| Location: has a - Examples ||..|| TableRow: has a - Feature ||..|| Location: has a - FeatureChild ||..|| Rule: has a - FeatureChild ||..|| Background: has a - FeatureChild ||..|| Scenario: has a - Rule ||..|| Location: has a - RuleChild ||..|| Background: has a - RuleChild ||..|| Scenario: has a - Scenario ||..|| Location: has a - Step ||..|| Location: has a - Step ||..|| DocString: has a - Step ||..|| DataTable: has a - TableCell ||..|| Location: has a - TableRow ||..|| Location: has a - Tag ||..|| Location: has a - Hook ||..|| SourceReference: has a - Meta ||..|| Product: has a - Meta ||..|| Product: has a - Meta ||..|| Product: has a - Meta ||..|| Product: has a - Meta ||..|| Ci: has a - Ci ||..|| Git: has a - ParameterType ||..|| SourceReference: has a - ParseError ||..|| SourceReference: has a - PickleStep ||..|| PickleStepArgument: has a - PickleStepArgument ||..|| PickleDocString: has a - PickleStepArgument ||..|| PickleTable: has a - SourceReference ||..|| JavaMethod: has a - SourceReference ||..|| JavaStackTraceElement: has a - SourceReference ||..|| Location: has a - StepDefinition ||..|| StepDefinitionPattern: has a - StepDefinition ||..|| SourceReference: has a - StepMatchArgument ||..|| Group: has a - TestCaseFinished ||..|| Timestamp: has a - TestCaseStarted ||..|| Timestamp: has a - TestRunFinished ||..|| Timestamp: has a - TestRunFinished ||..|| Exception: has a - TestRunHookFinished ||..|| TestStepResult: has a - TestRunHookFinished ||..|| Timestamp: has a - TestRunHookStarted ||..|| Timestamp: has a - TestRunStarted ||..|| Timestamp: has a - TestStepFinished ||..|| TestStepResult: has a - TestStepFinished ||..|| Timestamp: has a - TestStepResult ||..|| Duration: has a - TestStepResult ||..|| Exception: has a - TestStepStarted ||..|| Timestamp: has a ```