fix channel metadata choices schema

This commit is contained in:
Petitminion 2025-04-03 23:53:11 +02:00
parent c7bd63d1c1
commit b5b2ecc9c9
2 changed files with 69 additions and 4 deletions

View File

@ -2,10 +2,12 @@ from django import http
from django.db import transaction
from django.db.models import Count, Prefetch, Q, Sum
from django.utils import timezone
from drf_spectacular.utils import extend_schema, extend_schema_view
from drf_spectacular.utils import extend_schema, extend_schema_view, inline_serializer
from rest_framework import decorators, exceptions, mixins
from rest_framework import permissions as rest_permissions
from rest_framework import response, viewsets
from rest_framework import response
from rest_framework import serializers as rest_serializers
from rest_framework import viewsets
from funkwhale_api.common import locales, permissions, preferences
from funkwhale_api.common import utils as common_utils
@ -210,6 +212,32 @@ class ChannelViewSet(
data = serializers.rss_serialize_channel_full(channel=object, uploads=uploads)
return response.Response(data, status=200)
@extend_schema(
responses=inline_serializer(
name="MetedataChoicesSerializer",
fields={
"language": rest_serializers.ListField(
child=inline_serializer(
name="LanguageItem",
fields={
"value": rest_serializers.CharField(),
"label": rest_serializers.CharField(),
},
)
),
"itunes_category": rest_serializers.ListField(
child=inline_serializer(
name="iTunesCategoryItem",
fields={
"value": rest_serializers.CharField(),
"label": rest_serializers.CharField(),
"children": rest_serializers.CharField(),
},
)
),
},
)
)
@decorators.action(
methods=["get"],
detail=False,

View File

@ -2152,7 +2152,7 @@ paths:
content:
application/json:
schema:
$ref: '#/components/schemas/Channel'
$ref: '#/components/schemas/MetedataChoices'
description: ''
/api/v1/channels/rss-subscribe/:
post:
@ -11653,7 +11653,7 @@ paths:
content:
application/json:
schema:
$ref: '#/components/schemas/Channel'
$ref: '#/components/schemas/MetedataChoices'
description: ''
/api/v2/channels/rss-subscribe/:
post:
@ -20926,6 +20926,16 @@ components:
required:
- channel
- uuid
LanguageItem:
type: object
properties:
value:
type: string
label:
type: string
required:
- label
- value
Library:
type: object
properties:
@ -23146,6 +23156,20 @@ components:
readOnly: true
required:
- tracks
MetedataChoices:
type: object
properties:
language:
type: array
items:
$ref: '#/components/schemas/LanguageItem'
itunes_category:
type: array
items:
$ref: '#/components/schemas/iTunesCategoryItem'
required:
- itunes_category
- language
ModerationTarget:
type: object
properties:
@ -25845,6 +25869,19 @@ components:
minLength: 1
required:
- key
iTunesCategoryItem:
type: object
properties:
value:
type: string
label:
type: string
children:
type: string
required:
- children
- label
- value
securitySchemes:
ApplicationToken:
type: http