Skip to content

Commit

Permalink
Merge branch 'master' into change/406-create-item-collection-id
Browse files Browse the repository at this point in the history
  • Loading branch information
duckontheweb authored Jul 29, 2022
2 parents a35f41e + 1faabd3 commit 8529d07
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 6 deletions.
1 change: 1 addition & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
* Transactions Extension update Item endpoint validates that the `{collection_id}` path parameter matches the Item `"collection"` property
from the request body, if present, and falls back to using the path parameter if no `"collection"` property is found in the body
([#425](https://github.com/stac-utils/stac-fastapi/pull/425))
* `/queryables` endpoint now has type `application/schema+json` instead of `application/json` ([#421](https://github.com/stac-utils/stac-fastapi/pull/421))

## [2.3.0]

Expand Down
10 changes: 10 additions & 0 deletions stac_fastapi/api/stac_fastapi/api/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -160,10 +160,20 @@ class GeoJSONResponse(ORJSONResponse):

media_type = "application/geo+json"

class JSONSchemaResponse(ORJSONResponse):
"""JSON with custom, vendor content-type."""

media_type = "application/schema+json"

else:
from starlette.responses import JSONResponse

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

media_type = "application/geo+json"

class JSONSchemaResponse(JSONResponse):
"""JSON with custom, vendor content-type."""

media_type = "application/schema+json"
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,14 @@

import attr
from fastapi import APIRouter, FastAPI
from starlette.responses import JSONResponse, Response

from stac_fastapi.api.models import APIRequest, CollectionUri, EmptyRequest
from starlette.responses import Response

from stac_fastapi.api.models import (
APIRequest,
CollectionUri,
EmptyRequest,
JSONSchemaResponse,
)
from stac_fastapi.api.routes import create_async_endpoint, create_sync_endpoint
from stac_fastapi.types.core import AsyncBaseFiltersClient, BaseFiltersClient
from stac_fastapi.types.extension import ApiExtension
Expand Down Expand Up @@ -71,7 +76,7 @@ class FilterExtension(ApiExtension):
]
)
router: APIRouter = attr.ib(factory=APIRouter)
response_class: Type[Response] = attr.ib(default=JSONResponse)
response_class: Type[Response] = attr.ib(default=JSONSchemaResponse)

def _create_endpoint(
self,
Expand Down
9 changes: 9 additions & 0 deletions stac_fastapi/pgstac/tests/api/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,15 @@ async def test_get_search_content_type(app_client):
assert resp.headers["content-type"] == "application/geo+json"


async def test_get_queryables_content_type(app_client, load_test_collection):
resp = await app_client.get("queryables")
assert resp.headers["content-type"] == "application/schema+json"

coll = load_test_collection
resp = await app_client.get(f"collections/{coll.id}/queryables")
assert resp.headers["content-type"] == "application/schema+json"


async def test_api_headers(app_client):
resp = await app_client.get("/api")
assert (
Expand Down
2 changes: 0 additions & 2 deletions stac_fastapi/types/stac_fastapi/types/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -353,8 +353,6 @@ def landing_page(self, **kwargs) -> stac_types.LandingPage:
extension_schemas = [
schema.schema_href for schema in self.extensions if schema.schema_href
]
request: Request = kwargs["request"]
base_url = str(request.base_url)
landing_page = self._landing_page(
base_url=base_url,
conformance_classes=self.conformance_classes(),
Expand Down

0 comments on commit 8529d07

Please sign in to comment.