code: def tsbindings(swagger: swagger_parser.ParseResult) -> str:
      clean_description = swagger.info.description.replace("\n", " ")
      prelude = f"""
  /**
   * {swagger.info.title}
   * {clean_description}
   *
   * OpenAPI spec version: {swagger.info.version}
   * Contact: {swagger.info.contact}
   *
   * NOTE: Do not edit the class manually.
   */
  
  
  import {{ Configuration }} from "./configuration";
  
  type ValueOf<T> = T[keyof T];
  const BASE_PATH = "http://localhost".replace(/\/+$/, "");
  
  const convert = (v: unknown): string => {{
      switch (typeof v) {{
          case 'string':
          case 'boolean': {{
              return v.toString();
          }}
          case 'bigint': {{
              return '' + v
          }}
          case 'number': {{
              if (Number.isFinite(v))  {{
                  return encodeURIComponent(v);
              }}
              return '';
          }}
          default: {{
              return '';
          }}
      }}
  }}
  
  const objToSearchParams = (obj: {{}}, searchParams: URLSearchParams) => {{
      Object.entries(obj).forEach(([key, value]) => {{
          if (Array.isArray(value) && value.length > 0) {{
              searchParams.set(key, convert(value[0]))
              value.slice(1).forEach((subValue) => searchParams.append(key, convert(subValue)))
          }} else if (!Array.isArray(value)) {{
              searchParams.set(key, convert(value))
          }}
      }});
  }};
  
  /**
   *
   * @export
   */
  export const COLLECTION_FORMATS = {{
      csv: ",",
      ssv: " ",
      tsv: "\\t",
      pipes: "|",
  }};
  
  /**
   *
   * @export
   * @interface FetchAPI
   */
  export interface FetchAPI {{
      (url: string, init?: any): Promise<Response>;
  }}
  
  /**
   *
   * @export
   * @interface FetchArgs
   */
  export interface FetchArgs {{
      url: string;
      options: any;
  }}
  
  /**
   *
   * @export
   * @class BaseAPI
   */
  export class BaseAPI {{
      protected configuration: Configuration;
  
      constructor(configuration?: Configuration, protected basePath: string = BASE_PATH, protected fetch: FetchAPI = window.fetch) {{
          if (configuration) {{
              this.configuration = configuration;
              this.basePath = configuration.basePath || this.basePath;
          }} else {{
              this.configuration = new Configuration()
          }}
      }}
  }};
  
  /**
   *
   * @export
   * @class RequiredError
   * @extends {{Error}}
   */
  export class RequiredError extends Error {{
      override name: "RequiredError"
      constructor(public field: string, msg?: string) {{
          super(msg);
          this.name = "RequiredError"
      }}
  }}
  
  """
      out = [prelude]
  
      # workaround for streaming function behavior
      runtime_stream_error = swagger.defs["runtimeStreamError"]
      assert runtime_stream_error
      runtime_stream_error_ref = swagger_parser.Ref(
          name="RuntimeStreamError"
      )
      swagger_parser.Ref.all_refs.append(runtime_stream_error_ref)
      runtime_stream_error_ref.defn = runtime_stream_error
      runtime_stream_error_ref.linked = True
  
      ops_by_tag = {}
      for defn in swagger.ops.values():
          # fix naming conventions to match swagger-codegen here
          defn.name = camel_case(defn.name)
          for param in defn.params.values():
              param.name = camel_case(param.name)
          # group ops by tag name
          for tag in defn.tags:
              fixed_tag = upper_first(camel_case(tag))
              ops_by_tag[fixed_tag] = ops_by_tag.get(fixed_tag, [])
              ops_by_tag[fixed_tag].append(defn)
  
      for _, defn in sorted(swagger.defs.items(), key=head):
          if defn is None:
              continue
          out += [gen_def(defn)]
  
      for tag, functions in sorted(ops_by_tag.items(), key=head):
          out += [generate_api(tag, functions)]
  
      return "\n".join(out).strip()
  
imports: import os
  import re
  import typing
  from dataclasses import dataclass, field
  from shutil import copy, rmtree
  import swagger_parser
  from typing_extensions import Literal, assert_never
label_desc: Use image node_id 9 for calling a global function with example usage: tsbindings(swagger) and returns: str