diff --git a/drf_spectacular/openapi.py b/drf_spectacular/openapi.py index 81a99369..03c0095f 100644 --- a/drf_spectacular/openapi.py +++ b/drf_spectacular/openapi.py @@ -655,8 +655,9 @@ def _map_serializer_field(self, field, direction, bypass_extensions=False): if isinstance(field, serializers.ManyRelatedField): schema = self._map_serializer_field(field.child_relation, direction) # remove hand-over initkwargs applying only to outer scope - schema.pop('description', None) schema.pop('readOnly', None) + if meta.get('description') == schema.get('description'): + schema.pop('description', None) return append_meta(build_array_type(schema), meta) if isinstance(field, (serializers.PrimaryKeyRelatedField, serializers.SlugRelatedField)): diff --git a/tests/test_fields.py b/tests/test_fields.py index 3fb73158..e6a025cb 100644 --- a/tests/test_fields.py +++ b/tests/test_fields.py @@ -35,7 +35,7 @@ class Aux(models.Model): id = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=False) field_foreign = models.ForeignKey('Aux', null=True, on_delete=models.CASCADE) - url = models.URLField(unique=True) + url = models.URLField(unique=True, help_text="URL identifier for Aux") class AuxSerializer(serializers.ModelSerializer): diff --git a/tests/test_fields.yml b/tests/test_fields.yml index a2f21661..4e5ec9d4 100644 --- a/tests/test_fields.yml +++ b/tests/test_fields.yml @@ -127,12 +127,14 @@ components: field_related_slug: type: string format: uri + description: URL identifier for Aux readOnly: true field_related_slug_many: type: array items: type: string format: uri + description: URL identifier for Aux readOnly: true field_related_string: type: string @@ -368,6 +370,7 @@ components: url: type: string format: uri + description: URL identifier for Aux maxLength: 200 field_foreign: type: string