in aidial_assistant/open_api/operation_selector.py [0:0]
def collect_operations(spec: OpenAPISpec, spec_url: str) -> OpenAPIOperations:
operations: dict[str, APIOperation] = {}
def add_operation(spec, path, method):
operation = APIOperation.from_openapi_spec(spec, path, method) # type: ignore
operation.base_url = urljoin(spec_url, operation.base_url)
operations[operation.operation_id] = operation
if spec.paths is None: # type: ignore
return operations
for path, path_item in spec.paths.items(): # type: ignore
if path_item.get is not None:
add_operation(spec, path, "get")
if path_item.post is not None:
add_operation(spec, path, "post")
return operations