9595 "coordinates" : [[[- 180 , - 90 ], [180 , - 90 ], [180 , 90 ], [- 180 , 90 ], [- 180 , - 90 ]]],
9696}
9797DEFAULT_BBOX = (- 180.0 , - 90.0 , 180.0 , 90.0 )
98+ QUERYABLES = "/queryables"
9899# pylint: disable=too-many-lines
99100logger = Logging .default (__name__ )
100101
@@ -961,7 +962,7 @@ async def manage_get_response( # pylint: disable=too-many-locals, too-many-bran
961962 )
962963 # I don't know why but the STAC browser doesn't send authentication for the queryables endpoint.
963964 # So allow this endpoint without authentication in this specific case.
964- and not (common_settings .request_from_stacbrowser (request ) and request .url .path .endswith ("/queryables" ))
965+ and not (common_settings .request_from_stacbrowser (request ) and request .url .path .endswith (QUERYABLES ))
965966 ):
966967 detail = {"error" : "Unauthorized access." }
967968 return JSONResponse (content = detail , status_code = HTTP_401_UNAUTHORIZED )
@@ -1344,6 +1345,25 @@ async def dispatch(
13441345 response_content = json .loads (b"" .join (body ).decode ()) # type:ignore
13451346 self .clear_catalog_bucket (response_content )
13461347
1348+ # GET: '/catalog/queryables' when no collections in the catalog
1349+ if (
1350+ request .method == "GET"
1351+ and request .scope ["path" ] == QUERYABLES
1352+ and not self .request_ids ["collection_ids" ]
1353+ and response_content ["code" ] == "NotFoundError"
1354+ ):
1355+ # Return empty list of properties and additionalProperties set to true on /catalog/queryables
1356+ # when there are no collections in catalog.
1357+ empty_catalog_queryables_response = {
1358+ "$id" : f"{ request .base_url } queryables" ,
1359+ "type" : "object" ,
1360+ "title" : "STAC Queryables." ,
1361+ "$schema" : "https://json-schema.org/draft-07/schema#" ,
1362+ "properties" : {},
1363+ "additionalProperties" : True ,
1364+ }
1365+ return JSONResponse (status_code = HTTP_200_OK , content = empty_catalog_queryables_response )
1366+
13471367 # Return a regular JSON response instead of StreamingResponse because the body cannot be read again.
13481368 return JSONResponse (status_code = response .status_code , content = response_content )
13491369
@@ -1356,7 +1376,7 @@ async def dispatch(
13561376 response = await self .manage_download_response (request , response )
13571377
13581378 elif request .method == "GET" and (
1359- self .request_ids ["owner_id" ] or request .scope ["path" ] in ["/" , "/collections" , "/queryables" ]
1379+ self .request_ids ["owner_id" ] or request .scope ["path" ] in ["/" , "/collections" , QUERYABLES ]
13601380 ):
13611381 # URL: GET: '/catalog/collections/{USER}:{COLLECTION}'
13621382 # URL: GET: '/catalog/'
0 commit comments