Merge pull request #29 from agersant/docs

Added API docs
This commit is contained in:
Antoine Gersant 2019-04-07 17:34:19 -07:00 committed by GitHub
commit 6bcac3338f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
13 changed files with 1204 additions and 0 deletions

BIN
docs/api/favicon-16x16.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 665 B

BIN
docs/api/favicon-32x32.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 628 B

60
docs/api/index.html Normal file
View file

@ -0,0 +1,60 @@
<!-- HTML for static distribution bundle build -->
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Swagger UI</title>
<link rel="stylesheet" type="text/css" href="./swagger-ui.css" >
<link rel="icon" type="image/png" href="./favicon-32x32.png" sizes="32x32" />
<link rel="icon" type="image/png" href="./favicon-16x16.png" sizes="16x16" />
<style>
html
{
box-sizing: border-box;
overflow: -moz-scrollbars-vertical;
overflow-y: scroll;
}
*,
*:before,
*:after
{
box-sizing: inherit;
}
body
{
margin:0;
background: #fafafa;
}
</style>
</head>
<body>
<div id="swagger-ui"></div>
<script src="./swagger-ui-bundle.js"> </script>
<script src="./swagger-ui-standalone-preset.js"> </script>
<script>
window.onload = function() {
// Begin Swagger UI call region
const ui = SwaggerUIBundle({
url: "./polaris-api.json",
dom_id: '#swagger-ui',
deepLinking: true,
presets: [
SwaggerUIBundle.presets.apis,
SwaggerUIStandalonePreset
],
plugins: [
SwaggerUIBundle.plugins.DownloadUrl
],
layout: "StandaloneLayout"
})
// End Swagger UI call region
window.ui = ui
}
</script>
</body>
</html>

View file

@ -0,0 +1,67 @@
<!doctype html>
<html lang="en-US">
<body onload="run()">
</body>
</html>
<script>
'use strict';
function run () {
var oauth2 = window.opener.swaggerUIRedirectOauth2;
var sentState = oauth2.state;
var redirectUrl = oauth2.redirectUrl;
var isValid, qp, arr;
if (/code|token|error/.test(window.location.hash)) {
qp = window.location.hash.substring(1);
} else {
qp = location.search.substring(1);
}
arr = qp.split("&")
arr.forEach(function (v,i,_arr) { _arr[i] = '"' + v.replace('=', '":"') + '"';})
qp = qp ? JSON.parse('{' + arr.join() + '}',
function (key, value) {
return key === "" ? value : decodeURIComponent(value)
}
) : {}
isValid = qp.state === sentState
if ((
oauth2.auth.schema.get("flow") === "accessCode"||
oauth2.auth.schema.get("flow") === "authorizationCode"
) && !oauth2.auth.code) {
if (!isValid) {
oauth2.errCb({
authId: oauth2.auth.name,
source: "auth",
level: "warning",
message: "Authorization may be unsafe, passed state was changed in server Passed state wasn't returned from auth server"
});
}
if (qp.code) {
delete oauth2.state;
oauth2.auth.code = qp.code;
oauth2.callback({auth: oauth2.auth, redirectUrl: redirectUrl});
} else {
let oauthErrorMsg
if (qp.error) {
oauthErrorMsg = "["+qp.error+"]: " +
(qp.error_description ? qp.error_description+ ". " : "no accessCode received from the server. ") +
(qp.error_uri ? "More info: "+qp.error_uri : "");
}
oauth2.errCb({
authId: oauth2.auth.name,
source: "auth",
level: "error",
message: oauthErrorMsg || "[Authorization failed]: no accessCode received from the server"
});
}
} else {
oauth2.callback({auth: oauth2.auth, token: qp, isValid: isValid, redirectUrl: redirectUrl});
}
window.close();
}
</script>

954
docs/api/polaris-api.json Normal file
View file

