using MediaBrowser.Common.Configuration; using MediaBrowser.Common.Net; using ServiceStack.ServiceHost; using System.IO; namespace MediaBrowser.Server.Implementations.HttpServer { /// /// Class GetDashboardResource /// [Route("/swagger-ui/{ResourceName*}", "GET")] public class GetSwaggerResource { /// /// Gets or sets the name. /// /// The name. public string ResourceName { get; set; } } public class SwaggerService : IHasResultFactory, IRestfulService { private readonly IApplicationPaths _appPaths; public SwaggerService(IApplicationPaths appPaths) { _appPaths = appPaths; } /// /// Gets the specified request. /// /// The request. /// System.Object. public object Get(GetSwaggerResource request) { var runningDirectory = Path.GetDirectoryName(_appPaths.ApplicationPath); var swaggerDirectory = Path.Combine(runningDirectory, "swagger-ui"); var requestedFile = Path.Combine(swaggerDirectory, request.ResourceName.Replace('/', '\\')); return ResultFactory.GetStaticFileResult(RequestContext, requestedFile); } /// /// Gets or sets the result factory. /// /// The result factory. public IHttpResultFactory ResultFactory { get; set; } /// /// Gets or sets the request context. /// /// The request context. public IRequestContext RequestContext { get; set; } } }