Skip to content

Commit

Permalink
fix OpenAPI generation
Browse files Browse the repository at this point in the history
  • Loading branch information
tomkralidis committed Apr 3, 2024
1 parent 5bd9027 commit df05295
Show file tree
Hide file tree
Showing 10 changed files with 23 additions and 25 deletions.
6 changes: 3 additions & 3 deletions pygeoapi/api/coverages.py
Original file line number Diff line number Diff line change
Expand Up @@ -200,14 +200,14 @@ def get_collection_coverage(
return api.get_format_exception(request)


def get_oas_30(cfg: dict, locale: str) -> tuple[list[str], dict[str, dict]]:
def get_oas_30(cfg: dict, locale: str) -> tuple[list[dict[str, str]], dict[str, dict]]: # noqa
"""
Get OpenAPI fragments
:param cfg: `dict` of configuration
:param locale: `str` of locale
:returns: `tuple` of `list` of tags and `dict` of path objects
:returns: `tuple` of `list` of tag objects, and `dict` of path objects
"""

from pygeoapi.openapi import OPENAPI_YAML, get_visible_collections
Expand Down Expand Up @@ -250,4 +250,4 @@ def get_oas_30(cfg: dict, locale: str) -> tuple[list[str], dict[str, dict]]:
}
}

return [], {'paths': paths}
return [{'name': 'coverages'}], {'paths': paths}
6 changes: 3 additions & 3 deletions pygeoapi/api/environmental_data_retrieval.py
Original file line number Diff line number Diff line change
Expand Up @@ -206,14 +206,14 @@ def get_collection_edr_query(api: API, request: APIRequest,
return headers, HTTPStatus.OK, content


def get_oas_30(cfg: dict, locale: str) -> tuple[list[str], dict[str, dict]]:
def get_oas_30(cfg: dict, locale: str) -> tuple[list[dict[str, str]], dict[str, dict]]: # noqa
"""
Get OpenAPI fragments
:param cfg: `dict` of configuration
:param locale: `str` of locale
:returns: `tuple` of `list` of tags and `dict` of path objects
:returns: `tuple` of `list` of tag objects, and `dict` of path objects
"""

from pygeoapi.openapi import OPENAPI_YAML, get_visible_collections
Expand Down Expand Up @@ -329,4 +329,4 @@ def get_oas_30(cfg: dict, locale: str) -> tuple[list[str], dict[str, dict]]:
}
}

return [], {'paths': paths}
return [{'name': 'edr'}], {'paths': paths}
6 changes: 3 additions & 3 deletions pygeoapi/api/itemtypes.py
Original file line number Diff line number Diff line change
Expand Up @@ -1295,14 +1295,14 @@ def set_content_crs_header(
headers['Content-Crs'] = f'<{content_crs_uri}>'


def get_oas_30(cfg: dict, locale: str) -> tuple[list[str], dict[str, dict]]:
def get_oas_30(cfg: dict, locale: str) -> tuple[list[dict[str, str]], dict[str, dict]]: # noqa
"""
Get OpenAPI fragments
:param cfg: `dict` of configuration
:param locale: `str` of locale
:returns: `tuple` of `list` of tags, and `dict` of path objects
:returns: `tuple` of `list` of tag objects, and `dict` of path objects
"""

from pygeoapi.openapi import OPENAPI_YAML, get_visible_collections
Expand Down Expand Up @@ -1607,4 +1607,4 @@ def get_oas_30(cfg: dict, locale: str) -> tuple[list[str], dict[str, dict]]:
except ProviderTypeError:
LOGGER.debug('collection is not feature/item based')

return [], {'paths': paths}
return [{'name': 'records'}, {'name': 'features'}], {'paths': paths}
6 changes: 3 additions & 3 deletions pygeoapi/api/maps.py
Original file line number Diff line number Diff line change
Expand Up @@ -243,14 +243,14 @@ def get_collection_map_legend(api: API, request: APIRequest,
data, api.pretty_print)


def get_oas_30(cfg: dict, locale: str) -> tuple[list[str], dict[str, dict]]:
def get_oas_30(cfg: dict, locale: str) -> tuple[list[dict[str, str]], dict[str, dict]]: # noqa
"""
Get OpenAPI fragments
:param cfg: `dict` of configuration
:param locale: `str` of locale
:returns: `tuple` of `list` of tags, and `dict` of path objects
:returns: `tuple` of `list` of tag objects, and `dict` of path objects
"""

from pygeoapi.openapi import OPENAPI_YAML, get_visible_collections
Expand Down Expand Up @@ -337,4 +337,4 @@ def get_oas_30(cfg: dict, locale: str) -> tuple[list[str], dict[str, dict]]:
paths[pth]['get']['parameters'].append(
{'$ref': f"{OPENAPI_YAML['oapif-1']}#/components/parameters/datetime"}) # noqa

return [], {'paths': paths}
return [{'name': 'maps'}], {'paths': paths}
6 changes: 3 additions & 3 deletions pygeoapi/api/processes.py
Original file line number Diff line number Diff line change
Expand Up @@ -554,14 +554,14 @@ def delete_job(
return {}, http_status, response


def get_oas_30(cfg: dict, locale: str) -> tuple[list[str], dict[str, dict]]:
def get_oas_30(cfg: dict, locale: str) -> tuple[list[dict[str, str]], dict[str, dict]]: # noqa
"""
Get OpenAPI fragments
:param cfg: `dict` of configuration
:param locale: `str` of locale
:returns: `tuple` of `list` of tags, and `dict` of path objects
:returns: `tuple` of `list` of tag objects, and `dict` of path objects
"""

from pygeoapi.openapi import OPENAPI_YAML
Expand Down Expand Up @@ -737,4 +737,4 @@ def get_oas_30(cfg: dict, locale: str) -> tuple[list[str], dict[str, dict]]:
}
}

