• ABP框架使用Swagger


    参考文档:https://www.cnblogs.com/xcsn/p/7910890.html

    步骤1:Nuget安装Swashbuckle到*.WebApi项目

    步骤2:在*.WebApi》App_Start》SwaggerConfig.cs中,把多余的注释删掉,只保留用到的。

    using System.Web.Http;
    using WebActivatorEx;
    using Framework;
    using Swashbuckle.Application;
    using System.IO;
    using System.Linq;
    
    [assembly: PreApplicationStartMethod(typeof(SwaggerConfig), "Register")]
    
    namespace Framework
    {
        public class SwaggerConfig
        {
            public static void Register()
            {
                var thisAssembly = typeof(SwaggerConfig).Assembly;
    
                GlobalConfiguration.Configuration
                    .EnableSwagger(c =>
                        {
                            c.SingleApiVersion("v1", "Framework");//这个Framework是根据项目的前缀自动生成的,改成你自己的就好了
    
                            c.IncludeXmlComments(GetXmlCommentsPath("Application"));
    
                            c.UseFullTypeNameInSchemaIds();
    
                            c.ResolveConflictingActions(apiDescriptions => apiDescriptions.First());
    
                        }).EnableSwaggerUi("apis/{*assetPath}");
            }
    
            private static string GetXmlCommentsPath(string subName)
            {
                return Directory.GetFiles(System.AppDomain.CurrentDomain.BaseDirectory + "bin\").FirstOrDefault(n => n.ToLower().EndsWith(subName.ToLower() + ".xml"));
            }
        }
    }

    步骤3:*.Application项目》右键属性》生成》输出》勾选 [XML文档文件],把路径修改一下:binFramework.Application.xml,就是把中间的 Debug去掉就好了。

    步骤4:编译解决方案,设置Web项目启动项,Ctrl+F5,地址栏:http://localhost:61814/apis/index,就可以看到结果了。

  • 相关阅读:
    83. Remove Duplicates from Sorted List
    35. Search Insert Position
    96. Unique Binary Search Trees
    94. Binary Tree Inorder Traversal
    117. Populating Next Right Pointers in Each Node II
    116. Populating Next Right Pointers in Each Node
    111. Minimum Depth of Binary Tree
    169. Majority Element
    171. Excel Sheet Column Number
    190. Reverse Bits
  • 原文地址:https://www.cnblogs.com/xsj1989/p/9870738.html
Copyright © 2020-2023  润新知