stac-api-protocol 0.3.0__tar.gz → 0.4.0__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.
Files changed (48) hide show
  1. {stac_api_protocol-0.3.0 → stac_api_protocol-0.4.0}/CHANGELOG.md +8 -1
  2. {stac_api_protocol-0.3.0 → stac_api_protocol-0.4.0}/PKG-INFO +1 -1
  3. {stac_api_protocol-0.3.0 → stac_api_protocol-0.4.0}/demo/README.md +5 -0
  4. stac_api_protocol-0.4.0/demo/stac_api_demo/queryables.json +9 -0
  5. {stac_api_protocol-0.3.0 → stac_api_protocol-0.4.0}/demo/stac_api_demo/service.py +12 -0
  6. {stac_api_protocol-0.3.0 → stac_api_protocol-0.4.0}/docs/explanation/architecture.md +1 -1
  7. {stac_api_protocol-0.3.0 → stac_api_protocol-0.4.0}/docs/how-to/deploy-uvicorn.md +3 -2
  8. {stac_api_protocol-0.3.0 → stac_api_protocol-0.4.0}/docs/how-to/register-service.md +3 -3
  9. {stac_api_protocol-0.3.0 → stac_api_protocol-0.4.0}/docs/reference/api.md +31 -4
  10. {stac_api_protocol-0.3.0 → stac_api_protocol-0.4.0}/docs/reference/index.md +1 -1
  11. {stac_api_protocol-0.3.0 → stac_api_protocol-0.4.0}/docs/tutorials/first-steps.md +40 -8
  12. {stac_api_protocol-0.3.0 → stac_api_protocol-0.4.0}/src/stac_api_protocol/__about__.py +1 -1
  13. {stac_api_protocol-0.3.0 → stac_api_protocol-0.4.0}/src/stac_api_protocol/main.py +13 -9
  14. {stac_api_protocol-0.3.0 → stac_api_protocol-0.4.0}/src/stac_api_protocol/queryables.json +8 -1
  15. {stac_api_protocol-0.3.0 → stac_api_protocol-0.4.0}/src/stac_api_protocol/stac_service.py +15 -0
  16. stac_api_protocol-0.4.0/tests/test_demo_service.py +38 -0
  17. {stac_api_protocol-0.3.0 → stac_api_protocol-0.4.0}/tests/test_filter_compliance.py +30 -11
  18. {stac_api_protocol-0.3.0 → stac_api_protocol-0.4.0}/tests/test_stac_service.py +4 -0
  19. {stac_api_protocol-0.3.0 → stac_api_protocol-0.4.0}/.gitignore +0 -0
  20. {stac_api_protocol-0.3.0 → stac_api_protocol-0.4.0}/LICENSE +0 -0
  21. {stac_api_protocol-0.3.0 → stac_api_protocol-0.4.0}/README.md +0 -0
  22. {stac_api_protocol-0.3.0 → stac_api_protocol-0.4.0}/demo/.gitignore +0 -0
  23. {stac_api_protocol-0.3.0 → stac_api_protocol-0.4.0}/demo/download-data.sh +0 -0
  24. {stac_api_protocol-0.3.0 → stac_api_protocol-0.4.0}/demo/examples.sh +0 -0
  25. {stac_api_protocol-0.3.0 → stac_api_protocol-0.4.0}/demo/pyproject.toml +0 -0
  26. {stac_api_protocol-0.3.0 → stac_api_protocol-0.4.0}/demo/stac_api_demo/__init__.py +0 -0
  27. {stac_api_protocol-0.3.0 → stac_api_protocol-0.4.0}/demo/start.sh +0 -0
  28. {stac_api_protocol-0.3.0 → stac_api_protocol-0.4.0}/docs/diagrams/architecture.svg +0 -0
  29. {stac_api_protocol-0.3.0 → stac_api_protocol-0.4.0}/docs/diagrams/architecture_dark.svg +0 -0
  30. {stac_api_protocol-0.3.0 → stac_api_protocol-0.4.0}/docs/diagrams/src/architecture.puml +0 -0
  31. {stac_api_protocol-0.3.0 → stac_api_protocol-0.4.0}/docs/explanation/index.md +0 -0
  32. {stac_api_protocol-0.3.0 → stac_api_protocol-0.4.0}/docs/how-to/index.md +0 -0
  33. {stac_api_protocol-0.3.0 → stac_api_protocol-0.4.0}/docs/how-to/install.md +0 -0
  34. {stac_api_protocol-0.3.0 → stac_api_protocol-0.4.0}/docs/how-to/use-cli.md +0 -0
  35. {stac_api_protocol-0.3.0 → stac_api_protocol-0.4.0}/docs/index.md +0 -0
  36. {stac_api_protocol-0.3.0 → stac_api_protocol-0.4.0}/docs/reference/openapi.html +0 -0
  37. {stac_api_protocol-0.3.0 → stac_api_protocol-0.4.0}/docs/tutorials/index.md +0 -0
  38. {stac_api_protocol-0.3.0 → stac_api_protocol-0.4.0}/pyproject.toml +0 -0
  39. {stac_api_protocol-0.3.0 → stac_api_protocol-0.4.0}/src/stac_api_protocol/__init__.py +0 -0
  40. {stac_api_protocol-0.3.0 → stac_api_protocol-0.4.0}/src/stac_api_protocol/models.py +0 -0
  41. {stac_api_protocol-0.3.0 → stac_api_protocol-0.4.0}/src/stac_api_protocol/plugin_loader.py +0 -0
  42. {stac_api_protocol-0.3.0 → stac_api_protocol-0.4.0}/src/stac_api_protocol/py.typed +0 -0
  43. {stac_api_protocol-0.3.0 → stac_api_protocol-0.4.0}/tests/conftest.py +0 -0
  44. {stac_api_protocol-0.3.0 → stac_api_protocol-0.4.0}/tests/test_bbox_queries.py +0 -0
  45. {stac_api_protocol-0.3.0 → stac_api_protocol-0.4.0}/tests/test_models.py +0 -0
  46. {stac_api_protocol-0.3.0 → stac_api_protocol-0.4.0}/tests/test_plugin_loader.py +0 -0
  47. {stac_api_protocol-0.3.0 → stac_api_protocol-0.4.0}/tests/test_routes.py +0 -0
  48. {stac_api_protocol-0.3.0 → stac_api_protocol-0.4.0}/tests/test_search_validation.py +0 -0
