Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
stativ opened this issue May 29, 2025 · 0 comments · May be fixed by #167
Open

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

stativ opened this issue May 29, 2025 · 0 comments · May be fixed by #167

Comments

@stativ
Copy link

stativ commented May 29, 2025

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 e2c4473
  • sphinx 8.2.3
stativ pushed a commit to stativ/openapi that referenced this issue May 29, 2025
…e is a plain string.

When an example from a subschema of allOf does not return a dictionary,
return the subschema example directly rather than trying to merge with
the example dictionary.

Fixes sphinx-contrib#166.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy