Fix problem validating json key value pairs

This commit is contained in:
Grahame Grieve 2024-10-30 21:05:57 +10:30
parent 1850995465
commit 8a9039f08f
2 changed files with 13 additions and 2 deletions

View File

@ -163,6 +163,7 @@ public class Element extends Base implements NamedItem {
private Object nativeObject;
private List<SliceDefinition> sliceDefinitions;
private boolean elided;
private ElementDefinition valueProperty; // used to track the property value for JSON Key properties in logical models
public Element(String name) {
super();
@ -1648,4 +1649,13 @@ public class Element extends Base implements NamedItem {
public boolean isElided() {
return this.elided;
}
public ElementDefinition getValueProperty() {
return valueProperty;
}
public void setValueProperty(ElementDefinition valueProperty) {
this.valueProperty = valueProperty;
}
}

View File

@ -469,8 +469,8 @@ public class JsonParser extends ParserBase {
nKey.setPath(fpathKey);
n.getChildren().add(nKey);
nKey.setValue(pv.getName());
nKey.setValueProperty(propV.getDefinition());
boolean ok = true;
Property pvl = propV;
if (propV.isJsonPrimitiveChoice()) {
@ -573,7 +573,8 @@ public class JsonParser extends ParserBase {
n.setNull(true);
// nothing to do, it's ok, but we treat it like it doesn't exist
} else {
logError(errors, ValidationMessage.NO_RULE_DATE, line(e), col(e), npath, IssueType.INVALID, context.formatMessage(I18nConstants.THIS_PROPERTY_MUST_BE__NOT_, (property.isList() ? "an Array" : "an Object"), describe(e), name, npath), IssueSeverity.ERROR);
String msg = context.formatMessage(I18nConstants.THIS_PROPERTY_MUST_BE__NOT_, (property.isList() ? "an Array" : "an Object"), describe(e), name, npath);
logError(errors, ValidationMessage.NO_RULE_DATE, line(e), col(e), npath, IssueType.INVALID, msg, IssueSeverity.ERROR);
}
return null;
}