sphinx-contrib / openapi

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

Unexpected KeyError with simple descriptor #92

Open vroyer opened 4 years ago

vroyer commented 4 years ago

sphinx 2.4.4 + sphinxcontrib-openapi in /usr/local/lib/python3.7/site-packages (0.7.0)

test-0.1.yml:

openapi: 3.0.1
info:
  title: the title
  description: A nice API
  contact:
    name: Fred
    url: https://gigantic-server.com
    email: Fred@gigagantic-server.com
  license:
    name: Apache 2.0
    url: https://foo.bar
  version: "v1.1"

RST file content:

.. openapi:: test-0.1.yml

sphinx-build -b html -d build/doctrees source build/html Running Sphinx v2.4.4 making output directory... done building [mo]: targets for 0 po files that are out of date building [html]: targets for 11 source files that are out of date updating environment: [new config] 11 added, 0 changed, 0 removed reading sources... [ 72%] operator-setup Exception occurred: File "/usr/local/lib/python3.7/site-packages/sphinxcontrib/openapi/utils.py", line 105, in normalize_spec for endpoint in spec['paths'].values(): KeyError: 'paths' The full traceback has been saved in /var/folders/kw/y4ys06qn4bx8lww9yszq5h480000gn/T/sphinx-err-xwso7dyr.log, if you want to report the issue to the developers. Please also report this if it was a user error, so that a better error message can be provided next time. A bug report can be filed in the tracker at https://github.com/sphinx-doc/sphinx/issues. Thanks!

log file:

...
  File "/usr/local/lib/python3.7/site-packages/docutils/parsers/rst/states.py", line 196, in run
    results = StateMachineWS.run(self, input_lines, input_offset)
  File "/usr/local/lib/python3.7/site-packages/docutils/statemachine.py", line 239, in run
    context, state, transitions)
  File "/usr/local/lib/python3.7/site-packages/docutils/statemachine.py", line 460, in check_line
    return method(match, context, next_state)
  File "/usr/local/lib/python3.7/site-packages/docutils/parsers/rst/states.py", line 2344, in explicit_markup
    nodelist, blank_finish = self.explicit_construct(match)
  File "/usr/local/lib/python3.7/site-packages/docutils/parsers/rst/states.py", line 2356, in explicit_construct
    return method(self, expmatch)
  File "/usr/local/lib/python3.7/site-packages/docutils/parsers/rst/states.py", line 2099, in directive
    directive_class, match, type_name, option_presets)
  File "/usr/local/lib/python3.7/site-packages/docutils/parsers/rst/states.py", line 2148, in run_directive
    result = directive_instance.run()
  File "/usr/local/lib/python3.7/site-packages/sphinxcontrib/openapi/directive.py", line 56, in run
    return renderer_cls(self.state, self.options).render(spec)
  File "/usr/local/lib/python3.7/site-packages/sphinxcontrib/openapi/renderers/abc.py", line 40, in render
    for line in self.render_restructuredtext_markup(spec):
  File "/usr/local/lib/python3.7/site-packages/sphinxcontrib/openapi/renderers/_httpdomain_old.py", line 42, in render_restructuredtext_markup
    utils.normalize_spec(spec, **self._options)
  File "/usr/local/lib/python3.7/site-packages/sphinxcontrib/openapi/utils.py", line 105, in normalize_spec
    for endpoint in spec['paths'].values():
KeyError: 'paths'