Skip to content

Commit 0e4d529

Browse files
committed
Fix HandleProperty method to support $ref references and improve array handling in JSON schema processing
1 parent 2f7da65 commit 0e4d529

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

src/iop/cls/IOP/Message.cls

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -453,7 +453,7 @@ ClassMethod HandleProperty(
453453
{
454454
Set type = value.type
455455

456-
If type = "string" || type = "number" || type = "boolean" {
456+
If (type = "string") || (type = "number") || (type = "boolean") {
457457
Do ..HandlePrimitiveType(type, idx, .pContents)
458458
}
459459
ElseIf type = "array" {
@@ -465,6 +465,13 @@ ClassMethod HandleProperty(
465465
ElseIf $IsObject(value.allOf) {
466466
Do ..HandleAllOfType(value, key, idx, .pContents, schema)
467467
}
468+
ElseIf value.%Get("$ref")'="" {
469+
Set tDef = schema."$defs".%Get($Piece(value."$ref", "/", *))
470+
Do ..HandleObjectType(tDef, idx, .pContents)
471+
}
472+
Else {
473+
Set pContents(idx,"type") = type
474+
}
468475

469476
If type = "array" Set key = key_"()"
470477
Set pContents = idx
@@ -491,9 +498,8 @@ ClassMethod HandleArrayType(
491498
schema As %DynamicObject)
492499
{
493500
Set pContents(idx,"type") = "()"
494-
If $IsObject(value.items) && $IsObject(value.items.allOf) {
495-
Do ..HandleAllOfType(value.items, key, idx, .pContents, schema)
496-
}
501+
// Handle array as a Handle Property
502+
Do ..HandleProperty(value.items, key, idx, .pContents, schema)
497503
}
498504

499505
ClassMethod HandleObjectType(
@@ -504,7 +510,7 @@ ClassMethod HandleObjectType(
504510
Set pContents(idx,"type") = "object"
505511
If $IsObject(value.properties) {
506512
Do ..SchemaToContents(value, .subContents)
507-
Merge @pContents(idx) = subContents
513+
Merge pContents(idx) = subContents
508514
}
509515
}
510516

0 commit comments

Comments
 (0)