code: def process_paths(
      swagger_paths: dict, enums: dict
  ) -> typing.Tuple[
      typing.Dict[str, Function], typing.Dict[str, Class]
  ]:
      ops = {}
      extra_classes = {}
      for path, methods in swagger_paths.items():
          for method, spec in methods.items():
              name = spec["operationId"]
              # Figure out response types.
              responses = {}
              streaming = None
              bad_op = False
              for code, rspec in spec["responses"].items():
                  rschema = rspec["schema"]
                  if code == "default":
                      # We expect all "default" responses to be runtimeErrors, and we ignore them.
                      default_type = classify_type(
                          enums, f"{name}.responses.default", rschema
                      )
                      assert isinstance(default_type, Ref), rschema
                      assert (
                          default_type.name == "runtimeError"
                      ), rschema
                      # Safe to ignore this return type.
                      continue
  
                  if rschema.get("type") == "":
                      # not a valid response schema, skipping
                      bad_op = True
                      break
  
                  if rschema.get("title", "").startswith(
                      "Stream result"
                  ):
                      # We expect a specific structure to streaming endpoints.
                      assert rschema["type"] == "object", rschema
                      assert (
                          "additionalProperties" not in rschema
                      ), rschema
                      rprops = rschema["properties"]
                      assert set(rprops.keys()) == set(
                          ("result", "error")
                      ), rschema
                      error_type = classify_type(
                          enums,
                          f"{name}.responses.{code}.properties.error",
                          rprops["error"],
                      )
                      # We expect all "error" results to be runtimeStreamError.  They are parsed in
                      # code generated by Function.gen_def().
                      assert isinstance(error_type, Ref), rschema
                      assert (
                          error_type.name == "runtimeStreamError"
                      ), rschema
                      if streaming is False:
                          raise ValueError(
                              f"a method must be either all-streaming or all-nonstreaming: {rspec}"
                          )
                      streaming = True
  
                      # handle inlined objects similar to how swagger-codegen does
                      result_type_class = classify_definition(
                          enums, f"{name}.response.{code}", rschema
                      )
                      assert isinstance(result_type_class, Class)
                      result_type_class_ref = result_type_class.params[
                          "result"
                      ].type
                      assert isinstance(result_type_class_ref, Ref)
                      pascal_name = result_type_class_ref.name
                      pascal_name = (
                          pascal_name[0].upper() + pascal_name[1:]
                      )
                      result_type_class.name = (
                          f"StreamResultOf{pascal_name}"
                      )
                      result_type = Ref(result_type_class.name)
                      extra_classes[
                          result_type_class.name
                      ] = result_type_class
  
                      responses[code] = result_type
                      continue
  
                  responses[code] = classify_type(
                      enums, f"{name}.responses.{code}", rschema
                  )
                  if streaming is True:
                      raise ValueError(
                          f"a method must be either all-streaming or all-nonstreaming: {rspec}"
                      )
                  streaming = False
  
              if bad_op:
                  continue
  
              assert streaming is not None
  
              # Figure out parameters.
              params = {}
              for pspec in spec.get("parameters", []):
                  where = pspec["in"]
                  serialized_name = None
                  if where == "query":  # preserve query parameter names
                      serialized_name = pname = pspec["name"]
                  pname = pspec["name"].replace(".", "_")
                  required = pspec.get("required", False)
                  if "schema" in pspec:
                      pschema = pspec["schema"]
                  else:
                      # swagger has some weird inlining going on here...
                      inlined = (
                          "type",
                          "format",
                          "items",
                          "properties",
                          "enum",
                      )
                      pschema = {
                          k: pspec[k] for k in inlined if k in pspec
                      }
                  ptype = classify_type(
                      enums, f"{name}.{pname}", pschema
                  )
                  title = pspec.get("title") or pspec.get("description")
                  params[pname] = Parameter(
                      pname,
                      ptype,
                      required,
                      where,
                      serialized_name,
                      title,
                  )
  
              assert is_expected_path(path), (path, name)
              path = path.replace(".", "_")
              tags = set(spec["tags"])
              summary = spec["summary"]
              needs_auth = "security" not in spec
              op = Function(
                  name,
                  method,
                  path,
                  params,
                  responses,
                  streaming,
                  tags,
                  summary,
                  needs_auth,
              )
              ops[name] = op
      return ops, extra_classes
  
imports: import json
  import logging
  import sys
  import typing
  from dataclasses import dataclass, field
  import typing_extensions
label_desc: Use image node_id 6 for calling a global function with example usage: process_paths(swagger_paths, enums) and returns: ops,  extra_classes