From 8c49a65eddab1f1308fa44bd3e9f6ed4c9b2f7b8 Mon Sep 17 00:00:00 2001 From: fscelliott <42477011+fscelliott@users.noreply.github.com> Date: Mon, 21 Sep 2020 11:30:32 -0600 Subject: [PATCH 01/10] 1st stab at API reference for batch --- api/openapi-spec/openapi.yaml | 38 ++++++++++++++++++++++++++++++++++- 1 file changed, 37 insertions(+), 1 deletion(-) diff --git a/api/openapi-spec/openapi.yaml b/api/openapi-spec/openapi.yaml index 252f21cf..b9497e2c 100644 --- a/api/openapi-spec/openapi.yaml +++ b/api/openapi-spec/openapi.yaml @@ -103,12 +103,29 @@ paths: description: Generates valid JWT token for grant_type, client_id, and client_secret, using the values you pass in the request body. Configure expiration time and SDK keys (to which the token grants access) in Optimizely config. responses: '200': - description: Generates a valid token + description: Valid response '401': description: Unauthorized, invalid values for parameter(s) $ref: '#/components/responses/UnauthorizedToken' requestBody: $ref: '#/components/requestBodies/TokenContext' + /v1/batch: + post: + summary: Batch multiple API endpoints into one request. + operationId: TODO + description: + responses: | + You can use the Batch endpoint to do things like: + - Make activate decisions for a batch of users in a short timeframe for testing purposes + - Gather responses from a bunch of activate calls into one response for comparison or analysis + + '200': + description: Generates a valid token. TODO + '400': + description: Bad request, invalid parameters. TODO + requestBody: + $ref: '#/components/requestBodies/Batch' + components: parameters: disableTrackingParam: @@ -340,6 +357,25 @@ components: type: string client_secret: type: string + Batch: + properties: + operations: + method: + type: string + enum: + - GET + - POST + url: + type: string + operationID: + type: string + body: + type: object + parameters: + type: object + headers: + type: string + securitySchemes: SdkKeyAuth: in: header From ae1cb5394765dee7ac35e013a82ef2e1168d4a4b Mon Sep 17 00:00:00 2001 From: fscelliott <42477011+fscelliott@users.noreply.github.com> Date: Mon, 21 Sep 2020 13:08:37 -0600 Subject: [PATCH 02/10] adding more schemas --- api/openapi-spec/openapi.yaml | 83 +++++++++++++++++++++++++---------- 1 file changed, 61 insertions(+), 22 deletions(-) diff --git a/api/openapi-spec/openapi.yaml b/api/openapi-spec/openapi.yaml index b9497e2c..e1554ba3 100644 --- a/api/openapi-spec/openapi.yaml +++ b/api/openapi-spec/openapi.yaml @@ -113,18 +113,18 @@ paths: post: summary: Batch multiple API endpoints into one request. operationId: TODO - description: - responses: | - You can use the Batch endpoint to do things like: - - Make activate decisions for a batch of users in a short timeframe for testing purposes - - Gather responses from a bunch of activate calls into one response for comparison or analysis + description: | + You can use the Batch endpoint to do things like + Make activate decisions for a batch of users in a short timeframe for testing purposes + Gather responses from a bunch of activate calls into one response for comparison or analysis + responses: '200': description: Generates a valid token. TODO '400': description: Bad request, invalid parameters. TODO requestBody: - $ref: '#/components/requestBodies/Batch' + $ref: '#/components/requestBodies/BatchContext' components: parameters: @@ -200,6 +200,12 @@ components: application/json: schema: $ref: '#/components/schemas/TokenContext' + BatchContext: + required: true + content: + application/json: + schema: + $ref: '#/components/schemas/BatchContext' responses: Forbidden: description: You do not have necessary permissions for the resource @@ -213,6 +219,12 @@ components: application/json: schema: $ref: '#/components/schemas/TokenError' + BatchResponse: + description: responses for each endpoint called in the batch request + content: + application/json: + schema: + $ref: '#/components/schemas/BatchResponse' schemas: Error: properties: @@ -357,25 +369,52 @@ components: type: string client_secret: type: string - Batch: + BatchContext: properties: - operations: - method: - type: string - enum: - - GET - - POST - url: - type: string - operationID: - type: string - body: + operations: type: object - parameters: - type: object - headers: - type: string + additionalProperties: + method: + type: string + enum: + - GET + - POST + url: + type: string + operationID: + type: string + body: + type: object + parameters: + type: object + headers: + type: string + BatchResponse: + properties: + response: + type: object + additionalProperties: + status: + type: string + requestID: + type: string + operationID: + type: string + method: + type: string + enum: + - GET + - POST + - wrong_method + url: + type: string + body: + type: object + startedAt: + type: string + endedAt: + type: string securitySchemes: SdkKeyAuth: in: header From ac0674d93cb8a310872596b1c14a62f1474baef3 Mon Sep 17 00:00:00 2001 From: fscelliott <42477011+fscelliott@users.noreply.github.com> Date: Mon, 21 Sep 2020 14:06:03 -0600 Subject: [PATCH 03/10] Update openapi.yaml --- api/openapi-spec/openapi.yaml | 128 ++++++++++++++++++++++------------ 1 file changed, 82 insertions(+), 46 deletions(-) diff --git a/api/openapi-spec/openapi.yaml b/api/openapi-spec/openapi.yaml index e1554ba3..e6c5f4bc 100644 --- a/api/openapi-spec/openapi.yaml +++ b/api/openapi-spec/openapi.yaml @@ -114,13 +114,13 @@ paths: summary: Batch multiple API endpoints into one request. operationId: TODO description: | - You can use the Batch endpoint to do things like - Make activate decisions for a batch of users in a short timeframe for testing purposes - Gather responses from a bunch of activate calls into one response for comparison or analysis + You can use the Batch endpoint to do things like + 1. Make activate decisions for a batch of users in a short timeframe for testing purposes + 2. Gather responses from a bunch of activate calls into one response for comparison or analysis responses: '200': - description: Generates a valid token. TODO + $ref: '#/components/responses/BatchResponse' '400': description: Bad request, invalid parameters. TODO requestBody: @@ -223,8 +223,8 @@ components: description: responses for each endpoint called in the batch request content: application/json: - schema: - $ref: '#/components/schemas/BatchResponse' + schema: + $ref: '#/components/schemas/BatchResponse' schemas: Error: properties: @@ -372,49 +372,85 @@ components: BatchContext: properties: operations: - type: object - additionalProperties: - method: - type: string - enum: - - GET - - POST - url: - type: string - operationID: - type: string - body: - type: object - parameters: - type: object - headers: - type: string + type: array + items: + $ref: '#/components/schemas/BatchOperation' + required: + - operations + + BatchOperation: + properties: + method: + type: string + enum: + - GET + - POST + url: + type: string + operationID: + type: string + body: + type: object + parameters: + type: object + headers: + type: object + example: + method: "GET" + url: "/v1/config" + operationID: 1 + body: {} + parameters: {} + headers: {"X-Optimizely-SDK-Key": ""} + BatchResponse: properties: + startedAt: + type: string + endedAt: + type: string + errorCount: + type: integer + response: + type: array + items: + $ref: '#/components/schemas/BatchResponseItem' + + BatchResponseItem: + properties: + status: + type: int + enums: + - 200 + - 401 + requestID: + type: string + operationID: + type: string + method: + type: string + enum: + - GET + - POST + - wrong_method + url: + type: string + body: + type: object + startedAt: + type: string + endedAt: + + example: + status: 200 + requestID: "asdf" + operationID: "asdf" + method: POST + url: "/v1/activate" + body: {} + startedAt: "2020-09-10T10:50:37.466121-07:00" + endedAt: "2020-09-10T10:50:37.466192-07:00" - response: - type: object - additionalProperties: - status: - type: string - requestID: - type: string - operationID: - type: string - method: - type: string - enum: - - GET - - POST - - wrong_method - url: - type: string - body: - type: object - startedAt: - type: string - endedAt: - type: string securitySchemes: SdkKeyAuth: in: header From 7771b9fae5f2a68447a6290af01f5a85977c09ba Mon Sep 17 00:00:00 2001 From: fscelliott <42477011+fscelliott@users.noreply.github.com> Date: Mon, 21 Sep 2020 14:21:02 -0600 Subject: [PATCH 04/10] more updates --- api/openapi-spec/openapi.yaml | 40 +++++++++++++++++++++++++++++------ 1 file changed, 34 insertions(+), 6 deletions(-) diff --git a/api/openapi-spec/openapi.yaml b/api/openapi-spec/openapi.yaml index e6c5f4bc..4b7b0f70 100644 --- a/api/openapi-spec/openapi.yaml +++ b/api/openapi-spec/openapi.yaml @@ -415,12 +415,12 @@ components: type: array items: $ref: '#/components/schemas/BatchResponseItem' - + BatchResponseItem: properties: status: - type: int - enums: + type: integer + enum: - 200 - 401 requestID: @@ -440,14 +440,42 @@ components: startedAt: type: string endedAt: + type: string example: status: 200 - requestID: "asdf" - operationID: "asdf" + requestID: "abee6bdf-6d14-4fac-8357-769f5fd07e7c" + operationID: "1" method: POST url: "/v1/activate" - body: {} + body: [ + { + "enabled": true, + "experimentKey": "new_feature_test", + "featureKey": "new_feature", + "type": "feature", + "userId": "user1", + "variables": { + "flag": true, + "variable_key": "{\"var\": 34, \"var1\": 100.23}" + }, + "variationKey": "variation_2" + }, + + { + "enabled": false, + "experimentKey": "", + "featureKey": "jira_feature", + "type": "feature", + "userId": "user1", + "variables": { + "double": 0, + "json_key": {} + }, + "variationKey": "" + } + ] + startedAt: "2020-09-10T10:50:37.466121-07:00" endedAt: "2020-09-10T10:50:37.466192-07:00" From f5d01858a00fa0760bcf91a47e6fcb259e7b0e4d Mon Sep 17 00:00:00 2001 From: fscelliott <42477011+fscelliott@users.noreply.github.com> Date: Mon, 21 Sep 2020 14:31:08 -0600 Subject: [PATCH 05/10] getting near done --- api/openapi-spec/openapi.yaml | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/api/openapi-spec/openapi.yaml b/api/openapi-spec/openapi.yaml index 4b7b0f70..d898b4f4 100644 --- a/api/openapi-spec/openapi.yaml +++ b/api/openapi-spec/openapi.yaml @@ -456,16 +456,17 @@ components: "type": "feature", "userId": "user1", "variables": { - "flag": true, - "variable_key": "{\"var\": 34, \"var1\": 100.23}" + "bool_var": true, + "double_var": 5.6, + "int_var": 1, }, "variationKey": "variation_2" }, { "enabled": false, - "experimentKey": "", - "featureKey": "jira_feature", + "experimentKey": "flag_test_2", + "featureKey": "test_feature", "type": "feature", "userId": "user1", "variables": { From 9ea8915582dd93dd33f95259017fc3428d7a4929 Mon Sep 17 00:00:00 2001 From: fscelliott <42477011+fscelliott@users.noreply.github.com> Date: Mon, 21 Sep 2020 15:14:28 -0600 Subject: [PATCH 06/10] small fixes --- api/openapi-spec/openapi.yaml | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/api/openapi-spec/openapi.yaml b/api/openapi-spec/openapi.yaml index d898b4f4..d127c1f5 100644 --- a/api/openapi-spec/openapi.yaml +++ b/api/openapi-spec/openapi.yaml @@ -18,7 +18,7 @@ paths: description: Return all available experiment and features definitions for this environment. responses: '200': - description: Valid response + description: Generates a valid token content: application/json: schema: @@ -112,7 +112,6 @@ paths: /v1/batch: post: summary: Batch multiple API endpoints into one request. - operationId: TODO description: | You can use the Batch endpoint to do things like 1. Make activate decisions for a batch of users in a short timeframe for testing purposes @@ -122,7 +121,7 @@ paths: '200': $ref: '#/components/responses/BatchResponse' '400': - description: Bad request, invalid parameters. TODO + description: Bad request, invalid parameters. TODO pawel please fill in error respones requestBody: $ref: '#/components/requestBodies/BatchContext' @@ -371,10 +370,10 @@ components: type: string BatchContext: properties: - operations: - type: array - items: - $ref: '#/components/schemas/BatchOperation' + operations: + type: array + items: + $ref: '#/components/schemas/BatchOperation' required: - operations From 3cc4a033a547ec0264b7ce34f9493d0b60296325 Mon Sep 17 00:00:00 2001 From: fscelliott <42477011+fscelliott@users.noreply.github.com> Date: Mon, 21 Sep 2020 15:15:45 -0600 Subject: [PATCH 07/10] adding a todo --- api/openapi-spec/openapi.yaml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/api/openapi-spec/openapi.yaml b/api/openapi-spec/openapi.yaml index d127c1f5..ed451a25 100644 --- a/api/openapi-spec/openapi.yaml +++ b/api/openapi-spec/openapi.yaml @@ -419,8 +419,9 @@ components: properties: status: type: integer + #TODO: PAWEL please add whatever codes are necessary enum: - - 200 + - 200 - 401 requestID: type: string From 84600fb90523da9655ddc9dd472f409e187fd238 Mon Sep 17 00:00:00 2001 From: fscelliott <42477011+fscelliott@users.noreply.github.com> Date: Mon, 21 Sep 2020 15:17:28 -0600 Subject: [PATCH 08/10] fix misplaced edit --- api/openapi-spec/openapi.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/api/openapi-spec/openapi.yaml b/api/openapi-spec/openapi.yaml index ed451a25..dcbe22bb 100644 --- a/api/openapi-spec/openapi.yaml +++ b/api/openapi-spec/openapi.yaml @@ -18,7 +18,7 @@ paths: description: Return all available experiment and features definitions for this environment. responses: '200': - description: Generates a valid token + description: Valid response content: application/json: schema: @@ -103,7 +103,7 @@ paths: description: Generates valid JWT token for grant_type, client_id, and client_secret, using the values you pass in the request body. Configure expiration time and SDK keys (to which the token grants access) in Optimizely config. responses: '200': - description: Valid response + description: Generates a valid token '401': description: Unauthorized, invalid values for parameter(s) $ref: '#/components/responses/UnauthorizedToken' From cbb566b2b07ac259bec68514301b86b6038c721c Mon Sep 17 00:00:00 2001 From: Pawel Szczodruch <44238966+pawels-optimizely@users.noreply.github.com> Date: Mon, 21 Sep 2020 15:10:23 -0700 Subject: [PATCH 09/10] Update openapi.yaml --- api/openapi-spec/openapi.yaml | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/api/openapi-spec/openapi.yaml b/api/openapi-spec/openapi.yaml index dcbe22bb..09486236 100644 --- a/api/openapi-spec/openapi.yaml +++ b/api/openapi-spec/openapi.yaml @@ -121,7 +121,9 @@ paths: '200': $ref: '#/components/responses/BatchResponse' '400': - description: Bad request, invalid parameters. TODO pawel please fill in error respones + description: Bad request, invalid parameters. + '422': + description: Unprocessable Entity, too many operations requestBody: $ref: '#/components/requestBodies/BatchContext' @@ -419,10 +421,9 @@ components: properties: status: type: integer - #TODO: PAWEL please add whatever codes are necessary enum: - 200 - - 401 + - 400 requestID: type: string operationID: From 3be83bd6c5fc5215dd44537ad635f6795eed222f Mon Sep 17 00:00:00 2001 From: Pawel Szczodruch <44238966+pawels-optimizely@users.noreply.github.com> Date: Mon, 21 Sep 2020 15:10:57 -0700 Subject: [PATCH 10/10] Update openapi.yaml --- api/openapi-spec/openapi.yaml | 1 - 1 file changed, 1 deletion(-) diff --git a/api/openapi-spec/openapi.yaml b/api/openapi-spec/openapi.yaml index 09486236..42bb7545 100644 --- a/api/openapi-spec/openapi.yaml +++ b/api/openapi-spec/openapi.yaml @@ -433,7 +433,6 @@ components: enum: - GET - POST - - wrong_method url: type: string body: