openapi icon indicating copy to clipboard operation
openapi copied to clipboard

Missing header descriptions in response raise exception

Open cionz0 opened this issue 3 years ago • 1 comments

In my sample project on AWS I've enabled cors and since then I get this error.

Exception occurred: File "/Users/cionzo/myproject/venv/lib/python3.8/site-packages/sphinxcontrib/openapi/openapi30.py", line 354, in _httpresource for line in convert(header['description']).splitlines(): KeyError: 'description'

It occurs at the point of generating the docs for the OPTIONS method (depending on the cors). The openapi document is generated by aws apigateway, hence I have almost no control on it.

I suggest modifying line 354 of openapi30.py in order to cope with missing header descriptions and using a default value:

for line in convert(header.get('description', '')).splitlines():

cionz0 avatar Oct 09 '22 09:10 cionz0

You can open a pr in https://github.com/phofl/openapi if you like, but will need tests

phofl avatar Nov 30 '22 23:11 phofl