stac-fastapi.api 6.1.2__tar.gz → 6.1.3__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {stac_fastapi_api-6.1.2 → stac_fastapi_api-6.1.3}/PKG-INFO +1 -1
- {stac_fastapi_api-6.1.2 → stac_fastapi_api-6.1.3}/stac_fastapi/api/errors.py +3 -1
- {stac_fastapi_api-6.1.2 → stac_fastapi_api-6.1.3}/stac_fastapi/api/middleware.py +1 -1
- {stac_fastapi_api-6.1.2 → stac_fastapi_api-6.1.3}/stac_fastapi/api/models.py +8 -9
- {stac_fastapi_api-6.1.2 → stac_fastapi_api-6.1.3}/stac_fastapi/api/openapi.py +4 -1
- {stac_fastapi_api-6.1.2 → stac_fastapi_api-6.1.3}/stac_fastapi/api/routes.py +15 -6
- {stac_fastapi_api-6.1.2 → stac_fastapi_api-6.1.3}/stac_fastapi/api/version.py +1 -1
- {stac_fastapi_api-6.1.2 → stac_fastapi_api-6.1.3}/.gitignore +0 -0
- {stac_fastapi_api-6.1.2 → stac_fastapi_api-6.1.3}/README.md +0 -0
- {stac_fastapi_api-6.1.2 → stac_fastapi_api-6.1.3}/pyproject.toml +0 -0
- {stac_fastapi_api-6.1.2 → stac_fastapi_api-6.1.3}/stac_fastapi/api/__init__.py +0 -0
- {stac_fastapi_api-6.1.2 → stac_fastapi_api-6.1.3}/stac_fastapi/api/app.py +0 -0
- {stac_fastapi_api-6.1.2 → stac_fastapi_api-6.1.3}/stac_fastapi/api/config.py +0 -0
- {stac_fastapi_api-6.1.2 → stac_fastapi_api-6.1.3}/stac_fastapi/api/py.typed +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: stac-fastapi-api
|
|
3
|
-
Version: 6.1.
|
|
3
|
+
Version: 6.1.3
|
|
4
4
|
Summary: An implementation of STAC API based on the FastAPI framework.
|
|
5
5
|
Project-URL: Homepage, https://github.com/stac-utils/stac-fastapi
|
|
6
6
|
Author-email: ArturoAI <engineering@arturo.ai>
|
|
@@ -93,6 +93,8 @@ def add_exception_handlers(
|
|
|
93
93
|
status_code=status.HTTP_400_BAD_REQUEST,
|
|
94
94
|
)
|
|
95
95
|
|
|
96
|
+
# TODO: Argument 2 to "add_exception_handler" of "Starlette" has incompatible type
|
|
96
97
|
app.add_exception_handler(
|
|
97
|
-
RequestValidationError,
|
|
98
|
+
RequestValidationError,
|
|
99
|
+
request_validation_exception_handler, # type: ignore
|
|
98
100
|
)
|
|
@@ -86,7 +86,7 @@ class ProxyHeaderMiddleware:
|
|
|
86
86
|
proto = scope.get("scheme", "http")
|
|
87
87
|
header_host = self._get_header_value_by_name(scope, "host")
|
|
88
88
|
if header_host is None:
|
|
89
|
-
domain, port = scope
|
|
89
|
+
domain, port = scope["server"]
|
|
90
90
|
else:
|
|
91
91
|
header_host_parts = header_host.split(":")
|
|
92
92
|
if len(header_host_parts) == 2:
|
|
@@ -24,7 +24,7 @@ try:
|
|
|
24
24
|
import orjson # noqa
|
|
25
25
|
from fastapi.responses import ORJSONResponse as JSONResponse
|
|
26
26
|
except ImportError: # pragma: nocover
|
|
27
|
-
from starlette.responses import JSONResponse
|
|
27
|
+
from starlette.responses import JSONResponse # type: ignore
|
|
28
28
|
|
|
29
29
|
|
|
30
30
|
def create_request_model(
|
|
@@ -32,11 +32,11 @@ def create_request_model(
|
|
|
32
32
|
base_model: Union[Type[BaseModel], Type[APIRequest]] = BaseSearchGetRequest,
|
|
33
33
|
extensions: Optional[List[ApiExtension]] = None,
|
|
34
34
|
mixins: Optional[Union[List[Type[BaseModel]], List[Type[APIRequest]]]] = None,
|
|
35
|
-
request_type:
|
|
35
|
+
request_type: str = "GET",
|
|
36
36
|
) -> Union[Type[BaseModel], Type[APIRequest]]:
|
|
37
37
|
"""Create a pydantic model for validating request bodies."""
|
|
38
38
|
fields = {}
|
|
39
|
-
extension_models = []
|
|
39
|
+
extension_models: List[Union[Type[BaseModel], Type[APIRequest]]] = []
|
|
40
40
|
|
|
41
41
|
# Check extensions for additional parameters to search
|
|
42
42
|
for extension in extensions or []:
|
|
@@ -54,7 +54,7 @@ def create_request_model(
|
|
|
54
54
|
# Handle POST requests
|
|
55
55
|
elif all([issubclass(m, BaseModel) for m in models]):
|
|
56
56
|
for model in models:
|
|
57
|
-
for k, field_info in model.model_fields.items():
|
|
57
|
+
for k, field_info in model.model_fields.items(): # type: ignore
|
|
58
58
|
fields[k] = (field_info.annotation, field_info)
|
|
59
59
|
|
|
60
60
|
return create_model(model_name, **fields, __base__=base_model) # type: ignore
|
|
@@ -64,11 +64,10 @@ def create_request_model(
|
|
|
64
64
|
|
|
65
65
|
def create_get_request_model(
|
|
66
66
|
extensions: Optional[List[ApiExtension]],
|
|
67
|
-
base_model: BaseSearchGetRequest = BaseSearchGetRequest,
|
|
67
|
+
base_model: Type[BaseSearchGetRequest] = BaseSearchGetRequest,
|
|
68
68
|
) -> Type[APIRequest]:
|
|
69
69
|
"""Wrap create_request_model to create the GET request model."""
|
|
70
|
-
|
|
71
|
-
return create_request_model(
|
|
70
|
+
return create_request_model( # type: ignore
|
|
72
71
|
"SearchGetRequest",
|
|
73
72
|
base_model=base_model,
|
|
74
73
|
extensions=extensions,
|
|
@@ -78,10 +77,10 @@ def create_get_request_model(
|
|
|
78
77
|
|
|
79
78
|
def create_post_request_model(
|
|
80
79
|
extensions: Optional[List[ApiExtension]],
|
|
81
|
-
base_model: BaseSearchPostRequest = BaseSearchPostRequest,
|
|
80
|
+
base_model: Type[BaseSearchPostRequest] = BaseSearchPostRequest,
|
|
82
81
|
) -> Type[BaseModel]:
|
|
83
82
|
"""Wrap create_request_model to create the POST request model."""
|
|
84
|
-
return create_request_model(
|
|
83
|
+
return create_request_model( # type: ignore
|
|
85
84
|
"SearchPostRequest",
|
|
86
85
|
base_model=base_model,
|
|
87
86
|
extensions=extensions,
|
|
@@ -14,8 +14,11 @@ def update_openapi(app: FastAPI) -> FastAPI:
|
|
|
14
14
|
content-type response header.
|
|
15
15
|
"""
|
|
16
16
|
# Find the route for the openapi_url in the app
|
|
17
|
+
# TODO: Type info is Route, while it shoukd maybe be APIRoute? Check FastAPI source.
|
|
17
18
|
openapi_route: Route = next(
|
|
18
|
-
route
|
|
19
|
+
route
|
|
20
|
+
for route in app.router.routes
|
|
21
|
+
if route.path == app.openapi_url # type: ignore
|
|
19
22
|
)
|
|
20
23
|
# Store the old endpoint function so we can call it from the patched function
|
|
21
24
|
old_endpoint = openapi_route.endpoint
|
|
@@ -16,7 +16,7 @@ from starlette.responses import Response
|
|
|
16
16
|
from starlette.routing import BaseRoute, Match
|
|
17
17
|
from starlette.status import HTTP_204_NO_CONTENT
|
|
18
18
|
|
|
19
|
-
from stac_fastapi.
|
|
19
|
+
from stac_fastapi.types.search import APIRequest
|
|
20
20
|
|
|
21
21
|
|
|
22
22
|
def _wrap_response(resp: Any) -> Any:
|
|
@@ -58,7 +58,7 @@ def create_async_endpoint(
|
|
|
58
58
|
|
|
59
59
|
elif issubclass(request_model, APIRequest):
|
|
60
60
|
|
|
61
|
-
async def _endpoint(request: Request, request_data=Depends(request_model)):
|
|
61
|
+
async def _endpoint(request: Request, request_data=Depends(request_model)): # type: ignore
|
|
62
62
|
"""Endpoint."""
|
|
63
63
|
return _wrap_response(await func(request=request, **request_data.kwargs()))
|
|
64
64
|
|
|
@@ -100,10 +100,14 @@ def add_route_dependencies(
|
|
|
100
100
|
_scope = copy.deepcopy(scope)
|
|
101
101
|
for route in routes:
|
|
102
102
|
if scope["path"] == "*":
|
|
103
|
-
|
|
103
|
+
# NOTE: ignore type, because BaseRoute has no "path" attribute
|
|
104
|
+
# but APIRoute does.
|
|
105
|
+
_scope["path"] = route.path # type: ignore
|
|
104
106
|
|
|
107
|
+
# NOTE: ignore type, because BaseRoute has no "method" attribute
|
|
108
|
+
# but APIRoute does.
|
|
105
109
|
if scope["method"] == "*":
|
|
106
|
-
_scope["method"] = list(route.methods)[0]
|
|
110
|
+
_scope["method"] = list(route.methods)[0] # type: ignore
|
|
107
111
|
|
|
108
112
|
match, _ = route.matches({"type": "http", **_scope})
|
|
109
113
|
if match != Match.FULL:
|
|
@@ -119,7 +123,10 @@ def add_route_dependencies(
|
|
|
119
123
|
route.dependant.dependencies.insert(
|
|
120
124
|
0,
|
|
121
125
|
get_parameterless_sub_dependant(
|
|
122
|
-
|
|
126
|
+
# NOTE: ignore type, because BaseRoute has no "path_format"
|
|
127
|
+
# attribute but APIRoute does.
|
|
128
|
+
depends=depends,
|
|
129
|
+
path=route.path_format, # type: ignore
|
|
123
130
|
),
|
|
124
131
|
)
|
|
125
132
|
|
|
@@ -128,7 +135,9 @@ def add_route_dependencies(
|
|
|
128
135
|
# app.include_router(router))
|
|
129
136
|
# https://github.com/tiangolo/fastapi/blob/58ab733f19846b4875c5b79bfb1f4d1cb7f4823f/fastapi/applications.py#L337-L360
|
|
130
137
|
# https://github.com/tiangolo/fastapi/blob/58ab733f19846b4875c5b79bfb1f4d1cb7f4823f/fastapi/routing.py#L677-L678
|
|
131
|
-
|
|
138
|
+
# NOTE: ignore type, because BaseRoute has no "dependencies" attribute
|
|
139
|
+
# but APIRoute does.
|
|
140
|
+
route.dependencies.extend(dependencies) # type: ignore
|
|
132
141
|
|
|
133
142
|
|
|
134
143
|
def add_direct_response(app: FastAPI) -> None:
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|