raise ValueError(f"No {method} method found for {path}")
            return operation_obj
[docs]        def get_parameters_for_operation(self, operation: Operation) -> List[Parameter]:
            """Get the components for a given operation."""
            from openapi_schema_pydantic import Reference
            parameters = []
            if operation.parameters:
                for parameter in operation.parameters:
                    if isinstance(parameter, Reference):
                        parameter = self._get_root_referenced_parameter(parameter)
                    parameters.append(parameter)
            return parameters
[docs]        def get_request_body_for_operation(
            self, operation: Operation
        ) -> Optional[RequestBody]:
            """Get the request body for a given operation."""
            from openapi_schema_pydantic import Reference
            request_body = operation.requestBody
            if isinstance(request_body, Reference):
                request_body = self._get_root_referenced_request_body(request_body)
            return request_body
[docs]        @staticmethod
        def get_cleaned_operation_id(
            operation: Operation, path: str, method: str
        ) -> str:
            """Get a cleaned operation id from an operation id."""
            operation_id = operation.operationId
            if operation_id is None:
                # Replace all punctuation of any kind with underscore
                path = re.sub(r"[^a-zA-Z0-9]", "_", path.lstrip("/"))
                operation_id = f"{path}_{method}"
            return operation_id.replace("-", "_").replace(".", "_").replace("/", "_")
else:
[docs]    class OpenAPISpec:  # type: ignore[no-redef]
        """Shim for pydantic version >=2"""
        def __init__(self) -> None:
            raise NotImplementedError("Only supported for pydantic version 1")