Skip to content

Commit 042709b

Browse files
committed
Adding a schema-additions.json file to append elements to the schema rather than replace
1 parent 6b3f20f commit 042709b

4 files changed

Lines changed: 72 additions & 203 deletions

File tree

resources/schema-additions.json

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
{
2+
"us": {
3+
"mp": {
4+
"orders": {
5+
"paths": {
6+
"\/v3\/orders": {
7+
"get": {
8+
"parameters": [
9+
{
10+
"name": "hasMoreElements",
11+
"in": "query",
12+
"description": "hasMoreElements",
13+
"required": false,
14+
"schema": {
15+
"type": "string"
16+
}
17+
},
18+
{
19+
"name": "soIndex",
20+
"in": "query",
21+
"description": "Sales order index. This should only be populated from a next token",
22+
"required": false,
23+
"schema": {
24+
"type": "string"
25+
}
26+
},
27+
{
28+
"name": "poIndex",
29+
"in": "query",
30+
"description": "Purchase order index. This should only be populated from a next token",
31+
"required": false,
32+
"schema": {
33+
"type": "string"
34+
}
35+
},
36+
{
37+
"name": "partnerId",
38+
"in": "query",
39+
"description": "partnerId",
40+
"required": false,
41+
"schema": {
42+
"type": "string"
43+
}
44+
},
45+
{
46+
"name": "sellerId",
47+
"in": "query",
48+
"description": "sellerId",
49+
"required": false,
50+
"schema": {
51+
"type": "string"
52+
}
53+
}
54+
]
55+
}
56+
}
57+
}
58+
}
59+
}
60+
}
61+
}

resources/schema-corrections.json

