sphinx-contrib / sphinx-contrib/openapi

Missing header descriptions in response raise exception

Open
#130 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
126
Forks
88
PR merge metrics
No merged PRs in 30d

Description

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

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Inspect sphinxcontrib/openapi/openapi30.py around line 354, where response header descriptions are converted during documentation generation. Reproduce the AWS API Gateway OPTIONS case with a header lacking a description, then verify generation completes without the KeyError and still handles headers that include descriptions.

Written by the indexing model from the issue text.

Assessment

Tech stack
aws, openapi, python
Domain
api, documentation
Issue type
Bug
Difficulty
1/5
Estimated time
Under an hour
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.