Skip to content

Commit 5783ae3

Browse files
akoclaude
andcommitted
fix: JsonPath uses original JSON keys, export value MaxOccurs must be 0
- Import mapping JsonPath must use original JSON key path (not ExposedName) for both object and value elements. ExposedName is a display name that goes in the ExposedName field, not in JsonPath. - Export value element MaxOccurs changed from 1 to 0 to match JSON structure elements created by our snippet builder. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent b354224 commit 5783ae3

File tree

2 files changed

+5
-9
lines changed

2 files changed

+5
-9
lines changed

mdl/executor/cmd_import_mappings.go

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -287,17 +287,14 @@ func buildImportMappingElementModel(moduleName string, def *ast.ImportMappingEle
287287
}
288288
elem.JsonPath = jsonPath
289289
} else {
290-
// Look up by original JSON key, then use ExposedName for the mapping's JsonPath
290+
// Look up by original JSON key — JsonPath always uses original key
291291
lookupPath := parentPath + "|" + def.JsonName
292+
jsonPath = lookupPath
292293
if info, ok := jsElements[lookupPath]; ok {
293294
elem.ExposedName = info.ExposedName
294-
jsonPath = parentPath + "|" + info.ExposedName
295295
if info.ElementType == "Array" {
296296
elem.Kind = "Array"
297-
jsonPath = lookupPath // array container keeps original path
298297
}
299-
} else {
300-
jsonPath = lookupPath
301298
}
302299
elem.JsonPath = jsonPath
303300
// Array children use the item path for recursion
@@ -321,12 +318,11 @@ func buildImportMappingElementModel(moduleName string, def *ast.ImportMappingEle
321318
}
322319
elem.Attribute = attr
323320

324-
// Compute JsonPath and align ExposedName with JSON structure
325-
// Look up by original JSON key path, then use ExposedName for the mapping's JsonPath
321+
// Compute JsonPath (always original key) and align ExposedName with JSON structure
326322
lookupPath := parentPath + "|" + def.JsonName
327323
if info, ok := jsElements[lookupPath]; ok {
328324
elem.ExposedName = info.ExposedName
329-
elem.JsonPath = parentPath + "|" + info.ExposedName
325+
elem.JsonPath = lookupPath
330326
} else {
331327
elem.JsonPath = lookupPath
332328
}

sdk/mpr/writer_export_mapping.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ func serializeExportValueElement(id string, elem *model.ExportMappingElement, pa
165165
"XmlPath": "",
166166
"Type": dataType,
167167
"MinOccurs": int32(0),
168-
"MaxOccurs": int32(1),
168+
"MaxOccurs": int32(0),
169169
"Nillable": true,
170170
"IsDefaultType": false,
171171
"ElementType": "Value",

0 commit comments

Comments
 (0)