Lines changed: 0 additions & 203 deletions
Original file line numberDiff line numberDiff line change
@@ -20,209 +20,6 @@
2020
}
2121
},
2222
"schemas": {}
23-
},
24-
"orders": {
25-
"paths": {
26-
"\/v3\/orders": {
27-
"get": {
28-
"parameters": [
29-
{
30-
"name": "sku",
31-
"in": "query",
32-
"description": "A seller-provided Product ID",
33-
"required": false,
34-
"schema": {
35-
"type": "string"
36-
}
37-
},
38-
{
39-
"name": "customerOrderId",
40-
"in": "query",
41-
"description": "The customer order ID",
42-
"required": false,
43-
"schema": {
44-
"type": "string"
45-
}
46-
},
47-
{
48-
"name": "purchaseOrderId",
49-
"in": "query",
50-
"description": "The purchase order ID. One customer may have multiple purchase orders.",
51-
"required": false,
52-
"schema": {
53-
"type": "string"
54-
}
55-
},
56-
{
57-
"name": "status",
58-
"in": "query",
59-
"description": "Status of purchase order line. Valid statuses are: Created, Acknowledged, Shipped, Delivered and Cancelled.",
60-
"required": false,
61-
"schema": {
62-
"type": "string"
63-
}
64-
},
65-
{
66-
"name": "createdStartDate",
67-
"in": "query",
68-
"description": "Fetches all purchase orders that were created after this date. Default is current date - 7 days. Use either UTC or ISO 8601 formats. Date example: '2020-03-16'(yyyy-MM-dd). Date with Timestamp example: '2020-03-16T10:30:15Z'(yyyy-MM-dd'T'HH:mm:ssZ).",
69-
"required": false,
70-
"schema": {
71-
"type": "string"
72-
}
73-
},
74-
{
75-
"name": "createdEndDate",
76-
"in": "query",
77-
"description": "Fetches all purchase orders that were created before this date. Default is current date. Use either UTC or ISO 8601 formats. Date example: '2020-03-16'(yyyy-MM-dd). Date with Timestamp example: '2020-03-16T10:30:15Z'(yyyy-MM-dd'T'HH:mm:ssZ).",
78-
"required": false,
79-
"schema": {
80-
"type": "string"
81-
}
82-
},
83-
{
84-
"name": "fromExpectedShipDate",
85-
"in": "query",
86-
"description": "Fetches all purchase orders that have order lines with an expected ship date after this date. Use either UTC or ISO 8601 formats. Date example: '2020-03-16'(yyyy-MM-dd). Date with Timestamp example: '2020-03-16T10:30:15Z'(yyyy-MM-dd'T'HH:mm:ssZ)",
87-
"required": false,
88-
"schema": {
89-
"type": "string"
90-
}
91-
},
92-
{
93-
"name": "toExpectedShipDate",
94-
"in": "query",
95-
"description": "Fetches all purchase orders that have order lines with an expected ship date before this date. Use either UTC or ISO 8601 formats. Date example: '2020-03-16'(yyyy-MM-dd). Date with Timestamp example: '2020-03-16T10:30:15Z'(yyyy-MM-dd'T'HH:mm:ssZ)",
96-
"required": false,
97-
"schema": {
98-
"type": "string"
99-
}
100-
},
101-
{
102-
"name": "lastModifiedStartDate",
103-
"in": "query",
104-
"description": "Fetches all purchase orders that were modified after this date. Use either UTC or ISO 8601 formats. Date example: '2020-03-16'(yyyy-MM-dd). Date with Timestamp example: '2020-03-16T10:30:15Z'(yyyy-MM-dd'T'HH:mm:ssZ).",
105-
"required": false,
106-
"schema": {
107-
"type": "string"
108-
}
109-
},
110-
{
111-
"name": "lastModifiedEndDate",
112-
"in": "query",
113-
"description": "Fetches all purchase orders that were modified before this date. Use either UTC or ISO 8601 formats. Date example: '2020-03-16'(yyyy-MM-dd). Date with Timestamp example: '2020-03-16T10:30:15Z'(yyyy-MM-dd'T'HH:mm:ssZ).",
114-
"required": false,
115-
"schema": {
116-
"type": "string"
117-
}
118-
},
119-
{
120-
"name": "limit",
121-
"in": "query",
122-
"description": "The number of orders to be returned. Cannot be larger than 200.",
123-
"required": false,
124-
"schema": {
125-
"type": "string",
126-
"default": "100"
127-
}
128-
},
129-
{
130-
"name": "productInfo",
131-
"in": "query",
132-
"description": "Provides the image URL and product weight in response, if available. Allowed values are true or false.",
133-
"required": false,
134-
"schema": {
135-
"type": "string",
136-
"default": "false"
137-
}
138-
},
139-
{
140-
"name": "shipNodeType",
141-
"in": "query",
142-
"description": "Specifies the type of shipNode. Allowed values are SellerFulfilled(Default), WFSFulfilled and 3PLFulfilled.",
143-
"required": false,
144-
"schema": {
145-
"type": "string",
146-
"default": "SellerFulfilled"
147-
}
148-
},
149-
{
150-
"name": "shippingProgramType",
151-
"in": "query",
152-
"description": "Specifies the type of program. Allowed value is TWO_DAY.",
153-
"required": false,
154-
"schema": {
155-
"type": "string"
156-
}
157-
},
158-
{
159-
"name": "replacementInfo",
160-
"in": "query",
161-
"description": "Provides additional attributes - originalCustomerOrderID, orderType - related to Replacement order, in response, if available. Allowed values are true or false.",
162-
"required": false,
163-
"schema": {
164-
"type": "string",
165-
"default": "false"
166-
}
167-
},
168-
{
169-
"name": "orderType",
170-
"in": "query",
171-
"description": "Specifies if the order is a regular order or replacement order. Possible values are REGULAR or REPLACEMENT. Provided in response only if query parameter replacementInfo=true.",
172-
"required": false,
173-
"schema": {
174-
"type": "string"
175-
}
176-
},
177-
{
178-
"name": "hasMoreElements",
179-
"in": "query",
180-
"description": "hasMoreElements",
181-
"required": false,
182-
"schema": {
183-
"type": "string"
184-
}
185-
},
186-
{
187-
"name": "soIndex",
188-
"in": "query",
189-
"description": "Sales order index. This should only be populated from a next token",
190-
"required": false,
191-
"schema": {
192-
"type": "string"
193-
}
194-
},
195-
{
196-
"name": "poIndex",
197-
"in": "query",
198-
"description": "Purchase order index. This should only be populated from a next token",
199-
"required": false,
200-
"schema": {
201-
"type": "string"
202-
}
203-
},
204-
{
205-
"name": "partnerId",
206-
"in": "query",
207-
"description": "partnerId",
208-
"required": false,
209-
"schema": {
210-
"type": "string"
211-
}
212-
},
213-
{
214-
"name": "sellerId",
215-
"in": "query",
216-
"description": "sellerId",
217-
"required": false,
218-
"schema": {
219-
"type": "string"
220-
}
221-
}
222-
]
223-
}
224-
}
225-
}
22623
}
22724
}
22825
}

utils/constants.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414

1515
const LOGFILE = __DIR__ . '/../generate.log';
1616
const SCHEMA_FIXES_FILE = RESOURCE_DIR . '/schema-corrections.json';
17+
const SCHEMA_ADDITIONS_FILE = RESOURCE_DIR . '/schema-additions.json';
1718

1819
const ACCESS_TOKEN_HEADER = 'WM_SEC.ACCESS_TOKEN';
1920
const AUTH_SIG_HEADER = 'WM_SEC.AUTH_SIGNATURE';

utils/customize-schemas.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -456,6 +456,16 @@ function fixSchema(array $schema, string $country, string $category, string $cod
456456
);
457457
}
458458

459+
$allAdditions = json_decode(file_get_contents(SCHEMA_ADDITIONS_FILE), true);
460+
$additions = $allAdditions[$country][$category][$code] ?? [];
461+
462+
if (isset($additions['paths'])) {
463+
$schema['paths'] = array_merge_recursive(
464+
$schema['paths'],
465+
$additions['paths']
466+
);
467+
}
468+
459469
return $schema;
460470
}
461471

0 commit comments

Comments
 (0)