Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable custom API title and description #207

Merged
merged 8 commits into from
Mar 12, 2024
Merged

Enable custom API title and description #207

merged 8 commits into from
Mar 12, 2024

Conversation

jamesfisher-gis
Copy link
Collaborator

@jamesfisher-gis jamesfisher-gis commented Mar 11, 2024

Related Issue(s):

Description:
Adds API title and description parameters from environment variables STAC_API_TITLE and STAC_API_DESCRIPTION, respectively.

PR Checklist:

  • [ x ] Code is formatted and linted (run pre-commit run --all-files)
  • [ x ] Tests pass (run make test)
  • [ x ] Documentation has been updated to reflect changes, if applicable
  • Changes are added to the changelog

@@ -60,6 +62,8 @@
post_request_model = create_post_request_model(extensions)

api = StacApi(
title=os.getenv("STAC_FASTAPI_TITLE", "stac-fastapi"),
description=os.getenv("STAC_FASTAPI_DESCRIPTION", "stac-fastapi"),
Copy link
Collaborator

@jonhealy1 jonhealy1 Mar 12, 2024

Choose a reason for hiding this comment

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

Should we include the STAC_FASTAPI_VERSION from the pr in stac-fastapi? api_version=os.getenv("STAC_FASTAPI_VERSION", "2.1")) Also, should these have more specific default values? The title here for instance could be stac-fastapi.elasticsearch. The api version would be 2.1. If we could pull the default version in from the version file?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yeah, good call. I will make those changes

Copy link
Collaborator

Choose a reason for hiding this comment

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

We could add the new env vars to the app-opensearch and app-elasticsearch in the docker-compose.yml file too. It might help people realize that they can change those things.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Cool. Added that as well

@jonhealy1 jonhealy1 self-requested a review March 12, 2024 17:47
Copy link
Collaborator

@jonhealy1 jonhealy1 left a comment

Choose a reason for hiding this comment

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

Looks great

@jonhealy1 jonhealy1 merged commit 0c7cfcd into main Mar 12, 2024
4 checks passed
@jonhealy1 jonhealy1 deleted the 206-api-info branch March 12, 2024 17:53
@jamesfisher-gis
Copy link
Collaborator Author

@jonhealy1 Could not really follow the discussion in #639 and #657. Are there any change needed to this?

@jonhealy1
Copy link
Collaborator

I think the ENV variable names/ meanings may have changed, it's still nice to have our own defaults. We should probably include all of these. Once v2.5.0 is released we can update and make sure everything works. What do you think? I may be missing something here.

- `STAC_FASTAPI_VERSION` (string) is the version number of your API instance (this is not the STAC version).
- `STAC FASTAPI_TITLE` (string) should be a self-explanatory title for your API.
- `STAC FASTAPI_DESCRIPTION` (string) should be a good description for your API. It can contain CommonMark.
- `STAC_FASTAPI_LANDING_ID` (string) is a unique identifier for your Landing page.```

@jamesfisher-gis
Copy link
Collaborator Author

Sounds great. Would the defaults be defined when instantiating StacApi like below? Or will they be defined in a separate app config file?

api = StacApi(
    title=os.getenv("STAC_FASTAPI_TITLE", "stac-fastapi-elasticsearch"),
    description=os.getenv("STAC_FASTAPI_DESCRIPTION", "stac-fastapi-elasticsearch"),
    api_version=os.getenv("STAC_FASTAPI_VERSION", "2.1"),
    settings=settings,
    extensions=extensions,
    client=CoreClient(
        database=database_logic, session=session, post_request_model=post_request_model
    ),
    search_get_request_model=create_get_request_model(extensions),
    search_post_request_model=post_request_model,
)

@jonhealy1
Copy link
Collaborator

we could add something like this to the config file and then import them if we want: https://github.com/stac-utils/stac-fastapi/blob/f7d2eb3c30bef338e3bf6cce5c425b531a653a5e/stac_fastapi/types/stac_fastapi/types/config.py#L7-L42

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Enable API title and description to be set with environment vars
2 participants