When using the old renderer (since I cannot use the new one due to #124 and I want to keep API docs splitted based on path) with OpenAPI 3.1 and examples enabled there is a problem due to how examples are rendered and guessed:
|
if examples is None: |
|
examples = {} |
|
if not example: |
|
if re.match(r"application/[a-zA-Z\+]*json", content_type) is None: |
|
LOG.info("skipping non-JSON example generation.") |
|
continue |
|
example = _parse_schema(content["schema"], method=method) |
|
|
|
if method is None: |
|
examples["Example response"] = { |
|
"value": example, |
|
} |
|
else: |
|
examples["Example request"] = { |
|
"value": example, |
|
} |
|
|
|
for example in examples.values(): |
|
# According to OpenAPI v3 specs, string examples should be left unchanged |
|
if not isinstance(example["value"], str): |
|
example["value"] = json.dumps( |
|
example["value"], indent=4, separators=(",", ": ") |
|
) |
If no example is provided in the swagger file one is guessed from _parse_schema, but if there are only readonly properties this method returns an object (_READONLY_PROPERTY) which is not serializable. This results in an unhandled exception (TypeError: Object of type object is not JSON serializable) which is not what is intended.
When using the old renderer (since I cannot use the new one due to #124 and I want to keep API docs splitted based on path) with OpenAPI 3.1 and examples enabled there is a problem due to how examples are rendered and guessed:
openapi/sphinxcontrib/openapi/openapi31.py
Lines 214 to 236 in e62e298
If no example is provided in the swagger file one is guessed from
_parse_schema, but if there are only readonly properties this method returns an object (_READONLY_PROPERTY) which is not serializable. This results in an unhandled exception (TypeError: Object of type object is not JSON serializable) which is not what is intended.