diff options
| author | LukePulverenti <luke.pulverenti@gmail.com> | 2013-03-04 22:34:02 -0500 |
|---|---|---|
| committer | LukePulverenti <luke.pulverenti@gmail.com> | 2013-03-04 22:34:02 -0500 |
| commit | 4c725e69a8bb96da1f69fc3d958c680b77712f81 (patch) | |
| tree | f3c401132177e5f88c029fc1400866f8e6d31737 /MediaBrowser.Common.Implementations | |
| parent | 32ba557fe5293001b6c89d522e44ee92362a6390 (diff) | |
added swagger api docs
Diffstat (limited to 'MediaBrowser.Common.Implementations')
3 files changed, 79 insertions, 14 deletions
diff --git a/MediaBrowser.Common.Implementations/HttpServer/SwaggerService.cs b/MediaBrowser.Common.Implementations/HttpServer/SwaggerService.cs new file mode 100644 index 000000000..a4808834d --- /dev/null +++ b/MediaBrowser.Common.Implementations/HttpServer/SwaggerService.cs @@ -0,0 +1,38 @@ +using ServiceStack.ServiceHost; +using System.Diagnostics; +using System.IO; + +namespace MediaBrowser.Common.Implementations.HttpServer +{ + /// <summary> + /// Class GetDashboardResource + /// </summary> + [Route("/swagger-ui/{ResourceName*}", "GET")] + public class GetSwaggerResource + { + /// <summary> + /// Gets or sets the name. + /// </summary> + /// <value>The name.</value> + public string ResourceName { get; set; } + } + + public class SwaggerService : BaseRestService + { + /// <summary> + /// Gets the specified request. + /// </summary> + /// <param name="request">The request.</param> + /// <returns>System.Object.</returns> + public object Get(GetSwaggerResource request) + { + var runningDirectory = Path.GetDirectoryName(Process.GetCurrentProcess().MainModule.FileName); + + var swaggerDirectory = Path.Combine(runningDirectory, "swagger-ui"); + + var requestedFile = Path.Combine(swaggerDirectory, request.ResourceName.Replace('/', '\\')); + + return ToStaticFileResult(requestedFile); + } + } +} diff --git a/MediaBrowser.Common.Implementations/MediaBrowser.Common.Implementations.csproj b/MediaBrowser.Common.Implementations/MediaBrowser.Common.Implementations.csproj index bbbf9490e..2f3ebdf19 100644 --- a/MediaBrowser.Common.Implementations/MediaBrowser.Common.Implementations.csproj +++ b/MediaBrowser.Common.Implementations/MediaBrowser.Common.Implementations.csproj @@ -122,6 +122,7 @@ <Compile Include="HttpServer\NativeWebSocket.cs" /> <Compile Include="HttpServer\ServerFactory.cs" /> <Compile Include="HttpServer\StreamWriter.cs" /> + <Compile Include="HttpServer\SwaggerService.cs" /> <Compile Include="Logging\LogHelper.cs" /> <Compile Include="Logging\NLogger.cs" /> <Compile Include="Logging\NlogManager.cs" /> @@ -162,22 +163,48 @@ </ItemGroup> <ItemGroup> <Content Include="README.txt" /> - <Content Include="swagger-ui\css\screen.css" /> - <Content Include="swagger-ui\images\pet_store_api.png" /> - <Content Include="swagger-ui\images\wordnik_api.png" /> + <Content Include="swagger-ui\css\screen.css"> + <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> + </Content> + <Content Include="swagger-ui\images\pet_store_api.png"> + <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> + </Content> + <Content Include="swagger-ui\images\wordnik_api.png"> + <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> + </Content> <Content Include="swagger-ui\index.html"> <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> </Content> - <Content Include="swagger-ui\lib\backbone-min.js" /> - <Content Include="swagger-ui\lib\handlebars.runtime-1.0.0.beta.6.js" /> - <Content Include="swagger-ui\lib\jquery.ba-bbq.min.js" /> - <Content Include="swagger-ui\lib\jquery.min.js" /> - <Content Include="swagger-ui\lib\jquery.slideto.min.js" /> - <Content Include="swagger-ui\lib\jquery.wiggle.min.js" /> - <Content Include="swagger-ui\lib\swagger.js" /> - <Content Include="swagger-ui\lib\underscore-min.js" /> - <Content Include="swagger-ui\swagger-ui.js" /> - <Content Include="swagger-ui\swagger-ui.min.js" /> + <Content Include="swagger-ui\lib\backbone-min.js"> + <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> + </Content> + <Content Include="swagger-ui\lib\handlebars.runtime-1.0.0.beta.6.js"> + <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> + </Content> + <Content Include="swagger-ui\lib\jquery.ba-bbq.min.js"> + <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> + </Content> + <Content Include="swagger-ui\lib\jquery.min.js"> + <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> + </Content> + <Content Include="swagger-ui\lib\jquery.slideto.min.js"> + <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> + </Content> + <Content Include="swagger-ui\lib\jquery.wiggle.min.js"> + <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> + </Content> + <Content Include="swagger-ui\lib\swagger.js"> + <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> + </Content> + <Content Include="swagger-ui\lib\underscore-min.js"> + <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> + </Content> + <Content Include="swagger-ui\swagger-ui.js"> + <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> + </Content> + <Content Include="swagger-ui\swagger-ui.min.js"> + <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> + </Content> </ItemGroup> <ItemGroup /> <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> diff --git a/MediaBrowser.Common.Implementations/swagger-ui/index.html b/MediaBrowser.Common.Implementations/swagger-ui/index.html index 5d2a8d88d..0b2b02b10 100644 --- a/MediaBrowser.Common.Implementations/swagger-ui/index.html +++ b/MediaBrowser.Common.Implementations/swagger-ui/index.html @@ -42,7 +42,7 @@ <script type="text/javascript"> $(function () { window.swaggerUi = new SwaggerUi({ - discoveryUrl:'../api/resources', + discoveryUrl:'../resources', apiKey:"", dom_id:"swagger-ui-container", supportHeaderParams: false, |
