From cba1727b4ed102b3abd1bf179fed0df5094f1607 Mon Sep 17 00:00:00 2001 From: petitminion Date: Thu, 24 Apr 2025 23:19:51 +0000 Subject: [PATCH] fix-import-metadata-schema NOCHANGELOG --- api/funkwhale_api/common/schema.yml | 93 +++++++++++++++++++++++-- api/funkwhale_api/manage/serializers.py | 1 + api/funkwhale_api/music/serializers.py | 1 + 3 files changed, 90 insertions(+), 5 deletions(-) diff --git a/api/funkwhale_api/common/schema.yml b/api/funkwhale_api/common/schema.yml index bfafcd68c..b2ec199cf 100644 --- a/api/funkwhale_api/common/schema.yml +++ b/api/funkwhale_api/common/schema.yml @@ -20858,6 +20858,82 @@ components: required: - id - type + ImportMetadata: + type: object + properties: + title: + type: string + maxLength: 500 + description: + type: string + nullable: true + maxLength: 5000 + mbid: + type: string + format: uuid + nullable: true + copyright: + type: string + nullable: true + maxLength: 500 + position: + type: integer + minimum: 1 + nullable: true + tags: + type: array + items: + type: string + minItems: 0 + license: + type: string + nullable: true + required: + - title + ImportMetadataRequest: + type: object + properties: + title: + type: string + minLength: 1 + maxLength: 500 + description: + type: string + nullable: true + minLength: 1 + maxLength: 5000 + mbid: + type: string + format: uuid + nullable: true + copyright: + type: string + nullable: true + minLength: 1 + maxLength: 500 + position: + type: integer + minimum: 1 + nullable: true + tags: + type: array + items: + type: string + minLength: 1 + minItems: 0 + license: + type: string + nullable: true + cover: + type: string + writeOnly: true + nullable: true + album: + type: string + writeOnly: true + nullable: true + required: + - title ImportStatusEnum: enum: - draft @@ -22769,7 +22845,8 @@ components: import_details: {} import_status: $ref: '#/components/schemas/ImportStatusEnum' - import_metadata: {} + import_metadata: + $ref: '#/components/schemas/ImportMetadata' import_reference: type: string maxLength: 50 @@ -22782,6 +22859,7 @@ components: - domain - filename - id + - import_metadata - is_local - library - listen_url @@ -22845,7 +22923,8 @@ components: import_details: {} import_status: $ref: '#/components/schemas/ImportStatusEnum' - import_metadata: {} + import_metadata: + $ref: '#/components/schemas/ImportMetadataRequest' import_reference: type: string minLength: 1 @@ -22857,6 +22936,7 @@ components: required: - audio_file - domain + - import_metadata - library - track ManageUser: @@ -24661,7 +24741,8 @@ components: default: pending privacy_level: $ref: '#/components/schemas/LibraryPrivacyLevelEnum' - import_metadata: {} + import_metadata: + $ref: '#/components/schemas/ImportMetadataRequest' import_reference: type: string minLength: 1 @@ -25788,7 +25869,8 @@ components: $ref: '#/components/schemas/LibraryPrivacyLevelEnum' import_details: readOnly: true - import_metadata: {} + import_metadata: + $ref: '#/components/schemas/ImportMetadata' import_reference: type: string maxLength: 50 @@ -25828,7 +25910,8 @@ components: default: pending privacy_level: $ref: '#/components/schemas/LibraryPrivacyLevelEnum' - import_metadata: {} + import_metadata: + $ref: '#/components/schemas/ImportMetadataRequest' import_reference: type: string minLength: 1 diff --git a/api/funkwhale_api/manage/serializers.py b/api/funkwhale_api/manage/serializers.py index 0ccc86783..16c317d3e 100644 --- a/api/funkwhale_api/manage/serializers.py +++ b/api/funkwhale_api/manage/serializers.py @@ -626,6 +626,7 @@ class ManageUploadSerializer(serializers.ModelSerializer): track = ManageNestedTrackSerializer() library = ManageNestedLibrarySerializer() domain = serializers.CharField(source="domain_name") + import_metadata = music_serializers.ImportMetadataField() class Meta: model = music_models.Upload diff --git a/api/funkwhale_api/music/serializers.py b/api/funkwhale_api/music/serializers.py index 4a8ba7705..4a3111cb3 100644 --- a/api/funkwhale_api/music/serializers.py +++ b/api/funkwhale_api/music/serializers.py @@ -463,6 +463,7 @@ class ImportMetadataSerializer(serializers.Serializer): ) +@extend_schema_field(ImportMetadataSerializer) class ImportMetadataField(serializers.JSONField): def to_internal_value(self, v): v = super().to_internal_value(v)