✨ Add support for Pydantic v2 (while keeping support for v1 if v2 is not available), including initial work by AntonDeMeester (#722)
Co-authored-by: Mohamed Farahat <farahats9@yahoo.com> Co-authored-by: Stefan Borer <stefan.borer@gmail.com> Co-authored-by: Peter Landry <peter.landry@gmail.com> Co-authored-by: Anton De Meester <antondemeester+github@gmail.com>
This commit is contained in:
committed by
GitHub
parent
5b733b348d
commit
fa2f178b8a
@@ -7,6 +7,7 @@ from typing import Any, Callable, Dict, List, Union
|
||||
import pytest
|
||||
from pydantic import BaseModel
|
||||
from sqlmodel import SQLModel
|
||||
from sqlmodel._compat import IS_PYDANTIC_V2
|
||||
from sqlmodel.main import default_registry
|
||||
|
||||
top_level_path = Path(__file__).resolve().parent.parent
|
||||
@@ -56,12 +57,12 @@ def get_testing_print_function(
|
||||
data = []
|
||||
for arg in args:
|
||||
if isinstance(arg, BaseModel):
|
||||
data.append(arg.dict())
|
||||
data.append(arg.model_dump())
|
||||
elif isinstance(arg, list):
|
||||
new_list = []
|
||||
for item in arg:
|
||||
if isinstance(item, BaseModel):
|
||||
new_list.append(item.dict())
|
||||
new_list.append(item.model_dump())
|
||||
data.append(new_list)
|
||||
else:
|
||||
data.append(arg)
|
||||
@@ -70,6 +71,9 @@ def get_testing_print_function(
|
||||
return new_print
|
||||
|
||||
|
||||
needs_pydanticv2 = pytest.mark.skipif(not IS_PYDANTIC_V2, reason="requires Pydantic v2")
|
||||
needs_pydanticv1 = pytest.mark.skipif(IS_PYDANTIC_V2, reason="requires Pydantic v1")
|
||||
|
||||
needs_py39 = pytest.mark.skipif(sys.version_info < (3, 9), reason="requires python3.9+")
|
||||
needs_py310 = pytest.mark.skipif(
|
||||
sys.version_info < (3, 10), reason="requires python3.10+"
|
||||
|
||||
30
tests/test_deprecations.py
Normal file
30
tests/test_deprecations.py
Normal file
@@ -0,0 +1,30 @@
|
||||
import pytest
|
||||
from sqlmodel import SQLModel
|
||||
|
||||
|
||||
class Item(SQLModel):
|
||||
name: str
|
||||
|
||||
|
||||
class SubItem(Item):
|
||||
password: str
|
||||
|
||||
|
||||
def test_deprecated_from_orm_inheritance():
|
||||
new_item = SubItem(name="Hello", password="secret")
|
||||
with pytest.warns(DeprecationWarning):
|
||||
item = Item.from_orm(new_item)
|
||||
assert item.name == "Hello"
|
||||
assert not hasattr(item, "password")
|
||||
|
||||
|
||||
def test_deprecated_parse_obj():
|
||||
with pytest.warns(DeprecationWarning):
|
||||
item = Item.parse_obj({"name": "Hello"})
|
||||
assert item.name == "Hello"
|
||||
|
||||
|
||||
def test_deprecated_dict():
|
||||
with pytest.warns(DeprecationWarning):
|
||||
data = Item(name="Hello").dict()
|
||||
assert data == {"name": "Hello"}
|
||||
@@ -5,6 +5,8 @@ from sqlalchemy import create_mock_engine
|
||||
from sqlalchemy.sql.type_api import TypeEngine
|
||||
from sqlmodel import Field, SQLModel
|
||||
|
||||
from .conftest import needs_pydanticv1, needs_pydanticv2
|
||||
|
||||
"""
|
||||
Tests related to Enums
|
||||
|
||||
@@ -72,7 +74,8 @@ def test_sqlite_ddl_sql(capsys):
|
||||
assert "CREATE TYPE" not in captured.out
|
||||
|
||||
|
||||
def test_json_schema_flat_model():
|
||||
@needs_pydanticv1
|
||||
def test_json_schema_flat_model_pydantic_v1():
|
||||
assert FlatModel.schema() == {
|
||||
"title": "FlatModel",
|
||||
"type": "object",
|
||||
@@ -92,7 +95,8 @@ def test_json_schema_flat_model():
|
||||
}
|
||||
|
||||
|
||||
def test_json_schema_inherit_model():
|
||||
@needs_pydanticv1
|
||||
def test_json_schema_inherit_model_pydantic_v1():
|
||||
assert InheritModel.schema() == {
|
||||
"title": "InheritModel",
|
||||
"type": "object",
|
||||
@@ -110,3 +114,35 @@ def test_json_schema_inherit_model():
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
|
||||
@needs_pydanticv2
|
||||
def test_json_schema_flat_model_pydantic_v2():
|
||||
assert FlatModel.model_json_schema() == {
|
||||
"title": "FlatModel",
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"id": {"title": "Id", "type": "string", "format": "uuid"},
|
||||
"enum_field": {"$ref": "#/$defs/MyEnum1"},
|
||||
},
|
||||
"required": ["id", "enum_field"],
|
||||
"$defs": {
|
||||
"MyEnum1": {"enum": ["A", "B"], "title": "MyEnum1", "type": "string"}
|
||||
},
|
||||
}
|
||||
|
||||
|
||||
@needs_pydanticv2
|
||||
def test_json_schema_inherit_model_pydantic_v2():
|
||||
assert InheritModel.model_json_schema() == {
|
||||
"title": "InheritModel",
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"id": {"title": "Id", "type": "string", "format": "uuid"},
|
||||
"enum_field": {"$ref": "#/$defs/MyEnum2"},
|
||||
},
|
||||
"required": ["id", "enum_field"],
|
||||
"$defs": {
|
||||
"MyEnum2": {"enum": ["C", "D"], "title": "MyEnum2", "type": "string"}
|
||||
},
|
||||
}
|
||||
|
||||
@@ -6,7 +6,7 @@ from sqlmodel import Field, Relationship, SQLModel
|
||||
|
||||
|
||||
def test_sa_relationship_no_args() -> None:
|
||||
with pytest.raises(RuntimeError):
|
||||
with pytest.raises(RuntimeError): # pragma: no cover
|
||||
|
||||
class Team(SQLModel, table=True):
|
||||
id: Optional[int] = Field(default=None, primary_key=True)
|
||||
@@ -30,7 +30,7 @@ def test_sa_relationship_no_args() -> None:
|
||||
|
||||
|
||||
def test_sa_relationship_no_kwargs() -> None:
|
||||
with pytest.raises(RuntimeError):
|
||||
with pytest.raises(RuntimeError): # pragma: no cover
|
||||
|
||||
class Team(SQLModel, table=True):
|
||||
id: Optional[int] = Field(default=None, primary_key=True)
|
||||
|
||||
@@ -1,19 +1,16 @@
|
||||
from typing import Optional
|
||||
|
||||
from sqlalchemy import create_engine, select
|
||||
from sqlalchemy.orm import Session
|
||||
from sqlmodel import Field, SQLModel
|
||||
import pytest
|
||||
from pydantic import ValidationError
|
||||
from sqlmodel import Field, Session, SQLModel, create_engine, select
|
||||
|
||||
|
||||
def test_allow_instantiation_without_arguments(clear_sqlmodel):
|
||||
class Item(SQLModel):
|
||||
class Item(SQLModel, table=True):
|
||||
id: Optional[int] = Field(default=None, primary_key=True)
|
||||
name: str
|
||||
description: Optional[str] = None
|
||||
|
||||
class Config:
|
||||
table = True
|
||||
|
||||
engine = create_engine("sqlite:///:memory:")
|
||||
SQLModel.metadata.create_all(engine)
|
||||
with Session(engine) as db:
|
||||
@@ -21,7 +18,18 @@ def test_allow_instantiation_without_arguments(clear_sqlmodel):
|
||||
item.name = "Rick"
|
||||
db.add(item)
|
||||
db.commit()
|
||||
result = db.execute(select(Item)).scalars().all()
|
||||
statement = select(Item)
|
||||
result = db.exec(statement).all()
|
||||
assert len(result) == 1
|
||||
assert isinstance(item.id, int)
|
||||
SQLModel.metadata.clear()
|
||||
|
||||
|
||||
def test_not_allow_instantiation_without_arguments_if_not_table():
|
||||
class Item(SQLModel):
|
||||
id: Optional[int] = Field(default=None, primary_key=True)
|
||||
name: str
|
||||
description: Optional[str] = None
|
||||
|
||||
with pytest.raises(ValidationError):
|
||||
Item()
|
||||
|
||||
@@ -91,7 +91,6 @@ def test_should_raise_exception_when_try_to_duplicate_row_if_unique_constraint_i
|
||||
with Session(engine) as session:
|
||||
session.add(hero_2)
|
||||
session.commit()
|
||||
session.refresh(hero_2)
|
||||
|
||||
|
||||
def test_sa_relationship_property(clear_sqlmodel):
|
||||
|
||||
@@ -1,17 +1,18 @@
|
||||
from typing import Optional
|
||||
|
||||
import pytest
|
||||
from pydantic import BaseModel
|
||||
from sqlmodel import Field, SQLModel
|
||||
|
||||
|
||||
def test_missing_sql_type():
|
||||
class CustomType:
|
||||
class CustomType(BaseModel):
|
||||
@classmethod
|
||||
def __get_validators__(cls):
|
||||
yield cls.validate
|
||||
|
||||
@classmethod
|
||||
def validate(cls, v):
|
||||
def validate(cls, v): # pragma: no cover
|
||||
return v
|
||||
|
||||
with pytest.raises(ValueError):
|
||||
|
||||
@@ -58,7 +58,7 @@ def test_nullable_fields(clear_sqlmodel, caplog):
|
||||
][0]
|
||||
assert "primary_key INTEGER NOT NULL," in create_table_log
|
||||
assert "required_value VARCHAR NOT NULL," in create_table_log
|
||||
assert "optional_default_ellipsis VARCHAR NOT NULL," in create_table_log
|
||||
assert "optional_default_ellipsis VARCHAR," in create_table_log
|
||||
assert "optional_default_none VARCHAR," in create_table_log
|
||||
assert "optional_non_nullable VARCHAR NOT NULL," in create_table_log
|
||||
assert "optional_nullable VARCHAR," in create_table_log
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
from typing import Optional
|
||||
|
||||
import pytest
|
||||
from sqlmodel import Field, Session, SQLModel, create_engine
|
||||
|
||||
|
||||
@@ -21,6 +22,7 @@ def test_query(clear_sqlmodel):
|
||||
session.refresh(hero_1)
|
||||
|
||||
with Session(engine) as session:
|
||||
query_hero = session.query(Hero).first()
|
||||
with pytest.warns(DeprecationWarning):
|
||||
query_hero = session.query(Hero).first()
|
||||
assert query_hero
|
||||
assert query_hero.name == hero_1.name
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
from dirty_equals import IsDict
|
||||
from fastapi.testclient import TestClient
|
||||
from sqlmodel import create_engine
|
||||
from sqlmodel.pool import StaticPool
|
||||
@@ -284,7 +285,16 @@ def test_tutorial(clear_sqlmodel):
|
||||
"properties": {
|
||||
"name": {"title": "Name", "type": "string"},
|
||||
"secret_name": {"title": "Secret Name", "type": "string"},
|
||||
"age": {"title": "Age", "type": "integer"},
|
||||
"age": IsDict(
|
||||
{
|
||||
"title": "Age",
|
||||
"anyOf": [{"type": "integer"}, {"type": "null"}],
|
||||
}
|
||||
)
|
||||
| IsDict(
|
||||
# TODO: remove when deprecating Pydantic v1
|
||||
{"title": "Age", "type": "integer"}
|
||||
),
|
||||
},
|
||||
},
|
||||
"HeroRead": {
|
||||
@@ -294,7 +304,16 @@ def test_tutorial(clear_sqlmodel):
|
||||
"properties": {
|
||||
"name": {"title": "Name", "type": "string"},
|
||||
"secret_name": {"title": "Secret Name", "type": "string"},
|
||||
"age": {"title": "Age", "type": "integer"},
|
||||
"age": IsDict(
|
||||
{
|
||||
"title": "Age",
|
||||
"anyOf": [{"type": "integer"}, {"type": "null"}],
|
||||
}
|
||||
)
|
||||
| IsDict(
|
||||
# TODO: remove when deprecating Pydantic v1
|
||||
{"title": "Age", "type": "integer"}
|
||||
),
|
||||
"id": {"title": "Id", "type": "integer"},
|
||||
},
|
||||
},
|
||||
@@ -302,9 +321,36 @@ def test_tutorial(clear_sqlmodel):
|
||||
"title": "HeroUpdate",
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"name": {"title": "Name", "type": "string"},
|
||||
"secret_name": {"title": "Secret Name", "type": "string"},
|
||||
"age": {"title": "Age", "type": "integer"},
|
||||
"name": IsDict(
|
||||
{
|
||||
"title": "Name",
|
||||
"anyOf": [{"type": "string"}, {"type": "null"}],
|
||||
}
|
||||
)
|
||||
| IsDict(
|
||||
# TODO: remove when deprecating Pydantic v1
|
||||
{"title": "Name", "type": "string"}
|
||||
),
|
||||
"secret_name": IsDict(
|
||||
{
|
||||
"title": "Secret Name",
|
||||
"anyOf": [{"type": "string"}, {"type": "null"}],
|
||||
}
|
||||
)
|
||||
| IsDict(
|
||||
# TODO: remove when deprecating Pydantic v1
|
||||
{"title": "Secret Name", "type": "string"}
|
||||
),
|
||||
"age": IsDict(
|
||||
{
|
||||
"title": "Age",
|
||||
"anyOf": [{"type": "integer"}, {"type": "null"}],
|
||||
}
|
||||
)
|
||||
| IsDict(
|
||||
# TODO: remove when deprecating Pydantic v1
|
||||
{"title": "Age", "type": "integer"}
|
||||
),
|
||||
},
|
||||
},
|
||||
"ValidationError": {
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
from dirty_equals import IsDict
|
||||
from fastapi.testclient import TestClient
|
||||
from sqlmodel import create_engine
|
||||
from sqlmodel.pool import StaticPool
|
||||
@@ -287,7 +288,16 @@ def test_tutorial(clear_sqlmodel):
|
||||
"properties": {
|
||||
"name": {"title": "Name", "type": "string"},
|
||||
"secret_name": {"title": "Secret Name", "type": "string"},
|
||||
"age": {"title": "Age", "type": "integer"},
|
||||
"age": IsDict(
|
||||
{
|
||||
"title": "Age",
|
||||
"anyOf": [{"type": "integer"}, {"type": "null"}],
|
||||
}
|
||||
)
|
||||
| IsDict(
|
||||
# TODO: remove when deprecating Pydantic v1
|
||||
{"title": "Age", "type": "integer"}
|
||||
),
|
||||
},
|
||||
},
|
||||
"HeroRead": {
|
||||
@@ -297,7 +307,16 @@ def test_tutorial(clear_sqlmodel):
|
||||
"properties": {
|
||||
"name": {"title": "Name", "type": "string"},
|
||||
"secret_name": {"title": "Secret Name", "type": "string"},
|
||||
"age": {"title": "Age", "type": "integer"},
|
||||
"age": IsDict(
|
||||
{
|
||||
"title": "Age",
|
||||
"anyOf": [{"type": "integer"}, {"type": "null"}],
|
||||
}
|
||||
)
|
||||
| IsDict(
|
||||
# TODO: remove when deprecating Pydantic v1
|
||||
{"title": "Age", "type": "integer"}
|
||||
),
|
||||
"id": {"title": "Id", "type": "integer"},
|
||||
},
|
||||
},
|
||||
@@ -305,9 +324,36 @@ def test_tutorial(clear_sqlmodel):
|
||||
"title": "HeroUpdate",
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"name": {"title": "Name", "type": "string"},
|
||||
"secret_name": {"title": "Secret Name", "type": "string"},
|
||||
"age": {"title": "Age", "type": "integer"},
|
||||
"name": IsDict(
|
||||
{
|
||||
"title": "Name",
|
||||
"anyOf": [{"type": "string"}, {"type": "null"}],
|
||||
}
|
||||
)
|
||||
| IsDict(
|
||||
# TODO: remove when deprecating Pydantic v1
|
||||
{"title": "Name", "type": "string"}
|
||||
),
|
||||
"secret_name": IsDict(
|
||||
{
|
||||
"title": "Secret Name",
|
||||
"anyOf": [{"type": "string"}, {"type": "null"}],
|
||||
}
|
||||
)
|
||||
| IsDict(
|
||||
# TODO: remove when deprecating Pydantic v1
|
||||
{"title": "Secret Name", "type": "string"}
|
||||
),
|
||||
"age": IsDict(
|
||||
{
|
||||
"title": "Age",
|
||||
"anyOf": [{"type": "integer"}, {"type": "null"}],
|
||||
}
|
||||
)
|
||||
| IsDict(
|
||||
# TODO: remove when deprecating Pydantic v1
|
||||
{"title": "Age", "type": "integer"}
|
||||
),
|
||||
},
|
||||
},
|
||||
"ValidationError": {
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
from dirty_equals import IsDict
|
||||
from fastapi.testclient import TestClient
|
||||
from sqlmodel import create_engine
|
||||
from sqlmodel.pool import StaticPool
|
||||
@@ -287,7 +288,16 @@ def test_tutorial(clear_sqlmodel):
|
||||
"properties": {
|
||||
"name": {"title": "Name", "type": "string"},
|
||||
"secret_name": {"title": "Secret Name", "type": "string"},
|
||||
"age": {"title": "Age", "type": "integer"},
|
||||
"age": IsDict(
|
||||
{
|
||||
"title": "Age",
|
||||
"anyOf": [{"type": "integer"}, {"type": "null"}],
|
||||
}
|
||||
)
|
||||
| IsDict(
|
||||
# TODO: remove when deprecating Pydantic v1
|
||||
{"title": "Age", "type": "integer"}
|
||||
),
|
||||
},
|
||||
},
|
||||
"HeroRead": {
|
||||
@@ -297,7 +307,16 @@ def test_tutorial(clear_sqlmodel):
|
||||
"properties": {
|
||||
"name": {"title": "Name", "type": "string"},
|
||||
"secret_name": {"title": "Secret Name", "type": "string"},
|
||||
"age": {"title": "Age", "type": "integer"},
|
||||
"age": IsDict(
|
||||
{
|
||||
"title": "Age",
|
||||
"anyOf": [{"type": "integer"}, {"type": "null"}],
|
||||
}
|
||||
)
|
||||
| IsDict(
|
||||
# TODO: remove when deprecating Pydantic v1
|
||||
{"title": "Age", "type": "integer"}
|
||||
),
|
||||
"id": {"title": "Id", "type": "integer"},
|
||||
},
|
||||
},
|
||||
@@ -305,9 +324,36 @@ def test_tutorial(clear_sqlmodel):
|
||||
"title": "HeroUpdate",
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"name": {"title": "Name", "type": "string"},
|
||||
"secret_name": {"title": "Secret Name", "type": "string"},
|
||||
"age": {"title": "Age", "type": "integer"},
|
||||
"name": IsDict(
|
||||
{
|
||||
"title": "Name",
|
||||
"anyOf": [{"type": "string"}, {"type": "null"}],
|
||||
}
|
||||
)
|
||||
| IsDict(
|
||||
# TODO: remove when deprecating Pydantic v1
|
||||
{"title": "Name", "type": "string"}
|
||||
),
|
||||
"secret_name": IsDict(
|
||||
{
|
||||
"title": "Secret Name",
|
||||
"anyOf": [{"type": "string"}, {"type": "null"}],
|
||||
}
|
||||
)
|
||||
| IsDict(
|
||||
# TODO: remove when deprecating Pydantic v1
|
||||
{"title": "Secret Name", "type": "string"}
|
||||
),
|
||||
"age": IsDict(
|
||||
{
|
||||
"title": "Age",
|
||||
"anyOf": [{"type": "integer"}, {"type": "null"}],
|
||||
}
|
||||
)
|
||||
| IsDict(
|
||||
# TODO: remove when deprecating Pydantic v1
|
||||
{"title": "Age", "type": "integer"}
|
||||
),
|
||||
},
|
||||
},
|
||||
"ValidationError": {
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
from dirty_equals import IsDict
|
||||
from fastapi.testclient import TestClient
|
||||
from sqlmodel import create_engine
|
||||
from sqlmodel.pool import StaticPool
|
||||
@@ -217,7 +218,16 @@ def test_tutorial(clear_sqlmodel):
|
||||
"properties": {
|
||||
"name": {"title": "Name", "type": "string"},
|
||||
"secret_name": {"title": "Secret Name", "type": "string"},
|
||||
"age": {"title": "Age", "type": "integer"},
|
||||
"age": IsDict(
|
||||
{
|
||||
"title": "Age",
|
||||
"anyOf": [{"type": "integer"}, {"type": "null"}],
|
||||
}
|
||||
)
|
||||
| IsDict(
|
||||
# TODO: remove when deprecating Pydantic v1
|
||||
{"title": "Age", "type": "integer"}
|
||||
),
|
||||
},
|
||||
},
|
||||
"HeroRead": {
|
||||
@@ -227,7 +237,16 @@ def test_tutorial(clear_sqlmodel):
|
||||
"properties": {
|
||||
"name": {"title": "Name", "type": "string"},
|
||||
"secret_name": {"title": "Secret Name", "type": "string"},
|
||||
"age": {"title": "Age", "type": "integer"},
|
||||
"age": IsDict(
|
||||
{
|
||||
"title": "Age",
|
||||
"anyOf": [{"type": "integer"}, {"type": "null"}],
|
||||
}
|
||||
)
|
||||
| IsDict(
|
||||
# TODO: remove when deprecating Pydantic v1
|
||||
{"title": "Age", "type": "integer"}
|
||||
),
|
||||
"id": {"title": "Id", "type": "integer"},
|
||||
},
|
||||
},
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
from dirty_equals import IsDict
|
||||
from fastapi.testclient import TestClient
|
||||
from sqlmodel import create_engine
|
||||
from sqlmodel.pool import StaticPool
|
||||
@@ -220,7 +221,16 @@ def test_tutorial(clear_sqlmodel):
|
||||
"properties": {
|
||||
"name": {"title": "Name", "type": "string"},
|
||||
"secret_name": {"title": "Secret Name", "type": "string"},
|
||||
"age": {"title": "Age", "type": "integer"},
|
||||
"age": IsDict(
|
||||
{
|
||||
"title": "Age",
|
||||
"anyOf": [{"type": "integer"}, {"type": "null"}],
|
||||
}
|
||||
)
|
||||
| IsDict(
|
||||
# TODO: remove when deprecating Pydantic v1
|
||||
{"title": "Age", "type": "integer"}
|
||||
),
|
||||
},
|
||||
},
|
||||
"HeroRead": {
|
||||
@@ -230,7 +240,16 @@ def test_tutorial(clear_sqlmodel):
|
||||
"properties": {
|
||||
"name": {"title": "Name", "type": "string"},
|
||||
"secret_name": {"title": "Secret Name", "type": "string"},
|
||||
"age": {"title": "Age", "type": "integer"},
|
||||
"age": IsDict(
|
||||
{
|
||||
"title": "Age",
|
||||
"anyOf": [{"type": "integer"}, {"type": "null"}],
|
||||
}
|
||||
)
|
||||
| IsDict(
|
||||
# TODO: remove when deprecating Pydantic v1
|
||||
{"title": "Age", "type": "integer"}
|
||||
),
|
||||
"id": {"title": "Id", "type": "integer"},
|
||||
},
|
||||
},
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
from dirty_equals import IsDict
|
||||
from fastapi.testclient import TestClient
|
||||
from sqlmodel import create_engine
|
||||
from sqlmodel.pool import StaticPool
|
||||
@@ -220,7 +221,16 @@ def test_tutorial(clear_sqlmodel):
|
||||
"properties": {
|
||||
"name": {"title": "Name", "type": "string"},
|
||||
"secret_name": {"title": "Secret Name", "type": "string"},
|
||||
"age": {"title": "Age", "type": "integer"},
|
||||
"age": IsDict(
|
||||
{
|
||||
"title": "Age",
|
||||
"anyOf": [{"type": "integer"}, {"type": "null"}],
|
||||
}
|
||||
)
|
||||
| IsDict(
|
||||
# TODO: remove when deprecating Pydantic v1
|
||||
{"title": "Age", "type": "integer"}
|
||||
),
|
||||
},
|
||||
},
|
||||
"HeroRead": {
|
||||
@@ -230,7 +240,16 @@ def test_tutorial(clear_sqlmodel):
|
||||
"properties": {
|
||||
"name": {"title": "Name", "type": "string"},
|
||||
"secret_name": {"title": "Secret Name", "type": "string"},
|
||||
"age": {"title": "Age", "type": "integer"},
|
||||
"age": IsDict(
|
||||
{
|
||||
"title": "Age",
|
||||
"anyOf": [{"type": "integer"}, {"type": "null"}],
|
||||
}
|
||||
)
|
||||
| IsDict(
|
||||
# TODO: remove when deprecating Pydantic v1
|
||||
{"title": "Age", "type": "integer"}
|
||||
),
|
||||
"id": {"title": "Id", "type": "integer"},
|
||||
},
|
||||
},
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
from dirty_equals import IsDict
|
||||
from fastapi.testclient import TestClient
|
||||
from sqlalchemy import inspect
|
||||
from sqlalchemy.engine.reflection import Inspector
|
||||
@@ -53,11 +54,10 @@ def test_tutorial(clear_sqlmodel):
|
||||
assert data[1]["id"] != hero2_data["id"]
|
||||
|
||||
response = client.get("/openapi.json")
|
||||
data = response.json()
|
||||
|
||||
assert response.status_code == 200, response.text
|
||||
|
||||
assert data == {
|
||||
assert response.json() == {
|
||||
"openapi": "3.1.0",
|
||||
"info": {"title": "FastAPI", "version": "0.1.0"},
|
||||
"paths": {
|
||||
@@ -142,7 +142,16 @@ def test_tutorial(clear_sqlmodel):
|
||||
"properties": {
|
||||
"name": {"title": "Name", "type": "string"},
|
||||
"secret_name": {"title": "Secret Name", "type": "string"},
|
||||
"age": {"title": "Age", "type": "integer"},
|
||||
"age": IsDict(
|
||||
{
|
||||
"title": "Age",
|
||||
"anyOf": [{"type": "integer"}, {"type": "null"}],
|
||||
}
|
||||
)
|
||||
| IsDict(
|
||||
# TODO: remove when deprecating Pydantic v1
|
||||
{"title": "Age", "type": "integer"}
|
||||
),
|
||||
},
|
||||
},
|
||||
"HeroRead": {
|
||||
@@ -153,7 +162,16 @@ def test_tutorial(clear_sqlmodel):
|
||||
"id": {"title": "Id", "type": "integer"},
|
||||
"name": {"title": "Name", "type": "string"},
|
||||
"secret_name": {"title": "Secret Name", "type": "string"},
|
||||
"age": {"title": "Age", "type": "integer"},
|
||||
"age": IsDict(
|
||||
{
|
||||
"title": "Age",
|
||||
"anyOf": [{"type": "integer"}, {"type": "null"}],
|
||||
}
|
||||
)
|
||||
| IsDict(
|
||||
# TODO: remove when deprecating Pydantic v1
|
||||
{"title": "Age", "type": "integer"}
|
||||
),
|
||||
},
|
||||
},
|
||||
"ValidationError": {
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
from dirty_equals import IsDict
|
||||
from fastapi.testclient import TestClient
|
||||
from sqlalchemy import inspect
|
||||
from sqlalchemy.engine.reflection import Inspector
|
||||
@@ -56,11 +57,9 @@ def test_tutorial(clear_sqlmodel):
|
||||
assert data[1]["id"] != hero2_data["id"]
|
||||
|
||||
response = client.get("/openapi.json")
|
||||
data = response.json()
|
||||
|
||||
assert response.status_code == 200, response.text
|
||||
|
||||
assert data == {
|
||||
assert response.json() == {
|
||||
"openapi": "3.1.0",
|
||||
"info": {"title": "FastAPI", "version": "0.1.0"},
|
||||
"paths": {
|
||||
@@ -145,7 +144,16 @@ def test_tutorial(clear_sqlmodel):
|
||||
"properties": {
|
||||
"name": {"title": "Name", "type": "string"},
|
||||
"secret_name": {"title": "Secret Name", "type": "string"},
|
||||
"age": {"title": "Age", "type": "integer"},
|
||||
"age": IsDict(
|
||||
{
|
||||
"title": "Age",
|
||||
"anyOf": [{"type": "integer"}, {"type": "null"}],
|
||||
}
|
||||
)
|
||||
| IsDict(
|
||||
# TODO: remove when deprecating Pydantic v1
|
||||
{"title": "Age", "type": "integer"}
|
||||
),
|
||||
},
|
||||
},
|
||||
"HeroRead": {
|
||||
@@ -156,7 +164,16 @@ def test_tutorial(clear_sqlmodel):
|
||||
"id": {"title": "Id", "type": "integer"},
|
||||
"name": {"title": "Name", "type": "string"},
|
||||
"secret_name": {"title": "Secret Name", "type": "string"},
|
||||
"age": {"title": "Age", "type": "integer"},
|
||||
"age": IsDict(
|
||||
{
|
||||
"title": "Age",
|
||||
"anyOf": [{"type": "integer"}, {"type": "null"}],
|
||||
}
|
||||
)
|
||||
| IsDict(
|
||||
# TODO: remove when deprecating Pydantic v1
|
||||
{"title": "Age", "type": "integer"}
|
||||
),
|
||||
},
|
||||
},
|
||||
"ValidationError": {
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
from dirty_equals import IsDict
|
||||
from fastapi.testclient import TestClient
|
||||
from sqlalchemy import inspect
|
||||
from sqlalchemy.engine.reflection import Inspector
|
||||
@@ -56,11 +57,10 @@ def test_tutorial(clear_sqlmodel):
|
||||
assert data[1]["id"] != hero2_data["id"]
|
||||
|
||||
response = client.get("/openapi.json")
|
||||
data = response.json()
|
||||
|
||||
assert response.status_code == 200, response.text
|
||||
|
||||
assert data == {
|
||||
assert response.json() == {
|
||||
"openapi": "3.1.0",
|
||||
"info": {"title": "FastAPI", "version": "0.1.0"},
|
||||
"paths": {
|
||||
@@ -145,7 +145,16 @@ def test_tutorial(clear_sqlmodel):
|
||||
"properties": {
|
||||
"name": {"title": "Name", "type": "string"},
|
||||
"secret_name": {"title": "Secret Name", "type": "string"},
|
||||
"age": {"title": "Age", "type": "integer"},
|
||||
"age": IsDict(
|
||||
{
|
||||
"title": "Age",
|
||||
"anyOf": [{"type": "integer"}, {"type": "null"}],
|
||||
}
|
||||
)
|
||||
| IsDict(
|
||||
# TODO: remove when deprecating Pydantic v1
|
||||
{"title": "Age", "type": "integer"}
|
||||
),
|
||||
},
|
||||
},
|
||||
"HeroRead": {
|
||||
@@ -156,7 +165,16 @@ def test_tutorial(clear_sqlmodel):
|
||||
"id": {"title": "Id", "type": "integer"},
|
||||
"name": {"title": "Name", "type": "string"},
|
||||
"secret_name": {"title": "Secret Name", "type": "string"},
|
||||
"age": {"title": "Age", "type": "integer"},
|
||||
"age": IsDict(
|
||||
{
|
||||
"title": "Age",
|
||||
"anyOf": [{"type": "integer"}, {"type": "null"}],
|
||||
}
|
||||
)
|
||||
| IsDict(
|
||||
# TODO: remove when deprecating Pydantic v1
|
||||
{"title": "Age", "type": "integer"}
|
||||
),
|
||||
},
|
||||
},
|
||||
"ValidationError": {
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
from dirty_equals import IsDict
|
||||
from fastapi.testclient import TestClient
|
||||
from sqlalchemy import inspect
|
||||
from sqlalchemy.engine.reflection import Inspector
|
||||
@@ -53,11 +54,10 @@ def test_tutorial(clear_sqlmodel):
|
||||
assert data[1]["id"] != hero2_data["id"]
|
||||
|
||||
response = client.get("/openapi.json")
|
||||
data = response.json()
|
||||
|
||||
assert response.status_code == 200, response.text
|
||||
|
||||
assert data == {
|
||||
assert response.json() == {
|
||||
"openapi": "3.1.0",
|
||||
"info": {"title": "FastAPI", "version": "0.1.0"},
|
||||
"paths": {
|
||||
@@ -142,7 +142,16 @@ def test_tutorial(clear_sqlmodel):
|
||||
"properties": {
|
||||
"name": {"title": "Name", "type": "string"},
|
||||
"secret_name": {"title": "Secret Name", "type": "string"},
|
||||
"age": {"title": "Age", "type": "integer"},
|
||||
"age": IsDict(
|
||||
{
|
||||
"title": "Age",
|
||||
"anyOf": [{"type": "integer"}, {"type": "null"}],
|
||||
}
|
||||
)
|
||||
| IsDict(
|
||||
# TODO: remove when deprecating Pydantic v1
|
||||
{"title": "Age", "type": "integer"}
|
||||
),
|
||||
},
|
||||
},
|
||||
"HeroRead": {
|
||||
@@ -152,7 +161,16 @@ def test_tutorial(clear_sqlmodel):
|
||||
"properties": {
|
||||
"name": {"title": "Name", "type": "string"},
|
||||
"secret_name": {"title": "Secret Name", "type": "string"},
|
||||
"age": {"title": "Age", "type": "integer"},
|
||||
"age": IsDict(
|
||||
{
|
||||
"title": "Age",
|
||||
"anyOf": [{"type": "integer"}, {"type": "null"}],
|
||||
}
|
||||
)
|
||||
| IsDict(
|
||||
# TODO: remove when deprecating Pydantic v1
|
||||
{"title": "Age", "type": "integer"}
|
||||
),
|
||||
"id": {"title": "Id", "type": "integer"},
|
||||
},
|
||||
},
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
from dirty_equals import IsDict
|
||||
from fastapi.testclient import TestClient
|
||||
from sqlalchemy import inspect
|
||||
from sqlalchemy.engine.reflection import Inspector
|
||||
@@ -56,11 +57,10 @@ def test_tutorial(clear_sqlmodel):
|
||||
assert data[1]["id"] != hero2_data["id"]
|
||||
|
||||
response = client.get("/openapi.json")
|
||||
data = response.json()
|
||||
|
||||
assert response.status_code == 200, response.text
|
||||
|
||||
assert data == {
|
||||
assert response.json() == {
|
||||
"openapi": "3.1.0",
|
||||
"info": {"title": "FastAPI", "version": "0.1.0"},
|
||||
"paths": {
|
||||
@@ -145,7 +145,16 @@ def test_tutorial(clear_sqlmodel):
|
||||
"properties": {
|
||||
"name": {"title": "Name", "type": "string"},
|
||||
"secret_name": {"title": "Secret Name", "type": "string"},
|
||||
"age": {"title": "Age", "type": "integer"},
|
||||
"age": IsDict(
|
||||
{
|
||||
"title": "Age",
|
||||
"anyOf": [{"type": "integer"}, {"type": "null"}],
|
||||
}
|
||||
)
|
||||
| IsDict(
|
||||
# TODO: remove when deprecating Pydantic v1
|
||||
{"title": "Age", "type": "integer"}
|
||||
),
|
||||
},
|
||||
},
|
||||
"HeroRead": {
|
||||
@@ -155,7 +164,16 @@ def test_tutorial(clear_sqlmodel):
|
||||
"properties": {
|
||||
"name": {"title": "Name", "type": "string"},
|
||||
"secret_name": {"title": "Secret Name", "type": "string"},
|
||||
"age": {"title": "Age", "type": "integer"},
|
||||
"age": IsDict(
|
||||
{
|
||||
"title": "Age",
|
||||
"anyOf": [{"type": "integer"}, {"type": "null"}],
|
||||
}
|
||||
)
|
||||
| IsDict(
|
||||
# TODO: remove when deprecating Pydantic v1
|
||||
{"title": "Age", "type": "integer"}
|
||||
),
|
||||
"id": {"title": "Id", "type": "integer"},
|
||||
},
|
||||
},
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
from dirty_equals import IsDict
|
||||
from fastapi.testclient import TestClient
|
||||
from sqlalchemy import inspect
|
||||
from sqlalchemy.engine.reflection import Inspector
|
||||
@@ -56,11 +57,10 @@ def test_tutorial(clear_sqlmodel):
|
||||
assert data[1]["id"] != hero2_data["id"]
|
||||
|
||||
response = client.get("/openapi.json")
|
||||
data = response.json()
|
||||
|
||||
assert response.status_code == 200, response.text
|
||||
|
||||
assert data == {
|
||||
assert response.json() == {
|
||||
"openapi": "3.1.0",
|
||||
"info": {"title": "FastAPI", "version": "0.1.0"},
|
||||
"paths": {
|
||||
@@ -145,7 +145,16 @@ def test_tutorial(clear_sqlmodel):
|
||||
"properties": {
|
||||
"name": {"title": "Name", "type": "string"},
|
||||
"secret_name": {"title": "Secret Name", "type": "string"},
|
||||
"age": {"title": "Age", "type": "integer"},
|
||||
"age": IsDict(
|
||||
{
|
||||
"title": "Age",
|
||||
"anyOf": [{"type": "integer"}, {"type": "null"}],
|
||||
}
|
||||
)
|
||||
| IsDict(
|
||||
# TODO: remove when deprecating Pydantic v1
|
||||
{"title": "Age", "type": "integer"}
|
||||
),
|
||||
},
|
||||
},
|
||||
"HeroRead": {
|
||||
@@ -155,7 +164,16 @@ def test_tutorial(clear_sqlmodel):
|
||||
"properties": {
|
||||
"name": {"title": "Name", "type": "string"},
|
||||
"secret_name": {"title": "Secret Name", "type": "string"},
|
||||
"age": {"title": "Age", "type": "integer"},
|
||||
"age": IsDict(
|
||||
{
|
||||
"title": "Age",
|
||||
"anyOf": [{"type": "integer"}, {"type": "null"}],
|
||||
}
|
||||
)
|
||||
| IsDict(
|
||||
# TODO: remove when deprecating Pydantic v1
|
||||
{"title": "Age", "type": "integer"}
|
||||
),
|
||||
"id": {"title": "Id", "type": "integer"},
|
||||
},
|
||||
},
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
from dirty_equals import IsDict
|
||||
from fastapi.testclient import TestClient
|
||||
from sqlmodel import create_engine
|
||||
from sqlmodel.pool import StaticPool
|
||||
@@ -38,11 +39,10 @@ def test_tutorial(clear_sqlmodel):
|
||||
assert response.status_code == 404, response.text
|
||||
|
||||
response = client.get("/openapi.json")
|
||||
data = response.json()
|
||||
|
||||
assert response.status_code == 200, response.text
|
||||
|
||||
assert data == {
|
||||
assert response.json() == {
|
||||
"openapi": "3.1.0",
|
||||
"info": {"title": "FastAPI", "version": "0.1.0"},
|
||||
"paths": {
|
||||
@@ -163,7 +163,16 @@ def test_tutorial(clear_sqlmodel):
|
||||
"properties": {
|
||||
"name": {"title": "Name", "type": "string"},
|
||||
"secret_name": {"title": "Secret Name", "type": "string"},
|
||||
"age": {"title": "Age", "type": "integer"},
|
||||
"age": IsDict(
|
||||
{
|
||||
"title": "Age",
|
||||
"anyOf": [{"type": "integer"}, {"type": "null"}],
|
||||
}
|
||||
)
|
||||
| IsDict(
|
||||
# TODO: remove when deprecating Pydantic v1
|
||||
{"title": "Age", "type": "integer"}
|
||||
),
|
||||
},
|
||||
},
|
||||
"HeroRead": {
|
||||
@@ -173,7 +182,16 @@ def test_tutorial(clear_sqlmodel):
|
||||
"properties": {
|
||||
"name": {"title": "Name", "type": "string"},
|
||||
"secret_name": {"title": "Secret Name", "type": "string"},
|
||||
"age": {"title": "Age", "type": "integer"},
|
||||
"age": IsDict(
|
||||
{
|
||||
"title": "Age",
|
||||
"anyOf": [{"type": "integer"}, {"type": "null"}],
|
||||
}
|
||||
)
|
||||
| IsDict(
|
||||
# TODO: remove when deprecating Pydantic v1
|
||||
{"title": "Age", "type": "integer"}
|
||||
),
|
||||
"id": {"title": "Id", "type": "integer"},
|
||||
},
|
||||
},
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
from dirty_equals import IsDict
|
||||
from fastapi.testclient import TestClient
|
||||
from sqlmodel import create_engine
|
||||
from sqlmodel.pool import StaticPool
|
||||
@@ -41,11 +42,10 @@ def test_tutorial(clear_sqlmodel):
|
||||
assert response.status_code == 404, response.text
|
||||
|
||||
response = client.get("/openapi.json")
|
||||
data = response.json()
|
||||
|
||||
assert response.status_code == 200, response.text
|
||||
|
||||
assert data == {
|
||||
assert response.json() == {
|
||||
"openapi": "3.1.0",
|
||||
"info": {"title": "FastAPI", "version": "0.1.0"},
|
||||
"paths": {
|
||||
@@ -166,7 +166,16 @@ def test_tutorial(clear_sqlmodel):
|
||||
"properties": {
|
||||
"name": {"title": "Name", "type": "string"},
|
||||
"secret_name": {"title": "Secret Name", "type": "string"},
|
||||
"age": {"title": "Age", "type": "integer"},
|
||||
"age": IsDict(
|
||||
{
|
||||
"title": "Age",
|
||||
"anyOf": [{"type": "integer"}, {"type": "null"}],
|
||||
}
|
||||
)
|
||||
| IsDict(
|
||||
# TODO: remove when deprecating Pydantic v1
|
||||
{"title": "Age", "type": "integer"}
|
||||
),
|
||||
},
|
||||
},
|
||||
"HeroRead": {
|
||||
@@ -176,7 +185,16 @@ def test_tutorial(clear_sqlmodel):
|
||||
"properties": {
|
||||
"name": {"title": "Name", "type": "string"},
|
||||
"secret_name": {"title": "Secret Name", "type": "string"},
|
||||
"age": {"title": "Age", "type": "integer"},
|
||||
"age": IsDict(
|
||||
{
|
||||
"title": "Age",
|
||||
"anyOf": [{"type": "integer"}, {"type": "null"}],
|
||||
}
|
||||
)
|
||||
| IsDict(
|
||||
# TODO: remove when deprecating Pydantic v1
|
||||
{"title": "Age", "type": "integer"}
|
||||
),
|
||||
"id": {"title": "Id", "type": "integer"},
|
||||
},
|
||||
},
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
from dirty_equals import IsDict
|
||||
from fastapi.testclient import TestClient
|
||||
from sqlmodel import create_engine
|
||||
from sqlmodel.pool import StaticPool
|
||||
@@ -41,11 +42,10 @@ def test_tutorial(clear_sqlmodel):
|
||||
assert response.status_code == 404, response.text
|
||||
|
||||
response = client.get("/openapi.json")
|
||||
data = response.json()
|
||||
|
||||
assert response.status_code == 200, response.text
|
||||
|
||||
assert data == {
|
||||
assert response.json() == {
|
||||
"openapi": "3.1.0",
|
||||
"info": {"title": "FastAPI", "version": "0.1.0"},
|
||||
"paths": {
|
||||
@@ -166,7 +166,16 @@ def test_tutorial(clear_sqlmodel):
|
||||
"properties": {
|
||||
"name": {"title": "Name", "type": "string"},
|
||||
"secret_name": {"title": "Secret Name", "type": "string"},
|
||||
"age": {"title": "Age", "type": "integer"},
|
||||
"age": IsDict(
|
||||
{
|
||||
"title": "Age",
|
||||
"anyOf": [{"type": "integer"}, {"type": "null"}],
|
||||
}
|
||||
)
|
||||
| IsDict(
|
||||
# TODO: remove when deprecating Pydantic v1
|
||||
{"title": "Age", "type": "integer"}
|
||||
),
|
||||
},
|
||||
},
|
||||
"HeroRead": {
|
||||
@@ -176,7 +185,16 @@ def test_tutorial(clear_sqlmodel):
|
||||
"properties": {
|
||||
"name": {"title": "Name", "type": "string"},
|
||||
"secret_name": {"title": "Secret Name", "type": "string"},
|
||||
"age": {"title": "Age", "type": "integer"},
|
||||
"age": IsDict(
|
||||
{
|
||||
"title": "Age",
|
||||
"anyOf": [{"type": "integer"}, {"type": "null"}],
|
||||
}
|
||||
)
|
||||
| IsDict(
|
||||
# TODO: remove when deprecating Pydantic v1
|
||||
{"title": "Age", "type": "integer"}
|
||||
),
|
||||
"id": {"title": "Id", "type": "integer"},
|
||||
},
|
||||
},
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
from dirty_equals import IsDict
|
||||
from fastapi.testclient import TestClient
|
||||
from sqlmodel import create_engine
|
||||
from sqlmodel.pool import StaticPool
|
||||
@@ -531,8 +532,26 @@ def test_tutorial(clear_sqlmodel):
|
||||
"properties": {
|
||||
"name": {"title": "Name", "type": "string"},
|
||||
"secret_name": {"title": "Secret Name", "type": "string"},
|
||||
"age": {"title": "Age", "type": "integer"},
|
||||
"team_id": {"title": "Team Id", "type": "integer"},
|
||||
"age": IsDict(
|
||||
{
|
||||
"title": "Age",
|
||||
"anyOf": [{"type": "integer"}, {"type": "null"}],
|
||||
}
|
||||
)
|
||||
| IsDict(
|
||||
# TODO: remove when deprecating Pydantic v1
|
||||
{"title": "Age", "type": "integer"}
|
||||
),
|
||||
"team_id": IsDict(
|
||||
{
|
||||
"title": "Team Id",
|
||||
"anyOf": [{"type": "integer"}, {"type": "null"}],
|
||||
}
|
||||
)
|
||||
| IsDict(
|
||||
# TODO: remove when deprecating Pydantic v1
|
||||
{"title": "Team Id", "type": "integer"}
|
||||
),
|
||||
},
|
||||
},
|
||||
"HeroRead": {
|
||||
@@ -542,8 +561,26 @@ def test_tutorial(clear_sqlmodel):
|
||||
"properties": {
|
||||
"name": {"title": "Name", "type": "string"},
|
||||
"secret_name": {"title": "Secret Name", "type": "string"},
|
||||
"age": {"title": "Age", "type": "integer"},
|
||||
"team_id": {"title": "Team Id", "type": "integer"},
|
||||
"age": IsDict(
|
||||
{
|
||||
"title": "Age",
|
||||
"anyOf": [{"type": "integer"}, {"type": "null"}],
|
||||
}
|
||||
)
|
||||
| IsDict(
|
||||
# TODO: remove when deprecating Pydantic v1
|
||||
{"title": "Age", "type": "integer"}
|
||||
),
|
||||
"team_id": IsDict(
|
||||
{
|
||||
"title": "Team Id",
|
||||
"anyOf": [{"type": "integer"}, {"type": "null"}],
|
||||
}
|
||||
)
|
||||
| IsDict(
|
||||
# TODO: remove when deprecating Pydantic v1
|
||||
{"title": "Team Id", "type": "integer"}
|
||||
),
|
||||
"id": {"title": "Id", "type": "integer"},
|
||||
},
|
||||
},
|
||||
@@ -554,20 +591,85 @@ def test_tutorial(clear_sqlmodel):
|
||||
"properties": {
|
||||
"name": {"title": "Name", "type": "string"},
|
||||
"secret_name": {"title": "Secret Name", "type": "string"},
|
||||
"age": {"title": "Age", "type": "integer"},
|
||||
"team_id": {"title": "Team Id", "type": "integer"},
|
||||
"age": IsDict(
|
||||
{
|
||||
"title": "Age",
|
||||
"anyOf": [{"type": "integer"}, {"type": "null"}],
|
||||
}
|
||||
)
|
||||
| IsDict(
|
||||
# TODO: remove when deprecating Pydantic v1
|
||||
{"title": "Age", "type": "integer"}
|
||||
),
|
||||
"team_id": IsDict(
|
||||
{
|
||||
"title": "Team Id",
|
||||
"anyOf": [{"type": "integer"}, {"type": "null"}],
|
||||
}
|
||||
)
|
||||
| IsDict(
|
||||
# TODO: remove when deprecating Pydantic v1
|
||||
{"title": "Team Id", "type": "integer"}
|
||||
),
|
||||
"id": {"title": "Id", "type": "integer"},
|
||||
"team": {"$ref": "#/components/schemas/TeamRead"},
|
||||
"team": IsDict(
|
||||
{
|
||||
"anyOf": [
|
||||
{"$ref": "#/components/schemas/TeamRead"},
|
||||
{"type": "null"},
|
||||
]
|
||||
}
|
||||
)
|
||||
| IsDict(
|
||||
# TODO: remove when deprecating Pydantic v1
|
||||
{"$ref": "#/components/schemas/TeamRead"}
|
||||
),
|
||||
},
|
||||
},
|
||||
"HeroUpdate": {
|
||||
"title": "HeroUpdate",
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"name": {"title": "Name", "type": "string"},
|
||||
"secret_name": {"title": "Secret Name", "type": "string"},
|
||||
"age": {"title": "Age", "type": "integer"},
|
||||
"team_id": {"title": "Team Id", "type": "integer"},
|
||||
"name": IsDict(
|
||||
{
|
||||
"title": "Name",
|
||||
"anyOf": [{"type": "string"}, {"type": "null"}],
|
||||
}
|
||||
)
|
||||
| IsDict(
|
||||
# TODO: remove when deprecating Pydantic v1
|
||||
{"title": "Name", "type": "string"}
|
||||
),
|
||||
"secret_name": IsDict(
|
||||
{
|
||||
"title": "Secret Name",
|
||||
"anyOf": [{"type": "string"}, {"type": "null"}],
|
||||
}
|
||||
)
|
||||
| IsDict(
|
||||
# TODO: remove when deprecating Pydantic v1
|
||||
{"title": "Secret Name", "type": "string"}
|
||||
),
|
||||
"age": IsDict(
|
||||
{
|
||||
"title": "Age",
|
||||
"anyOf": [{"type": "integer"}, {"type": "null"}],
|
||||
}
|
||||
)
|
||||
| IsDict(
|
||||
# TODO: remove when deprecating Pydantic v1
|
||||
{"title": "Age", "type": "integer"}
|
||||
),
|
||||
"team_id": IsDict(
|
||||
{
|
||||
"title": "Team Id",
|
||||
"anyOf": [{"type": "integer"}, {"type": "null"}],
|
||||
}
|
||||
)
|
||||
| IsDict(
|
||||
# TODO: remove when deprecating Pydantic v1
|
||||
{"title": "Team Id", "type": "integer"}
|
||||
),
|
||||
},
|
||||
},
|
||||
"TeamCreate": {
|
||||
@@ -609,9 +711,36 @@ def test_tutorial(clear_sqlmodel):
|
||||
"title": "TeamUpdate",
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"id": {"title": "Id", "type": "integer"},
|
||||
"name": {"title": "Name", "type": "string"},
|
||||
"headquarters": {"title": "Headquarters", "type": "string"},
|
||||
"id": IsDict(
|
||||
{
|
||||
"title": "Id",
|
||||
"anyOf": [{"type": "integer"}, {"type": "null"}],
|
||||
}
|
||||
)
|
||||
| IsDict(
|
||||
# TODO: remove when deprecating Pydantic v1
|
||||
{"title": "Id", "type": "integer"}
|
||||
),
|
||||
"name": IsDict(
|
||||
{
|
||||
"title": "Name",
|
||||
"anyOf": [{"type": "string"}, {"type": "null"}],
|
||||
}
|
||||
)
|
||||
| IsDict(
|
||||
# TODO: remove when deprecating Pydantic v1
|
||||
{"title": "Name", "type": "string"}
|
||||
),
|
||||
"headquarters": IsDict(
|
||||
{
|
||||
"title": "Headquarters",
|
||||
"anyOf": [{"type": "string"}, {"type": "null"}],
|
||||
}
|
||||
)
|
||||
| IsDict(
|
||||
# TODO: remove when deprecating Pydantic v1
|
||||
{"title": "Headquarters", "type": "string"}
|
||||
),
|
||||
},
|
||||
},
|
||||
"ValidationError": {
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
from dirty_equals import IsDict
|
||||
from fastapi.testclient import TestClient
|
||||
from sqlmodel import create_engine
|
||||
from sqlmodel.pool import StaticPool
|
||||
@@ -534,8 +535,26 @@ def test_tutorial(clear_sqlmodel):
|
||||
"properties": {
|
||||
"name": {"title": "Name", "type": "string"},
|
||||
"secret_name": {"title": "Secret Name", "type": "string"},
|
||||
"age": {"title": "Age", "type": "integer"},
|
||||
"team_id": {"title": "Team Id", "type": "integer"},
|
||||
"age": IsDict(
|
||||
{
|
||||
"title": "Age",
|
||||
"anyOf": [{"type": "integer"}, {"type": "null"}],
|
||||
}
|
||||
)
|
||||
| IsDict(
|
||||
# TODO: remove when deprecating Pydantic v1
|
||||
{"title": "Age", "type": "integer"}
|
||||
),
|
||||
"team_id": IsDict(
|
||||
{
|
||||
"title": "Team Id",
|
||||
"anyOf": [{"type": "integer"}, {"type": "null"}],
|
||||
}
|
||||
)
|
||||
| IsDict(
|
||||
# TODO: remove when deprecating Pydantic v1
|
||||
{"title": "Team Id", "type": "integer"}
|
||||
),
|
||||
},
|
||||
},
|
||||
"HeroRead": {
|
||||
@@ -545,8 +564,26 @@ def test_tutorial(clear_sqlmodel):
|
||||
"properties": {
|
||||
"name": {"title": "Name", "type": "string"},
|
||||
"secret_name": {"title": "Secret Name", "type": "string"},
|
||||
"age": {"title": "Age", "type": "integer"},
|
||||
"team_id": {"title": "Team Id", "type": "integer"},
|
||||
"age": IsDict(
|
||||
{
|
||||
"title": "Age",
|
||||
"anyOf": [{"type": "integer"}, {"type": "null"}],
|
||||
}
|
||||
)
|
||||
| IsDict(
|
||||
# TODO: remove when deprecating Pydantic v1
|
||||
{"title": "Age", "type": "integer"}
|
||||
),
|
||||
"team_id": IsDict(
|
||||
{
|
||||
"title": "Team Id",
|
||||
"anyOf": [{"type": "integer"}, {"type": "null"}],
|
||||
}
|
||||
)
|
||||
| IsDict(
|
||||
# TODO: remove when deprecating Pydantic v1
|
||||
{"title": "Team Id", "type": "integer"}
|
||||
),
|
||||
"id": {"title": "Id", "type": "integer"},
|
||||
},
|
||||
},
|
||||
@@ -557,20 +594,85 @@ def test_tutorial(clear_sqlmodel):
|
||||
"properties": {
|
||||
"name": {"title": "Name", "type": "string"},
|
||||
"secret_name": {"title": "Secret Name", "type": "string"},
|
||||
"age": {"title": "Age", "type": "integer"},
|
||||
"team_id": {"title": "Team Id", "type": "integer"},
|
||||
"age": IsDict(
|
||||
{
|
||||
"title": "Age",
|
||||
"anyOf": [{"type": "integer"}, {"type": "null"}],
|
||||
}
|
||||
)
|
||||
| IsDict(
|
||||
# TODO: remove when deprecating Pydantic v1
|
||||
{"title": "Age", "type": "integer"}
|
||||
),
|
||||
"team_id": IsDict(
|
||||
{
|
||||
"title": "Team Id",
|
||||
"anyOf": [{"type": "integer"}, {"type": "null"}],
|
||||
}
|
||||
)
|
||||
| IsDict(
|
||||
# TODO: remove when deprecating Pydantic v1
|
||||
{"title": "Team Id", "type": "integer"}
|
||||
),
|
||||
"id": {"title": "Id", "type": "integer"},
|
||||
"team": {"$ref": "#/components/schemas/TeamRead"},
|
||||
"team": IsDict(
|
||||
{
|
||||
"anyOf": [
|
||||
{"$ref": "#/components/schemas/TeamRead"},
|
||||
{"type": "null"},
|
||||
]
|
||||
}
|
||||
)
|
||||
| IsDict(
|
||||
# TODO: remove when deprecating Pydantic v1
|
||||
{"$ref": "#/components/schemas/TeamRead"}
|
||||
),
|
||||
},
|
||||
},
|
||||
"HeroUpdate": {
|
||||
"title": "HeroUpdate",
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"name": {"title": "Name", "type": "string"},
|
||||
"secret_name": {"title": "Secret Name", "type": "string"},
|
||||
"age": {"title": "Age", "type": "integer"},
|
||||
"team_id": {"title": "Team Id", "type": "integer"},
|
||||
"name": IsDict(
|
||||
{
|
||||
"title": "Name",
|
||||
"anyOf": [{"type": "string"}, {"type": "null"}],
|
||||
}
|
||||
)
|
||||
| IsDict(
|
||||
# TODO: remove when deprecating Pydantic v1
|
||||
{"title": "Name", "type": "string"}
|
||||
),
|
||||
"secret_name": IsDict(
|
||||
{
|
||||
"title": "Secret Name",
|
||||
"anyOf": [{"type": "string"}, {"type": "null"}],
|
||||
}
|
||||
)
|
||||
| IsDict(
|
||||
# TODO: remove when deprecating Pydantic v1
|
||||
{"title": "Secret Name", "type": "string"}
|
||||
),
|
||||
"age": IsDict(
|
||||
{
|
||||
"title": "Age",
|
||||
"anyOf": [{"type": "integer"}, {"type": "null"}],
|
||||
}
|
||||
)
|
||||
| IsDict(
|
||||
# TODO: remove when deprecating Pydantic v1
|
||||
{"title": "Age", "type": "integer"}
|
||||
),
|
||||
"team_id": IsDict(
|
||||
{
|
||||
"title": "Team Id",
|
||||
"anyOf": [{"type": "integer"}, {"type": "null"}],
|
||||
}
|
||||
)
|
||||
| IsDict(
|
||||
# TODO: remove when deprecating Pydantic v1
|
||||
{"title": "Team Id", "type": "integer"}
|
||||
),
|
||||
},
|
||||
},
|
||||
"TeamCreate": {
|
||||
@@ -612,9 +714,36 @@ def test_tutorial(clear_sqlmodel):
|
||||
"title": "TeamUpdate",
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"id": {"title": "Id", "type": "integer"},
|
||||
"name": {"title": "Name", "type": "string"},
|
||||
"headquarters": {"title": "Headquarters", "type": "string"},
|
||||
"id": IsDict(
|
||||
{
|
||||
"title": "Id",
|
||||
"anyOf": [{"type": "integer"}, {"type": "null"}],
|
||||
}
|
||||
)
|
||||
| IsDict(
|
||||
# TODO: remove when deprecating Pydantic v1
|
||||
{"title": "Id", "type": "integer"}
|
||||
),
|
||||
"name": IsDict(
|
||||
{
|
||||
"title": "Name",
|
||||
"anyOf": [{"type": "string"}, {"type": "null"}],
|
||||
}
|
||||
)
|
||||
| IsDict(
|
||||
# TODO: remove when deprecating Pydantic v1
|
||||
{"title": "Name", "type": "string"}
|
||||
),
|
||||
"headquarters": IsDict(
|
||||
{
|
||||
"title": "Headquarters",
|
||||
"anyOf": [{"type": "string"}, {"type": "null"}],
|
||||
}
|
||||
)
|
||||
| IsDict(
|
||||
# TODO: remove when deprecating Pydantic v1
|
||||
{"title": "Headquarters", "type": "string"}
|
||||
),
|
||||
},
|
||||
},
|
||||
"ValidationError": {
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
from dirty_equals import IsDict
|
||||
from fastapi.testclient import TestClient
|
||||
from sqlmodel import create_engine
|
||||
from sqlmodel.pool import StaticPool
|
||||
@@ -534,8 +535,26 @@ def test_tutorial(clear_sqlmodel):
|
||||
"properties": {
|
||||
"name": {"title": "Name", "type": "string"},
|
||||
"secret_name": {"title": "Secret Name", "type": "string"},
|
||||
"age": {"title": "Age", "type": "integer"},
|
||||
"team_id": {"title": "Team Id", "type": "integer"},
|
||||
"age": IsDict(
|
||||
{
|
||||
"title": "Age",
|
||||
"anyOf": [{"type": "integer"}, {"type": "null"}],
|
||||
}
|
||||
)
|
||||
| IsDict(
|
||||
# TODO: remove when deprecating Pydantic v1
|
||||
{"title": "Age", "type": "integer"}
|
||||
),
|
||||
"team_id": IsDict(
|
||||
{
|
||||
"title": "Team Id",
|
||||
"anyOf": [{"type": "integer"}, {"type": "null"}],
|
||||
}
|
||||
)
|
||||
| IsDict(
|
||||
# TODO: remove when deprecating Pydantic v1
|
||||
{"title": "Team Id", "type": "integer"}
|
||||
),
|
||||
},
|
||||
},
|
||||
"HeroRead": {
|
||||
@@ -545,8 +564,26 @@ def test_tutorial(clear_sqlmodel):
|
||||
"properties": {
|
||||
"name": {"title": "Name", "type": "string"},
|
||||
"secret_name": {"title": "Secret Name", "type": "string"},
|
||||
"age": {"title": "Age", "type": "integer"},
|
||||
"team_id": {"title": "Team Id", "type": "integer"},
|
||||
"age": IsDict(
|
||||
{
|
||||
"title": "Age",
|
||||
"anyOf": [{"type": "integer"}, {"type": "null"}],
|
||||
}
|
||||
)
|
||||
| IsDict(
|
||||
# TODO: remove when deprecating Pydantic v1
|
||||
{"title": "Age", "type": "integer"}
|
||||
),
|
||||
"team_id": IsDict(
|
||||
{
|
||||
"title": "Team Id",
|
||||
"anyOf": [{"type": "integer"}, {"type": "null"}],
|
||||
}
|
||||
)
|
||||
| IsDict(
|
||||
# TODO: remove when deprecating Pydantic v1
|
||||
{"title": "Team Id", "type": "integer"}
|
||||
),
|
||||
"id": {"title": "Id", "type": "integer"},
|
||||
},
|
||||
},
|
||||
@@ -557,20 +594,85 @@ def test_tutorial(clear_sqlmodel):
|
||||
"properties": {
|
||||
"name": {"title": "Name", "type": "string"},
|
||||
"secret_name": {"title": "Secret Name", "type": "string"},
|
||||
"age": {"title": "Age", "type": "integer"},
|
||||
"team_id": {"title": "Team Id", "type": "integer"},
|
||||
"age": IsDict(
|
||||
{
|
||||
"title": "Age",
|
||||
"anyOf": [{"type": "integer"}, {"type": "null"}],
|
||||
}
|
||||
)
|
||||
| IsDict(
|
||||
# TODO: remove when deprecating Pydantic v1
|
||||
{"title": "Age", "type": "integer"}
|
||||
),
|
||||
"team_id": IsDict(
|
||||
{
|
||||
"title": "Team Id",
|
||||
"anyOf": [{"type": "integer"}, {"type": "null"}],
|
||||
}
|
||||
)
|
||||
| IsDict(
|
||||
# TODO: remove when deprecating Pydantic v1
|
||||
{"title": "Team Id", "type": "integer"}
|
||||
),
|
||||
"id": {"title": "Id", "type": "integer"},
|
||||
"team": {"$ref": "#/components/schemas/TeamRead"},
|
||||
"team": IsDict(
|
||||
{
|
||||
"anyOf": [
|
||||
{"$ref": "#/components/schemas/TeamRead"},
|
||||
{"type": "null"},
|
||||
]
|
||||
}
|
||||
)
|
||||
| IsDict(
|
||||
# TODO: remove when deprecating Pydantic v1
|
||||
{"$ref": "#/components/schemas/TeamRead"}
|
||||
),
|
||||
},
|
||||
},
|
||||
"HeroUpdate": {
|
||||
"title": "HeroUpdate",
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"name": {"title": "Name", "type": "string"},
|
||||
"secret_name": {"title": "Secret Name", "type": "string"},
|
||||
"age": {"title": "Age", "type": "integer"},
|
||||
"team_id": {"title": "Team Id", "type": "integer"},
|
||||
"name": IsDict(
|
||||
{
|
||||
"title": "Name",
|
||||
"anyOf": [{"type": "string"}, {"type": "null"}],
|
||||
}
|
||||
)
|
||||
| IsDict(
|
||||
# TODO: remove when deprecating Pydantic v1
|
||||
{"title": "Name", "type": "string"}
|
||||
),
|
||||
"secret_name": IsDict(
|
||||
{
|
||||
"title": "Secret Name",
|
||||
"anyOf": [{"type": "string"}, {"type": "null"}],
|
||||
}
|
||||
)
|
||||
| IsDict(
|
||||
# TODO: remove when deprecating Pydantic v1
|
||||
{"title": "Secret Name", "type": "string"}
|
||||
),
|
||||
"age": IsDict(
|
||||
{
|
||||
"title": "Age",
|
||||
"anyOf": [{"type": "integer"}, {"type": "null"}],
|
||||
}
|
||||
)
|
||||
| IsDict(
|
||||
# TODO: remove when deprecating Pydantic v1
|
||||
{"title": "Age", "type": "integer"}
|
||||
),
|
||||
"team_id": IsDict(
|
||||
{
|
||||
"title": "Team Id",
|
||||
"anyOf": [{"type": "integer"}, {"type": "null"}],
|
||||
}
|
||||
)
|
||||
| IsDict(
|
||||
# TODO: remove when deprecating Pydantic v1
|
||||
{"title": "Team Id", "type": "integer"}
|
||||
),
|
||||
},
|
||||
},
|
||||
"TeamCreate": {
|
||||
@@ -612,9 +714,36 @@ def test_tutorial(clear_sqlmodel):
|
||||
"title": "TeamUpdate",
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"id": {"title": "Id", "type": "integer"},
|
||||
"name": {"title": "Name", "type": "string"},
|
||||
"headquarters": {"title": "Headquarters", "type": "string"},
|
||||
"id": IsDict(
|
||||
{
|
||||
"title": "Id",
|
||||
"anyOf": [{"type": "integer"}, {"type": "null"}],
|
||||
}
|
||||
)
|
||||
| IsDict(
|
||||
# TODO: remove when deprecating Pydantic v1
|
||||
{"title": "Id", "type": "integer"}
|
||||
),
|
||||
"name": IsDict(
|
||||
{
|
||||
"title": "Name",
|
||||
"anyOf": [{"type": "string"}, {"type": "null"}],
|
||||
}
|
||||
)
|
||||
| IsDict(
|
||||
# TODO: remove when deprecating Pydantic v1
|
||||
{"title": "Name", "type": "string"}
|
||||
),
|
||||
"headquarters": IsDict(
|
||||
{
|
||||
"title": "Headquarters",
|
||||
"anyOf": [{"type": "string"}, {"type": "null"}],
|
||||
}
|
||||
)
|
||||
| IsDict(
|
||||
# TODO: remove when deprecating Pydantic v1
|
||||
{"title": "Headquarters", "type": "string"}
|
||||
),
|
||||
},
|
||||
},
|
||||
"ValidationError": {
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
from dirty_equals import IsDict
|
||||
from fastapi.testclient import TestClient
|
||||
from sqlmodel import create_engine
|
||||
from sqlmodel.pool import StaticPool
|
||||
@@ -31,11 +32,10 @@ def test_tutorial(clear_sqlmodel):
|
||||
assert data[0]["secret_name"] == hero_data["secret_name"]
|
||||
|
||||
response = client.get("/openapi.json")
|
||||
data = response.json()
|
||||
|
||||
assert response.status_code == 200, response.text
|
||||
|
||||
assert data == {
|
||||
assert response.json() == {
|
||||
"openapi": "3.1.0",
|
||||
"info": {"title": "FastAPI", "version": "0.1.0"},
|
||||
"paths": {
|
||||
@@ -114,10 +114,28 @@ def test_tutorial(clear_sqlmodel):
|
||||
"required": ["name", "secret_name"],
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"id": {"title": "Id", "type": "integer"},
|
||||
"id": IsDict(
|
||||
{
|
||||
"title": "Id",
|
||||
"anyOf": [{"type": "integer"}, {"type": "null"}],
|
||||
}
|
||||
)
|
||||
| IsDict(
|
||||
# TODO: remove when deprecating Pydantic v1
|
||||
{"title": "Id", "type": "integer"}
|
||||
),
|
||||
"name": {"title": "Name", "type": "string"},
|
||||
"secret_name": {"title": "Secret Name", "type": "string"},
|
||||
"age": {"title": "Age", "type": "integer"},
|
||||
"age": IsDict(
|
||||
{
|
||||
"title": "Age",
|
||||
"anyOf": [{"type": "integer"}, {"type": "null"}],
|
||||
}
|
||||
)
|
||||
| IsDict(
|
||||
# TODO: remove when deprecating Pydantic v1
|
||||
{"title": "Age", "type": "integer"}
|
||||
),
|
||||
},
|
||||
},
|
||||
"ValidationError": {
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
from dirty_equals import IsDict
|
||||
from fastapi.testclient import TestClient
|
||||
from sqlmodel import create_engine
|
||||
from sqlmodel.pool import StaticPool
|
||||
@@ -34,11 +35,10 @@ def test_tutorial(clear_sqlmodel):
|
||||
assert data[0]["secret_name"] == hero_data["secret_name"]
|
||||
|
||||
response = client.get("/openapi.json")
|
||||
data = response.json()
|
||||
|
||||
assert response.status_code == 200, response.text
|
||||
|
||||
assert data == {
|
||||
assert response.json() == {
|
||||
"openapi": "3.1.0",
|
||||
"info": {"title": "FastAPI", "version": "0.1.0"},
|
||||
"paths": {
|
||||
@@ -117,10 +117,28 @@ def test_tutorial(clear_sqlmodel):
|
||||
"required": ["name", "secret_name"],
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"id": {"title": "Id", "type": "integer"},
|
||||
"id": IsDict(
|
||||
{
|
||||
"title": "Id",
|
||||
"anyOf": [{"type": "integer"}, {"type": "null"}],
|
||||
}
|
||||
)
|
||||
| IsDict(
|
||||
# TODO: remove when deprecating Pydantic v1
|
||||
{"title": "Id", "type": "integer"}
|
||||
),
|
||||
"name": {"title": "Name", "type": "string"},
|
||||
"secret_name": {"title": "Secret Name", "type": "string"},
|
||||
"age": {"title": "Age", "type": "integer"},
|
||||
"age": IsDict(
|
||||
{
|
||||
"title": "Age",
|
||||
"anyOf": [{"type": "integer"}, {"type": "null"}],
|
||||
}
|
||||
)
|
||||
| IsDict(
|
||||
# TODO: remove when deprecating Pydantic v1
|
||||
{"title": "Age", "type": "integer"}
|
||||
),
|
||||
},
|
||||
},
|
||||
"ValidationError": {
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
from dirty_equals import IsDict
|
||||
from fastapi.testclient import TestClient
|
||||
from sqlmodel import create_engine
|
||||
from sqlmodel.pool import StaticPool
|
||||
@@ -34,11 +35,10 @@ def test_tutorial(clear_sqlmodel):
|
||||
assert data[0]["secret_name"] == hero_data["secret_name"]
|
||||
|
||||
response = client.get("/openapi.json")
|
||||
data = response.json()
|
||||
|
||||
assert response.status_code == 200, response.text
|
||||
|
||||
assert data == {
|
||||
assert response.json() == {
|
||||
"openapi": "3.1.0",
|
||||
"info": {"title": "FastAPI", "version": "0.1.0"},
|
||||
"paths": {
|
||||
@@ -117,10 +117,28 @@ def test_tutorial(clear_sqlmodel):
|
||||
"required": ["name", "secret_name"],
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"id": {"title": "Id", "type": "integer"},
|
||||
"id": IsDict(
|
||||
{
|
||||
"title": "Id",
|
||||
"anyOf": [{"type": "integer"}, {"type": "null"}],
|
||||
}
|
||||
)
|
||||
| IsDict(
|
||||
# TODO: remove when deprecating Pydantic v1
|
||||
{"title": "Id", "type": "integer"}
|
||||
),
|
||||
"name": {"title": "Name", "type": "string"},
|
||||
"secret_name": {"title": "Secret Name", "type": "string"},
|
||||
"age": {"title": "Age", "type": "integer"},
|
||||
"age": IsDict(
|
||||
{
|
||||
"title": "Age",
|
||||
"anyOf": [{"type": "integer"}, {"type": "null"}],
|
||||
}
|
||||
)
|
||||
| IsDict(
|
||||
# TODO: remove when deprecating Pydantic v1
|
||||
{"title": "Age", "type": "integer"}
|
||||
),
|
||||
},
|
||||
},
|
||||
"ValidationError": {
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
from dirty_equals import IsDict
|
||||
from fastapi.testclient import TestClient
|
||||
from sqlmodel import create_engine
|
||||
from sqlmodel.pool import StaticPool
|
||||
@@ -284,7 +285,16 @@ def test_tutorial(clear_sqlmodel):
|
||||
"properties": {
|
||||
"name": {"title": "Name", "type": "string"},
|
||||
"secret_name": {"title": "Secret Name", "type": "string"},
|
||||
"age": {"title": "Age", "type": "integer"},
|
||||
"age": IsDict(
|
||||
{
|
||||
"title": "Age",
|
||||
"anyOf": [{"type": "integer"}, {"type": "null"}],
|
||||
}
|
||||
)
|
||||
| IsDict(
|
||||
# TODO: remove when deprecating Pydantic v1
|
||||
{"title": "Age", "type": "integer"}
|
||||
),
|
||||
},
|
||||
},
|
||||
"HeroRead": {
|
||||
@@ -294,7 +304,16 @@ def test_tutorial(clear_sqlmodel):
|
||||
"properties": {
|
||||
"name": {"title": "Name", "type": "string"},
|
||||
"secret_name": {"title": "Secret Name", "type": "string"},
|
||||
"age": {"title": "Age", "type": "integer"},
|
||||
"age": IsDict(
|
||||
{
|
||||
"title": "Age",
|
||||
"anyOf": [{"type": "integer"}, {"type": "null"}],
|
||||
}
|
||||
)
|
||||
| IsDict(
|
||||
# TODO: remove when deprecating Pydantic v1
|
||||
{"title": "Age", "type": "integer"}
|
||||
),
|
||||
"id": {"title": "Id", "type": "integer"},
|
||||
},
|
||||
},
|
||||
@@ -302,9 +321,36 @@ def test_tutorial(clear_sqlmodel):
|
||||
"title": "HeroUpdate",
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"name": {"title": "Name", "type": "string"},
|
||||
"secret_name": {"title": "Secret Name", "type": "string"},
|
||||
"age": {"title": "Age", "type": "integer"},
|
||||
"name": IsDict(
|
||||
{
|
||||
"title": "Name",
|
||||
"anyOf": [{"type": "string"}, {"type": "null"}],
|
||||
}
|
||||
)
|
||||
| IsDict(
|
||||
# TODO: remove when deprecating Pydantic v1
|
||||
{"title": "Name", "type": "string"}
|
||||
),
|
||||
"secret_name": IsDict(
|
||||
{
|
||||
"title": "Secret Name",
|
||||
"anyOf": [{"type": "string"}, {"type": "null"}],
|
||||
}
|
||||
)
|
||||
| IsDict(
|
||||
# TODO: remove when deprecating Pydantic v1
|
||||
{"title": "Secret Name", "type": "string"}
|
||||
),
|
||||
"age": IsDict(
|
||||
{
|
||||
"title": "Age",
|
||||
"anyOf": [{"type": "integer"}, {"type": "null"}],
|
||||
}
|
||||
)
|
||||
| IsDict(
|
||||
# TODO: remove when deprecating Pydantic v1
|
||||
{"title": "Age", "type": "integer"}
|
||||
),
|
||||
},
|
||||
},
|
||||
"ValidationError": {
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
from dirty_equals import IsDict
|
||||
from fastapi.testclient import TestClient
|
||||
from sqlmodel import create_engine
|
||||
from sqlmodel.pool import StaticPool
|
||||
@@ -289,7 +290,16 @@ def test_tutorial(clear_sqlmodel):
|
||||
"properties": {
|
||||
"name": {"title": "Name", "type": "string"},
|
||||
"secret_name": {"title": "Secret Name", "type": "string"},
|
||||
"age": {"title": "Age", "type": "integer"},
|
||||
"age": IsDict(
|
||||
{
|
||||
"title": "Age",
|
||||
"anyOf": [{"type": "integer"}, {"type": "null"}],
|
||||
}
|
||||
)
|
||||
| IsDict(
|
||||
# TODO: remove when deprecating Pydantic v1
|
||||
{"title": "Age", "type": "integer"}
|
||||
),
|
||||
},
|
||||
},
|
||||
"HeroRead": {
|
||||
@@ -299,7 +309,16 @@ def test_tutorial(clear_sqlmodel):
|
||||
"properties": {
|
||||
"name": {"title": "Name", "type": "string"},
|
||||
"secret_name": {"title": "Secret Name", "type": "string"},
|
||||
"age": {"title": "Age", "type": "integer"},
|
||||
"age": IsDict(
|
||||
{
|
||||
"title": "Age",
|
||||
"anyOf": [{"type": "integer"}, {"type": "null"}],
|
||||
}
|
||||
)
|
||||
| IsDict(
|
||||
# TODO: remove when deprecating Pydantic v1
|
||||
{"title": "Age", "type": "integer"}
|
||||
),
|
||||
"id": {"title": "Id", "type": "integer"},
|
||||
},
|
||||
},
|
||||
@@ -307,9 +326,36 @@ def test_tutorial(clear_sqlmodel):
|
||||
"title": "HeroUpdate",
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"name": {"title": "Name", "type": "string"},
|
||||
"secret_name": {"title": "Secret Name", "type": "string"},
|
||||
"age": {"title": "Age", "type": "integer"},
|
||||
"name": IsDict(
|
||||
{
|
||||
"title": "Name",
|
||||
"anyOf": [{"type": "string"}, {"type": "null"}],
|
||||
}
|
||||
)
|
||||
| IsDict(
|
||||
# TODO: remove when deprecating Pydantic v1
|
||||
{"title": "Name", "type": "string"}
|
||||
),
|
||||
"secret_name": IsDict(
|
||||
{
|
||||
"title": "Secret Name",
|
||||
"anyOf": [{"type": "string"}, {"type": "null"}],
|
||||
}
|
||||
)
|
||||
| IsDict(
|
||||
# TODO: remove when deprecating Pydantic v1
|
||||
{"title": "Secret Name", "type": "string"}
|
||||
),
|
||||
"age": IsDict(
|
||||
{
|
||||
"title": "Age",
|
||||
"anyOf": [{"type": "integer"}, {"type": "null"}],
|
||||
}
|
||||
)
|
||||
| IsDict(
|
||||
# TODO: remove when deprecating Pydantic v1
|
||||
{"title": "Age", "type": "integer"}
|
||||
),
|
||||
},
|
||||
},
|
||||
"ValidationError": {
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
from dirty_equals import IsDict
|
||||
from fastapi.testclient import TestClient
|
||||
from sqlmodel import create_engine
|
||||
from sqlmodel.pool import StaticPool
|
||||
@@ -289,7 +290,16 @@ def test_tutorial(clear_sqlmodel):
|
||||
"properties": {
|
||||
"name": {"title": "Name", "type": "string"},
|
||||
"secret_name": {"title": "Secret Name", "type": "string"},
|
||||
"age": {"title": "Age", "type": "integer"},
|
||||
"age": IsDict(
|
||||
{
|
||||
"title": "Age",
|
||||
"anyOf": [{"type": "integer"}, {"type": "null"}],
|
||||
}
|
||||
)
|
||||
| IsDict(
|
||||
# TODO: remove when deprecating Pydantic v1
|
||||
{"title": "Age", "type": "integer"}
|
||||
),
|
||||
},
|
||||
},
|
||||
"HeroRead": {
|
||||
@@ -299,7 +309,16 @@ def test_tutorial(clear_sqlmodel):
|
||||
"properties": {
|
||||
"name": {"title": "Name", "type": "string"},
|
||||
"secret_name": {"title": "Secret Name", "type": "string"},
|
||||
"age": {"title": "Age", "type": "integer"},
|
||||
"age": IsDict(
|
||||
{
|
||||
"title": "Age",
|
||||
"anyOf": [{"type": "integer"}, {"type": "null"}],
|
||||
}
|
||||
)
|
||||
| IsDict(
|
||||
# TODO: remove when deprecating Pydantic v1
|
||||
{"title": "Age", "type": "integer"}
|
||||
),
|
||||
"id": {"title": "Id", "type": "integer"},
|
||||
},
|
||||
},
|
||||
@@ -307,9 +326,36 @@ def test_tutorial(clear_sqlmodel):
|
||||
"title": "HeroUpdate",
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"name": {"title": "Name", "type": "string"},
|
||||
"secret_name": {"title": "Secret Name", "type": "string"},
|
||||
"age": {"title": "Age", "type": "integer"},
|
||||
"name": IsDict(
|
||||
{
|
||||
"title": "Name",
|
||||
"anyOf": [{"type": "string"}, {"type": "null"}],
|
||||
}
|
||||
)
|
||||
| IsDict(
|
||||
# TODO: remove when deprecating Pydantic v1
|
||||
{"title": "Name", "type": "string"}
|
||||
),
|
||||
"secret_name": IsDict(
|
||||
{
|
||||
"title": "Secret Name",
|
||||
"anyOf": [{"type": "string"}, {"type": "null"}],
|
||||
}
|
||||
)
|
||||
| IsDict(
|
||||
# TODO: remove when deprecating Pydantic v1
|
||||
{"title": "Secret Name", "type": "string"}
|
||||
),
|
||||
"age": IsDict(
|
||||
{
|
||||
"title": "Age",
|
||||
"anyOf": [{"type": "integer"}, {"type": "null"}],
|
||||
}
|
||||
)
|
||||
| IsDict(
|
||||
# TODO: remove when deprecating Pydantic v1
|
||||
{"title": "Age", "type": "integer"}
|
||||
),
|
||||
},
|
||||
},
|
||||
"ValidationError": {
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
from dirty_equals import IsDict
|
||||
from fastapi.testclient import TestClient
|
||||
from sqlmodel import create_engine
|
||||
from sqlmodel.pool import StaticPool
|
||||
@@ -51,11 +52,10 @@ def test_tutorial(clear_sqlmodel):
|
||||
assert data[1]["id"] == hero2_data["id"]
|
||||
|
||||
response = client.get("/openapi.json")
|
||||
data = response.json()
|
||||
|
||||
assert response.status_code == 200, response.text
|
||||
|
||||
assert data == {
|
||||
assert response.json() == {
|
||||
"openapi": "3.1.0",
|
||||
"info": {"title": "FastAPI", "version": "0.1.0"},
|
||||
"paths": {
|
||||
@@ -120,10 +120,28 @@ def test_tutorial(clear_sqlmodel):
|
||||
"required": ["name", "secret_name"],
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"id": {"title": "Id", "type": "integer"},
|
||||
"id": IsDict(
|
||||
{
|
||||
"title": "Id",
|
||||
"anyOf": [{"type": "integer"}, {"type": "null"}],
|
||||
}
|
||||
)
|
||||
| IsDict(
|
||||
# TODO: remove when deprecating Pydantic v1
|
||||
{"title": "Id", "type": "integer"}
|
||||
),
|
||||
"name": {"title": "Name", "type": "string"},
|
||||
"secret_name": {"title": "Secret Name", "type": "string"},
|
||||
"age": {"title": "Age", "type": "integer"},
|
||||
"age": IsDict(
|
||||
{
|
||||
"title": "Age",
|
||||
"anyOf": [{"type": "integer"}, {"type": "null"}],
|
||||
}
|
||||
)
|
||||
| IsDict(
|
||||
# TODO: remove when deprecating Pydantic v1
|
||||
{"title": "Age", "type": "integer"}
|
||||
),
|
||||
},
|
||||
},
|
||||
"ValidationError": {
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
from dirty_equals import IsDict
|
||||
from fastapi.testclient import TestClient
|
||||
from sqlmodel import create_engine
|
||||
from sqlmodel.pool import StaticPool
|
||||
@@ -54,11 +55,10 @@ def test_tutorial(clear_sqlmodel):
|
||||
assert data[1]["id"] == hero2_data["id"]
|
||||
|
||||
response = client.get("/openapi.json")
|
||||
data = response.json()
|
||||
|
||||
assert response.status_code == 200, response.text
|
||||
|
||||
assert data == {
|
||||
assert response.json() == {
|
||||
"openapi": "3.1.0",
|
||||
"info": {"title": "FastAPI", "version": "0.1.0"},
|
||||
"paths": {
|
||||
@@ -123,10 +123,28 @@ def test_tutorial(clear_sqlmodel):
|
||||
"required": ["name", "secret_name"],
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"id": {"title": "Id", "type": "integer"},
|
||||
"id": IsDict(
|
||||
{
|
||||
"title": "Id",
|
||||
"anyOf": [{"type": "integer"}, {"type": "null"}],
|
||||
}
|
||||
)
|
||||
| IsDict(
|
||||
# TODO: remove when deprecating Pydantic v1
|
||||
{"title": "Id", "type": "integer"}
|
||||
),
|
||||
"name": {"title": "Name", "type": "string"},
|
||||
"secret_name": {"title": "Secret Name", "type": "string"},
|
||||
"age": {"title": "Age", "type": "integer"},
|
||||
"age": IsDict(
|
||||
{
|
||||
"title": "Age",
|
||||
"anyOf": [{"type": "integer"}, {"type": "null"}],
|
||||
}
|
||||
)
|
||||
| IsDict(
|
||||
# TODO: remove when deprecating Pydantic v1
|
||||
{"title": "Age", "type": "integer"}
|
||||
),
|
||||
},
|
||||
},
|
||||
"ValidationError": {
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
from dirty_equals import IsDict
|
||||
from fastapi.testclient import TestClient
|
||||
from sqlmodel import create_engine
|
||||
from sqlmodel.pool import StaticPool
|
||||
@@ -518,8 +519,26 @@ def test_tutorial(clear_sqlmodel):
|
||||
"properties": {
|
||||
"name": {"title": "Name", "type": "string"},
|
||||
"secret_name": {"title": "Secret Name", "type": "string"},
|
||||
"age": {"title": "Age", "type": "integer"},
|
||||
"team_id": {"title": "Team Id", "type": "integer"},
|
||||
"age": IsDict(
|
||||
{
|
||||
"title": "Age",
|
||||
"anyOf": [{"type": "integer"}, {"type": "null"}],
|
||||
}
|
||||
)
|
||||
| IsDict(
|
||||
# TODO: remove when deprecating Pydantic v1
|
||||
{"title": "Age", "type": "integer"}
|
||||
),
|
||||
"team_id": IsDict(
|
||||
{
|
||||
"title": "Team Id",
|
||||
"anyOf": [{"type": "integer"}, {"type": "null"}],
|
||||
}
|
||||
)
|
||||
| IsDict(
|
||||
# TODO: remove when deprecating Pydantic v1
|
||||
{"title": "Team Id", "type": "integer"}
|
||||
),
|
||||
},
|
||||
},
|
||||
"HeroRead": {
|
||||
@@ -529,8 +548,26 @@ def test_tutorial(clear_sqlmodel):
|
||||
"properties": {
|
||||
"name": {"title": "Name", "type": "string"},
|
||||
"secret_name": {"title": "Secret Name", "type": "string"},
|
||||
"age": {"title": "Age", "type": "integer"},
|
||||
"team_id": {"title": "Team Id", "type": "integer"},
|
||||
"age": IsDict(
|
||||
{
|
||||
"title": "Age",
|
||||
"anyOf": [{"type": "integer"}, {"type": "null"}],
|
||||
}
|
||||
)
|
||||
| IsDict(
|
||||
# TODO: remove when deprecating Pydantic v1
|
||||
{"title": "Age", "type": "integer"}
|
||||
),
|
||||
"team_id": IsDict(
|
||||
{
|
||||
"title": "Team Id",
|
||||
"anyOf": [{"type": "integer"}, {"type": "null"}],
|
||||
}
|
||||
)
|
||||
| IsDict(
|
||||
# TODO: remove when deprecating Pydantic v1
|
||||
{"title": "Team Id", "type": "integer"}
|
||||
),
|
||||
"id": {"title": "Id", "type": "integer"},
|
||||
},
|
||||
},
|
||||
@@ -538,10 +575,46 @@ def test_tutorial(clear_sqlmodel):
|
||||
"title": "HeroUpdate",
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"name": {"title": "Name", "type": "string"},
|
||||
"secret_name": {"title": "Secret Name", "type": "string"},
|
||||
"age": {"title": "Age", "type": "integer"},
|
||||
"team_id": {"title": "Team Id", "type": "integer"},
|
||||
"name": IsDict(
|
||||
{
|
||||
"title": "Name",
|
||||
"anyOf": [{"type": "string"}, {"type": "null"}],
|
||||
}
|
||||
)
|
||||
| IsDict(
|
||||
# TODO: remove when deprecating Pydantic v1
|
||||
{"title": "Name", "type": "string"}
|
||||
),
|
||||
"secret_name": IsDict(
|
||||
{
|
||||
"title": "Secret Name",
|
||||
"anyOf": [{"type": "string"}, {"type": "null"}],
|
||||
}
|
||||
)
|
||||
| IsDict(
|
||||
# TODO: remove when deprecating Pydantic v1
|
||||
{"title": "Secret Name", "type": "string"}
|
||||
),
|
||||
"age": IsDict(
|
||||
{
|
||||
"title": "Age",
|
||||
"anyOf": [{"type": "integer"}, {"type": "null"}],
|
||||
}
|
||||
)
|
||||
| IsDict(
|
||||
# TODO: remove when deprecating Pydantic v1
|
||||
{"title": "Age", "type": "integer"}
|
||||
),
|
||||
"team_id": IsDict(
|
||||
{
|
||||
"title": "Team Id",
|
||||
"anyOf": [{"type": "integer"}, {"type": "null"}],
|
||||
}
|
||||
)
|
||||
| IsDict(
|
||||
# TODO: remove when deprecating Pydantic v1
|
||||
{"title": "Team Id", "type": "integer"}
|
||||
),
|
||||
},
|
||||
},
|
||||
"TeamCreate": {
|
||||
@@ -567,8 +640,26 @@ def test_tutorial(clear_sqlmodel):
|
||||
"title": "TeamUpdate",
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"name": {"title": "Name", "type": "string"},
|
||||
"headquarters": {"title": "Headquarters", "type": "string"},
|
||||
"name": IsDict(
|
||||
{
|
||||
"title": "Name",
|
||||
"anyOf": [{"type": "string"}, {"type": "null"}],
|
||||
}
|
||||
)
|
||||
| IsDict(
|
||||
# TODO: remove when deprecating Pydantic v1
|
||||
{"title": "Name", "type": "string"}
|
||||
),
|
||||
"headquarters": IsDict(
|
||||
{
|
||||
"title": "Headquarters",
|
||||
"anyOf": [{"type": "string"}, {"type": "null"}],
|
||||
}
|
||||
)
|
||||
| IsDict(
|
||||
# TODO: remove when deprecating Pydantic v1
|
||||
{"title": "Headquarters", "type": "string"}
|
||||
),
|
||||
},
|
||||
},
|
||||
"ValidationError": {
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
from dirty_equals import IsDict
|
||||
from fastapi.testclient import TestClient
|
||||
from sqlmodel import create_engine
|
||||
from sqlmodel.pool import StaticPool
|
||||
@@ -521,8 +522,26 @@ def test_tutorial(clear_sqlmodel):
|
||||
"properties": {
|
||||
"name": {"title": "Name", "type": "string"},
|
||||
"secret_name": {"title": "Secret Name", "type": "string"},
|
||||
"age": {"title": "Age", "type": "integer"},
|
||||
"team_id": {"title": "Team Id", "type": "integer"},
|
||||
"age": IsDict(
|
||||
{
|
||||
"title": "Age",
|
||||
"anyOf": [{"type": "integer"}, {"type": "null"}],
|
||||
}
|
||||
)
|
||||
| IsDict(
|
||||
# TODO: remove when deprecating Pydantic v1
|
||||
{"title": "Age", "type": "integer"}
|
||||
),
|
||||
"team_id": IsDict(
|
||||
{
|
||||
"title": "Team Id",
|
||||
"anyOf": [{"type": "integer"}, {"type": "null"}],
|
||||
}
|
||||
)
|
||||
| IsDict(
|
||||
# TODO: remove when deprecating Pydantic v1
|
||||
{"title": "Team Id", "type": "integer"}
|
||||
),
|
||||
},
|
||||
},
|
||||
"HeroRead": {
|
||||
@@ -532,8 +551,26 @@ def test_tutorial(clear_sqlmodel):
|
||||
"properties": {
|
||||
"name": {"title": "Name", "type": "string"},
|
||||
"secret_name": {"title": "Secret Name", "type": "string"},
|
||||
"age": {"title": "Age", "type": "integer"},
|
||||
"team_id": {"title": "Team Id", "type": "integer"},
|
||||
"age": IsDict(
|
||||
{
|
||||
"title": "Age",
|
||||
"anyOf": [{"type": "integer"}, {"type": "null"}],
|
||||
}
|
||||
)
|
||||
| IsDict(
|
||||
# TODO: remove when deprecating Pydantic v1
|
||||
{"title": "Age", "type": "integer"}
|
||||
),
|
||||
"team_id": IsDict(
|
||||
{
|
||||
"title": "Team Id",
|
||||
"anyOf": [{"type": "integer"}, {"type": "null"}],
|
||||
}
|
||||
)
|
||||
| IsDict(
|
||||
# TODO: remove when deprecating Pydantic v1
|
||||
{"title": "Team Id", "type": "integer"}
|
||||
),
|
||||
"id": {"title": "Id", "type": "integer"},
|
||||
},
|
||||
},
|
||||
@@ -541,10 +578,46 @@ def test_tutorial(clear_sqlmodel):
|
||||
"title": "HeroUpdate",
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"name": {"title": "Name", "type": "string"},
|
||||
"secret_name": {"title": "Secret Name", "type": "string"},
|
||||
"age": {"title": "Age", "type": "integer"},
|
||||
"team_id": {"title": "Team Id", "type": "integer"},
|
||||
"name": IsDict(
|
||||
{
|
||||
"title": "Name",
|
||||
"anyOf": [{"type": "string"}, {"type": "null"}],
|
||||
}
|
||||
)
|
||||
| IsDict(
|
||||
# TODO: remove when deprecating Pydantic v1
|
||||
{"title": "Name", "type": "string"}
|
||||
),
|
||||
"secret_name": IsDict(
|
||||
{
|
||||
"title": "Secret Name",
|
||||
"anyOf": [{"type": "string"}, {"type": "null"}],
|
||||
}
|
||||
)
|
||||
| IsDict(
|
||||
# TODO: remove when deprecating Pydantic v1
|
||||
{"title": "Secret Name", "type": "string"}
|
||||
),
|
||||
"age": IsDict(
|
||||
{
|
||||
"title": "Age",
|
||||
"anyOf": [{"type": "integer"}, {"type": "null"}],
|
||||
}
|
||||
)
|
||||
| IsDict(
|
||||
# TODO: remove when deprecating Pydantic v1
|
||||
{"title": "Age", "type": "integer"}
|
||||
),
|
||||
"team_id": IsDict(
|
||||
{
|
||||
"title": "Team Id",
|
||||
"anyOf": [{"type": "integer"}, {"type": "null"}],
|
||||
}
|
||||
)
|
||||
| IsDict(
|
||||
# TODO: remove when deprecating Pydantic v1
|
||||
{"title": "Team Id", "type": "integer"}
|
||||
),
|
||||
},
|
||||
},
|
||||
"TeamCreate": {
|
||||
@@ -570,8 +643,26 @@ def test_tutorial(clear_sqlmodel):
|
||||
"title": "TeamUpdate",
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"name": {"title": "Name", "type": "string"},
|
||||
"headquarters": {"title": "Headquarters", "type": "string"},
|
||||
"name": IsDict(
|
||||
{
|
||||
"title": "Name",
|
||||
"anyOf": [{"type": "string"}, {"type": "null"}],
|
||||
}
|
||||
)
|
||||
| IsDict(
|
||||
# TODO: remove when deprecating Pydantic v1
|
||||
{"title": "Name", "type": "string"}
|
||||
),
|
||||
"headquarters": IsDict(
|
||||
{
|
||||
"title": "Headquarters",
|
||||
"anyOf": [{"type": "string"}, {"type": "null"}],
|
||||
}
|
||||
)
|
||||
| IsDict(
|
||||
# TODO: remove when deprecating Pydantic v1
|
||||
{"title": "Headquarters", "type": "string"}
|
||||
),
|
||||
},
|
||||
},
|
||||
"ValidationError": {
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
from dirty_equals import IsDict
|
||||
from fastapi.testclient import TestClient
|
||||
from sqlmodel import create_engine
|
||||
from sqlmodel.pool import StaticPool
|
||||
@@ -521,8 +522,26 @@ def test_tutorial(clear_sqlmodel):
|
||||
"properties": {
|
||||
"name": {"title": "Name", "type": "string"},
|
||||
"secret_name": {"title": "Secret Name", "type": "string"},
|
||||
"age": {"title": "Age", "type": "integer"},
|
||||
"team_id": {"title": "Team Id", "type": "integer"},
|
||||
"age": IsDict(
|
||||
{
|
||||
"title": "Age",
|
||||
"anyOf": [{"type": "integer"}, {"type": "null"}],
|
||||
}
|
||||
)
|
||||
| IsDict(
|
||||
# TODO: remove when deprecating Pydantic v1
|
||||
{"title": "Age", "type": "integer"}
|
||||
),
|
||||
"team_id": IsDict(
|
||||
{
|
||||
"title": "Team Id",
|
||||
"anyOf": [{"type": "integer"}, {"type": "null"}],
|
||||
}
|
||||
)
|
||||
| IsDict(
|
||||
# TODO: remove when deprecating Pydantic v1
|
||||
{"title": "Team Id", "type": "integer"}
|
||||
),
|
||||
},
|
||||
},
|
||||
"HeroRead": {
|
||||
@@ -532,8 +551,26 @@ def test_tutorial(clear_sqlmodel):
|
||||
"properties": {
|
||||
"name": {"title": "Name", "type": "string"},
|
||||
"secret_name": {"title": "Secret Name", "type": "string"},
|
||||
"age": {"title": "Age", "type": "integer"},
|
||||
"team_id": {"title": "Team Id", "type": "integer"},
|
||||
"age": IsDict(
|
||||
{
|
||||
"title": "Age",
|
||||
"anyOf": [{"type": "integer"}, {"type": "null"}],
|
||||
}
|
||||
)
|
||||
| IsDict(
|
||||
# TODO: remove when deprecating Pydantic v1
|
||||
{"title": "Age", "type": "integer"}
|
||||
),
|
||||
"team_id": IsDict(
|
||||
{
|
||||
"title": "Team Id",
|
||||
"anyOf": [{"type": "integer"}, {"type": "null"}],
|
||||
}
|
||||
)
|
||||
| IsDict(
|
||||
# TODO: remove when deprecating Pydantic v1
|
||||
{"title": "Team Id", "type": "integer"}
|
||||
),
|
||||
"id": {"title": "Id", "type": "integer"},
|
||||
},
|
||||
},
|
||||
@@ -541,10 +578,46 @@ def test_tutorial(clear_sqlmodel):
|
||||
"title": "HeroUpdate",
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"name": {"title": "Name", "type": "string"},
|
||||
"secret_name": {"title": "Secret Name", "type": "string"},
|
||||
"age": {"title": "Age", "type": "integer"},
|
||||
"team_id": {"title": "Team Id", "type": "integer"},
|
||||
"name": IsDict(
|
||||
{
|
||||
"title": "Name",
|
||||
"anyOf": [{"type": "string"}, {"type": "null"}],
|
||||
}
|
||||
)
|
||||
| IsDict(
|
||||
# TODO: remove when deprecating Pydantic v1
|
||||
{"title": "Name", "type": "string"}
|
||||
),
|
||||
"secret_name": IsDict(
|
||||
{
|
||||
"title": "Secret Name",
|
||||
"anyOf": [{"type": "string"}, {"type": "null"}],
|
||||
}
|
||||
)
|
||||
| IsDict(
|
||||
# TODO: remove when deprecating Pydantic v1
|
||||
{"title": "Secret Name", "type": "string"}
|
||||
),
|
||||
"age": IsDict(
|
||||
{
|
||||
"title": "Age",
|
||||
"anyOf": [{"type": "integer"}, {"type": "null"}],
|
||||
}
|
||||
)
|
||||
| IsDict(
|
||||
# TODO: remove when deprecating Pydantic v1
|
||||
{"title": "Age", "type": "integer"}
|
||||
),
|
||||
"team_id": IsDict(
|
||||
{
|
||||
"title": "Team Id",
|
||||
"anyOf": [{"type": "integer"}, {"type": "null"}],
|
||||
}
|
||||
)
|
||||
| IsDict(
|
||||
# TODO: remove when deprecating Pydantic v1
|
||||
{"title": "Team Id", "type": "integer"}
|
||||
),
|
||||
},
|
||||
},
|
||||
"TeamCreate": {
|
||||
@@ -570,8 +643,26 @@ def test_tutorial(clear_sqlmodel):
|
||||
"title": "TeamUpdate",
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"name": {"title": "Name", "type": "string"},
|
||||
"headquarters": {"title": "Headquarters", "type": "string"},
|
||||
"name": IsDict(
|
||||
{
|
||||
"title": "Name",
|
||||
"anyOf": [{"type": "string"}, {"type": "null"}],
|
||||
}
|
||||
)
|
||||
| IsDict(
|
||||
# TODO: remove when deprecating Pydantic v1
|
||||
{"title": "Name", "type": "string"}
|
||||
),
|
||||
"headquarters": IsDict(
|
||||
{
|
||||
"title": "Headquarters",
|
||||
"anyOf": [{"type": "string"}, {"type": "null"}],
|
||||
}
|
||||
)
|
||||
| IsDict(
|
||||
# TODO: remove when deprecating Pydantic v1
|
||||
{"title": "Headquarters", "type": "string"}
|
||||
),
|
||||
},
|
||||
},
|
||||
"ValidationError": {
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
from dirty_equals import IsDict
|
||||
from fastapi.testclient import TestClient
|
||||
from sqlmodel import create_engine
|
||||
from sqlmodel.pool import StaticPool
|
||||
@@ -263,7 +264,16 @@ def test_tutorial(clear_sqlmodel):
|
||||
"properties": {
|
||||
"name": {"title": "Name", "type": "string"},
|
||||
"secret_name": {"title": "Secret Name", "type": "string"},
|
||||
"age": {"title": "Age", "type": "integer"},
|
||||
"age": IsDict(
|
||||
{
|
||||
"title": "Age",
|
||||
"anyOf": [{"type": "integer"}, {"type": "null"}],
|
||||
}
|
||||
)
|
||||
| IsDict(
|
||||
# TODO: remove when deprecating Pydantic v1
|
||||
{"title": "Age", "type": "integer"}
|
||||
),
|
||||
},
|
||||
},
|
||||
"HeroRead": {
|
||||
@@ -273,7 +283,16 @@ def test_tutorial(clear_sqlmodel):
|
||||
"properties": {
|
||||
"name": {"title": "Name", "type": "string"},
|
||||
"secret_name": {"title": "Secret Name", "type": "string"},
|
||||
"age": {"title": "Age", "type": "integer"},
|
||||
"age": IsDict(
|
||||
{
|
||||
"title": "Age",
|
||||
"anyOf": [{"type": "integer"}, {"type": "null"}],
|
||||
}
|
||||
)
|
||||
| IsDict(
|
||||
# TODO: remove when deprecating Pydantic v1
|
||||
{"title": "Age", "type": "integer"}
|
||||
),
|
||||
"id": {"title": "Id", "type": "integer"},
|
||||
},
|
||||
},
|
||||
@@ -281,9 +300,36 @@ def test_tutorial(clear_sqlmodel):
|
||||
"title": "HeroUpdate",
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"name": {"title": "Name", "type": "string"},
|
||||
"secret_name": {"title": "Secret Name", "type": "string"},
|
||||
"age": {"title": "Age", "type": "integer"},
|
||||
"name": IsDict(
|
||||
{
|
||||
"title": "Name",
|
||||
"anyOf": [{"type": "string"}, {"type": "null"}],
|
||||
}
|
||||
)
|
||||
| IsDict(
|
||||
# TODO: remove when deprecating Pydantic v1
|
||||
{"title": "Name", "type": "string"}
|
||||
),
|
||||
"secret_name": IsDict(
|
||||
{
|
||||
"title": "Secret Name",
|
||||
"anyOf": [{"type": "string"}, {"type": "null"}],
|
||||
}
|
||||
)
|
||||
| IsDict(
|
||||
# TODO: remove when deprecating Pydantic v1
|
||||
{"title": "Secret Name", "type": "string"}
|
||||
),
|
||||
"age": IsDict(
|
||||
{
|
||||
"title": "Age",
|
||||
"anyOf": [{"type": "integer"}, {"type": "null"}],
|
||||
}
|
||||
)
|
||||
| IsDict(
|
||||
# TODO: remove when deprecating Pydantic v1
|
||||
{"title": "Age", "type": "integer"}
|
||||
),
|
||||
},
|
||||
},
|
||||
"ValidationError": {
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
from dirty_equals import IsDict
|
||||
from fastapi.testclient import TestClient
|
||||
from sqlmodel import create_engine
|
||||
from sqlmodel.pool import StaticPool
|
||||
@@ -266,7 +267,16 @@ def test_tutorial(clear_sqlmodel):
|
||||
"properties": {
|
||||
"name": {"title": "Name", "type": "string"},
|
||||
"secret_name": {"title": "Secret Name", "type": "string"},
|
||||
"age": {"title": "Age", "type": "integer"},
|
||||
"age": IsDict(
|
||||
{
|
||||
"title": "Age",
|
||||
"anyOf": [{"type": "integer"}, {"type": "null"}],
|
||||
}
|
||||
)
|
||||
| IsDict(
|
||||
# TODO: remove when deprecating Pydantic v1
|
||||
{"title": "Age", "type": "integer"}
|
||||
),
|
||||
},
|
||||
},
|
||||
"HeroRead": {
|
||||
@@ -276,7 +286,16 @@ def test_tutorial(clear_sqlmodel):
|
||||
"properties": {
|
||||
"name": {"title": "Name", "type": "string"},
|
||||
"secret_name": {"title": "Secret Name", "type": "string"},
|
||||
"age": {"title": "Age", "type": "integer"},
|
||||
"age": IsDict(
|
||||
{
|
||||
"title": "Age",
|
||||
"anyOf": [{"type": "integer"}, {"type": "null"}],
|
||||
}
|
||||
)
|
||||
| IsDict(
|
||||
# TODO: remove when deprecating Pydantic v1
|
||||
{"title": "Age", "type": "integer"}
|
||||
),
|
||||
"id": {"title": "Id", "type": "integer"},
|
||||
},
|
||||
},
|
||||
@@ -284,9 +303,36 @@ def test_tutorial(clear_sqlmodel):
|
||||
"title": "HeroUpdate",
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"name": {"title": "Name", "type": "string"},
|
||||
"secret_name": {"title": "Secret Name", "type": "string"},
|
||||
"age": {"title": "Age", "type": "integer"},
|
||||
"name": IsDict(
|
||||
{
|
||||
"title": "Name",
|
||||
"anyOf": [{"type": "string"}, {"type": "null"}],
|
||||
}
|
||||
)
|
||||
| IsDict(
|
||||
# TODO: remove when deprecating Pydantic v1
|
||||
{"title": "Name", "type": "string"}
|
||||
),
|
||||
"secret_name": IsDict(
|
||||
{
|
||||
"title": "Secret Name",
|
||||
"anyOf": [{"type": "string"}, {"type": "null"}],
|
||||
}
|
||||
)
|
||||
| IsDict(
|
||||
# TODO: remove when deprecating Pydantic v1
|
||||
{"title": "Secret Name", "type": "string"}
|
||||
),
|
||||
"age": IsDict(
|
||||
{
|
||||
"title": "Age",
|
||||
"anyOf": [{"type": "integer"}, {"type": "null"}],
|
||||
}
|
||||
)
|
||||
| IsDict(
|
||||
# TODO: remove when deprecating Pydantic v1
|
||||
{"title": "Age", "type": "integer"}
|
||||
),
|
||||
},
|
||||
},
|
||||
"ValidationError": {
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
from dirty_equals import IsDict
|
||||
from fastapi.testclient import TestClient
|
||||
from sqlmodel import create_engine
|
||||
from sqlmodel.pool import StaticPool
|
||||
@@ -266,7 +267,16 @@ def test_tutorial(clear_sqlmodel):
|
||||
"properties": {
|
||||
"name": {"title": "Name", "type": "string"},
|
||||
"secret_name": {"title": "Secret Name", "type": "string"},
|
||||
"age": {"title": "Age", "type": "integer"},
|
||||
"age": IsDict(
|
||||
{
|
||||
"title": "Age",
|
||||
"anyOf": [{"type": "integer"}, {"type": "null"}],
|
||||
}
|
||||
)
|
||||
| IsDict(
|
||||
# TODO: remove when deprecating Pydantic v1
|
||||
{"title": "Age", "type": "integer"}
|
||||
),
|
||||
},
|
||||
},
|
||||
"HeroRead": {
|
||||
@@ -276,7 +286,16 @@ def test_tutorial(clear_sqlmodel):
|
||||
"properties": {
|
||||
"name": {"title": "Name", "type": "string"},
|
||||
"secret_name": {"title": "Secret Name", "type": "string"},
|
||||
"age": {"title": "Age", "type": "integer"},
|
||||
"age": IsDict(
|
||||
{
|
||||
"title": "Age",
|
||||
"anyOf": [{"type": "integer"}, {"type": "null"}],
|
||||
}
|
||||
)
|
||||
| IsDict(
|
||||
# TODO: remove when deprecating Pydantic v1
|
||||
{"title": "Age", "type": "integer"}
|
||||
),
|
||||
"id": {"title": "Id", "type": "integer"},
|
||||
},
|
||||
},
|
||||
@@ -284,9 +303,36 @@ def test_tutorial(clear_sqlmodel):
|
||||
"title": "HeroUpdate",
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"name": {"title": "Name", "type": "string"},
|
||||
"secret_name": {"title": "Secret Name", "type": "string"},
|
||||
"age": {"title": "Age", "type": "integer"},
|
||||
"name": IsDict(
|
||||
{
|
||||
"title": "Name",
|
||||
"anyOf": [{"type": "string"}, {"type": "null"}],
|
||||
}
|
||||
)
|
||||
| IsDict(
|
||||
# TODO: remove when deprecating Pydantic v1
|
||||
{"title": "Name", "type": "string"}
|
||||
),
|
||||
"secret_name": IsDict(
|
||||
{
|
||||
"title": "Secret Name",
|
||||
"anyOf": [{"type": "string"}, {"type": "null"}],
|
||||
}
|
||||
)
|
||||
| IsDict(
|
||||
# TODO: remove when deprecating Pydantic v1
|
||||
{"title": "Secret Name", "type": "string"}
|
||||
),
|
||||
"age": IsDict(
|
||||
{
|
||||
"title": "Age",
|
||||
"anyOf": [{"type": "integer"}, {"type": "null"}],
|
||||
}
|
||||
)
|
||||
| IsDict(
|
||||
# TODO: remove when deprecating Pydantic v1
|
||||
{"title": "Age", "type": "integer"}
|
||||
),
|
||||
},
|
||||
},
|
||||
"ValidationError": {
|
||||
|
||||
@@ -1,12 +1,14 @@
|
||||
from typing import Optional
|
||||
|
||||
import pytest
|
||||
from pydantic import validator
|
||||
from pydantic.error_wrappers import ValidationError
|
||||
from sqlmodel import SQLModel
|
||||
|
||||
from .conftest import needs_pydanticv1, needs_pydanticv2
|
||||
|
||||
def test_validation(clear_sqlmodel):
|
||||
|
||||
@needs_pydanticv1
|
||||
def test_validation_pydantic_v1(clear_sqlmodel):
|
||||
"""Test validation of implicit and explicit None values.
|
||||
|
||||
# For consistency with pydantic, validators are not to be called on
|
||||
@@ -16,6 +18,7 @@ def test_validation(clear_sqlmodel):
|
||||
https://github.com/samuelcolvin/pydantic/issues/1223
|
||||
|
||||
"""
|
||||
from pydantic import validator
|
||||
|
||||
class Hero(SQLModel):
|
||||
name: Optional[str] = None
|
||||
@@ -31,3 +34,32 @@ def test_validation(clear_sqlmodel):
|
||||
|
||||
with pytest.raises(ValidationError):
|
||||
Hero.validate({"name": None, "age": 25})
|
||||
|
||||
|
||||
@needs_pydanticv2
|
||||
def test_validation_pydantic_v2(clear_sqlmodel):
|
||||
"""Test validation of implicit and explicit None values.
|
||||
|
||||
# For consistency with pydantic, validators are not to be called on
|
||||
# arguments that are not explicitly provided.
|
||||
|
||||
https://github.com/tiangolo/sqlmodel/issues/230
|
||||
https://github.com/samuelcolvin/pydantic/issues/1223
|
||||
|
||||
"""
|
||||
from pydantic import field_validator
|
||||
|
||||
class Hero(SQLModel):
|
||||
name: Optional[str] = None
|
||||
secret_name: Optional[str] = None
|
||||
age: Optional[int] = None
|
||||
|
||||
@field_validator("name", "secret_name", "age")
|
||||
def reject_none(cls, v):
|
||||
assert v is not None
|
||||
return v
|
||||
|
||||
Hero.model_validate({"age": 25})
|
||||
|
||||
with pytest.raises(ValidationError):
|
||||
Hero.model_validate({"name": None, "age": 25})
|
||||
|
||||
Reference in New Issue
Block a user