swashbuckle如何显示一个示例词典而不是其他词语?
我有一个API,我想让我感到自动为我自动化所有摇摇欲坠的文档。
我有一个端点,它返回带有字典属性的类,但是摇摇欲坠的示例包含“ fromeprop1,fropeprop2”等,而不是示例值。是否有一种方法可以使用 Simpleclass 类中指定的示例值?
班级示例的班级(这不起作用)。
public class SimpleClass
{
/// <example>"{"age":31,"height":234}"</example>
public Dictionary<string, int> DictionaryProperty { get; set; }
/// <example>The cow jumped over the moon</example>
public string someProperty { get; set; }
}
控制器的
[HttpGet]
[Route("/testexample")]
[ProducesResponseType(typeof(SimpleClass), StatusCodes.Status200OK)]
public async Task<IActionResult> TestExample()
{
return Ok();
}
I have an API and I want swashbuckle to autogenerate all the swagger documentation for me.
I have an endpoint that returns a class with a dictionary property but the swagger generated example contains "additionalProp1, additionalProp2" etc instead of example values. Is there a way to instead use example values specified in the SimpleClass class?
The class with the example for swagger (that doesn't work).
public class SimpleClass
{
/// <example>"{"age":31,"height":234}"</example>
public Dictionary<string, int> DictionaryProperty { get; set; }
/// <example>The cow jumped over the moon</example>
public string someProperty { get; set; }
}
The controller
[HttpGet]
[Route("/testexample")]
[ProducesResponseType(typeof(SimpleClass), StatusCodes.Status200OK)]
public async Task<IActionResult> TestExample()
{
return Ok();
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
取出XML
示例中的引号
值:Take out the quotes inside the XML
example
value: