using System.Web.Http;
using LHDN.CRM.WebAPI;
using Swashbuckle.Application;
using System;
using LHDN.CRM.WebAPI.Filters;
using System.Web;

[assembly: PreApplicationStartMethod(typeof(SwaggerConfig), "Register")]

namespace LHDN.CRM.WebAPI
{
    public class SwaggerConfig
    {
        public static void Register()
        {
            var thisAssembly = typeof(SwaggerConfig).Assembly;

            GlobalConfiguration.Configuration
                .EnableSwagger(c =>
                    {
                        c.SingleApiVersion("v1", "LHDN.CRM.WebAPI");
                        c.PrettyPrint();
                        c.Schemes(new[] { "http", "https" });
                        c.IncludeXmlComments(GetXmlCommentsPath());
                        c.IncludeXmlComments(GetXmlCommentsPathForModels());
                        c.DocumentFilter<EnableSwaggerFilter>();
                    })
                .EnableSwaggerUi();
        }

        private static string GetXmlCommentsPath()
        {
            return string.Format(@"{0}\bin\LHDN.CRM.WebAPI.XML", AppDomain.CurrentDomain.BaseDirectory);
        }
        private static string GetXmlCommentsPathForModels()
        {
            return string.Format(@"{0}\bin\LHDN.CRM.Models.XML", AppDomain.CurrentDomain.BaseDirectory);
        }

    }
}
