在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

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章