From bb6a21701bac3183cbf8002c026602384d2c7c0b Mon Sep 17 00:00:00 2001 From: Dennis Kliban Date: Fri, 5 Oct 2018 02:03:01 -0400 Subject: [PATCH] Problem: created resources OpenAPI schema is not specific enough Solution: strongly type created resources as an array of strings This patch changes the CreatedResource serializer to inherit from the RelatedField serializer. This lets the OpenAPI schema generator know that created resources are URI strings. closes: #4053 https://pulp.plan.io/issues/4053 --- pulpcore/pulpcore/app/serializers/task.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/pulpcore/pulpcore/app/serializers/task.py b/pulpcore/pulpcore/app/serializers/task.py index 19c1a6a5fc..b6d3fdc31f 100755 --- a/pulpcore/pulpcore/app/serializers/task.py +++ b/pulpcore/pulpcore/app/serializers/task.py @@ -9,7 +9,7 @@ from .base import viewset_for_model -class CreatedResourceSerializer(ModelSerializer): +class CreatedResourceSerializer(RelatedField): def to_representation(self, data): # If the content object was deleted @@ -79,7 +79,8 @@ class TaskSerializer(ModelSerializer): created_resources = CreatedResourceSerializer( help_text=_('Resources created by this task.'), many=True, - read_only=True + read_only=True, + view_name='None' # This is a polymorphic field. The serializer does not need a view name. ) class Meta: