Skip to content

Commit c861656

Browse files
committed
Set use_enum_values on all schema models
1 parent f39053f commit c861656

File tree

1 file changed

+19
-1
lines changed

1 file changed

+19
-1
lines changed

infrahub_sdk/schema/main.py

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
from enum import Enum
55
from typing import TYPE_CHECKING, Any, Optional, Union
66

7-
from pydantic import BaseModel, Field
7+
from pydantic import BaseModel, Field, ConfigDict
88

99
if TYPE_CHECKING:
1010
from ..node import InfrahubNode, InfrahubNodeSync
@@ -89,6 +89,8 @@ class RelationshipDeleteBehavior(str, Enum):
8989

9090

9191
class 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

110112
class 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

116120
class 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

135141
class 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

247255
class 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

277287
class 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

301313
class 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

313327
class 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

323339
class 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

Comments
 (0)