Skip to content

Commit 26d4ce6

Browse files
authored
OpenAPI: add POST for items endpoints (#2003) (#2113)
1 parent f54a134 commit 26d4ce6

File tree

2 files changed

+40
-19
lines changed

2 files changed

+40
-19
lines changed

pygeoapi/api/itemtypes.py

Lines changed: 39 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1204,28 +1204,48 @@ def get_oas_30(cfg: dict, locale: str) -> tuple[list[dict[str, str]], dict[str,
12041204
}
12051205
}
12061206

1207+
# TODO: update feature POSTs once updated in OGC API - Features
1208+
# https://github.com/opengeospatial/ogcapi-features/issues/771
1209+
paths[items_path]['post'] = {
1210+
'summary': f'Get {title} items with CQL2',
1211+
'description': description,
1212+
'tags': [k],
1213+
'operationId': f'getCQL2{k.capitalize()}Features',
1214+
'requestBody': {
1215+
'description': 'Get items with CQL2',
1216+
'content': {
1217+
'application/json': { # CQL2
1218+
'schema': {
1219+
'$ref': OPENAPI_YAML['cql2']
1220+
}
1221+
}
1222+
},
1223+
'required': True
1224+
},
1225+
'responses': {
1226+
'200': {'$ref': f"{OPENAPI_YAML['oapif-1']}#/components/responses/Features"}, # noqa
1227+
'400': {'$ref': f"{OPENAPI_YAML['oapif-1']}#/components/responses/InvalidParameter"}, # noqa
1228+
'500': {'$ref': f"{OPENAPI_YAML['oapif-1']}#/components/responses/ServerError"} # noqa
1229+
}
1230+
}
1231+
12071232
if p.editable:
12081233
LOGGER.debug('Provider is editable; adding post')
12091234

1210-
paths[items_path]['post'] = {
1211-
'summary': f'Add {title} items',
1212-
'description': description,
1213-
'tags': [k],
1214-
'operationId': f'add{k.capitalize()}Features',
1215-
'requestBody': {
1216-
'description': 'Adds item to collection',
1217-
'content': {
1218-
'application/geo+json': {
1219-
'schema': {}
1220-
}
1221-
},
1222-
'required': True
1223-
},
1224-
'responses': {
1225-
'201': {'description': 'Successful creation'},
1226-
'400': {'$ref': f"{OPENAPI_YAML['oapif-1']}#/components/responses/InvalidParameter"}, # noqa
1227-
'500': {'$ref': f"{OPENAPI_YAML['oapif-1']}#/components/responses/ServerError"} # noqa
1228-
}
1235+
paths[items_path]['post']['operationId'] = f'getCQL2OrAdd{k.capitalize()}Features' # noqa
1236+
1237+
val = paths[items_path]['post']['summary']
1238+
paths[items_path]['post']['summary'] = f'{val} or add item (see media type)' # noqa
1239+
1240+
val = paths[items_path]['post']['requestBody']['description']
1241+
paths[items_path]['post']['requestBody']['description'] = f'{val} or add item to collection' # noqa
1242+
1243+
paths[items_path]['post']['requestBody']['content']['application/geo+json'] = { # noqa
1244+
'schema': {}
1245+
}
1246+
1247+
paths[items_path]['post']['responses']['201'] = {
1248+
'description': 'Successful creation'
12291249
}
12301250

12311251
try:

pygeoapi/openapi.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@
5252
LOGGER = logging.getLogger(__name__)
5353

5454
OPENAPI_YAML = {
55+
'cql2': 'https://schemas.opengis.net/cql2/1.0/cql2.json',
5556
'oapif-1': 'https://schemas.opengis.net/ogcapi/features/part1/1.0/openapi/ogcapi-features-1.yaml', # noqa
5657
'oapif-2': 'https://schemas.opengis.net/ogcapi/features/part2/1.0/openapi/ogcapi-features-2.yaml', # noqa
5758
'oapip': 'https://schemas.opengis.net/ogcapi/processes/part1/1.0/openapi',

0 commit comments

Comments
 (0)