docusaurus-plugin-generate-schema-docs 1.2.0 → 1.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (89) hide show
  1. package/README.md +70 -6
  2. package/__tests__/ExampleDataLayer.test.js +91 -155
  3. package/__tests__/__fixtures__/static/schemas/add-to-cart-event.json +4 -15
  4. package/__tests__/__fixtures__/static/schemas/anchor/parent-event-anchor.json +29 -0
  5. package/__tests__/__fixtures__/static/schemas/choice-event.json +72 -0
  6. package/__tests__/__fixtures__/static/schemas/components/dataLayer.json +52 -54
  7. package/__tests__/__fixtures__/static/schemas/components/product.json +124 -210
  8. package/__tests__/__fixtures__/static/schemas/nested/child-event.json +10 -0
  9. package/__tests__/__fixtures__/static/schemas/nested/grandchild-a.json +9 -0
  10. package/__tests__/__fixtures__/static/schemas/nested/grandchild-b.json +9 -0
  11. package/__tests__/__fixtures__/static/schemas/nested/parent-event.json +7 -0
  12. package/__tests__/__fixtures__/static/schemas/root-any-of-event.json +34 -0
  13. package/__tests__/__fixtures__/static/schemas/root-choice-event.json +36 -0
  14. package/__tests__/__fixtures__/validateSchemas/circular-schema.json +6 -6
  15. package/__tests__/__fixtures__/validateSchemas/components/referenced.json +9 -7
  16. package/__tests__/__fixtures__/validateSchemas/invalid-example-schema.json +7 -7
  17. package/__tests__/__fixtures__/validateSchemas/main-schema-with-missing-ref.json +7 -7
  18. package/__tests__/__fixtures__/validateSchemas/main-schema-with-ref.json +7 -7
  19. package/__tests__/__fixtures__/validateSchemas/no-example-schema.json +11 -11
  20. package/__tests__/__fixtures__/validateSchemas/schema-A.json +5 -5
  21. package/__tests__/__fixtures__/validateSchemas/schema-B.json +5 -5
  22. package/__tests__/__fixtures__/validateSchemas/valid-schema.json +7 -7
  23. package/__tests__/__fixtures_versioned__/static/schemas/1.1.1/add-to-cart-event.json +44 -0
  24. package/__tests__/__fixtures_versioned__/static/schemas/1.1.1/components/dataLayer.json +56 -0
  25. package/__tests__/__fixtures_versioned__/static/schemas/1.1.1/components/product.json +125 -0
  26. package/__tests__/__fixtures_versioned__/static/schemas/next/add-to-cart-event.json +44 -0
  27. package/__tests__/__fixtures_versioned__/static/schemas/next/components/dataLayer.json +56 -0
  28. package/__tests__/__fixtures_versioned__/static/schemas/next/components/product.json +125 -0
  29. package/__tests__/__fixtures_versioned__/versions.json +1 -0
  30. package/__tests__/__snapshots__/ExampleDataLayer.test.js.snap +117 -0
  31. package/__tests__/__snapshots__/generateEventDocs.anchor.test.js.snap +79 -0
  32. package/__tests__/__snapshots__/generateEventDocs.nested.test.js.snap +98 -0
  33. package/__tests__/__snapshots__/generateEventDocs.test.js.snap +129 -16
  34. package/__tests__/__snapshots__/generateEventDocs.versioned.test.js.snap +59 -0
  35. package/__tests__/components/FoldableRows.test.js +330 -0
  36. package/__tests__/components/PropertiesTable.test.js +67 -17
  37. package/__tests__/components/PropertyRow.test.js +471 -51
  38. package/__tests__/components/SchemaJsonViewer.test.js +23 -19
  39. package/__tests__/components/SchemaRows.test.js +96 -66
  40. package/__tests__/components/SchemaViewer.test.js +34 -17
  41. package/__tests__/components/TableHeader.test.js +12 -12
  42. package/__tests__/generateEventDocs.anchor.test.js +71 -0
  43. package/__tests__/generateEventDocs.nested.test.js +80 -0
  44. package/__tests__/generateEventDocs.test.js +77 -71
  45. package/__tests__/generateEventDocs.versioned.test.js +69 -0
  46. package/__tests__/helpers/buildExampleFromSchema.test.js +160 -160
  47. package/__tests__/helpers/example-helper.test.js +71 -0
  48. package/__tests__/helpers/file-system.test.js +44 -0
  49. package/__tests__/helpers/getConstraints.test.js +93 -48
  50. package/__tests__/helpers/loadSchema.test.js +11 -5
  51. package/__tests__/helpers/path-helpers.test.js +34 -0
  52. package/__tests__/helpers/processSchema.test.js +42 -22
  53. package/__tests__/helpers/schema-processing.test.js +82 -0
  54. package/__tests__/helpers/schemaToExamples.test.js +56 -0
  55. package/__tests__/helpers/schemaToTableData.filtering.test.js +65 -0
  56. package/__tests__/helpers/schemaToTableData.hierarchicalLines.test.js +539 -0
  57. package/__tests__/helpers/schemaToTableData.test.js +217 -0
  58. package/__tests__/helpers/update-schema-ids.test.js +107 -0
  59. package/__tests__/update-schema-ids.test.js +39 -0
  60. package/__tests__/validateSchemas.test.js +125 -88
  61. package/components/ExampleDataLayer.js +68 -28
  62. package/components/FoldableRows.js +164 -0
  63. package/components/PropertiesTable.js +24 -6
  64. package/components/PropertiesTable.module.css +27 -0
  65. package/components/PropertyRow.js +168 -60
  66. package/components/SchemaJsonViewer.js +6 -6
  67. package/components/SchemaRows.css +242 -14
  68. package/components/SchemaRows.js +24 -41
  69. package/components/SchemaViewer.js +20 -14
  70. package/components/TableHeader.js +12 -12
  71. package/components/WordWrapButton.js +31 -0
  72. package/components/wordWrapButton.module.css +8 -0
  73. package/generateEventDocs.js +142 -61
  74. package/helpers/buildExampleFromSchema.js +60 -72
  75. package/helpers/choice-index-template.js +22 -0
  76. package/helpers/example-helper.js +41 -0
  77. package/helpers/file-system.js +32 -0
  78. package/helpers/getConstraints.js +44 -44
  79. package/helpers/loadSchema.js +2 -2
  80. package/helpers/path-helpers.js +22 -0
  81. package/helpers/processSchema.js +19 -19
  82. package/helpers/{mdx-template.js → schema-doc-template.js} +20 -13
  83. package/helpers/schema-processing.js +77 -0
  84. package/helpers/schemaToExamples.js +99 -0
  85. package/helpers/schemaToTableData.js +312 -0
  86. package/helpers/update-schema-ids.js +47 -0
  87. package/index.js +153 -55
  88. package/package.json +1 -1
  89. package/validateSchemas.js +56 -71
