Skip to content

Commit 0d48a44

Browse files
relax pydantic, pydantic-settings, and uvicorn
1 parent 44c0004 commit 0d48a44

File tree

2 files changed

+44
-4
lines changed

2 files changed

+44
-4
lines changed

pyproject.toml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,11 @@ dependencies = [
2525
"anyio>=4.5",
2626
"httpx>=0.27",
2727
"httpx-sse>=0.4",
28-
"pydantic>=2.10.1,<3.0.0",
28+
"pydantic>=2.7.2,<3.0.0",
2929
"starlette>=0.27",
3030
"sse-starlette>=1.6.1",
31-
"pydantic-settings>=2.6.1",
32-
"uvicorn>=0.30",
31+
"pydantic-settings>=2.5.2",
32+
"uvicorn>=0.23.1",
3333
]
3434

3535
[project.optional-dependencies]

tests/server/fastmcp/test_func_metadata.py

Lines changed: 41 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -235,8 +235,48 @@ async def check_call(args):
235235

236236

237237
def test_complex_function_json_schema():
238+
"""Test JSON schema generation for complex function arguments.
239+
240+
Note: This test accepts two equivalent JSON Schema formats for models with defaults:
241+
1. Pre-pydantic 2.7.2:
242+
{
243+
"$ref": "#/$defs/Model",
244+
"default": {}
245+
}
246+
247+
2. Pydantic 2.7.2+:
248+
{
249+
"allOf": [
250+
{
251+
"$ref": "#/$defs/Model"
252+
}
253+
],
254+
"default": {}
255+
}
256+
257+
Both formats are valid JSON Schema and represent the same validation rules.
258+
The newer format using allOf is more correct according to the JSON Schema spec
259+
as it properly composes the reference with additional properties.
260+
261+
This change in format does not affect runtime behavior since:
262+
1. Both schemas validate the same way
263+
2. The actual model classes and validation logic are unchanged
264+
3. func_metadata uses model_validate/model_dump, not the schema directly
265+
"""
238266
meta = func_metadata(complex_arguments_fn)
239-
assert meta.arg_model.model_json_schema() == {
267+
actual_schema = meta.arg_model.model_json_schema()
268+
269+
# Create a copy of the actual schema to normalize
270+
normalized_schema = actual_schema.copy()
271+
272+
# Normalize the my_model_a_with_default field to handle both pydantic formats
273+
if 'allOf' in actual_schema['properties']['my_model_a_with_default']:
274+
normalized_schema['properties']['my_model_a_with_default'] = {
275+
'$ref': '#/$defs/SomeInputModelA',
276+
'default': {}
277+
}
278+
279+
assert normalized_schema == {
240280
"$defs": {
241281
"InnerModel": {
242282
"properties": {"x": {"title": "X", "type": "integer"}},

0 commit comments

Comments
 (0)