2014-11-26 20:57:16 +00:00
|
|
|
|
using MediaBrowser.Controller;
|
2013-12-07 15:52:38 +00:00
|
|
|
|
using MediaBrowser.Controller.Net;
|
2013-03-05 03:34:02 +00:00
|
|
|
|
using System.IO;
|
2016-10-25 19:02:04 +00:00
|
|
|
|
using MediaBrowser.Model.Services;
|
2013-03-05 03:34:02 +00:00
|
|
|
|
|
2013-03-07 05:34:00 +00:00
|
|
|
|
namespace MediaBrowser.Server.Implementations.HttpServer
|
2013-03-05 03:34:02 +00:00
|
|
|
|
{
|
2013-04-14 18:09:40 +00:00
|
|
|
|
public class SwaggerService : IHasResultFactory, IRestfulService
|
2013-03-05 03:34:02 +00:00
|
|
|
|
{
|
2014-11-26 20:57:16 +00:00
|
|
|
|
private readonly IServerApplicationPaths _appPaths;
|
2013-12-04 14:52:38 +00:00
|
|
|
|
|
2014-11-26 20:57:16 +00:00
|
|
|
|
public SwaggerService(IServerApplicationPaths appPaths)
|
2013-12-04 14:52:38 +00:00
|
|
|
|
{
|
|
|
|
|
_appPaths = appPaths;
|
|
|
|
|
}
|
|
|
|
|
|
2013-03-05 03:34:02 +00:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Gets the specified request.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="request">The request.</param>
|
|
|
|
|
/// <returns>System.Object.</returns>
|
|
|
|
|
public object Get(GetSwaggerResource request)
|
|
|
|
|
{
|
2014-11-26 20:57:16 +00:00
|
|
|
|
var swaggerDirectory = Path.Combine(_appPaths.ApplicationResourcesPath, "swagger-ui");
|
2013-03-05 03:34:02 +00:00
|
|
|
|
|
2013-12-05 16:50:21 +00:00
|
|
|
|
var requestedFile = Path.Combine(swaggerDirectory, request.ResourceName.Replace('/', Path.DirectorySeparatorChar));
|
2013-03-05 03:34:02 +00:00
|
|
|
|
|
2016-06-19 06:18:29 +00:00
|
|
|
|
return ResultFactory.GetStaticFileResult(Request, requestedFile).Result;
|
2013-03-05 03:34:02 +00:00
|
|
|
|
}
|
2013-03-24 02:45:00 +00:00
|
|
|
|
|
2013-04-14 18:09:40 +00:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Gets or sets the result factory.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <value>The result factory.</value>
|
|
|
|
|
public IHttpResultFactory ResultFactory { get; set; }
|
|
|
|
|
|
2013-03-24 02:45:00 +00:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Gets or sets the request context.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <value>The request context.</value>
|
2013-12-07 15:52:38 +00:00
|
|
|
|
public IRequest Request { get; set; }
|
2013-03-05 03:34:02 +00:00
|
|
|
|
}
|
|
|
|
|
}
|