Skip to content

Commit 22648b1

Browse files
authored
support process output schemas in OpenAPI if exists (#1933)
1 parent 1d592ae commit 22648b1

1 file changed

Lines changed: 19 additions & 0 deletions

File tree

pygeoapi/api/processes.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -743,6 +743,25 @@ def get_oas_30(cfg: dict, locale: str) -> tuple[list[dict[str, str]], dict[str,
743743
}
744744
}
745745
}
746+
747+
try:
748+
first_key = list(p.metadata['outputs'])[0]
749+
p_output = p.metadata['outputs'][first_key]
750+
751+
if p_output.get('schema') is not None:
752+
LOGGER.debug('Adding output schema')
753+
content_media_type = p_output['schema'].pop('contentMediaType', 'application/json') # noqa
754+
paths[f'{process_name_path}/execution']['post']['responses']['200'] = { # noqa
755+
'description': 'Process output schema',
756+
'content': {
757+
content_media_type: {
758+
'schema': p_output['schema']
759+
}
760+
}
761+
}
762+
except (IndexError, KeyError):
763+
LOGGER.debug('No output defined')
764+
746765
if 'example' in p.metadata:
747766
paths[f'{process_name_path}/execution']['post']['requestBody']['content']['application/json']['example'] = p.metadata['example'] # noqa
748767

0 commit comments

Comments
 (0)