openapi icon indicating copy to clipboard operation
openapi copied to clipboard

Unable to render examples with only readonly properties

Open sevdog opened this issue 1 year ago • 0 comments

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:

https://github.com/sphinx-contrib/openapi/blob/e62e2986b66465e785a7ebd8905d639f1893dedc/sphinxcontrib/openapi/openapi31.py#L214-L236

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.

sevdog avatar Oct 16 '24 09:10 sevdog