Skip to content

Commit a434c25

Browse files
committed
Add json dump of operation value.
1 parent 5319c3b commit a434c25

File tree

1 file changed

+12
-1
lines changed
  • stac_fastapi/types/stac_fastapi/types

1 file changed

+12
-1
lines changed

stac_fastapi/types/stac_fastapi/types/stac.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
"""STAC types."""
22

3+
import json
34
from typing import Any, Dict, List, Literal, Optional, Union
45

5-
from pydantic import ConfigDict, Field
6+
from pydantic import ConfigDict, Field, computed_field
67
from stac_pydantic.shared import BBox, StacBaseModel
78
from typing_extensions import TypedDict
89

@@ -122,6 +123,16 @@ class PatchAddReplaceTest(StacBaseModel):
122123
op: Literal["add", "replace", "test"]
123124
value: Any
124125

126+
@computed_field
127+
@property
128+
def json_value(self) -> str:
129+
"""JSON dump of value field.
130+
131+
Returns:
132+
str: JSON-ised value
133+
"""
134+
return json.dumps(self.value)
135+
125136

126137
class PatchRemove(StacBaseModel):
127138
"""Remove Operation."""

0 commit comments

Comments
 (0)