File tree Expand file tree Collapse file tree 4 files changed +47
-6
lines changed Expand file tree Collapse file tree 4 files changed +47
-6
lines changed Original file line number Diff line number Diff line change 4
4
5
5
### Changed
6
6
7
- * add more openapi metadata in input models [ #734 ] ( https://github.com/stac-utils/stac-fastapi/pull/734 )
7
+ * Add more openapi metadata in input models [ #734 ] ( https://github.com/stac-utils/stac-fastapi/pull/734 )
8
+ * Use same ` Limit ` (capped to ` 10_000 ` ) for ` /items ` and ` GET - /search ` input models ([ #737 ] ( https://github.com/stac-utils/stac-fastapi/pull/737 ) )
8
9
9
10
### Added
11
+
10
12
* Add Free-text Extension ([ #655 ] ( https://github.com/stac-utils/stac-fastapi/pull/655 ) )
11
13
* Add Collection-Search Extension ([ #736 ] ( https://github.com/stac-utils/stac-fastapi/pull/736 ) )
12
14
Original file line number Diff line number Diff line change 14
14
APIRequest ,
15
15
BaseSearchGetRequest ,
16
16
BaseSearchPostRequest ,
17
+ Limit ,
17
18
_bbox_converter ,
18
19
_datetime_converter ,
19
20
)
@@ -113,7 +114,12 @@ class ItemCollectionUri(APIRequest):
113
114
"""Get item collection."""
114
115
115
116
collection_id : Annotated [str , Path (description = "Collection ID" )] = attr .ib ()
116
- limit : Annotated [int , Query ()] = attr .ib (default = 10 )
117
+ limit : Annotated [
118
+ Optional [Limit ],
119
+ Query (
120
+ description = "Limits the number of results that are included in each page of the response (capped to 10_000)." # noqa: E501
121
+ ),
122
+ ] = attr .ib (default = 10 )
117
123
bbox : Optional [BBox ] = attr .ib (default = None , converter = _bbox_converter )
118
124
datetime : Optional [DateTimeType ] = attr .ib (
119
125
default = None , converter = _datetime_converter
Original file line number Diff line number Diff line change @@ -174,9 +174,9 @@ class BaseSearchGetRequest(APIRequest):
174
174
default = None , converter = _datetime_converter
175
175
)
176
176
limit : Annotated [
177
- Optional [int ],
177
+ Optional [Limit ],
178
178
Query (
179
- description = "Limits the number of results that are included in each page of the response." # noqa: E501
179
+ description = "Limits the number of results that are included in each page of the response (capped to 10_000) ." # noqa: E501
180
180
),
181
181
] = attr .ib (default = 10 )
182
182
@@ -186,5 +186,5 @@ class BaseSearchPostRequest(Search):
186
186
187
187
limit : Optional [Limit ] = Field (
188
188
10 ,
189
- description = "Limits the number of results that are included in each page of the response." , # noqa: E501
189
+ description = "Limits the number of results that are included in each page of the response (capped to 10_000) ." , # noqa: E501
190
190
)
Original file line number Diff line number Diff line change 1
1
import pytest
2
+ from fastapi import Depends , FastAPI
3
+ from fastapi .testclient import TestClient
2
4
from pydantic import ValidationError
3
5
4
- from stac_fastapi .types .search import BaseSearchPostRequest
6
+ from stac_fastapi .types .search import BaseSearchGetRequest , BaseSearchPostRequest
5
7
6
8
7
9
@pytest .mark .parametrize ("value" , [0 , - 1 ])
@@ -20,3 +22,34 @@ def test_limit(value):
20
22
def test_limit_le (value ):
21
23
search = BaseSearchPostRequest (limit = value )
22
24
assert search .limit == 10_000
25
+
26
+
27
+ def test_limit_get_request ():
28
+ """test GET model."""
29
+
30
+ app = FastAPI ()
31
+
32
+ @app .get ("/test" )
33
+ def route (model = Depends (BaseSearchGetRequest )):
34
+ return model
35
+
36
+ with TestClient (app ) as client :
37
+ resp = client .get (
38
+ "/test" ,
39
+ params = {
40
+ "limit" : 10 ,
41
+ },
42
+ )
43
+ assert resp .status_code == 200
44
+ response_dict = resp .json ()
45
+ assert response_dict ["limit" ] == 10
46
+
47
+ resp = client .get (
48
+ "/test" ,
49
+ params = {
50
+ "limit" : 100_000 ,
51
+ },
52
+ )
53
+ assert resp .status_code == 200
54
+ response_dict = resp .json ()
55
+ assert response_dict ["limit" ] == 10_000
You can’t perform that action at this time.
0 commit comments