code: def generate_api(
      tag: str, functions: typing.List[swagger_parser.Function]
  ) -> Code:
      code = IndentedLines()
      api_name = f"{tag}Api"
      functions_in_order = sorted(
          functions, key=lambda f: f.name.lower()
      )
  
      # fetch param creator
      code.start_comment()
      code += f"{api_name} - fetch parameter creator"
      code += "@export"
      code.end_comment()
      code += f"export const {api_name}FetchParamCreator = function (configuration?: Configuration) {{"
      code.indent()
      code += "return {"
      # resetting indent level here so the function generator can take over
      cur_indent_level = code.indent_level
      code.indent_level = 0
      for function in functions_in_order:
          code += generate_function(api_name, "params", function)
      code.indent_level = cur_indent_level
      code += "}"
      code.dedent()
      code += "};"
      code += ""
  
      # functional programming interface
      code.start_comment()
      code += f"{api_name} - functional programming interface"
      code += "@export"
      code.end_comment()
      code += f"export const {api_name}Fp = function (configuration?: Configuration) {{"
      code.indent()
      code += "return {"
      cur_indent_level = code.indent_level
      code.indent_level = 0
      for function in functions_in_order:
          code += generate_function(api_name, "fp", function)
      code.indent_level = cur_indent_level
      code += "}"
      code.dedent()
      code += "};"
      code += ""
  
      # factory interface
      code.start_comment()
      code += f"{api_name} - factory interface"
      code += "@export"
      code.end_comment()
      code += f"export const {api_name}Factory = function (configuration?: Configuration, fetch?: FetchAPI, basePath?: string) {{"
      code.indent()
      code += "return {"
      cur_indent_level = code.indent_level
      code.indent_level = 0
      for function in functions_in_order:
          code += generate_function(api_name, "factory", function)
      code.indent_level = cur_indent_level
      code += "}"
      code.dedent()
      code += "};"
      code += ""
  
      # class interface
      code.start_comment()
      code += f"{api_name} - object-oriented interface"
      code += "@export"
      code += "@class"
      code += "@extends {BaseAPI}"
      code.end_comment()
      code += f"export class {api_name} extends BaseAPI {{"
      for function in functions_in_order:
          code += generate_function(api_name, "api", function)
      code += "}"
      code += ""
      return str(code)
  
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 8 for calling a global function with example usage: generate_api(tag, functions) and returns: str