ฉันกำลังพยายามกำหนดสคีมาอ้างอิงเพื่อใช้เป็นประเภทแผนที่ Cassandra CQL พร้อมช่องข้อความ โดยเฉพาะฉันต้องการแมป URI กับสตริง
ตอนนี้ฉันมี:
"scope": {
"type": "object",
"properties": {
"uri": {
"type": "string",
"format": "uri"
},
"permission": {
"type": "string",
"enum": ["read_only", "read_write", "write_only"]
}
},
"required": ["uri", "permission"],
"additionalProperties": false
}
นี่เป็นสิ่งที่ดีสำหรับข้อมูลเช่น
{"uri":"http://example.com",
"permission": "read_only"}
แต่ฉันต้องการสคีมาสำหรับข้อมูลเช่น
{"http://example.com": "read_only"}
http://spacetelescope.github.io/understand-json-schema/reference/object.html มีวิธีแก้ปัญหา:
{
"type": "object",
"patternProperties": {
"^S_": { "type": "string" },
"^I_": { "type": "integer" }
}
}
ปัญหาคือฉันต้องกำหนดรูปแบบบิวท์อินด้วยนิพจน์ทั่วไป การดูตัวอย่าง regex สำหรับ URI ทำให้ฉันต้องการหลีกเลี่ยงสิ่งนี้
เนื่องจากจำนวน URI ที่ฉันมีมีจำกัด การแมป enum กับ enum จึงเป็นวิธีแก้ปัญหาเช่นกัน เป็นไปได้ไหม?