Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Any serializer type regression breaking Ruby bindings #1799

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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