from typing import Optional
from typing import Dict
from typing import Any
import yaml


def load_schema(path: str) -> Optional[Dict[Any, Any]]:
    """Load Custom Resource OpenAPI schema definition from a file."""
    with open(path, "r") as stream:
        version = yaml.safe_load(stream)["spec"]["versions"][0]
        schema: Dict[Any, Any] = version["schema"]["openAPIV3Schema"]

    return schema