stac-fastapi.api 5.2.0__tar.gz → 5.2.1__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (24) hide show
  1. {stac_fastapi_api-5.2.0 → stac_fastapi_api-5.2.1}/PKG-INFO +1 -1
  2. {stac_fastapi_api-5.2.0 → stac_fastapi_api-5.2.1}/stac_fastapi/api/app.py +7 -2
  3. {stac_fastapi_api-5.2.0 → stac_fastapi_api-5.2.1}/stac_fastapi/api/errors.py +1 -1
  4. {stac_fastapi_api-5.2.0 → stac_fastapi_api-5.2.1}/stac_fastapi/api/models.py +7 -1
  5. {stac_fastapi_api-5.2.0 → stac_fastapi_api-5.2.1}/stac_fastapi/api/openapi.py +2 -2
  6. {stac_fastapi_api-5.2.0 → stac_fastapi_api-5.2.1}/stac_fastapi/api/version.py +1 -1
  7. {stac_fastapi_api-5.2.0 → stac_fastapi_api-5.2.1}/stac_fastapi.api.egg-info/PKG-INFO +1 -1
  8. {stac_fastapi_api-5.2.0 → stac_fastapi_api-5.2.1}/tests/test_models.py +4 -1
  9. {stac_fastapi_api-5.2.0 → stac_fastapi_api-5.2.1}/README.md +0 -0
  10. {stac_fastapi_api-5.2.0 → stac_fastapi_api-5.2.1}/setup.cfg +0 -0
  11. {stac_fastapi_api-5.2.0 → stac_fastapi_api-5.2.1}/setup.py +0 -0
  12. {stac_fastapi_api-5.2.0 → stac_fastapi_api-5.2.1}/stac_fastapi/api/__init__.py +0 -0
  13. {stac_fastapi_api-5.2.0 → stac_fastapi_api-5.2.1}/stac_fastapi/api/config.py +0 -0
  14. {stac_fastapi_api-5.2.0 → stac_fastapi_api-5.2.1}/stac_fastapi/api/middleware.py +0 -0
  15. {stac_fastapi_api-5.2.0 → stac_fastapi_api-5.2.1}/stac_fastapi/api/routes.py +0 -0
  16. {stac_fastapi_api-5.2.0 → stac_fastapi_api-5.2.1}/stac_fastapi.api.egg-info/SOURCES.txt +0 -0
  17. {stac_fastapi_api-5.2.0 → stac_fastapi_api-5.2.1}/stac_fastapi.api.egg-info/dependency_links.txt +0 -0
  18. {stac_fastapi_api-5.2.0 → stac_fastapi_api-5.2.1}/stac_fastapi.api.egg-info/not-zip-safe +0 -0
  19. {stac_fastapi_api-5.2.0 → stac_fastapi_api-5.2.1}/stac_fastapi.api.egg-info/requires.txt +0 -0
  20. {stac_fastapi_api-5.2.0 → stac_fastapi_api-5.2.1}/stac_fastapi.api.egg-info/top_level.txt +0 -0
  21. {stac_fastapi_api-5.2.0 → stac_fastapi_api-5.2.1}/tests/test_api.py +0 -0
  22. {stac_fastapi_api-5.2.0 → stac_fastapi_api-5.2.1}/tests/test_app.py +0 -0
  23. {stac_fastapi_api-5.2.0 → stac_fastapi_api-5.2.1}/tests/test_app_prefix.py +0 -0
  24. {stac_fastapi_api-5.2.0 → stac_fastapi_api-5.2.1}/tests/test_middleware.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: stac-fastapi.api
3
- Version: 5.2.0
3
+ Version: 5.2.1
4
4
  Summary: An implementation of STAC API based on the FastAPI framework.
5
5
  Home-page: https://github.com/stac-utils/stac-fastapi
6
6
  Author: Arturo Engineering
@@ -12,7 +12,7 @@ from stac_pydantic.api.collections import Collections
12
12
  from stac_pydantic.shared import MimeTypes
13
13
  from stac_pydantic.version import STAC_VERSION
14
14
  from starlette.middleware import Middleware
15
- from starlette.responses import JSONResponse, Response
15
+ from starlette.responses import Response
16
16
 
