This commit is contained in:
@@ -105,6 +105,29 @@ class ApiBasedToolSchemaParser:
|
||||
# overwrite the content
|
||||
interface["operation"]["requestBody"]["content"][content_type]["schema"] = root
|
||||
|
||||
# handle allOf reference in schema properties
|
||||
for prop_dict in root.get("properties", {}).values():
|
||||
for item in prop_dict.get("allOf", []):
|
||||
if "$ref" in item:
|
||||
ref_schema = openapi
|
||||
reference = item["$ref"].split("/")[1:]
|
||||
for ref in reference:
|
||||
ref_schema = ref_schema[ref]
|
||||
else:
|
||||
ref_schema = item
|
||||
for key, value in ref_schema.items():
|
||||
if isinstance(value, list):
|
||||
if key not in prop_dict:
|
||||
prop_dict[key] = []
|
||||
# extends list field
|
||||
if isinstance(prop_dict[key], list):
|
||||
prop_dict[key].extend(value)
|
||||
elif key not in prop_dict:
|
||||
# add new field
|
||||
prop_dict[key] = value
|
||||
if "allOf" in prop_dict:
|
||||
del prop_dict["allOf"]
|
||||
|
||||
# parse body parameters
|
||||
if "schema" in interface["operation"]["requestBody"]["content"][content_type]:
|
||||
body_schema = interface["operation"]["requestBody"]["content"][content_type]["schema"]
|
||||
|
Reference in New Issue
Block a user