C# 可选参数导致Swashback.AspNetCore中出现null异常

C# 可选参数导致Swashback.AspNetCore中出现null异常,c#,swagger,asp.net-core-2.0,swashbuckle,api-versioning,C#,Swagger,Asp.net Core 2.0,Swashbuckle,Api Versioning,我有一个asp.net core 2.0api控制器操作,带有一个可选(且可为空)参数Swashback.AspNetCore 1.0.0当此参数出现在方法签名中时,生成Swagger文档失败,但如果我将其从签名中删除,则生成成功。看起来可选参数是错误的原因,但我不知道为什么 我正在使用Swashback与aspnet api版本控制的集成: 控制器动作: [HttpGet("{id}")] public IActionResult GetPerson(int id, [FromQuery]

我有一个
asp.net core 2.0
api控制器操作,带有一个可选(且可为空)参数
Swashback.AspNetCore 1.0.0
当此参数出现在方法签名中时,生成Swagger文档失败,但如果我将其从签名中删除,则生成成功。看起来可选参数是错误的原因,但我不知道为什么

我正在使用Swashback与aspnet api版本控制的集成:

控制器动作

[HttpGet("{id}")]
public IActionResult GetPerson(int id, [FromQuery] bool? includeContactInfo = null)
{
    var includeInfo = (includeContactInfo.HasValue && includeContactInfo.Value == true);
    var person = _repo.GetPerson(id, includeInfo);
    if (person == null)
    {
        return NotFound();
    }

    if (includeInfo)
    {
        // using AutoMapper to map between entity and dto
        var personFullDto = Mapper.Map<PersonFullDto>(person);
        return Ok(personFullDto);
    }

    var personBasicDto = Mapper.Map<PersonBasicDto>(person);
    return Ok(personBasicDto);
}
我还使用了来自的SwaggerDefaultValues.cs类

当我检查
description
对象的
includeContactInfo
可选/查询参数时,
description.RouteInfo
为空

错误消息:

Object reference not set to an instance of an object.
堆栈跟踪:

at ContactsApp.Services.SwaggerDefaultValues.Apply(Operation operation, OperationFilterContext context) in C:\Users\me\Documents\Visual Studio 2017\Projects\ContactsApp\ContactsApp\Services\SwaggerDefaultValues.cs:line 37
at Swashbuckle.AspNetCore.SwaggerGen.SwaggerGenerator.CreateOperation(ApiDescription apiDescription, ISchemaRegistry schemaRegistry)
at Swashbuckle.AspNetCore.SwaggerGen.SwaggerGenerator.CreatePathItem(IEnumerable`1 apiDescriptions, ISchemaRegistry schemaRegistry)
at System.Linq.Enumerable.ToDictionary[TSource,TKey,TElement](IEnumerable`1 source, Func`2 keySelector, Func`2 elementSelector, IEqualityComparer`1 comparer)
at Swashbuckle.AspNetCore.SwaggerGen.SwaggerGenerator.GetSwagger(String documentName, String host, String basePath, String[] schemes)
at Swashbuckle.AspNetCore.Swagger.SwaggerMiddleware.<Invoke>d__6.MoveNext()
在C:\Users\me\Documents\Visual Studio 2017\Projects\ContactsApp\ContactsApp\Services\SwaggerDefaultValues.Apply中的ContactsApp.Services.SwaggerDefaultValues.Apply(操作操作,操作过滤器上下文)中
在swashbucklk.AspNetCore.swagggergen.swagggergenerator.CreateOperation(APISHEMARegistry schemaRegistry和APISHEMARegistry schemaRegistry)
位于swashback.AspNetCore.SwaggerGen.SwaggerGenerator.CreatePathItem(IEnumerable`1 apiDescriptions,ISchemaRegistry schemaRegistry)
在System.Linq.Enumerable.ToDictionary[TSource,TKey,TElement](IEnumerable`1源,Func`2键选择器,Func`2元素选择器,IEqualityComparer`1比较器)
位于swashback.AspNetCore.SwaggerGen.SwaggerGenerator.GetSwagger(String documentName、String host、String basePath、String[]schemes)
在swashback.AspNetCore.Swagger.Swagger.d_u6.MoveNext()中

使用空条件运算符:

parameter.Default = description.RouteInfo?.DefaultValue;

使用空条件运算符:

parameter.Default = description.RouteInfo?.DefaultValue;
at ContactsApp.Services.SwaggerDefaultValues.Apply(Operation operation, OperationFilterContext context) in C:\Users\me\Documents\Visual Studio 2017\Projects\ContactsApp\ContactsApp\Services\SwaggerDefaultValues.cs:line 37
at Swashbuckle.AspNetCore.SwaggerGen.SwaggerGenerator.CreateOperation(ApiDescription apiDescription, ISchemaRegistry schemaRegistry)
at Swashbuckle.AspNetCore.SwaggerGen.SwaggerGenerator.CreatePathItem(IEnumerable`1 apiDescriptions, ISchemaRegistry schemaRegistry)
at System.Linq.Enumerable.ToDictionary[TSource,TKey,TElement](IEnumerable`1 source, Func`2 keySelector, Func`2 elementSelector, IEqualityComparer`1 comparer)
at Swashbuckle.AspNetCore.SwaggerGen.SwaggerGenerator.GetSwagger(String documentName, String host, String basePath, String[] schemes)
at Swashbuckle.AspNetCore.Swagger.SwaggerMiddleware.<Invoke>d__6.MoveNext()
parameter.Default = description.RouteInfo?.DefaultValue;