Skip to content

Commit

Permalink
safeguard OpenAPI detection on startup (#1650) (#1758)
Browse files Browse the repository at this point in the history
  • Loading branch information
tomkralidis authored Jul 24, 2024
1 parent 3adfdb2 commit b2a8e06
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions pygeoapi/openapi.py
Original file line number Diff line number Diff line change
Expand Up @@ -903,6 +903,17 @@ def load_openapi_document() -> dict:

pygeoapi_openapi = os.environ.get('PYGEOAPI_OPENAPI')

if pygeoapi_openapi is None:
msg = 'PYGEOAPI_OPENAPI environment not set'
LOGGER.error(msg)
raise RuntimeError(msg)

if not os.path.exists(pygeoapi_openapi):
msg = (f'OpenAPI document {pygeoapi_openapi} does not exist. '
'Please generate before starting pygeoapi')
LOGGER.error(msg)
raise RuntimeError(msg)

with open(pygeoapi_openapi, encoding='utf8') as ff:
if pygeoapi_openapi.endswith(('.yaml', '.yml')):
openapi_ = yaml_load(ff)
Expand Down

0 comments on commit b2a8e06

Please sign in to comment.