Skip to content

Commit

Permalink
Switching to StacBaseModels for patch operations.
Browse files Browse the repository at this point in the history
  • Loading branch information
rhysrevans3 committed Sep 18, 2024
1 parent e325cb2 commit fefd493
Showing 1 changed file with 5 additions and 9 deletions.
14 changes: 5 additions & 9 deletions stac_fastapi/types/stac_fastapi/types/stac.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down Expand Up @@ -110,22 +110,22 @@ class PartialItem(TypedDict, total=False):
collection: Optional[str]


class PatchAddReplaceTest(BaseModel):
class PatchAddReplaceTest(StacBaseModel):
"""Add, Replace or Test Operation."""

path: str
op: Literal["add", "replace", "test"]
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)
Expand All @@ -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]

0 comments on commit fefd493

Please sign in to comment.