mirror of
https://github.com/aljazceru/mcp-python-sdk.git
synced 2025-12-19 23:04:25 +01:00
Fix comment about pydantic versioning
This commit is contained in:
@@ -237,26 +237,23 @@ async def test_lambda_function():
|
|||||||
def test_complex_function_json_schema():
|
def test_complex_function_json_schema():
|
||||||
"""Test JSON schema generation for complex function arguments.
|
"""Test JSON schema generation for complex function arguments.
|
||||||
|
|
||||||
Note: This test accepts two equivalent JSON Schema formats for models with defaults:
|
Note: Different versions of pydantic output slightly different
|
||||||
1. Pre-pydantic 2.7.2:
|
JSON Schema formats for model fields with defaults. The format changed in 2.9.0:
|
||||||
|
|
||||||
|
1. Before 2.9.0:
|
||||||
|
{
|
||||||
|
"allOf": [{"$ref": "#/$defs/Model"}],
|
||||||
|
"default": {}
|
||||||
|
}
|
||||||
|
|
||||||
|
2. Since 2.9.0:
|
||||||
{
|
{
|
||||||
"$ref": "#/$defs/Model",
|
"$ref": "#/$defs/Model",
|
||||||
"default": {}
|
"default": {}
|
||||||
}
|
}
|
||||||
|
|
||||||
2. Pydantic 2.7.2+:
|
Both formats are valid and functionally equivalent. This test accepts either format
|
||||||
{
|
to ensure compatibility across our supported pydantic versions.
|
||||||
"allOf": [
|
|
||||||
{
|
|
||||||
"$ref": "#/$defs/Model"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"default": {}
|
|
||||||
}
|
|
||||||
|
|
||||||
Both formats are valid JSON Schema and represent the same validation rules.
|
|
||||||
The newer format using allOf is more correct according to the JSON Schema spec
|
|
||||||
as it properly composes the reference with additional properties.
|
|
||||||
|
|
||||||
This change in format does not affect runtime behavior since:
|
This change in format does not affect runtime behavior since:
|
||||||
1. Both schemas validate the same way
|
1. Both schemas validate the same way
|
||||||
|
|||||||
Reference in New Issue
Block a user