Skip to content

Commit

Permalink
Merge branch 'main' of https://github.com/stac-utils/stac-pydantic in…
Browse files Browse the repository at this point in the history
…to patch/allow-null-datetime
  • Loading branch information
vincentsarago committed May 21, 2024
2 parents 41d8ab0 + b18cc74 commit 6e4c929
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 9 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@
- Fix STAC API Query Extension operator names from ne->neq, le->lte, and ge->gte (#120, @philvarner)
- Better **datetime** parsing/validation by using Pydantic native types and remove `ciso8601` requirement (#131, @eseglem)
- move datetime validation in `StacCommonMetadata` model definition (#131, @eseglem)
- use `StacBaseModel` as base model for `Asset` model (#148, @vincentsarago)
- add `license` in `StacCommonMetadata` model (#147, @vincentsarago)
- make `limit` optional in `api.Search` model (#150, @vincentsarago)

3.0.0 (2024-01-25)
------------------
Expand Down
2 changes: 1 addition & 1 deletion stac_pydantic/api/search.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ class Search(BaseModel):
bbox: Optional[BBox] = None
intersects: Optional[Intersection] = None
datetime: Optional[str] = None
limit: int = 10
limit: Optional[int] = 10

# Private properties to store the parsed datetime values. Not part of the model schema.
_start_date: Optional[dt] = None
Expand Down
11 changes: 3 additions & 8 deletions stac_pydantic/shared.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,8 @@ class StacCommonMetadata(StacBaseModel):
# Date and Time Range
start_datetime: Optional[UtcDatetime] = None
end_datetime: Optional[UtcDatetime] = None
# Licensing
license: Optional[str] = None
# Provider
providers: Optional[List[Provider]] = None
# Instrument
Expand Down Expand Up @@ -171,7 +173,7 @@ def validate_start_end(self) -> Self:
return self


class Asset(StacCommonMetadata):
class Asset(StacBaseModel):
"""
https://github.com/radiantearth/stac-spec/blob/v1.0.0/item-spec/item-spec.md#asset-object
"""
Expand All @@ -185,10 +187,3 @@ class Asset(StacCommonMetadata):
model_config = ConfigDict(
populate_by_name=True, use_enum_values=True, extra="allow"
)

@model_validator(mode="after")
def validate_datetime_or_start_end(self) -> Self:
# Overriding the parent method to avoid requiring datetime or start/end_datetime
# Additional fields MAY be added on the Asset object, but are not required.
# https://github.com/radiantearth/stac-spec/blob/v1.0.0/item-spec/item-spec.md#additional-fields-for-assets
return self

0 comments on commit 6e4c929

Please sign in to comment.