17
17
  from stac_fastapi.api.errors import DEFAULT_STATUS_CODES, add_exception_handlers
18
18
  from stac_fastapi.api.middleware import CORSMiddleware, ProxyHeaderMiddleware
@@ -21,8 +21,10 @@ from stac_fastapi.api.models import (
21
21
  CollectionUri,
22
22
  EmptyRequest,
23
23
  GeoJSONResponse,
24
+ HealthCheck,
24
25
  ItemCollectionUri,
25
26
  ItemUri,
27
+ JSONResponse,
26
28
  )
27
29
  from stac_fastapi.api.openapi import update_openapi
28
30
  from stac_fastapi.api.routes import (
@@ -396,12 +398,15 @@ class StacApi:
396
398
  mgmt_router.add_api_route(
397
399
  name="Health",
398
400
  path="/_mgmt/health",
399
- response_model=Dict,
401
+ response_model=(
402
+ HealthCheck if self.settings.enable_response_models else None
403
+ ),
400
404
  responses={
401
405
  200: {
402
406
  "content": {
403
407
  MimeTypes.json.value: {},
404
408
  },
409
+ "model": HealthCheck,
405
410
  },
406
411
  },
407
412
  response_class=self.response_class,
@@ -8,8 +8,8 @@ from fastapi.encoders import jsonable_encoder
8
8
  from fastapi.exceptions import RequestValidationError, ResponseValidationError
9
9
  from starlette import status
10
10
  from starlette.requests import Request
11
- from starlette.responses import JSONResponse
12
11
 
12
+ from stac_fastapi.api.models import JSONResponse
13
13
  from stac_fastapi.types.errors import (
14
14
  ConflictError,
15
15
  DatabaseError,
@@ -1,6 +1,6 @@
1
1
  """Api request/response models."""
2
2
 
3
- from typing import List, Optional, Type, Union
3
+ from typing import List, Literal, Optional, Type, Union
4
4
 
5
5
  import attr
6
6
  from fastapi import Path, Query
@@ -135,3 +135,9 @@ class JSONSchemaResponse(JSONResponse):
135
135
  """JSON with custom, vendor content-type."""
136
136
 
137
137
  media_type = "application/schema+json"
138
+
139
+
140
+ class HealthCheck(BaseModel, extra="allow"):
141
+ """health check response model."""
142
+
143
+ status: Literal["UP", "DOWN"]
@@ -2,7 +2,7 @@
2
2
 
3
3
  from fastapi import FastAPI
4
4
  from starlette.requests import Request
5
- from starlette.responses import JSONResponse, Response
5
+ from starlette.responses import Response
6
6
  from starlette.routing import Route, request_response
7
7
 
8
8
 
@@ -22,7 +22,7 @@ def update_openapi(app: FastAPI) -> FastAPI:
22
22
  # Create a patched endpoint function that modifies the content type of the response
23
23
  async def patched_openapi_endpoint(req: Request) -> Response:
24
24
  # Get the response from the old endpoint function
25
- response: JSONResponse = await old_endpoint(req)
25
+ response = await old_endpoint(req)
26
26
  # Update the content type header in place
27
27
  response.headers["content-type"] = "application/vnd.oai.openapi+json;version=3.0"
28
28
  # Return the updated response
@@ -1,3 +1,3 @@
1
1
  """Library version."""
2
2
 
3
- __version__ = "5.2.0"
3
+ __version__ = "5.2.1"
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: stac-fastapi.api
3
- Version: 5.2.0
3
+ Version: 5.2.1
4
4
  Summary: An implementation of STAC API based on the FastAPI framework.
5
5
  Home-page: https://github.com/stac-utils/stac-fastapi
6
6
  Author: Arturo Engineering
@@ -43,7 +43,10 @@ def test_create_get_request_model():
43
43
  model = request_model(bbox="0,0,0,1,1,1")
44
44
  assert model.bbox == (0.0, 0.0, 0.0, 1.0, 1.0, 1.0)
45
45
 
46
- with pytest.raises(AssertionError):
46
+ with pytest.raises(HTTPException):
47
+ request_model(bbox="a,b")
48
+
49
+ with pytest.raises(HTTPException):
47
50
  request_model(bbox="0,0,0,1,1")
48
51
 
49
52
  model = request_model(