From 37082a29bca1ca16142b2393eaedad679bf17536 Mon Sep 17 00:00:00 2001 From: Charles Cunningham Date: Thu, 28 May 2020 09:07:15 -0400 Subject: [PATCH] Infer description from property docstring --- rest_framework/schemas/openapi.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/rest_framework/schemas/openapi.py b/rest_framework/schemas/openapi.py index 9b3082822..be2e2579e 100644 --- a/rest_framework/schemas/openapi.py +++ b/rest_framework/schemas/openapi.py @@ -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,9 @@ 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 isinstance(model.__dict__[variable], property): + description = getdoc(model.__dict__[variable]) + parameter = { "name": variable, "in": "path",