docusaurus-plugin-generate-schema-docs 1.1.1 → 1.2.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 +22 -0
- package/__tests__/ExampleDataLayer.test.js +169 -0
- package/__tests__/__fixtures__/static/schemas/add-to-cart-event.json +55 -0
- package/__tests__/__fixtures__/static/schemas/components/dataLayer.json +58 -0
- package/__tests__/__fixtures__/static/schemas/components/product.json +211 -0
- package/__tests__/__fixtures__/validateSchemas/circular-schema.json +8 -0
- package/__tests__/__fixtures__/validateSchemas/components/referenced.json +8 -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__/__snapshots__/generateEventDocs.test.js.snap +53 -0
- package/__tests__/components/PropertiesTable.test.js +24 -0
- package/__tests__/components/PropertyRow.test.js +67 -0
- package/__tests__/components/SchemaJsonViewer.test.js +32 -0
- package/__tests__/components/SchemaRows.test.js +80 -0
- package/__tests__/components/SchemaViewer.test.js +27 -0
- package/__tests__/components/TableHeader.test.js +20 -0
- package/__tests__/generateEventDocs.test.js +84 -0
- package/__tests__/helpers/buildExampleFromSchema.test.js +188 -0
- package/__tests__/helpers/getConstraints.test.js +58 -0
- package/__tests__/helpers/loadSchema.test.js +14 -0
- package/__tests__/helpers/processSchema.test.js +36 -0
- package/__tests__/validateSchemas.test.js +100 -0
- package/components/ExampleDataLayer.js +7 -5
- package/components/PropertiesTable.js +5 -10
- package/components/PropertyRow.js +74 -0
- package/components/SchemaJsonViewer.js +3 -2
- package/components/SchemaRows.css +28 -0
- package/components/SchemaRows.js +19 -47
- package/components/SchemaViewer.js +4 -2
- package/components/TableHeader.js +15 -0
- package/generateEventDocs.js +37 -36
- package/helpers/buildExampleFromSchema.js +3 -3
- package/helpers/getConstraints.js +53 -0
- package/helpers/loadSchema.js +11 -0
- package/helpers/mdx-template.js +36 -0
- package/helpers/processSchema.js +32 -0
- package/index.js +21 -11
- package/package.json +6 -3
- package/validateSchemas.js +6 -3
package/README.md
CHANGED
|
@@ -66,6 +66,28 @@ The plugin reads your JSON schemas, dereferences any `$ref` properties, and merg
|
|
|
66
66
|
|
|
67
67
|
The validation script builds an example from each schema and validates it against the schema itself, ensuring your examples are always in sync with your schemas.
|
|
68
68
|
|
|
69
|
+
## Partials
|
|
70
|
+
|
|
71
|
+
You can provide additional content to the generated documentation pages by creating partial files. Partials are Markdown files that can be automatically included in the generated pages.
|
|
72
|
+
|
|
73
|
+
### Naming Convention
|
|
74
|
+
|
|
75
|
+
Partials must be named after the schema file they correspond to. For a schema named `my-event.json`, the partials would be:
|
|
76
|
+
|
|
77
|
+
* `my-event.mdx`: This partial is rendered directly after the schema's main description.
|
|
78
|
+
* `my-event_bottom.mdx`: This partial is rendered at the very bottom of the page.
|
|
79
|
+
|
|
80
|
+
### Location
|
|
81
|
+
|
|
82
|
+
Place your partial files in the `/docs/partials` directory at the root of your docusaurus project. The plugin will automatically find and include them.
|
|
83
|
+
|
|
84
|
+
### Example
|
|
85
|
+
|
|
86
|
+
If you have a schema `add-to-cart-event.json`, you can create the following files:
|
|
87
|
+
|
|
88
|
+
* `docs/partials/add-to-cart-event.mdx`: For content to appear after the description.
|
|
89
|
+
* `docs/partials/add-to-cart-event_bottom.mdx`: For content to appear at the bottom.
|
|
90
|
+
|
|
69
91
|
## Contributing
|
|
70
92
|
|
|
71
93
|
Contributions are welcome! Please open an issue or submit a pull request if you have any ideas or improvements.
|
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { render, screen } from '@testing-library/react';
|
|
3
|
+
import '@testing-library/jest-dom';
|
|
4
|
+
import ExampleDataLayer, { findClearableProperties } from '../components/ExampleDataLayer';
|
|
5
|
+
import buildExampleFromSchema from '../helpers/buildExampleFromSchema';
|
|
6
|
+
|
|
7
|
+
jest.mock('../helpers/buildExampleFromSchema', () => jest.fn());
|
|
8
|
+
|
|
9
|
+
jest.mock('@theme/CodeBlock', () => {
|
|
10
|
+
return function CodeBlock({ children }) {
|
|
11
|
+
return <pre>{children}</pre>;
|
|
12
|
+
};
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
describe('ExampleDataLayer', () => {
|
|
16
|
+
afterEach(() => {
|
|
17
|
+
jest.clearAllMocks();
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
it('should render correctly with a simple schema', () => {
|
|
21
|
+
const schema = {
|
|
22
|
+
type: 'object',
|
|
23
|
+
properties: {
|
|
24
|
+
event: { type: 'string', examples: ['test_event'] },
|
|
25
|
+
},
|
|
26
|
+
};
|
|
27
|
+
const example = { event: 'test_event' };
|
|
28
|
+
buildExampleFromSchema.mockReturnValue(example);
|
|
29
|
+
|
|
30
|
+
const { container } = render(<ExampleDataLayer schema={schema} />);
|
|
31
|
+
|
|
32
|
+
expect(buildExampleFromSchema).toHaveBeenCalledWith(schema);
|
|
33
|
+
const codeElement = container.querySelector('pre');
|
|
34
|
+
expect(codeElement.textContent).toMatchInlineSnapshot(`
|
|
35
|
+
"window.dataLayer.push({
|
|
36
|
+
"event": "test_event"
|
|
37
|
+
});"
|
|
38
|
+
`);
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
it('should render correctly with properties to reset', () => {
|
|
42
|
+
const schema = {
|
|
43
|
+
type: 'object',
|
|
44
|
+
properties: {
|
|
45
|
+
ecommerce: {
|
|
46
|
+
'x-gtm-clear': true,
|
|
47
|
+
type: 'object',
|
|
48
|
+
properties: { items: { type: 'array' } },
|
|
49
|
+
},
|
|
50
|
+
user_id: { type: 'string' }
|
|
51
|
+
},
|
|
52
|
+
};
|
|
53
|
+
const example = {
|
|
54
|
+
ecommerce: { items: [{ item_name: 'donuts' }] },
|
|
55
|
+
user_id: '123'
|
|
56
|
+
};
|
|
57
|
+
buildExampleFromSchema.mockReturnValue(example);
|
|
58
|
+
|
|
59
|
+
const { container } = render(<ExampleDataLayer schema={schema} />);
|
|
60
|
+
|
|
61
|
+
expect(buildExampleFromSchema).toHaveBeenCalledWith(schema);
|
|
62
|
+
|
|
63
|
+
const codeElement = container.querySelector('pre');
|
|
64
|
+
expect(codeElement.textContent).toMatchInlineSnapshot(`
|
|
65
|
+
"window.dataLayer.push({
|
|
66
|
+
"ecommerce": null
|
|
67
|
+
});
|
|
68
|
+
window.dataLayer.push({
|
|
69
|
+
"ecommerce": {
|
|
70
|
+
"items": [
|
|
71
|
+
{
|
|
72
|
+
"item_name": "donuts"
|
|
73
|
+
}
|
|
74
|
+
]
|
|
75
|
+
},
|
|
76
|
+
"user_id": "123"
|
|
77
|
+
});"
|
|
78
|
+
`);
|
|
79
|
+
});
|
|
80
|
+
|
|
81
|
+
it('should render correctly with an empty schema', () => {
|
|
82
|
+
const schema = {};
|
|
83
|
+
const example = {};
|
|
84
|
+
buildExampleFromSchema.mockReturnValue(example);
|
|
85
|
+
|
|
86
|
+
const { container } = render(<ExampleDataLayer schema={schema} />);
|
|
87
|
+
|
|
88
|
+
expect(buildExampleFromSchema).toHaveBeenCalledWith(schema);
|
|
89
|
+
const codeElement = container.querySelector('pre');
|
|
90
|
+
expect(codeElement.textContent).toMatchInlineSnapshot(`"window.dataLayer.push({});"`);
|
|
91
|
+
});
|
|
92
|
+
|
|
93
|
+
it('should not reset properties that are not in the final example', () => {
|
|
94
|
+
const schema = {
|
|
95
|
+
type: 'object',
|
|
96
|
+
properties: {
|
|
97
|
+
ecommerce: {
|
|
98
|
+
'x-gtm-clear': true,
|
|
99
|
+
type: 'object',
|
|
100
|
+
properties: { items: { type: 'array' } },
|
|
101
|
+
},
|
|
102
|
+
user_data: {
|
|
103
|
+
'x-gtm-clear': true,
|
|
104
|
+
type: 'object'
|
|
105
|
+
},
|
|
106
|
+
event: { type: 'string' }
|
|
107
|
+
},
|
|
108
|
+
};
|
|
109
|
+
// buildExampleFromSchema will not include user_data because it's an empty object
|
|
110
|
+
const example = {
|
|
111
|
+
ecommerce: { items: [{ item_name: 'donuts' }] },
|
|
112
|
+
event: 'purchase'
|
|
113
|
+
};
|
|
114
|
+
buildExampleFromSchema.mockReturnValue(example);
|
|
115
|
+
|
|
116
|
+
const { container } = render(<ExampleDataLayer schema={schema} />);
|
|
117
|
+
|
|
118
|
+
expect(buildExampleFromSchema).toHaveBeenCalledWith(schema);
|
|
119
|
+
|
|
120
|
+
const codeElement = container.querySelector('pre');
|
|
121
|
+
expect(codeElement.textContent).toMatchInlineSnapshot(`
|
|
122
|
+
"window.dataLayer.push({
|
|
123
|
+
"ecommerce": null
|
|
124
|
+
});
|
|
125
|
+
window.dataLayer.push({
|
|
126
|
+
"ecommerce": {
|
|
127
|
+
"items": [
|
|
128
|
+
{
|
|
129
|
+
"item_name": "donuts"
|
|
130
|
+
}
|
|
131
|
+
]
|
|
132
|
+
},
|
|
133
|
+
"event": "purchase"
|
|
134
|
+
});"
|
|
135
|
+
`);
|
|
136
|
+
});
|
|
137
|
+
});
|
|
138
|
+
|
|
139
|
+
describe('findClearableProperties', () => {
|
|
140
|
+
it('should return an empty array when schema is empty, null, or has no properties', () => {
|
|
141
|
+
expect(findClearableProperties({})).toEqual([]);
|
|
142
|
+
expect(findClearableProperties({ type: 'object' })).toEqual([]);
|
|
143
|
+
expect(findClearableProperties(null)).toEqual([]);
|
|
144
|
+
expect(findClearableProperties(undefined)).toEqual([]);
|
|
145
|
+
});
|
|
146
|
+
|
|
147
|
+
it('should return properties with "x-gtm-clear": true', () => {
|
|
148
|
+
const schema = {
|
|
149
|
+
properties: {
|
|
150
|
+
prop1: { type: 'string' },
|
|
151
|
+
prop2: { 'x-gtm-clear': true, type: 'object' },
|
|
152
|
+
prop3: { 'x-gtm-clear': false, type: 'object' },
|
|
153
|
+
prop4: { 'x-gtm-clear': true, type: 'array' },
|
|
154
|
+
}
|
|
155
|
+
};
|
|
156
|
+
expect(findClearableProperties(schema)).toEqual(['prop2', 'prop4']);
|
|
157
|
+
});
|
|
158
|
+
|
|
159
|
+
it('should return an empty array if no properties have "x-gtm-clear": true', () => {
|
|
160
|
+
const schema = {
|
|
161
|
+
properties: {
|
|
162
|
+
prop1: { type: 'string' },
|
|
163
|
+
prop2: { type: 'object' },
|
|
164
|
+
prop3: { 'x-gtm-clear': false, type: 'object' },
|
|
165
|
+
}
|
|
166
|
+
};
|
|
167
|
+
expect(findClearableProperties(schema)).toEqual([]);
|
|
168
|
+
});
|
|
169
|
+
});
|
|
@@ -0,0 +1,55 @@
|
|
|
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": [
|
|
26
|
+
30.03,
|
|
27
|
+
99.99,
|
|
28
|
+
45.50
|
|
29
|
+
]
|
|
30
|
+
},
|
|
31
|
+
"currency": {
|
|
32
|
+
"type": "string",
|
|
33
|
+
"description": "The currency of the items in ISO 4217 three-letter format. Required when value is set.",
|
|
34
|
+
"examples": [
|
|
35
|
+
"USD",
|
|
36
|
+
"EUR",
|
|
37
|
+
"GBP"
|
|
38
|
+
]
|
|
39
|
+
},
|
|
40
|
+
"items": {
|
|
41
|
+
"type": "array",
|
|
42
|
+
"description": "The products added to the cart.",
|
|
43
|
+
"minItems": 1,
|
|
44
|
+
"items": {
|
|
45
|
+
"$ref": "./components/product.json"
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
},
|
|
49
|
+
"required": [
|
|
50
|
+
"currency",
|
|
51
|
+
"items"
|
|
52
|
+
]
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
}
|
|
@@ -0,0 +1,58 @@
|
|
|
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": [
|
|
29
|
+
"event"
|
|
30
|
+
],
|
|
31
|
+
"$defs": {
|
|
32
|
+
"strictObject": {
|
|
33
|
+
"type": "object",
|
|
34
|
+
"propertyNames": {
|
|
35
|
+
"maxLength": 40,
|
|
36
|
+
"pattern": "^[a-z0-9_]+$"
|
|
37
|
+
},
|
|
38
|
+
"additionalProperties": {
|
|
39
|
+
"anyOf": [
|
|
40
|
+
{
|
|
41
|
+
"$ref": "#/$defs/strictObject"
|
|
42
|
+
},
|
|
43
|
+
{
|
|
44
|
+
"type": "array",
|
|
45
|
+
"items": {
|
|
46
|
+
"$ref": "#/$defs/strictObject"
|
|
47
|
+
}
|
|
48
|
+
},
|
|
49
|
+
{
|
|
50
|
+
"not": {
|
|
51
|
+
"type": "object"
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
]
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
}
|
|
@@ -0,0 +1,211 @@
|
|
|
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": [
|
|
12
|
+
"SKU_12345",
|
|
13
|
+
"PROD_98765"
|
|
14
|
+
]
|
|
15
|
+
},
|
|
16
|
+
"item_name": {
|
|
17
|
+
"type": "string",
|
|
18
|
+
"description": "The name of the item. Either item_id or item_name is required.",
|
|
19
|
+
"examples": [
|
|
20
|
+
"Stan and Friends Tee",
|
|
21
|
+
"Blue Running Shoes"
|
|
22
|
+
]
|
|
23
|
+
},
|
|
24
|
+
"affiliation": {
|
|
25
|
+
"type": "string",
|
|
26
|
+
"description": "A product affiliation to indicate a supplier or store. Note: affiliation is only available at the item level.",
|
|
27
|
+
"examples": [
|
|
28
|
+
"Google Merchandise Store",
|
|
29
|
+
"Nike Store"
|
|
30
|
+
]
|
|
31
|
+
},
|
|
32
|
+
"coupon": {
|
|
33
|
+
"type": "string",
|
|
34
|
+
"description": "The coupon name/code associated with the item. Coupon parameters at event and item levels are independent.",
|
|
35
|
+
"examples": [
|
|
36
|
+
"SUMMER_FUN",
|
|
37
|
+
"WELCOME20",
|
|
38
|
+
"SAVE10"
|
|
39
|
+
]
|
|
40
|
+
},
|
|
41
|
+
"discount": {
|
|
42
|
+
"type": "number",
|
|
43
|
+
"description": "The monetary value of the discount per unit applied to the item.",
|
|
44
|
+
"examples": [
|
|
45
|
+
2.22,
|
|
46
|
+
5.00,
|
|
47
|
+
10.50
|
|
48
|
+
]
|
|
49
|
+
},
|
|
50
|
+
"index": {
|
|
51
|
+
"type": "number",
|
|
52
|
+
"description": "The index or position of the item in a list.",
|
|
53
|
+
"examples": [
|
|
54
|
+
0,
|
|
55
|
+
1,
|
|
56
|
+
2
|
|
57
|
+
]
|
|
58
|
+
},
|
|
59
|
+
"item_brand": {
|
|
60
|
+
"type": "string",
|
|
61
|
+
"description": "The brand of the item.",
|
|
62
|
+
"examples": [
|
|
63
|
+
"Google",
|
|
64
|
+
"Nike",
|
|
65
|
+
"Adidas"
|
|
66
|
+
]
|
|
67
|
+
},
|
|
68
|
+
"item_category": {
|
|
69
|
+
"type": "string",
|
|
70
|
+
"description": "The category of the item. If used as part of a category hierarchy or taxonomy, this is the first category.",
|
|
71
|
+
"examples": [
|
|
72
|
+
"Apparel",
|
|
73
|
+
"Footwear",
|
|
74
|
+
"Electronics"
|
|
75
|
+
]
|
|
76
|
+
},
|
|
77
|
+
"item_category2": {
|
|
78
|
+
"type": "string",
|
|
79
|
+
"description": "The second category hierarchy or additional taxonomy of the item.",
|
|
80
|
+
"examples": [
|
|
81
|
+
"Adult",
|
|
82
|
+
"Women",
|
|
83
|
+
"Men"
|
|
84
|
+
]
|
|
85
|
+
},
|
|
86
|
+
"item_category3": {
|
|
87
|
+
"type": "string",
|
|
88
|
+
"description": "The third category hierarchy or additional taxonomy of the item.",
|
|
89
|
+
"examples": [
|
|
90
|
+
"Shirts",
|
|
91
|
+
"Shoes",
|
|
92
|
+
"Boots"
|
|
93
|
+
]
|
|
94
|
+
},
|
|
95
|
+
"item_category4": {
|
|
96
|
+
"type": "string",
|
|
97
|
+
"description": "The fourth category hierarchy or additional taxonomy of the item.",
|
|
98
|
+
"examples": [
|
|
99
|
+
"Crew",
|
|
100
|
+
"Running",
|
|
101
|
+
"Casual"
|
|
102
|
+
]
|
|
103
|
+
},
|
|
104
|
+
"item_category5": {
|
|
105
|
+
"type": "string",
|
|
106
|
+
"description": "The fifth category hierarchy or additional taxonomy of the item.",
|
|
107
|
+
"examples": [
|
|
108
|
+
"Short sleeve",
|
|
109
|
+
"Long distance",
|
|
110
|
+
"Lightweight"
|
|
111
|
+
]
|
|
112
|
+
},
|
|
113
|
+
"item_list_id": {
|
|
114
|
+
"type": "string",
|
|
115
|
+
"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.",
|
|
116
|
+
"examples": [
|
|
117
|
+
"related_products",
|
|
118
|
+
"search_results",
|
|
119
|
+
"recommendations"
|
|
120
|
+
]
|
|
121
|
+
},
|
|
122
|
+
"item_list_name": {
|
|
123
|
+
"type": "string",
|
|
124
|
+
"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.",
|
|
125
|
+
"examples": [
|
|
126
|
+
"Related Products",
|
|
127
|
+
"Search Results",
|
|
128
|
+
"Recommended Items"
|
|
129
|
+
]
|
|
130
|
+
},
|
|
131
|
+
"item_variant": {
|
|
132
|
+
"type": "string",
|
|
133
|
+
"description": "The item variant or unique code or description for additional item details/options.",
|
|
134
|
+
"examples": [
|
|
135
|
+
"green",
|
|
136
|
+
"Blue Size 10",
|
|
137
|
+
"M-Black"
|
|
138
|
+
]
|
|
139
|
+
},
|
|
140
|
+
"location_id": {
|
|
141
|
+
"type": "string",
|
|
142
|
+
"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.",
|
|
143
|
+
"examples": [
|
|
144
|
+
"ChIJIQBpAG2ahYAR_6128GcTUEo",
|
|
145
|
+
"store_123",
|
|
146
|
+
"location_sf"
|
|
147
|
+
]
|
|
148
|
+
},
|
|
149
|
+
"price": {
|
|
150
|
+
"type": "number",
|
|
151
|
+
"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.",
|
|
152
|
+
"examples": [
|
|
153
|
+
10.01,
|
|
154
|
+
21.01,
|
|
155
|
+
89.99
|
|
156
|
+
]
|
|
157
|
+
},
|
|
158
|
+
"quantity": {
|
|
159
|
+
"type": "number",
|
|
160
|
+
"description": "The item quantity. If not set, quantity is set to 1.",
|
|
161
|
+
"examples": [
|
|
162
|
+
1,
|
|
163
|
+
2,
|
|
164
|
+
3
|
|
165
|
+
]
|
|
166
|
+
},
|
|
167
|
+
"promotion_id": {
|
|
168
|
+
"type": "string",
|
|
169
|
+
"description": "The ID of the promotion associated with the item.",
|
|
170
|
+
"examples": [
|
|
171
|
+
"P_12345",
|
|
172
|
+
"PROMO_001"
|
|
173
|
+
]
|
|
174
|
+
},
|
|
175
|
+
"promotion_name": {
|
|
176
|
+
"type": "string",
|
|
177
|
+
"description": "The name of the promotion associated with the item.",
|
|
178
|
+
"examples": [
|
|
179
|
+
"Summer Sale",
|
|
180
|
+
"Black Friday",
|
|
181
|
+
"Flash Deal"
|
|
182
|
+
]
|
|
183
|
+
},
|
|
184
|
+
"creative_name": {
|
|
185
|
+
"type": "string",
|
|
186
|
+
"description": "The name of the promotion creative.",
|
|
187
|
+
"examples": [
|
|
188
|
+
"summer_banner2",
|
|
189
|
+
"holiday_email_v1"
|
|
190
|
+
]
|
|
191
|
+
},
|
|
192
|
+
"creative_slot": {
|
|
193
|
+
"type": "string",
|
|
194
|
+
"description": "The name of the creative slot associated with the item.",
|
|
195
|
+
"examples": [
|
|
196
|
+
"featured_app_1",
|
|
197
|
+
"top_banner",
|
|
198
|
+
"sidebar"
|
|
199
|
+
]
|
|
200
|
+
},
|
|
201
|
+
"google_business_vertical": {
|
|
202
|
+
"type": "string",
|
|
203
|
+
"description": "The business vertical for the item (e.g., 'retail').",
|
|
204
|
+
"examples": [
|
|
205
|
+
"retail",
|
|
206
|
+
"ecommerce"
|
|
207
|
+
]
|
|
208
|
+
}
|
|
209
|
+
},
|
|
210
|
+
"required": []
|
|
211
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
3
|
+
"$id": "main-schema-with-missing-ref",
|
|
4
|
+
"title": "Main Schema with Missing Ref",
|
|
5
|
+
"type": "object",
|
|
6
|
+
"properties": { "component": { "$ref": "non-existent-component.json" } },
|
|
7
|
+
"required": ["component"]
|
|
8
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
3
|
+
"$id": "no-valid-example-schema",
|
|
4
|
+
"title": "No Valid Example Schema",
|
|
5
|
+
"type": "object",
|
|
6
|
+
"properties": {
|
|
7
|
+
"some_prop": {
|
|
8
|
+
"description": "This property has no type or example, so it won't be in the generated example."
|
|
9
|
+
}
|
|
10
|
+
},
|
|
11
|
+
"required": ["some_prop"]
|
|
12
|
+
}
|