@ -0,0 +1,954 @@
{
"openapi": "3.0.0",
"info": {
"description": "",
"version": "3.0",
"title": "Polaris",
"termsOfService": ""
},
"tags": [
{
"name": "Collection",
"description": "Browsing the music collection"
},
{
"name": "Last.fm",
"description": "Integrating with Last.fm"
},
{
"name": "Settings",
"description": "Managing the polaris installation"
},
{
"name": "Playlists",
"description": "Managing playlists"
},
{
"name": "Other"
}
],
"paths": {
"/version": {
"get": {
"tags": ["Other"],
"summary": "Returns which API version this server implements",
"operationId": "getVersion",
"responses": {
"200": {
"description": "Successful operation",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/Version"
}
}
}
}
}
}
},
"/initial_setup": {
"get": {
"tags": ["Other"],
"summary": "Returns the current state of the initial setup flow",
"operationId": "getInitialSetup",
"responses": {
"200": {
"description": "Successful operation",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/InitialSetup"
}
}
}
}
}
}
},
"/trigger_index": {
"post": {
"tags": ["Other"],
"summary": "Begins or queues a crawl of the music collection",
"operationId": "postTriggerIndex",
"responses": {
"200": {
"description": "Successful operation"
}
},
"security": [
{
"admin_http_header": [],
"admin_cookie": []
}
]
}
},
"/settings": {
"get": {
"tags": ["Settings"],
"summary": "Reads the existing server configuration",
"operationId": "getSettings",
"responses": {
"200": {
"description": "Successful operation",
"content": {
"application/json": {
"schema": {
"$ref": "#components/schemas/Config"
}
}
}
}
},
"security": [
{
"admin_http_header": [],
"admin_cookie": []
}
]
},
"put": {
"tags": ["Settings"],
"summary": "Overwrites the server configuration",
"operationId": "getSettings",
"requestBody": {
"required": true,
"content": { "application/json": { "schema": { "$ref": "#components/schemas/Config" } } }
},
"responses": {
"200": {
"description": "Successful operation"
}
},
"security": [
{
"admin_http_header": [],
"admin_cookie": []
}
]
}
},
"/preferences": {
"get": {
"tags": ["Settings"],
"summary": "Reads the preferences of the current user",
"operationId": "getPreferences",
"responses": {
"200": {
"description": "Successful operation",
"content": {
"application/json": {
"schema": {
"$ref": "#components/schemas/Preferences"
}
}
}
}
},
"security": [
{
"auth_http_header": [],
"auth_cookie": []
}
]
}
},
"/auth": {
"post": {
"tags": ["Other"],
"summary": "Returns information about user permissions and a session cookie for future authenticated requests.",
"operationId": "postAuth",
"requestBody": {
"required": true,
"content": { "application/json": { "schema": { "$ref": "#components/schemas/AuthCredentials" } } }
},
"responses": {
"200": {
"description": "Successful operation",
"content": { "application/json": { "schema": { "$ref":"#components/schemas/AuthOutput" } } }
},
"401": {
"description": "Invalid credentials"
}
}
}
},
"/browse": {
"get": {
"tags": ["Collection"],
"summary": "Reads the content of the top-level directory in the music collection",
"operationId": "getBrowse",
"responses": {
"200": {
"description": "Successful operation",
"content": {
"application/json": {
"schema": {
"type": "array",
"items": {
"$ref": "#/components/schemas/CollectionFile"
}
}
}
}
}
},
"security": [
{
"auth_http_header": [],
"auth_cookie": []
}
]
}
},
"/browse/{location}": {
"get": {
"tags": ["Collection"],
"summary": "Reads the content of a directory in the music collection",
"operationId": "getBrowsePath",
"parameters": [
{
"name": "location",
"in": "path",
"description": "Path to the collection directory begin explored",
"schema": {
"type": "string"
}
}
],
"responses": {
"200": {
"description": "Successful operation",
"content": {
"application/json": {
"schema": {
"type": "array",
"items": {
"$ref": "#/components/schemas/CollectionFile"
}
}
}
}
}
},
"security": [
{
"auth_http_header": [],
"auth_cookie": []
}
]
}
},
"/flatten": {
"get": {
"tags": ["Collection"],
"summary": "Recursively lists all the songs in the music collection",
"operationId": "getFlatten",
"responses": {
"200": {
"description": "Successful operation",
"content": {
"application/json": {
"schema": {
"type": "array",
"items": {
"$ref": "#/components/schemas/Song"
}
}
}
}
}
},
"security": [
{
"auth_http_header": [],
"auth_cookie": []
}
]
}
},
"/flatten/{location}": {
"get": {
"tags": ["Collection"],
"summary": "Recursively lists all the songs within a directory of the music collection",
"operationId": "getFlattenPath",
"parameters": [
{
"name": "location",
"in": "path",
"description": "Path to the collection directory begin explored",
"schema": {
"type": "string"
}
}
],
"responses": {
"200": {
"description": "Successful operation",
"content": {
"application/json": {
"schema": {
"type": "array",
"items": {
"$ref": "#/components/schemas/Song"
}
}
}
}
}
},
"security": [
{
"auth_http_header": [],
"auth_cookie": []
}
]
}
},
"/random": {
"get": {
"tags": ["Collection"],
"summary": "Returns a list of random albums",
"operationId": "getRandom",
"responses": {
"200": {
"description": "Successful operation",
"content": {
"application/json": {
"schema": {
"type": "array",
"items": {
"$ref": "#/components/schemas/Directory"
}
}
}
}
}
},
"security": [
{
"auth_http_header": [],
"auth_cookie": []
}
]
}
},
"/recent": {
"get": {
"tags": ["Collection"],
"summary": "Returns the albums most recently added to the collection",
"operationId": "getRecent",
"responses": {
"200": {
"description": "Successful operation",
"content": {
"application/json": {
"schema": {
"type": "array",
"items": {
"$ref": "#/components/schemas/Directory"
}
}
}
}
}
},
"security": [
{
"auth_http_header": [],
"auth_cookie": []
}
]
}
},
"/search/{query}": {
"get": {
"tags": ["Collection"],
"summary": "Searches for songs and directories",
"operationId": "getSearch",
"parameters": [
{
"name": "query",
"in": "path",
"description": "Search query used to filter results",
"schema": {
"type": "string"
}
}
],
"responses": {
"200": {
"description": "Successful operation",
"content": {
"application/json": {
"schema": {
"type": "array",
"items": {
"$ref": "#/components/schemas/CollectionFile"
}
}
}
}
}
},
"security": [
{
"auth_http_header": [],
"auth_cookie": []
}
]
}
},
"/serve/{file}": {
"get": {
"tags": ["Collection"],
"summary": "Access a media file in the collection",
"operationId": "getServe",
"parameters": [
{
"name": "file",
"in": "path",
"description": "Path to the desired file",
"schema": {
"type": "string"
}
}
],
"responses": {
"200": {
"description": "Successful operation",
"content": {
"image/*": { "schema": { "format": "binary" } },
"audio/*": { "schema": { "format": "binary" } }
}
}
},
"security": [
{
"auth_http_header": [],
"auth_cookie": []
}
]
}
},
"/playlists": {
"get": {
"tags": ["Playlists"],
"summary": "Lists the playlists belonging to the current user",
"operationId": "getPlaylists",
"responses": {
"200": {
"description": "Successful operation",
"content": {
"application/json": {
"schema": {
"type": "array",
"items": {
"$ref": "#/components/schemas/ListPlaylistsEntry"
}
}
}
}
}
},
"security": [
{
"auth_http_header": [],
"auth_cookie": []
}
]
}
},
"/playlist/{playlistName}": {
"get": {
"tags": ["Playlists"],
"summary": "Reads the content of a playlist",
"operationId": "getPlaylist",
"parameters": [
{
"name": "playlistName",
"in": "path",
"description": "Name of the playlist to read",
"schema": {
"type": "string"
}
}
],
"responses": {
"200": {
"description": "Successful operation",
"content": {
"application/json": {
"schema": {
"type": "array",
"items": {
"$ref": "#/components/schemas/Song"
}
}
}
}
}
},
"security": [
{
"auth_http_header": [],
"auth_cookie": []
}
]
},
"put": {
"tags": ["Playlists"],
"summary": "Saves a playlist",
"operationId": "putPlaylist",
"parameters": [
{
"name": "playlistName",
"in": "path",
"description": "Name of the playlist to save",
"schema": {
"type": "string"
}
}
],
"requestBody": {
"required": true,
"content": {
"application/json":{
"schema": {
"$ref": "#/components/schemas/SavePlaylistInput"
}
}
}
},
"responses": {
"200": {
"description": "Successful operation"
}
},
"security": [
{
"auth_http_header": [],
"auth_cookie": []
}
]
},
"delete": {
"tags": ["Playlists"],
"summary": "Deletes a playlist",
"operationId": "deletePlaylist",
"parameters": [
{
"name": "playlistName",
"in": "path",
"description": "Name of the playlist to delete",
"schema": {
"type": "string"
}
}
],
"responses": {
"200": {
"description": "Successful operation"
}
},
"security": [
{
"auth_http_header": [],
"auth_cookie": []
}
]
}
},
"/lastfm/now_playing/{song}": {
"put": {
"tags": ["Last.fm"],
"summary": "Tells Last.fm the song currently being played",
"operationId": "putLastFMNowPlaying",
"parameters": [
{
"name": "song",
"in": "path",
"description": "Path to the song being played",
"schema": {
"type": "string"
}
}
],
"responses": {
"200": {
"description": "Successful operation"
}
},
"security": [
{
"auth_http_header": [],
"auth_cookie": []
}
]
}
},
"/lastfm/scrobble/{song}": {
"post": {
"tags": ["Last.fm"],
"summary": "Tells Last.fm that a song has been playing for long enough to be scrobbled",
"operationId": "postLastFMScrobble",
"parameters": [
{
"name": "song",
"in": "path",
"description": "Path to the song being played",
"schema": {
"type": "string"
}
}
],
"responses": {
"200": {
"description": "Successful operation"
}
},
"security": [
{
"auth_http_header": [],
"auth_cookie": []
}
]
}
},
"/lastfm/link": {
"get": {
"tags": ["Last.fm"],
"summary": "Links a Polaris user with a Last.fm account.",
"externalDocs": {
"description": "This endpoint is meant to be used as a Last.fm authentication handler, as described here:",
"url": "https://www.last.fm/api/webauth"
},
"operationId": "getLastFMLink",
"parameters": [
{
"name": "token",
"in": "query",
"required": true,
"description": "Last.fm authentication token",
"schema": {
"type": "string"
}
},
{
"name": "content",
"in": "query",
"required": true,
"description": "Base64 encoded HTML content to be returned to the client initiating the link operation",
"schema": {
"type": "string"
}
}
],
"responses": {
"200": {
"description": "Successful operation",
"content": {
"text/html": {
"description": "The same content originally present in the 'content' parameter"
}
}
}
}
},
"delete": {
"tags": ["Last.fm"],
"summary": "Unlinks Polaris user and Last.fm account",
"operationId": "deleteLastFMLink",
"responses": {
"200": {
"description": "Successful operation"
}
},
"security": [
{
"auth_http_header": [],
"auth_cookie": []
}
]
}
}
},
"components": {
"schemas": {
"Version": {
"type": "object",
"properties": {
"major": {
"type": "integer",
"format": "int64",
"example": 3
},
"minor": {
"type": "integer",
"format": "int64",
"example": 0
}
}
},
"InitialSetup": {
"type": "object",
"properties": {
"has_any_users": {
"type": "boolean"
}
}
},
"Config": {
"type": "object",
"properties": {
"album_art_pattern": {
"type": "string",
"example": "^Folder.(png|jpg|jpeg)$"
},
"reindex_every_n_seconds": {
"type": "integer",
"example": 3600
},
"mount_dirs": {
"type": "array",
"items": {
"$ref": "#/components/schemas/MountPoint"
}
},
"prefix_url": {
"type": "string"
},
"users": {
"type": "array",
"items": {
"$ref": "#/components/schemas/ConfigUser"
}
},
"ydns": {
"type": "object",
"properties": {
"host": {
"type": "string",
"example": "yourname.ydns.eu"
},
"username": {
"type": "string",
"example": "you@host.com"
},
"password": {
"type": "string",
"example": "hunter2"
}
}
}
}
},
"ConfigUser": {
"type": "object",
"properties": {
"name": {
"type": "string"
},
"password": {
"type": "string",
"description": "Always blank when this field appear in a server response"
},
"admin": {
"type": "boolean"
}
}
},
"MountPoint": {
"type": "object",
"properties": {
"source": {
"type": "string",
"example": "/mnt/some_drive/music"
},
"name": {
"type": "string",
"example": "My Music"
}
}
},
"Preferences": {
"type": "object",
"properties": {
"lastfm_username": {
"type": "string"
}
}
},
"AuthCredentials": {
"type": "object",
"properties": {
"username": {
"type": "string"
},
"password": {
"type": "string"
}
}
},
"AuthOutput": {
"type": "object",
"properties": {
"admin": {
"type": "boolean"
}
}
},
"CollectionFile": {
"oneOf": [
{
"$ref": "#/components/schemas/CollectionFileDirectory"
},
{
"$ref": "#/components/schemas/CollectionFileSong"
}
]
},
"CollectionFileDirectory": {
"type": "object",
"properties": {
"Directory": {
"$ref": "#/components/schemas/Directory"
}
}
},
"CollectionFileSong": {
"type": "object",
"properties": {
"Song": {
"$ref": "#/components/schemas/Song"
}
}
},
"Directory": {
"type": "object",
"properties": {
"path": {
"type": "string",
"example": "My Music/Metal/Stratovarius/Destiny",
"required": true
},
"artist": {
"type": "string",
"example": "Stratovarius"
},
"year": {
"type": "integer",
"example": 1998
},
"album": {
"type": "string",
"example": "Destiny"
},
"artwork": {
"type": "string",
"example": "My Music/Metal/Stratovarius/Destiny/Folder.png"
},
"date_added": {
"type": "integer",
"example": 1453179635,
"required": true
}
}
},
"Song": {
"type": "object",
"properties": {
"path": {
"type": "string",
"example": "My Music/Metal/Stratovarius/Destiny/Anthem of the World.mp3",
"required": true
},
"track_number": {
"type": "integer",
"example": 9
},
"disc_number": {
"type": "integer",
"example": 1
},
"title": {
"type": "string",
"example": "Anthem of the World"
},
"artist": {
"type": "string",
"example": "Stratovarius"
},
"album_artist": {
"type": "string",
"example": null
},
"year": {
"type": "integer",
"example": 1998
},
"album": {
"type": "string",
"example": "Destiny"
},
"artwork": {
"type": "string",
"example": "My Music/Metal/Stratovarius/Destiny/Folder.png"
},
"duration": {
"type": "integer",
"example": 571
}
}
},
"ListPlaylistsEntry": {
"type": "object",
"properties": {
"name": {
"type": "string",
"example": "Friday Chill"
}
}
},
"SavePlaylistInput": {
"type": "object",
"properties": {
"tracks": {
"type": "array",
"items": {
"type": "string",
"example": "My Music/Metal/Stratovarius/Destiny/Anthem of the World.mp3"
}
}
}
}
},
"securitySchemes": {
"auth_http_header": {
"type": "http",
"scheme": "basic"
},
"auth_cookie": {
"type": "apikey",
"in": "cookie",
"name": "session",
"description": "A session token obtained returned as a server cookie by making a request via the auth_http_header scheme."
},
"admin_http_header": {
"type": "http",
"scheme": "basic",
"description": "Identical to the auth_http_header scheme but only for users recognized as admin by the Polaris server"
},
"admin_cookie": {
"type": "apikey",
"in": "cookie",
"name": "session",
"description": "Identical to the auth_cookie scheme but only for users recognized as admin by the Polaris server"
}
},
"links": {},
"callbacks": {}
},
"security": []
}

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

3
docs/api/swagger-ui.css Normal file

File diff suppressed because one or more lines are too long

View file

@ -0,0 +1 @@
{"version":3,"sources":[],"names":[],"mappings":"","file":"swagger-ui.css","sourceRoot":""}

9
docs/api/swagger-ui.js Normal file

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long