mirror of
https://github.com/PrefectHQ/fastmcp.git
synced 2026-08-28 02:10:38 +02:00
Fix: Preserve OpenAPI parameter descriptions in experimental parser (#1877)
This commit is contained in:
parent
0ee263a1c6
commit
92b7e92e05
2 changed files with 22 additions and 4 deletions
|
|
@ -303,9 +303,11 @@ def _combine_schemas_and_map_params(
|
|||
|
||||
# Convert refs if needed
|
||||
if convert_refs:
|
||||
param_schema = _replace_ref_with_defs(param.schema_)
|
||||
param_schema = _replace_ref_with_defs(param.schema_, param.description)
|
||||
else:
|
||||
param_schema = param.schema_
|
||||
param_schema = param.schema_.copy()
|
||||
if param.description and not param_schema.get("description"):
|
||||
param_schema["description"] = param.description
|
||||
original_desc = param_schema.get("description", "")
|
||||
location_desc = f"({param.location.capitalize()} parameter)"
|
||||
if original_desc:
|
||||
|
|
@ -330,9 +332,11 @@ def _combine_schemas_and_map_params(
|
|||
|
||||
# Convert refs if needed
|
||||
if convert_refs:
|
||||
param_schema = _replace_ref_with_defs(param.schema_)
|
||||
param_schema = _replace_ref_with_defs(param.schema_, param.description)
|
||||
else:
|
||||
param_schema = param.schema_
|
||||
param_schema = param.schema_.copy()
|
||||
if param.description and not param_schema.get("description"):
|
||||
param_schema["description"] = param.description
|
||||
|
||||
# Don't make optional parameters nullable - they can simply be omitted
|
||||
# The OpenAPI specification doesn't require optional parameters to accept null values
|
||||
|
|
|
|||
|
|
@ -154,6 +154,20 @@ class TestParameterHandling:
|
|||
assert "tags" in properties
|
||||
assert "X-API-Key" in properties
|
||||
|
||||
# Check that parameter descriptions are included
|
||||
assert "description" in properties["query"], (
|
||||
"Query parameter should have description"
|
||||
)
|
||||
assert properties["query"]["description"] == "Search query"
|
||||
assert "description" in properties["limit"], (
|
||||
"Limit parameter should have description"
|
||||
)
|
||||
assert properties["limit"]["description"] == "Maximum number of results"
|
||||
assert "description" in properties["tags"], (
|
||||
"Tags parameter should have description"
|
||||
)
|
||||
assert properties["tags"]["description"] == "Filter by tags"
|
||||
|
||||
# Check that required parameters are marked as required
|
||||
required = params.get("required", [])
|
||||
assert "query" in required
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue