Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Introduce Parameters type (using RootModel), equivalent to edr-pydantic Parameters #21

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/covjson_pydantic/coverage.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
from .ndarray import NdArrayInt
from .ndarray import NdArrayStr
from .ndarray import TiledNdArrayFloat
from .parameter import Parameter
from .parameter import Parameters
from .parameter import ParameterGroup
from .reference_system import ReferenceSystemConnectionObject

Expand All @@ -32,7 +32,7 @@ class Coverage(CovJsonBaseModel, extra="allow"):
id: Optional[str] = None
type: Literal["Coverage"] = "Coverage"
domain: Domain
parameters: Optional[Dict[str, Parameter]] = None
parameters: Optional[Parameters] = None
parameterGroups: Optional[List[ParameterGroup]] = None # noqa: N815
ranges: Dict[str, Union[NdArrayTypes, TiledNdArrayFloat, AnyUrl]]

Expand All @@ -41,6 +41,6 @@ class CoverageCollection(CovJsonBaseModel, extra="allow"):
type: Literal["CoverageCollection"] = "CoverageCollection"
domainType: Optional[DomainType] = None # noqa: N815
coverages: List[Coverage]
parameters: Optional[Dict[str, Parameter]] = None
parameters: Optional[Parameters] = None
parameterGroups: Optional[List[ParameterGroup]] = None # noqa: N815
referencing: Optional[List[ReferenceSystemConnectionObject]] = None
4 changes: 4 additions & 0 deletions src/covjson_pydantic/parameter.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
from typing import Union

from pydantic import model_validator
from pydantic import RootModel

from .base_models import CovJsonBaseModel
from .i18n import i18n
Expand Down Expand Up @@ -32,6 +33,9 @@ def must_not_have_unit_if_observed_property_has_categories(self):
return self


Parameters = RootModel[Dict[str, Parameter]]


class ParameterGroup(CovJsonBaseModel, extra="allow"):
type: Literal["ParameterGroup"] = "ParameterGroup"
id: Optional[str] = None
Expand Down
Loading