|
1 | | -import inspect |
2 | 1 | import re |
3 | 2 | import typing |
4 | 3 | from operator import attrgetter |
|
23 | 22 | from drf_spectacular.plumbing import ( |
24 | 23 | ComponentRegistry, ResolvedComponent, anyisinstance, append_meta, build_array_type, |
25 | 24 | build_basic_type, build_choice_field, build_object_type, build_parameter_type, error, |
26 | | - follow_field_source, force_instance, get_override, has_override, is_basic_type, is_field, |
27 | | - is_serializer, resolve_regex_path_parameter, safe_ref, warn, |
| 25 | + follow_field_source, force_instance, get_doc, get_override, has_override, is_basic_type, |
| 26 | + is_field, is_serializer, resolve_regex_path_parameter, safe_ref, warn, |
28 | 27 | ) |
29 | 28 | from drf_spectacular.settings import spectacular_settings |
30 | 29 | from drf_spectacular.types import OpenApiTypes |
@@ -171,8 +170,8 @@ def dict_helper(parameters): |
171 | 170 | def get_description(self): |
172 | 171 | """ override this for custom behaviour """ |
173 | 172 | action_or_method = getattr(self.view, getattr(self.view, 'action', self.method.lower()), None) |
174 | | - view_doc = inspect.getdoc(self.view) or '' |
175 | | - action_doc = inspect.getdoc(action_or_method) or '' |
| 173 | + view_doc = get_doc(self.view.__class__) |
| 174 | + action_doc = get_doc(action_or_method) |
176 | 175 | return action_doc or view_doc |
177 | 176 |
|
178 | 177 | def get_summary(self): |
@@ -645,7 +644,7 @@ def _map_basic_serializer(self, serializer, direction): |
645 | 644 | return build_object_type( |
646 | 645 | properties=properties, |
647 | 646 | required=required, |
648 | | - description=inspect.getdoc(serializer), |
| 647 | + description=get_doc(serializer.__class__), |
649 | 648 | ) |
650 | 649 |
|
651 | 650 | def _map_field_validators(self, field, schema): |
|
0 commit comments