Skip to content

Commit 1faabd3

Browse files
Fix media type for queryables endpoints (#421)
* Fix media type for queryables endpoints * Add CHANGELOG entry for #421 Co-authored-by: Jeff Albrecht <[email protected]>
1 parent 4f55ba4 commit 1faabd3

File tree

4 files changed

+29
-4
lines changed

4 files changed

+29
-4
lines changed

CHANGES.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
* Fixed stray `/` before the `#` in several extension conformance class strings ([383](https://github.com/stac-utils/stac-fastapi/pull/383))
3333
* SQLAlchemy backend bulk item insert now works ([#356](https://github.com/stac-utils/stac-fastapi/issues/356))
3434
* PGStac Backend has stricter implementation of Fields Extension syntax ([#397](https://github.com/stac-utils/stac-fastapi/pull/397))
35+
* `/queryables` endpoint now has type `application/schema+json` instead of `application/json` ([#421](https://github.com/stac-utils/stac-fastapi/pull/421))
3536

3637
## [2.3.0]
3738

stac_fastapi/api/stac_fastapi/api/models.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,10 +160,20 @@ class GeoJSONResponse(ORJSONResponse):
160160

161161
media_type = "application/geo+json"
162162

163+
class JSONSchemaResponse(ORJSONResponse):
164+
"""JSON with custom, vendor content-type."""
165+
166+
media_type = "application/schema+json"
167+
163168
else:
164169
from starlette.responses import JSONResponse
165170

166171
class GeoJSONResponse(JSONResponse):
167172
"""JSON with custom, vendor content-type."""
168173

169174
media_type = "application/geo+json"
175+
176+
class JSONSchemaResponse(JSONResponse):
177+
"""JSON with custom, vendor content-type."""
178+
179+
media_type = "application/schema+json"

stac_fastapi/extensions/stac_fastapi/extensions/core/filter/filter.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,14 @@
55

66
import attr
77
from fastapi import APIRouter, FastAPI
8-
from starlette.responses import JSONResponse, Response
9-
10-
from stac_fastapi.api.models import APIRequest, CollectionUri, EmptyRequest
8+
from starlette.responses import Response
9+
10+
from stac_fastapi.api.models import (
11+
APIRequest,
12+
CollectionUri,
13+
EmptyRequest,
14+
JSONSchemaResponse,
15+
)
1116
from stac_fastapi.api.routes import create_async_endpoint, create_sync_endpoint
1217
from stac_fastapi.types.core import AsyncBaseFiltersClient, BaseFiltersClient
1318
from stac_fastapi.types.extension import ApiExtension
@@ -71,7 +76,7 @@ class FilterExtension(ApiExtension):
7176
]
7277
)
7378
router: APIRouter = attr.ib(factory=APIRouter)
74-
response_class: Type[Response] = attr.ib(default=JSONResponse)
79+
response_class: Type[Response] = attr.ib(default=JSONSchemaResponse)
7580

7681
def _create_endpoint(
7782
self,

stac_fastapi/pgstac/tests/api/test_api.py

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

3434

35+
async def test_get_queryables_content_type(app_client, load_test_collection):
36+
resp = await app_client.get("queryables")
37+
assert resp.headers["content-type"] == "application/schema+json"
38+
39+
coll = load_test_collection
40+
resp = await app_client.get(f"collections/{coll.id}/queryables")
41+
assert resp.headers["content-type"] == "application/schema+json"
42+
43+
3544
async def test_api_headers(app_client):
3645
resp = await app_client.get("/api")
3746
assert (

0 commit comments

Comments
 (0)