return ['jobs'], {'paths': paths}
return [{'name': 'proceses'}, {'name': 'jobs'}], {'paths': paths}
6 changes: 3 additions & 3 deletions pygeoapi/api/stac.py
Original file line number Diff line number Diff line change
Expand Up @@ -224,14 +224,14 @@ def get_stac_path(api: API, request: APIRequest,
return headers, HTTPStatus.OK, stac_data


def get_oas_30(cfg: dict, locale: str) -> tuple[list[str], dict[str, dict]]:
def get_oas_30(cfg: dict, locale: str) -> tuple[list[dict[str, str]], dict[str, dict]]: # noqa
"""
Get OpenAPI fragments
:param cfg: `dict` of configuration
:param locale: `str` of locale
:returns: `tuple` of `list` of tags, and `dict` of path objects
:returns: `tuple` of `list` of tag objects, and `dict` of path objects
"""

LOGGER.debug('setting up STAC')
Expand All @@ -252,4 +252,4 @@ def get_oas_30(cfg: dict, locale: str) -> tuple[list[str], dict[str, dict]]:
}
}
}
return ['stac'], {'paths': paths}
return [{'name': 'stac'}], {'paths': paths}
6 changes: 3 additions & 3 deletions pygeoapi/api/tiles.py
Original file line number Diff line number Diff line change
Expand Up @@ -436,14 +436,14 @@ def tilematrixset(api: API,
return headers, HTTPStatus.OK, to_json(tms, api.pretty_print)


def get_oas_30(cfg: dict, locale: str) -> tuple[list[str], dict[str, dict]]:
def get_oas_30(cfg: dict, locale: str) -> tuple[list[dict[str, str]], dict[str, dict]]: # noqa
"""
Get OpenAPI fragments
:param cfg: `dict` of configuration
:param locale: `str` of locale
:returns: `tuple` of `list` of tags, and `dict` of path objects
:returns: `tuple` of `list` of tag objects, and `dict` of path objects
"""

from pygeoapi.openapi import OPENAPI_YAML, get_visible_collections
Expand Down Expand Up @@ -531,4 +531,4 @@ def get_oas_30(cfg: dict, locale: str) -> tuple[list[str], dict[str, dict]]:
}
}

return [], {'paths': paths}
return [{'name': 'tiles'}], {'paths': paths}
4 changes: 2 additions & 2 deletions pygeoapi/openapi.py
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ def get_oas_30(cfg: dict, fail_on_invalid_collection: bool = True) -> dict:
'x-keywords': l10n.translate(cfg['metadata']['identification']['keywords'], locale_), # noqa
'termsOfService':
cfg['metadata']['identification']['terms_of_service'],
'contact': {
'contact': {
'name': cfg['metadata']['provider']['name'],
'url': cfg['metadata']['provider']['url'],
'email': cfg['metadata']['contact']['email']
Expand Down Expand Up @@ -455,7 +455,7 @@ def get_oas_30(cfg: dict, fail_on_invalid_collection: bool = True) -> dict:

try:
sub_tags, sub_paths = api_module.get_oas_30(cfg, locale_)
oas['paths'].update(sub_paths)
oas['paths'].update(sub_paths['paths'])
oas['tags'].extend(sub_tags)
except Exception as err:
if fail_on_invalid_collection:
Expand Down
1 change: 0 additions & 1 deletion tests/api/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -595,7 +595,6 @@ def test_describe_collections(config, api_):
rsp_headers, code, response = api_.describe_collections(req)
collections = json.loads(response)

print(collections)
assert len(collections) == 2
assert len(collections['collections']) == 9
assert len(collections['links']) == 3
Expand Down
1 change: 0 additions & 1 deletion tests/api/test_coverages.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,6 @@ def test_get_collection_schema(config, api_):

assert 'properties' in schema
assert len(schema['properties']) == 1
print(schema['properties'])
assert schema['properties']['1']['type'] == 'number'
assert schema['properties']['1']['title'] == 'Temperature [C]'

Expand Down

0 comments on commit df05295

Please sign in to comment.