|
55 | 55 | import ca.uhn.fhir.rest.api.EncodingEnum;
|
56 | 56 | import ca.uhn.fhir.util.ElementUtil;
|
57 | 57 | import ca.uhn.fhir.util.FhirTerser;
|
| 58 | +import jakarta.annotation.Nonnull; |
58 | 59 | import org.apache.commons.lang3.StringUtils;
|
59 | 60 | import org.apache.commons.lang3.Validate;
|
60 | 61 | import org.apache.commons.text.WordUtils;
|
@@ -1474,17 +1475,19 @@ private void parseExtension(ParserState<?> theState, BaseJsonLikeArray theValues
|
1474 | 1475 | int allUnderscoreNames = 0;
|
1475 | 1476 | int handledUnderscoreNames = 0;
|
1476 | 1477 |
|
| 1478 | + if (theValues == null) { |
| 1479 | + String parentElementName = getExtensionElementName(theIsModifier); |
| 1480 | + getErrorHandler() |
| 1481 | + .missingRequiredElement(new ParseLocation().setParentElementName(parentElementName), "url"); |
| 1482 | + return; |
| 1483 | + } |
| 1484 | + |
1477 | 1485 | for (int i = 0; i < theValues.size(); i++) {
|
1478 | 1486 | BaseJsonLikeObject nextExtObj = BaseJsonLikeValue.asObject(theValues.get(i));
|
1479 | 1487 | BaseJsonLikeValue jsonElement = nextExtObj.get("url");
|
1480 | 1488 | String url;
|
1481 | 1489 | if (null == jsonElement || !(jsonElement.isScalar())) {
|
1482 |
| - String parentElementName; |
1483 |
| - if (theIsModifier) { |
1484 |
| - parentElementName = "modifierExtension"; |
1485 |
| - } else { |
1486 |
| - parentElementName = "extension"; |
1487 |
| - } |
| 1490 | + String parentElementName = getExtensionElementName(theIsModifier); |
1488 | 1491 | getErrorHandler()
|
1489 | 1492 | .missingRequiredElement(new ParseLocation().setParentElementName(parentElementName), "url");
|
1490 | 1493 | url = null;
|
@@ -1553,6 +1556,17 @@ private void parseExtension(ParserState<?> theState, BaseJsonLikeArray theValues
|
1553 | 1556 | }
|
1554 | 1557 | }
|
1555 | 1558 |
|
| 1559 | + @Nonnull |
| 1560 | + private static String getExtensionElementName(boolean theIsModifier) { |
| 1561 | + String parentElementName; |
| 1562 | + if (theIsModifier) { |
| 1563 | + parentElementName = "modifierExtension"; |
| 1564 | + } else { |
| 1565 | + parentElementName = "extension"; |
| 1566 | + } |
| 1567 | + return parentElementName; |
| 1568 | + } |
| 1569 | + |
1556 | 1570 | private void parseFhirComments(BaseJsonLikeValue theObject, ParserState<?> theState) {
|
1557 | 1571 | if (isSupportsFhirComment()) {
|
1558 | 1572 | if (theObject.isArray()) {
|
|
0 commit comments