Jeremiah Lowin commited on
Commit
08d4e16
·
unverified ·
2 Parent(s): 029001b5f72fab

Merge pull request #953 from jlowin/claude-wt-20250625-195151

Browse files
src/fastmcp/utilities/openapi.py CHANGED
@@ -302,11 +302,17 @@ class OpenAPIParser(
302
 
303
  # Extract parameter info - handle both 3.0 and 3.1 parameter models
304
  param_in = parameter.param_in # Both use param_in
305
- param_location = self._convert_to_parameter_location(param_in)
 
 
 
 
 
 
306
  param_schema_obj = parameter.param_schema # Both use param_schema
307
 
308
  # Skip duplicate parameters (same name and location)
309
- param_key = (parameter.name, param_in)
310
  if param_key in seen_params:
311
  continue
312
  seen_params[param_key] = True
 
302
 
303
  # Extract parameter info - handle both 3.0 and 3.1 parameter models
304
  param_in = parameter.param_in # Both use param_in
305
+ # Handle enum or string parameter locations
306
+ from enum import Enum
307
+
308
+ param_in_str = (
309
+ param_in.value if isinstance(param_in, Enum) else param_in
310
+ )
311
+ param_location = self._convert_to_parameter_location(param_in_str)
312
  param_schema_obj = parameter.param_schema # Both use param_schema
313
 
314
  # Skip duplicate parameters (same name and location)
315
+ param_key = (parameter.name, param_in_str)
316
  if param_key in seen_params:
317
  continue
318
  seen_params[param_key] = True
tests/server/openapi/test_openapi_path_parameters.py CHANGED
@@ -455,3 +455,31 @@ async def test_array_query_parameter_exploded_format(mock_client):
455
  json=None,
456
  timeout=None,
457
  )
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
455
  json=None,
456
  timeout=None,
457
  )
458
+
459
+
460
+ def test_parameter_location_enum_handling():
461
+ """Test that ParameterLocation enum values are handled correctly (issue #950)."""
462
+ from enum import Enum
463
+
464
+ # Create a mock ParameterLocation enum like the one from openapi_pydantic
465
+ class MockParameterLocation(Enum):
466
+ PATH = "path"
467
+ QUERY = "query"
468
+ HEADER = "header"
469
+ COOKIE = "cookie"
470
+
471
+ # Test the enum handling logic directly (reproduces the fix in openapi.py)
472
+ test_cases = [
473
+ (MockParameterLocation.PATH, "path"),
474
+ (MockParameterLocation.QUERY, "query"),
475
+ (MockParameterLocation.HEADER, "header"),
476
+ (MockParameterLocation.COOKIE, "cookie"),
477
+ ("path", "path"), # Also test that strings work
478
+ ("query", "query"),
479
+ ]
480
+
481
+ for param_in, expected_str in test_cases:
482
+ # This is the enum handling logic from the fix
483
+ param_in_str = param_in.value if isinstance(param_in, Enum) else param_in
484
+ assert param_in_str == expected_str
485
+ assert isinstance(param_in_str, str)