def test_parse_spec_with_duplicate_parameter_names(openapi_spec_generator):
  """Test handling of duplicate parameter names (one in query, one in body).

  The expected behavior is that both parameters should be captured but with
  different suffix, and
  their `original_name` attributes should reflect their origin (query or body).
  """
  openapi_spec = {
      "openapi": "3.1.0",
      "info": {"title": "Duplicate Parameter Names API", "version": "1.0.0"},
      "paths": {
          "/duplicate": {
              "post": {
                  "operationId": "createWithDuplicate",
                  "parameters": [{
                      "name": "name",
                      "in": "query",
                      "schema": {"type": "string"},
                  }],
                  "requestBody": {
                      "content": {
                          "application/json": {
                              "schema": {
                                  "type": "object",
                                  "properties": {"name": {"type": "integer"}},
                              }
                          }
                      }
                  },
                  "responses": {"200": {"description": "OK"}},
              }
          }
      },
  }

  parsed_operations = openapi_spec_generator.parse(openapi_spec)
  assert len(parsed_operations) == 1
  op = parsed_operations[0]
  assert op.name == "create_with_duplicate"
  assert len(op.parameters) == 2

  query_param = None
  body_param = None
  for param in op.parameters:
    if param.param_location == "query" and param.original_name == "name":
      query_param = param
    elif param.param_location == "body" and param.original_name == "name":
      body_param = param

  assert query_param is not None
  assert query_param.original_name == "name"
  assert query_param.py_name == "name"

  assert body_param is not None
  assert body_param.original_name == "name"
  assert body_param.py_name == "name_0"
Test handling of duplicate parameter names (one in query, one in body).

  The expected behavior is that both parameters should be captured but with
  different suffix, and
  their `original_name` attributes should reflect their origin (query or body).
  
tests/unittests/tools/openapi_tool/openapi_spec_parser/test_openapi_spec_parser.py