删除swagger模型文档中的所有逗号
我想去掉斯威格模型文档中的逗号。例如: 每个属性(最后一个属性除外)都在字符串末尾用逗号描述。我怎样才能摆脱它?我尝试了一个OperationFilter,但逗号似乎添加得比它晚(可能在UI中?)(编辑:已确认,见下文) 如果有关系的话,我会在C#项目中使用Swashback 编辑:根据要求,提供代码示例删除swagger模型文档中的所有逗号,swagger,swagger-ui,swashbuckle,Swagger,Swagger Ui,Swashbuckle,我想去掉斯威格模型文档中的逗号。例如: 每个属性(最后一个属性除外)都在字符串末尾用逗号描述。我怎样才能摆脱它?我尝试了一个OperationFilter,但逗号似乎添加得比它晚(可能在UI中?)(编辑:已确认,见下文) 如果有关系的话,我会在C#项目中使用Swashback 编辑:根据要求,提供代码示例 public void ConfigureServices(IServiceCollection services) { services.AddMvc(); service
public void ConfigureServices(IServiceCollection services)
{
services.AddMvc();
services.AddSwaggerGen(c =>
{
c.SwaggerDoc("v1", new Info { Title = "My API", Version = "v1" });
// "HumanReadableTypeName" is irrelevant to the question but
// selects the schema name as namespace + type name
c.CustomSchemaIds(HumanReadableTypeName);
c.DescribeAllEnumsAsStrings();
c.IncludeXmlComments(GetXmlComments);
});
}
public class ScopeResponseModel
{
/// <summary>
/// Id of the administrative scope.
/// </summary>
public string Id { get; set; }
/// <summary>
/// Name of the administrative scope.
/// </summary>
public string Name { get; set; }
/// <summary>
/// Description of the administrative scope.
/// </summary>
public string Description { get; set; }
/// <summary>
/// Whether the administrative scope is built-in.
/// </summary>
public bool IsBuiltIn { get; set; }
/// <summary>
/// Indicates the built-in "All" scope. There will be
/// exactly one scope with this property set to <c>true</c>.
/// </summary>
public bool IsAllScope { get; set; }
}
public void配置服务(IServiceCollection服务)
{
services.AddMvc();
services.AddSwaggerGen(c=>
{
c、 SwaggerDoc(“v1”,新信息{Title=“My API”,Version=“v1”});
//“HumanReadableTypeName”与问题无关,但
//选择架构名称作为命名空间+类型名称
c、 CustomSchemaAIDS(HumanReadableTypeName);
c、 descripbeAllenumsasstrings();
c、 includexmlcoments(getxmlcoments);
});
}
公共类ScopeResponseModel
{
///
///管理范围的Id。
///
公共字符串Id{get;set;}
///
///管理范围的名称。
///
公共字符串名称{get;set;}
///
///管理范围的说明。
///
公共字符串说明{get;set;}
///
///管理范围是否内置。
///
公共布尔是内置的{get;set;}
///
///指示内置的“全部”作用域。将有
///只有一个作用域的此属性设置为true。
///
公共bool IsAllScope{get;set;}
}
我检查了swagger.json
文件,它不包含屏幕截图中出现的逗号。因此,它们一定来自UI代码
我怎样才能禁用它
谢谢 您能提供您的代码示例吗?@HelderSepu代码段包含在上面;然而,我相信我已经确认逗号来自我没有以任何方式定制的招摇过市代码。我正在尝试复制它。。。你使用的是什么版本的Swashback?你的模型在最新版本的SwaggerUI上看起来不错:我从SwaggerUI转到Redoc,它没有问题。但是我刚刚检查了@HelderSepulveda是正确的,最新版本的SwaggerUI似乎呈现出不同的效果,所以没有问题。