From a00d43be50dfee4acc13a66f2759c181b30981ed 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 | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/rest_framework/schemas/openapi.py b/rest_framework/schemas/openapi.py index 9b3082822..ee42f4b49 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,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",