Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@
- avoid future deprecation for pydantic.Field and use `json_schema_extra` instead of `openapi_examples`
- use `orjson` based JSONResponse when available

### Added

- add response model for `/_mgmt/health` endpoint

## [5.2.0] - 2025-04-18

### Fixed
Expand Down
6 changes: 5 additions & 1 deletion stac_fastapi/api/stac_fastapi/api/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
CollectionUri,
EmptyRequest,
GeoJSONResponse,
HealthCheck,
ItemCollectionUri,
ItemUri,
JSONResponse,
Expand Down Expand Up @@ -397,12 +398,15 @@ async def ping():
mgmt_router.add_api_route(
name="Health",
path="/_mgmt/health",
response_model=Dict,
response_model=(
HealthCheck if self.settings.enable_response_models else None
),
responses={
200: {
"content": {
MimeTypes.json.value: {},
},
"model": HealthCheck,
},
},
response_class=self.response_class,
Expand Down
8 changes: 7 additions & 1 deletion stac_fastapi/api/stac_fastapi/api/models.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
"""Api request/response models."""

from typing import List, Optional, Type, Union
from typing import List, Literal, Optional, Type, Union

import attr
from fastapi import Path, Query
Expand Down Expand Up @@ -135,3 +135,9 @@ class JSONSchemaResponse(JSONResponse):
"""JSON with custom, vendor content-type."""

media_type = "application/schema+json"


class HealthCheck(BaseModel, extra="allow"):
"""health check response model."""

status: Literal["UP", "DOWN"]