Hey! I'm new toopenapi-python-client. I recently generated the ConfigCat Public Management API viauvx openapi-python-client generate using thisjson file provided by ConfigCat. The ProblemLooking through the generated code, found some issues like the python snippet below from fileupdate_setting_value_v2.py: - The arg
body is a union of two exact same types - The line
if isinstance(body, list["JsonPatchOperation"]) isn't correct python (see relevant PEPhere), it should be something likeif isinstance(body, list) and all(isinstance(item, JsonPatchOperation) for item in body)
What might be causing this? Any pointers would be greatly appreciated, thank you 🙏 def_get_kwargs(environment_id:UUID,setting_id:int,*,body:Union[list["JsonPatchOperation"],list["JsonPatchOperation"], ],reason:Union[Unset,str]=UNSET,)->dict[str,Any]:headers:dict[str,Any]= {}params:dict[str,Any]= {}params["reason"]=reasonparams= {k:vfork,vinparams.items()ifvisnotUNSETandvisnotNone}_kwargs:dict[str,Any]= {"method":"patch","url":f"/v1/environments/{environment_id}/settings/{setting_id}/value","params":params, }ifisinstance(body,list["JsonPatchOperation"]):_json_body= []forbody_item_datainbody:body_item=body_item_data.to_dict()_json_body.append(body_item)_kwargs["json"]=_json_bodyheaders["Content-Type"]="application/json"ifisinstance(body,list["JsonPatchOperation"]):_json_body= []forbody_item_datainbody:body_item=body_item_data.to_dict()_json_body.append(body_item)_kwargs["json"]=_json_bodyheaders["Content-Type"]="application/*+json"_kwargs["headers"]=headersreturn_kwargsExtra Infouv version: 0.4.6
The section in ConfigCat json linked above that's relevant to the code snippet"patch": { "tags": [ "Feature Flag & Setting values V2" ], "summary": "Update value", "description": "This endpoint updates the value of a Feature Flag or Setting\nwith a collection of [JSON Patch](https://jsonpatch.com) operations in a specified Environment.\n\nOnly the `defaultValue`, `targetingRules`, and `percentageEvaluationAttribute` fields are modifiable by this endpoint.\n\nThe advantage of using JSON Patch is that you can describe individual update operations on a resource\nwithout touching attributes that you don't want to change. It supports collection reordering, so it also\ncan be used for reordering the targeting rules of a Feature Flag or Setting.\n\nFor example: We have the following resource of a Feature Flag.\n```json\n{\n \"defaultValue\": {\n \"boolValue\": false\n },\n \"targetingRules\": [\n {\n \"conditions\": [\n {\n \"userCondition\": {\n \"comparisonAttribute\": \"Email\",\n \"comparator\": \"sensitiveTextEquals\",\n \"comparisonValue\": {\n \"stringValue\": \"test@example.com\"\n }\n }\n }\n ],\n \"percentageOptions\": [],\n \"value\": {\n \"boolValue\": true\n }\n }\n ]\n}\n```\nIf we send an update request body as below:\n```json\n[\n {\n \"op\": \"replace\",\n \"path\": \"/targetingRules/0/value/boolValue\",\n \"value\": true\n }\n]\n```\nOnly the first Targeting Rule's `value` is going to be set to `false` and all the other fields are remaining unchanged.\n\nSo we get a response like this:\n```json\n{\n \"defaultValue\": {\n \"boolValue\": false\n },\n \"targetingRules\": [\n {\n \"conditions\": [\n {\n \"userCondition\": {\n \"comparisonAttribute\": \"Email\",\n \"comparator\": \"sensitiveTextEquals\",\n \"comparisonValue\": {\n \"stringValue\": \"test@example.com\"\n }\n }\n }\n ],\n \"percentageOptions\": [],\n \"value\": {\n \"boolValue\": false\n }\n }\n ]\n}\n```", "operationId": "update-setting-value-v2", "parameters": [ { "name": "environmentId", "in": "path", "description": "The identifier of the Environment.", "required": true, "schema": { "type": "string", "format": "uuid" } }, { "name": "settingId", "in": "path", "description": "The id of the Setting.", "required": true, "schema": { "type": "integer", "format": "int32" } }, { "name": "reason", "in": "query", "description": "The reason note for the Audit Log if the Product's \"Config changes require a reason\" preference is turned on.", "schema": { "type": "string" } } ], "requestBody": { "content": { "application/json": { "schema": { "type": "array", "items": { "$ref": "#/components/schemas/JsonPatchOperation" } }, "examples": { "turn on a feature flag": { "description": "This example turns on a feature flag.", "value": [ { "op": "replace", "path": "/defaultValue/boolValue", "value": true } ] }, "add targeting rules": { "description": "This example adds an evaluation rule with two conditions to the Flag's targeting rules.", "value": [ { "op": "add", "path": "/targetingRules/-", "value": { "conditions": [ { "userCondition": { "comparator": "sensitiveTextEquals", "comparisonAttribute": "Email", "comparisonValue": { "stringValue": "example@test.com" } } }, { "userCondition": { "comparator": "sensitiveTextEquals", "comparisonAttribute": "Role", "comparisonValue": { "stringValue": "Developer" } } } ], "value": { "boolValue": false } } } ] }, "modify targeting rule": { "description": "This example modifies a targeting rule's value.", "value": [ { "op": "replace", "path": "/targetingRules/0/value/boolValue", "value": "true" } ] }, "modify targeting rule's condition": { "description": "This example modifies a condition's comparison attribute within a targeting rule.", "value": [ { "op": "replace", "path": "/targetingRules/0/conditions/0/userCondition/comparisonAttribute", "value": "Role" } ] }, "add segment condition": { "description": "This example adds a segment condition to a targeting rule.", "value": [ { "op": "add", "path": "/targetingRules/0/conditions/-", "value": { "segmentCondition": { "segmentComparator": "isIn", "segmentId": "008a1fd6-8245-4ea8-90dc-a1dc36c1b4ff" } } } ] }, "add prerequisite flag condition": { "description": "This example adds a prerequisite flag condition to a targeting rule.", "value": [ { "op": "add", "path": "/targetingRules/0/conditions/-", "value": { "prerequisiteFlagCondition": { "prerequisiteSettingId": "isIn", "comparator": "008a1fd6-8245-4ea8-90dc-a1dc36c1b4ff", "prerequisiteComparisonValue": { "boolValue": true } } } } ] }, "reorder targeting rules": { "description": "This example swaps the first and the second targeting rule.", "value": [ { "op": "move", "path": "/targetingRules/1", "from": "/targetingRules/0" } ] }, "reorder targeting rule conditions": { "description": "This example swaps the first and the second condition of a targeting rule.", "value": [ { "op": "move", "path": "/targetingRules/0/conditions/1", "from": "/targetingRules/0/conditions/0" } ] } } }, "text/json": { "schema": { "type": "array", "items": { "$ref": "#/components/schemas/JsonPatchOperation" } }, "examples": { "turn on a feature flag": { "description": "This example turns on a feature flag.", "value": [ { "op": "replace", "path": "/defaultValue/boolValue", "value": true } ] }, "add targeting rules": { "description": "This example adds an evaluation rule with two conditions to the Flag's targeting rules.", "value": [ { "op": "add", "path": "/targetingRules/-", "value": { "conditions": [ { "userCondition": { "comparator": "sensitiveTextEquals", "comparisonAttribute": "Email", "comparisonValue": { "stringValue": "example@test.com" } } }, { "userCondition": { "comparator": "sensitiveTextEquals", "comparisonAttribute": "Role", "comparisonValue": { "stringValue": "Developer" } } } ], "value": { "boolValue": false } } } ] }, "modify targeting rule": { "description": "This example modifies a targeting rule's value.", "value": [ { "op": "replace", "path": "/targetingRules/0/value/boolValue", "value": "true" } ] }, "modify targeting rule's condition": { "description": "This example modifies a condition's comparison attribute within a targeting rule.", "value": [ { "op": "replace", "path": "/targetingRules/0/conditions/0/userCondition/comparisonAttribute", "value": "Role" } ] }, "add segment condition": { "description": "This example adds a segment condition to a targeting rule.", "value": [ { "op": "add", "path": "/targetingRules/0/conditions/-", "value": { "segmentCondition": { "segmentComparator": "isIn", "segmentId": "008a1fd6-8245-4ea8-90dc-a1dc36c1b4ff" } } } ] }, "add prerequisite flag condition": { "description": "This example adds a prerequisite flag condition to a targeting rule.", "value": [ { "op": "add", "path": "/targetingRules/0/conditions/-", "value": { "prerequisiteFlagCondition": { "prerequisiteSettingId": "isIn", "comparator": "008a1fd6-8245-4ea8-90dc-a1dc36c1b4ff", "prerequisiteComparisonValue": { "boolValue": true } } } } ] }, "reorder targeting rules": { "description": "This example swaps the first and the second targeting rule.", "value": [ { "op": "move", "path": "/targetingRules/1", "from": "/targetingRules/0" } ] }, "reorder targeting rule conditions": { "description": "This example swaps the first and the second condition of a targeting rule.", "value": [ { "op": "move", "path": "/targetingRules/0/conditions/1", "from": "/targetingRules/0/conditions/0" } ] } } }, "application/*+json": { "schema": { "type": "array", "items": { "$ref": "#/components/schemas/JsonPatchOperation" } }, "examples": { "turn on a feature flag": { "description": "This example turns on a feature flag.", "value": [ { "op": "replace", "path": "/defaultValue/boolValue", "value": true } ] }, "add targeting rules": { "description": "This example adds an evaluation rule with two conditions to the Flag's targeting rules.", "value": [ { "op": "add", "path": "/targetingRules/-", "value": { "conditions": [ { "userCondition": { "comparator": "sensitiveTextEquals", "comparisonAttribute": "Email", "comparisonValue": { "stringValue": "example@test.com" } } }, { "userCondition": { "comparator": "sensitiveTextEquals", "comparisonAttribute": "Role", "comparisonValue": { "stringValue": "Developer" } } } ], "value": { "boolValue": false } } } ] }, "modify targeting rule": { "description": "This example modifies a targeting rule's value.", "value": [ { "op": "replace", "path": "/targetingRules/0/value/boolValue", "value": "true" } ] }, "modify targeting rule's condition": { "description": "This example modifies a condition's comparison attribute within a targeting rule.", "value": [ { "op": "replace", "path": "/targetingRules/0/conditions/0/userCondition/comparisonAttribute", "value": "Role" } ] }, "add segment condition": { "description": "This example adds a segment condition to a targeting rule.", "value": [ { "op": "add", "path": "/targetingRules/0/conditions/-", "value": { "segmentCondition": { "segmentComparator": "isIn", "segmentId": "008a1fd6-8245-4ea8-90dc-a1dc36c1b4ff" } } } ] }, "add prerequisite flag condition": { "description": "This example adds a prerequisite flag condition to a targeting rule.", "value": [ { "op": "add", "path": "/targetingRules/0/conditions/-", "value": { "prerequisiteFlagCondition": { "prerequisiteSettingId": "isIn", "comparator": "008a1fd6-8245-4ea8-90dc-a1dc36c1b4ff", "prerequisiteComparisonValue": { "boolValue": true } } } } ] }, "reorder targeting rules": { "description": "This example swaps the first and the second targeting rule.", "value": [ { "op": "move", "path": "/targetingRules/1", "from": "/targetingRules/0" } ] }, "reorder targeting rule conditions": { "description": "This example swaps the first and the second condition of a targeting rule.", "value": [ { "op": "move", "path": "/targetingRules/0/conditions/1", "from": "/targetingRules/0/conditions/0" } ] } } } }, "required": true }, "responses": { "200": { "description": "When the patch was successful.", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/SettingFormulaModel" } } } }, "204": { "description": "When no change applied on the resource." }, "400": { "description": "Bad request." }, "404": { "description": "Not found." }, "429": { "description": "Too many requests. In case of the request rate exceeds the rate limits." } } } },
|