157 lines
5.9 KiB
Python
157 lines
5.9 KiB
Python
from rest_framework.schemas import AutoSchema
|
||
import coreapi
|
||
import coreschema
|
||
|
||
class SongSchema(AutoSchema):
|
||
def get_serializer_fields(self, path, method):
|
||
if path.endswith('/get_song_history/'):
|
||
return [
|
||
coreapi.Field(
|
||
name='start',
|
||
location='form',
|
||
required=False,
|
||
schema=coreschema.String(description='Начало периода')
|
||
),
|
||
coreapi.Field(
|
||
name='end',
|
||
location='form',
|
||
required=False,
|
||
schema=coreschema.String(description='Конец периода')
|
||
),
|
||
]
|
||
if path.endswith('/add_favorite/'):
|
||
return [
|
||
coreapi.Field(
|
||
name='azura_id',
|
||
location='form',
|
||
required=False,
|
||
schema=coreschema.String(description='ID трека с Азуры')
|
||
),
|
||
coreapi.Field(
|
||
name='title',
|
||
location='form',
|
||
required=False,
|
||
schema=coreschema.String(description='Название трека')
|
||
),
|
||
coreapi.Field(
|
||
name='artist',
|
||
location='form',
|
||
required=False,
|
||
schema=coreschema.String(description='Исполнитель')
|
||
),
|
||
coreapi.Field(
|
||
name='album',
|
||
location='form',
|
||
required=False,
|
||
schema=coreschema.String(description='Альбом трека')
|
||
),
|
||
coreapi.Field(
|
||
name='genre',
|
||
location='form',
|
||
required=False,
|
||
schema=coreschema.String(description='Жанр трека')
|
||
),
|
||
coreapi.Field(
|
||
name='art',
|
||
location='form',
|
||
required=False,
|
||
schema=coreschema.String(description='Изображение трека')
|
||
),
|
||
]
|
||
return []
|
||
|
||
class DeleteSongSchema(AutoSchema):
|
||
def get_serializer_fields(self, path, method):
|
||
return [
|
||
coreapi.Field(
|
||
name='azura_id',
|
||
location='form',
|
||
required=False,
|
||
schema=coreschema.String(description='ID трека с Азуры')
|
||
),
|
||
]
|
||
|
||
class PlayListSchema(AutoSchema):
|
||
def get_serializer_fields(self, path, method):
|
||
if path.endswith('/create_playlist/'):
|
||
return [
|
||
coreapi.Field(
|
||
name='name',
|
||
location='form',
|
||
required=False,
|
||
schema=coreschema.String(description='Название плейлиста')
|
||
),
|
||
coreapi.Field(
|
||
name='playlist_art',
|
||
location='form',
|
||
required=False,
|
||
schema=coreschema.Integer(description='Обложка плейлиста')
|
||
),
|
||
]
|
||
if path.endswith('/delete_song_with_playlist/'):
|
||
return [
|
||
coreapi.Field(
|
||
name='azura_id',
|
||
location='form',
|
||
required=False,
|
||
schema=coreschema.String(description='ID трека с Азуры')
|
||
),
|
||
]
|
||
if path.endswith('/update_playlist/'):
|
||
return [
|
||
coreapi.Field(
|
||
name='name',
|
||
location='form',
|
||
required=False,
|
||
schema=coreschema.String(description='Название плейлиста')
|
||
),
|
||
coreapi.Field(
|
||
name='playlist_art',
|
||
location='form',
|
||
required=False,
|
||
schema=coreschema.Integer(description='Обложка плейлиста')
|
||
),
|
||
]
|
||
|
||
if path.endswith('/add_to_playlist/'):
|
||
return [
|
||
coreapi.Field(
|
||
name='azura_id',
|
||
location='form',
|
||
required=False,
|
||
schema=coreschema.String(description='ID трека с Азуры')
|
||
),
|
||
coreapi.Field(
|
||
name='title',
|
||
location='form',
|
||
required=False,
|
||
schema=coreschema.String(description='Название трека')
|
||
),
|
||
coreapi.Field(
|
||
name='artist',
|
||
location='form',
|
||
required=False,
|
||
schema=coreschema.String(description='Исполнитель')
|
||
),
|
||
coreapi.Field(
|
||
name='album',
|
||
location='form',
|
||
required=False,
|
||
schema=coreschema.String(description='Альбом трека')
|
||
),
|
||
coreapi.Field(
|
||
name='genre',
|
||
location='form',
|
||
required=False,
|
||
schema=coreschema.String(description='Жанр трека')
|
||
),
|
||
coreapi.Field(
|
||
name='art',
|
||
location='form',
|
||
required=False,
|
||
schema=coreschema.String(description='Изображение трека')
|
||
),
|
||
]
|
||
return []
|
||
|
||
|