@@ -23,6 +23,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
23
23
 
24
24
  ## [Unreleased]
25
25
 
26
+ ## [0.4.0] - 2026-12-01
27
+
28
+ ### Added
29
+
30
+ - Queryables JSON Schema definition delegated to `StacApiService` implementations.
31
+
26
32
  ## [0.3.0] - 2026-11-30
27
33
 
28
34
  ### Changed
@@ -59,7 +65,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
59
65
 
60
66
  - Initial project release.
61
67
 
62
- [Unreleased]: https://github.com/Terradue/stac-api-protocol/compare/0.3.0...HEAD
68
+ [Unreleased]: https://github.com/Terradue/stac-api-protocol/compare/0.3.1...HEAD
69
+ [0.3.1]: https://github.com/Terradue/stac-api-protocol/compare/0.3.0...0.3.1
63
70
  [0.3.0]: https://github.com/Terradue/stac-api-protocol/compare/0.2.0...0.3.0
64
71
  [0.2.0]: https://github.com/Terradue/stac-api-protocol/compare/0.1.1...0.2.0
65
72
  [0.1.1]: https://github.com/Terradue/stac-api-protocol/compare/0.1.0...0.1.1
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.5
2
2
  Name: stac-api-protocol
3
- Version: 0.3.0
3
+ Version: 0.4.0
4
4
  Summary: A Python FastAPI HTTP adapter for STAC API Core, Item Search, Features and Collections.
5
5
  Project-URL: Documentation, https://terradue.github.io/stac-api-protocol/
6
6
  Project-URL: Issues, https://github.com/Terradue/stac-api-protocol/issues
@@ -56,3 +56,8 @@ JSON-encoded string. `pygeofilter-duckdb` translates the existing search argumen
56
56
  internally.
57
57
  Each query uses its own DuckDB connection. Runtime queries use downloaded local
58
58
  files and a preinstalled spatial extension, with no external database server.
