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