Skip to content

Commit

Permalink
Fix Any serializer type regression breaking Ruby bindings
Browse files Browse the repository at this point in the history
  • Loading branch information
pedro-psb authored and lubosmj committed Oct 25, 2024
1 parent 98a886f commit 5cc3da7
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 @@ -29,7 +29,7 @@
)

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


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 5cc3da7

Please sign in to comment.