using System.Web.Http; using WebActivatorEx; using WebAPI; using Swashbuckle.Application; [assembly: PreApplicationStartMethod(typeof(SwaggerConfig), "Register")] namespace WebAPI { public class SwaggerConfig { public static void Register() { //var thisAssembly = typeof(SwaggerConfig).Assembly; //GlobalConfiguration.Configuration // .EnableSwagger(c => // { // c.SingleApiVersion("v1", "WebAPI"); // c.MultipleApiVersions( // (apiDesc, targetApiVersion) => ResolveVersionSupportByRouteConstraint(apiDesc, targetApiVersion), // (vc) => // { // vc.Version("v2", "Swashbuckle Dummy API V2"); // vc.Version("v1", "Swashbuckle Dummy API V1"); // }); // c.BasicAuth("basic") // .Description("Basic HTTP Authentication"); // c.ApiKey("apiKey") // .Description("API Key Authentication") // .Name("apiKey") // .In("header"); // c.OAuth2("oauth2") // .Description("OAuth2 Implicit Grant") // .Flow("implicit") // .AuthorizationUrl("http://petstore.swagger.wordnik.com/api/oauth/dialog") // //.TokenUrl("https://tempuri.org/token") // .Scopes(scopes => // { // scopes.Add("read", "Read access to protected resources"); // scopes.Add("write", "Write access to protected resources"); // }); // c.IgnoreObsoleteActions(); // c.GroupActionsBy(apiDesc => apiDesc.HttpMethod.ToString()); // c.OrderActionGroupsBy(new DescendingAlphabeticComparer()); // c.MapType(() => new Schema { type = "integer", format = "int32" }); // c.SchemaFilter(); // c.IgnoreObsoleteProperties(); // c.UseFullTypeNameInSchemaIds(); // c.DescribeAllEnumsAsStrings(); // c.OperationFilter(); // c.OperationFilter(); // c.DocumentFilter(); // c.IncludeXmlComments(GetXmlCommentsPath()); // c.ResolveConflictingActions(apiDescriptions => apiDescriptions.First()); // }) // .EnableSwaggerUi(c => // { // c.InjectStylesheet(containingAssembly, "Swashbuckle.Dummy.SwaggerExtensions.testStyles1.css"); // c.InjectJavaScript(thisAssembly, "Swashbuckle.Dummy.SwaggerExtensions.testScript1.js"); // c.BooleanValues(new[] { "0", "1" }); // c.DocExpansion(DocExpansion.List); // c.CustomAsset("index", containingAssembly, "YourWebApiProject.SwaggerExtensions.index.html"); // c.EnableDiscoveryUrlSelector(); // c.EnableOAuth2Support("test-client-id", "test-realm", "Swagger UI"); // }); } } }