def test_parse_spec_with_multiple_paths_deep_refs(openapi_spec_generator):
  """Test specs with multiple paths, request/response bodies using deep refs."""
  openapi_spec = {
      "openapi": "3.1.0",
      "info": {"title": "Multiple Paths Deep Refs API", "version": "1.0.0"},
      "paths": {
          "/path1": {
              "post": {
                  "operationId": "postPath1",
                  "requestBody": {
                      "content": {
                          "application/json": {
                              "schema": {
                                  "$ref": "#/components/schemas/Request1"
                              }
                          }
                      }
                  },
                  "responses": {
                      "200": {
                          "description": "OK",
                          "content": {
                              "application/json": {
                                  "schema": {
                                      "$ref": "#/components/schemas/Response1"
                                  }
                              }
                          },
                      }
                  },
              }
          },
          "/path2": {
              "put": {
                  "operationId": "putPath2",
                  "requestBody": {
                      "content": {
                          "application/json": {
                              "schema": {
                                  "$ref": "#/components/schemas/Request2"
                              }
                          }
                      }
                  },
                  "responses": {
                      "200": {
                          "description": "OK",
                          "content": {
                              "application/json": {
                                  "schema": {
                                      "$ref": "#/components/schemas/Response2"
                                  }
                              }
                          },
                      }
                  },
              },
              "get": {
                  "operationId": "getPath2",
                  "responses": {
                      "200": {
                          "description": "OK",
                          "content": {
                              "application/json": {
                                  "schema": {
                                      "$ref": "#/components/schemas/Response2"
                                  }
                              }
                          },
                      }
                  },
              },
          },
      },
      "components": {
          "schemas": {
              "Request1": {
                  "type": "object",
                  "properties": {
                      "req1_prop1": {"$ref": "#/components/schemas/Level1_1"}
                  },
              },
              "Response1": {
                  "type": "object",
                  "properties": {
                      "res1_prop1": {"$ref": "#/components/schemas/Level1_2"}
                  },
              },
              "Request2": {
                  "type": "object",
                  "properties": {
                      "req2_prop1": {"$ref": "#/components/schemas/Level1_1"}
                  },
              },
              "Response2": {
                  "type": "object",
                  "properties": {
                      "res2_prop1": {"$ref": "#/components/schemas/Level1_2"}
                  },
              },
              "Level1_1": {
                  "type": "object",
                  "properties": {
                      "level1_1_prop1": {
                          "$ref": "#/components/schemas/Level2_1"
                      }
                  },
              },
              "Level1_2": {
                  "type": "object",
                  "properties": {
                      "level1_2_prop1": {
                          "$ref": "#/components/schemas/Level2_2"
                      }
                  },
              },
              "Level2_1": {
                  "type": "object",
                  "properties": {
                      "level2_1_prop1": {"$ref": "#/components/schemas/Level3"}
                  },
              },
              "Level2_2": {
                  "type": "object",
                  "properties": {"level2_2_prop1": {"type": "string"}},
              },
              "Level3": {"type": "integer"},
          }
      },
  }

  parsed_operations = openapi_spec_generator.parse(openapi_spec)
  assert len(parsed_operations) == 3

  # Verify Path 1
  path1_ops = [op for op in parsed_operations if op.endpoint.path == "/path1"]
  assert len(path1_ops) == 1
  path1_op = path1_ops[0]
  assert path1_op.name == "post_path1"

  assert len(path1_op.parameters) == 1
  assert path1_op.parameters[0].original_name == "req1_prop1"
  assert (
      path1_op.parameters[0]
      .param_schema.properties["level1_1_prop1"]
      .properties["level2_1_prop1"]
      .type
      == "integer"
  )
  assert (
      path1_op.return_value.param_schema.properties["res1_prop1"]
      .properties["level1_2_prop1"]
      .properties["level2_2_prop1"]
      .type
      == "string"
  )

  # Verify Path 2
  path2_ops = [
      op
      for op in parsed_operations
      if op.endpoint.path == "/path2" and op.name == "put_path2"
  ]
  path2_op = path2_ops[0]
  assert path2_op is not None
  assert len(path2_op.parameters) == 1
  assert path2_op.parameters[0].original_name == "req2_prop1"
  assert (
      path2_op.parameters[0]
      .param_schema.properties["level1_1_prop1"]
      .properties["level2_1_prop1"]
      .type
      == "integer"
  )
  assert (
      path2_op.return_value.param_schema.properties["res2_prop1"]
      .properties["level1_2_prop1"]
      .properties["level2_2_prop1"]
      .type
      == "string"
  )
Test specs with multiple paths, request/response bodies using deep refs.
tests/unittests/tools/openapi_tool/openapi_spec_parser/test_openapi_spec_parser.py