使用njsonschema,我希望生成一个模式,确保写入字典的所有值都将根据正则表达式模式进行验证。
考虑下面的类:
class File
{
[RegularExpression("^\\d+\\.\\d+\\.\\d+\\.\\d+$")]
public Dictionary<string, string> Versions { get; set; }
}我希望njsonschema生成模式部分是:
"Versions": {
"type": "object",
"additionalProperties": {
"type": "string",
"pattern": "^\\d+\\.\\d+\\.\\d+\\.\\d+$"
}
}安装后,njsonschema会生成如下内容:
"Versions": {
"type": "object",
"pattern": "^\\d+\\.\\d+\\.\\d+\\.\\d+$",
"additionalProperties": {
"type": "string"
}
}有什么办法可以解决这个问题吗?
提前感谢!
发布于 2017-08-04 13:25:37
此问题已在此提交中修复:
https://github.com/RSuter/NJsonSchema/commit/fa1b36b68bb5ad7ec005b2a77002a5668d1aa2b4
已发布带有此修复程序的NJsonSchema (v9.4.4+)版本...
https://stackoverflow.com/questions/45014613
复制相似问题