Update ValidationError schema in FastAPI-related tests to be compatible with FastAPI 0.128.1+ (#1744)

This commit is contained in:
Motov Yurii
2026-02-05 12:58:01 +03:00
committed by GitHub
parent 944af80660
commit f1aad85fc1
12 changed files with 372 additions and 108 deletions

View File

@@ -2,6 +2,7 @@ import importlib
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"},
},
),
},
}
},

View File

@@ -2,6 +2,7 @@ import importlib
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"},
},
),
},
}
},

View File

@@ -2,6 +2,7 @@ import importlib
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"},
},
),
},
}
},

View File

@@ -2,6 +2,7 @@ import importlib
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"},
},
),
},
}
},

View File

@@ -2,6 +2,7 @@ import importlib
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"},
},
),
},
}
},

View File

@@ -2,6 +2,7 @@ import importlib
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"},
},
),
},
}
},

View File

@@ -2,6 +2,7 @@ import importlib
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"},
},
),
},
}
},

View File

@@ -2,6 +2,7 @@ import importlib
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"},
},
),
},
}
},

View File

@@ -2,6 +2,7 @@ import importlib
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"},
},
),
},
}
},

View File

@@ -2,6 +2,7 @@ import importlib
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"},
},
),
},
}
},

View File

@@ -2,6 +2,7 @@ import importlib
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"},
},
),
},
}
},

View File

@@ -2,6 +2,7 @@ import importlib
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"},
},
),
},
}
},