MCPcopy
hub / github.com/intruder-io/autoswagger / handle_composite_schemas

Function handle_composite_schemas

autoswagger.py:313–327  ·  view source on GitHub ↗

Handles composite schema definitions like oneOf, anyOf, and allOf. Calls build_nested_object recursively on the chosen sub-schema or the combined properties.

(schema, value_index=0)

Source from the content-addressed store, hash-verified

311 return obj
312
313def handle_composite_schemas(schema, value_index=0):
314 """
315 Handles composite schema definitions like oneOf, anyOf, and allOf.
316 Calls build_nested_object recursively on the chosen sub-schema or the combined properties.
317 """
318 if 'oneOf' in schema:
319 return build_nested_object(schema['oneOf'][value_index % len(schema['oneOf'])], value_index)
320 elif 'anyOf' in schema:
321 return build_nested_object(schema['anyOf'][value_index % len(schema['anyOf'])], value_index)
322 elif 'allOf' in schema:
323 combined_schema = {}
324 for sub_schema in schema['allOf']:
325 combined_schema.update(sub_schema.get('properties', {}))
326 return build_nested_object({'properties': combined_schema}, value_index)
327 return build_nested_object(schema, value_index)
328
329def build_array_item(item_schema, value_index=0):
330 """

Callers 2

build_nested_objectFunction · 0.85
build_request_bodyFunction · 0.85

Calls 1

build_nested_objectFunction · 0.85

Tested by

no test coverage detected