File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ """Test models for nested IRI serialization."""
2+
3+ from __future__ import annotations
4+
5+ from pydantic .v1 import Field
6+
7+ from oold .model .v1 import LinkedBaseModel
8+
9+
10+ class Bar2 (LinkedBaseModel ):
11+ class Config :
12+ schema_extra = {"title" : "Bar2" }
13+
14+ id : str | None = None
15+ type : list [str ] | None = ["Bar2" ]
16+ prop1 : str | None = None
17+
18+
19+ class Bar (Bar2 ):
20+ class Config :
21+ schema_extra = {"title" : "Bar" }
22+
23+ type : list [str ] | None = ["Bar" ]
24+ prop2 : str | None = None
25+
26+
27+ class NestedItem (LinkedBaseModel ):
28+ """A nested item with an IRI reference field."""
29+
30+ class Config :
31+ schema_extra = {"title" : "NestedItem" }
32+
33+ id : str | None = None
34+ type : list [str ] | None = ["NestedItem" ]
35+ ref : Bar | None = Field (None , range = "Bar.json" )
36+ value : int | None = None
37+
38+
39+ class Container (LinkedBaseModel ):
40+ class Config :
41+ schema_extra = {"title" : "Container" }
42+
43+ id : str
44+ type : list [str ] | None = ["Container" ]
45+ items : list [NestedItem ] | None = None
Original file line number Diff line number Diff line change 1+ """Test models for nested IRI serialization (pydantic v2)."""
2+
3+ from __future__ import annotations
4+
5+ from pydantic import ConfigDict , Field
6+
7+ from oold .model import LinkedBaseModel
8+
9+
10+ class Bar2 (LinkedBaseModel ):
11+ model_config = ConfigDict (json_schema_extra = {"title" : "Bar2" })
12+
13+ id : str | None = None
14+ type : list [str ] | None = ["Bar2" ]
15+ prop1 : str | None = None
16+
17+
18+ class Bar (Bar2 ):
19+ model_config = ConfigDict (json_schema_extra = {"title" : "Bar" })
20+
21+ type : list [str ] | None = ["Bar" ]
22+ prop2 : str | None = None
23+
24+
25+ class NestedItem (LinkedBaseModel ):
26+ """A nested item with an IRI reference field."""
27+
28+ model_config = ConfigDict (json_schema_extra = {"title" : "NestedItem" })
29+
30+ id : str | None = None
31+ type : list [str ] | None = ["NestedItem" ]
32+ ref : Bar | None = Field (None , json_schema_extra = {"range" : "Bar.json" })
33+ value : int | None = None
34+
35+
36+ class Container (LinkedBaseModel ):
37+ model_config = ConfigDict (json_schema_extra = {"title" : "Container" })
38+
39+ id : str
40+ type : list [str ] | None = ["Container" ]
41+ items : list [NestedItem ] | None = None
You can’t perform that action at this time.
0 commit comments