Skip to content

Commit

Permalink
Change stac_extension URL serialization
Browse files Browse the repository at this point in the history
  • Loading branch information
ividito committed Jan 7, 2025
1 parent d1e785c commit 4d791c0
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions ingest_api/runtime/src/schemas.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,14 @@

import src.validators as validators
from pydantic import (
AnyUrl,
BaseModel,
ConfigDict,
Field,
Json,
PositiveInt,
error_wrappers,
field_serializer,
field_validator,
)
from src.schema_helpers import SpatioTemporalExtent
Expand Down Expand Up @@ -67,6 +69,13 @@ class DashboardCollection(Collection):
assets: Optional[Dict]
extent: SpatioTemporalExtent
model_config = ConfigDict(populate_by_name=True)
# workaround for https://github.com/pydantic/pydantic/discussions/8211 and https://github.com/pydantic/pydantic/issues/7186 (changes expected on pydantic 3 roadmap)
# URL types don't serialize properly to JSON - stac-pydantic uses those types for stac-extensions
stac_extensions: Optional[List[AnyUrl]] = []

@field_serializer("stac_extensions")
def serialize_url(self, urls: List[AnyUrl], _info):
return [str(url) for url in urls]


class Status(str, enum.Enum):
Expand Down

0 comments on commit 4d791c0

Please sign in to comment.