sphinx-contrib / sphinx-contrib/openapi
ValueError: dictionary update sequence element #0 has length 1; 2 is required
Open
Beginner friendly
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 126
- Forks
- 88
- PR merge metrics
- No merged PRs in 30d
Description
When allOf refers to schema that is not an object but a string, sphinx-build fails when generating examples with a following error
File "/home/stativ/development/workdir/astra-open-api/.venv/lib/python3.13/site-packages/sphinxcontrib/openapi/schema_utils.py", line 67, in example_from_schema
example.update(example_from_schema(sub_schema))
~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
ValueError: dictionary update sequence element #0 has length 1; 2 is required
Minimal Example
test.yaml
openapi: 3.0.3
info:
version: 1.0.0
title: Bug example
paths:
/test:
get:
responses:
'200':
description: Success.
content:
application/json:
schema:
title: SomeTitle
type: object
properties:
timestamp:
allOf:
- $ref: '#/components/schemas/Timestamp'
components:
schemas:
Timestamp:
type: string
example: 2022-09-12 13:09:16:18
index.rst
.. openapi:: test.yaml
:generate-examples-from-schemas:
SW Versions
- sphinx-openapi commit e2c4473480c9299da8f5f1a43958836c5bd833b2
- sphinx 8.2.3
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in schema_utils.py at example_from_schema, using the supplied test.yaml and index.rst with :generate-examples-from-schemas: to reproduce the failure. Verify the handling of an allOf reference to a string schema, and confirm that sphinx-build completes and generates an example without the dictionary update ValueError.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- openapi, python
- Domain
- documentation
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 72/100