diff --git a/CHANGES/+created_resource_schema.bugfix b/CHANGES/+created_resource_schema.bugfix new file mode 100644 index 00000000000..5a463a011d9 --- /dev/null +++ b/CHANGES/+created_resource_schema.bugfix @@ -0,0 +1 @@ +Fixed the schema definition for created resources. diff --git a/pulpcore/app/serializers/base.py b/pulpcore/app/serializers/base.py index fc47468e6de..f88b210b04d 100644 --- a/pulpcore/app/serializers/base.py +++ b/pulpcore/app/serializers/base.py @@ -20,6 +20,7 @@ NestedHyperlinkedIdentityField, NestedHyperlinkedRelatedField, ) +from drf_spectacular.utils import extend_schema_field from pulpcore.app.models import ( Task, @@ -176,6 +177,7 @@ def to_representation(self, value): PKDomainObject = namedtuple("PKDomainObject", ["pk", "pulp_domain"]) +@extend_schema_field({"anyOf": [{"type": "null"}, {"type": "string", "format": "uri"}]}) class RelatedResourceField(RelatedField): """RelatedResourceField when relating a Resource object models. diff --git a/pulpcore/app/serializers/task.py b/pulpcore/app/serializers/task.py index f8ae456e7e0..b4f28955faa 100755 --- a/pulpcore/app/serializers/task.py +++ b/pulpcore/app/serializers/task.py @@ -17,7 +17,7 @@ from pulpcore.app.util import reverse -class CreatedResourceSerializer(RelatedResourceField): +class CreatedResourceField(RelatedResourceField): class Meta: model = models.CreatedResource fields = [] @@ -78,7 +78,7 @@ class TaskSerializer(ModelSerializer): view_name="task-groups-detail", ) progress_reports = ProgressReportSerializer(many=True, read_only=True) - created_resources = CreatedResourceSerializer( + created_resources = CreatedResourceField( help_text=_("Resources created by this task."), many=True, read_only=True,