我想摆脱swagger的模型文档中的逗号。例如:
每个属性(最后一个属性除外)都在字符串末尾用逗号描述。我怎么能摆脱它呢?我尝试了一个OperationFilter,但是逗号似乎是在晚些时候添加的(也许在UI中?)(编辑:已确认,见下文。)
如果重要的话,我正在使用带有C#项目的swashbuckle。
编辑:根据要求,提供代码示例。
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; }
}
我检查了swagger.json
文件,但它不包含屏幕截图中显示的逗号。所以他们必须来自UI代码。
如何禁用它?
谢谢!