c# - 当输入是原始Json时,C#如何让大摇大摆地工作?
问题描述
在 C# 中,当 API 读取原始 JSON 时,我如何让 swagger 文档工作?目前正如预期的那样,它认为 API 不接受任何输入。
我正在使用 Swashbuckle.AspNetCore nuget 包。有没有办法添加注释以显示带有类型的参数,以便生成的文件具有正确的信息?
[HttpPost]
public async Task<ActionResult<int>> Process()
{
string jsonString = await GetRequestBody();
...
}
private async Task<string> GetRequestBody()
{
string jsonString;
using (StreamReader reader = new StreamReader(Request.Body, Encoding.UTF8))
{
jsonString = await reader.ReadToEndAsync();
}
return jsonString;
}
解决方案
推荐阅读
- r - 如何计算字符“x”在“ID”列中报告的次数,并报告每行的重量度量?
- javascript - 如何调整我的翻转时钟代码以在多个实例上运行?
- flutter - 在 Flutter 中显示 Snackbar 时向上移动底部对齐的小部件
- python - pos_label=1 不是有效标签
- python - 为什么变量有效,但在 python 中使用 xlrd 打开工作簿的列表无效?
- javascript - 返回 1 或 -1 如何在 array.sort (a>b) (JS) 中工作/表示?询问methos array.sort的过程
- azure - 如何以编程方式重新启动 Azure 应用服务实例?
- javascript - 嵌套在 each() 中的函数应用于所有元素而不是单个元素
- javascript - 复制选择但小写
- python - 拟合 B 样条“围绕”点