@@ -0,0 +1,44 @@
1
+ {
2
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3
+ "$id": "https://tracking-docs-demo.buchert.digital/schemas/add-to-cart-event.json",
4
+ "title": "Add to Cart Event",
5
+ "description": "An add_to_cart event fires when a user adds one or more items to their shopping cart. Based on Google Analytics 4 ecommerce event specifications.",
6
+ "type": "object",
7
+ "allOf": [
8
+ {
9
+ "$ref": "./components/dataLayer.json"
10
+ }
11
+ ],
12
+ "properties": {
13
+ "event": {
14
+ "type": "string",
15
+ "const": "add_to_cart",
16
+ "description": "The name of the event indicating a add_to_cart has occurred."
17
+ },
18
+ "ecommerce": {
19
+ "type": "object",
20
+ "description": "Ecommerce related data for the purchase event.",
21
+ "properties": {
22
+ "value": {
23
+ "type": "number",
24
+ "description": "The monetary value of the event. Set value to the sum of (price * quantity) for all items in items.",
25
+ "examples": [30.03, 99.99, 45.5]
26
+ },
27
+ "currency": {
28
+ "type": "string",
29
+ "description": "The currency of the items in ISO 4217 three-letter format. Required when value is set.",
30
+ "examples": ["USD", "EUR", "GBP"]
31
+ },
32
+ "items": {
33
+ "type": "array",
34
+ "description": "The products added to the cart.",
35
+ "minItems": 1,
36
+ "items": {
37
+ "$ref": "./components/product.json"
38
+ }
39
+ }
40
+ },
41
+ "required": ["currency", "items"]
42
+ }
43
+ }
44
+ }
@@ -0,0 +1,56 @@
1
+ {
2
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3
+ "$id": "https://tracking-docs-demo.buchert.digital/schemas/components/dataLayer.json",
4
+ "title": "dataLayer",
5
+ "description": "Schema for the object structure pushed to the dataLayer.",
6
+ "type": "object",
7
+ "allOf": [
8
+ {
9
+ "$ref": "#/$defs/strictObject"
10
+ }
11
+ ],
12
+ "properties": {
13
+ "event": {
14
+ "type": "string",
15
+ "description": "The name of the event."
16
+ },
17
+ "ecommerce": {
18
+ "type": "object",
19
+ "description": "Ecommerce related data.",
20
+ "x-gtm-clear": true
21
+ },
22
+ "user_data": {
23
+ "type": "object",
24
+ "description": "User related data.",
25
+ "x-gtm-clear": true
26
+ }
27
+ },
28
+ "required": ["event"],
29
+ "$defs": {
30
+ "strictObject": {
31
+ "type": "object",
32
+ "propertyNames": {
33
+ "maxLength": 40,
34
+ "pattern": "^[a-z0-9_]+$"
35
+ },
36
+ "additionalProperties": {
37
+ "anyOf": [
38
+ {
39
+ "$ref": "#/$defs/strictObject"
40
+ },
41
+ {
42
+ "type": "array",
43
+ "items": {
44
+ "$ref": "#/$defs/strictObject"
45
+ }
46
+ },
47
+ {
48
+ "not": {
49
+ "type": "object"
50
+ }
51
+ }
52
+ ]
53
+ }
54
+ }
55
+ }
56
+ }
@@ -0,0 +1,125 @@
1
+ {
2
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3
+ "$id": "https://tracking-docs-demo.buchert.digital/schemas/components/product.json",
4
+ "title": "A Product",
5
+ "description": "A product object representing an item for use within a purchase event, based on Google Analytics 4 ecommerce event specifications.",
6
+ "type": "object",
7
+ "properties": {
8
+ "item_id": {
9
+ "type": "string",
10
+ "description": "The ID of the item. Either item_id or item_name is required.",
11
+ "examples": ["SKU_12345", "PROD_98765"]
12
+ },
13
+ "item_name": {
14
+ "type": "string",
15
+ "description": "The name of the item. Either item_id or item_name is required.",
16
+ "examples": ["Stan and Friends Tee", "Blue Running Shoes"]
17
+ },
18
+ "affiliation": {
19
+ "type": "string",
20
+ "description": "A product affiliation to indicate a supplier or store. Note: affiliation is only available at the item level.",
21
+ "examples": ["Google Merchandise Store", "Nike Store"]
22
+ },
23
+ "coupon": {
24
+ "type": "string",
25
+ "description": "The coupon name/code associated with the item. Coupon parameters at event and item levels are independent.",
26
+ "examples": ["SUMMER_FUN", "WELCOME20", "SAVE10"]
27
+ },
28
+ "discount": {
29
+ "type": "number",
30
+ "description": "The monetary value of the discount per unit applied to the item.",
31
+ "examples": [2.22, 5.0, 10.5]
32
+ },
33
+ "index": {
34
+ "type": "number",
35
+ "description": "The index or position of the item in a list.",
36
+ "examples": [0, 1, 2]
37
+ },
38
+ "item_brand": {
39
+ "type": "string",
40
+ "description": "The brand of the item.",
41
+ "examples": ["Google", "Nike", "Adidas"]
42
+ },
43
+ "item_category": {
44
+ "type": "string",
45
+ "description": "The category of the item. If used as part of a category hierarchy or taxonomy, this is the first category.",
46
+ "examples": ["Apparel", "Footwear", "Electronics"]
47
+ },
48
+ "item_category2": {
49
+ "type": "string",
50
+ "description": "The second category hierarchy or additional taxonomy of the item.",
51
+ "examples": ["Adult", "Women", "Men"]
52
+ },
53
+ "item_category3": {
54
+ "type": "string",
55
+ "description": "The third category hierarchy or additional taxonomy of the item.",
56
+ "examples": ["Shirts", "Shoes", "Boots"]
57
+ },
58
+ "item_category4": {
59
+ "type": "string",
60
+ "description": "The fourth category hierarchy or additional taxonomy of the item.",
61
+ "examples": ["Crew", "Running", "Casual"]
62
+ },
63
+ "item_category5": {
64
+ "type": "string",
65
+ "description": "The fifth category hierarchy or additional taxonomy of the item.",
66
+ "examples": ["Short sleeve", "Long distance", "Lightweight"]
67
+ },
68
+ "item_list_id": {
69
+ "type": "string",
70
+ "description": "The ID of the list in which the item was presented to the user. If set, item_list_id at the event level is ignored. If not set, item_list_id at the event level is used if available.",
71
+ "examples": ["related_products", "search_results", "recommendations"]
72
+ },
73
+ "item_list_name": {
74
+ "type": "string",
75
+ "description": "The name of the list in which the item was presented to the user. If set, item_list_name at the event level is ignored. If not set, item_list_name at the event level is used if available.",
76
+ "examples": ["Related Products", "Search Results", "Recommended Items"]
77
+ },
78
+ "item_variant": {
79
+ "type": "string",
80
+ "description": "The item variant or unique code or description for additional item details/options.",
81
+ "examples": ["green", "Blue Size 10", "M-Black"]
82
+ },
83
+ "location_id": {
84
+ "type": "string",
85
+ "description": "The physical location associated with the item, such as the location of a brick-and-mortar store. It is recommended to use the Google Place ID that corresponds to the associated item. A custom location ID can also be used. Note: location_id is only available at the item level.",
86
+ "examples": ["ChIJIQBpAG2ahYAR_6128GcTUEo", "store_123", "location_sf"]
87
+ },
88
+ "price": {
89
+ "type": "number",
90
+ "description": "The price of the item in the specified currency unit. If a discount is applied to the item, set price to the reduced per-unit price and provide the per-unit price discount in the discount parameter.",
91
+ "examples": [10.01, 21.01, 89.99]
92
+ },
93
+ "quantity": {
94
+ "type": "number",
95
+ "description": "The item quantity. If not set, quantity is set to 1.",
96
+ "examples": [1, 2, 3]
97
+ },
98
+ "promotion_id": {
99
+ "type": "string",
100
+ "description": "The ID of the promotion associated with the item.",
101
+ "examples": ["P_12345", "PROMO_001"]
102
+ },
103
+ "promotion_name": {
104
+ "type": "string",
105
+ "description": "The name of the promotion associated with the item.",
106
+ "examples": ["Summer Sale", "Black Friday", "Flash Deal"]
107
+ },
108
+ "creative_name": {
109
+ "type": "string",
110
+ "description": "The name of the promotion creative.",
111
+ "examples": ["summer_banner2", "holiday_email_v1"]
112
+ },
113
+ "creative_slot": {
114
+ "type": "string",
115
+ "description": "The name of the creative slot associated with the item.",
116
+ "examples": ["featured_app_1", "top_banner", "sidebar"]
117
+ },
118
+ "google_business_vertical": {
119
+ "type": "string",
120
+ "description": "The business vertical for the item (e.g., 'retail').",
121
+ "examples": ["retail", "ecommerce"]
122
+ }
123
+ },
124
+ "required": []
125
+ }
@@ -0,0 +1,44 @@
1
+ {
2
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3
+ "$id": "https://tracking-docs-demo.buchert.digital/schemas/add-to-cart-event.json",
4
+ "title": "Add to Cart Event",
5
+ "description": "An add_to_cart event fires when a user adds one or more items to their shopping cart. Based on Google Analytics 4 ecommerce event specifications.",
6
+ "type": "object",
7
+ "allOf": [
8
+ {
9
+ "$ref": "./components/dataLayer.json"
10
+ }
11
+ ],
12
+ "properties": {
13
+ "event": {
14
+ "type": "string",
15
+ "const": "add_to_cart",
16
+ "description": "The name of the event indicating a add_to_cart has occurred."
17
+ },
18
+ "ecommerce": {
19
+ "type": "object",
20
+ "description": "Ecommerce related data for the purchase event.",
21
+ "properties": {
22
+ "value": {
23
+ "type": "number",
24
+ "description": "The monetary value of the event. Set value to the sum of (price * quantity) for all items in items.",
25
+ "examples": [30.03, 99.99, 45.5]
26
+ },
27
+ "currency": {
28
+ "type": "string",
29
+ "description": "The currency of the items in ISO 4217 three-letter format. Required when value is set.",
30
+ "examples": ["USD", "EUR", "GBP"]
31
+ },
32
+ "items": {
33
+ "type": "array",
34
+ "description": "The products added to the cart.",
35
+ "minItems": 1,
36
+ "items": {
37
+ "$ref": "./components/product.json"
38
+ }
39
+ }
40
+ },
41
+ "required": ["currency", "items"]
42
+ }
43
+ }
44
+ }
@@ -0,0 +1,56 @@
1
+ {
2
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3
+ "$id": "https://tracking-docs-demo.buchert.digital/schemas/components/dataLayer.json",
4
+ "title": "dataLayer",
5
+ "description": "Schema for the object structure pushed to the dataLayer.",
6
+ "type": "object",
7
+ "allOf": [
8
+ {
9
+ "$ref": "#/$defs/strictObject"
10
+ }
11
+ ],
12
+ "properties": {
13
+ "event": {
14
+ "type": "string",
15
+ "description": "The name of the event."
16
+ },
17
+ "ecommerce": {
18
+ "type": "object",
19
+ "description": "Ecommerce related data.",
20
+ "x-gtm-clear": true
21
+ },
22
+ "user_data": {
23
+ "type": "object",
24
+ "description": "User related data.",
25
+ "x-gtm-clear": true
26
+ }
27
+ },
28
+ "required": ["event"],
29
+ "$defs": {
30
+ "strictObject": {
31
+ "type": "object",
32
+ "propertyNames": {
33
+ "maxLength": 40,
34
+ "pattern": "^[a-z0-9_]+$"
35
+ },
36
+ "additionalProperties": {
37
+ "anyOf": [
38
+ {
39
+ "$ref": "#/$defs/strictObject"
40
+ },
41
+ {
42
+ "type": "array",
43
+ "items": {
44
+ "$ref": "#/$defs/strictObject"
45
+ }
46
+ },
47
+ {
48
+ "not": {
49
+ "type": "object"
50
+ }
51
+ }
52
+ ]
53
+ }
54
+ }
55
+ }
56
+ }
@@ -0,0 +1,125 @@
1
+ {
2
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3
+ "$id": "https://tracking-docs-demo.buchert.digital/schemas/components/product.json",
4
+ "title": "A Product",
5
+ "description": "A product object representing an item for use within a purchase event, based on Google Analytics 4 ecommerce event specifications.",
6
+ "type": "object",
7
+ "properties": {
8
+ "item_id": {
9
+ "type": "string",
10
+ "description": "The ID of the item. Either item_id or item_name is required.",
11
+ "examples": ["SKU_12345", "PROD_98765"]
12
+ },
13
+ "item_name": {
14
+ "type": "string",
15
+ "description": "The name of the item. Either item_id or item_name is required.",
16
+ "examples": ["Stan and Friends Tee", "Blue Running Shoes"]
17
+ },
18
+ "affiliation": {
19
+ "type": "string",
20
+ "description": "A product affiliation to indicate a supplier or store. Note: affiliation is only available at the item level.",
21
+ "examples": ["Google Merchandise Store", "Nike Store"]
22
+ },
23
+ "coupon": {
24
+ "type": "string",
25
+ "description": "The coupon name/code associated with the item. Coupon parameters at event and item levels are independent.",
26
+ "examples": ["SUMMER_FUN", "WELCOME20", "SAVE10"]
27
+ },
28
+ "discount": {
29
+ "type": "number",
30
+ "description": "The monetary value of the discount per unit applied to the item.",
31
+ "examples": [2.22, 5.0, 10.5]
32
+ },
33
+ "index": {
34
+ "type": "number",
35
+ "description": "The index or position of the item in a list.",
36
+ "examples": [0, 1, 2]
37
+ },
38
+ "item_brand": {
39
+ "type": "string",
40
+ "description": "The brand of the item.",
41
+ "examples": ["Google", "Nike", "Adidas"]
42
+ },
43
+ "item_category": {
44
+ "type": "string",
45
+ "description": "The category of the item. If used as part of a category hierarchy or taxonomy, this is the first category.",
46
+ "examples": ["Apparel", "Footwear", "Electronics"]
47
+ },
48
+ "item_category2": {
49
+ "type": "string",
50
+ "description": "The second category hierarchy or additional taxonomy of the item.",
51
+ "examples": ["Adult", "Women", "Men"]
52
+ },
53
+ "item_category3": {
54
+ "type": "string",
55
+ "description": "The third category hierarchy or additional taxonomy of the item.",
56
+ "examples": ["Shirts", "Shoes", "Boots"]
57
+ },
58
+ "item_category4": {
59
+ "type": "string",
60
+ "description": "The fourth category hierarchy or additional taxonomy of the item.",
61
+ "examples": ["Crew", "Running", "Casual"]
62
+ },
63
+ "item_category5": {
64
+ "type": "string",
65
+ "description": "The fifth category hierarchy or additional taxonomy of the item.",
66
+ "examples": ["Short sleeve", "Long distance", "Lightweight"]
67
+ },
68
+ "item_list_id": {
69
+ "type": "string",
70
+ "description": "The ID of the list in which the item was presented to the user. If set, item_list_id at the event level is ignored. If not set, item_list_id at the event level is used if available.",
71
+ "examples": ["related_products", "search_results", "recommendations"]
72
+ },
73
+ "item_list_name": {
74
+ "type": "string",
75
+ "description": "The name of the list in which the item was presented to the user. If set, item_list_name at the event level is ignored. If not set, item_list_name at the event level is used if available.",
76
+ "examples": ["Related Products", "Search Results", "Recommended Items"]
77
+ },
78
+ "item_variant": {
79
+ "type": "string",
80
+ "description": "The item variant or unique code or description for additional item details/options.",
81
+ "examples": ["green", "Blue Size 10", "M-Black"]
82
+ },
83
+ "location_id": {
84
+ "type": "string",
85
+ "description": "The physical location associated with the item, such as the location of a brick-and-mortar store. It is recommended to use the Google Place ID that corresponds to the associated item. A custom location ID can also be used. Note: location_id is only available at the item level.",
86
+ "examples": ["ChIJIQBpAG2ahYAR_6128GcTUEo", "store_123", "location_sf"]
87
+ },
88
+ "price": {
89
+ "type": "number",
90
+ "description": "The price of the item in the specified currency unit. If a discount is applied to the item, set price to the reduced per-unit price and provide the per-unit price discount in the discount parameter.",
91
+ "examples": [10.01, 21.01, 89.99]
92
+ },
93
+ "quantity": {
94
+ "type": "number",
95
+ "description": "The item quantity. If not set, quantity is set to 1.",
96
+ "examples": [1, 2, 3]
97
+ },
98
+ "promotion_id": {
99
+ "type": "string",
100
+ "description": "The ID of the promotion associated with the item.",
101
+ "examples": ["P_12345", "PROMO_001"]
102
+ },
103
+ "promotion_name": {
104
+ "type": "string",
105
+ "description": "The name of the promotion associated with the item.",
106
+ "examples": ["Summer Sale", "Black Friday", "Flash Deal"]
107
+ },
108
+ "creative_name": {
109
+ "type": "string",
110
+ "description": "The name of the promotion creative.",
111
+ "examples": ["summer_banner2", "holiday_email_v1"]
112
+ },
113
+ "creative_slot": {
114
+ "type": "string",
115
+ "description": "The name of the creative slot associated with the item.",
116
+ "examples": ["featured_app_1", "top_banner", "sidebar"]
117
+ },
118
+ "google_business_vertical": {
119
+ "type": "string",
120
+ "description": "The business vertical for the item (e.g., 'retail').",
121
+ "examples": ["retail", "ecommerce"]
122
+ }
123
+ },
124
+ "required": []
125
+ }
@@ -0,0 +1 @@
1
+ ["1.1.1"]
@@ -0,0 +1,117 @@
1
+ // Jest Snapshot v1, https://jestjs.io/docs/snapshot-testing
2
+
3
+ exports[`ExampleDataLayer should render a single example for a simple schema 1`] = `
4
+ <div>
5
+ <pre
6
+ data-language="javascript"
7
+ >
8
+ window.dataLayer.push({
9
+ "event": "test_event"
10
+ });
11
+ </pre>
12
+ </div>
13
+ `;
14
+
15
+ exports[`ExampleDataLayer should render grouped tabs for a schema with choices 1`] = `
16
+ <div>
17
+ <div
18
+ style="margin-top: 20px;"
19
+ >
20
+ <h4>
21
+ <code>
22
+ user_id
23
+ </code>
24
+ options:
25
+ </h4>
26
+ <div
27
+ data-testid="tabs"
28
+ >
29
+ <div
30
+ data-label="User ID as String"
31
+ data-testid="tab-item"
32
+ >
33
+ <pre
34
+ data-language="javascript"
35
+ >
36
+ window.dataLayer.push({
37
+ "event": "one_of_event",
38
+ "user_id": "user-123",
39
+ "payment_method": {
40
+ "payment_type": "credit_card",
41
+ "card_number": "1234-5678-9012-3456",
42
+ "expiry_date": "12/26"
43
+ }
44
+ });
45
+ </pre>
46
+ </div>
47
+ <div
48
+ data-label="User ID as Integer"
49
+ data-testid="tab-item"
50
+ >
51
+ <pre
52
+ data-language="javascript"
53
+ >
54
+ window.dataLayer.push({
55
+ "event": "one_of_event",
56
+ "user_id": 123,
57
+ "payment_method": {
58
+ "payment_type": "credit_card",
59
+ "card_number": "1234-5678-9012-3456",
60
+ "expiry_date": "12/26"
61
+ }
62
+ });
63
+ </pre>
64
+ </div>
65
+ </div>
66
+ </div>
67
+ <div
68
+ style="margin-top: 20px;"
69
+ >
70
+ <h4>
71
+ <code>
72
+ payment_method
73
+ </code>
74
+ options:
75
+ </h4>
76
+ <div
77
+ data-testid="tabs"
78
+ >
79
+ <div
80
+ data-label="Credit Card"
81
+ data-testid="tab-item"
82
+ >
83
+ <pre
84
+ data-language="javascript"
85
+ >
86
+ window.dataLayer.push({
87
+ "event": "one_of_event",
88
+ "user_id": "user-123",
89
+ "payment_method": {
90
+ "payment_type": "credit_card",
91
+ "card_number": "1234-5678-9012-3456",
92
+ "expiry_date": "12/26"
93
+ }
94
+ });
95
+ </pre>
96
+ </div>
97
+ <div
98
+ data-label="PayPal"
99
+ data-testid="tab-item"
100
+ >
101
+ <pre
102
+ data-language="javascript"
103
+ >
104
+ window.dataLayer.push({
105
+ "event": "one_of_event",
106
+ "user_id": "user-123",
107
+ "payment_method": {
108
+ "payment_type": "paypal",
109
+ "email": "test@example.com"
110
+ }
111
+ });
112
+ </pre>
113
+ </div>
114
+ </div>
115
+ </div>
116
+ </div>
117
+ `;
@@ -0,0 +1,79 @@
1
+ // Jest Snapshot v1, https://jestjs.io/docs/snapshot-testing
2
+
3
+ exports[`generateEventDocs (oneOf with $anchor) should generate documentation using $anchor for slug 1`] = `
4
+ "---
5
+ title: Parent Event Anchor
6
+ description: "This is a parent event with oneOf."
7
+ ---
8
+ import SchemaJsonViewer from '@theme/SchemaJsonViewer';
9
+
10
+ # Parent Event Anchor
11
+
12
+ This is a parent event with oneOf.
13
+
14
+ Please select one of the following options:
15
+
16
+ - [Child Event Anchor](./child-event-with-anchor)
17
+ - [Child Event Title](./child-event-title)
18
+
19
+ <SchemaJsonViewer schema={{"$id":"https://example.com/parent-event-anchor.json","title":"Parent Event Anchor","description":"This is a parent event with oneOf.","type":"object","oneOf":[{"title":"Child Event Anchor","description":"This is a child event with an anchor.","$anchor":"child-event-with-anchor","type":"object","properties":{"property_a":{"type":"string"}}},{"title":"Child Event Title","description":"This is a child event with only a title.","type":"object","properties":{"property_b":{"type":"string"}}}]}} />
20
+ "
21
+ `;
22
+
23
+ exports[`generateEventDocs (oneOf with $anchor) should generate documentation using $anchor for slug 2`] = `
24
+ "---
25
+ title: Child Event Anchor
26
+ description: "This is a child event with an anchor."
27
+ sidebar_label: Child Event Anchor
28
+ custom_edit_url: https://github.com/test-org/test-project/edit/main/__fixtures_anchor__/docs/parent-event-anchor/01-child-event-with-anchor.json
29
+ ---
30
+
31
+ import SchemaViewer from '@theme/SchemaViewer';
32
+ import SchemaJsonViewer from '@theme/SchemaJsonViewer';
33
+
34
+
35
+
36
+ # Child Event Anchor
37
+
38
+ This is a child event with an anchor.
39
+
40
+
41
+
42
+ <SchemaViewer
43
+ schema={{"$id":"https://example.com/parent-event-anchor.json#child-event-with-anchor","title":"Child Event Anchor","description":"This is a child event with an anchor.","type":"object","$anchor":"child-event-with-anchor","properties":{"property_a":{"type":"string"}}}}
44
+
45
+ />
46
+ <SchemaJsonViewer schema={{"$id":"https://example.com/parent-event-anchor.json#child-event-with-anchor","title":"Child Event Anchor","description":"This is a child event with an anchor.","type":"object","$anchor":"child-event-with-anchor","properties":{"property_a":{"type":"string"}}}} />
47
+
48
+
49
+ "
50
+ `;
51
+
52
+ exports[`generateEventDocs (oneOf with $anchor) should generate documentation using $anchor for slug 3`] = `
53
+ "---
54
+ title: Child Event Title
55
+ description: "This is a child event with only a title."
56
+ sidebar_label: Child Event Title
57
+ custom_edit_url: https://github.com/test-org/test-project/edit/main/__fixtures_anchor__/docs/parent-event-anchor/02-child-event-title.json
58
+ ---
59
+
60
+ import SchemaViewer from '@theme/SchemaViewer';
61
+ import SchemaJsonViewer from '@theme/SchemaJsonViewer';
62
+
63
+
64
+
65
+ # Child Event Title
66
+
67
+ This is a child event with only a title.
68
+
69
+
70
+
71
+ <SchemaViewer
72
+ schema={{"$id":"https://example.com/parent-event-anchor.json#child-event-title","title":"Child Event Title","description":"This is a child event with only a title.","type":"object","properties":{"property_b":{"type":"string"}}}}
73
+
74
+ />
75
+ <SchemaJsonViewer schema={{"$id":"https://example.com/parent-event-anchor.json#child-event-title","title":"Child Event Title","description":"This is a child event with only a title.","type":"object","properties":{"property_b":{"type":"string"}}}} />
76
+
77
+
78
+ "
79
+ `;