From 77d6e80a1b7909f86ac6d0399e720cb991a20cd4 Mon Sep 17 00:00:00 2001 From: Lukas Jirkovsky Date: Thu, 29 May 2025 11:51:59 +0200 Subject: [PATCH] Fix failure when generating examples for allOff when subschema example 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 #166. --- sphinxcontrib/openapi/schema_utils.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/sphinxcontrib/openapi/schema_utils.py b/sphinxcontrib/openapi/schema_utils.py index 2078244..35564d6 100644 --- a/sphinxcontrib/openapi/schema_utils.py +++ b/sphinxcontrib/openapi/schema_utils.py @@ -64,7 +64,11 @@ def example_from_schema(schema): # Combine schema examples example = {} for sub_schema in schema["allOf"]: - example.update(example_from_schema(sub_schema)) + sub_example = example_from_schema(sub_schema) + if isinstance(sub_example, dict): + example.update(sub_example) + else: + return sub_example return example elif "enum" in schema: