mirror of
https://github.com/BreizhHardware/Jellystat.git
synced 2026-01-18 16:27:20 +01:00
updated swagger doc
added hacky code to add param enums to sort field, to fix later
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
const swaggerAutogen = require("swagger-autogen")();
|
||||
const fs = require("fs");
|
||||
|
||||
const outputFile = "./swagger.json";
|
||||
const endpointsFiles = ["./server.js"];
|
||||
@@ -55,4 +56,42 @@ const config = {
|
||||
|
||||
module.exports = config;
|
||||
|
||||
swaggerAutogen(outputFile, endpointsFiles, config);
|
||||
const modifySwaggerFile = (filePath) => {
|
||||
const swaggerData = JSON.parse(fs.readFileSync(filePath, "utf8"));
|
||||
|
||||
const endpointsToModify = ["/api/getHistory", "/api/getLibraryHistory", "/api/getUserHistory", "/api/getItemHistory"]; // Add more endpoints as needed
|
||||
|
||||
endpointsToModify.forEach((endpoint) => {
|
||||
if (swaggerData.paths[endpoint]) {
|
||||
const methods = Object.keys(swaggerData.paths[endpoint]);
|
||||
methods.forEach((method) => {
|
||||
const parameters = swaggerData.paths[endpoint][method].parameters;
|
||||
if (parameters) {
|
||||
parameters.forEach((param) => {
|
||||
if (param.name === "sort") {
|
||||
param.enum = [
|
||||
"UserName",
|
||||
"RemoteEndPoint",
|
||||
"NowPlayingItemName",
|
||||
"Client",
|
||||
"DeviceName",
|
||||
"ActivityDateInserted",
|
||||
"PlaybackDuration",
|
||||
];
|
||||
|
||||
if (endpoint.includes("getHistory") || endpoint.includes("getLibraryHistory")) {
|
||||
param.enum.push("TotalPlays");
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
fs.writeFileSync(filePath, JSON.stringify(swaggerData, null, 2));
|
||||
};
|
||||
|
||||
swaggerAutogen(outputFile, endpointsFiles, config).then(() => {
|
||||
modifySwaggerFile(outputFile);
|
||||
});
|
||||
|
||||
@@ -2022,6 +2022,26 @@
|
||||
"name": "search",
|
||||
"in": "query",
|
||||
"type": "string"
|
||||
},
|
||||
{
|
||||
"name": "sort",
|
||||
"in": "query",
|
||||
"type": "string",
|
||||
"enum": [
|
||||
"UserName",
|
||||
"RemoteEndPoint",
|
||||
"NowPlayingItemName",
|
||||
"Client",
|
||||
"DeviceName",
|
||||
"ActivityDateInserted",
|
||||
"PlaybackDuration",
|
||||
"TotalPlays"
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "desc",
|
||||
"in": "query",
|
||||
"type": "string"
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
@@ -2077,6 +2097,26 @@
|
||||
"in": "query",
|
||||
"type": "string"
|
||||
},
|
||||
{
|
||||
"name": "sort",
|
||||
"in": "query",
|
||||
"type": "string",
|
||||
"enum": [
|
||||
"UserName",
|
||||
"RemoteEndPoint",
|
||||
"NowPlayingItemName",
|
||||
"Client",
|
||||
"DeviceName",
|
||||
"ActivityDateInserted",
|
||||
"PlaybackDuration",
|
||||
"TotalPlays"
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "desc",
|
||||
"in": "query",
|
||||
"type": "string"
|
||||
},
|
||||
{
|
||||
"name": "body",
|
||||
"in": "body",
|
||||
@@ -2149,6 +2189,25 @@
|
||||
"in": "query",
|
||||
"type": "string"
|
||||
},
|
||||
{
|
||||
"name": "sort",
|
||||
"in": "query",
|
||||
"type": "string",
|
||||
"enum": [
|
||||
"UserName",
|
||||
"RemoteEndPoint",
|
||||
"NowPlayingItemName",
|
||||
"Client",
|
||||
"DeviceName",
|
||||
"ActivityDateInserted",
|
||||
"PlaybackDuration"
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "desc",
|
||||
"in": "query",
|
||||
"type": "string"
|
||||
},
|
||||
{
|
||||
"name": "body",
|
||||
"in": "body",
|
||||
@@ -2221,6 +2280,25 @@
|
||||
"in": "query",
|
||||
"type": "string"
|
||||
},
|
||||
{
|
||||
"name": "sort",
|
||||
"in": "query",
|
||||
"type": "string",
|
||||
"enum": [
|
||||
"UserName",
|
||||
"RemoteEndPoint",
|
||||
"NowPlayingItemName",
|
||||
"Client",
|
||||
"DeviceName",
|
||||
"ActivityDateInserted",
|
||||
"PlaybackDuration"
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "desc",
|
||||
"in": "query",
|
||||
"type": "string"
|
||||
},
|
||||
{
|
||||
"name": "body",
|
||||
"in": "body",
|
||||
|
||||
Reference in New Issue
Block a user