报错
Could not resolve reference: Could not resolve pointer: /components/schemas/Model.RequsetModels.BPC+Details does not exist in document
我的实体类结构是如下:嵌套子层级
public class BPC
{
public string BP { get; set; }
public List<Details> Detail { get; set; }
public class Details
{
public string ML { get; set; }
public string BP { get; set; }
}
}
经排查生成Swagger Json 的时候 层级相关联的默认用的是加号 ,从而得知 Model.RequsetModels.BPC+Details 的 “+” 加号是出错,我尝试更新swagger 最新版本仍未解决
最终处理方式 加号替换成点 解决
services.AddSwaggerGen(c =>
{
c.CustomSchemaIds(s => s.FullName?.Replace(“+”, “.”));
}
参考 链接: https://stackoverflow.com/questions/73571160/could-not-resolve-pointer-components-schemas-when-nested-model-and-custom-sche
参考 链接: https://github.com/swagger-api/swagger-ui/issues/7911