Skip to content

Commit

Permalink
🐛 Allow SoftwarePackageCategory to be correctly serialised and deseri…
Browse files Browse the repository at this point in the history
…alised as a string
  • Loading branch information
jemrobinson committed Jan 25, 2024
1 parent e0ed8ee commit 4e5ec60
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion data_safe_haven/config/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
from azure.keyvault.keys import KeyVaultKey
from pydantic import (
BaseModel,
ConfigDict,
Field,
FieldSerializationInfo,
ValidationError,
Expand Down Expand Up @@ -149,6 +150,7 @@ def update(


class ConfigSectionSRE(BaseModel, validate_assignment=True):
model_config = ConfigDict(use_enum_values=True)
databases: list[DatabaseSystem] = Field(..., default_factory=list[DatabaseSystem])
data_provider_ip_addresses: list[IpAddress] = Field(
..., default_factory=list[IpAddress]
Expand Down Expand Up @@ -176,9 +178,11 @@ def all_databases_must_be_unique(
@field_serializer("software_packages")
def software_packages_serializer(
self,
packages: SoftwarePackageCategory,
packages: SoftwarePackageCategory | str,
info: FieldSerializationInfo, # noqa: ARG002
) -> str:
if isinstance(packages, str):
packages = SoftwarePackageCategory(packages)
return packages.value

def update(
Expand Down

0 comments on commit 4e5ec60

Please sign in to comment.