fastapi icon indicating copy to clipboard operation
fastapi copied to clipboard

[FEATURE] use form feed in models docstrings to truncate description

Open EricPobot opened this issue 4 years ago • 2 comments

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.

EricPobot avatar Mar 06 '20 10:03 EricPobot

I think this would be a great feature as well!

jearistiz avatar Oct 03 '20 14:10 jearistiz

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': {}}

thatguysimon avatar Sep 08 '22 09:09 thatguysimon