docusaurus-plugin-generate-schema-docs 1.1.1 → 1.3.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.
- package/README.md +60 -2
- package/__tests__/ExampleDataLayer.test.js +92 -0
- package/__tests__/__fixtures__/static/schemas/add-to-cart-event.json +44 -0
- package/__tests__/__fixtures__/static/schemas/choice-event.json +72 -0
- package/__tests__/__fixtures__/static/schemas/components/dataLayer.json +56 -0
- package/__tests__/__fixtures__/static/schemas/components/product.json +125 -0
- package/__tests__/__fixtures__/static/schemas/nested/child-event.json +10 -0
- package/__tests__/__fixtures__/static/schemas/nested/grandchild-a.json +9 -0
- package/__tests__/__fixtures__/static/schemas/nested/grandchild-b.json +9 -0
- package/__tests__/__fixtures__/static/schemas/nested/parent-event.json +7 -0
- package/__tests__/__fixtures__/static/schemas/root-any-of-event.json +34 -0
- package/__tests__/__fixtures__/static/schemas/root-choice-event.json +36 -0
- package/__tests__/__fixtures__/validateSchemas/circular-schema.json +8 -0
- package/__tests__/__fixtures__/validateSchemas/components/referenced.json +10 -0
- package/__tests__/__fixtures__/validateSchemas/invalid-example-schema.json +8 -0
- package/__tests__/__fixtures__/validateSchemas/main-schema-with-missing-ref.json +8 -0
- package/__tests__/__fixtures__/validateSchemas/main-schema-with-ref.json +8 -0
- package/__tests__/__fixtures__/validateSchemas/no-example-schema.json +12 -0
- package/__tests__/__fixtures__/validateSchemas/schema-A.json +7 -0
- package/__tests__/__fixtures__/validateSchemas/schema-B.json +7 -0
- package/__tests__/__fixtures__/validateSchemas/valid-schema.json +8 -0
- package/__tests__/__fixtures_versioned__/static/schemas/1.1.1/add-to-cart-event.json +44 -0
- package/__tests__/__fixtures_versioned__/static/schemas/1.1.1/components/dataLayer.json +56 -0
- package/__tests__/__fixtures_versioned__/static/schemas/1.1.1/components/product.json +125 -0
- package/__tests__/__fixtures_versioned__/static/schemas/next/add-to-cart-event.json +44 -0
- package/__tests__/__fixtures_versioned__/static/schemas/next/components/dataLayer.json +56 -0
- package/__tests__/__fixtures_versioned__/static/schemas/next/components/product.json +125 -0
- package/__tests__/__fixtures_versioned__/versions.json +1 -0
- package/__tests__/__snapshots__/ExampleDataLayer.test.js.snap +117 -0
- package/__tests__/__snapshots__/generateEventDocs.nested.test.js.snap +92 -0
- package/__tests__/__snapshots__/generateEventDocs.test.js.snap +151 -0
- package/__tests__/__snapshots__/generateEventDocs.versioned.test.js.snap +53 -0
- package/__tests__/components/FoldableRows.test.js +330 -0
- package/__tests__/components/PropertiesTable.test.js +41 -0
- package/__tests__/components/PropertyRow.test.js +487 -0
- package/__tests__/components/SchemaJsonViewer.test.js +36 -0
- package/__tests__/components/SchemaRows.test.js +110 -0
- package/__tests__/components/SchemaViewer.test.js +44 -0
- package/__tests__/components/TableHeader.test.js +20 -0
- package/__tests__/generateEventDocs.nested.test.js +80 -0
- package/__tests__/generateEventDocs.test.js +90 -0
- package/__tests__/generateEventDocs.versioned.test.js +69 -0
- package/__tests__/helpers/buildExampleFromSchema.test.js +188 -0
- package/__tests__/helpers/file-system.test.js +44 -0
- package/__tests__/helpers/getConstraints.test.js +58 -0
- package/__tests__/helpers/loadSchema.test.js +20 -0
- package/__tests__/helpers/path-helpers.test.js +34 -0
- package/__tests__/helpers/processSchema.test.js +56 -0
- package/__tests__/helpers/schema-processing.test.js +82 -0
- package/__tests__/helpers/schemaToExamples.test.js +56 -0
- package/__tests__/helpers/schemaToTableData.filtering.test.js +65 -0
- package/__tests__/helpers/schemaToTableData.hierarchicalLines.test.js +539 -0
- package/__tests__/helpers/schemaToTableData.test.js +222 -0
- package/__tests__/helpers/update-schema-ids.test.js +107 -0
- package/__tests__/update-schema-ids.test.js +39 -0
- package/__tests__/validateSchemas.test.js +137 -0
- package/components/ExampleDataLayer.js +60 -27
- package/components/FoldableRows.js +164 -0
- package/components/PropertiesTable.js +12 -14
- package/components/PropertyRow.js +183 -0
- package/components/SchemaJsonViewer.js +8 -7
- package/components/SchemaRows.css +250 -0
- package/components/SchemaRows.js +24 -69
- package/components/SchemaViewer.js +21 -13
- package/components/TableHeader.js +15 -0
- package/generateEventDocs.js +141 -60
- package/helpers/buildExampleFromSchema.js +59 -73
- package/helpers/choice-index-template.js +22 -0
- package/helpers/file-system.js +32 -0
- package/helpers/getConstraints.js +52 -0
- package/helpers/loadSchema.js +11 -0
- package/helpers/path-helpers.js +22 -0
- package/helpers/processSchema.js +32 -0
- package/helpers/schema-doc-template.js +36 -0
- package/helpers/schema-processing.js +75 -0
- package/helpers/schemaToExamples.js +99 -0
- package/helpers/schemaToTableData.js +311 -0
- package/helpers/update-schema-ids.js +47 -0
- package/index.js +146 -47
- package/package.json +6 -3
- package/validateSchemas.js +56 -70
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
// Jest Snapshot v1, https://jestjs.io/docs/snapshot-testing
|
|
2
|
+
|
|
3
|
+
exports[`generateEventDocs (nested oneOf) should generate nested documentation correctly 1`] = `
|
|
4
|
+
"---
|
|
5
|
+
title: Parent Event
|
|
6
|
+
description: "undefined"
|
|
7
|
+
---
|
|
8
|
+
import SchemaJsonViewer from '@theme/SchemaJsonViewer';
|
|
9
|
+
|
|
10
|
+
# Parent Event
|
|
11
|
+
|
|
12
|
+
undefined
|
|
13
|
+
|
|
14
|
+
Please select one of the following options:
|
|
15
|
+
|
|
16
|
+
- [Child Event](./child-event)
|
|
17
|
+
|
|
18
|
+
<SchemaJsonViewer schema={{"$schema":"https://json-schema.org/draft/2020-12/schema","$id":"https://example.com/schemas/nested/parent-event.json","title":"Parent Event","type":"object","oneOf":[{"$ref":"./child-event.json"}]}} />
|
|
19
|
+
"
|
|
20
|
+
`;
|
|
21
|
+
|
|
22
|
+
exports[`generateEventDocs (nested oneOf) should generate nested documentation correctly 2`] = `
|
|
23
|
+
"---
|
|
24
|
+
title: Child Event
|
|
25
|
+
description: "undefined"
|
|
26
|
+
---
|
|
27
|
+
import SchemaJsonViewer from '@theme/SchemaJsonViewer';
|
|
28
|
+
|
|
29
|
+
# Child Event
|
|
30
|
+
|
|
31
|
+
undefined
|
|
32
|
+
|
|
33
|
+
Please select one of the following options:
|
|
34
|
+
|
|
35
|
+
- [Grandchild A](./grandchild-a)
|
|
36
|
+
- [Grandchild B](./grandchild-b)
|
|
37
|
+
|
|
38
|
+
<SchemaJsonViewer schema={{"$schema":"https://json-schema.org/draft/2020-12/schema","$id":"https://example.com/schemas/nested/child-event.json","title":"Child Event","type":"object","oneOf":[{"$schema":"https://json-schema.org/draft/2020-12/schema","$id":"https://example.com/schemas/nested/grandchild-a.json","title":"Grandchild A","type":"object","properties":{"prop_a":{"type":"string"}}},{"$schema":"https://json-schema.org/draft/2020-12/schema","$id":"https://example.com/schemas/nested/grandchild-b.json","title":"Grandchild B","type":"object","properties":{"prop_b":{"type":"string"}}}],"properties":{}}} />
|
|
39
|
+
"
|
|
40
|
+
`;
|
|
41
|
+
|
|
42
|
+
exports[`generateEventDocs (nested oneOf) should generate nested documentation correctly 3`] = `
|
|
43
|
+
"---
|
|
44
|
+
title: Grandchild A
|
|
45
|
+
description: undefined
|
|
46
|
+
sidebar_label: Grandchild A
|
|
47
|
+
custom_edit_url: https://github.com/test-org/test-project/edit/main/__fixtures_nested__/docs/parent-event/01-child-event/01-grandchild-a.json
|
|
48
|
+
---
|
|
49
|
+
|
|
50
|
+
import SchemaViewer from '@theme/SchemaViewer';
|
|
51
|
+
import SchemaJsonViewer from '@theme/SchemaJsonViewer';
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
# Grandchild A
|
|
56
|
+
|
|
57
|
+
undefined
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
<SchemaViewer schema={{"$schema":"https://json-schema.org/draft/2020-12/schema","$id":"https://example.com/schemas/nested/grandchild-a.json","title":"Grandchild A","type":"object","properties":{"prop_a":{"type":"string"}}}} />
|
|
62
|
+
<SchemaJsonViewer schema={{"$schema":"https://json-schema.org/draft/2020-12/schema","$id":"https://example.com/schemas/nested/grandchild-a.json","title":"Grandchild A","type":"object","properties":{"prop_a":{"type":"string"}}}} />
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
"
|
|
66
|
+
`;
|
|
67
|
+
|
|
68
|
+
exports[`generateEventDocs (nested oneOf) should generate nested documentation correctly 4`] = `
|
|
69
|
+
"---
|
|
70
|
+
title: Grandchild B
|
|
71
|
+
description: undefined
|
|
72
|
+
sidebar_label: Grandchild B
|
|
73
|
+
custom_edit_url: https://github.com/test-org/test-project/edit/main/__fixtures_nested__/docs/parent-event/01-child-event/02-grandchild-b.json
|
|
74
|
+
---
|
|
75
|
+
|
|
76
|
+
import SchemaViewer from '@theme/SchemaViewer';
|
|
77
|
+
import SchemaJsonViewer from '@theme/SchemaJsonViewer';
|
|
78
|
+
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+
# Grandchild B
|
|
82
|
+
|
|
83
|
+
undefined
|
|
84
|
+
|
|
85
|
+
|
|
86
|
+
|
|
87
|
+
<SchemaViewer schema={{"$schema":"https://json-schema.org/draft/2020-12/schema","$id":"https://example.com/schemas/nested/grandchild-b.json","title":"Grandchild B","type":"object","properties":{"prop_b":{"type":"string"}}}} />
|
|
88
|
+
<SchemaJsonViewer schema={{"$schema":"https://json-schema.org/draft/2020-12/schema","$id":"https://example.com/schemas/nested/grandchild-b.json","title":"Grandchild B","type":"object","properties":{"prop_b":{"type":"string"}}}} />
|
|
89
|
+
|
|
90
|
+
|
|
91
|
+
"
|
|
92
|
+
`;
|
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
// Jest Snapshot v1, https://jestjs.io/docs/snapshot-testing
|
|
2
|
+
|
|
3
|
+
exports[`generateEventDocs (non-versioned) should generate documentation correctly 1`] = `
|
|
4
|
+
"---
|
|
5
|
+
title: Add to Cart Event
|
|
6
|
+
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."
|
|
7
|
+
sidebar_label: Add to Cart Event
|
|
8
|
+
custom_edit_url: https://github.com/test-org/test-project/edit/main/__fixtures__/static/schemas/add-to-cart-event.json
|
|
9
|
+
---
|
|
10
|
+
|
|
11
|
+
import SchemaViewer from '@theme/SchemaViewer';
|
|
12
|
+
import SchemaJsonViewer from '@theme/SchemaJsonViewer';
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
# Add to Cart Event
|
|
17
|
+
|
|
18
|
+
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.
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
<SchemaViewer schema={{"$schema":"https://json-schema.org/draft/2020-12/schema","$id":"https://tracking-docs-demo.buchert.digital/schemas/add-to-cart-event.json","title":"Add to Cart Event","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.","type":"object","required":["event"],"$defs":{"strictObject":{"type":"object","propertyNames":{"maxLength":40,"pattern":"^[a-z0-9_]+$"},"additionalProperties":{"anyOf":[{"$ref":"#/allOf/0/$defs/strictObject"},{"type":"array","items":{"$ref":"#/allOf/0/$defs/strictObject"}},{"not":{"type":"object"}}]}}},"$ref":"#/allOf/0/$defs/strictObject","properties":{"event":{"type":"string","const":"add_to_cart","description":"The name of the event indicating a add_to_cart has occurred."},"ecommerce":{"type":"object","description":"Ecommerce related data for the purchase event.","required":["currency","items"],"x-gtm-clear":true,"properties":{"value":{"type":"number","description":"The monetary value of the event. Set value to the sum of (price * quantity) for all items in items.","examples":[30.03,99.99,45.5]},"currency":{"type":"string","description":"The currency of the items in ISO 4217 three-letter format. Required when value is set.","examples":["USD","EUR","GBP"]},"items":{"type":"array","description":"The products added to the cart.","minItems":1,"items":{"$schema":"https://json-schema.org/draft/2020-12/schema","$id":"https://tracking-docs-demo.buchert.digital/schemas/components/product.json","title":"A Product","description":"A product object representing an item for use within a purchase event, based on Google Analytics 4 ecommerce event specifications.","type":"object","required":[],"properties":{"item_id":{"type":"string","description":"The ID of the item. Either item_id or item_name is required.","examples":["SKU_12345","PROD_98765"]},"item_name":{"type":"string","description":"The name of the item. Either item_id or item_name is required.","examples":["Stan and Friends Tee","Blue Running Shoes"]},"affiliation":{"type":"string","description":"A product affiliation to indicate a supplier or store. Note: affiliation is only available at the item level.","examples":["Google Merchandise Store","Nike Store"]},"coupon":{"type":"string","description":"The coupon name/code associated with the item. Coupon parameters at event and item levels are independent.","examples":["SUMMER_FUN","WELCOME20","SAVE10"]},"discount":{"type":"number","description":"The monetary value of the discount per unit applied to the item.","examples":[2.22,5,10.5]},"index":{"type":"number","description":"The index or position of the item in a list.","examples":[0,1,2]},"item_brand":{"type":"string","description":"The brand of the item.","examples":["Google","Nike","Adidas"]},"item_category":{"type":"string","description":"The category of the item. If used as part of a category hierarchy or taxonomy, this is the first category.","examples":["Apparel","Footwear","Electronics"]},"item_category2":{"type":"string","description":"The second category hierarchy or additional taxonomy of the item.","examples":["Adult","Women","Men"]},"item_category3":{"type":"string","description":"The third category hierarchy or additional taxonomy of the item.","examples":["Shirts","Shoes","Boots"]},"item_category4":{"type":"string","description":"The fourth category hierarchy or additional taxonomy of the item.","examples":["Crew","Running","Casual"]},"item_category5":{"type":"string","description":"The fifth category hierarchy or additional taxonomy of the item.","examples":["Short sleeve","Long distance","Lightweight"]},"item_list_id":{"type":"string","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.","examples":["related_products","search_results","recommendations"]},"item_list_name":{"type":"string","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.","examples":["Related Products","Search Results","Recommended Items"]},"item_variant":{"type":"string","description":"The item variant or unique code or description for additional item details/options.","examples":["green","Blue Size 10","M-Black"]},"location_id":{"type":"string","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.","examples":["ChIJIQBpAG2ahYAR_6128GcTUEo","store_123","location_sf"]},"price":{"type":"number","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.","examples":[10.01,21.01,89.99]},"quantity":{"type":"number","description":"The item quantity. If not set, quantity is set to 1.","examples":[1,2,3]},"promotion_id":{"type":"string","description":"The ID of the promotion associated with the item.","examples":["P_12345","PROMO_001"]},"promotion_name":{"type":"string","description":"The name of the promotion associated with the item.","examples":["Summer Sale","Black Friday","Flash Deal"]},"creative_name":{"type":"string","description":"The name of the promotion creative.","examples":["summer_banner2","holiday_email_v1"]},"creative_slot":{"type":"string","description":"The name of the creative slot associated with the item.","examples":["featured_app_1","top_banner","sidebar"]},"google_business_vertical":{"type":"string","description":"The business vertical for the item (e.g., 'retail').","examples":["retail","ecommerce"]}}}}}},"user_data":{"type":"object","description":"User related data.","x-gtm-clear":true}}}} />
|
|
23
|
+
<SchemaJsonViewer schema={{"$schema":"https://json-schema.org/draft/2020-12/schema","$id":"https://tracking-docs-demo.buchert.digital/schemas/add-to-cart-event.json","title":"Add to Cart Event","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.","type":"object","allOf":[{"$ref":"./components/dataLayer.json"}],"properties":{"event":{"type":"string","const":"add_to_cart","description":"The name of the event indicating a add_to_cart has occurred."},"ecommerce":{"type":"object","description":"Ecommerce related data for the purchase event.","properties":{"value":{"type":"number","description":"The monetary value of the event. Set value to the sum of (price * quantity) for all items in items.","examples":[30.03,99.99,45.5]},"currency":{"type":"string","description":"The currency of the items in ISO 4217 three-letter format. Required when value is set.","examples":["USD","EUR","GBP"]},"items":{"type":"array","description":"The products added to the cart.","minItems":1,"items":{"$ref":"./components/product.json"}}},"required":["currency","items"]}}}} />
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
"
|
|
27
|
+
`;
|
|
28
|
+
|
|
29
|
+
exports[`generateEventDocs (non-versioned) should generate documentation correctly 2`] = `
|
|
30
|
+
"---
|
|
31
|
+
title: Choice Event
|
|
32
|
+
description: "An example event that uses oneOf and anyOf."
|
|
33
|
+
sidebar_label: Choice Event
|
|
34
|
+
custom_edit_url: https://github.com/test-org/test-project/edit/main/__fixtures__/static/schemas/choice-event.json
|
|
35
|
+
---
|
|
36
|
+
|
|
37
|
+
import SchemaViewer from '@theme/SchemaViewer';
|
|
38
|
+
import SchemaJsonViewer from '@theme/SchemaJsonViewer';
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
# Choice Event
|
|
43
|
+
|
|
44
|
+
An example event that uses oneOf and anyOf.
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
<SchemaViewer schema={{"$schema":"https://json-schema.org/draft/2020-12/schema","$id":"https://tracking-docs-demo.buchert.digital/schemas/1.2.0/choice-event.json","title":"Choice Event","description":"An example event that uses oneOf and anyOf.","type":"object","required":["event","user_id","payment_method"],"properties":{"event":{"type":"string","const":"one_of_event"},"user_id":{"description":"The user's ID.","oneOf":[{"type":"string","title":"User ID as String","description":"The user's ID as a string.","examples":["user-123"]},{"type":"integer","title":"User ID as Integer","description":"The user's ID as an integer.","examples":[123]}]},"payment_method":{"description":"The user's payment method.","type":"object","anyOf":[{"title":"Credit Card","properties":{"payment_type":{"type":"string","enum":["credit_card","debit_card"],"examples":["credit_card"]},"card_number":{"type":"string","examples":["1234-5678-9012-3456"]},"expiry_date":{"type":"string","examples":["12/26"]}},"required":["card_number","expiry_date"]},{"title":"PayPal","type":"object","properties":{"payment_type":{"type":"string","const":"paypal"},"email":{"type":"string","format":"email","examples":["test@example.com"]}},"required":["email"]}]}}}} />
|
|
49
|
+
<SchemaJsonViewer schema={{"$schema":"https://json-schema.org/draft/2020-12/schema","$id":"https://tracking-docs-demo.buchert.digital/schemas/1.2.0/choice-event.json","title":"Choice Event","description":"An example event that uses oneOf and anyOf.","type":"object","properties":{"event":{"type":"string","const":"one_of_event"},"user_id":{"description":"The user's ID.","oneOf":[{"type":"string","title":"User ID as String","description":"The user's ID as a string.","examples":["user-123"]},{"type":"integer","title":"User ID as Integer","description":"The user's ID as an integer.","examples":[123]}]},"payment_method":{"description":"The user's payment method.","type":"object","anyOf":[{"title":"Credit Card","properties":{"payment_type":{"type":"string","enum":["credit_card","debit_card"],"examples":["credit_card"]},"card_number":{"type":"string","examples":["1234-5678-9012-3456"]},"expiry_date":{"type":"string","examples":["12/26"]}},"required":["card_number","expiry_date"]},{"title":"PayPal","type":"object","properties":{"payment_type":{"type":"string","const":"paypal"},"email":{"type":"string","format":"email","examples":["test@example.com"]}},"required":["email"]}]}},"required":["event","user_id","payment_method"]}} />
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
"
|
|
53
|
+
`;
|
|
54
|
+
|
|
55
|
+
exports[`generateEventDocs (non-versioned) should generate documentation correctly 3`] = `
|
|
56
|
+
"---
|
|
57
|
+
title: Root AnyOf Event
|
|
58
|
+
description: "An example event that has anyOf at the root level."
|
|
59
|
+
sidebar_label: Root AnyOf Event
|
|
60
|
+
custom_edit_url: https://github.com/test-org/test-project/edit/main/__fixtures__/static/schemas/root-any-of-event.json
|
|
61
|
+
---
|
|
62
|
+
|
|
63
|
+
import SchemaViewer from '@theme/SchemaViewer';
|
|
64
|
+
import SchemaJsonViewer from '@theme/SchemaJsonViewer';
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
# Root AnyOf Event
|
|
69
|
+
|
|
70
|
+
An example event that has anyOf at the root level.
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
<SchemaViewer schema={{"$schema":"https://json-schema.org/draft/2020-12/schema","$id":"https://tracking-docs-demo.buchert.digital/schemas/1.2.0/root-any-of-event.json","title":"Root AnyOf Event","description":"An example event that has anyOf at the root level.","type":"object","anyOf":[{"title":"Has Param C","properties":{"param_c":{"type":"string","examples":["example_c"],"description":"This is the description for Param C."}}},{"title":"Has Param D","properties":{"param_d":{"type":"boolean","examples":[true]}}}],"properties":{"event":{"type":"string","const":"any_of_event"}}}} />
|
|
75
|
+
<SchemaJsonViewer schema={{"$schema":"https://json-schema.org/draft/2020-12/schema","$id":"https://tracking-docs-demo.buchert.digital/schemas/1.2.0/root-any-of-event.json","title":"Root AnyOf Event","description":"An example event that has anyOf at the root level.","type":"object","properties":{"event":{"type":"string","const":"any_of_event"}},"anyOf":[{"title":"Has Param C","properties":{"param_c":{"type":"string","examples":["example_c"],"description":"This is the description for Param C."}}},{"title":"Has Param D","properties":{"param_d":{"type":"boolean","examples":[true]}}}]}} />
|
|
76
|
+
|
|
77
|
+
|
|
78
|
+
"
|
|
79
|
+
`;
|
|
80
|
+
|
|
81
|
+
exports[`generateEventDocs (non-versioned) should generate documentation correctly 4`] = `
|
|
82
|
+
"---
|
|
83
|
+
title: Root Choice Event
|
|
84
|
+
description: "An example event that has oneOf at the root level."
|
|
85
|
+
---
|
|
86
|
+
import SchemaJsonViewer from '@theme/SchemaJsonViewer';
|
|
87
|
+
|
|
88
|
+
# Root Choice Event
|
|
89
|
+
|
|
90
|
+
An example event that has oneOf at the root level.
|
|
91
|
+
|
|
92
|
+
Please select one of the following options:
|
|
93
|
+
|
|
94
|
+
- [Option A](./option-a)
|
|
95
|
+
- [Option B](./option-b)
|
|
96
|
+
|
|
97
|
+
<SchemaJsonViewer schema={{"$schema":"https://json-schema.org/draft/2020-12/schema","$id":"https://example.com/root-choice-event.schema.json","title":"Root Choice Event","description":"An example event that has oneOf at the root level.","oneOf":[{"title":"Option A","type":"object","properties":{"event":{"type":"string","const":"option_a"},"param_a":{"type":"string","examples":["example_a"]}}},{"title":"Option B","type":"object","properties":{"event":{"type":"string","const":"option_b"},"param_b":{"type":"integer","examples":[123]}}}]}} />
|
|
98
|
+
"
|
|
99
|
+
`;
|
|
100
|
+
|
|
101
|
+
exports[`generateEventDocs (non-versioned) should generate documentation correctly 5`] = `
|
|
102
|
+
"---
|
|
103
|
+
title: Option A
|
|
104
|
+
description: "An example event that has oneOf at the root level."
|
|
105
|
+
sidebar_label: Option A
|
|
106
|
+
custom_edit_url: https://github.com/test-org/test-project/edit/main/__fixtures__/docs/root-choice-event/01-option-a.json
|
|
107
|
+
---
|
|
108
|
+
|
|
109
|
+
import SchemaViewer from '@theme/SchemaViewer';
|
|
110
|
+
import SchemaJsonViewer from '@theme/SchemaJsonViewer';
|
|
111
|
+
|
|
112
|
+
|
|
113
|
+
|
|
114
|
+
# Option A
|
|
115
|
+
|
|
116
|
+
An example event that has oneOf at the root level.
|
|
117
|
+
|
|
118
|
+
|
|
119
|
+
|
|
120
|
+
<SchemaViewer schema={{"$schema":"https://json-schema.org/draft/2020-12/schema","$id":"https://example.com/root-choice-event.schema.json#option-a","title":"Option A","description":"An example event that has oneOf at the root level.","type":"object","properties":{"event":{"type":"string","const":"option_a"},"param_a":{"type":"string","examples":["example_a"]}}}} />
|
|
121
|
+
<SchemaJsonViewer schema={{"$schema":"https://json-schema.org/draft/2020-12/schema","$id":"https://example.com/root-choice-event.schema.json#option-a","title":"Option A","description":"An example event that has oneOf at the root level.","type":"object","properties":{"event":{"type":"string","const":"option_a"},"param_a":{"type":"string","examples":["example_a"]}}}} />
|
|
122
|
+
|
|
123
|
+
|
|
124
|
+
"
|
|
125
|
+
`;
|
|
126
|
+
|
|
127
|
+
exports[`generateEventDocs (non-versioned) should generate documentation correctly 6`] = `
|
|
128
|
+
"---
|
|
129
|
+
title: Option B
|
|
130
|
+
description: "An example event that has oneOf at the root level."
|
|
131
|
+
sidebar_label: Option B
|
|
132
|
+
custom_edit_url: https://github.com/test-org/test-project/edit/main/__fixtures__/docs/root-choice-event/02-option-b.json
|
|
133
|
+
---
|
|
134
|
+
|
|
135
|
+
import SchemaViewer from '@theme/SchemaViewer';
|
|
136
|
+
import SchemaJsonViewer from '@theme/SchemaJsonViewer';
|
|
137
|
+
|
|
138
|
+
|
|
139
|
+
|
|
140
|
+
# Option B
|
|
141
|
+
|
|
142
|
+
An example event that has oneOf at the root level.
|
|
143
|
+
|
|
144
|
+
|
|
145
|
+
|
|
146
|
+
<SchemaViewer schema={{"$schema":"https://json-schema.org/draft/2020-12/schema","$id":"https://example.com/root-choice-event.schema.json#option-b","title":"Option B","description":"An example event that has oneOf at the root level.","type":"object","properties":{"event":{"type":"string","const":"option_b"},"param_b":{"type":"integer","examples":[123]}}}} />
|
|
147
|
+
<SchemaJsonViewer schema={{"$schema":"https://json-schema.org/draft/2020-12/schema","$id":"https://example.com/root-choice-event.schema.json#option-b","title":"Option B","description":"An example event that has oneOf at the root level.","type":"object","properties":{"event":{"type":"string","const":"option_b"},"param_b":{"type":"integer","examples":[123]}}}} />
|
|
148
|
+
|
|
149
|
+
|
|
150
|
+
"
|
|
151
|
+
`;
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
// Jest Snapshot v1, https://jestjs.io/docs/snapshot-testing
|
|
2
|
+
|
|
3
|
+
exports[`generateEventDocs (versioned) should generate documentation for "current" version 1`] = `
|
|
4
|
+
"---
|
|
5
|
+
title: Add to Cart Event
|
|
6
|
+
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."
|
|
7
|
+
sidebar_label: Add to Cart Event
|
|
8
|
+
custom_edit_url: https://github.com/test-org/test-project/edit/main/__fixtures_versioned__/static/schemas/next/add-to-cart-event.json
|
|
9
|
+
---
|
|
10
|
+
|
|
11
|
+
import SchemaViewer from '@theme/SchemaViewer';
|
|
12
|
+
import SchemaJsonViewer from '@theme/SchemaJsonViewer';
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
# Add to Cart Event
|
|
17
|
+
|
|
18
|
+
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.
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
<SchemaViewer schema={{"$schema":"https://json-schema.org/draft/2020-12/schema","$id":"https://tracking-docs-demo.buchert.digital/schemas/add-to-cart-event.json","title":"Add to Cart Event","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.","type":"object","required":["event"],"$defs":{"strictObject":{"type":"object","propertyNames":{"maxLength":40,"pattern":"^[a-z0-9_]+$"},"additionalProperties":{"anyOf":[{"$ref":"#/allOf/0/$defs/strictObject"},{"type":"array","items":{"$ref":"#/allOf/0/$defs/strictObject"}},{"not":{"type":"object"}}]}}},"$ref":"#/allOf/0/$defs/strictObject","properties":{"event":{"type":"string","const":"add_to_cart","description":"The name of the event indicating a add_to_cart has occurred."},"ecommerce":{"type":"object","description":"Ecommerce related data for the purchase event.","required":["currency","items"],"x-gtm-clear":true,"properties":{"value":{"type":"number","description":"The monetary value of the event. Set value to the sum of (price * quantity) for all items in items.","examples":[30.03,99.99,45.5]},"currency":{"type":"string","description":"The currency of the items in ISO 4217 three-letter format. Required when value is set.","examples":["USD","EUR","GBP"]},"items":{"type":"array","description":"The products added to the cart.","minItems":1,"items":{"$schema":"https://json-schema.org/draft/2020-12/schema","$id":"https://tracking-docs-demo.buchert.digital/schemas/components/product.json","title":"A Product","description":"A product object representing an item for use within a purchase event, based on Google Analytics 4 ecommerce event specifications.","type":"object","required":[],"properties":{"item_id":{"type":"string","description":"The ID of the item. Either item_id or item_name is required.","examples":["SKU_12345","PROD_98765"]},"item_name":{"type":"string","description":"The name of the item. Either item_id or item_name is required.","examples":["Stan and Friends Tee","Blue Running Shoes"]},"affiliation":{"type":"string","description":"A product affiliation to indicate a supplier or store. Note: affiliation is only available at the item level.","examples":["Google Merchandise Store","Nike Store"]},"coupon":{"type":"string","description":"The coupon name/code associated with the item. Coupon parameters at event and item levels are independent.","examples":["SUMMER_FUN","WELCOME20","SAVE10"]},"discount":{"type":"number","description":"The monetary value of the discount per unit applied to the item.","examples":[2.22,5,10.5]},"index":{"type":"number","description":"The index or position of the item in a list.","examples":[0,1,2]},"item_brand":{"type":"string","description":"The brand of the item.","examples":["Google","Nike","Adidas"]},"item_category":{"type":"string","description":"The category of the item. If used as part of a category hierarchy or taxonomy, this is the first category.","examples":["Apparel","Footwear","Electronics"]},"item_category2":{"type":"string","description":"The second category hierarchy or additional taxonomy of the item.","examples":["Adult","Women","Men"]},"item_category3":{"type":"string","description":"The third category hierarchy or additional taxonomy of the item.","examples":["Shirts","Shoes","Boots"]},"item_category4":{"type":"string","description":"The fourth category hierarchy or additional taxonomy of the item.","examples":["Crew","Running","Casual"]},"item_category5":{"type":"string","description":"The fifth category hierarchy or additional taxonomy of the item.","examples":["Short sleeve","Long distance","Lightweight"]},"item_list_id":{"type":"string","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.","examples":["related_products","search_results","recommendations"]},"item_list_name":{"type":"string","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.","examples":["Related Products","Search Results","Recommended Items"]},"item_variant":{"type":"string","description":"The item variant or unique code or description for additional item details/options.","examples":["green","Blue Size 10","M-Black"]},"location_id":{"type":"string","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.","examples":["ChIJIQBpAG2ahYAR_6128GcTUEo","store_123","location_sf"]},"price":{"type":"number","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.","examples":[10.01,21.01,89.99]},"quantity":{"type":"number","description":"The item quantity. If not set, quantity is set to 1.","examples":[1,2,3]},"promotion_id":{"type":"string","description":"The ID of the promotion associated with the item.","examples":["P_12345","PROMO_001"]},"promotion_name":{"type":"string","description":"The name of the promotion associated with the item.","examples":["Summer Sale","Black Friday","Flash Deal"]},"creative_name":{"type":"string","description":"The name of the promotion creative.","examples":["summer_banner2","holiday_email_v1"]},"creative_slot":{"type":"string","description":"The name of the creative slot associated with the item.","examples":["featured_app_1","top_banner","sidebar"]},"google_business_vertical":{"type":"string","description":"The business vertical for the item (e.g., 'retail').","examples":["retail","ecommerce"]}}}}}},"user_data":{"type":"object","description":"User related data.","x-gtm-clear":true}}}} />
|
|
23
|
+
<SchemaJsonViewer schema={{"$schema":"https://json-schema.org/draft/2020-12/schema","$id":"https://tracking-docs-demo.buchert.digital/schemas/next/add-to-cart-event.json","title":"Add to Cart Event","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.","type":"object","allOf":[{"$ref":"./components/dataLayer.json"}],"properties":{"event":{"type":"string","const":"add_to_cart","description":"The name of the event indicating a add_to_cart has occurred."},"ecommerce":{"type":"object","description":"Ecommerce related data for the purchase event.","properties":{"value":{"type":"number","description":"The monetary value of the event. Set value to the sum of (price * quantity) for all items in items.","examples":[30.03,99.99,45.5]},"currency":{"type":"string","description":"The currency of the items in ISO 4217 three-letter format. Required when value is set.","examples":["USD","EUR","GBP"]},"items":{"type":"array","description":"The products added to the cart.","minItems":1,"items":{"$ref":"./components/product.json"}}},"required":["currency","items"]}}}} />
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
"
|
|
27
|
+
`;
|
|
28
|
+
|
|
29
|
+
exports[`generateEventDocs (versioned) should generate documentation for a specific version 1`] = `
|
|
30
|
+
"---
|
|
31
|
+
title: Add to Cart Event
|
|
32
|
+
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."
|
|
33
|
+
sidebar_label: Add to Cart Event
|
|
34
|
+
custom_edit_url: https://github.com/test-org/test-project/edit/main/__fixtures_versioned__/static/schemas/1.1.1/add-to-cart-event.json
|
|
35
|
+
---
|
|
36
|
+
|
|
37
|
+
import SchemaViewer from '@theme/SchemaViewer';
|
|
38
|
+
import SchemaJsonViewer from '@theme/SchemaJsonViewer';
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
# Add to Cart Event
|
|
43
|
+
|
|
44
|
+
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.
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
<SchemaViewer schema={{"$schema":"https://json-schema.org/draft/2020-12/schema","$id":"https://tracking-docs-demo.buchert.digital/schemas/add-to-cart-event.json","title":"Add to Cart Event","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.","type":"object","required":["event"],"$defs":{"strictObject":{"type":"object","propertyNames":{"maxLength":40,"pattern":"^[a-z0-9_]+$"},"additionalProperties":{"anyOf":[{"$ref":"#/allOf/0/$defs/strictObject"},{"type":"array","items":{"$ref":"#/allOf/0/$defs/strictObject"}},{"not":{"type":"object"}}]}}},"$ref":"#/allOf/0/$defs/strictObject","properties":{"event":{"type":"string","const":"add_to_cart","description":"The name of the event indicating a add_to_cart has occurred."},"ecommerce":{"type":"object","description":"Ecommerce related data for the purchase event.","required":["currency","items"],"x-gtm-clear":true,"properties":{"value":{"type":"number","description":"The monetary value of the event. Set value to the sum of (price * quantity) for all items in items.","examples":[30.03,99.99,45.5]},"currency":{"type":"string","description":"The currency of the items in ISO 4217 three-letter format. Required when value is set.","examples":["USD","EUR","GBP"]},"items":{"type":"array","description":"The products added to the cart.","minItems":1,"items":{"$schema":"https://json-schema.org/draft/2020-12/schema","$id":"https://tracking-docs-demo.buchert.digital/schemas/components/product.json","title":"A Product","description":"A product object representing an item for use within a purchase event, based on Google Analytics 4 ecommerce event specifications.","type":"object","required":[],"properties":{"item_id":{"type":"string","description":"The ID of the item. Either item_id or item_name is required.","examples":["SKU_12345","PROD_98765"]},"item_name":{"type":"string","description":"The name of the item. Either item_id or item_name is required.","examples":["Stan and Friends Tee","Blue Running Shoes"]},"affiliation":{"type":"string","description":"A product affiliation to indicate a supplier or store. Note: affiliation is only available at the item level.","examples":["Google Merchandise Store","Nike Store"]},"coupon":{"type":"string","description":"The coupon name/code associated with the item. Coupon parameters at event and item levels are independent.","examples":["SUMMER_FUN","WELCOME20","SAVE10"]},"discount":{"type":"number","description":"The monetary value of the discount per unit applied to the item.","examples":[2.22,5,10.5]},"index":{"type":"number","description":"The index or position of the item in a list.","examples":[0,1,2]},"item_brand":{"type":"string","description":"The brand of the item.","examples":["Google","Nike","Adidas"]},"item_category":{"type":"string","description":"The category of the item. If used as part of a category hierarchy or taxonomy, this is the first category.","examples":["Apparel","Footwear","Electronics"]},"item_category2":{"type":"string","description":"The second category hierarchy or additional taxonomy of the item.","examples":["Adult","Women","Men"]},"item_category3":{"type":"string","description":"The third category hierarchy or additional taxonomy of the item.","examples":["Shirts","Shoes","Boots"]},"item_category4":{"type":"string","description":"The fourth category hierarchy or additional taxonomy of the item.","examples":["Crew","Running","Casual"]},"item_category5":{"type":"string","description":"The fifth category hierarchy or additional taxonomy of the item.","examples":["Short sleeve","Long distance","Lightweight"]},"item_list_id":{"type":"string","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.","examples":["related_products","search_results","recommendations"]},"item_list_name":{"type":"string","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.","examples":["Related Products","Search Results","Recommended Items"]},"item_variant":{"type":"string","description":"The item variant or unique code or description for additional item details/options.","examples":["green","Blue Size 10","M-Black"]},"location_id":{"type":"string","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.","examples":["ChIJIQBpAG2ahYAR_6128GcTUEo","store_123","location_sf"]},"price":{"type":"number","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.","examples":[10.01,21.01,89.99]},"quantity":{"type":"number","description":"The item quantity. If not set, quantity is set to 1.","examples":[1,2,3]},"promotion_id":{"type":"string","description":"The ID of the promotion associated with the item.","examples":["P_12345","PROMO_001"]},"promotion_name":{"type":"string","description":"The name of the promotion associated with the item.","examples":["Summer Sale","Black Friday","Flash Deal"]},"creative_name":{"type":"string","description":"The name of the promotion creative.","examples":["summer_banner2","holiday_email_v1"]},"creative_slot":{"type":"string","description":"The name of the creative slot associated with the item.","examples":["featured_app_1","top_banner","sidebar"]},"google_business_vertical":{"type":"string","description":"The business vertical for the item (e.g., 'retail').","examples":["retail","ecommerce"]}}}}}},"user_data":{"type":"object","description":"User related data.","x-gtm-clear":true}}}} />
|
|
49
|
+
<SchemaJsonViewer schema={{"$schema":"https://json-schema.org/draft/2020-12/schema","$id":"https://tracking-docs-demo.buchert.digital/schemas/1.1.1/add-to-cart-event.json","title":"Add to Cart Event","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.","type":"object","allOf":[{"$ref":"./components/dataLayer.json"}],"properties":{"event":{"type":"string","const":"add_to_cart","description":"The name of the event indicating a add_to_cart has occurred."},"ecommerce":{"type":"object","description":"Ecommerce related data for the purchase event.","properties":{"value":{"type":"number","description":"The monetary value of the event. Set value to the sum of (price * quantity) for all items in items.","examples":[30.03,99.99,45.5]},"currency":{"type":"string","description":"The currency of the items in ISO 4217 three-letter format. Required when value is set.","examples":["USD","EUR","GBP"]},"items":{"type":"array","description":"The products added to the cart.","minItems":1,"items":{"$ref":"./components/product.json"}}},"required":["currency","items"]}}}} />
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
"
|
|
53
|
+
`;
|