JSON type in Dynamic Entity

This commit is contained in:
simonredfern 2025-12-08 12:14:28 +01:00
parent cc812f230f
commit eb49ea7593
4 changed files with 42 additions and 1 deletions

View File

@ -2538,6 +2538,14 @@ object ExampleValue {
| "type": "integer",
| "example": "698761728934",
| "description": "description of **number** field, can be markdown text."
| },
| "metadata": {
| "type": "json",
| "example": {
| "tags": ["important", "verified"],
| "settings": {"color": "blue", "priority": 1}
| },
| "description": "description of **metadata** field (JSON object or array), can be markdown text."
| }
| }
| }

View File

@ -2966,7 +2966,7 @@ object Glossary extends MdcLoggable {
|
|**Supported field types:**
|
|STRING, INTEGER, DOUBLE, BOOLEAN, DATE_WITH_DAY (format: yyyy-MM-dd), and reference types (foreign keys)
|STRING, INTEGER, DOUBLE, BOOLEAN, DATE_WITH_DAY (format: yyyy-MM-dd), JSON (objects and arrays), and reference types (foreign keys)
|
|**The hasPersonalEntity flag:**
|

View File

@ -2321,6 +2321,17 @@ trait APIMethods400 extends MdcLoggable {
| "summary": {
| "type": "string",
| "example": "User received 'No such price' error using Stripe API"
| },
| "custom_metadata": {
| "type": "json",
| "example": {
| "priority": "high",
| "tags": ["support", "billing"],
| "context": {
| "page": "checkout",
| "step": 3
| }
| }
| }
| }
| },
@ -2513,6 +2524,17 @@ trait APIMethods400 extends MdcLoggable {
| "summary": {
| "type": "string",
| "example": "User received 'No such price' error using Stripe API"
| },
| "custom_metadata": {
| "type": "json",
| "example": {
| "priority": "high",
| "tags": ["support", "billing"],
| "context": {
| "page": "checkout",
| "step": 3
| }
| }
| }
| }
| },

View File

@ -249,6 +249,17 @@ object DynamicEntityFieldType extends OBPEnumeration[DynamicEntityFieldType]{
override def wrongTypeMsg: String = s"the value's type should be $this, format is $dateFormat."
}
object json extends Value {
val jValueType = classOf[JValue]
override def isJValueValid(jValue: JValue): Boolean = {
jValue match {
case _: JObject => true
case _: JArray => true
case _ => false
}
}
override def wrongTypeMsg: String = "the value's type should be a JSON object or array."
}
//object array extends Value{val jValueType = classOf[JArray]}
//object `object` extends Value{val jValueType = classOf[JObject]} //TODO in the future, we consider support nested type
}