mirror of
https://github.com/encode/django-rest-framework.git
synced 2025-07-27 16:40:03 +03:00
Infer description from property docstring
This commit is contained in:
parent
acbd9d8222
commit
a00d43be50
|
@ -2,6 +2,7 @@ import re
|
|||
import warnings
|
||||
from collections import OrderedDict
|
||||
from decimal import Decimal
|
||||
from inspect import getdoc
|
||||
from operator import attrgetter
|
||||
from urllib.parse import urljoin
|
||||
|
||||
|
@ -284,6 +285,11 @@ class AutoSchema(ViewInspector):
|
|||
elif model_field is not None and model_field.primary_key:
|
||||
description = get_pk_description(model, model_field)
|
||||
|
||||
if model_field is None and variable in model.__dict__.keys() and \
|
||||
isinstance(model.__dict__[variable], property):
|
||||
doc = getdoc(model.__dict__[variable])
|
||||
description = '' if doc is None else doc
|
||||
|
||||
parameter = {
|
||||
"name": variable,
|
||||
"in": "path",
|
||||
|
|
Loading…
Reference in New Issue
Block a user