59
+
60
+ Since v0.4.0, `GeoParquetService.get_queryables()` supplies the document served at
61
+ both queryables endpoints from `stac_api_demo/queryables.json`. It advertises no
62
+ CQL2 fields (`properties: {}`, `additionalProperties: false`) because this demo
63
+ rejects CQL2 filters. The adapter preserves the provider's `$id` and other metadata.
@@ -0,0 +1,9 @@
1
+ {
2
+ "$schema": "https://json-schema.org/draft/2019-09/schema",
3
+ "$id": "/queryables",
4
+ "type": "object",
5
+ "title": "NAIP demo queryables",
6
+ "description": "This demo supports standard Item Search parameters but does not implement CQL2 filtering.",
7
+ "properties": {},
8
+ "additionalProperties": false
9
+ }
@@ -20,6 +20,7 @@ import json
20
20
  import os
21
21
  from datetime import datetime as DateTime
22
22
  from functools import cache
23
+ from importlib.resources import files
23
24
  from pathlib import Path
24
25
  from typing import TYPE_CHECKING
25
26
 
@@ -145,6 +146,17 @@ class GeoParquetService(StacApiService):
145
146
  )
146
147
  }
147
148
 
149
+ def get_queryables(self) -> dict[str, object]:
150
+ """Return a fresh schema advertising no CQL2 fields in this demo.
151
+
152
+ The demo supports standard Item Search parameters but rejects CQL2
153
+ expressions. The schema therefore disallows additional queryables.
154
+ """
155
+ schema: dict[str, object] = json.loads(
156
+ files("stac_api_demo").joinpath("queryables.json").read_text("utf-8")
157
+ )
158
+ return schema
159
+
148
160
  def get_collections(self, base_url: str) -> Collections:
149
161
  """Return all static collection descriptions, including metadata-only datasets."""
