Skip to content

Commit 5a4d5b9

Browse files
Feature/update stac pydantic3.1.0 (#697)
* update stac-pydantic dependendy * replace stac-pydantic todos * fix benchmark * replace deprecated .dict() * fix datetime interval for GET Search * update changelog
1 parent f815c23 commit 5a4d5b9

File tree

7 files changed

+18
-15
lines changed

7 files changed

+18
-15
lines changed

CHANGES.md

+4-2
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,10 @@
44

55
### Changed
66

7-
* switch from `fastapi` to `fastapi-slim` to avoid installing unwanted dependencies. ([#687](https://github.com/stac-utils/stac-fastapi/pull/687))
8-
* replace Enum with `Literal` for `FilterLang`. ([#686](https://github.com/stac-utils/stac-fastapi/pull/686))
7+
* Switch from `fastapi` to `fastapi-slim` to avoid installing unwanted dependencies. ([#687](https://github.com/stac-utils/stac-fastapi/pull/687))
8+
* Replace Enum with `Literal` for `FilterLang`. ([#686](https://github.com/stac-utils/stac-fastapi/pull/686))
9+
* Update stac-pydantic requirement to `~3.1` ([#697](https://github.com/stac-utils/stac-fastapi/pull/697))
10+
* Fix datetime interval for GET Search when passing a single value ([#697](https://github.com/stac-utils/stac-fastapi/pull/697))
911

1012
### Removed
1113

stac_fastapi/api/stac_fastapi/api/app.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -172,14 +172,14 @@ def register_conformance_classes(self):
172172
name="Conformance Classes",
173173
path="/conformance",
174174
response_model=(
175-
api.ConformanceClasses if self.settings.enable_response_models else None
175+
api.Conformance if self.settings.enable_response_models else None
176176
),
177177
responses={
178178
200: {
179179
"content": {
180180
MimeTypes.json.value: {},
181181
},
182-
"model": api.ConformanceClasses,
182+
"model": api.Conformance,
183183
},
184184
},
185185
response_class=self.response_class,

stac_fastapi/api/tests/benchmarks.py

+3-2
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
collections = [
1818
stac_types.Collection(
1919
id=f"test_collection_{n}",
20+
type="Collection",
2021
title="Test Collection",
2122
description="A test collection",
2223
keywords=["test"],
@@ -25,7 +26,7 @@
2526
"spatial": {"bbox": [[-180, -90, 180, 90]]},
2627
"temporal": {"interval": [["2000-01-01T00:00:00Z", None]]},
2728
},
28-
links=collection_links.dict(exclude_none=True),
29+
links=collection_links.model_dump(exclude_none=True),
2930
)
3031
for n in range(0, 10)
3132
]
@@ -37,7 +38,7 @@
3738
geometry={"type": "Point", "coordinates": [0, 0]},
3839
bbox=[-180, -90, 180, 90],
3940
properties={"datetime": "2000-01-01T00:00:00Z"},
40-
links=item_links.dict(exclude_none=True),
41+
links=item_links.model_dump(exclude_none=True),
4142
assets={},
4243
)
4344
for n in range(0, 1000)

stac_fastapi/api/tests/conftest.py

+1
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
@pytest.fixture
1717
def _collection():
1818
return Collection(
19+
type="Collection",
1920
id="test_collection",
2021
title="Test Collection",
2122
description="A test collection",

stac_fastapi/types/setup.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
"fastapi-slim",
1010
"attrs>=23.2.0",
1111
"pydantic-settings>=2",
12-
"stac_pydantic>=3",
12+
"stac_pydantic~=3.1",
1313
"iso8601>=1.0.2,<2.2.0",
1414
]
1515

stac_fastapi/types/stac_fastapi/types/core.py

+4-8
Original file line numberDiff line numberDiff line change
@@ -380,10 +380,8 @@ def landing_page(self, **kwargs) -> stac.LandingPage:
380380
if self.extension_is_enabled("FilterExtension"):
381381
landing_page["links"].append(
382382
{
383-
# TODO: replace this with Relations.queryables.value,
384-
"rel": "http://www.opengis.net/def/rel/ogc/1.0/queryables",
385-
# TODO: replace this with MimeTypes.jsonschema,
386-
"type": "application/schema+json",
383+
"rel": Relations.queryables.value,
384+
"type": MimeTypes.jsonschema.value,
387385
"title": "Queryables",
388386
"href": urljoin(base_url, "queryables"),
389387
"method": "GET",
@@ -586,10 +584,8 @@ async def landing_page(self, **kwargs) -> stac.LandingPage:
586584
if self.extension_is_enabled("FilterExtension"):
587585
landing_page["links"].append(
588586
{
589-
# TODO: replace this with Relations.queryables.value,
590-
"rel": "http://www.opengis.net/def/rel/ogc/1.0/queryables",
591-
# TODO: replace this with MimeTypes.jsonschema,
592-
"type": "application/schema+json",
587+
"rel": Relations.queryables.value,
588+
"type": MimeTypes.jsonschema.value,
593589
"title": "Queryables",
594590
"href": urljoin(base_url, "queryables"),
595591
"method": "GET",

stac_fastapi/types/stac_fastapi/types/rfc3339.py

+3
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,9 @@ def str_to_interval(interval: Optional[str]) -> Optional[DateTimeType]:
122122
detail="Interval string contains more than one forward slash.",
123123
)
124124

125+
if len(values) == 1:
126+
values = [values[0], values[0]]
127+
125128
try:
126129
start = parse_single_date(values[0]) if values[0] not in ["..", ""] else None
127130
end = (

0 commit comments

Comments
 (0)