44from enum import Enum
55from typing import TYPE_CHECKING , Any , Optional , Union
66
7- from pydantic import BaseModel , Field
7+ from pydantic import BaseModel , Field , ConfigDict
88
99if TYPE_CHECKING :
1010 from ..node import InfrahubNode , InfrahubNodeSync
@@ -89,6 +89,8 @@ class RelationshipDeleteBehavior(str, Enum):
8989
9090
9191class AttributeSchema (BaseModel ):
92+ model_config = ConfigDict (use_enum_values = True )
93+
9294 id : Optional [str ] = None
9395 state : SchemaState = SchemaState .PRESENT
9496 name : str
@@ -108,12 +110,16 @@ class AttributeSchema(BaseModel):
108110
109111
110112class AttributeSchemaAPI (AttributeSchema ):
113+ model_config = ConfigDict (use_enum_values = True )
114+
111115 inherited : bool = False
112116 read_only : bool = False
113117 allow_override : AllowOverrideType = AllowOverrideType .ANY
114118
115119
116120class RelationshipSchema (BaseModel ):
121+ model_config = ConfigDict (use_enum_values = True )
122+
117123 id : Optional [str ] = None
118124 state : SchemaState = SchemaState .PRESENT
119125 name : str
@@ -133,6 +139,8 @@ class RelationshipSchema(BaseModel):
133139
134140
135141class RelationshipSchemaAPI (RelationshipSchema ):
142+ model_config = ConfigDict (use_enum_values = True )
143+
136144 inherited : bool = False
137145 read_only : bool = False
138146 hierarchical : Optional [str ] = None
@@ -245,6 +253,8 @@ def unique_attributes(self) -> list[AttributeSchemaAPI]:
245253
246254
247255class BaseSchema (BaseModel ):
256+ model_config = ConfigDict (use_enum_values = True )
257+
248258 id : Optional [str ] = None
249259 state : SchemaState = SchemaState .PRESENT
250260 name : str
@@ -275,6 +285,8 @@ class GenericSchemaAPI(BaseSchema, BaseSchemaAttrRelAPI):
275285
276286
277287class BaseNodeSchema (BaseSchema ):
288+ model_config = ConfigDict (use_enum_values = True )
289+
278290 inherit_from : list [str ] = Field (default_factory = list )
279291 branch : Optional [BranchSupportType ] = None
280292 default_filter : Optional [str ] = None
@@ -299,6 +311,8 @@ class ProfileSchemaAPI(BaseSchema, BaseSchemaAttrRelAPI):
299311
300312
301313class NodeExtensionSchema (BaseModel ):
314+ model_config = ConfigDict (use_enum_values = True )
315+
302316 name : Optional [str ] = None
303317 kind : str
304318 description : Optional [str ] = None
@@ -311,6 +325,8 @@ class NodeExtensionSchema(BaseModel):
311325
312326
313327class SchemaRoot (BaseModel ):
328+ model_config = ConfigDict (use_enum_values = True )
329+
314330 version : str
315331 generics : list [GenericSchema ] = Field (default_factory = list )
316332 nodes : list [NodeSchema ] = Field (default_factory = list )
@@ -321,6 +337,8 @@ def to_schema_dict(self) -> dict[str, Any]:
321337
322338
323339class SchemaRootAPI (BaseModel ):
340+ model_config = ConfigDict (use_enum_values = True )
341+
324342 version : str
325343 generics : list [GenericSchemaAPI ] = Field (default_factory = list )
326344 nodes : list [NodeSchemaAPI ] = Field (default_factory = list )
0 commit comments