sphinx-contrib / openapi

OpenAPI (fka Swagger) spec renderer for Sphinx.
https://sphinxcontrib-openapi.readthedocs.io
BSD 2-Clause "Simplified" License
111 stars 80 forks source link

Missing header descriptions in response raise exception #130

Open cionz0 opened 2 years ago

cionz0 commented 2 years ago

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():

phofl commented 1 year ago

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