aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorcrobibero <cody@robibe.ro>2020-08-04 08:27:54 -0600
committercrobibero <cody@robibe.ro>2020-08-04 08:27:54 -0600
commit8f6c2e767906c1d4c62d51ae2e66af1a78edde9a (patch)
tree4e6736c8252b0aeaf7277aa0326852f665d81f4d
parent8385c5459142e69eb4004d32b3d772b998c37b0b (diff)
Remove leading slash from route attributes
-rw-r--r--Emby.Server.Implementations/Services/SwaggerService.cs287
-rw-r--r--Jellyfin.Api/Controllers/ActivityLogController.cs2
-rw-r--r--Jellyfin.Api/Controllers/ApiKeyController.cs2
-rw-r--r--Jellyfin.Api/Controllers/ArtistsController.cs2
-rw-r--r--Jellyfin.Api/Controllers/CollectionController.cs2
-rw-r--r--Jellyfin.Api/Controllers/ItemRefreshController.cs3
-rw-r--r--Jellyfin.Api/Controllers/LibraryStructureController.cs2
-rw-r--r--Jellyfin.Api/Controllers/SearchController.cs2
-rw-r--r--Jellyfin.Api/Controllers/SystemController.cs2
-rw-r--r--Jellyfin.Api/Controllers/TimeSyncController.cs2
-rw-r--r--Jellyfin.Api/Controllers/TvShowsController.cs2
-rw-r--r--Jellyfin.Api/Controllers/UserController.cs2
12 files changed, 11 insertions, 299 deletions
diff --git a/Emby.Server.Implementations/Services/SwaggerService.cs b/Emby.Server.Implementations/Services/SwaggerService.cs
deleted file mode 100644
index 4f011a678..000000000
--- a/Emby.Server.Implementations/Services/SwaggerService.cs
+++ /dev/null
@@ -1,287 +0,0 @@
-#pragma warning disable CS1591
-
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using Emby.Server.Implementations.HttpServer;
-using MediaBrowser.Controller.Net;
-using MediaBrowser.Model.Services;
-
-namespace Emby.Server.Implementations.Services
-{
- [Route("/swagger", "GET", Summary = "Gets the swagger specifications")]
- [Route("/swagger.json", "GET", Summary = "Gets the swagger specifications")]
- public class GetSwaggerSpec : IReturn<SwaggerSpec>
- {
- }
-
- public class SwaggerSpec
- {
- public string swagger { get; set; }
-
- public string[] schemes { get; set; }
-
- public SwaggerInfo info { get; set; }
-
- public string host { get; set; }
-
- public string basePath { get; set; }
-
- public SwaggerTag[] tags { get; set; }
-
- public IDictionary<string, Dictionary<string, SwaggerMethod>> paths { get; set; }
-
- public Dictionary<string, SwaggerDefinition> definitions { get; set; }
-
- public SwaggerComponents components { get; set; }
- }
-
- public class SwaggerComponents
- {
- public Dictionary<string, SwaggerSecurityScheme> securitySchemes { get; set; }
- }
-
- public class SwaggerSecurityScheme
- {
- public string name { get; set; }
-
- public string type { get; set; }
-
- public string @in { get; set; }
- }
-
- public class SwaggerInfo
- {
- public string description { get; set; }
-
- public string version { get; set; }
-
- public string title { get; set; }
-
- public string termsOfService { get; set; }
-
- public SwaggerConcactInfo contact { get; set; }
- }
-
- public class SwaggerConcactInfo
- {
- public string email { get; set; }
-
- public string name { get; set; }
-
- public string url { get; set; }
- }
-
- public class SwaggerTag
- {
- public string description { get; set; }
-
- public string name { get; set; }
- }
-
- public class SwaggerMethod
- {
- public string summary { get; set; }
-
- public string description { get; set; }
-
- public string[] tags { get; set; }
-
- public string operationId { get; set; }
-
- public string[] consumes { get; set; }
-
- public string[] produces { get; set; }
-
- public SwaggerParam[] parameters { get; set; }
-
- public Dictionary<string, SwaggerResponse> responses { get; set; }
-
- public Dictionary<string, string[]>[] security { get; set; }
- }
-
- public class SwaggerParam
- {
- public string @in { get; set; }
-
- public string name { get; set; }
-
- public string description { get; set; }
-
- public bool required { get; set; }
-
- public string type { get; set; }
-
- public string collectionFormat { get; set; }
- }
-
- public class SwaggerResponse
- {
- public string description { get; set; }
-
- // ex. "$ref":"#/definitions/Pet"
- public Dictionary<string, string> schema { get; set; }
- }
-
- public class SwaggerDefinition
- {
- public string type { get; set; }
-
- public Dictionary<string, SwaggerProperty> properties { get; set; }
- }
-
- public class SwaggerProperty
- {
- public string type { get; set; }
-
- public string format { get; set; }
-
- public string description { get; set; }
-
- public string[] @enum { get; set; }
-
- public string @default { get; set; }
- }
-
- public class SwaggerService : IService, IRequiresRequest
- {
- private readonly IHttpServer _httpServer;
- private SwaggerSpec _spec;
-
- public IRequest Request { get; set; }
-
- public SwaggerService(IHttpServer httpServer)
- {
- _httpServer = httpServer;
- }
-
- public object Get(GetSwaggerSpec request)
- {
- return _spec ?? (_spec = GetSpec());
- }
-
- private SwaggerSpec GetSpec()
- {
- string host = null;
- Uri uri;
- if (Uri.TryCreate(Request.RawUrl, UriKind.Absolute, out uri))
- {
- host = uri.Host;
- }
-
- var securitySchemes = new Dictionary<string, SwaggerSecurityScheme>();
-
- securitySchemes["api_key"] = new SwaggerSecurityScheme
- {
- name = "api_key",
- type = "apiKey",
- @in = "query"
- };
-
- var spec = new SwaggerSpec
- {
- schemes = new[] { "http" },
- tags = GetTags(),
- swagger = "2.0",
- info = new SwaggerInfo
- {
- title = "Jellyfin Server API",
- version = "1.0.0",
- description = "Explore the Jellyfin Server API",
- contact = new SwaggerConcactInfo
- {
- name = "Jellyfin Community",
- url = "https://jellyfin.readthedocs.io/en/latest/user-docs/getting-help/"
- }
- },
- paths = GetPaths(),
- definitions = GetDefinitions(),
- basePath = "/jellyfin",
- host = host,
-
- components = new SwaggerComponents
- {
- securitySchemes = securitySchemes
- }
- };
-
- return spec;
- }
-
-
- private SwaggerTag[] GetTags()
- {
- return Array.Empty<SwaggerTag>();
- }
-
- private Dictionary<string, SwaggerDefinition> GetDefinitions()
- {
- return new Dictionary<string, SwaggerDefinition>();
- }
-
- private IDictionary<string, Dictionary<string, SwaggerMethod>> GetPaths()
- {
- var paths = new SortedDictionary<string, Dictionary<string, SwaggerMethod>>();
-
- // REVIEW: this can be done better
- var all = ((HttpListenerHost)_httpServer).ServiceController.RestPathMap.OrderBy(i => i.Key, StringComparer.OrdinalIgnoreCase).ToList();
-
- foreach (var current in all)
- {
- foreach (var info in current.Value)
- {
- if (info.IsHidden)
- {
- continue;
- }
-
- if (info.Path.StartsWith("/mediabrowser", StringComparison.OrdinalIgnoreCase)
- || info.Path.StartsWith("/jellyfin", StringComparison.OrdinalIgnoreCase))
- {
- continue;
- }
-
- paths[info.Path] = GetPathInfo(info);
- }
- }
-
- return paths;
- }
-
- private Dictionary<string, SwaggerMethod> GetPathInfo(RestPath info)
- {
- var result = new Dictionary<string, SwaggerMethod>();
-
- foreach (var verb in info.Verbs)
- {
- var responses = new Dictionary<string, SwaggerResponse>
- {
- { "200", new SwaggerResponse { description = "OK" } }
- };
-
- var apiKeySecurity = new Dictionary<string, string[]>
- {
- { "api_key", Array.Empty<string>() }
- };
-
- result[verb.ToLowerInvariant()] = new SwaggerMethod
- {
- summary = info.Summary,
- description = info.Description,
- produces = new[] { "application/json" },
- consumes = new[] { "application/json" },
- operationId = info.RequestType.Name,
- tags = Array.Empty<string>(),
-
- parameters = Array.Empty<SwaggerParam>(),
-
- responses = responses,
-
- security = new[] { apiKeySecurity }
- };
- }
-
- return result;
- }
- }
-}
diff --git a/Jellyfin.Api/Controllers/ActivityLogController.cs b/Jellyfin.Api/Controllers/ActivityLogController.cs
index 12ea24973..a07cea9c0 100644
--- a/Jellyfin.Api/Controllers/ActivityLogController.cs
+++ b/Jellyfin.Api/Controllers/ActivityLogController.cs
@@ -13,7 +13,7 @@ namespace Jellyfin.Api.Controllers
/// <summary>
/// Activity log controller.
/// </summary>
- [Route("/System/ActivityLog")]
+ [Route("System/ActivityLog")]
[Authorize(Policy = Policies.RequiresElevation)]
public class ActivityLogController : BaseJellyfinApiController
{
diff --git a/Jellyfin.Api/Controllers/ApiKeyController.cs b/Jellyfin.Api/Controllers/ApiKeyController.cs
index fef4d7262..ccb7f47f0 100644
--- a/Jellyfin.Api/Controllers/ApiKeyController.cs
+++ b/Jellyfin.Api/Controllers/ApiKeyController.cs
@@ -15,7 +15,7 @@ namespace Jellyfin.Api.Controllers
/// <summary>
/// Authentication controller.
/// </summary>
- [Route("/Auth")]
+ [Route("Auth")]
public class ApiKeyController : BaseJellyfinApiController
{
private readonly ISessionManager _sessionManager;
diff --git a/Jellyfin.Api/Controllers/ArtistsController.cs b/Jellyfin.Api/Controllers/ArtistsController.cs
index d39021446..9d1010803 100644
--- a/Jellyfin.Api/Controllers/ArtistsController.cs
+++ b/Jellyfin.Api/Controllers/ArtistsController.cs
@@ -19,7 +19,7 @@ namespace Jellyfin.Api.Controllers
/// The artists controller.
/// </summary>
[Authorize(Policy = Policies.DefaultAuthorization)]
- [Route("/Artists")]
+ [Route("Artists")]
public class ArtistsController : BaseJellyfinApiController
{
private readonly ILibraryManager _libraryManager;
diff --git a/Jellyfin.Api/Controllers/CollectionController.cs b/Jellyfin.Api/Controllers/CollectionController.cs
index 6f78a7d84..1e8426df4 100644
--- a/Jellyfin.Api/Controllers/CollectionController.cs
+++ b/Jellyfin.Api/Controllers/CollectionController.cs
@@ -16,7 +16,7 @@ namespace Jellyfin.Api.Controllers
/// The collection controller.
/// </summary>
[Authorize(Policy = Policies.DefaultAuthorization)]
- [Route("/Collections")]
+ [Route("Collections")]
public class CollectionController : BaseJellyfinApiController
{
private readonly ICollectionManager _collectionManager;
diff --git a/Jellyfin.Api/Controllers/ItemRefreshController.cs b/Jellyfin.Api/Controllers/ItemRefreshController.cs
index 4697d869d..3f5d305c1 100644
--- a/Jellyfin.Api/Controllers/ItemRefreshController.cs
+++ b/Jellyfin.Api/Controllers/ItemRefreshController.cs
@@ -13,8 +13,7 @@ namespace Jellyfin.Api.Controllers
/// <summary>
/// Item Refresh Controller.
/// </summary>
- /// [Authenticated]
- [Route("/Items")]
+ [Route("Items")]
[Authorize(Policy = Policies.DefaultAuthorization)]
public class ItemRefreshController : BaseJellyfinApiController
{
diff --git a/Jellyfin.Api/Controllers/LibraryStructureController.cs b/Jellyfin.Api/Controllers/LibraryStructureController.cs
index 827879e0a..ca150f3f2 100644
--- a/Jellyfin.Api/Controllers/LibraryStructureController.cs
+++ b/Jellyfin.Api/Controllers/LibraryStructureController.cs
@@ -24,7 +24,7 @@ namespace Jellyfin.Api.Controllers
/// <summary>
/// The library structure controller.
/// </summary>
- [Route("/Library/VirtualFolders")]
+ [Route("Library/VirtualFolders")]
[Authorize(Policy = Policies.FirstTimeSetupOrElevated)]
public class LibraryStructureController : BaseJellyfinApiController
{
diff --git a/Jellyfin.Api/Controllers/SearchController.cs b/Jellyfin.Api/Controllers/SearchController.cs
index 2cbd32d2f..e159a9666 100644
--- a/Jellyfin.Api/Controllers/SearchController.cs
+++ b/Jellyfin.Api/Controllers/SearchController.cs
@@ -23,7 +23,7 @@ namespace Jellyfin.Api.Controllers
/// <summary>
/// Search controller.
/// </summary>
- [Route("/Search/Hints")]
+ [Route("Search/Hints")]
[Authorize(Policy = Policies.DefaultAuthorization)]
public class SearchController : BaseJellyfinApiController
{
diff --git a/Jellyfin.Api/Controllers/SystemController.cs b/Jellyfin.Api/Controllers/SystemController.cs
index e0bce3a41..6f9a75e2f 100644
--- a/Jellyfin.Api/Controllers/SystemController.cs
+++ b/Jellyfin.Api/Controllers/SystemController.cs
@@ -23,7 +23,7 @@ namespace Jellyfin.Api.Controllers
/// <summary>
/// The system controller.
/// </summary>
- [Route("/System")]
+ [Route("System")]
public class SystemController : BaseJellyfinApiController
{
private readonly IServerApplicationHost _appHost;
diff --git a/Jellyfin.Api/Controllers/TimeSyncController.cs b/Jellyfin.Api/Controllers/TimeSyncController.cs
index 57a720b26..bbabcd6e6 100644
--- a/Jellyfin.Api/Controllers/TimeSyncController.cs
+++ b/Jellyfin.Api/Controllers/TimeSyncController.cs
@@ -9,7 +9,7 @@ namespace Jellyfin.Api.Controllers
/// <summary>
/// The time sync controller.
/// </summary>
- [Route("/GetUtcTime")]
+ [Route("GetUtcTime")]
public class TimeSyncController : BaseJellyfinApiController
{
/// <summary>
diff --git a/Jellyfin.Api/Controllers/TvShowsController.cs b/Jellyfin.Api/Controllers/TvShowsController.cs
index 508b5e24e..d4560dfa2 100644
--- a/Jellyfin.Api/Controllers/TvShowsController.cs
+++ b/Jellyfin.Api/Controllers/TvShowsController.cs
@@ -22,7 +22,7 @@ namespace Jellyfin.Api.Controllers
/// <summary>
/// The tv shows controller.
/// </summary>
- [Route("/Shows")]
+ [Route("Shows")]
[Authorize(Policy = Policies.DefaultAuthorization)]
public class TvShowsController : BaseJellyfinApiController
{
diff --git a/Jellyfin.Api/Controllers/UserController.cs b/Jellyfin.Api/Controllers/UserController.cs
index ce0c9281b..482baf641 100644
--- a/Jellyfin.Api/Controllers/UserController.cs
+++ b/Jellyfin.Api/Controllers/UserController.cs
@@ -27,7 +27,7 @@ namespace Jellyfin.Api.Controllers
/// <summary>
/// User controller.
/// </summary>
- [Route("/Users")]
+ [Route("Users")]
public class UserController : BaseJellyfinApiController
{
private readonly IUserManager _userManager;