feat(docs): Add some initial structure to schema

This commit is contained in:
Ciarán Ainsworth 2023-11-16 02:38:34 +01:00
parent 169cd69a46
commit 4416daebd2
No known key found for this signature in database
1 changed files with 661 additions and 143 deletions

View File

@ -1,4 +1,4 @@
openapi: "3.0.3"
openapi: "3.1.0"
info:
description: "Interactive documentation for [Funkwhale](https://funkwhale.audio) API."
version: "2.0.0"
@ -21,11 +21,40 @@ servers:
- "https"
default: "https"
tags:
- name: Collections
- name: History
- name: Instance
description: Information about the server
- name: Content
description: Information about content on the server
- name: Recordings
- name: Releases
- name: Tags
paths:
/api/v2/collections:
get:
tags:
- Collections
summary: Retrieve a list of collections from the server
description: Retrieve a list of collections stored on the server
operationId: getCollection
parameters:
- $ref: "#/components/parameters/query"
- $ref: "#/components/parameters/pageParam"
- $ref: "#/components/parameters/pageSizeParam"
responses:
"200":
description: Successful operation
content:
application/json:
schema:
allOf:
- $ref: "#/components/schemas/Pagination"
- type: object
required:
- results
properties:
results:
type: array
items:
$ref: "#/components/schemas/Collection"
/api/v2/instance/nodeinfo/2.1:
get:
tags:
@ -40,37 +69,161 @@ paths:
application/json:
schema:
$ref: "#/components/schemas/Nodeinfo"
application/xml:
"401":
$ref: "#/components/responses/Unauthorized"
/api/v2/recordings:
get:
tags:
- Recordings
summary: Retrieve a list of recordings
description: Retrieve a list of recordings uploaded to the server
operationId: getRecordings
parameters:
- $ref: "#/components/parameters/query"
- $ref: "#/components/parameters/pageParam"
- $ref: "#/components/parameters/pageSizeParam"
- name: release
in: query
required: false
description: Filter recordings by their associated release
schema:
type: string
- name: artist
in: query
required: false
description: Filter recordings by their associated artist
schema:
type: string
- name: id
in: query
required: false
description: Filter recordings by ID
schema:
type: array
items:
type: string
- name: collection
in: query
required: false
description: Filter recordings by collection ID
schema:
type: string
format: uuid
- name: mbid
in: query
required: false
description: Filter recordings by MusicBrainz ID
schema:
type: array
items:
type: string
responses:
"200":
description: Successful operation
content:
application/json:
schema:
$ref: "#/components/schemas/Nodeinfo"
allOf:
- $ref: "#/components/schemas/Pagination"
- type: object
required:
- results
properties:
results:
type: array
items:
$ref: "#/components/schemas/Recording"
"401":
$ref: "#/components/responses/Unauthorized"
/api/v2/releases:
get:
tags:
- Releases
summary: Retrieve information about releases on the server
description: Retrieve a list of releases on the pod
operationId: getReleases
parameters:
- $ref: "#/components/parameters/query"
- $ref: "#/components/parameters/pageParam"
- $ref: "#/components/parameters/pageSizeParam"
- name: artist
in: query
required: false
description: Filter releases by artist
schema:
type: integer
- name: id
in: query
required: false
description: Filter releases by ID
schema:
type: array
items:
type: string
- name: collection
in: query
required: false
description: Filter releases by collection ID
schema:
type: string
format: uuid
- name: mbid
in: query
required: false
description: Filter recordings by MusicBrainz ID
schema:
type: array
items:
type: string
responses:
"200":
description: Successful operation
content:
application/json:
schema:
allOf:
- $ref: "#/components/schemas/Pagination"
- type: object
required:
- results
properties:
results:
type: array
items:
$ref: "#/components/schemas/Release"
post:
tags:
- Releases
summary: Add a new release to the server
description: Add a new release object to the server
operationId: postRelease
requestBody:
description: The release information you want to upload
required: true
content:
application/json:
schema:
$ref: "#/components/schemas/CreateRelease"
responses:
"200":
description: Successful operation
content:
application/json:
schema:
$ref: "#/components/schemas/SimpleRelease"
"401":
$ref: "#/components/responses/Unauthorized"
/api/v2/tags/podcasts:
get:
tags:
- Content
- Tags
summary: Retrieve podcast categories
description: Retrieve a list of podcast categories and the number of uploads tagged with those categories
operationId: getTagsPodcasts
parameters:
- name: q
in: query
required: false
description: A free text field to filter category names
schema:
type: string
- name: page
in: query
required: false
description: The number of the result page you want to return
schema:
type: number
- name: page_size
in: query
required: false
description: The number of results to return on each page. Defaults to 50.
schema:
type: number
- $ref: "#/components/parameters/query"
- $ref: "#/components/parameters/pageParam"
- $ref: "#/components/parameters/pageSizeParam"
- name: ordering
in: query
required: false
@ -91,18 +244,24 @@ paths:
content:
application/json:
schema:
$ref: "#/components/schemas/Categories"
application/xml:
schema:
$ref: "#/components/schemas/Categories"
allOf:
- $ref: "#/components/schemas/Pagination"
- type: object
required:
- results
properties:
results:
type: array
items:
$ref: "#/components/schemas/Category"
"401":
$ref: "#/components/responses/Unauthorized"
/api/v2/tags/podcasts/{category}:
get:
tags:
- Content
summary: Retrieve podcast categories
description: Retrieve a list of podcast categories and the number of uploads tagged with those categories
- Tags
summary: Retrieve podcasts by category
description: Retrieve all podcasts in a category
operationId: getTagPodcasts
parameters:
- name: category
@ -118,15 +277,12 @@ paths:
application/json:
schema:
$ref: "#/components/schemas/Category"
application/xml:
schema:
$ref: "#/components/schemas/Category"
"401":
$ref: "#/components/responses/Unauthorized"
/api/v2/tags/music:
get:
tags:
- Content
- Tags
summary: Retrieve music genres
description: Retrieve a list of music genres and the number of uploads tagged with those categories
operationId: getTagsMusic
@ -137,18 +293,8 @@ paths:
description: A free text field to filter genre names
schema:
type: string
- name: page
in: query
required: false
description: The number of the result page you want to return
schema:
type: number
- name: page_size
in: query
required: false
description: The number of results to return on each page. Defaults to 50.
schema:
type: number
- $ref: "#/components/parameters/pageParam"
- $ref: "#/components/parameters/pageSizeParam"
- name: ordering
in: query
required: false
@ -169,18 +315,24 @@ paths:
content:
application/json:
schema:
$ref: "#/components/schemas/Genres"
application/xml:
schema:
$ref: "#/components/schemas/Genres"
allOf:
- $ref: "#/components/schemas/Pagination"
- type: object
required:
- results
properties:
results:
type: array
items:
$ref: "#/components/schemas/Genre"
"401":
$ref: "#/components/responses/Unauthorized"
/api/v2/tags/music/{genre}:
get:
tags:
- Content
summary: Retrieve podcast categories
description: Retrieve a list of podcast categories and the number of uploads tagged with those categories
- Tags
summary: Retrieve music by genre
description: Retrieve all podcasts in a genre
operationId: getTagMusic
parameters:
- name: genre
@ -196,9 +348,34 @@ paths:
application/json:
schema:
$ref: "#/components/schemas/Genre"
application/xml:
"401":
$ref: "#/components/responses/Unauthorized"
/api/v2/history/listenings:
get:
tags:
- History
summary: Fetch a list of listenings
description: Fetch a list of listenings from public and followed users
operationId: getHistory
parameters:
- $ref: "#/components/parameters/pageParam"
- $ref: "#/components/parameters/pageSizeParam"
responses:
"200":
description: Successful operation
content:
application/json:
schema:
$ref: "#/components/schemas/Genre"
allOf:
- $ref: "#/components/schemas/Pagination"
- type: object
required:
- results
properties:
results:
type: array
items:
$ref: "#/components/schemas/Listening"
"401":
$ref: "#/components/responses/Unauthorized"
components:
@ -209,44 +386,72 @@ components:
application/json:
schema:
$ref: "#/components/schemas/Error"
example:
code: 401
message: User not authorized
application/xml:
schema:
$ref: "#/components/schemas/Error"
example:
code: 401
message: User not authorized
examples:
code:
value: 401
message:
value: User not authorized
parameters:
pageParam:
name: page
in: query
required: false
description: The number of the result page you want to return
schema:
type: number
pageSizeParam:
name: page_size
in: query
required: false
description: The number of results to return on each page. Defaults to 50.
schema:
type: number
default: 50
query:
name: q
in: query
required: false
description: A free text field to filter results
schema:
type: string
schemas:
Categories:
type: object
properties:
total:
type: number
next:
type: string
format: url
previous:
type: string
format: url
results:
type: array
items:
$ref: "#/components/schemas/Category"
example:
total: 5
next: https://demo.funkwhale.audio/api/v2/categories?page=2&page_size=2&q=crime
previous: null
results:
- category: "True Crime"
created_date: "2020-01-01T00:00:00.000Z"
tagged_items: 5
results_page: "https://demo.funkwhale.audio/library/categories/True%20Crime"
- category: "True Stories"
created_date: "2023-12-15T23:32:52.000Z"
tagged_items: 200
results_page: "https://demo.funkwhale.audio/library/categories/True%20Stories"
Actor:
allOf:
- $ref: "#/components/schemas/SimpleActor"
- type: object
properties:
lastFetchDate:
type: string
format: date-time
manuallyApprovesFollowers:
type: boolean
type:
type: string
enum:
- person
- tombstone
- application
- group
- organization
- service
Artist:
allOf:
- $ref: "#/components/schemas/SimpleArtist"
- type: object
properties:
creationDate:
type: string
format: date-time
recordingCount:
type: integer
tags:
type: array
items:
type: string
releases:
type: array
items:
$ref: "#/components/schemas/SimpleRelease"
Category:
type: object
properties:
@ -260,39 +465,90 @@ components:
results_page:
type: string
format: url
example:
category: "True Crime"
created_date: "2020-01-01T00:00:00.000Z"
tagged_items: 5
results_page: "https://demo.funkwhale.audio/library/categories/True%20Crime"
Genres:
Collection:
allOf:
- $ref: "#/components/schemas/SimpleCollection"
- type: object
properties:
items:
type: integer
CoverUrls:
type: object
required:
- uuid
- mimetype
- size
- creationDate
- urls
properties:
total:
type: number
next:
uuid:
type: string
format: url
previous:
format: uuid
mimetype:
type: string
format: url
results:
size:
type: integer
creationDate:
type: string
format: date-time
urls:
type: object
required:
- original
properties:
source:
type: string
format: url
original:
type: string
format: url
CreateRelease:
type: object
required:
- title
- artist
properties:
title:
type: string
releaseDate:
type: string
format: date-time
tags:
type: array
items:
$ref: "#/components/schemas/Genre"
example:
total: 5
next: https://demo.funkwhale.audio/api/v2/categories?page=2&page_size=2&q=rock
previous: null
results:
- genre: "Acoustic Rock"
created_date: "2020-01-01T00:00:00.000Z"
tagged_items: 5
results_page: "https://demo.funkwhale.audio/library/categories/Acoustic%20Rock"
- genre: "Surf Rock"
created_date: "2023-12-15T23:32:52.000Z"
tagged_items: 200
results_page: "https://demo.funkwhale.audio/library/categories/Surf%20Rock"
type: string
type:
$ref: "#/components/schemas/ReleaseTypeEnum"
description:
type: object
required:
- text
- contentType
properties:
text:
type: string
description: A description of the release
contentType:
type: string
enum:
- "text/html"
- "text/markdown"
- "text/plain"
html:
type: string
artist:
type: string
description: The name of the associated artist
Error:
type: object
properties:
code:
type: string
message:
type: string
required:
- code
- message
Genre:
type: object
properties:
@ -306,11 +562,24 @@ components:
results_page:
type: string
format: url
example:
genre: "Acoustic Rock"
created_date: "2020-01-01T00:00:00.000Z"
tagged_items: 5
results_page: "https://demo.funkwhale.audio/library/categories/Acoustic%20Rock"
Listening:
type: object
required:
- guid
- createdDate
- user
- recording
properties:
guid:
type: string
format: uuid
createdDate:
type: string
format: date-time
recording:
$ref: "#/components/schemas/SimpleRecording"
user:
$ref: "#/components/schemas/SimpleUser"
Nodeinfo:
type: object
required:
@ -338,7 +607,8 @@ components:
- "Funkwhale"
version:
type: string
example: "1.4.0"
examples:
- "1.4.0"
repository:
type: string
format: url
@ -365,7 +635,7 @@ components:
- "tent"
- "xmpp"
- "zot"
example:
examples:
- "activitypub"
services:
type: object
@ -505,11 +775,11 @@ components:
type: number
hoursOfContent:
type: number
example:
artists: 1000
releases: 10000
recordings: 150000
hoursOfContent: 7500
examples:
- artists: 1000
releases: 10000
recordings: 150000
hoursOfContent: 7500
topMusicCategories:
type: array
items:
@ -570,23 +840,271 @@ components:
type: array
items:
type: string
example:
examples:
- "channels"
- "podcasts"
- "collections"
- "audiobooks"
- "federation"
- "anonymousCanListen"
Error:
Pagination:
type: object
properties:
code:
type: string
message:
type: string
required:
- code
- message
- total
properties:
total:
type: integer
next:
type: string
format: url
previous:
type: string
format: url
Recording:
allOf:
- $ref: "#/components/schemas/SimpleRecording"
- type: object
required:
- creationDate
- downloadsCount
- attributedTo
properties:
creationDate:
type: string
format: date-time
copyright:
format: string
license:
format: string
tags:
format: array
items:
type: string
mbid:
type: string
format: uuid
downloadsCount:
type: integer
discNumber:
type: integer
position:
type: integer
attributedTo:
$ref: "#/components/schemas/SimpleActor"
collections:
type: array
items:
$ref: "#/components/schemas/SimpleCollection"
Release:
allOf:
- $ref: "#/components/schemas/SimpleRelease"
- type: object
properties:
creationDate:
type: string
format: date-time
releaseDate:
type: string
format: date
recordingCount:
type: integer
duration:
type: integer
attributedTo:
$ref: "#/components/schemas/SimpleActor"
local:
type: boolean
recordings:
type: array
items:
$ref: "#/components/schemas/SimpleRecording"
ReleaseGroup:
type: object
required:
- guid
- artist
- primaryType
properties:
guid:
type: string
format: uuid
artist:
$ref: "#/components/schemas/SimpleArtist"
primaryType:
$ref: "#/components/schemas/ReleaseTypeEnum"
secondaryType:
type: string
enum:
- compilation
- soundtrack
- spokenword
- interview
- audiobook
- audio-drama
- live
- remix
- dj-mix
- mixtape
- demo
- field-recording
releases:
type: array
items:
$ref: "#/components/schemas/SimpleRelease"
ReleaseTypeEnum:
type: string
default: album
description: The type of release
enum:
- album
- single
- ep
- broadcast
- other
SimpleActor:
type: object
required:
- fid
- preferredUsername
- fullUsername
- local
- domain
properties:
fid:
type: string
format: url
url:
type: string
format: url
fullUsername:
type: string
preferredUsername:
type: string
name:
type: string
domain:
type: string
local:
type: boolean
SimpleArtist:
type: object
required:
- id
- fid
- name
- contentCategory
- local
properties:
id:
type: integer
fid:
type: string
format: url
mbid:
type: string
format: uuid
name:
type: string
contentCategory:
type: string
enum:
- music
- podcast
- other
local:
type: boolean
channel:
type: string
format: uuid
SimpleCollection:
type: object
required:
- uuid
- name
- local
- owner
properties:
uuid:
type: string
format: uuid
name:
type: string
local:
type: boolean
owner:
$ref: "#/components/schemas/SimpleActor"
SimpleRecording:
type: object
required:
- id
- fid
- name
- playable
- local
- release
- artist
- cover
properties:
id:
type: integer
fid:
type: string
format: url
name:
type: string
playable:
type: boolean
local:
type: boolean
release:
$ref: "#/components/schemas/SimpleRelease"
artist:
$ref: "#/components/schemas/SimpleArtist"
cover:
$ref: "#/components/schemas/CoverUrls"
SimpleRelease:
type: object
required:
- id
- fid
- name
- local
properties:
id:
type: integer
fid:
type: string
format: url
mbid:
type: string
format: uuid
name:
type: string
playable:
type: boolean
releaseGroup:
type: string
format: uuid
cover:
$ref: "#/components/schemas/CoverUrls"
SimpleUser:
type: object
required:
- id
- username
- fullUsername
- avatar
properties:
id:
type: integer
username:
type: string
fullUsername:
type: string
preferredUsername:
type: string
avatar:
$ref: "#/components/schemas/CoverUrls"
securitySchemes:
oauth2:
type: oauth2
@ -602,7 +1120,7 @@ components:
"read:edits": "Read-only access to edits"
"write:edits": "Write-only access to edits"
"read:favorites": "Read-only access to favorites"
"write:favorites": "Write-only access to favorits"
"write:favorites": "Write-only access to favorites"
"read:filters": "Read-only to to content filters"
"write:filters": "Write-only access to content-filters"
"read:follows": "Read-only to follows"