stac-fastapi.api 4.0.1__tar.gz → 5.0.1__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-4.0.1 → stac_fastapi_api-5.0.1}/PKG-INFO +2 -2
- {stac_fastapi_api-4.0.1 → stac_fastapi_api-5.0.1}/setup.py +1 -1
- {stac_fastapi_api-4.0.1 → stac_fastapi_api-5.0.1}/stac_fastapi/api/app.py +17 -34
- {stac_fastapi_api-4.0.1 → stac_fastapi_api-5.0.1}/stac_fastapi/api/version.py +1 -1
- {stac_fastapi_api-4.0.1 → stac_fastapi_api-5.0.1}/stac_fastapi.api.egg-info/PKG-INFO +2 -2
- {stac_fastapi_api-4.0.1 → stac_fastapi_api-5.0.1}/stac_fastapi.api.egg-info/requires.txt +1 -1
- {stac_fastapi_api-4.0.1 → stac_fastapi_api-5.0.1}/tests/test_app.py +39 -1
- {stac_fastapi_api-4.0.1 → stac_fastapi_api-5.0.1}/tests/test_app_prefix.py +27 -0
- {stac_fastapi_api-4.0.1 → stac_fastapi_api-5.0.1}/README.md +0 -0
- {stac_fastapi_api-4.0.1 → stac_fastapi_api-5.0.1}/setup.cfg +0 -0
- {stac_fastapi_api-4.0.1 → stac_fastapi_api-5.0.1}/stac_fastapi/api/__init__.py +0 -0
- {stac_fastapi_api-4.0.1 → stac_fastapi_api-5.0.1}/stac_fastapi/api/config.py +0 -0
- {stac_fastapi_api-4.0.1 → stac_fastapi_api-5.0.1}/stac_fastapi/api/errors.py +0 -0
- {stac_fastapi_api-4.0.1 → stac_fastapi_api-5.0.1}/stac_fastapi/api/middleware.py +0 -0
- {stac_fastapi_api-4.0.1 → stac_fastapi_api-5.0.1}/stac_fastapi/api/models.py +0 -0
- {stac_fastapi_api-4.0.1 → stac_fastapi_api-5.0.1}/stac_fastapi/api/openapi.py +0 -0
- {stac_fastapi_api-4.0.1 → stac_fastapi_api-5.0.1}/stac_fastapi/api/routes.py +0 -0
- {stac_fastapi_api-4.0.1 → stac_fastapi_api-5.0.1}/stac_fastapi.api.egg-info/SOURCES.txt +0 -0
- {stac_fastapi_api-4.0.1 → stac_fastapi_api-5.0.1}/stac_fastapi.api.egg-info/dependency_links.txt +0 -0
- {stac_fastapi_api-4.0.1 → stac_fastapi_api-5.0.1}/stac_fastapi.api.egg-info/not-zip-safe +0 -0
- {stac_fastapi_api-4.0.1 → stac_fastapi_api-5.0.1}/stac_fastapi.api.egg-info/top_level.txt +0 -0
- {stac_fastapi_api-4.0.1 → stac_fastapi_api-5.0.1}/tests/test_api.py +0 -0
- {stac_fastapi_api-4.0.1 → stac_fastapi_api-5.0.1}/tests/test_middleware.py +0 -0
- {stac_fastapi_api-4.0.1 → stac_fastapi_api-5.0.1}/tests/test_models.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.2
|
|
2
2
|
Name: stac-fastapi.api
|
|
3
|
-
Version:
|
|
3
|
+
Version: 5.0.1
|
|
4
4
|
Summary: An implementation of STAC API based on the FastAPI framework.
|
|
5
5
|
Home-page: https://github.com/stac-utils/stac-fastapi
|
|
6
6
|
Author: Arturo Engineering
|
|
@@ -19,7 +19,7 @@ Classifier: License :: OSI Approved :: MIT License
|
|
|
19
19
|
Requires-Python: >=3.9
|
|
20
20
|
Description-Content-Type: text/markdown
|
|
21
21
|
Requires-Dist: brotli_asgi
|
|
22
|
-
Requires-Dist: stac-fastapi.types~=
|
|
22
|
+
Requires-Dist: stac-fastapi.types~=5.0
|
|
23
23
|
Provides-Extra: dev
|
|
24
24
|
Requires-Dist: httpx; extra == "dev"
|
|
25
25
|
Requires-Dist: pytest; extra == "dev"
|
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
"""Fastapi app creation."""
|
|
2
2
|
|
|
3
3
|
|
|
4
|
-
from typing import
|
|
4
|
+
from typing import Dict, List, Optional, Tuple, Type, Union
|
|
5
5
|
|
|
6
6
|
import attr
|
|
7
7
|
from brotli_asgi import BrotliMiddleware
|
|
8
8
|
from fastapi import APIRouter, FastAPI
|
|
9
|
-
from fastapi.openapi.utils import get_openapi
|
|
10
9
|
from fastapi.params import Depends
|
|
11
10
|
from stac_pydantic import api
|
|
12
11
|
from stac_pydantic.api.collections import Collections
|
|
@@ -71,19 +70,6 @@ class StacApi:
|
|
|
71
70
|
exceptions: Dict[Type[Exception], int] = attr.ib(
|
|
72
71
|
default=attr.Factory(lambda: DEFAULT_STATUS_CODES)
|
|
73
72
|
)
|
|
74
|
-
app: FastAPI = attr.ib(
|
|
75
|
-
default=attr.Factory(
|
|
76
|
-
lambda self: FastAPI(
|
|
77
|
-
openapi_url=self.settings.openapi_url,
|
|
78
|
-
docs_url=self.settings.docs_url,
|
|
79
|
-
redoc_url=None,
|
|
80
|
-
root_path=self.settings.root_path,
|
|
81
|
-
),
|
|
82
|
-
takes_self=True,
|
|
83
|
-
),
|
|
84
|
-
converter=update_openapi,
|
|
85
|
-
)
|
|
86
|
-
router: APIRouter = attr.ib(default=attr.Factory(APIRouter))
|
|
87
73
|
title: str = attr.ib(
|
|
88
74
|
default=attr.Factory(
|
|
89
75
|
lambda self: self.settings.stac_fastapi_title, takes_self=True
|
|
@@ -100,6 +86,22 @@ class StacApi:
|
|
|
100
86
|
lambda self: self.settings.stac_fastapi_description, takes_self=True
|
|
101
87
|
)
|
|
102
88
|
)
|
|
89
|
+
app: FastAPI = attr.ib(
|
|
90
|
+
default=attr.Factory(
|
|
91
|
+
lambda self: FastAPI(
|
|
92
|
+
openapi_url=self.settings.openapi_url,
|
|
93
|
+
docs_url=self.settings.docs_url,
|
|
94
|
+
redoc_url=None,
|
|
95
|
+
root_path=self.settings.root_path,
|
|
96
|
+
title=self.title,
|
|
97
|
+
version=self.api_version,
|
|
98
|
+
description=self.description,
|
|
99
|
+
),
|
|
100
|
+
takes_self=True,
|
|
101
|
+
),
|
|
102
|
+
converter=update_openapi,
|
|
103
|
+
)
|
|
104
|
+
router: APIRouter = attr.ib(default=attr.Factory(APIRouter))
|
|
103
105
|
search_get_request_model: Type[BaseSearchGetRequest] = attr.ib(
|
|
104
106
|
default=BaseSearchGetRequest
|
|
105
107
|
)
|
|
@@ -388,22 +390,6 @@ class StacApi:
|
|
|
388
390
|
self.register_get_collection()
|
|
389
391
|
self.register_get_item_collection()
|
|
390
392
|
|
|
391
|
-
def customize_openapi(self) -> Optional[Dict[str, Any]]:
|
|
392
|
-
"""Customize openapi schema."""
|
|
393
|
-
if self.app.openapi_schema:
|
|
394
|
-
return self.app.openapi_schema
|
|
395
|
-
|
|
396
|
-
openapi_schema = get_openapi(
|
|
397
|
-
title=self.title,
|
|
398
|
-
version=self.api_version,
|
|
399
|
-
description=self.description,
|
|
400
|
-
routes=self.app.routes,
|
|
401
|
-
servers=self.app.servers,
|
|
402
|
-
)
|
|
403
|
-
|
|
404
|
-
self.app.openapi_schema = openapi_schema
|
|
405
|
-
return self.app.openapi_schema
|
|
406
|
-
|
|
407
393
|
def add_health_check(self):
|
|
408
394
|
"""Add a health check."""
|
|
409
395
|
mgmt_router = APIRouter(prefix=self.app.state.router_prefix)
|
|
@@ -467,9 +453,6 @@ class StacApi:
|
|
|
467
453
|
# register exception handlers
|
|
468
454
|
add_exception_handlers(self.app, status_codes=self.exceptions)
|
|
469
455
|
|
|
470
|
-
# customize openapi
|
|
471
|
-
self.app.openapi = self.customize_openapi
|
|
472
|
-
|
|
473
456
|
# add middlewares
|
|
474
457
|
if self.middlewares and self.app.middleware_stack is not None:
|
|
475
458
|
raise RuntimeError("Cannot add middleware after an application has started")
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.2
|
|
2
2
|
Name: stac-fastapi.api
|
|
3
|
-
Version:
|
|
3
|
+
Version: 5.0.1
|
|
4
4
|
Summary: An implementation of STAC API based on the FastAPI framework.
|
|
5
5
|
Home-page: https://github.com/stac-utils/stac-fastapi
|
|
6
6
|
Author: Arturo Engineering
|
|
@@ -19,7 +19,7 @@ Classifier: License :: OSI Approved :: MIT License
|
|
|
19
19
|
Requires-Python: >=3.9
|
|
20
20
|
Description-Content-Type: text/markdown
|
|
21
21
|
Requires-Dist: brotli_asgi
|
|
22
|
-
Requires-Dist: stac-fastapi.types~=
|
|
22
|
+
Requires-Dist: stac-fastapi.types~=5.0
|
|
23
23
|
Provides-Extra: dev
|
|
24
24
|
Requires-Dist: httpx; extra == "dev"
|
|
25
25
|
Requires-Dist: pytest; extra == "dev"
|
|
@@ -15,7 +15,11 @@ from stac_fastapi.api.models import (
|
|
|
15
15
|
create_get_request_model,
|
|
16
16
|
create_post_request_model,
|
|
17
17
|
)
|
|
18
|
-
from stac_fastapi.extensions.core import
|
|
18
|
+
from stac_fastapi.extensions.core import (
|
|
19
|
+
FieldsExtension,
|
|
20
|
+
FilterExtension,
|
|
21
|
+
SearchFilterExtension,
|
|
22
|
+
)
|
|
19
23
|
from stac_fastapi.types import stac
|
|
20
24
|
from stac_fastapi.types.config import ApiSettings
|
|
21
25
|
from stac_fastapi.types.core import BaseCoreClient, NumType
|
|
@@ -184,6 +188,40 @@ def test_filter_extension(validate, TestCoreClient, item_dict):
|
|
|
184
188
|
)
|
|
185
189
|
|
|
186
190
|
assert landing.status_code == 200, landing.text
|
|
191
|
+
assert "Queryables" in [link.get("title") for link in landing.json()["links"]]
|
|
192
|
+
assert get_search.status_code == 200, get_search.text
|
|
193
|
+
assert post_search.status_code == 200, post_search.text
|
|
194
|
+
|
|
195
|
+
test_app = app.StacApi(
|
|
196
|
+
settings=ApiSettings(enable_response_models=validate),
|
|
197
|
+
client=FilterClient(),
|
|
198
|
+
search_get_request_model=create_get_request_model([SearchFilterExtension()]),
|
|
199
|
+
search_post_request_model=create_post_request_model([SearchFilterExtension()]),
|
|
200
|
+
extensions=[SearchFilterExtension()],
|
|
201
|
+
)
|
|
202
|
+
|
|
203
|
+
with TestClient(test_app.app) as client:
|
|
204
|
+
landing = client.get("/")
|
|
205
|
+
get_search = client.get(
|
|
206
|
+
"/search",
|
|
207
|
+
params={
|
|
208
|
+
"filter": "TEST",
|
|
209
|
+
"filter-crs": "EPSG:4326",
|
|
210
|
+
"filter-lang": "cql2-text",
|
|
211
|
+
},
|
|
212
|
+
)
|
|
213
|
+
post_search = client.post(
|
|
214
|
+
"/search",
|
|
215
|
+
json={
|
|
216
|
+
"collections": ["test"],
|
|
217
|
+
"filter": {},
|
|
218
|
+
"filter-crs": "EPSG:4326",
|
|
219
|
+
"filter-lang": "cql2-json",
|
|
220
|
+
},
|
|
221
|
+
)
|
|
222
|
+
|
|
223
|
+
assert landing.status_code == 200, landing.text
|
|
224
|
+
assert "Queryables" in [link.get("title") for link in landing.json()["links"]]
|
|
187
225
|
assert get_search.status_code == 200, get_search.text
|
|
188
226
|
assert post_search.status_code == 200, post_search.text
|
|
189
227
|
|
|
@@ -208,3 +208,30 @@ def test_api_prefix_with_root_path(TestCoreClient, prefix):
|
|
|
208
208
|
|
|
209
209
|
resp = client.get(prefix + expected_path)
|
|
210
210
|
assert resp.status_code == 200
|
|
211
|
+
|
|
212
|
+
|
|
213
|
+
def test_api_fastapi_option(TestCoreClient):
|
|
214
|
+
api_settings = ApiSettings(
|
|
215
|
+
stac_fastapi_title="stac-fastapi-tests",
|
|
216
|
+
stac_fastapi_description="test for stac-fastapi",
|
|
217
|
+
stac_fastapi_version="0.1.0dev",
|
|
218
|
+
)
|
|
219
|
+
|
|
220
|
+
api = StacApi(
|
|
221
|
+
settings=api_settings,
|
|
222
|
+
client=TestCoreClient(),
|
|
223
|
+
)
|
|
224
|
+
|
|
225
|
+
with TestClient(api.app, base_url="http://stac.io") as client:
|
|
226
|
+
landing = client.get("/")
|
|
227
|
+
assert landing.status_code == 200
|
|
228
|
+
body = landing.json()
|
|
229
|
+
assert body["title"] == "stac-fastapi-tests"
|
|
230
|
+
assert body["description"] == "test for stac-fastapi"
|
|
231
|
+
|
|
232
|
+
service_desc = client.get("/api")
|
|
233
|
+
assert service_desc.status_code == 200
|
|
234
|
+
body = service_desc.json()["info"]
|
|
235
|
+
assert body["title"] == "stac-fastapi-tests"
|
|
236
|
+
assert body["description"] == "test for stac-fastapi"
|
|
237
|
+
assert body["version"] == "0.1.0dev"
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{stac_fastapi_api-4.0.1 → stac_fastapi_api-5.0.1}/stac_fastapi.api.egg-info/dependency_links.txt
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|