Skip to content

Commit

Permalink
Fix Any serializer type regression breaking Ruby bindings
Browse files Browse the repository at this point in the history
See pulp/pulp_rpm#3639

(cherry picked from commit 5cc3da7)
  • Loading branch information
pedro-psb authored and lubosmj committed Oct 25, 2024
1 parent 0443b86 commit 796d71c
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 3 deletions.
2 changes: 2 additions & 0 deletions CHANGES/+fix-any-type.bugfix
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Fixed the JSONField specification so it doesn't break ruby bindings.
See context [here](https://github.com/pulp/pulp_rpm/issues/3639).
12 changes: 12 additions & 0 deletions pulp_container/app/fields.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
from drf_spectacular.utils import extend_schema_field
from drf_spectacular.types import OpenApiTypes
from rest_framework import serializers


@extend_schema_field(OpenApiTypes.OBJECT)
class JSONObjectField(serializers.JSONField):
"""A drf JSONField override to force openapi schema to use 'object' type.
Not strictly correct, but we relied on that for a long time.
See: https://github.com/tfranzel/drf-spectacular/issues/1095
"""
6 changes: 3 additions & 3 deletions pulp_container/app/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
ValidateFieldsMixin,
)

from pulp_container.app import models
from pulp_container.app import models, fields
from pulp_container.constants import SIGNATURE_TYPE

VALID_SIGNATURE_NAME_REGEX = r"^sha256:[0-9a-f]{64}@[0-9a-f]{32}$"
Expand Down Expand Up @@ -84,11 +84,11 @@ class ManifestSerializer(NoArtifactContentSerializer):
queryset=models.Blob.objects.all(),
)

annotations = serializers.JSONField(
annotations = fields.JSONObjectField(
read_only=True,
help_text=_("Property that contains arbitrary metadata stored inside the image manifest."),
)
labels = serializers.JSONField(
labels = fields.JSONObjectField(
read_only=True,
help_text=_("Property describing metadata stored inside the image configuration"),
)
Expand Down

0 comments on commit 796d71c

Please sign in to comment.