caikit.runtime.http_server.utils ================================ .. py:module:: caikit.runtime.http_server.utils .. autoapi-nested-parse:: This module holds utility functions and classes used only by the REST server, this includes things like parameter handles and openapi spec generation Functions --------- .. autoapisummary:: caikit.runtime.http_server.utils.convert_json_schema_to_multipart caikit.runtime.http_server.utils._extract_raw_from_schema caikit.runtime.http_server.utils._clean_schema_path caikit.runtime.http_server.utils._parse_raw_json_schema caikit.runtime.http_server.utils.flatten_json_schema caikit.runtime.http_server.utils._replace_json_refs caikit.runtime.http_server.utils.update_dict_at_dot_path Module Contents --------------- .. py:function:: convert_json_schema_to_multipart(json_schema, defs) Helper function to convert a json schema from applicaiton/json into one that can be used for multipart requests .. py:function:: _extract_raw_from_schema(json_schema: Any, defs: Dict[str, Any], current_path=None) -> (dict, dict) Helper function to extract all "bytes" or File fields from a json schema and return the cleaned schema dict and a dict of extracted schemas where the key is the original raw's path .. py:function:: _clean_schema_path(path) Clean a schema path of all reserved openapi fields. For example this turns inputs.properties.anyOf.file.properties.filename to inputs.file.filename .. py:function:: _parse_raw_json_schema(json_schema: dict) -> Optional[dict] Helper to check if a json schema matches a raw objects schema. If it does return the generic binary openapi schema .. py:function:: flatten_json_schema(json_schema: dict) -> dict Function to flatten a json schema. It replaces all references to $def with the requested object or {} if it's not found .. py:function:: _replace_json_refs(current_json: Any, refs_map: dict) Helper function to replace all items of {'$ref':'#/'} with the raw objects. This is used for generating flattened openapi specs .. py:function:: update_dict_at_dot_path(dict_obj: dict, key: str, updated_value: Any) -> bool Helper to set values in a dict using 'foo.bar' key notation Args: dict_obj: dict The dict into which the key will be set key: str Key that may contain '.' notation indicating dict nesting updated_value: Any The value to place at the nested key Returns: bool: Weather the dict was successfully updated