From d9fc682ab03cc9b1334c562efcfd2654d41cd39c Mon Sep 17 00:00:00 2001 From: Yurii Motov Date: Wed, 4 Feb 2026 23:34:14 +0100 Subject: [PATCH] Update `ValidationError` schema --- .../test_delete/test_tutorial001.py | 40 ++++++++++++++----- .../test_limit_and_offset/test_tutorial001.py | 40 ++++++++++++++----- .../test_multiple_models/test_tutorial001.py | 40 ++++++++++++++----- .../test_multiple_models/test_tutorial002.py | 40 ++++++++++++++----- .../test_read_one/test_tutorial001.py | 40 ++++++++++++++----- .../test_relationships/test_tutorial001.py | 40 ++++++++++++++----- .../test_response_model/test_tutorial001.py | 40 ++++++++++++++----- .../test_tutorial001.py | 40 ++++++++++++++----- .../test_simple_hero_api/test_tutorial001.py | 40 ++++++++++++++----- .../test_teams/test_tutorial001.py | 40 ++++++++++++++----- .../test_update/test_tutorial001.py | 40 ++++++++++++++----- .../test_update/test_tutorial002.py | 40 ++++++++++++++----- 12 files changed, 372 insertions(+), 108 deletions(-) diff --git a/tests/test_tutorial/test_fastapi/test_delete/test_tutorial001.py b/tests/test_tutorial/test_fastapi/test_delete/test_tutorial001.py index a766b37d47..d3dea79f47 100644 --- a/tests/test_tutorial/test_fastapi/test_delete/test_tutorial001.py +++ b/tests/test_tutorial/test_fastapi/test_delete/test_tutorial001.py @@ -2,6 +2,7 @@ from types import ModuleType import pytest +from dirty_equals import IsOneOf from fastapi.testclient import TestClient from sqlmodel import create_engine from sqlmodel.pool import StaticPool @@ -341,17 +342,38 @@ def test_tutorial(module: ModuleType): "title": "ValidationError", "required": ["loc", "msg", "type"], "type": "object", - "properties": { - "loc": { - "title": "Location", - "type": "array", - "items": { - "anyOf": [{"type": "string"}, {"type": "integer"}] + "properties": IsOneOf( + { + "loc": { + "title": "Location", + "type": "array", + "items": { + "anyOf": [ + {"type": "string"}, + {"type": "integer"}, + ] + }, }, + "msg": {"title": "Message", "type": "string"}, + "type": {"title": "Error Type", "type": "string"}, }, - "msg": {"title": "Message", "type": "string"}, - "type": {"title": "Error Type", "type": "string"}, - }, + { + "loc": { + "title": "Location", + "type": "array", + "items": { + "anyOf": [ + {"type": "string"}, + {"type": "integer"}, + ] + }, + }, + "msg": {"title": "Message", "type": "string"}, + "type": {"title": "Error Type", "type": "string"}, + "ctx": {"title": "Context", "type": "object"}, + "input": {"title": "Input"}, + }, + ), }, } }, diff --git a/tests/test_tutorial/test_fastapi/test_limit_and_offset/test_tutorial001.py b/tests/test_tutorial/test_fastapi/test_limit_and_offset/test_tutorial001.py index 241241a422..99f5566360 100644 --- a/tests/test_tutorial/test_fastapi/test_limit_and_offset/test_tutorial001.py +++ b/tests/test_tutorial/test_fastapi/test_limit_and_offset/test_tutorial001.py @@ -2,6 +2,7 @@ from types import ModuleType import pytest +from dirty_equals import IsOneOf from fastapi.testclient import TestClient from sqlmodel import create_engine from sqlmodel.pool import StaticPool @@ -258,17 +259,38 @@ def test_tutorial(module: ModuleType): "title": "ValidationError", "required": ["loc", "msg", "type"], "type": "object", - "properties": { - "loc": { - "title": "Location", - "type": "array", - "items": { - "anyOf": [{"type": "string"}, {"type": "integer"}] + "properties": IsOneOf( + { + "loc": { + "title": "Location", + "type": "array", + "items": { + "anyOf": [ + {"type": "string"}, + {"type": "integer"}, + ] + }, }, + "msg": {"title": "Message", "type": "string"}, + "type": {"title": "Error Type", "type": "string"}, }, - "msg": {"title": "Message", "type": "string"}, - "type": {"title": "Error Type", "type": "string"}, - }, + { + "loc": { + "title": "Location", + "type": "array", + "items": { + "anyOf": [ + {"type": "string"}, + {"type": "integer"}, + ] + }, + }, + "msg": {"title": "Message", "type": "string"}, + "type": {"title": "Error Type", "type": "string"}, + "ctx": {"title": "Context", "type": "object"}, + "input": {"title": "Input"}, + }, + ), }, } }, diff --git a/tests/test_tutorial/test_fastapi/test_multiple_models/test_tutorial001.py b/tests/test_tutorial/test_fastapi/test_multiple_models/test_tutorial001.py index 1690ba26ef..5e3a956069 100644 --- a/tests/test_tutorial/test_fastapi/test_multiple_models/test_tutorial001.py +++ b/tests/test_tutorial/test_fastapi/test_multiple_models/test_tutorial001.py @@ -2,6 +2,7 @@ from types import ModuleType import pytest +from dirty_equals import IsOneOf from fastapi.testclient import TestClient from sqlalchemy import inspect from sqlalchemy.engine.reflection import Inspector @@ -182,17 +183,38 @@ def test_tutorial(module: ModuleType): "title": "ValidationError", "required": ["loc", "msg", "type"], "type": "object", - "properties": { - "loc": { - "title": "Location", - "type": "array", - "items": { - "anyOf": [{"type": "string"}, {"type": "integer"}] + "properties": IsOneOf( + { + "loc": { + "title": "Location", + "type": "array", + "items": { + "anyOf": [ + {"type": "string"}, + {"type": "integer"}, + ] + }, }, + "msg": {"title": "Message", "type": "string"}, + "type": {"title": "Error Type", "type": "string"}, }, - "msg": {"title": "Message", "type": "string"}, - "type": {"title": "Error Type", "type": "string"}, - }, + { + "loc": { + "title": "Location", + "type": "array", + "items": { + "anyOf": [ + {"type": "string"}, + {"type": "integer"}, + ] + }, + }, + "msg": {"title": "Message", "type": "string"}, + "type": {"title": "Error Type", "type": "string"}, + "ctx": {"title": "Context", "type": "object"}, + "input": {"title": "Input"}, + }, + ), }, } }, diff --git a/tests/test_tutorial/test_fastapi/test_multiple_models/test_tutorial002.py b/tests/test_tutorial/test_fastapi/test_multiple_models/test_tutorial002.py index b17fc20ffa..d8a891ff1b 100644 --- a/tests/test_tutorial/test_fastapi/test_multiple_models/test_tutorial002.py +++ b/tests/test_tutorial/test_fastapi/test_multiple_models/test_tutorial002.py @@ -2,6 +2,7 @@ from types import ModuleType import pytest +from dirty_equals import IsOneOf from fastapi.testclient import TestClient from sqlalchemy import inspect from sqlalchemy.engine.reflection import Inspector @@ -182,17 +183,38 @@ def test_tutorial(module: ModuleType): "title": "ValidationError", "required": ["loc", "msg", "type"], "type": "object", - "properties": { - "loc": { - "title": "Location", - "type": "array", - "items": { - "anyOf": [{"type": "string"}, {"type": "integer"}] + "properties": IsOneOf( + { + "loc": { + "title": "Location", + "type": "array", + "items": { + "anyOf": [ + {"type": "string"}, + {"type": "integer"}, + ] + }, }, + "msg": {"title": "Message", "type": "string"}, + "type": {"title": "Error Type", "type": "string"}, }, - "msg": {"title": "Message", "type": "string"}, - "type": {"title": "Error Type", "type": "string"}, - }, + { + "loc": { + "title": "Location", + "type": "array", + "items": { + "anyOf": [ + {"type": "string"}, + {"type": "integer"}, + ] + }, + }, + "msg": {"title": "Message", "type": "string"}, + "type": {"title": "Error Type", "type": "string"}, + "ctx": {"title": "Context", "type": "object"}, + "input": {"title": "Input"}, + }, + ), }, } }, diff --git a/tests/test_tutorial/test_fastapi/test_read_one/test_tutorial001.py b/tests/test_tutorial/test_fastapi/test_read_one/test_tutorial001.py index 420da4a379..8b22e050c5 100644 --- a/tests/test_tutorial/test_fastapi/test_read_one/test_tutorial001.py +++ b/tests/test_tutorial/test_fastapi/test_read_one/test_tutorial001.py @@ -2,6 +2,7 @@ from types import ModuleType import pytest +from dirty_equals import IsOneOf from fastapi.testclient import TestClient from sqlmodel import create_engine from sqlmodel.pool import StaticPool @@ -201,17 +202,38 @@ def test_tutorial(module: ModuleType): "title": "ValidationError", "required": ["loc", "msg", "type"], "type": "object", - "properties": { - "loc": { - "title": "Location", - "type": "array", - "items": { - "anyOf": [{"type": "string"}, {"type": "integer"}] + "properties": IsOneOf( + { + "loc": { + "title": "Location", + "type": "array", + "items": { + "anyOf": [ + {"type": "string"}, + {"type": "integer"}, + ] + }, }, + "msg": {"title": "Message", "type": "string"}, + "type": {"title": "Error Type", "type": "string"}, }, - "msg": {"title": "Message", "type": "string"}, - "type": {"title": "Error Type", "type": "string"}, - }, + { + "loc": { + "title": "Location", + "type": "array", + "items": { + "anyOf": [ + {"type": "string"}, + {"type": "integer"}, + ] + }, + }, + "msg": {"title": "Message", "type": "string"}, + "type": {"title": "Error Type", "type": "string"}, + "ctx": {"title": "Context", "type": "object"}, + "input": {"title": "Input"}, + }, + ), }, } }, diff --git a/tests/test_tutorial/test_fastapi/test_relationships/test_tutorial001.py b/tests/test_tutorial/test_fastapi/test_relationships/test_tutorial001.py index 07be8c3089..4756ac6c86 100644 --- a/tests/test_tutorial/test_fastapi/test_relationships/test_tutorial001.py +++ b/tests/test_tutorial/test_fastapi/test_relationships/test_tutorial001.py @@ -2,6 +2,7 @@ from types import ModuleType import pytest +from dirty_equals import IsOneOf from fastapi.testclient import TestClient from sqlmodel import create_engine from sqlmodel.pool import StaticPool @@ -679,17 +680,38 @@ def test_tutorial(module: ModuleType): "title": "ValidationError", "required": ["loc", "msg", "type"], "type": "object", - "properties": { - "loc": { - "title": "Location", - "type": "array", - "items": { - "anyOf": [{"type": "string"}, {"type": "integer"}] + "properties": IsOneOf( + { + "loc": { + "title": "Location", + "type": "array", + "items": { + "anyOf": [ + {"type": "string"}, + {"type": "integer"}, + ] + }, }, + "msg": {"title": "Message", "type": "string"}, + "type": {"title": "Error Type", "type": "string"}, }, - "msg": {"title": "Message", "type": "string"}, - "type": {"title": "Error Type", "type": "string"}, - }, + { + "loc": { + "title": "Location", + "type": "array", + "items": { + "anyOf": [ + {"type": "string"}, + {"type": "integer"}, + ] + }, + }, + "msg": {"title": "Message", "type": "string"}, + "type": {"title": "Error Type", "type": "string"}, + "ctx": {"title": "Context", "type": "object"}, + "input": {"title": "Input"}, + }, + ), }, } }, diff --git a/tests/test_tutorial/test_fastapi/test_response_model/test_tutorial001.py b/tests/test_tutorial/test_fastapi/test_response_model/test_tutorial001.py index 2951268d99..77a7fc6f68 100644 --- a/tests/test_tutorial/test_fastapi/test_response_model/test_tutorial001.py +++ b/tests/test_tutorial/test_fastapi/test_response_model/test_tutorial001.py @@ -2,6 +2,7 @@ from types import ModuleType import pytest +from dirty_equals import IsOneOf from fastapi.testclient import TestClient from sqlmodel import create_engine from sqlmodel.pool import StaticPool @@ -146,17 +147,38 @@ def test_tutorial(module: ModuleType): "title": "ValidationError", "required": ["loc", "msg", "type"], "type": "object", - "properties": { - "loc": { - "title": "Location", - "type": "array", - "items": { - "anyOf": [{"type": "string"}, {"type": "integer"}] + "properties": IsOneOf( + { + "loc": { + "title": "Location", + "type": "array", + "items": { + "anyOf": [ + {"type": "string"}, + {"type": "integer"}, + ] + }, }, + "msg": {"title": "Message", "type": "string"}, + "type": {"title": "Error Type", "type": "string"}, }, - "msg": {"title": "Message", "type": "string"}, - "type": {"title": "Error Type", "type": "string"}, - }, + { + "loc": { + "title": "Location", + "type": "array", + "items": { + "anyOf": [ + {"type": "string"}, + {"type": "integer"}, + ] + }, + }, + "msg": {"title": "Message", "type": "string"}, + "type": {"title": "Error Type", "type": "string"}, + "ctx": {"title": "Context", "type": "object"}, + "input": {"title": "Input"}, + }, + ), }, } }, diff --git a/tests/test_tutorial/test_fastapi/test_session_with_dependency/test_tutorial001.py b/tests/test_tutorial/test_fastapi/test_session_with_dependency/test_tutorial001.py index 6528f85333..ffd0381bfb 100644 --- a/tests/test_tutorial/test_fastapi/test_session_with_dependency/test_tutorial001.py +++ b/tests/test_tutorial/test_fastapi/test_session_with_dependency/test_tutorial001.py @@ -2,6 +2,7 @@ from types import ModuleType import pytest +from dirty_equals import IsOneOf from fastapi.testclient import TestClient from sqlmodel import create_engine from sqlmodel.pool import StaticPool @@ -343,17 +344,38 @@ def test_tutorial(module: ModuleType): "title": "ValidationError", "required": ["loc", "msg", "type"], "type": "object", - "properties": { - "loc": { - "title": "Location", - "type": "array", - "items": { - "anyOf": [{"type": "string"}, {"type": "integer"}] + "properties": IsOneOf( + { + "loc": { + "title": "Location", + "type": "array", + "items": { + "anyOf": [ + {"type": "string"}, + {"type": "integer"}, + ] + }, }, + "msg": {"title": "Message", "type": "string"}, + "type": {"title": "Error Type", "type": "string"}, }, - "msg": {"title": "Message", "type": "string"}, - "type": {"title": "Error Type", "type": "string"}, - }, + { + "loc": { + "title": "Location", + "type": "array", + "items": { + "anyOf": [ + {"type": "string"}, + {"type": "integer"}, + ] + }, + }, + "msg": {"title": "Message", "type": "string"}, + "type": {"title": "Error Type", "type": "string"}, + "ctx": {"title": "Context", "type": "object"}, + "input": {"title": "Input"}, + }, + ), }, } }, diff --git a/tests/test_tutorial/test_fastapi/test_simple_hero_api/test_tutorial001.py b/tests/test_tutorial/test_fastapi/test_simple_hero_api/test_tutorial001.py index b6f88b136e..17c69440a8 100644 --- a/tests/test_tutorial/test_fastapi/test_simple_hero_api/test_tutorial001.py +++ b/tests/test_tutorial/test_fastapi/test_simple_hero_api/test_tutorial001.py @@ -2,6 +2,7 @@ from types import ModuleType import pytest +from dirty_equals import IsOneOf from fastapi.testclient import TestClient from sqlmodel import create_engine from sqlmodel.pool import StaticPool @@ -152,17 +153,38 @@ def test_tutorial(module: ModuleType): "title": "ValidationError", "required": ["loc", "msg", "type"], "type": "object", - "properties": { - "loc": { - "title": "Location", - "type": "array", - "items": { - "anyOf": [{"type": "string"}, {"type": "integer"}] + "properties": IsOneOf( + { + "loc": { + "title": "Location", + "type": "array", + "items": { + "anyOf": [ + {"type": "string"}, + {"type": "integer"}, + ] + }, }, + "msg": {"title": "Message", "type": "string"}, + "type": {"title": "Error Type", "type": "string"}, }, - "msg": {"title": "Message", "type": "string"}, - "type": {"title": "Error Type", "type": "string"}, - }, + { + "loc": { + "title": "Location", + "type": "array", + "items": { + "anyOf": [ + {"type": "string"}, + {"type": "integer"}, + ] + }, + }, + "msg": {"title": "Message", "type": "string"}, + "type": {"title": "Error Type", "type": "string"}, + "ctx": {"title": "Context", "type": "object"}, + "input": {"title": "Input"}, + }, + ), }, } }, diff --git a/tests/test_tutorial/test_fastapi/test_teams/test_tutorial001.py b/tests/test_tutorial/test_fastapi/test_teams/test_tutorial001.py index 6982ee9913..c770b4718f 100644 --- a/tests/test_tutorial/test_fastapi/test_teams/test_tutorial001.py +++ b/tests/test_tutorial/test_fastapi/test_teams/test_tutorial001.py @@ -2,6 +2,7 @@ from types import ModuleType import pytest +from dirty_equals import IsOneOf from fastapi.testclient import TestClient from sqlmodel import create_engine from sqlmodel.pool import StaticPool @@ -620,17 +621,38 @@ def test_tutorial(module: ModuleType): "title": "ValidationError", "required": ["loc", "msg", "type"], "type": "object", - "properties": { - "loc": { - "title": "Location", - "type": "array", - "items": { - "anyOf": [{"type": "string"}, {"type": "integer"}] + "properties": IsOneOf( + { + "loc": { + "title": "Location", + "type": "array", + "items": { + "anyOf": [ + {"type": "string"}, + {"type": "integer"}, + ] + }, }, + "msg": {"title": "Message", "type": "string"}, + "type": {"title": "Error Type", "type": "string"}, }, - "msg": {"title": "Message", "type": "string"}, - "type": {"title": "Error Type", "type": "string"}, - }, + { + "loc": { + "title": "Location", + "type": "array", + "items": { + "anyOf": [ + {"type": "string"}, + {"type": "integer"}, + ] + }, + }, + "msg": {"title": "Message", "type": "string"}, + "type": {"title": "Error Type", "type": "string"}, + "ctx": {"title": "Context", "type": "object"}, + "input": {"title": "Input"}, + }, + ), }, } }, diff --git a/tests/test_tutorial/test_fastapi/test_update/test_tutorial001.py b/tests/test_tutorial/test_fastapi/test_update/test_tutorial001.py index cba5c1ae62..b28ca100b0 100644 --- a/tests/test_tutorial/test_fastapi/test_update/test_tutorial001.py +++ b/tests/test_tutorial/test_fastapi/test_update/test_tutorial001.py @@ -2,6 +2,7 @@ from types import ModuleType import pytest +from dirty_equals import IsOneOf from fastapi.testclient import TestClient from sqlmodel import create_engine from sqlmodel.pool import StaticPool @@ -320,17 +321,38 @@ def test_tutorial(module: ModuleType): "title": "ValidationError", "required": ["loc", "msg", "type"], "type": "object", - "properties": { - "loc": { - "title": "Location", - "type": "array", - "items": { - "anyOf": [{"type": "string"}, {"type": "integer"}] + "properties": IsOneOf( + { + "loc": { + "title": "Location", + "type": "array", + "items": { + "anyOf": [ + {"type": "string"}, + {"type": "integer"}, + ] + }, }, + "msg": {"title": "Message", "type": "string"}, + "type": {"title": "Error Type", "type": "string"}, }, - "msg": {"title": "Message", "type": "string"}, - "type": {"title": "Error Type", "type": "string"}, - }, + { + "loc": { + "title": "Location", + "type": "array", + "items": { + "anyOf": [ + {"type": "string"}, + {"type": "integer"}, + ] + }, + }, + "msg": {"title": "Message", "type": "string"}, + "type": {"title": "Error Type", "type": "string"}, + "ctx": {"title": "Context", "type": "object"}, + "input": {"title": "Input"}, + }, + ), }, } }, diff --git a/tests/test_tutorial/test_fastapi/test_update/test_tutorial002.py b/tests/test_tutorial/test_fastapi/test_update/test_tutorial002.py index 22110ecb03..1b784b2f64 100644 --- a/tests/test_tutorial/test_fastapi/test_update/test_tutorial002.py +++ b/tests/test_tutorial/test_fastapi/test_update/test_tutorial002.py @@ -2,6 +2,7 @@ from types import ModuleType import pytest +from dirty_equals import IsOneOf from fastapi.testclient import TestClient from sqlmodel import Session, create_engine from sqlmodel.pool import StaticPool @@ -388,17 +389,38 @@ def test_tutorial(module: ModuleType): "title": "ValidationError", "required": ["loc", "msg", "type"], "type": "object", - "properties": { - "loc": { - "title": "Location", - "type": "array", - "items": { - "anyOf": [{"type": "string"}, {"type": "integer"}] + "properties": IsOneOf( + { + "loc": { + "title": "Location", + "type": "array", + "items": { + "anyOf": [ + {"type": "string"}, + {"type": "integer"}, + ] + }, }, + "msg": {"title": "Message", "type": "string"}, + "type": {"title": "Error Type", "type": "string"}, }, - "msg": {"title": "Message", "type": "string"}, - "type": {"title": "Error Type", "type": "string"}, - }, + { + "loc": { + "title": "Location", + "type": "array", + "items": { + "anyOf": [ + {"type": "string"}, + {"type": "integer"}, + ] + }, + }, + "msg": {"title": "Message", "type": "string"}, + "type": {"title": "Error Type", "type": "string"}, + "ctx": {"title": "Context", "type": "object"}, + "input": {"title": "Input"}, + }, + ), }, } },