fastapi
fastapi copied to clipboard
[FEATURE] use form feed in models docstrings to truncate description
It would be nice if the model description text generation work the same way as the path documentation one, by truncating the docstrings at form feed (\f) character if present.
Currently (FastAPI 0.52.0), the full docstrings is included in the OpenAPI schema, which prevents from using it to properly document the class at Python level.
I think this would be a great feature as well!
I believe this is actually a Pydantic issue.
In [19]: from pydantic import BaseModel
In [20]: class Banana(BaseModel):
...: """
...: one
...: \f
...: two
...: """
...:
In [21]: Banana.schema()
Out[21]:
{'title': 'Banana',
'description': 'one\n\x0c\ntwo',
'type': 'object',
'properties': {}}