stac-utils / stac-utils/stac-fastapi
Pass StacAPI reference to ApiExtension.register instead of FastAPI reference
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 324
- Forks
- 126
- Avg merge
- 1d 22h
- Merged PRs (30d)
- 10
Description
When registering extensions app.py passes a reference to the FastAPI object with self.app and as a result any extensions have access to the FastAPI object during registration.
The FastAPI type does not provide access to useful functionality in the StacApi type that may be required by an extension, such as add_route_dependencies. Authentication / authorisation checks could form part of a useful extension and would be cleaner and simpler to implement with access to the add_route_dependencies function.
Perhaps the StacApi type itself should not be passed to ApiExtension.register as this would give the extension access to the extensions list and other properties outside the extension's concern. A stripped-down type, providing access only to the app property, add_route_dependencies, and other safe properties could be used. For example:
# define type
class StacApiExtension(BaseModel):
app: FastAPI
add_route_dependencies: Callable[[List[Scope], List[Depends]], None]
[...]
# register extensions in app.py
for ext in self.extensions:
ext.register(StacApiExtension(**self))
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in stac_fastapi/api/stac_fastapi/api/app.py at the extension registration around line 386, then inspect ApiExtension.register and the StacApi and FastAPI types. Decide which API surface an extension should receive, including add_route_dependencies, while keeping unrelated StacApi properties out of scope. Done means extensions receive the intended reference during registration and the affected behavior is covered by the repository's tests.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- fastapi, python
- Domain
- api, backend-api-design
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100