Skip to content

Commit 61d9119

Browse files
committed
fix: get_item response is geojson
1 parent 7cf3db7 commit 61d9119

File tree

3 files changed

+22
-4
lines changed

3 files changed

+22
-4
lines changed

stac_fastapi/api/stac_fastapi/api/app.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -158,12 +158,12 @@ def register_get_item(self):
158158
name="Get Item",
159159
path="/collections/{collection_id}/items/{item_id}",
160160
response_model=Item if self.settings.enable_response_models else None,
161-
response_class=self.response_class,
161+
response_class=GeoJSONResponse,
162162
response_model_exclude_unset=True,
163163
response_model_exclude_none=True,
164164
methods=["GET"],
165165
endpoint=create_async_endpoint(
166-
self.client.get_item, ItemUri, self.response_class
166+
self.client.get_item, ItemUri, GeoJSONResponse
167167
),
168168
)
169169

stac_fastapi/pgstac/tests/api/test_api.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,15 @@ async def test_get_features_content_type(app_client, load_test_collection):
5151
assert resp.headers["content-type"] == "application/geo+json"
5252

5353

54+
async def test_get_feature_content_type(
55+
app_client, load_test_collection, load_test_item
56+
):
57+
resp = await app_client.get(
58+
f"collections/{load_test_collection.id}/items/{load_test_item.id}"
59+
)
60+
assert resp.headers["content-type"] == "application/geo+json"
61+
62+
5463
async def test_api_headers(app_client):
5564
resp = await app_client.get("/api")
5665
assert (

stac_fastapi/sqlalchemy/tests/api/test_api.py

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -445,9 +445,18 @@ def test_app_search_response_duplicate_forwarded_headers(
445445
assert link["href"].startswith("https://testserver:1234/")
446446

447447

448-
async def test_get_features_content_type(app_client, load_test_data):
448+
def test_get_features_content_type(app_client, load_test_data):
449449
item = load_test_data("test_item.json")
450-
resp = await app_client.get(f"collections/{item['collection']}/items")
450+
resp = app_client.get(f"collections/{item['collection']}/items")
451+
assert resp.headers["content-type"] == "application/geo+json"
452+
453+
454+
def test_get_feature_content_type(app_client, load_test_data, postgres_transactions):
455+
item = load_test_data("test_item.json")
456+
postgres_transactions.create_item(
457+
item["collection"], item, request=MockStarletteRequest
458+
)
459+
resp = app_client.get(f"collections/{item['collection']}/items/{item['id']}")
451460
assert resp.headers["content-type"] == "application/geo+json"
452461

453462

0 commit comments

Comments
 (0)