From fefd493eebda22ed173cd76932f029cf4f428bfc Mon Sep 17 00:00:00 2001 From: rhysrevans3 Date: Wed, 18 Sep 2024 14:49:49 +0100 Subject: [PATCH] Switching to StacBaseModels for patch operations. --- stac_fastapi/types/stac_fastapi/types/stac.py | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/stac_fastapi/types/stac_fastapi/types/stac.py b/stac_fastapi/types/stac_fastapi/types/stac.py index 559d178d..10021591 100644 --- a/stac_fastapi/types/stac_fastapi/types/stac.py +++ b/stac_fastapi/types/stac_fastapi/types/stac.py @@ -2,8 +2,8 @@ from typing import Any, Dict, List, Literal, Optional, Union -from pydantic import BaseModel, ConfigDict, Field -from stac_pydantic.shared import BBox +from pydantic import ConfigDict, Field +from stac_pydantic.shared import BBox, StacBaseModel from typing_extensions import TypedDict NumType = Union[float, int] @@ -110,7 +110,7 @@ class PartialItem(TypedDict, total=False): collection: Optional[str] -class PatchAddReplaceTest(BaseModel): +class PatchAddReplaceTest(StacBaseModel): """Add, Replace or Test Operation.""" path: str @@ -118,14 +118,14 @@ class PatchAddReplaceTest(BaseModel): value: Any -class PatchRemove(BaseModel): +class PatchRemove(StacBaseModel): """Remove Operation.""" path: str op: Literal["remove"] -class PatchMoveCopy(BaseModel): +class PatchMoveCopy(StacBaseModel): """Move or Copy Operation.""" model_config = ConfigDict(populate_by_name=True) @@ -134,9 +134,5 @@ class PatchMoveCopy(BaseModel): op: Literal["move", "copy"] from_: str = Field(alias="from") - def model_dump(self, by_alias=True, **kwargs) -> Dict[str, Any]: - """Override by_alias default to True""" - return super().model_dump(by_alias=by_alias, **kwargs) - PatchOperation = Union[PatchAddReplaceTest, PatchMoveCopy, PatchRemove]