Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

## [Unreleased]

### Fixed

- Remove defaults in OpenAPI schemas

### Added

- add `enable_direct_response` settings to by-pass Pydantic validation and FastAPI serialization for responses
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,21 +40,21 @@ class BaseCollectionSearchPostRequest(BaseModel):
bbox: Optional[BBox] = Field(
default=None,
description="Only return items intersecting this bounding box. Mutually exclusive with **intersects**.", # noqa: E501
json_schema_extra={
"example": [-175.05, -85.05, 175.05, 85.05],
openapi_examples={
"user-provided": {"value": None},
"Montreal": {"value": "-73.896103,45.364690,-73.413734,45.674283"},
},
)
datetime: Optional[str] = Field(
default=None,
description="""Only return items that have a temporal property that intersects this value.\n
Either a date-time or an interval, open or closed. Date and time expressions adhere to RFC 3339. Open intervals are expressed using double-dots.""", # noqa: E501
json_schema_extra={
"examples": {
"datetime": {"value": "2018-02-12T23:20:50Z"},
"closed-interval": {"value": "2018-02-12T00:00:00Z/2018-03-18T12:31:12Z"},
"open-interval-from": {"value": "2018-02-12T00:00:00Z/.."},
"open-interval-to": {"value": "../2018-03-18T12:31:12Z"},
},
openapi_examples={
"user-provided": {"value": None},
"datetime": {"value": "2018-02-12T23:20:50Z"},
"closed-interval": {"value": "2018-02-12T00:00:00Z/2018-03-18T12:31:12Z"},
"open-interval-from": {"value": "2018-02-12T00:00:00Z/.."},
"open-interval-to": {"value": "../2018-03-18T12:31:12Z"},
},
)
limit: Optional[Limit] = Field(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,9 @@ def _fields_converter(
Optional[str],
Query(
description="Include or exclude fields from items body.",
json_schema_extra={
"example": "properties.datetime",
openapi_examples={
"user-provided": {"value": None},
"datetime": {"value": "properties.datetime"},
},
),
] = None,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,11 @@ class FilterExtensionGetRequest(APIRequest):
description="""A CQL filter expression for filtering items.\n
Supports `CQL-JSON` as defined in https://portal.ogc.org/files/96288\n
Remember to URL encode the CQL-JSON if using GET""",
json_schema_extra={
"example": "id='LC08_L1TP_060247_20180905_20180912_01_T1_L1TP' AND collection='landsat8_l1tp'", # noqa: E501
openapi_examples={
"user-provided": {"value": None},
"landsat8-item": {
"value": "id='LC08_L1TP_060247_20180905_20180912_01_T1_L1TP' AND collection='landsat8_l1tp'" # noqa: E501
},
},
),
] = attr.ib(default=None)
Expand All @@ -51,19 +54,25 @@ class FilterExtensionPostRequest(BaseModel):
default=None,
alias="filter",
description="A CQL filter expression for filtering items.",
json_schema_extra={
"example": {
"op": "and",
"args": [
{
"op": "=",
"args": [
{"property": "id"},
"LC08_L1TP_060247_20180905_20180912_01_T1_L1TP",
],
},
{"op": "=", "args": [{"property": "collection"}, "landsat8_l1tp"]},
],
openapi_examples={
"user-provided": {"value": None},
"landsat8-item": {
"value": {
"op": "and",
"args": [
{
"op": "=",
"args": [
{"property": "id"},
"LC08_L1TP_060247_20180905_20180912_01_T1_L1TP",
],
},
{
"op": "=",
"args": [{"property": "collection"}, "landsat8_l1tp"],
},
],
},
},
},
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,9 @@ def _ft_converter(
Optional[str],
Query(
description="Parameter to perform free-text queries against STAC metadata",
json_schema_extra={
"example": "ocean,coast",
openapi_examples={
"user-provided": {"value": None},
"Coastal": {"value": "ocean,coast"},
},
),
] = None,
Expand Down Expand Up @@ -48,8 +49,9 @@ class FreeTextAdvancedExtensionGetRequest(APIRequest):
Optional[str],
Query(
description="Parameter to perform free-text queries against STAC metadata",
json_schema_extra={
"example": "ocean,coast",
openapi_examples={
"user-provided": {"value": None},
"Coastal": {"value": "ocean,coast"},
},
),
] = attr.ib(default=None)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,9 @@ class QueryExtensionGetRequest(APIRequest):
Optional[str],
Query(
description="Allows additional filtering based on the properties of Item objects", # noqa: E501
json_schema_extra={
"example": '{"eo:cloud_cover": {"gte": 95}}',
openapi_examples={
"user-provided": {"value": None},
"cloudy": {"value": '{"eo:cloud_cover": {"gte": 95}}'},
},
),
] = attr.ib(default=None)
Expand All @@ -31,7 +32,8 @@ class QueryExtensionPostRequest(BaseModel):
query: Optional[Dict[str, Dict[str, Any]]] = Field(
None,
description="Allows additional filtering based on the properties of Item objects", # noqa: E501
json_schema_extra={
"example": {"eo:cloud_cover": {"gte": 95}},
openapi_examples={
"user-provided": {"value": None},
"cloudy": {"value": '{"eo:cloud_cover": {"gte": 95}}'},
},
)
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,10 @@ def _sort_converter(
Optional[str],
Query(
description="An array of property names, prefixed by either '+' for ascending or '-' for descending. If no prefix is provided, '+' is assumed.", # noqa: E501
json_schema_extra={
"example": "-gsd,-datetime",
openapi_examples={
"user-provided": {"value": None},
"resolution": {"value": "-gsd"},
"resolution-and-dates": {"value": "-gsd,-datetime"},
},
),
],
Expand All @@ -38,12 +40,15 @@ class SortExtensionPostRequest(BaseModel):
sortby: Optional[List[PostSortModel]] = Field(
None,
description="An array of property (field) names, and direction in form of '{'field': '<property_name>', 'direction':'<direction>'}'", # noqa: E501
json_schema_extra={
"example": [
{
"field": "properties.created",
"direction": "asc",
}
],
openapi_examples={
"user-provided": {"value": None},
"creation-time": {
"value": [
{
"field": "properties.created",
"direction": "asc",
}
],
},
},
)
19 changes: 13 additions & 6 deletions stac_fastapi/types/stac_fastapi/types/search.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,10 @@ def _collection_converter(
Optional[str],
Query(
description="Array of collection Ids to search for items.",
json_schema_extra={
"example": "collection1,collection2",
openapi_examples={
"user-provided": {"value": None},
"single-collection": {"value": "collection1"},
"multi-collections": {"value": "collection1,collection2"},
},
),
] = None,
Expand All @@ -60,8 +62,10 @@ def _ids_converter(
Optional[str],
Query(
description="Array of Item ids to return.",
json_schema_extra={
"example": "item1,item2",
openapi_examples={
"user-provided": {"value": None},
"single-item": {"value": "item1"},
"multi-items": {"value": "item1,item2"},
},
),
] = None,
Expand All @@ -74,8 +78,9 @@ def _bbox_converter(
Optional[str],
Query(
description="Only return items intersecting this bounding box. Mutually exclusive with **intersects**.", # noqa: E501
json_schema_extra={
"example": "-175.05,-85.05,175.05,85.05",
openapi_examples={
"user-provided": {"value": None},
"Montreal": {"value": "-73.896103,45.364690,-73.413734,45.674283"},
},
),
] = None,
Expand All @@ -99,6 +104,7 @@ def _validate_datetime(instance, attribute, value):
description="""Only return items that have a temporal property that intersects this value.\n
Either a date-time or an interval, open or closed. Date and time expressions adhere to RFC 3339. Open intervals are expressed using double-dots.""", # noqa: E501
openapi_examples={
"user-provided": {"value": None},
"datetime": {"value": "2018-02-12T23:20:50Z"},
"closed-interval": {"value": "2018-02-12T00:00:00Z/2018-03-18T12:31:12Z"},
"open-interval-from": {"value": "2018-02-12T00:00:00Z/.."},
Expand Down Expand Up @@ -162,6 +168,7 @@ class BaseSearchGetRequest(APIRequest, DatetimeMixin):
description="""Only return items intersecting this GeoJSON Geometry. Mutually exclusive with **bbox**. \n
*Remember to URL encode the GeoJSON geometry when using GET request*.""", # noqa: E501
openapi_examples={
"user-provided": {"value": None},
"madrid": {
"value": {
"type": "Feature",
Expand Down
Loading