docusaurus-plugin-generate-schema-docs 1.4.0 → 1.5.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.
@@ -0,0 +1,45 @@
1
+ {
2
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3
+ "$id": "events/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
+ "properties": {
8
+ "$schema": {
9
+ "description": "Defines the structure of the event. This can be used to validate an event against the schema provided.",
10
+ "const": "events/add-to-cart-event.json",
11
+ "type": "string"
12
+ },
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
+ "required": ["$schema", "event"]
45
+ }
@@ -0,0 +1,78 @@
1
+ {
2
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3
+ "$id": "events/choice-event.json",
4
+ "title": "Choice Event",
5
+ "description": "An example event that uses oneOf and anyOf.",
6
+ "type": "object",
7
+ "properties": {
8
+ "$schema": {
9
+ "type": "string",
10
+ "description": "Defines the structure of the event. This can be used to validate an event against the schema provided.",
11
+ "const": "events/choice-event.json"
12
+ },
13
+ "event": {
14
+ "type": "string",
15
+ "const": "one_of_event"
16
+ },
17
+ "user_id": {
18
+ "description": "The user's ID.",
19
+ "oneOf": [
20
+ {
21
+ "type": "string",
22
+ "title": "User ID as String",
23
+ "description": "The user's ID as a string.",
24
+ "examples": ["user-123"]
25
+ },
26
+ {
27
+ "type": "integer",
28
+ "title": "User ID as Integer",
29
+ "description": "The user's ID as an integer.",
30
+ "examples": [123]
31
+ }
32
+ ]
33
+ },
34
+ "payment_method": {
35
+ "description": "The user's payment method.",
36
+ "type": "object",
37
+ "anyOf": [
38
+ {
39
+ "title": "Credit Card",
40
+ "type": "object",
41
+ "properties": {
42
+ "payment_type": {
43
+ "type": "string",
44
+ "enum": ["credit_card", "debit_card"],
45
+ "examples": ["credit_card"]
46
+ },
47
+ "card_number": {
48
+ "type": "string",
49
+ "examples": ["1234-5678-9012-3456"]
50
+ },
51
+ "expiry_date": {
52
+ "type": "string",
53
+ "examples": ["12/26"]
54
+ }
55
+ },
56
+ "required": ["card_number", "expiry_date"]
57
+ },
58
+ {
59
+ "title": "PayPal",
60
+ "type": "object",
61
+ "properties": {
62
+ "payment_type": {
63
+ "type": "string",
64
+ "const": "paypal"
65
+ },
66
+ "email": {
67
+ "type": "string",
68
+ "format": "email",
69
+ "examples": ["test@example.com"]
70
+ }
71
+ },
72
+ "required": ["email"]
73
+ }
74
+ ]
75
+ }
76
+ },
77
+ "required": ["event", "user_id", "payment_method"]
78
+ }
@@ -0,0 +1,193 @@
1
+ {
2
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3
+ "$id": "events/complex-event.json",
4
+ "title": "Complex Event with Validation Constraints",
5
+ "description": "A generic event demonstrating various validation constraints and recursive documentation capabilities.",
6
+ "type": "object",
7
+ "required": [
8
+ "$schema",
9
+ "event",
10
+ "number_constraints",
11
+ "string_constraints",
12
+ "user_data"
13
+ ],
14
+ "properties": {
15
+ "$schema": {
16
+ "type": "string",
17
+ "description": "Defines the structure of the event. This can be used to validate an event against the schema provided.",
18
+ "const": "events/complex-event.json"
19
+ },
20
+ "event": {
21
+ "type": "string",
22
+ "const": "user_update",
23
+ "description": "The event name.",
24
+ "examples": ["user_update"]
25
+ },
26
+ "timestamp": {
27
+ "type": "integer",
28
+ "description": "Unix timestamp of the event.",
29
+ "examples": [16788922]
30
+ },
31
+ "user_data": {
32
+ "type": "object",
33
+ "description": "Container for user information.",
34
+ "required": ["user_id", "attributes"],
35
+ "properties": {
36
+ "user_id": {
37
+ "type": "string",
38
+ "description": "Unique User ID.",
39
+ "examples": ["U_999"]
40
+ },
41
+ "is_active": {
42
+ "type": "boolean",
43
+ "description": "Status of the user.",
44
+ "examples": [true]
45
+ },
46
+ "attributes": {
47
+ "type": "object",
48
+ "description": "Nested generic attributes.",
49
+ "properties": {
50
+ "segment": {
51
+ "type": "string",
52
+ "description": "Marketing segment.",
53
+ "examples": ["premium"]
54
+ },
55
+ "score": {
56
+ "type": "number",
57
+ "description": "Engagement score.",
58
+ "examples": [95]
59
+ }
60
+ }
61
+ },
62
+ "addresses": {
63
+ "type": "array",
64
+ "description": "List of user addresses.",
65
+ "items": {
66
+ "type": "object",
67
+ "required": ["city", "zip"],
68
+ "properties": {
69
+ "street": {
70
+ "type": "string",
71
+ "examples": ["123 Main St"]
72
+ },
73
+ "city": {
74
+ "type": "string",
75
+ "examples": ["New York"]
76
+ },
77
+ "zip": {
78
+ "type": "string",
79
+ "examples": ["10001"]
80
+ }
81
+ }
82
+ }
83
+ }
84
+ }
85
+ },
86
+ "string_constraints": {
87
+ "type": "string",
88
+ "description": "A string with various constraints.",
89
+ "minLength": 2,
90
+ "maxLength": 10,
91
+ "pattern": "^[a-z]+$",
92
+ "format": "hostname",
93
+ "examples": ["example"]
94
+ },
95
+ "number_constraints": {
96
+ "type": "number",
97
+ "description": "A number with various constraints.",
98
+ "minimum": 10,
99
+ "maximum": 100,
100
+ "multipleOf": 5,
101
+ "examples": [50]
102
+ },
103
+ "exclusive_number_constraints": {
104
+ "type": "number",
105
+ "description": "A number with exclusive constraints.",
106
+ "exclusiveMinimum": 10,
107
+ "exclusiveMaximum": 100,
108
+ "examples": [50]
109
+ },
110
+ "array_constraints": {
111
+ "type": "array",
112
+ "description": "An array with various constraints.",
113
+ "minItems": 1,
114
+ "maxItems": 5,
115
+ "uniqueItems": true,
116
+ "items": {
117
+ "type": "string"
118
+ },
119
+ "examples": [["a", "b"]]
120
+ },
121
+ "contains_array_constraints": {
122
+ "type": "array",
123
+ "description": "An array with contains constraints.",
124
+ "contains": {
125
+ "type": "integer"
126
+ },
127
+ "minContains": 1,
128
+ "maxContains": 2,
129
+ "examples": [[1, "text", 2]]
130
+ },
131
+ "object_constraints": {
132
+ "type": "object",
133
+ "description": "An object with various constraints.",
134
+ "minProperties": 1,
135
+ "maxProperties": 3,
136
+ "additionalProperties": false,
137
+ "propertyNames": {
138
+ "pattern": "^[a-z0-9_]+$"
139
+ },
140
+ "properties": {
141
+ "prop_a": {
142
+ "type": "string",
143
+ "examples": ["some_value"]
144
+ },
145
+ "prop_b": {
146
+ "type": "string",
147
+ "examples": ["another_value"]
148
+ }
149
+ },
150
+ "examples": [
151
+ {
152
+ "prop_a": "some_value",
153
+ "prop_b": "another_value"
154
+ }
155
+ ]
156
+ },
157
+ "dependent_required_constraint": {
158
+ "type": "object",
159
+ "description": "An object with dependent required properties.",
160
+ "dependentRequired": {
161
+ "credit_card": ["billing_address"]
162
+ },
163
+ "properties": {
164
+ "credit_card": {
165
+ "type": "number",
166
+ "examples": [1234567890123456]
167
+ },
168
+ "billing_address": {
169
+ "type": "string",
170
+ "examples": ["123 Billing Address, Anytown, USA"]
171
+ }
172
+ },
173
+ "examples": [
174
+ {
175
+ "credit_card": 1234567890123456,
176
+ "billing_address": "123 Billing Address, Anytown, USA"
177
+ }
178
+ ]
179
+ },
180
+ "enum_constraint": {
181
+ "type": "string",
182
+ "description": "A property with an enum constraint.",
183
+ "enum": ["admin", "editor", "viewer"],
184
+ "examples": ["admin"]
185
+ },
186
+ "const_constraint": {
187
+ "type": "string",
188
+ "description": "A property that must have a constant value.",
189
+ "const": "must_be_this",
190
+ "examples": ["must_be_this"]
191
+ }
192
+ }
193
+ }
@@ -0,0 +1,56 @@
1
+ {
2
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3
+ "$id": "events/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": "^(\\$schema)|[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,126 @@
1
+ {
2
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3
+ "$id": "events/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, 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
+ "default": 1
98
+ },
99
+ "promotion_id": {
100
+ "type": "string",
101
+ "description": "The ID of the promotion associated with the item.",
102
+ "examples": ["P_12345", "PROMO_001"]
103
+ },
104
+ "promotion_name": {
105
+ "type": "string",
106
+ "description": "The name of the promotion associated with the item.",
107
+ "examples": ["Summer Sale", "Black Friday", "Flash Deal"]
108
+ },
109
+ "creative_name": {
110
+ "type": "string",
111
+ "description": "The name of the promotion creative.",
112
+ "examples": ["summer_banner2", "holiday_email_v1"]
113
+ },
114
+ "creative_slot": {
115
+ "type": "string",
116
+ "description": "The name of the creative slot associated with the item.",
117
+ "examples": ["featured_app_1", "top_banner", "sidebar"]
118
+ },
119
+ "google_business_vertical": {
120
+ "type": "string",
121
+ "description": "The business vertical for the item (e.g., 'retail').",
122
+ "examples": ["retail", "ecommerce"]
123
+ }
124
+ },
125
+ "required": []
126
+ }
@@ -0,0 +1,73 @@
1
+ {
2
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3
+ "$id": "events/purchase-event.json",
4
+ "title": "Purchase Event",
5
+ "description": "A purchase event fires when a user completes a purchase. Based on Google Analytics 4 ecommerce event specifications.",
6
+ "type": "object",
7
+ "properties": {
8
+ "$schema": {
9
+ "type": "string",
10
+ "description": "Defines the structure of the event. This can be used to validate an event against the schema provided.",
11
+ "const": "events/purchase-event.json"
12
+ },
13
+ "event": {
14
+ "type": "string",
15
+ "const": "purchase",
16
+ "description": "The name of the event indicating a purchase has occurred."
17
+ },
18
+ "ecommerce": {
19
+ "type": "object",
20
+ "description": "Ecommerce related data for the purchase event.",
21
+ "properties": {
22
+ "transaction_id": {
23
+ "type": "string",
24
+ "description": "The unique ID of a transaction. The transaction_id parameter helps avoid duplicate transaction recording.",
25
+ "examples": ["T_12345", "TXN_20231205_001"]
26
+ },
27
+ "value": {
28
+ "type": "number",
29
+ "description": "The monetary value of the event. Set value to the sum of (price * quantity) for all items in items.",
30
+ "examples": [72.05, 99.99, 150.5]
31
+ },
32
+ "currency": {
33
+ "type": "string",
34
+ "description": "The currency of the items in ISO 4217 three-letter format. Required when value is set.",
35
+ "minLength": 3,
36
+ "maxLength": 3,
37
+ "examples": ["USD", "EUR", "GBP"]
38
+ },
39
+ "coupon": {
40
+ "type": "string",
41
+ "description": "The coupon/code associated with the event. Event-level and item-level coupon parameters are independent.",
42
+ "examples": ["SUMMER_SALE", "WELCOME15"]
43
+ },
44
+ "shipping": {
45
+ "type": "number",
46
+ "description": "The shipping cost associated with the transaction.",
47
+ "examples": [5.99, 10, 0]
48
+ },
49
+ "tax": {
50
+ "type": "number",
51
+ "description": "The tax associated with the transaction.",
52
+ "examples": [3.6, 7.5, 0]
53
+ },
54
+ "customer_type": {
55
+ "type": "string",
56
+ "enum": ["new", "returning"],
57
+ "description": "Whether this is from a new or returning customer. 'new' = customer with no purchase in the specified time window (default 540 days). 'returning' = customer with purchase in the specified time window.",
58
+ "examples": ["new", "returning"]
59
+ },
60
+ "items": {
61
+ "type": "array",
62
+ "description": "The products purchased in the transaction.",
63
+ "minItems": 1,
64
+ "items": {
65
+ "$ref": "./components/product.json"
66
+ }
67
+ }
68
+ },
69
+ "required": ["transaction_id", "value", "currency", "items"]
70
+ }
71
+ },
72
+ "required": ["$schema", "event"]
73
+ }
@@ -0,0 +1,40 @@
1
+ {
2
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3
+ "$id": "events/root-any-of-event.json",
4
+ "title": "Root AnyOf Event",
5
+ "description": "An example event that has anyOf at the root level.",
6
+ "type": "object",
7
+ "properties": {
8
+ "$schema": {
9
+ "type": "string",
10
+ "description": "Defines the structure of the event. This can be used to validate an event against the schema provided.",
11
+ "const": "events/root-any-of-event.json"
12
+ },
13
+ "event": {
14
+ "type": "string",
15
+ "const": "any_of_event"
16
+ }
17
+ },
18
+ "required": ["$schema", "event"],
19
+ "anyOf": [
20
+ {
21
+ "title": "Has Param C",
22
+ "description": "This is the description for Param C.",
23
+ "properties": {
24
+ "param_c": {
25
+ "type": "string",
26
+ "examples": ["example_c"]
27
+ }
28
+ }
29
+ },
30
+ {
31
+ "title": "Has Param D",
32
+ "properties": {
33
+ "param_d": {
34
+ "type": "boolean",
35
+ "examples": [true]
36
+ }
37
+ }
38
+ }
39
+ ]
40
+ }
@@ -0,0 +1,54 @@
1
+ {
2
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3
+ "$id": "events/root-choice-event.json",
4
+ "title": "Root Choice Event",
5
+ "description": "An example event that has oneOf at the root level.",
6
+ "allOf": [
7
+ {
8
+ "type": "object",
9
+ "properties": {
10
+ "$schema": {
11
+ "type": "string",
12
+ "description": "Defines the structure of the event. This can be used to validate an event against the schema provided.",
13
+ "const": "events/root-choice-event.json"
14
+ }
15
+ },
16
+ "required": ["$schema"]
17
+ },
18
+ {
19
+ "oneOf": [
20
+ {
21
+ "title": "Option A",
22
+ "$anchor": "option_a",
23
+ "description": "This is the description for Param A.",
24
+ "type": "object",
25
+ "properties": {
26
+ "event": {
27
+ "type": "string",
28
+ "const": "option_a"
29
+ },
30
+ "param_a": {
31
+ "type": "string",
32
+ "examples": ["example_a"]
33
+ }
34
+ }
35
+ },
36
+ {
37
+ "title": "Option B",
38
+ "$anchor": "option_b",
39
+ "type": "object",
40
+ "properties": {
41
+ "event": {
42
+ "type": "string",
43
+ "const": "option_b"
44
+ },
45
+ "param_b": {
46
+ "type": "integer",
47
+ "examples": [123]
48
+ }
49
+ }
50
+ }
51
+ ]
52
+ }
53
+ ]
54
+ }