150
162
  return Collections(
@@ -25,7 +25,7 @@ acts exclusively as the HTTP adapter**.
25
25
  ## The service port
26
26
 
27
27
  `StacApiService`, defined in `src/stac_api_protocol/stac_service.py`, is the boundary
28
- between the HTTP adapter and an adopter's catalogue application. It is an abstract base class with five adopter-defined catalogue operations and
28
+ between the HTTP adapter and an adopter's catalogue application. It is an abstract base class with six adopter-defined catalogue operations and
29
29
  two final metadata methods. Adopters subclass it and supply a catalogue identifier,
30
30
  title, and description. Incomplete subclasses cannot be instantiated.
31
31
 
@@ -132,8 +132,9 @@ curl -fsS "$api/openapi.json" > /dev/null
132
132
  ```
133
133
 
134
134
  The landing page's `self` should be `https://api.example.com/stac/`, its `data`
135
- link should be `https://api.example.com/stac/collections`, and the queryables `$id`
136
- should be `https://api.example.com/stac/queryables`. Inspect provider-generated
135
+ link should be `https://api.example.com/stac/collections`. Since v0.4.0, the
136
+ queryables `$id` is supplied by the provider and is not rewritten by the adapter;
137
+ check it against your provider configuration. Inspect provider-generated
137
138
  navigation links too. Open the public `/stac/docs` URL in a browser and check that
138
139
  its schema loads.
139
140
 
@@ -19,7 +19,7 @@ limitations under the License.
19
19
  ## Implement the port
20
20
 
21
21
  Create a concrete implementation of `StacApiService` from
22
- `stac_api_protocol.stac_service`. Implement the five abstract methods in the
22
+ `stac_api_protocol.stac_service`. Implement the six abstract methods in the
23
23
  [service contract](../reference/api.md), using your own application and backend
24
24
  logic. The [tutorial](../tutorials/first-steps.md) provides a complete minimal
25
25
  example.
@@ -42,8 +42,8 @@ def create_service() -> StacApiService:
42
42
 
43
43
  This example uses the base constructor, which requires catalogue identity metadata.
44
44
  Adapt construction to your application's configuration and resource lifecycle.
45
- The inherited landing-page method uses the incoming request; your five catalogue
46
- operations receive ordinary filter values.
45
+ The inherited landing-page method uses the incoming request; your catalogue operations receive ordinary filter values. Since v0.4.0,
46
+ `get_queryables()` also supplies the provider-owned schema without request arguments.
47
47
 
48
48
  ## Declare the entry point
49
49
 
@@ -18,10 +18,10 @@ limitations under the License.
18
18
 
19
19
  Adopters subclass `StacApiService`, defined in
20
20
  `src/stac_api_protocol/stac_service.py`. The HTTP adapter invokes its synchronous
21
- methods with parsed filter values. All seven operations belong to the same
21
+ methods with parsed filter values. All eight operations belong to the same
22
22
  registered `item_service` provider.
23
23
 
24
- The constructor requires `id`, `title`, and `description`. Five catalogue operations
24
+ The constructor requires `id`, `title`, and `description`. Six catalogue operations
25
25
  are abstract. `get_landing_page()` and `get_conformance_declaration()` are
26
26
  final concrete methods and must not be overridden. The landing page uses
27
27
  root-relative links. Both responses advertise the bundled STAC and OGC
@@ -38,8 +38,8 @@ conformance classes, including Filter Extension capabilities since version 0.2.0
38
38
  | `GET /collections/{collectionId}/items/{featureId}` | `get_feature(collection_id, feature_id)` | `pystac.Item` or `None` |
39
39
  | `GET /conformance` | `get_conformance_declaration()` | `ConformanceClasses` |
40
40
  | `GET /search`, `POST /search` | `get_item_search(bbox, intersects, datetime, limit, ids, collections, filter)` | `pystac.ItemCollection` or `None` |
41
- | `GET /queryables` | Served by the HTTP adapter | JSON Schema (`application/schema+json`) |
42
- | `GET /collections/{collectionId}/queryables` | Adapter checks `describe_collection(collection_id)` | JSON Schema (`application/schema+json`) |
41
+ | `GET /queryables` | `get_queryables()` | JSON Schema (`application/schema+json`) |
42
+ | `GET /collections/{collectionId}/queryables` | `get_queryables()` after `describe_collection(collection_id)` | JSON Schema (`application/schema+json`) |
43
43
 
44
44
  `LandingPage`, `Collections`, and `ConformanceClasses` come from
45
45
  `stac_api_protocol.models`. Use these existing types rather than creating
@@ -70,6 +70,33 @@ Providers are responsible for evaluating expressions, combining them with other
70
70
  search constraints, and fulfilling the advertised conformance classes. Protocol
71
71
  support and protocol tests do not certify a backend's filtering behavior.
72
72
 
73
+ ## Provider-defined queryables since v0.4.0
74
+
75
+ **Version 0.4.0 adds the abstract `get_queryables() -> dict[str, object]` method.**
76
+ Existing providers must implement this method before they can be instantiated.
77
+ The adapter no longer loads the protocol's bundled `queryables.json`.
78
+
79
+ Return a JSON-serializable JSON Schema document describing the Item fields your
80
+ backend supports in CQL2 expressions. Providers own `$schema`, `$id`, `type`,
81
+ `properties`, and `additionalProperties`. Keep the schema in your provider
82
+ package and load it with `importlib.resources`, as the demo does. Queryable names
83
+ are Item fields such as `id` or `eo:cloud_cover`; request parameters such as
84
+ `filter` and `filter-lang` are not queryable fields.
85
+
86
+ Both `/queryables` and `/collections/{collectionId}/queryables` return the provider's
87
+ document unchanged with media type `application/schema+json`. The method receives
88
+ no request URL or collection identifier, so it supplies a shared schema across
89
+ collections. The adapter does not rewrite `$id` to match either endpoint or
90
+ validate the returned schema. Configure the document's identifier in the provider.
91
+ For collection requests, the adapter first checks that the collection exists;
92
+ unknown collections return HTTP 404 without calling `get_queryables()`. A provider
93
+ failure returns HTTP 500 with a generic description.
94
+
95
+ The demo implements the method using its own packaged JSON file. Because its
96
+ backend rejects CQL2 expressions, it returns empty `properties` and
97
+ `additionalProperties: false`. This documents the demo's limitation; it does not
98
+ make the demo fulfill the protocol's advertised CQL2 conformance classes.
99
+
73
100
  ## Filter and result semantics
74
101
 
75
102
  - `bbox` is a list of numbers or `None`; `ids` and `collections` are lists of strings
@@ -24,7 +24,7 @@ and HTTP error handling.
24
24
 
25
25
  ## Integration at a glance
26
26
 
27
- 1. Subclass `StacApiService` and implement its five abstract catalogue operations.
27
+ 1. Subclass `StacApiService` and implement its six abstract catalogue operations.
28
28
  2. Expose a callable factory that returns your service implementation.
29
29
  3. Register that factory in your package's `pyproject.toml`:
30
30
 
@@ -16,7 +16,7 @@ limitations under the License.
16
16
 
17
17
  # Build your first service
18
18
 
19
- This tutorial builds an empty catalogue provider. It demonstrates the five abstract operations of the
19
+ This tutorial builds an empty catalogue provider. It demonstrates the six abstract operations of the
20
20
  service contract and factory discovery without requiring a database. An empty
21
21
  catalogue cannot demonstrate filtering or item retrieval; replace these methods
22
22
  with your own application logic when connecting real data.
@@ -31,7 +31,8 @@ my-catalogue/
31
31
  └── src/
32
32
  └── my_catalogue/
33
33
  ├── __init__.py
34
- └── provider.py
34
+ ├── provider.py
35
+ └── queryables.json
35
36
  ```
36
37
 
37
38
  Leave `__init__.py` empty. Put the following in `pyproject.toml`:
@@ -45,7 +46,7 @@ build-backend = "hatchling.build"
45
46
  name = "my-catalogue"
46
47
  version = "0.1.0"
47
48
  requires-python = ">=3.11"
48
- dependencies = ["stac-api-protocol"]
49
+ dependencies = ["stac-api-protocol>=0.4.0"]
49
50
 
50
51
  [project.entry-points."stacapi.service"]
51
52
  item_service = "my_catalogue.provider:create_service"
@@ -62,6 +63,9 @@ to find your factory once this package is installed.
62
63
  Put this implementation in `src/my_catalogue/provider.py`:
63
64
 
64
65
  ```python
66
+ import json
67
+ from importlib.resources import files
68
+
65
69
  from geojson import GeometryCollection
66
70
  from geojson.geometry import Geometry
67
71
  from pystac import Collection, Item, ItemCollection
@@ -73,36 +77,47 @@ from stac_api_protocol.stac_service import StacApiService
73
77
  class EmptyCatalogueService(StacApiService):
74
78
  """Expose an empty catalogue to demonstrate the service boundary."""
75
79
 
76
- def get_collections(self) -> Collections:
80
+ def get_queryables(self) -> dict[str, object]:
81
+ """Return the packaged schema for this empty catalogue."""
82
+ schema: dict[str, object] = json.loads(
83
+ files("my_catalogue").joinpath("queryables.json").read_text("utf-8")
84
+ )
85
+ return schema
86
+
87
+ def get_collections(self, base_url: str) -> Collections:
77
88
  """Return the catalogue's empty collection listing."""
78
89
  return Collections(collections=[], links=[])
79
90
 
80
- def describe_collection(self, collection_id: str) -> Collection | None:
91
+ def describe_collection(self, base_url: str, collection_id: str) -> Collection | None:
81
92
  """Report that the requested collection does not exist."""
82
93
  return None
83
94
 
84
95
  def get_features(
85
96
  self,
97
+ base_url: str,
86
98
  collection_id: str,
87
99
  limit: int | None,
88
100
  bbox: list[float] | None,
89
101
  datetime: str | None,
102
+ filter: str | dict[str, object] | bool | None = None,
90
103
  ) -> ItemCollection | None:
91
104
  """Report that the requested collection does not exist."""
92
105
  return None
93
106
 
94
- def get_feature(self, collection_id: str, feature_id: str) -> Item | None:
107
+ def get_feature(self, base_url: str, collection_id: str, feature_id: str) -> Item | None:
95
108
  """Report that the requested item does not exist."""
96
109
  return None
97
110
 
98
111
  def get_item_search(
99
112
  self,
113
+ base_url: str,
100
114
  bbox: list[float] | None,
101
115
  intersects: Geometry | GeometryCollection | None,
102
116
  datetime: str | None,
103
117
  limit: int | None,
104
118
  ids: list[str] | None,
105
119
  collections: list[str] | None,
120
+ filter: str | dict[str, object] | bool | None = None,
106
121
  ) -> ItemCollection | None:
107
122
  """Return a successful search with no matching items."""
108
123
  return ItemCollection([])
@@ -115,12 +130,29 @@ def create_service() -> StacApiService:
115
130
  )
