NSwag中的自定义架构名称

时间:2019-06-03 19:16:49

标签: nswag

我已经阅读了许多文档并搜索了Internet,但是我找不到如何使用NSwag执行以下操作:

services.AddSwaggerGen(c =>
{
    c.CustomSchemaIds(type => type.FullName);
};

这取自Swashbuckle,我正在寻找NSwag中的等效物。

我想要这个,因为我有嵌套的DTO类,这些类带有编号后缀,我希望能够通过父类+实际DTO而不是编号后缀来区分这些DTO: enter image description here

using System.Collections.Generic;

namespace Blog.Api.Responses
{
    public class IndustriesResponse : List<IndustriesResponse.IndustryDto>
    {
        public class IndustryDto
        {
            public string Code { get; set; }
            public bool IsEditable { get; set; }
        }
    }
}
using System.Collections.Generic;

namespace Blog.Api.Requests
{
    public class UpdateIndustriesRequest : List<UpdateIndustriesRequest.IndustryDto>
    {
        public class IndustryDto
        {
            public string Code { get; set; }
            public bool IsEditable { get; set; }
        }
    }
}

1 个答案:

答案 0 :(得分:1)

实现自己的ISchemaNameGenerator并将其与SchemaNameGenerator设置属性一起使用