Infer description from property docstring

This commit is contained in:
Charles Cunningham 2020-05-28 09:07:15 -04:00
parent acbd9d8222
commit 37082a29bc

View File

@ -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",