openapi
openapi copied to clipboard
Allow anyOf in schema
Hello !
I am using the new release with the fix from the PR #143 and there is still an issue iwht anyOf attribute.
Example:
$ make doc
python contrib/openapi.py
rm -Rf docs/_build
sphinx-build docs/ docs/_build/html
Running Sphinx v4.5.0
making output directory... done
checking bibtex cache... out of date
parsing bibtex file /home/cedric/git/SCANDAL/scandale/docs/refs.bib... parsed 8 entries
building [mo]: targets for 0 po files that are out of date
building [html]: targets for 6 source files that are out of date
updating environment: [new config] 6 added, 0 changed, 0 removed
reading sources... [ 50%] formats
Exception occurred:
File "/home/cedric/.cache/pypoetry/virtualenvs/scandale-YR99gNwR-py3.10/lib/python3.10/site-packages/sphinxcontrib/openapi/openapi31.py", line 305, in _get_type_from_schema
for t in schema["anyOf"]:
KeyError: 'anyOf'
The full traceback has been saved in /tmp/sphinx-err-x_7m9qol.log, if you want to report the issue to the developers.
Below is the log file of the execution:
$ cat /tmp/sphinx-err-_2fr90vn.log
# Sphinx version: 4.5.0
# Python version: 3.10.13 (CPython)
# Docutils version: 0.17.1 release
# Jinja2 version: 3.0.3
# Last messages:
# parsing bibtex file /home/cedric/git/SCANDAL/scandale/docs/refs.bib...
# parsed 8 entries
# building [mo]: targets for 0 po files that are out of date
# building [html]: targets for 6 source files that are out of date
# updating environment:
# [new config]
# 6 added, 0 changed, 0 removed
# reading sources... [ 16%] architecture
# reading sources... [ 33%] deployment
# reading sources... [ 50%] formats
# Loaded extensions:
# sphinx.ext.mathjax (4.5.0) from /home/cedric/.cache/pypoetry/virtualenvs/scandale-YR99gNwR-py3.10/lib/python3.10/site-packages/sphinx/ext/mathjax.py
# sphinxcontrib.applehelp (1.0.4) from /home/cedric/.cache/pypoetry/virtualenvs/scandale-YR99gNwR-py3.10/lib/python3.10/site-packages/sphinxcontrib/applehelp/__init__.py
# sphinxcontrib.devhelp (1.0.2) from /home/cedric/.cache/pypoetry/virtualenvs/scandale-YR99gNwR-py3.10/lib/python3.10/site-packages/sphinxcontrib/devhelp/__init__.py
# sphinxcontrib.htmlhelp (2.0.1) from /home/cedric/.cache/pypoetry/virtualenvs/scandale-YR99gNwR-py3.10/lib/python3.10/site-packages/sphinxcontrib/htmlhelp/__init__.py
# sphinxcontrib.serializinghtml (1.1.5) from /home/cedric/.cache/pypoetry/virtualenvs/scandale-YR99gNwR-py3.10/lib/python3.10/site-packages/sphinxcontrib/serializinghtml/__init__.py
# sphinxcontrib.qthelp (1.0.3) from /home/cedric/.cache/pypoetry/virtualenvs/scandale-YR99gNwR-py3.10/lib/python3.10/site-packages/sphinxcontrib/qthelp/__init__.py
# alabaster (0.7.13) from /home/cedric/.cache/pypoetry/virtualenvs/scandale-YR99gNwR-py3.10/lib/python3.10/site-packages/alabaster/__init__.py
# sphinx.ext.autodoc.preserve_defaults (1.0) from /home/cedric/.cache/pypoetry/virtualenvs/scandale-YR99gNwR-py3.10/lib/python3.10/site-packages/sphinx/ext/autodoc/preserve_defaults.py
# sphinx.ext.autodoc.type_comment (4.5.0) from /home/cedric/.cache/pypoetry/virtualenvs/scandale-YR99gNwR-py3.10/lib/python3.10/site-packages/sphinx/ext/autodoc/type_comment.py
# sphinx.ext.autodoc (4.5.0) from /home/cedric/.cache/pypoetry/virtualenvs/scandale-YR99gNwR-py3.10/lib/python3.10/site-packages/sphinx/ext/autodoc/__init__.py
# sphinx_autodoc_typehints (unknown version) from /home/cedric/.cache/pypoetry/virtualenvs/scandale-YR99gNwR-py3.10/lib/python3.10/site-packages/sphinx_autodoc_typehints/__init__.py
# sphinxcontrib.mermaid (4.5.0) from /home/cedric/.cache/pypoetry/virtualenvs/scandale-YR99gNwR-py3.10/lib/python3.10/site-packages/sphinxcontrib/mermaid.py
# sphinxcontrib.bibtex (2.6.1) from /home/cedric/.cache/pypoetry/virtualenvs/scandale-YR99gNwR-py3.10/lib/python3.10/site-packages/sphinxcontrib/bibtex/__init__.py
# sphinxcontrib.httpdomain (unknown version) from /home/cedric/.cache/pypoetry/virtualenvs/scandale-YR99gNwR-py3.10/lib/python3.10/site-packages/sphinxcontrib/httpdomain.py
# sphinxcontrib.openapi (0.8.3) from /home/cedric/.cache/pypoetry/virtualenvs/scandale-YR99gNwR-py3.10/lib/python3.10/site-packages/sphinxcontrib/openapi/__init__.py
# sphinx_book_theme (unknown version) from /home/cedric/.cache/pypoetry/virtualenvs/scandale-YR99gNwR-py3.10/lib/python3.10/site-packages/sphinx_book_theme/__init__.py
# pydata_sphinx_theme (unknown version) from /home/cedric/.cache/pypoetry/virtualenvs/scandale-YR99gNwR-py3.10/lib/python3.10/site-packages/pydata_sphinx_theme/__init__.py
Traceback (most recent call last):
.
.
.
.
File "/home/cedric/.cache/pypoetry/virtualenvs/scandale-YR99gNwR-py3.10/lib/python3.10/site-packages/sphinxcontrib/openapi/renderers/_httpdomain_old.py", line 55, in render_restructuredtext_markup
yield from openapihttpdomain(spec, **self._options)
File "/home/cedric/.cache/pypoetry/virtualenvs/scandale-YR99gNwR-py3.10/lib/python3.10/site-packages/sphinxcontrib/openapi/openapi31.py", line 314, in _httpresource
type_ = _get_type_from_schema(param["schema"])
File "/home/cedric/.cache/pypoetry/virtualenvs/scandale-YR99gNwR-py3.10/lib/python3.10/site-packages/sphinxcontrib/openapi/openapi31.py", line 305, in _get_type_from_schema
for t in schema["anyOf"]:
KeyError: 'anyOf'
The openapi.json file has been generated by FastAPI. See here. Swagger UI and redoc UI are working fine.
The OpenAPI file used is this one: https://github.com/scandale-project/scandale/blob/main/docs/_static/openapi.json
It is also possible to see the logs on ReadTheDocs: https://readthedocs.org/projects/scandale/builds/22900095/
I've just proposed a fix to this issue. Could you see if it can be accepted ? Thanks !
This caused a failure for me as well. The solution above fixed it. A new release with this fix will help me use sphinxcontrib.openapi
What is the plan to release this fix, @cedricbonhomme ?
This caused a failure for me as well. The solution above fixed it. A new release with this fix will help me use sphinxcontrib.openapi
Still waiting for this to be fixed!