Skip to content

Commit e44a2d4

Browse files
akoclaude
andcommitted
fix: root ExposedName must be 'Root' from JSON structure, not empty
Compared BSON before/after Studio Pro fix and found: - Root ExposedName must match JSON structure root (typically 'Root'), not empty string. Empty ExposedName causes CE5015 "Custom name does not match schema element '(Object)'" - Export value JsonPath uses original JSON key (not ExposedName) - Export object elements need CustomHandlerCall: null and ElementType from Kind field (Array for array containers) - Export Kind field set to "Array" for array elements Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 19ee7ef commit e44a2d4

File tree

3 files changed

+12
-9
lines changed

3 files changed

+12
-9
lines changed

mdl/executor/cmd_export_mappings.go

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -301,27 +301,26 @@ func buildExportMappingElementModel(moduleName string, def *ast.ExportMappingEle
301301
var jsonPath string
302302
if isRoot {
303303
jsonPath = parentPath // "(Object)"
304-
elem.ExposedName = ""
304+
elem.ExposedName = "Root" // default; overridden from JSON structure below
305305
if info, ok := jsElements[jsonPath]; ok {
306+
elem.ExposedName = info.ExposedName
306307
elem.MaxOccurs = info.MaxOccurs
307308
}
308309
elem.JsonPath = jsonPath
309310
} else {
310311
// Look up by original JSON key, then use ExposedName for the mapping's JsonPath
311312
lookupPath := parentPath + "|" + def.JsonName
313+
jsonPath = lookupPath // export JsonPath always uses original JSON key
312314
if info, ok := jsElements[lookupPath]; ok {
313315
elem.ExposedName = info.ExposedName
314316
elem.MaxOccurs = info.MaxOccurs
315-
jsonPath = parentPath + "|" + info.ExposedName
316317
if info.ElementType == "Array" {
317-
jsonPath = lookupPath // array keeps original path
318+
elem.Kind = "Array"
318319
}
319-
} else {
320-
jsonPath = lookupPath
321320
}
322321
elem.JsonPath = jsonPath
323-
// Array children use the item path
324-
if jsElements[lookupPath] != nil && jsElements[lookupPath].ElementType == "Array" {
322+
// Array children use the item path for recursion
323+
if elem.Kind == "Array" {
325324
jsonPath = lookupPath + "|(Object)"
326325
}
327326
}

mdl/executor/cmd_import_mappings.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -281,7 +281,10 @@ func buildImportMappingElementModel(moduleName string, def *ast.ImportMappingEle
281281
var jsonPath string
282282
if isRoot {
283283
jsonPath = "(Object)"
284-
elem.ExposedName = ""
284+
elem.ExposedName = "Root" // default; overridden from JSON structure below
285+
if info, ok := jsElements["(Object)"]; ok {
286+
elem.ExposedName = info.ExposedName
287+
}
285288
elem.JsonPath = jsonPath
286289
} else {
287290
// Look up by original JSON key, then use ExposedName for the mapping's JsonPath

sdk/mpr/writer_export_mapping.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,8 +141,9 @@ func serializeExportObjectElement(id string, elem *model.ExportMappingElement, p
141141
"MaxOccurs": maxOccurs,
142142
"Nillable": true,
143143
"IsDefaultType": false,
144-
"ElementType": "Object",
144+
"ElementType": elementTypeForKind(elem.Kind),
145145
"Documentation": "",
146+
"CustomHandlerCall": nil,
146147
}
147148
}
148149

0 commit comments

Comments
 (0)