From 300683f2c257882ef0147cbc3f6f12ff77a5faa2 Mon Sep 17 00:00:00 2001 From: Pedro Brochado Date: Tue, 9 Jul 2024 13:54:07 -0300 Subject: [PATCH 1/2] Fix Package fields --- pulp_rpm/app/serializers/package.py | 30 ++++++++++------------------- 1 file changed, 10 insertions(+), 20 deletions(-) diff --git a/pulp_rpm/app/serializers/package.py b/pulp_rpm/app/serializers/package.py index 819fd2078..a2b89018e 100644 --- a/pulp_rpm/app/serializers/package.py +++ b/pulp_rpm/app/serializers/package.py @@ -77,64 +77,54 @@ class PackageSerializer(SingleArtifactContentUploadSerializer, ContentChecksumSe read_only=True, ) - changelogs = serializers.JSONField( + changelogs = serializers.ListField( help_text=_("Changelogs that package contains"), - default="[]", required=False, read_only=True, ) - files = serializers.JSONField( + files = serializers.ListField( help_text=_("Files that package contains"), - default="[]", required=False, read_only=True, ) - requires = serializers.JSONField( + requires = serializers.ListField( help_text=_("Capabilities the package requires"), - default="[]", required=False, read_only=True, ) - provides = serializers.JSONField( + provides = serializers.ListField( help_text=_("Capabilities the package provides"), - default="[]", required=False, read_only=True, ) - conflicts = serializers.JSONField( + conflicts = serializers.ListField( help_text=_("Capabilities the package conflicts"), - default="[]", required=False, read_only=True, ) - obsoletes = serializers.JSONField( + obsoletes = serializers.ListField( help_text=_("Capabilities the package obsoletes"), - default="[]", required=False, read_only=True, ) - suggests = serializers.JSONField( + suggests = serializers.ListField( help_text=_("Capabilities the package suggests"), - default="[]", required=False, read_only=True, ) - enhances = serializers.JSONField( + enhances = serializers.ListField( help_text=_("Capabilities the package enhances"), - default="[]", required=False, read_only=True, ) - recommends = serializers.JSONField( + recommends = serializers.ListField( help_text=_("Capabilities the package recommends"), - default="[]", required=False, read_only=True, ) - supplements = serializers.JSONField( + supplements = serializers.ListField( help_text=_("Capabilities the package supplements"), - default="[]", required=False, read_only=True, ) From d3f53441705fe36f6f1c76cfb3a6c1b4bb126586 Mon Sep 17 00:00:00 2001 From: Pedro Brochado Date: Tue, 9 Jul 2024 14:45:09 -0300 Subject: [PATCH 2/2] Fix Repository json fields --- pulp_rpm/app/serializers/repository.py | 28 ++++++++++++++++++++++---- 1 file changed, 24 insertions(+), 4 deletions(-) diff --git a/pulp_rpm/app/serializers/repository.py b/pulp_rpm/app/serializers/repository.py index 682cf8132..1fda2c2c1 100644 --- a/pulp_rpm/app/serializers/repository.py +++ b/pulp_rpm/app/serializers/repository.py @@ -139,7 +139,7 @@ class RpmRepositorySerializer(RepositorySerializer): ), read_only=True, ) - repo_config = serializers.JSONField( + repo_config = serializers.DictField( required=False, help_text=_("A JSON document describing config.repo file"), ) @@ -402,7 +402,7 @@ class RpmPublicationSerializer(PublicationSerializer): ), read_only=True, ) - repo_config = serializers.JSONField( + repo_config = serializers.DictField( required=False, help_text=_("A JSON document describing config.repo file"), ) @@ -536,13 +536,33 @@ def validate(self, data): return data +copy_config_example = """ +[ + { + "source_repo_version": {{ version-href }}, + "dest_repo": {{ repo-href }}, + "content": [ {{ item-1.href }}, {{ item-2.href }} ] + }, + { + "source_repo_version": {{ version-href }}, + "dest_repo": {{ repo-href }}, + "dest_base_version": 0, + "content": [ {{ item-1.href }}, {{ item-2.href }} ] + } +] +""" + + class CopySerializer(ValidateFieldsMixin, serializers.Serializer): """ A serializer for Content Copy API. """ - config = serializers.JSONField( - help_text=_("A JSON document describing sources, destinations, and content to be copied"), + config = serializers.ListField( + help_text=_( + "A JSON List of Objects describing sources, destinations, and content to be copied. " + f"E.g:\n```{copy_config_example}```" + ), ) dependency_solving = serializers.BooleanField(