autodoc_pydantic
autodoc_pydantic copied to clipboard
[Feature Request] Print json schema as (collapsible) table
Hi, really love your extension and it makes pydantic
so much more useful. :) Thank you for your work on this.
I was wondering if you had considered adding an option to print the json schema as a table? This would be a nice add-on feature between using erdantic (which makes using the extension more complicated since it adds the graphviz which is not a pure pip-dependency) and displaying the raw json schema.
There is already an extension for sphinx that can convert json schemas into an rst table (sphinx-jsonschema
) and you already have a function to extract the raw json schema - so it might be an easy-to-implement yet useful feature.
@lucaslie thanks for raising the idea and for your kind words ;-).
The table format is more human readable than the currently used nested JSON output. Hence, I suggest it would be meaningful to either output the JSON or the TABLE format in the generated documentation. Outputting both seems awkward. Anyway, what is your exact benefit having a potential table format? I would like to better understand your use case.
Thanks for getting in touch. I am using pydantic to validate a user-provided config. So my main motivation is to have a simple overview with field names and default values at the top of the docs for a pedantic model. So if someone is just looking to make a simple change from the default config, e.g., just change the value of a single field, they can quickly understand how to make that change.
I actually already made a slight modification to your extension that will just print the fields with their default value as json instead of the full json schema. I found that to be useful already.