我正在尝试让Avro架构注册表强制执行enum
类型。这是我的avro架构的相关部分:
...
{
"name": "profileImageSource",
"type": {
"name": "ProfileImageSource",
"type": "enum",
"symbols" : ["BASE64", "URL", "S3"]
},
"doc": "One of three options as to how the profile image will be provided: BASE64, URL, or S3."
},
...
...但是,当我使用ValidateRecord时...它没有 - 我可以为profileImageSource
字段添加任何内容,并且它已被接受。
更新(额外信息)
Strict Type Checking
无效(无论是真还是假,结果都相同)。
如果要重现此内容,可以使用此avro架构和示例数据:
模式
{
"type": "record",
"name": "CustomerRecord",
"fields": [{
"name": "identifier",
"type": "string"
},
{
"name": "profileImageSource",
"type": {
"name": "ProfileImageSource",
"type": "enum",
"symbols" : ["BASE64", "URL", "S3"]
},
"doc": "One of three options as to how the profile image will be provided: BASE64, URL, or S3."
},
{
"name": "profileImageData",
"type": "string",
"doc": "A profile image of the customer."
}
]
}
数据
{
"identifier": "CUSTOMER-UNO",
"profileImageSource": "Cheese",
"profileImageData": "https://google.com"
}
有什么想法吗?谢谢!