From 727d3d447dbf9e9a776f3ec408e6f110289a6ae9 Mon Sep 17 00:00:00 2001 From: Martin Lehmann Date: Mon, 2 Dec 2024 13:22:06 +0100 Subject: [PATCH] fix(backend): Fix Pydantic default values --- capella_model_explorer/backend/templates.py | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/capella_model_explorer/backend/templates.py b/capella_model_explorer/backend/templates.py index ca8fecd..a2873c6 100644 --- a/capella_model_explorer/backend/templates.py +++ b/capella_model_explorer/backend/templates.py @@ -57,8 +57,8 @@ def find_objects(model, obj_type=None, below=None, attr=None, filters=None): class InstanceDetails(BaseModel): - idx: str = Field(..., title="Instance Identifier") - name: str = Field(..., title="Instance Name") + idx: str = Field(title="Instance Identifier") + name: str = Field(title="Instance Name") class TemplateScope(BaseModel): @@ -72,13 +72,13 @@ class TemplateScope(BaseModel): class Template(BaseModel): - idx: str = Field(..., title="Template Identifier") - name: str = Field(..., title="Template Name") - template: Path = Field(..., title="Template File Path") - description: str = Field(..., title="Template Description") + idx: str = Field(title="Template Identifier") + name: str = Field(title="Template Name") + template: Path = Field(title="Template File Path") + description: str = Field(title="Template Description") - scope: TemplateScope | None = Field( - default_factory=dict, title="Template Scope" + scope: TemplateScope = Field( + default_factory=TemplateScope.model_construct, title="Template Scope" ) single: bool | None = Field(None, title="Single Instance Flag") isStable: bool | None = Field(None, title="Stable Template Flag") @@ -121,7 +121,7 @@ def compute_instance_list(self, model: capellambse.MelodyModel): class TemplateCategory(BaseModel): - idx: str = Field(..., title="Category Identifier") + idx: str = Field(title="Category Identifier") templates: list[Template] = Field( default_factory=list, title="Templates in this category" )