Skip to content

Commit b682d80

Browse files
1st stab at API reference for batch (#279)
* 1st stab at API reference for batch * adding more schemas * Update openapi.yaml * more updates * getting near done * small fixes * adding a todo * fix misplaced edit * Update openapi.yaml * Update openapi.yaml Co-authored-by: Pawel Szczodruch <[email protected]>
1 parent bef6617 commit b682d80

File tree

1 file changed

+140
-0
lines changed

1 file changed

+140
-0
lines changed

api/openapi-spec/openapi.yaml

Lines changed: 140 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,24 @@ paths:
109109
$ref: '#/components/responses/UnauthorizedToken'
110110
requestBody:
111111
$ref: '#/components/requestBodies/TokenContext'
112+
/v1/batch:
113+
post:
114+
summary: Batch multiple API endpoints into one request.
115+
description: |
116+
You can use the Batch endpoint to do things like
117+
1. Make activate decisions for a batch of users in a short timeframe for testing purposes
118+
2. Gather responses from a bunch of activate calls into one response for comparison or analysis
119+
responses:
120+
121+
'200':
122+
$ref: '#/components/responses/BatchResponse'
123+
'400':
124+
description: Bad request, invalid parameters.
125+
'422':
126+
description: Unprocessable Entity, too many operations
127+
requestBody:
128+
$ref: '#/components/requestBodies/BatchContext'
129+
112130
components:
113131
parameters:
114132
disableTrackingParam:
@@ -183,6 +201,12 @@ components:
183201
application/json:
184202
schema:
185203
$ref: '#/components/schemas/TokenContext'
204+
BatchContext:
205+
required: true
206+
content:
207+
application/json:
208+
schema:
209+
$ref: '#/components/schemas/BatchContext'
186210
responses:
187211
Forbidden:
188212
description: You do not have necessary permissions for the resource
@@ -196,6 +220,12 @@ components:
196220
application/json:
197221
schema:
198222
$ref: '#/components/schemas/TokenError'
223+
BatchResponse:
224+
description: responses for each endpoint called in the batch request
225+
content:
226+
application/json:
227+
schema:
228+
$ref: '#/components/schemas/BatchResponse'
199229
schemas:
200230
Error:
201231
properties:
@@ -340,6 +370,116 @@ components:
340370
type: string
341371
client_secret:
342372
type: string
373+
BatchContext:
374+
properties:
375+
operations:
376+
type: array
377+
items:
378+
$ref: '#/components/schemas/BatchOperation'
379+
required:
380+
- operations
381+
382+
BatchOperation:
383+
properties:
384+
method:
385+
type: string
386+
enum:
387+
- GET
388+
- POST
389+
url:
390+
type: string
391+
operationID:
392+
type: string
393+
body:
394+
type: object
395+
parameters:
396+
type: object
397+
headers:
398+
type: object
399+
example:
400+
method: "GET"
401+
url: "/v1/config"
402+
operationID: 1
403+
body: {}
404+
parameters: {}
405+
headers: {"X-Optimizely-SDK-Key": "<sdk_key>"}
406+
407+
BatchResponse:
408+
properties:
409+
startedAt:
410+
type: string
411+
endedAt:
412+
type: string
413+
errorCount:
414+
type: integer
415+
response:
416+
type: array
417+
items:
418+
$ref: '#/components/schemas/BatchResponseItem'
419+
420+
BatchResponseItem:
421+
properties:
422+
status:
423+
type: integer
424+
enum:
425+
- 200
426+
- 400
427+
requestID:
428+
type: string
429+
operationID:
430+
type: string
431+
method:
432+
type: string
433+
enum:
434+
- GET
435+
- POST
436+
url:
437+
type: string
438+
body:
439+
type: object
440+
startedAt:
441+
type: string
442+
endedAt:
443+
type: string
444+
445+
example:
446+
status: 200
447+
requestID: "abee6bdf-6d14-4fac-8357-769f5fd07e7c"
448+
operationID: "1"
449+
method: POST
450+
url: "/v1/activate"
451+
body: [
452+
{
453+
"enabled": true,
454+
"experimentKey": "new_feature_test",
455+
"featureKey": "new_feature",
456+
"type": "feature",
457+
"userId": "user1",
458+
"variables": {
459+
"bool_var": true,
460+
"double_var": 5.6,
461+
"int_var": 1,
462+
},
463+
"variationKey": "variation_2"
464+
},
465+
466+
{
467+
"enabled": false,
468+
"experimentKey": "flag_test_2",
469+
"featureKey": "test_feature",
470+
"type": "feature",
471+
"userId": "user1",
472+
"variables": {
473+
"double": 0,
474+
"json_key": {}
475+
},
476+
"variationKey": ""
477+
}
478+
]
479+
480+
startedAt: "2020-09-10T10:50:37.466121-07:00"
481+
endedAt: "2020-09-10T10:50:37.466192-07:00"
482+
343483
securitySchemes:
344484
SdkKeyAuth:
345485
in: header

0 commit comments

Comments
 (0)