mirror of https://github.com/tiangolo/fastapi.git
♻ Strip empty whitespace from description extracted from docstrings (#2821)
Co-authored-by: Sebastián Ramírez <tiangolo@gmail.com>
This commit is contained in:
parent
f8f5281ef5
commit
f6808e76dc
|
|
@ -409,7 +409,7 @@ class APIRoute(routing.Route):
|
||||||
self.description = description or inspect.cleandoc(self.endpoint.__doc__ or "")
|
self.description = description or inspect.cleandoc(self.endpoint.__doc__ or "")
|
||||||
# if a "form feed" character (page break) is found in the description text,
|
# if a "form feed" character (page break) is found in the description text,
|
||||||
# truncate description text to the content preceding the first "form feed"
|
# truncate description text to the content preceding the first "form feed"
|
||||||
self.description = self.description.split("\f")[0]
|
self.description = self.description.split("\f")[0].strip()
|
||||||
response_fields = {}
|
response_fields = {}
|
||||||
for additional_status_code, response in self.responses.items():
|
for additional_status_code, response in self.responses.items():
|
||||||
assert isinstance(response, dict), "An additional response must be a dict"
|
assert isinstance(response, dict), "An additional response must be a dict"
|
||||||
|
|
|
||||||
|
|
@ -31,7 +31,7 @@ openapi_schema = {
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
"summary": "Create an item",
|
"summary": "Create an item",
|
||||||
"description": "Create an item with all the information:\n\n- **name**: each item must have a name\n- **description**: a long description\n- **price**: required\n- **tax**: if the item doesn't have tax, you can omit this\n- **tags**: a set of unique tag strings for this item\n",
|
"description": "Create an item with all the information:\n\n- **name**: each item must have a name\n- **description**: a long description\n- **price**: required\n- **tax**: if the item doesn't have tax, you can omit this\n- **tags**: a set of unique tag strings for this item",
|
||||||
"operationId": "create_item_items__post",
|
"operationId": "create_item_items__post",
|
||||||
"requestBody": {
|
"requestBody": {
|
||||||
"content": {
|
"content": {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue