问题描述
<messageBuilders>
..
<messageBuilder contentType="application/hal+json"
class="org.wso2.carbon.integrator.core.json.JsonStreamBuilder"/>
..
</messageBuilders>
接下来我要实现:
我使用了下一篇文章:swagger-ui-web-api-documentation-present-enums-as-strings
public enum DataTypes { [Description("All")] All,Man,Woman }
[JsonConverter(typeof(StringEnumConverter))] //this is using newton
public enum DataTypes
{
[Description("All")]
All,[Description("Male222")]
Male,[Description("Female")]
Female
}
在我使用过的Enum模型中:
services.AddMvc().AddJsonoptions(options =>
options.SerializerSettings.Converters.Add(new StringEnumConverter()));
//and also services.AddSwaggerGen(c => {
c.SwaggerDoc("v1",new Info { Title = "My API",Version = "v1" });
c.DescribeAllEnumsAsstrings();
});
我看到的唯一变化是[0,1,2]和现在的[All,Male,Female] 我会错过一些设置吗?
[EnumDataType(typeof(Constans.DataTypes))]
[JsonConverter(typeof(StringEnumConverter))]
public Constans.DataTypes DataType;
并替换为:
[Description("None enum descriptiondd")]
[EnumMember(Value = "None")]
对于EnumDocumentFilter类,我使用了来自 swagger-ui-web-api-documentation-present-enums-as-strings
但是我得到了错误:
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)