openapi icon indicating copy to clipboard operation
openapi copied to clipboard

ValueError: dictionary update sequence element #0 has length 1; 2 is required

Open stativ opened this issue 8 months ago • 0 comments

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

stativ avatar May 29 '25 09:05 stativ