class_docstr: OpenAPIServiceToFunctions is responsible for converting an OpenAPI service specification into a format suitable
  for OpenAI function calling, based on the provided OpenAPI specification. Given an OpenAPI specification,
  OpenAPIServiceToFunctions processes it, and extracts function definitions that can be invoked via OpenAI's
  function calling mechanism. The format of the extracted functions is compatible with OpenAI's function calling
  JSON format.
  
  Minimal requirements for OpenAPI specification:
  - OpenAPI version 3.0.0 or higher
  - Each function must have a unique operationId
  - Each function must have a description
  - Each function must have a requestBody or parameters or both
  - Each function must have a schema for the requestBody and/or parameters
  
  
  See https://github.com/OAI/OpenAPI-Specification for more details on OpenAPI specification.
  See https://platform.openai.com/docs/guides/function-calling for more details on OpenAI function calling.
class_docstr_tok: ["OpenAPIServiceToFunctions","is","responsible","for","converting","an","OpenAPI","service","specification","into","a","format","suitable","for","OpenAI","function","calling",",","based","on","the","provided","OpenAPI","specification",".","Given","an","OpenAPI","specification",",","OpenAPIServiceToFunctions","processes","it",",","and","extracts","function","definitions","that","can","be","invoked","via","OpenAI's","function","calling","mechanism",".","The","format","of","the","extracted","functions","is","compatible","with","OpenAI","'s","function","calling","JSON","format",".","Minimal","requirements","for","OpenAPI","specification",":","-","OpenAPI","version","3.0.0","or","higher","-","Each","function","must","have","a","unique","operationId","-","Each","function","must","have","a","description","-","Each","function","must","have","a","requestBody","or","parameters","or","both","-","Each","function","must","have","a","schema","for","the","requestBody","and\/or","parameters","See","https",":","\/\/github.com\/OAI\/OpenAPI-Specification","for","more","details","on","OpenAPI","specification",".","See","https",":","\/\/platform.openai.com\/docs\/guides\/function-calling","for","more","details","on","OpenAI","function","calling","."]
docstr: Parses OpenAPI specification content, supporting both JSON and YAML formats.
  
  :param content: The content of the OpenAPI specification.
  :type content: str
  :return: The parsed OpenAPI specification.
  :rtype: Dict[str, Any]
docstr_tok: ["Parses","OpenAPI","specification","content",",","supporting","both","JSON","and","YAML","formats",".",":","param","content",":","The","content","of","the","OpenAPI","specification",".",":","type","content",":","str",":","return",":","The","parsed","OpenAPI","specification",".",":","rtype",":","Dict","[","str",",","Any","]"]
code: def _parse_openapi_spec(self, content: str) -> Dict[str, Any]:
      """
      Parses OpenAPI specification content, supporting both JSON and YAML formats.
  
      :param content: The content of the OpenAPI specification.
      :type content: str
      :return: The parsed OpenAPI specification.
      :rtype: Dict[str, Any]
      """
      try:
          return json.loads(content)
      except json.JSONDecodeError as json_error:
          # heuristic to confirm that the content is likely malformed JSON
          if content.strip().startswith(("{", "[")):
              raise json_error
  
      try:
          return yaml.safe_load(content)
      except yaml.YAMLError:
          error_message = (
              "Failed to parse the OpenAPI specification. "
              "The content does not appear to be valid JSON or YAML.\n\n"
          )
          raise RuntimeError(error_message, content)
  
file_path: haystack/haystack/components/converters/openapi_functions.py
imports: import json
  import logging
  import os
  from pathlib import Path
  from typing import List, Dict, Any, Union, Optional
  import requests
  import yaml
  from requests import RequestException
  from haystack import component, Document
  from haystack.dataclasses.byte_stream import ByteStream
  from haystack.lazy_imports import LazyImport
label_desc: Use image node_id 4 for calling the OpenAPIServiceToFunctions obj's underlying member method code with example usage: obj._parse_openapi_spec(content) and returns: json, yaml