nswagstudio - 更改 NSwagStudio 序列化设置以允许 Nulls
问题描述
有没有办法更改 NSwagStudio 中的设置,以便当 JSON 序列化设置输出为Newtonsoft.Json.Required.AllowNull
而不是Newtonsoft.Json.Required.Always
?
我目前手动更改了属性以允许空值。
[Newtonsoft.Json.JsonProperty("returnCode", Required = Newtonsoft.Json.Required.Always)]
public int ReturnCode { get; set; }
我需要它是:
[Newtonsoft.Json.JsonProperty("returnCode", Required = Newtonsoft.Json.Required.AllowNull)]
public int ReturnCode { get; set; }
解决方案
如果它在 API 规范中不可为空,则它在生成的代码中也不能为空
API 规范示例:
ReturnCode:
type: integer
nullable: true
推荐阅读
- dynamics-crm - 从客户子网格添加新机会会自动填充机会上的每个客户查找
- c# - 如何将 Json 原始对象或属性转换为特定模型?
- android - 如何从通知中获取链接并通过firebase在mainactivity webview中打开?
- r - R中的Forestplot。如何添加箭头、x轴中断和扩展x轴?
- django - 从 Pycharm 和 Django 将网站发布到 Raspberry Pi 3
- mysql - mysql选择匹配1个条件或另一个的记录
- java - Linux top 命令 CPU 使用率
- python - 如何在其调用方法中定义带有布尔参数的自定义 keras 层?
- python - 在 Python 中搜索关键字,然后返回关键字
- c# - 使用子集合项的 Automapper 展平