zoukankan      html  css  js  c++  java
  • .net core Startup配置

    api post输入 输出 参数配置

    services.AddControllers(options =>
                {
                    options.ModelMetadataDetailsProviders.Add(new ModelBindingMetadataProvider());
                }).AddNewtonsoftJson(options =>
                {
                    //忽略循环引用
                    options.SerializerSettings.ReferenceLoopHandling = ReferenceLoopHandling.Ignore;
                    // 返回数据首字母不小写 DefaultContractResolver默认大写,CamelCasePropertyNamesContractResolver是小写
                    options.SerializerSettings.ContractResolver = new DefaultContractResolver();
                    options.SerializerSettings.DateFormatString = "yyyy-MM-dd HH:mm:ss";//设置时间格式
                })
                .AddJsonOptions(options => {
                    //让post输入参数的首字母为大写,如果不加默认为小写
                    options.JsonSerializerOptions.PropertyNamingPolicy = null;
                    //options.JsonSerializerOptions.Converters.Add(new MyCustomJsonConverter());
                });

     配置本地查看的接口路径:

    #region Swagger Api文档 第三方接口 只在开发下显示
                    app.UseSwagger();
                    app.UseSwaggerUI(c =>
                    {
                        c.SwaggerEndpoint("/swagger/V1/swagger.json", "XHS.Build.SmartCity V1");
                        c.RoutePrefix = "swagger1";//根目录后加一层访问路径,与launchsettings.json 中的launchUrl保持一致 如果是IIS发布可以注释该语句,并打开launchSettings.launchUrl
                        c.DocExpansion(Swashbuckle.AspNetCore.SwaggerUI.DocExpansion.None);//折叠Api
                    });
                    #endregion

    swagger配置:

    https://www.cnblogs.com/xbding/p/14666917.html

  • 相关阅读:
    GlusterFS安装部署
    glusterfs peer失败
    GlusterFs 启动报错
    利用idea反编译jar包
    hive 错误记录 之moveing 失败
    节点不可用,显示noReady
    kafka 配置认证与授权
    flink (2) 读取kafka数据
    Flink (1) 安装部署
    redis the cluster is down
  • 原文地址:https://www.cnblogs.com/xbding/p/14688147.html
Copyright © 2011-2022 走看看