|
1 | | -"""fastapi app creation.""" |
| 1 | +"""Fastapi app creation.""" |
2 | 2 | from typing import Any, Dict, List, Optional, Tuple, Type, Union |
3 | 3 |
|
4 | 4 | import attr |
|
37 | 37 | class StacApi: |
38 | 38 | """StacApi factory. |
39 | 39 |
|
40 | | - Factory for creating a STAC-compliant FastAPI application. After instantation, the application is accessible from |
41 | | - the `StacApi.app` attribute. |
| 40 | + Factory for creating a STAC-compliant FastAPI application. After |
| 41 | + instantation, the application is accessible from the `StacApi.app` attribute. |
42 | 42 |
|
43 | 43 | Attributes: |
44 | 44 | settings: |
45 | | - API settings and configuration, potentially using environment variables. See https://pydantic-docs.helpmanual.io/usage/settings/. |
| 45 | + API settings and configuration, potentially using environment |
| 46 | + variables. See https://pydantic-docs.helpmanual.io/usage/settings/. |
46 | 47 | client: |
47 | | - A subclass of `stac_api.clients.BaseCoreClient`. Defines the application logic which is injected into the API. |
| 48 | + A subclass of `stac_api.clients.BaseCoreClient`. Defines the |
| 49 | + application logic which is injected into the API. |
48 | 50 | extensions: |
49 | | - API extensions to include with the application. This may include official STAC extensions as well as third-party add ons. |
| 51 | + API extensions to include with the application. This may include |
| 52 | + official STAC extensions as well as third-party add ons. |
50 | 53 | exceptions: |
51 | | - Defines a global mapping between exceptions and status codes, allowing configuration of response behavior on certain exceptions (https://fastapi.tiangolo.com/tutorial/handling-errors/#install-custom-exception-handlers). |
| 54 | + Defines a global mapping between exceptions and status codes, |
| 55 | + allowing configuration of response behavior on certain exceptions |
| 56 | + (https://fastapi.tiangolo.com/tutorial/handling-errors/#install-custom-exception-handlers). |
52 | 57 | app: |
53 | 58 | The FastAPI application, defaults to a fresh application. |
54 | | - route_dependencies (list of tuples of route scope dicts (eg `{'path': '/collections', 'method': 'POST'}`) and list of dependencies (e.g. `[Depends(oauth2_scheme)]`)): |
55 | | - Applies specified dependencies to specified routes. This is useful for applying custom auth requirements to routes defined elsewhere in the application. |
| 59 | + route_dependencies: |
| 60 | + List of tuples of route scope dicts (eg `{'path': |
| 61 | + '/collections', 'method': 'POST'}`) and list of dependencies (e.g. |
| 62 | + `[Depends(oauth2_scheme)]`)). Applies specified dependencies to |
| 63 | + specified routes. This is useful |
| 64 | + for applying custom auth requirements to routes defined elsewhere in |
| 65 | + the application. |
56 | 66 | """ |
57 | 67 |
|
58 | 68 | settings: ApiSettings = attr.ib() |
@@ -341,8 +351,11 @@ def add_route_dependencies( |
341 | 351 | """Add custom dependencies to routes. |
342 | 352 |
|
343 | 353 | Args: |
344 | | - scopes: list of scopes. Each scope should be a dict with a `path` and `method` property. |
345 | | - dependencies: list of [FastAPI dependencies](https://fastapi.tiangolo.com/tutorial/dependencies/) to apply to each scope. |
| 354 | + scopes: list of scopes. Each scope should be a dict with a `path` |
| 355 | + and `method` property. |
| 356 | + dependencies: list of [FastAPI |
| 357 | + dependencies](https://fastapi.tiangolo.com/tutorial/dependencies/) |
| 358 | + to apply to each scope. |
346 | 359 |
|
347 | 360 | Returns: |
348 | 361 | None |
|
0 commit comments