SwaggerUI 不显示模型架构
SwaggerUI not displaying Model Schema
我有一个带有 Swagger 和 Swashbuckle 的 C# Web.API 项目。
我有一个模型:
public class TimeZoneName
{
public string zoneName { get; }
}
我有一个带有方法的控制器:
public string GetLocalTimeByTimeZone(TimeZoneName timezone)
{
//Stuff Happens here
return "12:00";
}
在构建过程中,我希望 Swashbuckle 生成一个 SwaggerUI,它在 UI.
中显示 TimeZoneName 类型的 JSON 表示形式
那没有发生。
如何设置我的方法和模型,以便在 SwaggerUI 中显示模型架构?
Swashbuckle 解释 Action 名称开头的 Get 并假定您没有在请求正文中发送复杂数据。
您可以通过添加装饰器强制 Swashbuckle 将 Action 解释为 POST。
[HttpPost]
public string GetLocalTimeByTimeZone(TimeZoneName timezone)
我有一个带有 Swagger 和 Swashbuckle 的 C# Web.API 项目。
我有一个模型:
public class TimeZoneName
{
public string zoneName { get; }
}
我有一个带有方法的控制器:
public string GetLocalTimeByTimeZone(TimeZoneName timezone)
{
//Stuff Happens here
return "12:00";
}
在构建过程中,我希望 Swashbuckle 生成一个 SwaggerUI,它在 UI.
中显示 TimeZoneName 类型的 JSON 表示形式那没有发生。
如何设置我的方法和模型,以便在 SwaggerUI 中显示模型架构?
Swashbuckle 解释 Action 名称开头的 Get 并假定您没有在请求正文中发送复杂数据。
您可以通过添加装饰器强制 Swashbuckle 将 Action 解释为 POST。
[HttpPost]
public string GetLocalTimeByTimeZone(TimeZoneName timezone)