Skip to content

Commit

Permalink
Fix openapi schema for created resources
Browse files Browse the repository at this point in the history
  • Loading branch information
mdellweg committed Dec 5, 2024
1 parent ed27c95 commit 5f0146e
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGES/+created_resource_schema.bugfix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fixed the schema definition for created resources.
2 changes: 2 additions & 0 deletions pulpcore/app/serializers/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
NestedHyperlinkedIdentityField,
NestedHyperlinkedRelatedField,
)
from drf_spectacular.utils import extend_schema_field

from pulpcore.app.models import (
Task,
Expand Down Expand Up @@ -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.
Expand Down
4 changes: 2 additions & 2 deletions pulpcore/app/serializers/task.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
from pulpcore.app.util import reverse


class CreatedResourceSerializer(RelatedResourceField):
class CreatedResourceField(RelatedResourceField):
class Meta:
model = models.CreatedResource
fields = []
Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit 5f0146e

Please sign in to comment.