通用类型的Json模式$ ref名称已用Swagger和OpenApi更改

问题描述

我正在将.NET Core项目从2.2升级到3.1 ...

与此同时,我还更新了Swagger版本,该版本现在基于OpenApi。我从Swagger获得的API的.json模式已更改了自定义通用类型的$ ref名称。我在很多回复中都使用了这些类型。

我不确定是否是因为OpenApi规范,或者我没有正确配置某些东西。

这是我的控制器方法的示例:

/// <summary>
/// Gets recording sets by search settings.
/// </summary>
/// <response code="200">The recording sets were returned correctly.</response>
/// <response code="401">The unauthorized access.</response>
/// <response code="406">The not acceptable format.</response>
/// <response code="415">The unsupported media type.</response>
/// <response code="500">The unexpected error.</response>
/// <param name="recordingSetSearchSettings">The search settings of the recording set.</param>
/// <returns>The found recording sets.</returns>
[HttpGet]
[ProducesResponseType(typeof(IDataPage<RecordingSet>),StatusCodes.Status200OK)]
[ProducesResponseType(typeof(void),StatusCodes.Status401Unauthorized)]
[ProducesResponseType(typeof(void),StatusCodes.Status406NotAcceptable)]
[ProducesResponseType(typeof(void),StatusCodes.Status415UnsupportedMediaType)]
[ProducesResponseType(typeof(ApiErrorSummary),StatusCodes.Status500InternalServerError)]
[SwaggerOperation(OperationId = "SearchRecordingSets")]
public IDataPage<RecordingSet> Get([FromQuery(Name = "")] RecordingSetSearchSettings recordingSetSearchSettings)
{
    return recordingSetService.Search(recordingSetSearchSettings);
}

请注意IDataPage<RecordingSet>中的ProducesResponseType

这是我在.json中的$ ref名称以前看起来像的样子:IDataPage[RecordingSet](我想维护这一点,因为我使用自定义NSwag .exe为FrontEnd生成Client方法)

.json中$ ref名称的外观如下:RecordingSetIDataPage

这是配置问题还是规范更改,所以我必须实现一些自定义方法以支持此操作?

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)