116
131
  ```
117
132
 
133
+ Create `src/my_catalogue/queryables.json` for the provider-owned queryables API,
134
+ available since v0.4.0:
135
+
136
+ ```json
137
+ {
138
+ "$schema": "https://json-schema.org/draft/2019-09/schema",
139
+ "$id": "/queryables",
140
+ "type": "object",
141
+ "properties": {},
142
+ "additionalProperties": false
143
+ }
144
+ ```
145
+
146
+ This empty catalogue advertises no queryable fields. Replace the schema with the
147
+ fields your backend supports when adding CQL2 evaluation. The adapter serves this
148
+ document unchanged at both queryables endpoints for existing collections.
149
+
118
150
  The class specializes `StacApiService`; the factory returns it through the port.
119
151
  Neither needs to import FastAPI. All HTTP handling remains in the adapter.
120
152
 
121
153
  The base class supplies the final landing-page and conformance methods. It builds
122
- links from the incoming landing-page request and advertises the four bundled STAC
123
- API conformance classes. Adopters implement the other five abstract operations
154
+ links from the incoming landing-page request and advertises the bundled STAC
155
+ and OGC conformance classes. Adopters implement the other six abstract operations
124
156
  and must fulfill those advertised capabilities. This empty example demonstrates
125
157
  the integration mechanics; it is not a conformance certification.
126
158
 
@@ -14,4 +14,4 @@
14
14
 
15
15
  """Package metadata for STAC API Protocol."""
16
16
 
17
- __version__ = "0.3.0"
17
+ __version__ = "0.4.0"
@@ -18,12 +18,10 @@
18
18
 
19
19
  """Expose STAC routes backed by the configured service provider."""
20
20
 
21
- import json
22
21
  import logging
23
22
  import math
24
23
  import re
25
24
  from datetime import datetime as DateTime
26
- from importlib.resources import files
27
25
  from typing import TYPE_CHECKING, Annotated
28
26
  from urllib.parse import quote
29
27
 
@@ -442,10 +440,16 @@ def _item_search(
442
440
  },
443
441
  tags=["Filter Extension"],
444
442
  )
445
- def get_queryables(request: Request) -> Response:
446
- """Return the shared queryables schema identified by the requested URL."""
447
- schema = json.loads(files("stac_api_protocol").joinpath("queryables.json").read_text("utf-8"))
448
- schema["$id"] = str(request.url.replace(query=""))
443
+ def get_queryables(service: StacApiService = Depends(get_item_service)) -> Response:
444
+ """Return the provider's queryables schema without modifying its contents.
445
+
446
+ Raises:
447
+ HTTPException: With status 500 if the provider cannot retrieve queryables.
448
+ """
449
+ try:
450
+ schema = service.get_queryables()
451
+ except Exception as error:
452
+ raise _server_error("Unable to retrieve queryables") from error
449
453
  return JSONResponse(content=schema, media_type="application/schema+json")
450
454
 
451
455
 
@@ -463,11 +467,11 @@ def get_collection_queryables(
463
467
  collection_id: str = Path(..., alias="collectionId"),
464
468
  service: StacApiService = Depends(get_item_service),
465
469
  ) -> Response:
466
- """Return the shared queryables schema for an existing collection.
470
+ """Return the provider's shared queryables schema for an existing collection.
467
471
 
468
472
  Raises:
469
473
  HTTPException: With status 404 if the collection does not exist, or
470
- status 500 if the provider cannot retrieve collection metadata.
474
+ status 500 if the provider cannot retrieve metadata or queryables.
471
475
  """
472
476
  try:
473
477
  collection = service.describe_collection(_get_url(request), collection_id)
@@ -475,7 +479,7 @@ def get_collection_queryables(
475
479
  raise _server_error("Unable to retrieve collection metadata") from error
476
480
  if collection is None:
477
481
  raise _not_found(f"Collection {collection_id} does not exist in this Catalogue")
478
- return get_queryables(request)
482
+ return get_queryables(service)
479
483
 
480
484
 
481
485
  def _parse_intersects(value: str | None) -> GeometryGeoJSON | GeometryCollection | None:
@@ -3,7 +3,7 @@
3
3
  "$id": "/queryables",
4
4
  "type": "object",
5
5
  "title": "Queryables for STAC API",
6
- "description": "Queryable names for the STAC API Item Search filter.",
6
+ "description": "Queryable names for the STAC API Item Search filter, supporting CQL2 JSON (cql2-json) and CQL2 Text (cql2-text) expressions.",
7
7
  "properties": {
8
8
  "id": {
9
9
  "description": "ID",
@@ -28,6 +28,13 @@
28
28
  "updated": {
29
29
  "description": "Last Update Time",
30
30
  "$ref": "https://schemas.stacspec.org/v1.0.0/item-spec/json-schema/datetime.json#/properties/updated"
31
+ },
32
+ "filter": {
33
+ "description": "The CQL2-(JSON|TEXT) filter.",
34
+ "oneOf": [
35
+ { "type": "string" },
36
+ { "$ref": "https://schemas.opengis.net/cql2/1.0/cql2.json" }
37
+ ]
31
38
  }
32
39
  },
33
40
  "additionalProperties": true
@@ -183,3 +183,18 @@ class StacApiService(ABC):
183
183
  collections: Collection identifiers, or None to search all collections.
184
184
  filter: CQL2 expression, or None to omit CQL2 filtering.
185
185
  """
186
+
187
+ @abstractmethod
188
+ def get_queryables(self) -> dict[str, object]:
189
+ """Return the JSON Schema describing fields available in CQL2 filters.
190
+
191
+ Available since v0.4.0. Providers own the complete JSON-serializable
192
+ document, including its schema dialect, identifier, property definitions,
193
+ and additional-property policy. The adapter returns it unchanged at both
194
+ catalogue and collection queryables endpoints. No collection identifier
195
+ or request URL is passed, so the schema must apply across collections.
196
+
197
+ Returns:
198
+ A queryables JSON Schema document. Its properties describe searchable
199
+ Item fields, rather than search request parameters such as ``filter``.
200
+ """
@@ -0,0 +1,38 @@
1
+ # Copyright 2026 Terradue
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # http://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+
15
+ from __future__ import annotations
16
+
17
+ from typing import TYPE_CHECKING
18
+
19
+ from stac_api_demo.service import GeoParquetService
20
+
21
+ if TYPE_CHECKING:
22
+ from pathlib import Path
23
+
24
+
25
+ def test_demo_queryables_describes_cql2_limitation_and_returns_fresh_document(
26
+ tmp_path: Path,
27
+ ) -> None:
28
+ (tmp_path / "naip.parquet").touch()
29
+ (tmp_path / "collections.json").write_text("[]", encoding="utf-8")
30
+ service = GeoParquetService(tmp_path)
31
+
32
+ schema = service.get_queryables()
33
+ assert schema["type"] == "object"
34
+ assert schema["properties"] == {}
35
+ assert schema["additionalProperties"] is False
36
+ assert schema["$id"] == "/queryables"
37
+ schema["properties"] = {"unsupported": {"type": "string"}}
38
+ assert service.get_queryables()["properties"] == {}
@@ -62,6 +62,13 @@ def filter_app(
62
62
  service.get_item_search.return_value = ItemCollection([])
63
63
  service.get_features.return_value = ItemCollection([])
64
64
  service.describe_collection.return_value = queryables_collection
65
+ service.get_queryables.return_value = {
66
+ "$schema": "https://json-schema.org/draft/2019-09/schema",
67
+ "$id": "https://provider.example/queryables",
68
+ "type": "object",
69
+ "properties": {"eo:cloud_cover": {"type": "number", "minimum": 0}},
70
+ "additionalProperties": False,
71
+ }
65
72
  app.dependency_overrides[api.get_item_service] = lambda: service
66
73
  try:
67
74
  yield app
@@ -145,18 +152,17 @@ def test_landing_page_advertises_queryables_with_standard_relation(service: Mock
145
152
 
146
153
 
147
154
  @pytest.mark.parametrize("path", ["/queryables", "/collections/sentinel/queryables"])
148
- def test_global_and_collection_queryables_are_available(filter_app: FastAPI, path: str) -> None:
155
+ def test_global_and_collection_queryables_are_available(
156
+ filter_app: FastAPI, service: Mock, path: str
157
+ ) -> None:
149
158
  status, body, headers = asyncio.run(_request(filter_app, "GET", path, {}))
150
159
  assert status == HTTPStatus.OK
151
160
  assert headers[b"content-type"].split(b";")[0] == b"application/schema+json"
152
161
  schema = json.loads(body)
153
162
  assert schema["type"] == "object"
154
163
  assert schema["$schema"].startswith("https://json-schema.org/")
155
- assert urlsplit(schema["$id"]).path == path
156
- assert isinstance(schema["properties"], dict)
157
- assert all(not name.startswith("properties.") for name in schema["properties"])
158
- if not schema["properties"]:
159
- assert schema["additionalProperties"] is True
164
+ assert schema == service.get_queryables.return_value
165
+ service.get_queryables.assert_called_once_with()
160
166
 
161
167
 
162
168
  @pytest.mark.parametrize("filter_lang", [None, "cql2-json"])
@@ -392,13 +398,25 @@ def queryables_collection() -> Collection:
392
398
 
393
399
 
394
400
  @pytest.mark.parametrize("path", ["/queryables", "/collections/sentinel/queryables"])
395
- def test_queryables_identity_excludes_query_string(filter_app: FastAPI, path: str) -> None:
401
+ def test_queryables_preserves_provider_document(
402
+ filter_app: FastAPI, service: Mock, path: str
403
+ ) -> None:
404
+ original = json.dumps(service.get_queryables.return_value)
396
405
  status, body, _ = asyncio.run(_request(filter_app, "GET", path, {"unused": "value"}))
397
406
  assert status == HTTPStatus.OK
398
- schema = json.loads(body)
399
- assert schema["$id"] == "http://localhost:8000" + path
400
- assert "filter" not in schema["properties"]
401
- assert {"id", "collection", "geometry", "datetime"} <= schema["properties"].keys()
407
+ assert json.loads(body) == json.loads(original)
408
+ assert json.dumps(service.get_queryables.return_value) == original
409
+ service.get_queryables.assert_called_once_with()
410
+
411
+
412
+ @pytest.mark.parametrize("path", ["/queryables", "/collections/sentinel/queryables"])
413
+ def test_queryables_provider_failure_returns_server_error(
414
+ filter_app: FastAPI, service: Mock, path: str
415
+ ) -> None:
416
+ service.get_queryables.side_effect = RuntimeError("Private provider details")
417
+ status, body, _ = asyncio.run(_request(filter_app, "GET", path, {}))
418
+ assert status == HTTPStatus.INTERNAL_SERVER_ERROR
419
+ assert json.loads(body) == {"code": "500", "description": "Unable to retrieve queryables"}
402
420
 
403
421
 
404
422
  @pytest.mark.parametrize("path", ["/collections/sentinel", "/collections"])
@@ -434,6 +452,7 @@ def test_unknown_collection_queryables_returns_not_found(
434
452
  assert status == HTTPStatus.NOT_FOUND
435
453
  assert json.loads(body)["code"] == "404"
436
454
  service.describe_collection.assert_called_once_with("http://localhost:8000", "unknown")
455
+ service.get_queryables.assert_not_called()
437
456
 
438
457
 
439
458
  def test_collection_queryables_provider_failure_returns_server_error(
@@ -28,6 +28,10 @@ if TYPE_CHECKING:
28
28
  class EmptyCatalogueService(StacApiService):
29
29
  """Exercise inherited metadata using a concrete empty catalogue."""
30
30
 
31
+ def get_queryables(self) -> dict[str, object]:
32
+ """Return an empty queryables document for this test provider."""
33
+ return {"type": "object", "properties": {}, "additionalProperties": False}
34
+
31
35
  def get_collections(self, base_url: str) -> Collections:
32
36
  """Return an empty collection listing."""
33
37
  return Collections(collections=[], links=[])