I'm trying to use this plugin to integrate an OpenAPI spec in a Sphinx document. However, when using date-time strings in examples I get a build error. An example spec which creates the error would be the following
File "/home/user/.local/share/hatch/env/virtual/docs/0DJxZvn8/docs/lib/python3.12/site-packages/sphinxcontrib/openapi/directive.py", line 56, in run
return renderer_cls(self.state, self.options).render(spec)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/user/.local/share/hatch/env/virtual/docs/0DJxZvn8/docs/lib/python3.12/site-packages/sphinxcontrib/openapi/renderers/abc.py", line 40, in render
for line in self.render_restructuredtext_markup(spec):
File "/home/user/.local/share/hatch/env/virtual/docs/0DJxZvn8/docs/lib/python3.12/site-packages/sphinxcontrib/openapi/renderers/_httpdomain_old.py", line 55, in render_restructuredtext_markup
yield from openapihttpdomain(spec, **self._options)
File "/home/user/.local/share/hatch/env/virtual/docs/0DJxZvn8/docs/lib/python3.12/site-packages/sphinxcontrib/openapi/openapi30.py", line 342, in _httpresource
for line in _example(
File "/home/user/.local/share/hatch/env/virtual/docs/0DJxZvn8/docs/lib/python3.12/site-packages/sphinxcontrib/openapi/openapi30.py", line 211, in _example
example['value'] = json.dumps(
^^^^^^^^^^^
File "/usr/lib/python3.12/json/__init__.py", line 238, in dumps
**kw).encode(obj)
^^^^^^^^^^^
File "/usr/lib/python3.12/json/encoder.py", line 202, in encode
chunks = list(chunks)
^^^^^^^^^^^^
File "/usr/lib/python3.12/json/encoder.py", line 432, in _iterencode
yield from _iterencode_dict(o, _current_indent_level)
File "/usr/lib/python3.12/json/encoder.py", line 406, in _iterencode_dict
yield from chunks
File "/usr/lib/python3.12/json/encoder.py", line 439, in _iterencode
o = _default(o)
^^^^^^^^^^^
File "/usr/lib/python3.12/json/encoder.py", line 180, in default
raise TypeError(f'Object of type {o.__class__.__name__} '
TypeError: Object of type datetime is not JSON serializable
Exception occurred:
File "/usr/lib/python3.12/json/encoder.py", line 180, in default
raise TypeError(f'Object of type {o.__class__.__name__} '
TypeError: Object of type datetime is not JSON serializable
The full traceback has been saved in /tmp/sphinx-err-vn0id8op.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!
I'm trying to use this plugin to integrate an OpenAPI spec in a Sphinx document. However, when using date-time strings in examples I get a build error. An example spec which creates the error would be the following
Trying to use this file results in:
If I replace the
TestDateentry in the example with200001-23T04:56:07.000+00:00the error doesn't get triggered.