在asp.net mvc中使用了owin startup如何使用 swagger插件
SwaggerConfig.cs
public class SwaggerConfig { public static void Register(HttpConfiguration config) { var thisAssembly = typeof(SwaggerConfig).Assembly; config .EnableSwagger(c => { c.SingleApiVersion("v1", "webApi"); c.IncludeXmlComments(GetXmlCommentsPath()); c.ResolveConflictingActions(apiDescriptions => apiDescriptions.FirstOrDefault()); c.SchemaId(x => x.FullName); }) .EnableSwaggerUi(c => { }); } static string GetXmlCommentsPath() { return System.String.Format(@"{0}\bin\webApi.xml", System.AppDomain.CurrentDomain.BaseDirectory); } }
Startup.cs
public class Startup { /// <summary> /// Configures the application using the provided builder. /// </summary> /// <param name="builder">The current application builder.</param> public void Configuration(IAppBuilder builder) { //swagger SwaggerConfig.Register(configuration); }
参考:https://www.andrewhoefling.com/Blog/Post/web-api-swagger-swashbuckle