四、ABP 学习系列

摘要:
一、再XX.Web项目中用Nuget安装Swashbuckle.AspNetCore.SwaggerGen和Swashbuckle.AspNetCore.SwaggerUI二、在Startup.cs中添加如下代码publicclassStartup{publicIServiceProviderConfigureServices(IServiceCollectionservices){service

一、再XX.Web项目中用Nuget安装Swashbuckle.AspNetCore.SwaggerGen和Swashbuckle.AspNetCore.SwaggerUI

二、在Startup.cs中添加如下代码

public classStartup
    {
        publicIServiceProvider ConfigureServices(IServiceCollection services)
        {
          
            services.AddMvc(options =>{
                options.Filters.Add(newAutoValidateAntiforgeryTokenAttribute());
            });


            //// Configure CORS for angular2 UI
            //services.AddCors(
            //options => options.AddPolicy(
            //_defaultCorsPolicyName,
            //builder => builder
            //.WithOrigins(
            //                //App:CorsOrigins in appsettings.json can contain more than one address separated by comma.
            //_appConfiguration["App:CorsOrigins"]
            //.Split(",", StringSplitOptions.RemoveEmptyEntries)
            //.Select(o => o.RemovePostFix("/"))
            //.ToArray()
            //)
            //.AllowAnyHeader()
            //.AllowAnyMethod()
            //)
            //);

            //Swagger - Enable this line and the related lines in Configure method to enable swagger UI
            services.AddSwaggerGen(options =>{
                options.SwaggerDoc("v1", new Info { Title = "M API", Version = "v1"});
                options.DescribeAllEnumsAsStrings();                                        //Enum转字符串
                options.DescribeAllParametersInCamelCase();                                 //开启驼峰规则
                options.DocInclusionPredicate((docName, description) => true);              //显示备注
                options.IncludeXmlComments(GetXmlCommentsPath("XX.Web"));                  //注意:此处替换成所生成的XML documentation的文件名。
                options.IncludeXmlComments(GetXmlCommentsPath("XX.Application"));          //注意:此处替换成所生成的XML documentation的文件名。
                //Define the BearerAuth scheme that's in use
                options.AddSecurityDefinition("bearerAuth", newApiKeyScheme()
                {
                    Description = "JWT Authorization header using the Bearer scheme. Example: "Authorization: Bearer {token}"",
                    Name = "Authorization",
                    In = "header",
                    Type = "apiKey"});
                //Assign scope requirements to operations based on AuthorizeAttribute
                options.OperationFilter<SecurityRequirementsOperationFilter>();
            });

        }

        public voidConfigure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
        {

            app.UseMvc(routes =>{
                routes.MapRoute(
                    name: "default",
                    template: "{controller=Home}/{action=Index}/{id?}");
            });


            //Enable middleware to serve generated Swagger as a JSON endpoint
app.UseSwagger();
            //Enable middleware to serve swagger-ui assets (HTML, JS, CSS etc.)
            app.UseSwaggerUI(options =>{
                options.InjectOnCompleteJavaScript("/swagger/ui/abp.js");
                options.InjectOnCompleteJavaScript("/swagger/ui/on-complete.js");
                options.SwaggerEndpoint("/swagger/v1/swagger.json", "M API V1");
            }); //URL: /swagger
}

        /// <summary>
        ///获取帮助文件路径
        /// </summary>
        /// <param name="name">文件名</param>
        /// <returns></returns>
        protected string GetXmlCommentsPath(stringname)
        {
            return string.Format(@"{0}{1}.XML", AppDomain.CurrentDomain.BaseDirectory, name);
        }
    }

免责声明:文章转载自《四、ABP 学习系列》仅用于学习参考。如对内容有疑问,请及时联系本站处理。

上篇VMware安装Centos7,ens33无IP地址解决方式如何判定多边形是顺时针还是逆时针下篇

宿迁高防,2C2G15M,22元/月;香港BGP,2C5G5M,25元/月 雨云优惠码:MjYwNzM=

随便看看

IPI 通信(SMP)【转】

在MIPS架构下的IPI通信被关闭和中断后,IPIMIPS接口结构平台也将被发送_ smp_Ops{void;void;…}IPI通信是多个处理器之间的通信。send_ ipi_Single:一对一聊天send_ ipi_Mask:Mask posting,Mask表示Mask posting/*Octeon Tellanothercore of Lushi...

数据不平衡的相关

大多数常见的机器学习算法不能很好地处理不平衡的数据集。例如,搜索引擎的点击预测(点击页面往往占很小的比例)、电子商务中的产品推荐(正在购买的推荐产品的比例很低)、信用卡欺诈检测、网络攻击识别、癌症检测等。处理数据不平衡的方法主要有以下几种。2.数据级别2.1重新采样2.1.1欠采样(下采样)欠采样通过减少丰富类的大小来平衡数据集。它试图通过增加稀有样本的数量...

k8s集群上删除pod及service

删除k8s集群中的pod:找到pod的名称空间,并根据名称空间删除pod1。首先删除pod2,然后删除相应的部署。否则,删除pod是无用的。您还将看到pod,因为deployment.yaml文件中定义的副本数如下:delete the pod[root@test2~]#kubectlgetpod-njenkinsNAMEREADYSTATUSRESTART...

Python之路

Python之路引子与其感慨路难行,不如马上出发PythonPython之路(一):初识Python之路(二):基本数据类型(上)Python之路(三):基本数据类型(下)Python之路(四):函数介绍及使用Python之路(五):内置函数Python之路(六):迭代器,装饰器,生成器Python之路(七):字符串处理Python之路(八):基础模块(一)...

记一次Arcgis Server10.2许可过期导致发布图层失败

1.今天,当使用arcmap将地图服务发布到arcgisserver时,发布突然失败。在arcgisserver的管理页面的日志选项中发现错误:未能初始化服务器对象“System/PublicingTools”:0x80004005:错误:(-8003)YourArcGISServerlicense已过期。2.然后在服务器路径中查找文件:...

【转载】 银河麒麟V10系统安装U盘制作

在制作U盘安装盘的过程中,Kylin系统的ISO映像文件比较大,因此很耗时。创建完成后,“写入硬盘映像”对话框将自动关闭。...