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
18 changes: 14 additions & 4 deletions stac_fastapi/api/stac_fastapi/api/app.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
"""Fastapi app creation."""
import os

from typing import Any, Dict, List, Optional, Tuple, Type, Union

import attr
Expand Down Expand Up @@ -84,11 +84,21 @@ class StacApi:
converter=update_openapi,
)
router: APIRouter = attr.ib(default=attr.Factory(APIRouter))
title: str = attr.ib(default=os.getenv("STAC_FASTAPI_TITLE", "stac-fastapi"))
api_version: str = attr.ib(default=os.getenv("STAC_FASTAPI_VERSION", "0.1"))
title: str = attr.ib(
default=attr.Factory(
lambda self: self.settings.stac_fastapi_title, takes_self=True
)
)
api_version: str = attr.ib(
default=attr.Factory(
lambda self: self.settings.stac_fastapi_version, takes_self=True
)
)
stac_version: str = attr.ib(default=STAC_VERSION)
description: str = attr.ib(
default=os.getenv("STAC_FASTAPI_DESCRIPTION", "stac-fastapi")
default=attr.Factory(
lambda self: self.settings.stac_fastapi_description, takes_self=True
)
)
search_get_request_model: Type[BaseSearchGetRequest] = attr.ib(
default=BaseSearchGetRequest
Expand Down
5 changes: 5 additions & 0 deletions stac_fastapi/types/stac_fastapi/types/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,11 @@ class ApiSettings(BaseSettings):
# `pydantic.BaseSettings` instead
default_includes: Optional[Set[str]] = None

stac_fastapi_title: str = "stac-fastapi"
stac_fastapi_description: str = "stac-fastapi"
stac_fastapi_version: str = "0.1"
stac_fastapi_landing_id: str = "stac-fastapi"
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

as discussed in #639 I think it makes more sense for this variable to be named landing_id

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've also reverted to stac-fastapi default as it was before

landing_page_id: str = attr.ib(default="stac-fastapi")

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me. The version is the version number of the User's stac_fastapi, not this version ie. soon to be 2.5.0


app_host: str = "0.0.0.0"
app_port: int = 8000
reload: bool = True
Expand Down
12 changes: 6 additions & 6 deletions stac_fastapi/types/stac_fastapi/types/core.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
"""Base clients."""

import abc
import os
from typing import Any, Dict, List, Optional, Union
from urllib.parse import urljoin

Expand All @@ -13,6 +12,7 @@
from starlette.responses import Response

from stac_fastapi.types import stac as stac_types
from stac_fastapi.types.config import ApiSettings
from stac_fastapi.types.conformance import BASE_CONFORMANCE_CLASSES
from stac_fastapi.types.extension import ApiExtension
from stac_fastapi.types.requests import get_base_url
Expand All @@ -23,6 +23,8 @@
NumType = Union[float, int]
StacType = Dict[str, Any]

api_settings = ApiSettings()


@attr.s # type:ignore
class BaseTransactionsClient(abc.ABC):
Expand Down Expand Up @@ -256,11 +258,9 @@ class LandingPageMixin(abc.ABC):
"""Create a STAC landing page (GET /)."""

stac_version: str = attr.ib(default=STAC_VERSION)
landing_page_id: str = attr.ib(default=os.getenv("STAC_FASTAPI_ID", "0.1"))
title: str = attr.ib(default=os.getenv("STAC_FASTAPI_TITLE", "stac-fastapi"))
description: str = attr.ib(
default=os.getenv("STAC_FASTAPI_DESCRIPTION", "stac-fastapi")
)
landing_page_id: str = attr.ib(default=api_settings.stac_fastapi_landing_id)
title: str = attr.ib(default=api_settings.stac_fastapi_title)
description: str = attr.ib(default=api_settings.stac_fastapi_description)

def _landing_page(
self,
Expand Down