【问题标题】:NSwag - provide additional information for the expected data in a controller actionNSwag - 为控制器操作中的预期数据提供附加信息
【发布时间】:2018-09-25 18:22:02
【问题描述】:

我有一个控制器动作,它接受对象数组形式的数据(称为ControlLinePointDto 的复杂对象)。由于我的问答here 中描述的原因,我将其读入JArray 而不是ControlLinePointDto[]。我在多个地方使用不同的对象执行此操作。

如何更改文档 (NSwag) 以将其记录为(包括示例)ControlLinePointDto[],而不是 []

[HttpPost("AddPoints")]
[ProducesResponseType(typeof(List<ControlLinePointDto>), 200)]
public async Task<IActionResult> AddPoints(int ControlLineId, [FromBody] JArray pointSetJson){
}

【问题讨论】:

    标签: asp.net-core-webapi nswag


    【解决方案1】:

    您可以通过这种方式更改文档类型:

    [JsonSchemaType(typeof(MyDto[]), FromBody] JArray array
    

    https://github.com/RSuter/NJsonSchema/blob/master/src/NJsonSchema/Annotations/JsonSchemaTypeAttribute.cs#L19

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2011-01-30
      • 2019-08-17
      • 2017-09-08
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-09-14
      • 1970-01-01
      相关资源
      最近更新 更多