Skip to content

Commit 4202c3b

Browse files
committed
add passthrough for collections when fields is enabled
1 parent 7b3f48d commit 4202c3b

File tree

2 files changed

+9
-5
lines changed

2 files changed

+9
-5
lines changed

stac_fastapi/pgstac/core.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ async def all_collections( # noqa: C901
150150
prev=prev_link,
151151
).get_links()
152152

153-
return Collections(
153+
collections = Collections(
154154
collections=linked_collections or [],
155155
links=links,
156156
numberMatched=collections_result.get(
@@ -161,6 +161,14 @@ async def all_collections( # noqa: C901
161161
),
162162
)
163163

164+
# If we have the `fields` extension enabled
165+
# we need to avoid Pydantic validation because the
166+
# Items might not be a valid STAC Item objects
167+
if fields:
168+
return JSONResponse(collections) # type: ignore
169+
170+
return collections
171+
164172
async def get_collection(
165173
self,
166174
collection_id: str,

tests/api/test_api.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -274,10 +274,6 @@ async def test_app_query_extension_gte(load_test_data, app_client, load_test_col
274274
async def test_app_collection_fields_extension(
275275
load_test_data, app_client, load_test_collection, app
276276
):
277-
if app.state.settings.enable_response_models:
278-
# https://github.com/stac-utils/stac-fastapi-pgstac/issues/328
279-
pytest.skip("Skipping test when model_validation is enabled, see #328")
280-
281277
fields = ["title"]
282278
resp = await app_client.get("/collections", params={"fields": ",".join(fields)})
283279

0 commit comments

Comments
 (0)