Skip to content

Commit c449ae5

Browse files
dconathandconatha
andauthored
🐛 Fix JSON Schema for ValidationError at field loc (#3810)
Co-authored-by: Devin Conathan <[email protected]>
1 parent 1d8d81a commit c449ae5

File tree

78 files changed

+83
-79
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

78 files changed

+83
-79
lines changed

fastapi/openapi/utils.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,11 @@
3838
"title": "ValidationError",
3939
"type": "object",
4040
"properties": {
41-
"loc": {"title": "Location", "type": "array", "items": {"type": "string"}},
41+
"loc": {
42+
"title": "Location",
43+
"type": "array",
44+
"items": {"anyOf": [{"type": "string"}, {"type": "integer"}]},
45+
},
4246
"msg": {"title": "Message", "type": "string"},
4347
"type": {"title": "Error Type", "type": "string"},
4448
},

tests/test_additional_properties.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ def foo(items: Items):
7676
"loc": {
7777
"title": "Location",
7878
"type": "array",
79-
"items": {"type": "string"},
79+
"items": {"anyOf": [{"type": "string"}, {"type": "integer"}]},
8080
},
8181
"msg": {"title": "Message", "type": "string"},
8282
"type": {"title": "Error Type", "type": "string"},

tests/test_additional_responses_custom_model_in_callback.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ def main_route(callback_url: HttpUrl):
119119
"loc": {
120120
"title": "Location",
121121
"type": "array",
122-
"items": {"type": "string"},
122+
"items": {"anyOf": [{"type": "string"}, {"type": "integer"}]},
123123
},
124124
"msg": {"title": "Message", "type": "string"},
125125
"type": {"title": "Error Type", "type": "string"},

tests/test_additional_responses_default_validationerror.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ async def a(id):
5454
"loc": {
5555
"title": "Location",
5656
"type": "array",
57-
"items": {"type": "string"},
57+
"items": {"anyOf": [{"type": "string"}, {"type": "integer"}]},
5858
},
5959
"msg": {"title": "Message", "type": "string"},
6060
"type": {"title": "Error Type", "type": "string"},

tests/test_application.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1101,7 +1101,7 @@
11011101
"loc": {
11021102
"title": "Location",
11031103
"type": "array",
1104-
"items": {"type": "string"},
1104+
"items": {"anyOf": [{"type": "string"}, {"type": "integer"}]},
11051105
},
11061106
"msg": {"title": "Message", "type": "string"},
11071107
"type": {"title": "Error Type", "type": "string"},

tests/test_dependency_duplicates.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ async def no_duplicates_sub(
177177
"loc": {
178178
"title": "Location",
179179
"type": "array",
180-
"items": {"type": "string"},
180+
"items": {"anyOf": [{"type": "string"}, {"type": "integer"}]},
181181
},
182182
"msg": {"title": "Message", "type": "string"},
183183
"type": {"title": "Error Type", "type": "string"},

tests/test_extra_routes.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -292,7 +292,7 @@ def trace_item(item_id: str):
292292
"loc": {
293293
"title": "Location",
294294
"type": "array",
295-
"items": {"type": "string"},
295+
"items": {"anyOf": [{"type": "string"}, {"type": "integer"}]},
296296
},
297297
"msg": {"title": "Message", "type": "string"},
298298
"type": {"title": "Error Type", "type": "string"},

tests/test_filter_pydantic_sub_model.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ async def get_model_a(name: str, model_c=Depends(get_model_c)):
116116
"loc": {
117117
"title": "Location",
118118
"type": "array",
119-
"items": {"type": "string"},
119+
"items": {"anyOf": [{"type": "string"}, {"type": "integer"}]},
120120
},
121121
"msg": {"title": "Message", "type": "string"},
122122
"type": {"title": "Error Type", "type": "string"},

tests/test_get_request_body.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ async def create_item(product: Product):
8585
"loc": {
8686
"title": "Location",
8787
"type": "array",
88-
"items": {"type": "string"},
88+
"items": {"anyOf": [{"type": "string"}, {"type": "integer"}]},
8989
},
9090
"msg": {"title": "Message", "type": "string"},
9191
"type": {"title": "Error Type", "type": "string"},

tests/test_include_router_defaults_overrides.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6612,7 +6612,7 @@ def test_paths_level5(override1, override2, override3, override4, override5):
66126612
"loc": {
66136613
"title": "Location",
66146614
"type": "array",
6615-
"items": {"type": "string"},
6615+
"items": {"anyOf": [{"type": "string"}, {"type": "integer"}]},
66166616
},
66176617
"msg": {"title": "Message", "type": "string"},
66186618
"type": {"title": "Error Type", "type": "string"},

0 commit comments

Comments
 (0)