path: str,
            method: str,
        ) -> "APIOperation":
            """Create an APIOperation from an OpenAPI spec."""
            operation = spec.get_operation(path, method)
            parameters = spec.get_parameters_for_operation(operation)
            properties = cls._get_properties_from_parameters(parameters, spec)
            operation_id = OpenAPISpec.get_cleaned_operation_id(operation, path, method)
            request_body = spec.get_request_body_for_operation(operation)
            api_request_body = (
                APIRequestBody.from_request_body(request_body, spec)
                if request_body is not None
                else None
            )
            description = operation.description or operation.summary
            if not description and spec.paths is not None:
                description = spec.paths[path].description or spec.paths[path].summary
            return cls(
                operation_id=operation_id,
                description=description or "",
                base_url=spec.base_url,
                path=path,
                method=method,
                properties=properties,
                request_body=api_request_body,
            )
[docs]        @staticmethod
        def ts_type_from_python(type_: SCHEMA_TYPE) -> str:
            if type_ is None:
                # TODO: Handle Nones better. These often result when
                # parsing specs that are < v3
                return "any"
            elif isinstance(type_, str):
                return {
                    "str": "string",
                    "integer": "number",
                    "float": "number",
                    "date-time": "string",
                }.get(type_, type_)
            elif isinstance(type_, tuple):
                return f"Array<{APIOperation.ts_type_from_python(type_[0])}>"
            elif isinstance(type_, type) and issubclass(type_, Enum):