Skip to content

Commit ad7312f

Browse files
add ouput model for health check (#837)
1 parent c4e6ead commit ad7312f

File tree

3 files changed

+16
-2
lines changed

3 files changed

+16
-2
lines changed

CHANGES.md

+4
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@
77
- avoid future deprecation for pydantic.Field and use `json_schema_extra` instead of `openapi_examples`
88
- use `orjson` based JSONResponse when available
99

10+
### Added
11+
12+
- add response model for `/_mgmt/health` endpoint
13+
1014
## [5.2.0] - 2025-04-18
1115

1216
### Fixed

stac_fastapi/api/stac_fastapi/api/app.py

+5-1
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
CollectionUri,
2222
EmptyRequest,
2323
GeoJSONResponse,
24+
HealthCheck,
2425
ItemCollectionUri,
2526
ItemUri,
2627
JSONResponse,
@@ -397,12 +398,15 @@ async def ping():
397398
mgmt_router.add_api_route(
398399
name="Health",
399400
path="/_mgmt/health",
400-
response_model=Dict,
401+
response_model=(
402+
HealthCheck if self.settings.enable_response_models else None
403+
),
401404
responses={
402405
200: {
403406
"content": {
404407
MimeTypes.json.value: {},
405408
},
409+
"model": HealthCheck,
406410
},
407411
},
408412
response_class=self.response_class,

stac_fastapi/api/stac_fastapi/api/models.py

+7-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
"""Api request/response models."""
22

3-
from typing import List, Optional, Type, Union
3+
from typing import List, Literal, Optional, Type, Union
44

55
import attr
66
from fastapi import Path, Query
@@ -135,3 +135,9 @@ class JSONSchemaResponse(JSONResponse):
135135
"""JSON with custom, vendor content-type."""
136136

137137
media_type = "application/schema+json"
138+
139+
140+
class HealthCheck(BaseModel, extra="allow"):
141+
"""health check response model."""
142+
143+
status: Literal["UP", "DOWN"]

0 commit comments

Comments
 (0)